import { postDelete, processRequest, getDetailed, postExportForDetail, fileStorage } from '@/api/wms-api' import { accept, close, cancel, cancelAccept, open } from '@/api/wms-job' export const drawerMixins = { data() { return { //抽屉按钮多选数据 dropdownData: { dropdown1: { command: "delete", label: "删除", }, }, //抽屉传入参数 propsData: {}, } }, methods: { //关闭抽屉 closeValue(val) { this.displayDialog.detailsDialog = val; }, //抽屉常用按钮 drawerbutton(val, that) { if (!that) { that = this } if (val == "edit") { this.formTitle = this.$route.meta.title + "编辑"; this.formReveal = false this.theEvent = "edit" const listAssign = (arr1, arr2) => { Object.keys(arr1).forEach(item => { arr1[item] = arr2[item] }) } listAssign(this.editFormData, this.propsData) if(this.$route.name == 'CustomerItem'){ this.editFormData.beginTime = new Date(this.propsData.beginTime) this.editFormData.endTime = new Date(this.propsData.endTime) } // this.$listAssign(this.editFormData, this.propsData) this.displayDialog.editDialog = true } // 申请业务 流程按钮实现 if (val == 'submitRequest') { that.Loading.appMainLoading = true processRequest(that.propsData.id, that.URL + '/submit/').then(res => { that.$successMsg('已提交') getDetailed(that.propsData.id, that.URL).then(res => { that.propsData = res }) that.paging() that.Loading.appMainLoading = false }).catch(err => { console.log(err) that.Loading.appMainLoading = false }) } else if (val == 'agreeRequest') { that.Loading.appMainLoading = true processRequest(that.propsData.id, that.URL + '/agree/').then(res => { that.$successMsg('已同意') getDetailed(that.propsData.id, that.URL).then(res => { that.propsData = res }) that.paging() that.Loading.appMainLoading = false }).catch(err => { console.log(err) that.Loading.appMainLoading = false }) } else if (val == 'handleRequest') { that.Loading.appMainLoading = true processRequest(that.propsData.id, that.URL + '/handle/').then(res => { that.$successMsg('处理完成') getDetailed(that.propsData.id, that.URL).then(res => { that.propsData = res }) that.paging() that.Loading.appMainLoading = false }).catch(err => { console.log(err) that.Loading.appMainLoading = false }) } else if (val == 'againHandleRequest') { // 针对部分完成情况下,再次执行任务操作 that.Loading.appMainLoading = true processRequest(that.propsData.id, that.URL + '/handle/').then(res => { that.$successMsg('执行成功') getDetailed(that.propsData.id, that.URL).then(res => { that.propsData = res }) that.paging() that.Loading.appMainLoading = false }).catch(err => { console.log(err) that.Loading.appMainLoading = false }) } else if (val == 'abortRequest') { that.Loading.appMainLoading = true processRequest(that.propsData.id, that.URL + '/abort/').then(res => { that.$successMsg('已中止') getDetailed(that.propsData.id, that.URL).then(res => { that.propsData = res }) that.paging() that.Loading.appMainLoading = false }).catch(err => { console.log(err) that.Loading.appMainLoading = false }) } else if (val == 'completeRequest') { that.Loading.appMainLoading = true processRequest(that.propsData.id, that.URL + '/complete/').then(res => { that.$successMsg('执行完成') getDetailed(that.propsData.id, that.URL).then(res => { that.propsData = res }) that.paging() that.Loading.appMainLoading = false }).catch(err => { console.log(err) that.Loading.appMainLoading = false }) } else if (val == 'cancelRequest') { that.Loading.appMainLoading = true processRequest(that.propsData.id, that.URL + '/cancel/').then(res => { that.$successMsg('已取消') getDetailed(that.propsData.id, that.URL).then(res => { that.propsData = res }) that.paging() that.Loading.appMainLoading = false }).catch(err => { console.log(err) that.Loading.appMainLoading = false }) } else if (val == 'refuseRequest') { that.Loading.appMainLoading = true processRequest(that.propsData.id, that.URL + '/refuse/').then(res => { that.$successMsg('已驳回') getDetailed(that.propsData.id, that.URL).then(res => { that.propsData = res }) that.paging() that.Loading.appMainLoading = false }).catch(err => { console.log(err) that.Loading.appMainLoading = false }) } // 任务 流程按钮实现 if (val == 'acceptJob') { that.Loading.appMainLoading = true accept(that.URL, {id: that.propsData.id}).then(res => { that.$successMsg('已接任务') that.Loading.appMainLoading = false getDetailed(that.propsData.id, that.URL).then(res => { that.propsData = res }) that.paging(); }).catch(err => { that.Loading.appMainLoading = false }) } else if(val == 'closeJob'){ that.Loading.appMainLoading = true close(that.URL, {id: that.propsData.id}).then(res => { that.$successMsg('已关闭任务') that.Loading.appMainLoading = false getDetailed(that.propsData.id, that.URL).then(res => { that.propsData = res }) that.paging(); }).catch(err => { that.Loading.appMainLoading = false }) } else if(val == 'invalidJob'){ that.Loading.appMainLoading = true cancel(that.URL, {id: that.propsData.id}).then(res => { that.$successMsg('已作废任务') that.Loading.appMainLoading = false getDetailed(that.propsData.id, that.URL).then(res => { that.propsData = res }) that.paging(); }).catch(err => { that.Loading.appMainLoading = false }) } else if(val == 'cancelAcceptJob'){ that.Loading.appMainLoading = true cancelAccept(that.URL, {id: that.propsData.id}).then(res => { that.$successMsg('已取消接受任务') that.Loading.appMainLoading = false getDetailed(that.propsData.id, that.URL).then(res => { that.propsData = res }) that.paging(); }).catch(err => { that.Loading.appMainLoading = false }) } else if(val == 'openJob'){ that.Loading.appMainLoading = true open(that.URL, {id: that.propsData.id}).then(res => { that.$successMsg('已打开任务') that.Loading.appMainLoading = false getDetailed(that.propsData.id, that.URL).then(res => { that.propsData = res }) that.paging(); }).catch(err => { that.Loading.appMainLoading = false }) } else if(val == 'handleJob'){ // 请在主页写相关执行任务操作代码 console.log('请在主页写相关执行任务操作代码') } }, //抽屉下拉按钮操作 async drawerHandle(val) { if (val == 'delete') { this.$confirm('此操作将永久删除该消息, 是否继续?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(() => { this.Loading.appMainLoading = true // this.Loading.tableLoading = true this.displayDialog.detailsDialog = false postDelete(this.propsData.id, this.URL).then(res => { this.$successMsg('删除成功!') this.Loading.appMainLoading = false this.paging() }).catch(err => { this.Loading.appMainLoading = false // this.Loading.tableLoading = false }) }).catch(() => { this.Loading.appMainLoading = false }); } else if (val == 'print') { this.Loading.appMainLoading = true // this.Print(this.printData(this.propsData)).then(resolve=>{ this.Print(this.printData(this.tableDataDetails)).then(resolve=>{ this.Loading.appMainLoading = false },reject=>{ this.Loading.appMainLoading = false }).catch(() => { this.Loading.appMainLoading = false }); } else if (val == 'tuoPrint') { this.Loading.appMainLoading = true // let obj = await this.tuoPrintData(this.propsData) let obj = await this.tuoPrintData(this.tableDataDetails) this.Print(obj).then(resolve=>{ this.Loading.appMainLoading = false },reject=>{ this.Loading.appMainLoading = false }).catch(() => { this.Loading.appMainLoading = false }); } else if (val == 'xbqPrint') { this.Loading.appMainLoading = true // let obj = await this.xbqPrintData(this.propsData) let obj = await this.xbqPrintData(this.tableDataDetails) this.Print(obj).then(resolve=>{ this.Loading.appMainLoading = false },reject=>{ this.Loading.appMainLoading = false }).catch(() => { this.Loading.appMainLoading = false }); } }, // 导出 exportForDetailHandle(that,url,params){ if (!that) { that = this } let PageListParams = {} that.Loading.appMainLoading = true PageListParams.company = window.SITE_CONFIG['company'] PageListParams.function = that.$route.meta.title PageListParams.route = url; postExportForDetail(PageListParams,url,params).then(res => { this.blob(res, this.$route.meta.title )//使用前端导出名称 // fileStorage({blobName: res.blobName}).then( fileStorageRes => { // that.downloadFile(fileStorageRes.bytes, fileStorageRes.fileName) // }).catch( err => { // console.log(err) // }) that.Loading.appMainLoading = false }).catch(err => { that.Loading.appMainLoading = false }) } } }