|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
|
<div class="myDiv">
|
|
|
- <el-dropdown trigger="click" :hide-on-click="false">
|
|
|
+ <el-dropdown trigger="click" v-if="btnObj" :hide-on-click="false">
|
|
|
<span class="el-dropdown-link">
|
|
|
<el-button v-if="btnObj.btnParentId == 0" type="warning"
|
|
|
><span
|
|
@@ -11,7 +11,7 @@
|
|
|
:icon-class="btnObj.btnIcon" />{{ btnObj.btnName }}
|
|
|
<i class="el-icon-arrow-down el-icon--right"></i></span
|
|
|
></el-button>
|
|
|
- <span v-else>
|
|
|
+ <el-button v-else>
|
|
|
<span
|
|
|
><svg-icon
|
|
|
class="pre-icon"
|
|
@@ -20,7 +20,7 @@
|
|
|
:icon-class="btnObj.btnIcon" />{{ btnObj.btnName }}
|
|
|
<i class="el-icon-arrow-down el-icon--right"></i
|
|
|
></span>
|
|
|
- </span>
|
|
|
+ </el-button>
|
|
|
</span>
|
|
|
<el-dropdown-menu slot="dropdown">
|
|
|
<template v-for="item in btnObj.children">
|
|
@@ -57,10 +57,44 @@ export default {
|
|
|
},
|
|
|
computed: {
|
|
|
btnObj() {
|
|
|
- return this.listAll;
|
|
|
+ let btnObj = JSON.parse(JSON.stringify(this.listAll));
|
|
|
+ let rootRes = this.isHiddenBtn(this.row, btnObj.btnShowCondition);
|
|
|
+ if (rootRes) return null;
|
|
|
+ btnObj.children = btnObj.children.filter((item) => {
|
|
|
+ return !this.isHiddenBtn(this.row, item.btnShowCondition);
|
|
|
+ });
|
|
|
+ console.log("btnObj", btnObj);
|
|
|
+ return btnObj;
|
|
|
},
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 判断按钮是否隐藏
|
|
|
+ isHiddenBtn(row, condition) {
|
|
|
+ if (condition.length == 0) return false;
|
|
|
+ let con = JSON.parse(condition);
|
|
|
+ let res = con.every((item) => {
|
|
|
+ return !this.judgeBtnHandler(row, item);
|
|
|
+ });
|
|
|
+ return res;
|
|
|
+ },
|
|
|
+ judgeBtnHandler(row, con) {
|
|
|
+ let { fieldName, refValue, mark } = con;
|
|
|
+ console.log(row[fieldName], mark, refValue);
|
|
|
+ switch (mark) {
|
|
|
+ case ">":
|
|
|
+ return row[fieldName] > refValue;
|
|
|
+ case "<":
|
|
|
+ return row[fieldName] < refValue;
|
|
|
+ case "=":
|
|
|
+ return row[fieldName] == refValue;
|
|
|
+ case ">=":
|
|
|
+ return row[fieldName] >= refValue;
|
|
|
+ case "<=":
|
|
|
+ return row[fieldName] <= refValue;
|
|
|
+ default:
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ },
|
|
|
clickHandler(btnData, row) {
|
|
|
this.$emit("excuteHandler", btnData, row);
|
|
|
},
|