| | |
| | | }, |
| | | data() { |
| | | return { |
| | | warehouseColOptions: [], |
| | | labelCol: { |
| | | xs: { span: 24 }, |
| | | sm: { span: 5 }, |
| | |
| | | }, |
| | | // 新增时子表默认添加几行空数据 |
| | | addDefaultRowNum: 1, |
| | | validatorRules: { |
| | | }, |
| | | refKeys: ['lswMaterialInventory', ], |
| | | tableKeys:['lswMaterialInventory', ], |
| | | activeKey: 'lswMaterialInventory', |
| | |
| | | loading: false, |
| | | dataSource: [], |
| | | columns: [ |
| | | { |
| | | title: '物料ID', |
| | | key: 'materialId', |
| | | type: JVXETypes.input, |
| | | width:"200px", |
| | | placeholder: '请输入${title}', |
| | | defaultValue:'', |
| | | }, |
| | | { |
| | | title: '批次号', |
| | | key: 'batchNumber', |
| | |
| | | { |
| | | title: '库存类型', |
| | | key: 'inventoryCategory', |
| | | type: JVXETypes.input, |
| | | type: JVXETypes.select, |
| | | width:"200px", |
| | | placeholder: '请输入${title}', |
| | | placeholder: '请选择${title}', |
| | | defaultValue:'', |
| | | options:[], |
| | | dictCode: 'inventoryCategory' |
| | | }, |
| | | { |
| | | title: '数量', |
| | |
| | | defaultValue:'', |
| | | }, |
| | | { |
| | | title: '库存地ID', |
| | | title: '库存地', |
| | | key: 'warehouseId', |
| | | type: JVXETypes.input, |
| | | type: JVXETypes.select, |
| | | width:"200px", |
| | | placeholder: '请输入${title}', |
| | | defaultValue:'', |
| | | options: this.warehouseColOptions, |
| | | }, |
| | | { |
| | | title: '库存状态', |
| | | key: 'inventoryStatus', |
| | | type: JVXETypes.input, |
| | | type: JVXETypes.select, |
| | | width:"200px", |
| | | placeholder: '请输入${title}', |
| | | defaultValue:'', |
| | | options:[], |
| | | dictCode: 'inventory_status' |
| | | }, |
| | | ] |
| | | }, |
| | | validatorRules: { |
| | | materialNumber: [ |
| | | { required: true, message: '物料编码是必选项', trigger: 'change' } |
| | | ], |
| | | materialName: [ |
| | | { required: true, message: '物料名称是必选项', trigger: 'change' } |
| | | ], |
| | | materialModel: [ |
| | | { required: true, message: '物料型号是必选项', trigger: 'change' } |
| | | ], |
| | | materialCategory: [ |
| | | { required: true, message: '物料类型是必选项', trigger: 'change' } |
| | | ], |
| | | materialUnit: [ |
| | | { required: true, message: '单位是必选项', trigger: 'change' } |
| | | ], |
| | | }, |
| | | url: { |
| | | add: "/lswmaterial/lswMaterial/add", |
| | | edit: "/lswmaterial/lswMaterial/edit", |
| | | queryById: "/lswmaterial/lswMaterial/queryById", |
| | | warehouseList:"/base/lineSideWarehouse/list", |
| | | lswMaterialInventory: { |
| | | list: '/lswmaterial/lswMaterial/queryLswMaterialInventoryByMainId' |
| | | }, |
| | |
| | | }, |
| | | }, |
| | | created () { |
| | | this.loadWarehouseOptions(); |
| | | }, |
| | | methods: { |
| | | async loadWarehouseOptions() { |
| | | try { |
| | | const res = await getAction(this.url.warehouseList); |
| | | console.log("仓库API响应:", res); |
| | | let data = []; |
| | | data = res.result.records; |
| | | console.log("处理后的仓库数据:", data); |
| | | const options = data.map(item => ({ |
| | | text: item.warehouseName || `仓库(${item.id})`, // 显示文本 |
| | | value: item.id // 实际值 |
| | | })); |
| | | console.log("格式化后的选项:", options); |
| | | const warehouseCol = this.lswMaterialInventoryTable.columns.find( |
| | | col => col.key === 'warehouseId' |
| | | ); |
| | | if (warehouseCol) { |
| | | this.$set(warehouseCol, 'options', options); |
| | | this.warehouseColOptions = warehouseCol.options |
| | | console.log("更新后的列选项:", warehouseCol.options); |
| | | } |
| | | this.$nextTick(() => { |
| | | this.$forceUpdate(); |
| | | console.log("已强制更新视图"); |
| | | }); |
| | | } catch (error) { |
| | | console.error('加载仓库列表失败:', error); |
| | | } |
| | | }, |
| | | addBefore(){ |
| | | this.lswMaterialInventoryTable.dataSource=[] |
| | | }, |