From c47ec7b37e7f68c49b40fc4b59098e79626e66de Mon Sep 17 00:00:00 2001
From: xwt <2740516069@qq.com>
Date: 星期日, 03 八月 2025 13:39:14 +0800
Subject: [PATCH] 首检巡检

---
 pages/QC/XJ/Add.vue |  150 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 142 insertions(+), 8 deletions(-)

diff --git a/pages/QC/XJ/Add.vue b/pages/QC/XJ/Add.vue
index da84f2f..7140538 100644
--- a/pages/QC/XJ/Add.vue
+++ b/pages/QC/XJ/Add.vue
@@ -24,10 +24,18 @@
               <view class="info-value">{{ formData.createDate }}</view>
             </view>
             <view class="info-item">
+              <view class="info-label">鐢熶骇杞﹂棿</view>
+              <picker v-if="isUpdate" class="picker-input" name="selector" :range="departmentList" range-key="departmentname"
+                      @change="onDepartmentChange">
+                <view class="picker-value">{{ getSelectedDepartmentName() || '璇烽�夋嫨杞﹂棿' }}</view>
+              </picker>
+              <view v-else class="info-value">{{ WORKSHOP }}</view>
+            </view>
+            <view class="info-item">
               <view class="info-label">绾夸綋缂栧彿</view>
-              <picker v-if="isUpdate" class="picker-input" name="selector" :range="DAA020List"
+              <picker v-if="isUpdate" class="picker-input" name="selector" :range="filteredDAA020List"
                       @change="onDaa020Change">
-                <view class="picker-value">{{ DAA020List[DAA020Index] || '璇烽�夋嫨' }}</view>
+                <view class="picker-value">{{ filteredDAA020List[DAA020Index] || '璇烽�夋嫨' }}</view>
               </picker>
               <view v-else class="info-value">{{ formData.daa020 }}</view>
             </view>
@@ -40,7 +48,7 @@
               <view v-else class="info-value">{{ formData.itemNo }}</view>
             </view>
             <view class="info-item">
-              <view class="info-label">璁″垝缂栧彿</view>
+              <view class="info-label">宸ュ崟鍗曞彿</view>
               <picker v-if="isUpdate" class="picker-input" name="selector" :range="DAA001List"
                       @change="onDaa001Change">
                 <view class="picker-value">{{ DAA001List[DAA001Index] || '璇烽�夋嫨' }}</view>
@@ -114,6 +122,8 @@
         <button class="action-btn warning" v-if="!isUpdate && !isShowTable" @click="saveRemarks">娣诲姞涓嶅悎鏍兼弿杩�</button>
         <button class="action-btn primary" v-if="isShowTable" @click="getTable">鑾峰彇妫�楠岄」鐩�</button>
         <button class="action-btn primary" v-if="isShowTable && isUpdate" @click="saveTable">鐢熸垚妫�楠岄」鐩�</button>
+        <button class="action-btn success" v-if="!isUpdate && !isShowTable" @click="getGenUpdate">鑾峰彇妫�楠岄」鐩�</button>
+        <button class="action-btn success" v-if="!isUpdate && !isShowTable" @click="submitInspection">鎻愪氦妫�楠�</button>
       </view>
       <!-- 淇敼涓嶅悎鏍兼弿杩板脊鍑烘 -->
       <view v-if="remarksPopup" class="overlay">
@@ -161,6 +171,7 @@
   
         DAA020List: [],
         DAA020Index: -1,
+        filteredDAA020List: [],
   
         DAA001List: [],
         DAA001Index: -1,
@@ -184,6 +195,11 @@
   
         remarks: "",
         remarksPopup: false,
+        
+        // 閮ㄩ棬閫夋嫨鐩稿叧
+        departmentList: [],
+        selectedDepartment: '',
+        WORKSHOP: '',
       };
     },
     onLoad(options) {
@@ -213,7 +229,11 @@
         }).then(res => {
           this.lineList = res.data.tbBillList;
           this.DAA020List = res.data.tbBillList.map(item => item.lineName);
+          this.filteredDAA020List = this.DAA020List; // 鍒濆鏃舵樉绀烘墍鏈夌嚎浣�
         })
+        
+        // 鑾峰彇閮ㄩ棬鍒楄〃
+        this.loadDepartments();
       }
     },
     methods: {
@@ -260,13 +280,10 @@
       },
       getItem() {
   
-        if (this.isSubmit) {
-          this.$showMessage("姝ょ墿鏂欐棤鍚敤鐨勬楠岄」鐩紝璇风淮鎶�!");
-          return;
-        }
+
   
         if (!this.formData.billNo) {
-          this.$showMessage("璇烽�夋嫨璁″垝缂栧彿");
+          this.$showMessage("璇烽�夋嫨宸ュ崟鍗曞彿");
           return;
         }
   
@@ -284,6 +301,81 @@
           this.isUpdate = false;
         });
       },
