| | |
| | | this.selectionRows = selection |
| | | }, |
| | | changeMachineName() { |
| | | this.selectionRows.map(val => { |
| | | const existingIds = new Set(this.calibrationPlanDetailList.map(item => item.deviceId)) |
| | | let skipped = 0 |
| | | this.selectionRows.forEach(val => { |
| | | if (existingIds.has(val.id)) { |
| | | skipped++ |
| | | return |
| | | } |
| | | // 将 val.nextCalibrationDate 转换为 Date 对象并减去 5 天 |
| | | let nextCalibrationDate = val.nextCalibrationDate ? new Date(val.nextCalibrationDate) : null; |
| | | if (nextCalibrationDate) { |
| | |
| | | verificationUnit: val.calibrationServices, |
| | | deviceAmount: 1 |
| | | }) |
| | | existingIds.add(val.id) |
| | | }) |
| | | if (skipped > 0) { |
| | | this.$message.warning(`已跳过 ${skipped} 台已在计划中的设备`) |
| | | } |
| | | this.addEquipDia = false |
| | | this.rowDrop() |
| | | }, |
| | |
| | | }, |
| | | // 提交新增 |
| | | submitForm() { |
| | | if (!this.form.planName) { |
| | | this.$message.warning('请输入计划名称') |
| | | return |
| | | } |
| | | if (!this.form.planYear) { |
| | | this.$message.warning('请选择年份') |
| | | return |
| | | } |
| | | if (!this.calibrationPlanDetailList.length) { |
| | | this.$message.warning('请添加设备') |
| | | return |
| | | } |
| | | this.form.calibrationPlanDetailList = this.HaveJson(this.calibrationPlanDetailList) |
| | | this.submitFormLoading = true |
| | | if (this.operationType === 'add') { |
| | |
| | | } else { |
| | | updateDeviceCalibrationPlan(this.form).then(res => { |
| | | if (res.code == 200) { |
| | | this.$message.success('新增成功') |
| | | this.$message.success('修改成功') |
| | | this.closeDialog() |
| | | this.$emit('closeDia') |
| | | } |