对页面 新增 修改 删除等按钮进行隐藏,添加自定义按钮 ``` cruds() { return CRUD({ title: '出库明细', url: 'api/pickDetail', idField: 'id', sort: 'id,desc', crudMethod: {...crudPickDetail}, optShow: { add: true, edit: false, del: false, reset: true, download: true } }) } ``` 添加自定义按钮 [:disabled="show_fp” ]()为显示状态 [@click="allocate(crud.selections)"]() 为点击时间 [crud.selections]() 选中的数据 ``` 分配 ``` ``` data() { return { show_fp: true, show_jh: true, show_cancelfp:true, radio3: '全部', items: [], permission: { add: ['admin', 'pickDetail:add'], edit: ['admin', 'pickDetail:edit'], del: ['admin', 'pickDetail:del'] }, rules: { item: [ {required: true, message: '物料必填', trigger: 'blur'} ] }, queryTypeOptions: [ {key: 'itemCode', display_name: '物料编码'}, {key: 'itemName', display_name: '物料名称'}, {key: 'po', display_name: '任务号'}, {key: 'status', display_name: '状态'} ] } } ``` ``` allocate(datas) { this.$confirm(`选中的${datas.length}条数据分配确认?`, '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(() => { const ids = []; for (let i = 0; i < datas.length; i++) { ids.push(datas[i].id) } crudPickDetail.allocate(ids).then(res => { DonMessage.success('分配成功!') this.crud.toQuery(); }).catch(() => { }) }).catch(() => { this.$refs.table.clearSelection() DonMessage.info('取消成功!') }); } ``` 修改选择框选中事件 [@selection-change="selectionChangeHandlerTwo"]() ``` ``` 根据选择的数据进行判断,新加的按钮是否可用 ``` selectionChangeHandlerTwo(val) { this.crud.selections = val if (this.crud.selections.length > 1 || this.crud.selections.length == 0) { this.show_jh = true; this.show_fp = true; this.show_cancelfp=true; } //分配 if (this.crud.selections.length == 1 && this.crud.selections[0].orderQty > this.crud.selections[0].allocatedQty) { this.show_jh = true; this.show_fp = false; } //取消分配 if (this.crud.selections.length == 1 && this.crud.selections[0].orderQty == this.crud.selections[0].allocatedQty&&this.crud.selections[0].pickedQty==0) { this.show_jh = true; this.show_fp = true; this.show_cancelfp=false; } //拣货 if (this.crud.selections.length == 1 && this.crud.selections[0].orderQty == this.crud.selections[0].allocatedQty) { this.show_jh = false; this.show_fp = true; } } ``` 完整代码,请查看 /views/business-data/asnDetial/index ``` 全部 打开 已分配 拣货完成 分配 取消分配 拣货确认 {{ scope.row.item.code }} {{ scope.row.item.name }} {{ dict.label.pick_status[scope.row.status] }} ```