| | |
| | | ]" |
| | | > |
| | | <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(); |
| | |
| | | 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) => { |