feat: 部门物品报废
1、分发单选择增加校验
2、明细列表字段对接
| | |
| | | // 新增 |
| | | export function scrappedAdd(data) { |
| | | return request({ |
| | | url: '/pc/l/wh/form/scrapped/add', |
| | | url: '/pc/l/wh/form/scrapped/deptAdd', |
| | | method: 'post', |
| | | data, |
| | | }); |
| | |
| | | // 列信息 |
| | | columns: [ |
| | | {title: '单号', field: 'businessFormCode', align: 'center', width: 130}, |
| | | {title: '物品名称', field: 'goodsName', align: 'left', minWidth: 140}, |
| | | {title: '物品名称', field: 'baseGoodsTemplateName', align: 'left', minWidth: 140}, |
| | | /*{ |
| | | title: '类别', field: 'type', align: 'center', formatter: (row) => { |
| | | return {value: row.type + '类'}; |
| | | }, |
| | | },*/ |
| | | {title: '规格型号', field: 'goodsModelName', align: 'left', minWidth: 130}, |
| | | {title: '报废数量', field: 'count', align: 'center'}, |
| | | {title: '规格型号', field: 'baseGoodsModelsName', align: 'left', minWidth: 130}, |
| | | {title: '报废数量', field: 'counts', align: 'center'}, |
| | | /*{title: '所属机构', field: 'tenantName', align: 'left', minWidth: 130},*/ |
| | | {title: '部门', field: 'departmentName', align: 'left', minWidth: 130}, |
| | | {title: '创建人', field: 'operatorName', align: 'center', width: 100}, |
| | | { |
| | | title: '操作时间', field: 'createTime', align: 'center', |
| | | title: '操作时间', field: 'dealTime', align: 'center', |
| | | width: 160, |
| | | formatter: (row) => { |
| | | return {value: DateFormatter.LongToDateTime(row.createTime)}; |
| | |
| | | <span>{{ goodsItem.businessFormCode }}</span> |
| | | </el-col> |
| | | </el-row> |
| | | <!-- <div v-for="(mItem,k) in goodsItem.models" :key="k">--> |
| | | <div class="card3"> |
| | | <el-row v-if="goodsItem.models[0].goodsUserName" :gutter="24" type="flex" align="middle"> |
| | | <div class="card3" v-for="(mItem,k) in mItem" :key="k"> |
| | | <el-row v-if="mItem[0].goodsUserName" :gutter="24" type="flex" align="middle"> |
| | | <el-col :span="8"> |
| | | <span>规格型号:</span> |
| | | <span>{{ goodsItem.models[0].baseGoodsModelsName }}</span> |
| | | <span>{{ mItem[0].baseGoodsModelsName }}</span> |
| | | </el-col> |
| | | <el-col :span="4"> |
| | | <span>单位:</span> |
| | | <span>{{ goodsItem.models[0].unit }}</span> |
| | | <span>{{ mItem[0].unit }}</span> |
| | | </el-col> |
| | | </el-row> |
| | | <el-table :data="goodsItem.models" style="margin-top: 15px"> |
| | | <el-table-column prop="baseGoodsModelsName" label="规格型号" align="left" v-if="!goodsItem.models[0].goodsUserName"/> |
| | | <el-table-column prop="unit" label="单位" align="center" v-if="!goodsItem.models[0].goodsUserName"/> |
| | | <el-table-column prop="goodsUserName" label="使用人" align="left" v-if="goodsItem.models[0].goodsUserName"/> |
| | | <el-table :data="mItem" style="margin-top: 15px"> |
| | | <el-table-column prop="baseGoodsModelsName" label="规格型号" align="left" v-if="!mItem[0].goodsUserName"/> |
| | | <el-table-column prop="unit" label="单位" align="center" v-if="!mItem[0].goodsUserName"/> |
| | | <el-table-column prop="goodsUserName" label="使用人" align="left" v-if="mItem[0].goodsUserName"/> |
| | | <el-table-column prop="useCount" label="在用数量" align="center"/> |
| | | <el-table-column prop="counts" label="报废数量" align="center"/> |
| | | <el-table-column prop="scrappedName" label="报废原因" align="left"/> |
| | |
| | | }, |
| | | }, |
| | | data() { |
| | | // 自定义校验 |
| | | // 物品重复校验 |
| | | var checkBusinessFormCode = (rule, value, callback) => { |
| | | if (!value) { |
| | | return callback(new Error('请选择')); |
| | | } |
| | | let temp = this.formData.goods.filter((v) => v.businessFormCode == value); |
| | | if (!temp || temp.length != 1) { |
| | | return callback(new Error('已选过此分发单')); |
| | | } |
| | | callback(); |
| | | }; |
| | | return { |
| | | checkCounts: (rule, value, callback) => { |
| | | if (!rule.counts) { |
| | |
| | | message: '请选择物品', |
| | | trigger: 'change' |
| | | }], |
| | | businessFormCode: [{ |
| | | required: true, |
| | | message: '请选择分发单', |
| | | trigger: 'change' |
| | | }, {validator: checkBusinessFormCode, trigger: ['blur', 'change']}], |
| | | businessFormCode: [{required: true, message: '请选择分发单', trigger: 'change'}], |
| | | counts: [{required: true, message: '请输入', trigger: 'change'}], |
| | | reason: [{required: true, message: '请选择', trigger: 'change'}], |
| | | }, |
| | |
| | | // 物品名称列表选择 |
| | | goodsTemplateChange(e, index) { |
| | | this.formData.goods[index].models = []; |
| | | |
| | | this.formData.goods[index].businessFormCode = ''; |
| | | this.formData.goods[index].goodsTemplateName = this.getGoodsTemplateName(e); |
| | | |
| | | }, |
| | | showFenFa(index) { |
| | | this.loading = true |
| | |
| | | this.$message.error('请选择分发单'); |
| | | return |
| | | } |
| | | let bIdx = this.formData.goods.findIndex((v) => v.businessFormCode == this.curFenfa.businessFormCode); |
| | | let gIdx = this.formData.goods.findIndex((v) => v.baseGoodsTemplateId == this.fenfaSetting.baseGoodsTemplateId); |
| | | |
| | | if (gIdx !== -1 && gIdx !== this.fenfaSetting.goodsIdx && bIdx !== -1 && bIdx !== this.fenfaSetting.goodsIdx) { |
| | | this.$message.error('同一个物品不能选择相同的分发单'); |
| | | return; |
| | | } |
| | | getGoodsUseInfoByFfOrderAndGoodId({ |
| | | transBusinessId: this.curFenfa.transBusinessId, |
| | | baseGoodsTemplateId: this.fenfaSetting.baseGoodsTemplateId |
| | |
| | | table: { |
| | | showIndex: true, // 是否显示序号 |
| | | expand: false, // 是否显示详情数据 |
| | | url: SettingIplatform.apiBaseURL + '/pc/l/wh/form/transfer/department/list', // 请求地址 |
| | | url: SettingIplatform.apiBaseURL + '/pc/l/wh/form/scrapped/deptListByModel', // 请求地址 |
| | | // 工具条 |
| | | tools: { |
| | | columnsCtrl: { |
| | |
| | | // 列信息 |
| | | columns: [ |
| | | {title: '单号', field: 'businessFormCode', align: 'center', width: 130}, |
| | | {title: '物品名称', field: 'goodsName', align: 'left', minWidth: 140}, |
| | | {title: '物品名称', field: 'baseGoodsTemplateName', align: 'left', minWidth: 140}, |
| | | /*{ |
| | | title: '类别', field: 'type', align: 'center', formatter: (row) => { |
| | | return {value: row.type + '类'}; |
| | | }, |
| | | },*/ |
| | | {title: '规格型号', field: 'goodsModelName', align: 'left', minWidth: 130}, |
| | | {title: '报废数量', field: 'count', align: 'center'}, |
| | | {title: '规格型号', field: 'baseGoodsModelsName', align: 'left', minWidth: 130}, |
| | | {title: '报废数量', field: 'counts', align: 'center'}, |
| | | /*{title: '所属机构', field: 'tenantName', align: 'left', minWidth: 130},*/ |
| | | {title: '部门', field: 'departmentName', align: 'left', minWidth: 130}, |
| | | {title: '创建人', field: 'operatorName', align: 'center', width: 100}, |
| | | { |
| | | title: '操作时间', field: 'createTime', align: 'center', |
| | | title: '操作时间', field: 'dealTime', align: 'center', |
| | | width: 160, |
| | | formatter: (row) => { |
| | | return {value: DateFormatter.LongToDateTime(row.createTime)}; |
| | |
| | | <span>{{ goodsItem.businessFormCode }}</span> |
| | | </el-col> |
| | | </el-row> |
| | | <!-- <div v-for="(mItem,k) in goodsItem.models" :key="k">--> |
| | | <div class="card3"> |
| | | <el-row v-if="goodsItem.models[0].goodsUserName" :gutter="24" type="flex" align="middle"> |
| | | <div class="card3" v-for="(mItem,k) in goodsItem.models" :key="k"> |
| | | <el-row v-if="mItem[0].goodsUserName" :gutter="24" type="flex" align="middle"> |
| | | <el-col :span="8"> |
| | | <span>规格型号:</span> |
| | | <span>{{ goodsItem.models[0].baseGoodsModelsName }}</span> |
| | | <span>{{ mItem[0].baseGoodsModelsName }}</span> |
| | | </el-col> |
| | | <el-col :span="4"> |
| | | <span>单位:</span> |
| | | <span>{{ goodsItem.models[0].unit }}</span> |
| | | <span>{{ mItem[0].unit }}</span> |
| | | </el-col> |
| | | </el-row> |
| | | <el-table :data="goodsItem.models" style="margin-top: 15px"> |
| | | <el-table-column prop="baseGoodsModelsName" label="规格型号" align="left" v-if="!goodsItem.models[0].goodsUserName"/> |
| | | <el-table-column prop="unit" label="单位" align="center" v-if="!goodsItem.models[0].goodsUserName"/> |
| | | <el-table-column prop="goodsUserName" label="使用人" align="left" v-if="goodsItem.models[0].goodsUserName"/> |
| | | <el-table :data="mItem" style="margin-top: 15px"> |
| | | <el-table-column prop="baseGoodsModelsName" label="规格型号" align="left" v-if="!mItem[0].goodsUserName"/> |
| | | <el-table-column prop="unit" label="单位" align="center" v-if="!mItem[0].goodsUserName"/> |
| | | <el-table-column prop="goodsUserName" label="使用人" align="left" v-if="mItem[0].goodsUserName"/> |
| | | <el-table-column prop="useCount" label="在用数量" align="center"/> |
| | | <el-table-column prop="counts" label="报废数量" align="center"/> |
| | | <el-table-column prop="scrappedName" label="报废原因" align="left"/> |
| | |
| | | }, |
| | | }, |
| | | data() { |
| | | // 自定义校验 |
| | | // 物品重复校验 |
| | | var checkBusinessFormCode = (rule, value, callback) => { |
| | | if (!value) { |
| | | return callback(new Error('请选择')); |
| | | } |
| | | let temp = this.formData.goods.filter((v) => v.businessFormCode == value); |
| | | if (!temp || temp.length != 1) { |
| | | return callback(new Error('已选过此分发单')); |
| | | } |
| | | callback(); |
| | | }; |
| | | return { |
| | | checkCounts: (rule, value, callback) => { |
| | | if (!rule.counts) { |
| | |
| | | message: '请选择物品', |
| | | trigger: 'change' |
| | | }], |
| | | businessFormCode: [{ |
| | | required: true, |
| | | message: '请选择分发单', |
| | | trigger: 'change' |
| | | }, {validator: checkBusinessFormCode, trigger: ['blur', 'change']}], |
| | | businessFormCode: [{required: true, message: '请选择分发单', trigger: 'change'}], |
| | | counts: [{required: true, message: '请输入', trigger: 'change'}], |
| | | reason: [{required: true, message: '请选择', trigger: 'change'}], |
| | | }, |
| | |
| | | categoryChange(e, index) { |
| | | this.formData.goods[index].goodsOptions = []; |
| | | this.formData.goods[index].baseGoodsTemplateId = ''; |
| | | this.formData.goods[index].businessFormCode = ''; |
| | | this.formData.goods[index].goodsTemplateName = ''; |
| | | this.formData.goods[index].models = []; |
| | | // 根据选中分类请求物品名称列表 |
| | |
| | | // 物品名称列表选择 |
| | | goodsTemplateChange(e, index) { |
| | | this.formData.goods[index].models = []; |
| | | |
| | | this.formData.goods[index].goodsTemplateName = this.getGoodsTemplateName(e); |
| | | |
| | | this.formData.goods[index].businessFormCode = ''; |
| | | }, |
| | | showFenFa(index) { |
| | | this.loading = true |
| | |
| | | this.$message.error('请选择分发单'); |
| | | return |
| | | } |
| | | let bIdx = this.formData.goods.findIndex((v) => v.businessFormCode == this.curFenfa.businessFormCode); |
| | | let gIdx = this.formData.goods.findIndex((v) => v.baseGoodsTemplateId == this.fenfaSetting.baseGoodsTemplateId); |
| | | |
| | | if (gIdx !== -1 && gIdx !== this.fenfaSetting.goodsIdx && bIdx !== -1 && bIdx !== this.fenfaSetting.goodsIdx) { |
| | | this.$message.error('同一个物品不能选择相同的分发单'); |
| | | return; |
| | | } |
| | | getGoodsUseInfoByFfOrderAndGoodId({ |
| | | transBusinessId: this.curFenfa.transBusinessId, |
| | | baseGoodsTemplateId: this.fenfaSetting.baseGoodsTemplateId |
| | |
| | | }) |
| | | g.models = arr |
| | | }) |
| | | // console.log('params', params); |
| | | // return |
| | | if(this.loading) return |
| | | this.loading = true |
| | | scrappedAdd(params) |
| | | .then((res) => { |
| | | this.loading = false |
| | | this.$message.success('保存成功!'); |
| | | this.close(); |
| | | this.$emit('search'); |
| | | }) |
| | | .catch((err) => { |
| | | console.log('edit err', err); |
| | | this.loading = false |
| | | this.$message.error('保存失败'); |
| | | }); |
| | | } else { |