| | |
| | | ]" |
| | | > |
| | | <el-input |
| | | clearable |
| | | type="number" |
| | | v-model.number="row.counts" |
| | | ></el-input> |
| | |
| | | label-width="0" |
| | | :prop="`goods.${goodsIndex}.models.${mIndex}.scrappedCode`" |
| | | :rules="[ |
| | | {validator: checkReason,scrappedCode:row.scrappedCode, trigger: ['blur', 'change']} |
| | | {validator: checkReason,counts:row.counts,scrappedCode:row.scrappedCode, trigger: ['blur', 'change']} |
| | | ]" |
| | | > |
| | | <el-select v-model="row.scrappedCode" placeholder="请选择"> |
| | | <el-select v-model="row.scrappedCode" clearable placeholder="请选择"> |
| | | <el-option |
| | | v-for="item in scrapReasonOptions" |
| | | :key="item.dict_code" |
| | |
| | | return { |
| | | checkCounts: (rule, value, callback) => { |
| | | if (!rule.counts) { |
| | | return callback(new Error('请输入报废数量')); |
| | | return callback(); |
| | | } |
| | | if (!Number.isInteger(rule.counts)) { |
| | | // this.$message.warning('请输入数字值'); |
| | | return callback(new Error('请输入数字值')); |
| | | } |
| | | if (rule.counts < 1) { |
| | | // this.$message.warning('数字值不能为0'); |
| | | return callback(new Error('数字值必须大于0')); |
| | | } |
| | | if (rule.counts > rule.userUseCount) { |
| | | // this.$message.warning('分发数量不能大于剩余数量'); |
| | |
| | | callback(); |
| | | }, |
| | | checkReason: (rule, value, callback) => { |
| | | if (!rule.scrappedCode) { |
| | | if (rule.counts && !rule.scrappedCode) { |
| | | return callback(new Error('请选择报废原因')); |
| | | } |
| | | callback(); |
| | |
| | | fenfaData: [], |
| | | formData: { |
| | | departmentId: '', // 报废部门id |
| | | dealTime: '', // 报废时间 |
| | | dealTime: DateFormatter.formatDate(new Date(), 'yyyyMMddhhmmss'), // 报废时间 |
| | | procureDoc: '', |
| | | goods: [], |
| | | }, |
| | |
| | | title: '上传', |
| | | max: 20, // 最大大小,单位M |
| | | num: 10, // 支持上传图片个数 |
| | | accept: '.jpg,.png', // 限制格式 |
| | | tip: '', // 提示 默认:`只能上传${this.defaultSettings.num}个${this.defaultSettings.accept}文件,且不超过${this.defaultSettings.max}kb` |
| | | uploadUrl: getUploadUrl(), // 上传路径 |
| | | multiple: true, // 是否支持批量上传 |
| | | disabled: false, // 是否禁用 |
| | | type: 'picture', // text/picture |
| | | }, |
| | | scrapReasonOptions: [] // 报废原因 |
| | | }; |
| | |
| | | }).then(res => { |
| | | this.loading = false |
| | | if (!res || res.length === 0) { |
| | | this.$message.error('未查询到分发单'); |
| | | this.$message.error('未查询到可以报废的分发单'); |
| | | return |
| | | } |
| | | this.fenfaSetting.show = true |
| | |
| | | this.$refs['ruleForm'].validate((valid) => { |
| | | if (valid) { |
| | | let params = JSON.parse(JSON.stringify(this.formData)) |
| | | params.goods.map((g, gid) => { |
| | | params.goods.map(g => { |
| | | delete g.goodsOptions |
| | | let arr = [] |
| | | g.models.map(m => { |
| | | arr = arr.concat(m) |
| | | m.map(item=>{ |
| | | if(item.counts&&item.counts>0){ |
| | | arr.push(item) |
| | | } |
| | | }) |
| | | }) |
| | | g.models = arr |
| | | }) |
| | | if(this.loading) return |
| | | params.goods = params.goods.filter(g=>g.models.length>0) |
| | | if(params.goods.length===0){ |
| | | this.$message.error('请至少填写一个报废物品'); |
| | | return; |
| | | } |
| | | if (this.loading) return |
| | | this.loading = true |
| | | scrappedAdd(params) |
| | | .then((res) => { |