From 0e59e3ebb9f7e9f83c7f906f40d0a562a8a686e8 Mon Sep 17 00:00:00 2001
From: cuilei <ray_tsu1@163.com>
Date: 星期一, 18 八月 2025 17:07:08 +0800
Subject: [PATCH] 排产功能物料下拉框调整
---
src/views/lsw/modules/LswMaterialForm.vue | 325 ++++++++++++++++--------------------------------------
1 files changed, 97 insertions(+), 228 deletions(-)
diff --git a/src/views/lsw/modules/LswMaterialForm.vue b/src/views/lsw/modules/LswMaterialForm.vue
index 98276bb..cb1d462 100644
--- a/src/views/lsw/modules/LswMaterialForm.vue
+++ b/src/views/lsw/modules/LswMaterialForm.vue
@@ -1,260 +1,129 @@
<template>
<a-spin :spinning="confirmLoading">
- <j-form-container :disabled="formDisabled">
+ <j-form-container :disabled="true">
<!-- 涓昏〃鍗曞尯鍩� -->
- <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
+ <a-form-model ref="form1" :model="model" :rules="validatorRules" slot="detail">
<a-row>
- <a-col :span="12" >
+ <a-col :span="24">
<a-form-model-item label="鐗╂枡缂栫爜" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="materialNumber">
- <a-input v-model="model.materialNumber" placeholder="璇疯緭鍏ョ墿鏂欑紪鐮�" ></a-input>
+ <a-input v-model="model.materialNumber"></a-input>
</a-form-model-item>
</a-col>
- <a-col :span="12" >
+ <a-col :span="24">
<a-form-model-item label="鐗╂枡鍚嶇О" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="materialName">
- <a-input v-model="model.materialName" placeholder="璇疯緭鍏ョ墿鏂欏悕绉�" ></a-input>
+ <a-input v-model="model.materialName"></a-input>
</a-form-model-item>
</a-col>
- <a-col :span="12" >
- <a-form-model-item label="鐗╂枡鍨嬪彿" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="materialModel">
- <a-input v-model="model.materialModel" placeholder="璇疯緭鍏ョ墿鏂欏瀷鍙�" ></a-input>
- </a-form-model-item>
- </a-col>
- <a-col :span="12" >
- <a-form-model-item label="鐗╂枡绫诲瀷" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="materialCategory">
- <j-dict-select-tag type="list" v-model="model.materialCategory" dictCode="material_category" placeholder="璇烽�夋嫨鐗╂枡绫诲瀷" />
- </a-form-model-item>
- </a-col>
- <a-col :span="12" >
- <a-form-model-item label="鍗曚綅" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="materialUnit">
- <a-input v-model="model.materialUnit" placeholder="璇疯緭鍏ュ崟浣�" ></a-input>
+ <a-col :span="24">
+ <a-form-model-item label="鍩烘湰璁¢噺鍗曚綅" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="materialUnit">
+ <a-input v-model="model.materialUnit"></a-input>
</a-form-model-item>
</a-col>
</a-row>
</a-form-model>
</j-form-container>
- <!-- 瀛愯〃鍗曞尯鍩� -->
- <a-tabs v-model="activeKey" @change="handleChangeTabs">
- <a-tab-pane tab="鐗╂枡搴撳瓨淇℃伅" :key="refKeys[0]" :forceRender="true">
- <j-vxe-table
- keep-source
- :ref="refKeys[0]"
- :loading="lswMaterialInventoryTable.loading"
- :columns="lswMaterialInventoryTable.columns"
- :dataSource="lswMaterialInventoryTable.dataSource"
- :maxHeight="300"
- :disabled="formDisabled"
- :rowNumber="true"
- :rowSelection="true"
- :toolbar="true"
- />
- </a-tab-pane>
- </a-tabs>
+ <j-form-container :disabled="formDisabled">
+ <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
+ <a-row>
+ <a-col :span="24">
+ <a-form-model-item label="鐗╂枡绫诲瀷" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="materialCategory">
+ <j-dict-select-tag type="list" v-model="model.materialCategory" dictCode="material_category" />
+ </a-form-model-item>
+ </a-col>
+ </a-row>
+ </a-form-model>
+ </j-form-container>
</a-spin>
</template>
<script>
- import { getAction } from '@/api/manage'
- import { JVxeTableModelMixin } from '@/mixins/JVxeTableModelMixin.js'
- import { JVXETypes } from '@/components/jeecg/JVxeTable'
- import { getRefPromise,VALIDATE_FAILED} from '@/components/jeecg/JVxeTable/utils/vxeUtils.js'
- import { validateDuplicateValue } from '@/utils/util'
- import JFormContainer from '@/components/jeecg/JFormContainer'
+import { httpAction } from '@/api/manage'
- export default {
- name: 'LswMaterialForm',
- mixins: [JVxeTableModelMixin],
- components: {
- JFormContainer,
- },
- data() {
- return {
- warehouseColOptions: [],
- labelCol: {
- xs: { span: 24 },
- sm: { span: 5 },
- },
- wrapperCol: {
- xs: { span: 24 },
- sm: { span: 16 },
- },
- model:{
- },
- // 鏂板鏃跺瓙琛ㄩ粯璁ゆ坊鍔犲嚑琛岀┖鏁版嵁
- addDefaultRowNum: 1,
- refKeys: ['lswMaterialInventory', ],
- tableKeys:['lswMaterialInventory', ],
- activeKey: 'lswMaterialInventory',
- // 鐗╂枡搴撳瓨淇℃伅
- lswMaterialInventoryTable: {
- loading: false,
- dataSource: [],
- columns: [
- {
- title: '鎵规鍙�',
- key: 'batchNumber',
- type: JVXETypes.input,
- width:"200px",
- placeholder: '璇疯緭鍏�${title}',
- defaultValue:'',
- },
- {
- title: '搴撳瓨绫诲瀷',
- key: 'inventoryCategory',
- type: JVXETypes.select,
- width:"200px",
- placeholder: '璇烽�夋嫨${title}',
- defaultValue:'',
- options:[],
- dictCode: 'inventoryCategory'
- },
- {
- title: '鏁伴噺',
- key: 'quantity',
- type: JVXETypes.input,
- width:"200px",
- placeholder: '璇疯緭鍏�${title}',
- defaultValue:'',
- },
- {
- title: '搴撳瓨鍦�',
- key: 'warehouseId',
- type: JVXETypes.select,
- width: "200px",
- options: this.warehouseColOptions,
- },
- {
- title: '搴撳瓨鐘舵��',
- key: 'inventoryStatus',
- 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'
- },
- }
- }
- },
- props: {
- //琛ㄥ崟绂佺敤
- disabled: {
- type: Boolean,
- default: false,
- required: false
- }
- },
- computed: {
- formDisabled(){
- return this.disabled
+export default {
+ name: 'LswMaterialForm',
+ components: {
+ },
+ data() {
+ return {
+ confirmLoading: false,
+ labelCol: {
+ xs: { span: 24 },
+ sm: { span: 5 }
},
+ wrapperCol: {
+ xs: { span: 24 },
+ sm: { span: 16 }
+ },
+ model: {},
+ validatorRules: {
+ materialCategory: [
+ { required: true, message: '鐗╂枡绫诲瀷蹇呴��', trigger: 'change' }
+ ]
+ },
+ url: {
+ add: '',
+ edit: '/lsw/lswMaterial/edit'
+ }
+ }
+ },
+ props: {
+ //琛ㄥ崟绂佺敤
+ disabled: {
+ type: Boolean,
+ default: false,
+ required: false
+ }
+ },
+ computed: {
+ formDisabled() {
+ return this.disabled
+ }
+ },
+ created() {
+ //澶囦唤model鍘熷鍊�
+ this.modelDefault = JSON.parse(JSON.stringify(this.model))
+ console.log('formDisabled' + this.formDisabled)
+ },
+ methods: {
+ add() {
+ this.edit(this.modelDefault)
},
- created () {
- this.loadWarehouseOptions();
+ edit(record) {
+ this.model = Object.assign({}, record)
+ this.visible = true
},
- 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);
+ submitForm() {
+ const that = this
+ // 瑙﹀彂琛ㄥ崟楠岃瘉
+ this.$refs.form.validate(valid => {
+ if (valid) {
+ that.confirmLoading = true
+ let httpurl = ''
+ let method = ''
+ if (!this.model.id) {
+ httpurl += this.url.add
+ method = 'post'
+ } else {
+ httpurl += this.url.edit
+ method = 'put'
}
- this.$nextTick(() => {
- this.$forceUpdate();
- console.log("宸插己鍒舵洿鏂拌鍥�");
- });
- } catch (error) {
- console.error('鍔犺浇浠撳簱鍒楄〃澶辫触:', error);
+ httpAction(httpurl, this.model, method).then((res) => {
+ if (res.success) {
+ that.$message.success(res.message)
+ that.$emit('ok')
+ } else {
+ that.$message.warning(res.message)
+ }
+ }).finally(() => {
+ that.confirmLoading = false
+ })
}
- },
- addBefore(){
- this.lswMaterialInventoryTable.dataSource=[]
- },
- getAllTable() {
- let values = this.tableKeys.map(key => getRefPromise(this, key))
- return Promise.all(values)
- },
- /** 璋冪敤瀹宔dit()鏂规硶涔嬪悗浼氳嚜鍔ㄨ皟鐢ㄦ鏂规硶 */
- editAfter() {
- this.$nextTick(() => {
- })
- // 鍔犺浇瀛愯〃鏁版嵁
- if (this.model.id) {
- let params = { id: this.model.id }
- this.requestSubTableData(this.url.lswMaterialInventory.list, params, this.lswMaterialInventoryTable)
- }
- },
- //鏍¢獙鎵�鏈変竴瀵逛竴瀛愯〃琛ㄥ崟
- validateSubForm(allValues){
- return new Promise((resolve,reject)=>{
- Promise.all([
- ]).then(() => {
- resolve(allValues)
- }).catch(e => {
- if (e.error === VALIDATE_FAILED) {
- // 濡傛灉鏈夋湭閫氳繃琛ㄥ崟楠岃瘉鐨勫瓙琛紝灏辫嚜鍔ㄨ烦杞埌瀹冩墍鍦ㄧ殑tab
- this.activeKey = e.index == null ? this.activeKey : this.refKeys[e.index]
- } else {
- console.error(e)
- }
- })
- })
- },
- /** 鏁寸悊鎴恌ormData */
- classifyIntoFormData(allValues) {
- let main = Object.assign(this.model, allValues.formValue)
- return {
- ...main, // 灞曞紑
- lswMaterialInventoryList: allValues.tablesValue[0].tableData,
- }
- },
- validateError(msg){
- this.$message.error(msg)
- },
+ })
}
}
+}
</script>
<style scoped>
--
Gitblit v1.9.3