From 7b7d716d98e126adfbf8c5f008ed0a73f9ce5ee3 Mon Sep 17 00:00:00 2001
From: llj <132905093+newwwwwwtree@users.noreply.github.com>
Date: 星期二, 02 十二月 2025 10:55:23 +0800
Subject: [PATCH] 物料和客户测试修复

---
 src/views/GyCustomer/index.vue              |   33 +++++---
 src/views/gyMaterial/GyMaterial.vue         |   43 ++++++----
 src/views/GyCustomer/CustomerEdit/index.vue |  138 +++++++++++++++++++++++----------
 3 files changed, 142 insertions(+), 72 deletions(-)

diff --git a/src/views/GyCustomer/CustomerEdit/index.vue b/src/views/GyCustomer/CustomerEdit/index.vue
index 5fb9f44..6433895 100644
--- a/src/views/GyCustomer/CustomerEdit/index.vue
+++ b/src/views/GyCustomer/CustomerEdit/index.vue
@@ -119,15 +119,15 @@
 
    
               <el-tab-pane label="鍏朵粬淇℃伅" name="other">
-                <el-form ref="formOther" :model="formData" label-width="100px">
+                <el-form ref="formOther" :model="formData" :rules="rules" label-width="100px">
                   <el-row :gutter="20">
                     <el-col :span="12">
-                      <el-form-item label="鑱旂郴浜�">
+                      <el-form-item label="鑱旂郴浜�" prop="HLinkMan">
                         <el-input v-model="formData.HLinkMan" placeholder="璇疯緭鍏ヨ仈绯讳汉"></el-input>
                       </el-form-item>
                     </el-col>
                     <el-col :span="12">
-                      <el-form-item label="鑱旂郴鐢佃瘽">
+                      <el-form-item label="鑱旂郴鐢佃瘽" prop="HLinkPhone">
                         <el-input v-model="formData.HLinkPhone" placeholder="璇疯緭鍏ヨ仈绯荤數璇�"></el-input>
                       </el-form-item>
                     </el-col>
@@ -148,7 +148,7 @@
 
                   <el-row :gutter="20">
                     <el-col :span="12">
-                      <el-form-item label="鍦板潃">
+                      <el-form-item label="鍦板潃" prop="HAddress">
                         <el-input v-model="formData.HAddress" placeholder="璇疯緭鍏ュ湴鍧�"></el-input>
                       </el-form-item>
                     </el-col>
@@ -220,7 +220,7 @@
                       </el-form-item>
                     </el-col>
                     <el-col :span="12">
-                      <el-form-item label="鍦板尯">
+                      <el-form-item label="鍦板尯" prop="HAreaID">
                         <el-input 
                           v-model="formData.HAreaName" 
                           placeholder="璇烽�夋嫨鍦板尯"
@@ -280,7 +280,7 @@
 
                   <el-row :gutter="20">
                     <el-col :span="12">
-                      <el-form-item label="瀹㈡埛鐘舵��">
+                      <el-form-item label="瀹㈡埛鐘舵��" prop="HCusStatus">
                         <el-select v-model="formData.HCusStatus" placeholder="璇烽�夋嫨瀹㈡埛鐘舵��" style="width: 100%">
                           <el-option label="娼滃湪" value="101"></el-option>
                           <el-option label="鍚堟牸" value="102"></el-option>
@@ -548,6 +548,7 @@
     this.initData()
     this.loadOrganizations()
     this.handleOperationType()
