diff --git a/src/components/action_button/index.vue b/src/components/action_button/index.vue index be2be56e6f7c1b75fc3523bd6f96b1cea326d3d6..818e4ca63f604b216da9d72984a142a1ad1f7173 100644 --- a/src/components/action_button/index.vue +++ b/src/components/action_button/index.vue @@ -50,20 +50,38 @@ export default { }, row: Object, }, + watch: { + row() { + this.init(); + }, + }, + data() { + return { + buttonsArr: [], + }; + }, + created() { + this.init(); + }, computed: { basicBtns() { - return this.buttons.length > 3 ? this.buttons.slice(0, 3) : this.buttons; + return this.buttonsArr.length > 3 ? this.buttonsArr.slice(0, 3) : this.buttonsArr; }, moreBtns() { - return this.buttons.length > 3 ? this.buttons.slice(3) : []; + return this.buttonsArr.length > 3 ? this.buttonsArr.slice(3) : []; }, }, - methods: { getDelUrl(url, row) { if (isFunction(url)) return url(row); return url; }, + init() { + this.buttons.map((i) => { + i.__hidden__ = i.isHidden && i.isHidden(this.row); + }); + this.buttonsArr = this.buttons.filter((i) => !i.__hidden__); + }, }, }; diff --git a/src/components/popconfirm_delete/index.vue b/src/components/popconfirm_delete/index.vue index 89b6993b115a4fa6696125098cd24c90b8584205..b478ee47a84c2b5da9761425088d361a5cacfe9d 100644 --- a/src/components/popconfirm_delete/index.vue +++ b/src/components/popconfirm_delete/index.vue @@ -6,11 +6,11 @@