From 7282d4b49f4577c6807a78bdd6e705feb2fe0e2c Mon Sep 17 00:00:00 2001
From: zhangherong <571457620@qq.com>
Date: 星期四, 14 八月 2025 20:47:04 +0800
Subject: [PATCH] art: 线边库管理,物料台账相关代码修改

---
 src/views/lsw/modules/LswMaterialForm.vue |  286 +++++++++++++++++++-------------------------------------
 1 files changed, 98 insertions(+), 188 deletions(-)

diff --git a/src/views/lsw/modules/LswMaterialForm.vue b/src/views/lsw/modules/LswMaterialForm.vue
index 8c4958e..cb1d462 100644
--- a/src/views/lsw/modules/LswMaterialForm.vue
+++ b/src/views/lsw/modules/LswMaterialForm.vue
@@ -1,219 +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 {
-        labelCol: {
-          xs: { span: 24 },
-          sm: { span: 5 },
-        },
-        wrapperCol: {
-          xs: { span: 24 },
-          sm: { span: 16 },
-        },
-        model:{
-         },
-        // 鏂板鏃跺瓙琛ㄩ粯璁ゆ坊鍔犲嚑琛岀┖鏁版嵁
-        addDefaultRowNum: 1,
-        validatorRules: {
-        },
-        refKeys: ['lswMaterialInventory', ],
-        tableKeys:['lswMaterialInventory', ],
-        activeKey: 'lswMaterialInventory',
-        // 鐗╂枡搴撳瓨淇℃伅
-        lswMaterialInventoryTable: {
-          loading: false,
-          dataSource: [],
-          columns: [
-            {
-              title: '鐗╂枡ID',
-              key: 'materialId',
-               type: JVXETypes.input,
-              width:"200px",
-              placeholder: '璇疯緭鍏�${title}',
-              defaultValue:'',
-            },
-            {
-              title: '鎵规鍙�',
-              key: 'batchNumber',
-               type: JVXETypes.input,
-              width:"200px",
-              placeholder: '璇疯緭鍏�${title}',
-              defaultValue:'',
-            },
-            {
-              title: '搴撳瓨绫诲瀷',
-              key: 'inventoryCategory',
-               type: JVXETypes.input,
-              width:"200px",
-              placeholder: '璇疯緭鍏�${title}',
-              defaultValue:'',
-            },
-            {
-              title: '鏁伴噺',
-              key: 'quantity',
-               type: JVXETypes.input,
-              width:"200px",
-              placeholder: '璇疯緭鍏�${title}',
-              defaultValue:'',
-            },
-            {
-              title: '搴撳瓨鍦癐D',
-              key: 'warehouseId',
-               type: JVXETypes.input,
-              width:"200px",
-              placeholder: '璇疯緭鍏�${title}',
-              defaultValue:'',
-            },
-            {
-              title: '搴撳瓨鐘舵��',
-              key: 'inventoryStatus',
-               type: JVXETypes.input,
-              width:"200px",
-              placeholder: '璇疯緭鍏�${title}',
-              defaultValue:'',
-            },
-          ]
-        },
-        url: {
-          add: "/lswmaterial/lswMaterial/add",
-          edit: "/lswmaterial/lswMaterial/edit",
-          queryById: "/lswmaterial/lswMaterial/queryById",
-          lswMaterialInventory: {
-            list: '/lswmaterial/lswMaterial/queryLswMaterialInventoryByMainId'
-          },
-        }
+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)
     },
-    props: {
-      //琛ㄥ崟绂佺敤
-      disabled: {
-        type: Boolean,
-        default: false,
-        required: false
-      }
+    edit(record) {
+      this.model = Object.assign({}, record)
+      this.visible = true
     },
-    computed: {
-      formDisabled(){
-        return this.disabled
-      },
-    },
-    created () {
-    },
-    methods: {
-      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)
+    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'
+          }
+          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
+          })
         }
-      },
-      //鏍¢獙鎵�鏈変竴瀵逛竴瀛愯〃琛ㄥ崟
-        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