+    this.setConditionalRules()
   },
   methods: {
     initData() {
@@ -708,44 +709,95 @@
     },
     
     // 淇濆瓨
-    handleSave() {
-      this.$refs.form.validate(valid => {
-        if (valid) {
-          if (!this.validateForm()) {
-            return
-          }
-          
-          const formData = { ...this.formData }
-          formData.HStopflag = formData.HStopflag ? 'true' : 'false'
-          
-          let url = `${this.baseURL}/Gy_Customer/AddBill`
-          let params = { oMain: JSON.stringify(formData) + ';' + this.user }
-          
-          if (this.operationType === 3) {
-            // 缂栬緫淇濆瓨
-            url = `${this.baseURL}/Gy_Customer/AddBill1`
-            params = { 
-              oMain: JSON.stringify(formData) + ';' + this.linterid + ';' + this.user + ';Gy_Customer_Edit'
-            }
-          }
-          
-          axios.post(url, params)
-            .then(response => {
-              if (response.data.count === 1) {
-                this.$modal.msgSuccess(response.data.Message)
-                this.saveDisabled = true
-                this.saveConfig()
-                this.openEdit = false
-                this.$emit('editClose', true)
-              } else {
-                this.$modal.msgError(response.data.Message)
-              }
-            })
-            .catch(error => {
-              this.$modal.msgError('淇濆瓨澶辫触!')
-            })
-        }
+    async handleSave() {
+      const validMain = await new Promise(resolve => {
+        this.$refs.form.validate(valid => resolve(valid))
       })
+
+      let validOther = true
+      if (this.$refs.formOther) {
+        validOther = await new Promise(resolve => {
+          this.$refs.formOther.validate(valid => resolve(valid))
+        })
+      }
+
+      if (validMain && validOther) {
+        if (!this.validateForm()) {
+          return
+        }
+
+        const formData = { ...this.formData }
+        formData.HStopflag = formData.HStopflag ? 'true' : 'false'
+
+        let url = `${this.baseURL}/Gy_Customer/AddBill`
+        let params = { oMain: JSON.stringify(formData) + ';' + this.user }
+
+        if (this.operationType === 3) {
+          // 缂栬緫淇濆瓨
+          url = `${this.baseURL}/Gy_Customer/AddBill1`
+          params = { 
+            oMain: JSON.stringify(formData) + ';' + this.linterid + ';' + this.user + ';Gy_Customer_Edit'
+          }
+        }
+
+        axios.post(url, params)
+          .then(response => {
+            if (response.data.count === 1) {
+              this.$modal.msgSuccess(response.data.Message)
+              this.saveDisabled = true
+              this.saveConfig()
+              this.openEdit = false
+              this.$emit('editClose', true)
+            } else {
+              this.$modal.msgError(response.data.Message)
+            }
+          })
+          .catch(error => {
+            this.$modal.msgError('淇濆瓨澶辫触!')
+          })
+      }
+    },
+
+    setConditionalRules() {
+      this.rules.HLinkMan = [
+        { validator: this.validateRequiredIfAdd, trigger: 'blur', message: '璇疯緭鍏ヨ仈绯讳汉' }
+      ]
+
+      this.rules.HLinkPhone = [
+        { validator: this.validateRequiredIfAdd, trigger: 'blur', message: '璇疯緭鍏ヨ仈绯荤數璇�' }
+      ]
+
+      this.rules.HAddress = [
+        { validator: this.validateRequiredIfAdd, trigger: 'blur', message: '璇疯緭鍏ュ湴鍧�' }
+      ]
+
+      this.rules.HAreaID = [
+        { validator: this.validateRequiredIfAdd, trigger: 'change', message: '璇烽�夋嫨鍦板尯' }
+      ]
+
+      this.rules.HCusStatus = [
+        { validator: this.validateRequiredIfAdd, trigger: 'change', message: '璇烽�夋嫨瀹㈡埛鐘舵��' }
+      ]
+    },
+
+    validateRequiredIfAdd(rule, value, callback) {
+      if (this.operationType !== 1) {
+        return callback()
+      }
+
+      if (value === null || value === undefined) {
+        return callback(new Error(rule.message || '璇ラ」涓哄繀濉�'))
+      }
+
+      if (typeof value === 'string' && value.trim() === '') {
+        return callback(new Error(rule.message || '璇ラ」涓哄繀濉�'))
+      }
+
+      if (value === '0') {
+        return callback(new Error(rule.message || '璇ラ」涓哄繀濉�'))
+      }
+
+      return callback()
     },
     
     // 琛ㄥ崟楠岃瘉
diff --git a/src/views/GyCustomer/index.vue b/src/views/GyCustomer/index.vue
index 06f328a..e14f775 100644
--- a/src/views/GyCustomer/index.vue
+++ b/src/views/GyCustomer/index.vue
@@ -29,14 +29,14 @@
                   <el-row>
                     <el-col :span="7">
                       <el-select v-model="queryParams.ColName" placeholder="璇烽�夋嫨" style="width: 100%">
-                        <el-option value="0" label=""></el-option>
+                        <!-- <el-option value="0" label=""></el-option> -->
                         <el-option v-for="(item, index) in visibleColumns" :key="index" :label="item.title"
                           :value="item.field"></el-option>
                       </el-select>
                     </el-col>
                     <el-col :span="6" style="padding: 0 10px">
                       <el-select v-model="queryParams.Comparator" placeholder="璇烽�夋嫨" style="width: 100%">
-                        <el-option value="0" label=""></el-option>
+                        <!-- <el-option value="0" label=""></el-option> -->
                         <el-option v-for="(item, index) in comparatorList" :key="index" :label="item.label"
                           :value="item.value"></el-option>
                       </el-select>
@@ -51,14 +51,14 @@
                   <el-row>
                     <el-col :span="7">
                       <el-select v-model="queryParams.ColName1" placeholder="璇烽�夋嫨" style="width: 100%">
-                        <el-option value="0" label=""></el-option>
+                        <!-- <el-option value="0" label=""></el-option> -->
                         <el-option v-for="(item, index) in visibleColumns" :key="index" :label="item.title"
                           :value="item.field"></el-option>
                       </el-select>
                     </el-col>
                     <el-col :span="6" style="padding: 0 10px">
                       <el-select v-model="queryParams.Comparator1" placeholder="璇烽�夋嫨" style="width: 100%">
-                        <el-option value="0" label=""></el-option>
+                        <!-- <el-option value="0" label=""></el-option> -->
                         <el-option v-for="(item, index) in comparatorList" :key="index" :label="item.label"
                           :value="item.value"></el-option>
                       </el-select>
@@ -73,14 +73,14 @@
                   <el-row>
                     <el-col :span="7">
                       <el-select v-model="queryParams.ColName2" placeholder="璇烽�夋嫨" style="width: 100%">
-                        <el-option value="0" label=""></el-option>
+                        <!-- <el-option value="0" label=""></el-option> -->
                         <el-option v-for="(item, index) in visibleColumns" :key="index" :label="item.title"
                           :value="item.field"></el-option>
                       </el-select>
                     </el-col>
                     <el-col :span="6" style="padding: 0 10px">
                       <el-select v-model="queryParams.Comparator2" placeholder="璇烽�夋嫨" style="width: 100%">
-                        <el-option value="0" label=""></el-option>
+                        <!-- <el-option value="0" label=""></el-option> -->
                         <el-option v-for="(item, index) in comparatorList" :key="index" :label="item.label"
                           :value="item.value"></el-option>
                       </el-select>
@@ -301,12 +301,12 @@
         HNumber: null,
         HName: null,
         HNumber2: null,
-        ColName: "0",
-        ColName1: "0",
-        ColName2: "0",
-        Comparator: "0",
-        Comparator1: "0",
-        Comparator2: "0",
+        ColName: "",
+        ColName1: "",
+        ColName2: "",
+        Comparator: "",
+        Comparator1: "",
+        Comparator2: "",
         ColContent: "",
         ColContent1: "",
         ColContent2: "",
@@ -739,6 +739,13 @@
     },
 
     handleRefresh() {
+      if (this.$refs.tableData && this.$refs.tableData.clearSelection) {
+        this.$refs.tableData.clearSelection();
+      }
+      this.selectedRow = null;
+      this.ids = [];
+      this.single = true;
+      this.multiple = true;
       this.getList();
     },
 
@@ -798,7 +805,7 @@
 
     rowStyle({ row, rowIndex }) {
       if (this.ids.includes(row.hmainid)) {
-        return { background: "#ecf5ff" };
+        return {  };
       }
     },
 
diff --git a/src/views/gyMaterial/GyMaterial.vue b/src/views/gyMaterial/GyMaterial.vue
index f5b0936..3b24fb6 100644
--- a/src/views/gyMaterial/GyMaterial.vue
+++ b/src/views/gyMaterial/GyMaterial.vue
@@ -78,7 +78,7 @@
                         placeholder="璇烽�夋嫨"
                         style="width: 100%"
                       >
-                        <el-option value="0" label=""></el-option>
+                        <!-- <el-option value="" label=""></el-option> -->
                         <el-option
                           v-for="(item, index) in visibleColumns"
                           :key="index"
@@ -93,7 +93,7 @@
                         placeholder="璇烽�夋嫨"
                         style="width: 100%"
                       >
-                        <el-option value="0" label=""></el-option>
+                        <!-- <el-option value="0" label=""></el-option> -->
                         <el-option
                           v-for="(item, index) in comparatorList"
                           :key="index"
@@ -120,7 +120,7 @@
                         placeholder="璇烽�夋嫨"
                         style="width: 100%"
                       >
-                        <el-option value="0" label=""></el-option>
+                        <!-- <el-option value="0" label=""></el-option> -->
                         <el-option
                           v-for="(item, index) in visibleColumns"
                           :key="index"
@@ -135,7 +135,7 @@
                         placeholder="璇烽�夋嫨"
                         style="width: 100%"
                       >
-                        <el-option value="0" label=""></el-option>
+                        <!-- <el-option value="0" label=""></el-option> -->
                         <el-option
                           v-for="(item, index) in comparatorList"
                           :key="index"
@@ -162,7 +162,7 @@
                         placeholder="璇烽�夋嫨"
                         style="width: 100%"
                       >
-                        <el-option value="0" label=""></el-option>
+                        <!-- <el-option value="0" label=""></el-option> -->
                         <el-option
                           v-for="(item, index) in visibleColumns"
                           :key="index"
@@ -177,7 +177,7 @@
                         placeholder="璇烽�夋嫨"
                         style="width: 100%"
                       >
-                        <el-option value="0" label=""></el-option>
+                        <!-- <el-option value="0" label=""></el-option> -->
                         <el-option
                           v-for="(item, index) in comparatorList"
                           :key="index"
@@ -642,12 +642,12 @@
         HModel: null,
         HOrgID: null,
         HProject: null,
-        ColName: "0",
-        ColName1: "0",
-        ColName2: "0",
-        Comparator: "0",
-        Comparator1: "0",
-        Comparator2: "0",
+        ColName: "",
+        ColName1: "",
+        ColName2: "",
+        Comparator: "",
+        Comparator1: "",
+        Comparator2: "",
         ColContent: "",
         ColContent1: "",
         ColContent2: "",
@@ -713,7 +713,9 @@
         .then((response) => {
           let data = response.data.data[0];
           this.user = data.Czymc;
+          
           this.getOrganizations();
+          this.queryParams.HOrgID = data.HUSEORGID;
           this.getTreeData();
           this.getProjectOptions();
           this.getList();
@@ -730,9 +732,9 @@
         .then((response) => {
           if (response.data.count == 1) {
             this.organizationOptions = response.data.data;
-            if (this.organizationOptions.length > 0) {
-              this.queryParams.HOrgID = this.organizationOptions[0].ID;
-            }
+            // if (this.organizationOptions.length > 0) {
+            //   this.queryParams.HOrgID = this.organizationOptions[0].ID;
+            // }
           }
         })
         .catch((error) => {
@@ -1128,6 +1130,14 @@
     },
     
     handleRefresh() {
+      // 鍒锋柊鏃舵竻闄よ〃鏍奸�夋嫨骞堕噸缃浉鍏崇姸鎬侊紝淇濊瘉澶嶅埗/缂栬緫/鍒犻櫎/瀹℃牳绛夋寜閽绂佺敤
+      if (this.$refs.tableData && this.$refs.tableData.clearSelection) {
+        this.$refs.tableData.clearSelection();
+      }
+      this.selectedRow = null;
+      this.ids = [];
+      this.single = true;
+      this.multiple = true;
       this.getList();
     },
     
@@ -1224,7 +1234,8 @@
     // 琛屾牱寮�
     rowStyle({ row, rowIndex }) {
       if (this.ids.includes(row.hmainid)) {
-        return { background: "#ecf5ff" };
+        return {  };
+        // background: "#ecf5ff"
       }
     },
     

--
Gitblit v1.9.1