+      
+      // 鍔犺浇閮ㄩ棬鍒楄〃
+      loadDepartments() {
+        this.$post({
+          url: "/XJ/getDepartmentsWithLines"
+        }).then(res => {
+          if (res.status === 0) {
+            this.departmentList = res.data.tbBillList;
+          } else {
+            this.$showMessage("鑾峰彇閮ㄩ棬鍒楄〃澶辫触");
+          }
+        });
+      },
+      
+      // 閮ㄩ棬閫夋嫨鍙樺寲澶勭悊
+      onDepartmentChange(e) {
+        const index = e.detail.value;
+        if (index >= 0 && index < this.departmentList.length) {
+          const selectedDept = this.departmentList[index];
+          this.selectedDepartment = selectedDept.departmentid;
+          this.WORKSHOP = selectedDept.departmentname;
+          
+          // 鏍规嵁閫変腑鐨勯儴闂ㄨ繃婊ょ嚎浣撳垪琛�
+          this.filterLinesByDepartment(selectedDept.departmentid);
+          
+          // 淇濆瓨閮ㄩ棬閫夋嫨
+          this.saveDepartmentSelection();
+        }
+      },
+      
+      // 鑾峰彇閫変腑鐨勯儴闂ㄥ悕绉�
+      getSelectedDepartmentName() {
+        if (!this.selectedDepartment) return '';
+        const dept = this.departmentList.find(item => item.departmentid === this.selectedDepartment);
+        return dept ? dept.departmentname : '';
+      },
+      
+      // 淇濆瓨閮ㄩ棬閫夋嫨
+      saveDepartmentSelection() {
+        if (this.formData.id && this.selectedDepartment) {
+          this.$post({
+            url: "/XJ/saveDepartmentSelection",
+            data: {
+              id: this.formData.id,
+              departmentId: this.selectedDepartment,
+              departmentName: this.WORKSHOP
+            }
+          }).then(res => {
+            if (res.status === 0) {
+              this.$showMessage("閮ㄩ棬閫夋嫨宸蹭繚瀛�");
+            }
+          });
+        }
+      },
+      
+      // 鏍规嵁閮ㄩ棬杩囨护绾夸綋鍒楄〃
+      filterLinesByDepartment(departmentId) {
+        this.$post({
+          url: "/XJ/getLinesByDepartment",
+          data: {
+            departmentId: departmentId
+          }
+        }).then(res => {
+          if (res.status === 0) {
+            this.filteredDAA020List = res.data.tbBillList.map(item => item.lineName);
+            this.lineList = res.data.tbBillList;
+            // 閲嶇疆绾夸綋閫夋嫨绱㈠紩
+            this.DAA020Index = -1;
+            this.formData.daa020 = '';
+          } else {
+            this.$showMessage("鑾峰彇绾夸綋鍒楄〃澶辫触");
+          }
+        });
+      },
+      
       //鐢熶骇绾垮埆閫夋嫨骞跺垵濮嬭瘽宸ュ崟鍙�
       onDaa020Change(event) {
         //鑾峰彇鐢熶骇绾垮埆鐨勪笅鏍囧湴鍧�
@@ -480,6 +572,43 @@
           this.isUpdate = false;
           this.init();
         })
+      },
+      submitInspection() {
+        if (this.formData.id) {
+          this.$post({
+            url: "/XJ/SjSubmit",
+            data: {
+              id: this.formData.id,
+              userNo: this.$loginInfo.account
+            }
+          }).then(res => {
+            if (res.data.tbBillList) {
+              this.$showMessage("鎻愪氦鎴愬姛");
+              this.init();
+            }
+          });
+        }
+      },
+      getGenUpdate() {
+        if (!this.formData.id || !this.formData.releaseNo) {
+          this.$showMessage("璇峰厛淇濆瓨妫�楠屽崟锛�");
+          return;
+        }
+        this.$post({
+          url: "/XJ/GenUpdate",
+          data: {
+            id: this.formData.id,
+            no: this.formData.releaseNo,
+            user: this.$loginInfo.account
+          }
+        }).then(res => {
+          if (res.data.result === 0) {
+            this.$showMessage("鑾峰彇妫�楠岄」鐩垚鍔�");
+            this.init();
+          } else {
+            this.$showMessage(res.data.message || "鑾峰彇澶辫触");
+          }
+        });
       }
     },
     onShow() {
@@ -725,6 +854,11 @@
     color: white;
   }
   
+  .action-btn.success {
+    background-color: #2ecc71;
+    color: white;
+  }
+  
   /* 寮瑰嚭妗嗘牱寮� */
   .overlay {
     position: fixed;

--
Gitblit v1.9.3