<template> <div class="formActBtn"> <template v-if="activities"> <template v-if="activities.length == 1"> <!-- 褰撲负1涓寜閽椂 --> <mt-button :class="[priorityBtn[0] && priorityBtn[0].type == 3?'delBtn':'']" type="primary" :disabled="priorityBtn[0]?priorityBtn[0].readonly:''" @click="onClick(priorityBtn[0])" > <i v-if="priorityBtn[0] && priorityBtn[0].icon && JSON.parse(priorityBtn[0].icon).type == 'font'" :class="JSON.parse(priorityBtn[0].icon).icon" /> <img class="btn-img" v-if="priorityBtn[0] && priorityBtn[0].icon && JSON.parse(priorityBtn[0].icon).type == 'img'" :src="priorityBtn[0] && priorityBtn[0].icon ? $Constant.contextPath + '/uploads/lib/icon' + JSON.parse(priorityBtn[0].icon).icon : ''"/> <span>{{priorityBtn[0] ? priorityBtn[0].name : ''}}</span> </mt-button> </template> <template v-else-if="activities.length == 2"> <!-- 褰撲负2涓寜閽椂 --> <mt-button v-for="(act, i) in priorityBtn" :key = i type="primary" :plain="i>0?true:false" :class="[act.type == 3?'delBtn':'','ml-1']" :disabled="act.readonly" @click="onClick(act)" > <i v-if="act.icon && JSON.parse(act.icon).type == 'font'" :class="JSON.parse(act.icon).icon" /> <img class="btn-img" v-if="act.icon && JSON.parse(act.icon).type == 'img'" :src="$Constant.contextPath + '/uploads/lib/icon' + JSON.parse(act.icon).icon"/> <span>{{act.name}}</span> </mt-button> </template> <template v-else-if="activities.length == 3"> <!-- 褰撲负3涓寜閽椂 --> <mt-button v-for="(act, i) in priorityBtn" :key = i type="primary" :plain="i>0?true:false" :class="[act.type == 3?'delBtn':'', 'ml-1']" :disabled="act.readonly" @click="onClick(act)" > <i v-if="act.icon && JSON.parse(act.icon).type == 'font'" :class="JSON.parse(act.icon).icon" /> <img class="btn-img" v-if="act.icon && JSON.parse(act.icon).type == 'img'" :src="$Constant.contextPath + '/uploads/lib/icon' + JSON.parse(act.icon).icon"/> <span>{{act.name}}</span> </mt-button> </template> <template v-if="activities.length > 3"> <!-- 褰撲负3涓互涓婃寜閽椂 --> <mt-button :class="[activities[0].type == 3?'moreDelBtn':'', 'ml-1']" type="primary" :disabled="activities[0].readonly" @click="onClick(activities[0])" > <i v-if="activities[0].icon && JSON.parse(activities[0].icon).type == 'font'" :class="JSON.parse(activities[0].icon).icon" /> <img class="btn-img" v-if="activities[0].icon && JSON.parse(activities[0].icon).type == 'img'" :src="$Constant.contextPath + '/uploads/lib/icon' + JSON.parse(activities[0].icon).icon"/> <span>{{activities[0].name}}</span> </mt-button> <mt-button :class="[activities[1].type == 3?'moreDelBtn':'', 'ml-1']" type="primary" :disabled="activities[1].readonly" @click="onClick(activities[1])" > <i v-if="activities[1].icon && JSON.parse(activities[1].icon).type == 'font'" :class="JSON.parse(activities[1].icon).icon" /> <img class="btn-img" v-if="activities[1].icon && JSON.parse(activities[1].icon).type == 'img'" :src="$Constant.contextPath + '/uploads/lib/icon' + JSON.parse(activities[1].icon).icon"/> <span>{{activities[1].name}}</span> </mt-button> <mt-button type="primary" @click.stop plain @click="onBtnMoreClick" >{{$t('more')}}</mt-button> <div v-show="showMoreBtns" > <div class="moreBtn-popup"> <template v-for="(act,i) in activities"> <a v-if="i >1" :key="act.id + act.name" class="btn-pop" @click="onClick(act)"> <i v-if="act.icon && JSON.parse(act.icon).type == 'font'" :class="JSON.parse(act.icon).icon" /> <img class="btn-img" v-if="act.icon && JSON.parse(act.icon).type == 'img'" :src="$Constant.contextPath + '/uploads/lib/icon' + JSON.parse(act.icon).icon"/> <span>{{act.name}}</span> </a> </template> <div v-show="showMoreBtns" class="border-down-empty"> <span></span> </div> </div> </div> </template> </template> </div> </template> <script> export default { props: [ "activities", "math", "viewType", "viewPage" ], data: function() { return { priorityBtn:[], showMoreBtns: false, }; }, watch: { activities() { this.hideSomeButtons(); }, math(){ this.mathRom(); } }, mounted() { this.setViewPageBtn(); }, methods: { //璁剧疆瑙嗗浘鐨勬柊寤猴紙2锛夈€佸垹闄わ紙3锛夋寜閽紭鍏堟樉绀� setViewPageBtn() { if(this.viewPage) { if(this.activities) { let actArr = JSON.parse(JSON.stringify(this.activities)); let priorityBtn = []; for(let j=0; j<actArr.length; j++) { if(actArr[j].type == 2) { priorityBtn.unshift(actArr[j]); actArr.splice(j, 1); j--; }else if(actArr[j].type == 3) { priorityBtn.push(actArr[j]); actArr.splice(j, 1); j--; } } if(priorityBtn.length > 0) { priorityBtn = priorityBtn.concat(actArr); }else { priorityBtn = actArr; } this.priorityBtn = priorityBtn; } } }, hideSomeButtons() { if(this.activities) { for (var i = 0; i < this.activities.length; i++) { if ( this.activities[i].type == 8 || //鍏抽棴绐楀彛 //this.activities[i].type == 20 || //鎵归噺鎻愪氦 鏆傛椂鍏堝睆钄� //this.activities[i].type == 13 || //鍙戦€佸井淇℃秷鎭�(鍙戦€侀偖浠�) this.activities[i].type == 14 || //缃戦〉鎵撳嵃 this.activities[i].type == 15 || //鎵撳嵃鍖呭惈娴佺▼鍘嗗彶 this.activities[i].type == 16 || //excel瀵煎嚭 this.activities[i].type == 25 || //PDF瀵煎嚭 this.activities[i].type == 26 || //鏂囦欢涓嬭浇 this.activities[i].type == 27 || //excel瀵煎叆 this.activities[i].type == 30 || //鑷畾涔夋墦鍗� // this.activities[i].type == 33 || //娴佺▼鍚姩 this.activities[i].type == 36 || //缃戦〉鎵撳嵃 // this.activities[i].type == 43 || //璺宠浆 this.activities[i].type == 46 //绛剧珷 // this.activities[i].type == 1 //鍒锋柊 ) { //鏂囦欢涓嬭浇 this.activities.splice(i, 1); i--; } } if(this.activities) { //娴佺▼澶勭悊锛堟彁浜わ級5銆佽繑鍥�10 let actArr = JSON.parse(JSON.stringify(this.activities)); let priorityBtn = []; for(let j=0; j<actArr.length; j++) { if(actArr[j].type == 5) { priorityBtn.unshift(actArr[j]); actArr.splice(j, 1); j--; }else if(actArr[j].type == 10) { priorityBtn.push(actArr[j]); actArr.splice(j, 1); j--; } } if(priorityBtn.length > 0) { priorityBtn = priorityBtn.concat(actArr); }else { priorityBtn = actArr; } this.priorityBtn = priorityBtn; } } }, mathRom(){ if(this.math){ this.showMoreBtns = false; } }, onBtnMoreClick() { this.showMoreBtns = !this.showMoreBtns; }, onClick(act) { if(!act.readonly) { this.onAction(act); } }, onAction(act) { let activityType = act.type; switch (act.type) { case 1: //杞藉叆瑙嗗浘 this.$emit("action",act); break; case 2: //鍒涘缓 this.$emit("action",act); // this.$parent.doCreate(act); break; case 3: //鍒犻櫎 this.$emit("action",act); break; case 4: //淇濆瓨骞跺惎鍔ㄦ祦绋� act.flowType = '1'; this.$emit("action",act); break; case 5: //娴佺▼澶勭悊 act.flowType = '80'; this.$emit("action",act); break; case 8: //鍏抽棴绐楀彛 this.$parent.runBeforeAction(act.id, "", "", activityType); break; case 10: //杩斿洖 //this.$parent.$parent.doBack(); this.$emit("action",act); //this.$parent.goBack(); break; case 11: //淇濆瓨骞惰繑鍥� this.$parent.runBeforeAction(act.id, "", "", activityType,act); break; case 13: //鏃� this.$emit("action",act); break; case 14: //缃戦〉鎵撳嵃(琛ㄥ崟) this.$parent.runBeforeAction(act.id, "", "", activityType); break; case 15: //缃戦〉鎵撳嵃鍚巻鍙� this.$parent.runBeforeAction(act.id, "", "", activityType); break; case 16: //瀵煎嚭excel break; case 19: //淇濆瓨鑽夌ǹ涓嶆牎妫€ //this.$parent.saveDraft(); this.$parent.runBeforeAction(act.id, "", "", activityType); break; case 18: //娓呯┖鎵€鏈夋暟鎹� this.$emit("action",act); break; case 20: //鎵归噺鎻愪氦 act.flowType = '80'; this.$emit("action",act); break; case 21: //淇濆瓨骞跺鍒� this.$parent.runBeforeAction(act.id, "", "", activityType); break; case 25: //PDF瀵煎嚭 this.$parent.runBeforeAction(act.id, "", "", activityType); break; case 26: //鏂囦欢涓嬭浇 this.$parent.runBeforeAction(act.id, "", "", activityType); break; case 27: //瀵煎叆excel break; case 28: //鐢靛瓙绛剧珷 this.$emit("action",act); break; case 29: //鎵归噺绛剧珷 break; case 33: //娴佺▼鍚姩 act.flowType = '1'; this.$emit("action",act); break; case 34: //淇濆瓨 //this.$parent.doSave(); // this.$parent.runBeforeAction(act.id, "", "", activityType); this.$emit("action",act); break; case 36: //缃戦〉鎵撳嵃(瑙嗗浘) break; case 37: //閭欢鐭俊鍒嗕韩 break; case 42: //淇濆瓨骞舵柊寤� this.$parent.runBeforeAction(act.id, "", "", activityType); break; case 43: //璺宠浆 this.$emit("action",act); break; case 45: //褰掓。 this.$parent.runBeforeAction(act.id, "", "", activityType); break; case 46: //绛剧珷 break; case 47: //鍥為€€娴佺▼ this.$emit("action",act); break; case 48: //鍌姙娴佺▼ this.$emit("action",act); break; case 49: //鎸傝捣娴佺▼ act.flowType = '88'; this.$emit("action", act); break; case 50: //鎭㈠娴佺▼ act.flowType = '89'; this.$emit("action", act); break; case 51: //鍥炴挙娴佺▼ act.flowType = '85'; this.$emit("action", act); break; case 52: //缁堟娴佺▼ act.flowType = '8'; this.$emit("action", act); break; case 53: //缂栬緫娴佺▼瀹℃壒浜� this.$emit("action", act); break; case 54: //璋冩暣娴佺▼ break; case 55: //鐐硅瘎 this.$emit("action", act); break; case 56: //琛ョ this.$emit("action", act); break; case 57: //鍔犵涓诲姙 this.$emit("action", act); break; case 58: //鍔犵鍗忓姙 this.$emit("action", act); break; default: break; } } } }; </script>