695593266@qq.com 6 napja
szülő
commit
60261fc7c3

+ 77 - 42
src/views/factoryModel/station/components/edit.vue

@@ -85,42 +85,6 @@
             </el-form-item>
           </el-col>
 
-          <el-col :span="8">
-            <el-form-item label="班组:" prop="extInfo.teamId">
-              <el-select
-                style="width: 100%"
-                v-model="form.extInfo.teamId"
-                clearable
-                :filterable="true"
-              >
-                <el-option
-                  v-for="item in teamPagerList"
-                  :key="item.id"
-                  :label="item.name"
-                  :value="item.id"
-                  @click.native="userListFn(item)"
-                />
-              </el-select>
-            </el-form-item>
-          </el-col>
-          <el-col :span="8">
-            <el-form-item label="人员:" prop="extInfo.userIds">
-              <el-select
-                style="width: 100%"
-                v-model="form.extInfo.userIds"
-                multiple
-                clearable
-              >
-                <el-option
-                  v-for="item in userList"
-                  :key="item.id"
-                  :label="item.name"
-                  :value="item.id"
-                />
-              </el-select>
-            </el-form-item>
-          </el-col>
-
           <el-col :span="8">
             <el-form-item label="所属区域:" prop="location_city">
               <area-select
@@ -216,6 +180,43 @@
             </el-form-item>
           </el-col>
 
+          <el-col :span="8">
+            <el-form-item label="班组:" prop="extInfo.teamId">
+              <el-select
+                style="width: 100%"
+                v-model="form.extInfo.teamId"
+                clearable
+                :filterable="true"
+                :disabled="!form.extInfo.factoryId"
+                @change="change_team"
+              >
+                <el-option
+                  v-for="item in teamPagerList"
+                  :key="item.id"
+                  :label="item.name"
+                  :value="item.id"
+                />
+              </el-select>
+            </el-form-item>
+          </el-col>
+          <el-col :span="8">
+            <el-form-item label="人员:" prop="extInfo.userIds">
+              <el-select
+                style="width: 100%"
+                v-model="form.extInfo.userIds"
+                multiple
+                clearable
+              >
+                <el-option
+                  v-for="item in userList"
+                  :key="item.id"
+                  :label="item.name"
+                  :value="item.id"
+                />
+              </el-select>
+            </el-form-item>
+          </el-col>
+
           <el-col :span="8">
             <el-form-item label="负责人部门:" prop="extInfo.principalDep">
               <ele-tree-select
@@ -606,19 +607,31 @@
       this.getGs();
       this.getFactoryList();
       this.getBasicAreaList();
-      this.getteampagerList();
     },
     methods: {
       chooseAsset() {
         this.$refs.productRefs.open(this.form.extInfo, '选择设备', '4');
       },
+      change_team(teamId) {
+        const team = this.teamPagerList.find((item) => item.id === teamId);
+        this.userListFn(team || {});
+      },
       userListFn(e, init) {
-        listUserByIds([e.teamId || e.id]).then((res) => {
+        const teamId = e.teamId || e.id;
+        if (!teamId) {
+          if (!this.form.extInfo.teamId) {
+            this.userList = [];
+          }
+          this.form.extInfo.userIds = [];
+          this.form.extInfo.workCenterId = null;
+          return;
+        }
+        listUserByIds([teamId]).then((res) => {
           this.userList = res;
         });
         if (!init) {
           this.form.extInfo.userIds = [];
-          if (e.workCenterIds.length) {
+          if (e.workCenterIds && e.workCenterIds.length) {
             this.form.extInfo.workCenterId = e.workCenterIds[0];
           }
         }
@@ -684,8 +697,11 @@
           // 请求下拉数据
           if (this.form.extInfo.factoryId) {
             this.getlistCf();
+            this.getteampagerList(this.form.extInfo.factoryId);
+          }
+          if (!this.form.extInfo.teamId) {
+            this.userList = [];
           }
-          this.userList = [];
           if (this.form.extInfo.workshopPlanId) {
             this.getListWorkshopByParentId(true);
           }
@@ -703,10 +719,15 @@
         this.getListProduce();
       },
 
-      getteampagerList() {
+      getteampagerList(factoryId) {
+        if (!factoryId) {
+          this.teamPagerList = [];
+          return;
+        }
         let param = {
           pageNum: 1,
-          size: -1
+          size: -1,
+          factoryId
         };
         getteampage(param).then((res) => {
           this.teamPagerList = res.list || [];
@@ -864,6 +885,12 @@
       },
       // 选择工厂
       change_factoryId() {
+        this.form.extInfo.teamId = null;
+        this.form.extInfo.userIds = [];
+        this.form.extInfo.workCenterId = null;
+        this.teamPagerList = [];
+        this.userList = [];
+
         this.form.extInfo.workshopPlanId = '';
         this.workshopPlanList = [];
 
@@ -875,8 +902,13 @@
         this.options.productionLineId = [];
 
         this.getlistCf();
+        this.getteampagerList(this.form.extInfo.factoryId);
       },
       getlistCf() {
+        if (!this.form.extInfo.factoryId) {
+          this.workshopPlanList = [];
+          return;
+        }
         let par = {
           type: 2,
           parentId: this.form.extInfo.factoryId,
@@ -897,6 +929,9 @@
       change_workshop() {
         this.form.leaderId = '';
         this.options.leaderId = [];
+        if (this.form.extInfo.principalDep) {
+          this.getUserPage();
+        }
         this.getlistFactoryLineByParentId();
       },
 

+ 11 - 4
src/views/system/parmasManage/index-new.vue

@@ -477,21 +477,22 @@
           .split(/[;;,,、]/)
           .map((part) => part.trim())
           .map((part) => {
-            const optionMatch = part.match(/^(\d+)\s*[::]?\s*(.+)$/);
+            const optionMatch = part.match(/^(\d+)\s*[::、,,;;]?\s*(.+)$/);
             if (!optionMatch) return null;
             return {
               value: optionMatch[1],
-              label: optionMatch[2].replace(/[;;,,。]+$/, '').trim()
+              label: this.normalizeOptionLabel(optionMatch[2])
             };
           })
           .filter(Boolean);
       },
       parseCompactOptions(text) {
         const options = [];
-        const optionReg = /(\d+)\s*[::]?\s*([^0-9]+?)(?=\s*\d+\s*[::]?|$)/g;
+        const optionReg =
+          /(\d+)\s*[::、,,;;]?\s*([^0-9]+?)(?=\s*\d+\s*[::、,,;;]?|$)/g;
         let match = optionReg.exec(text);
         while (match) {
-          const label = match[2].replace(/[;;,,。]+$/, '').trim();
+          const label = this.normalizeOptionLabel(match[2]);
           if (label) {
             options.push({
               value: match[1],
@@ -502,6 +503,12 @@
         }
         return options;
       },
+      normalizeOptionLabel(label) {
+        return String(label || '')
+          .replace(/^[\s::、,,;;。]+/, '')
+          .replace(/[\s::、,,;;。]+$/, '')
+          .trim();
+      },
       resolveViewType(param, options) {
         const code = String(param.code || '');
         const name = String(param.name || '');