diff --git a/src/api/yh/report.js b/src/api/yh/report.js index 7e4e4fc..47a9067 100644 --- a/src/api/yh/report.js +++ b/src/api/yh/report.js @@ -19,20 +19,26 @@ export function getReport(reportId, params = {}) { } // 新增报表 -export function addReport(data) { +export function addReport(data, submit) { return request({ url: '/yh/report', method: 'post', - data: data + data: data, + params: { + submit + } }) } // 修改报表 -export function updateReport(data) { +export function updateReport(data, submit) { return request({ url: '/yh/report', method: 'put', - data: data + data: data, + params: { + submit + } }) } diff --git a/src/views/yh/report/edit/components/ReportProductEdit.vue b/src/views/yh/report/edit/components/ReportProductEdit.vue index 222d587..07e7c31 100644 --- a/src/views/yh/report/edit/components/ReportProductEdit.vue +++ b/src/views/yh/report/edit/components/ReportProductEdit.vue @@ -16,7 +16,6 @@ class="mini-table" > - - + - + - + - + - + @@ -242,6 +241,7 @@ export default { deptId: this.form.deptId, status: PriceStatus.PASS, // 已审核 disabled: false, + excludePriceIds: this.value.map(item => item.priceId) } } }, @@ -329,10 +329,14 @@ export default { this.selection = selection; }, // 删除 - handleDel(index) { - if (this.value != null) { + handleDel(row, index) { + this.$confirm(`确定删除工序【${row.priceName}】吗?`, '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { this.value.splice(index, 1); - } + }) }, // 批量修改产量 handleBatchUserProduct(){ @@ -388,12 +392,15 @@ export default { num: item.num } }) - // 计算总产量 - let totalCount = notNullDecimal(0); - row.userProdList.forEach(item => { - totalCount = notNullDecimal(item.num).add(totalCount); - }) - row.num = totalCount.toNumber(); + + // 若需要更新总产量,则计算总产量 + if (data.updateTotal) { + let totalCount = notNullDecimal(0); + row.userProdList.forEach(item => { + totalCount = notNullDecimal(item.num).add(totalCount); + }) + row.num = totalCount.toNumber(); + } }) this.$message.success("批量编辑成功"); } diff --git a/src/views/yh/report/edit/components/ReportProductOrderListEdit.vue b/src/views/yh/report/edit/components/ReportProductOrderListEdit.vue index c3e09a4..54f9fd5 100644 --- a/src/views/yh/report/edit/components/ReportProductOrderListEdit.vue +++ b/src/views/yh/report/edit/components/ReportProductOrderListEdit.vue @@ -141,13 +141,20 @@ export default { erpStatusList: [ProdOrderErpStatus.START_WORK], materialCategory: this.reportProd.priceCategory, materialSize: this.reportProd.priceSize, + excludeIds: this.value.map(item => item.orderId), } } }, methods: { isEmpty, handleDel(index) { - this.value.splice(index, 1) + this.$confirm(`确定删除与当前订单的关联吗?`, "提示", { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning", + }).then(() => { + this.value.splice(index, 1) + }) }, onChangeProdOrder(row, item) { row.orderErpQty = item.erpQty; diff --git a/src/views/yh/report/edit/components/ReportProductRowEdit.vue b/src/views/yh/report/edit/components/ReportProductRowEdit.vue index a67ae15..30ff20f 100644 --- a/src/views/yh/report/edit/components/ReportProductRowEdit.vue +++ b/src/views/yh/report/edit/components/ReportProductRowEdit.vue @@ -136,7 +136,7 @@ export default { this.$refs.form.validate(valid => { if (valid) { // 校验产量是否一致 - let error = this.checkNum(this.form); + let error = this.preCheckProd(this.form); if (!isEmpty(error)) { this.$message.warning(error); return; diff --git a/src/views/yh/report/edit/components/ReportProductUserListEdit.vue b/src/views/yh/report/edit/components/ReportProductUserListEdit.vue index 8361684..abf8d9c 100644 --- a/src/views/yh/report/edit/components/ReportProductUserListEdit.vue +++ b/src/views/yh/report/edit/components/ReportProductUserListEdit.vue @@ -4,7 +4,7 @@ @@ -38,7 +38,7 @@ type="text" icon="el-icon-delete" size="mini" - @click="handleDelUserProduct(d.$index)" + @click="handleDelUserProduct(d.row, d.$index)" >删除 @@ -51,7 +51,7 @@ :show.sync="showUserDialog" :list-api="listUserWithShift" @select="onSelectUsers" - :query="userQuery" + :query="userQueryParams" /> @@ -101,6 +101,12 @@ export default { } }, computed: { + userQueryParams() { + return { + excludeUserIds: this.value.map(item => item.userId), + ...this.userQuery + } + }, userIncome() { return (num) => { return calcMulDecimal(num, this.price); @@ -114,8 +120,14 @@ export default { this.showUserDialog = true; }, // 删除用户产量 - handleDelUserProduct(index) { - this.value.splice(index, 1); + handleDelUserProduct(row, index) { + this.$confirm(`确定删除当前员工产量吗?`, "提示", { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning", + }).then(() => { + this.value.splice(index, 1); + }) }, // 确认添加用户 onSelectUsers(list) { diff --git a/src/views/yh/report/edit/components/UserProductBatchDialog.vue b/src/views/yh/report/edit/components/UserProductBatchDialog.vue index b44c055..7489923 100644 --- a/src/views/yh/report/edit/components/UserProductBatchDialog.vue +++ b/src/views/yh/report/edit/components/UserProductBatchDialog.vue @@ -1,14 +1,20 @@ @@ -58,7 +64,7 @@ @@ -94,8 +100,11 @@ export default { } }, computed: { - IncomeMode() { - return IncomeMode + userQueryParams() { + return { + excludeUserIds: this.form.list.map(item => item.userId), + ...this.userQuery, + } }, visible: { get() { @@ -108,32 +117,60 @@ export default { }, data() { return { + IncomeMode, form: { - mode: IncomeMode.COUNT + list: [], + mode: IncomeMode.COUNT, + updateTotal: true, }, showUserDialog: false, + rules: { + list: { + num: [ + {required: true, message: '请输入员工产量', trigger: 'blur'}, + ], + score: [ + {required: true, message: '请输入员工分数', trigger: 'blur'}, + ] + } + } } }, methods: { listUserWithShift, onSubmit() { - this.$emit('submit', this.form); + this.$refs.form.validate(valid => { + if (valid) { + this.$confirm('【注意!】保存后将会覆盖已选中的员工产量数据,是否确认保存当前产量信息?', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + this.$emit('submit', this.form); + }) + } else { + this.$message.warning("表单校验不通过,请检查") + } + }) }, handleDel(index) { - this.form.list.splice(index, 1); + this.$confirm(`确定删除当前员工产量吗?`, '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(res => { + this.form.list.splice(index, 1); + }) }, handleAdd() { this.showUserDialog = true; }, onSelectUsers(list) { - if (isEmpty(this.form.list)) { - this.form.list = []; - } list.forEach(item => { this.form.list.push({ userId: item.userId, userName: item.nickName, - num: 0, + num: null, score: 10, }) }) diff --git a/src/views/yh/report/edit/edit.vue b/src/views/yh/report/edit/edit.vue index 402f9f5..43f0696 100644 --- a/src/views/yh/report/edit/edit.vue +++ b/src/views/yh/report/edit/edit.vue @@ -1,7 +1,8 @@