From f0420251442ac6f7bfb6beafa37ad045b4f6478a Mon Sep 17 00:00:00 2001
From: 廖井涛 <2265517004@qq.com>
Date: 星期三, 31 十二月 2025 15:49:05 +0800
Subject: [PATCH] 报工多工序,用户多工序修改

---
 north-glass-erp/northglass-erp/src/views/system/user/UserList.vue |   90 ++++++++++++++++++++++++++++++++++----------
 1 files changed, 69 insertions(+), 21 deletions(-)

diff --git a/north-glass-erp/northglass-erp/src/views/system/user/UserList.vue b/north-glass-erp/northglass-erp/src/views/system/user/UserList.vue
index 03a0511..2f6294f 100644
--- a/north-glass-erp/northglass-erp/src/views/system/user/UserList.vue
+++ b/north-glass-erp/northglass-erp/src/views/system/user/UserList.vue
@@ -12,7 +12,7 @@
 const dialogVisibleProcess = ref(false)
 let roleList = ref([])
 //宸ュ簭
-const processValue = ref()
+const processValue = ref([])
 let userRole= ref({
   userId:'',
   roles:[]
@@ -94,12 +94,39 @@
     arr.forEach(item=>{
       let bValues = item.userRoleList.map(item => item.role);
       item.role = bValues.join(',')
+      // 鏍稿績锛氬鐞嗗伐搴忓垪鏄剧ず锛堣浆涓哄垏鍓诧紝纾ㄨ竟鏍煎紡锛�
+      item.address = formatProcessForTable(item.address)
     })
     gridOptions.data = res.data.users[0]
     roleList.value = res.data.role[0]
   })
 
 })
+
+// 宸ュ叿鍑芥暟锛氱粺涓�澶勭悊宸ュ簭鏁版嵁涓洪�楀彿鍒嗛殧瀛楃涓诧紙閫傞厤琛ㄦ牸鏄剧ず锛�
+const formatProcessForTable = (processData) => {
+  if (!processData) return ''
+
+  // 姝ラ1锛氬鐞咼SON瀛楃涓诧紙濡� "\"[\"鍒囧壊\",\"纾ㄨ竟\"]\""锛�
+  let str = String(processData).trim()
+  if (str.startsWith('"') && str.endsWith('"')) {
+    str = str.slice(1, -1)
+  }
+
+  // 姝ラ2锛氬皾璇曡В鏋愪负鏁扮粍
+  try {
+    const arr = JSON.parse(str)
+    if (Array.isArray(arr)) {
+      return arr.join(',') // 涓枃閫楀彿鍒嗛殧锛屽闇�鑻辨枃閫楀彿鏀逛负 ','
+    }
+  } catch (e) {
+    // 瑙f瀽澶辫触锛岀洿鎺ヤ娇鐢ㄥ師瀛楃涓诧紙濡傚凡涓�"鍒囧壊锛岀(杈�"锛�
+    return str.replace(/[,锛宂/g, '锛�') // 缁熶竴涓轰腑鏂囬�楀彿
+  }
+
+  // 鍏滃簳锛氶潪鏁扮粍鏍煎紡鐩存帴杩斿洖
+  return str
+}
 
 const getTableRow =  (row,type) => {
   switch (type) {
@@ -126,11 +153,17 @@
     case 'editProcess': {
       dialogVisibleProcess.value = true
       processRow.value.userId = row.id
+      // 娓呯┖涔嬪墠閫夋嫨鐨勫伐搴�
+      processValue.value = []
+
+      processValue.value = row.address ? row.address.split(',').filter(item => item.trim()) : []
       break
     }
 
   }
 }
+
+
 
 const handleClose = (done) => {
   userRole.value.roles = []
@@ -156,20 +189,28 @@
 }
 
 const updateProcess = () => {
-  let userId=processRow.value.userId
-  if (processValue.value!=null){
-    request.post(`userInfo/updateProcess/${userId}/${processValue.value}`).then(res=>{
-      if(res.code==200 && res.data===true){
-        ElMessage.success(t('basicData.msg.saveSuccess'))
-        router.push({path:'/main/user/userList',query:{random:Math.random()}})
-      }
+  const userId = processRow.value.userId
+  // 妫�鏌ユ槸鍚﹂�夋嫨浜嗗伐搴�
+  let processStr=""
+  if (processValue.value && processValue.value.length > 0) {
+    // 灏嗛�変腑鐨勫伐搴忔暟缁勮浆涓哄瓧绗︿覆锛堟牴鎹悗绔渶姹傝皟鏁存牸寮忥級
+     processStr = JSON.stringify(processValue.value)
 
-    })
-    dialogVisible.value = false
-  }else {
-    ElMessage.warning(t('report.pleaseSelectAProcessFirst'))
   }
-
+  try {
+    request.post(`userInfo/updateProcess/${userId}`,{processList: processStr}).then(res => {
+      if (res.code == 200 && res.data === true) {
+        ElMessage.success(t('basicData.msg.saveSuccess'))
+        router.push({ path: '/main/user/userList', query: { random: Math.random() } })
+        // 鍏抽棴宸ュ簭寮圭獥
+        dialogVisibleProcess.value = false
+      }
+    })
+  }catch (err) {
+    // 鎹曡幏缃戠粶閿欒銆佹帴鍙f姤閿欑瓑鎵�鏈夊紓甯�
+    console.error('鍒濆鍖栧伐搴忓け璐ワ細', err);
+    ElMessage.error('鍒濆鍖栨暟鎹け璐ワ紝璇峰埛鏂伴噸璇�');
+  }
 }
 
 
@@ -237,14 +278,21 @@
         width="30%"
         :before-close="handleClose"
     >
-      <el-select v-model="processValue" clearable :placeholder="$t('reportingWorks.selectProcess')" default-value="default_city" style="width: 120px">
-        <el-option
-            v-for="item in processRow['process']"
-            :key="item.id"
-            :label="item.basic_name"
-            :value="item.basic_name"
-        />
-      </el-select>
+      <div class="process-checkbox-group">
+        <el-checkbox-group
+            v-model="processValue"
+            class="checkbox-group"
+        >
+          <el-checkbox
+              v-for="item in processRow.process"
+              :key="item.id"
+              :label="item.basic_name"
+              class="checkbox-item"
+          >
+            {{ item.basic_name }}
+          </el-checkbox>
+        </el-checkbox-group>
+      </div>
       <template #footer>
       <span class="dialog-footer">
         <el-button @click="dialogVisibleProcess = false">{{ $t('basicData.cancelButtonText') }}</el-button>

--
Gitblit v1.8.0