Parcourir la source

Merge branch 'dev' into test

lihaiting il y a 4 jours
Parent
commit
c179d5b50c

+ 11 - 11
src/views/material/BOMmanage/components/detailedList.vue

@@ -501,17 +501,17 @@
             showOverflowTooltip: true,
             width: 100
           },
-          {
-            // 序号:普通列 + 前端插槽渲染行号(见模板 v-slot:rowIndex),不绑定 sn;
-            // 也不能用 type: 'index':index 列不在列设置缓存里,会被 ele-pro-table 排到最前面。
-            prop: 'rowIndex',
-            columnKey: 'rowIndex',
-            label: '序号',
-            align: 'center',
-            width: 90,
-            showOverflowTooltip: true,
-            slot: 'rowIndex'
-          },
+          // {
+          //   // 序号:普通列 + 前端插槽渲染行号(见模板 v-slot:rowIndex),不绑定 sn;
+          //   // 也不能用 type: 'index':index 列不在列设置缓存里,会被 ele-pro-table 排到最前面。
+          //   prop: 'rowIndex',
+          //   columnKey: 'rowIndex',
+          //   label: '序号',
+          //   align: 'center',
+          //   width: 90,
+          //   showOverflowTooltip: true,
+          //   slot: 'rowIndex'
+          // },
           {
             prop: 'categoryCode',
             label: '物料编码',

+ 59 - 3
src/views/material/BOMmanage/detailsPop.vue

@@ -440,6 +440,7 @@
     deviceBomSubmit,
     hasNewVersion
   } from '@/api/material/BOM.js';
+  import { parameterGetByCode } from '@/api/system/dictionary-data';
 
   import baseInfo from './components/baseInfo.vue';
   import baseInfoSave from './components/baseInfoSave.vue';
@@ -691,12 +692,17 @@
           this.treeLoading = false;
           if (res?.code === '0') {
             if (res.data?.length > 0) {
-              this.treeList = res.data;
+              let treeData = res.data;
+              // 润天:左侧树同级节点按 sn 升序(与右侧 PBOM 明细同一口径);非润天(无 sn)保持原顺序
+              if (this.treeHasSn(treeData) || (await this.isRuntianEnv())) {
+                treeData = this.sortTreeBySn(treeData);
+              }
+              this.treeList = treeData;
               this.$nextTick(() => {
                 this.isNotData = true;
                 // 默认高亮第一个
-                this.$refs.treeRef.setCurrentKey(res.data[0].id);
-                this.handleNodeClick(res.data[0]);
+                this.$refs.treeRef.setCurrentKey(treeData[0].id);
+                this.handleNodeClick(treeData[0]);
               });
             } else {
               this.isNotData = false;
@@ -710,6 +716,56 @@
         this.treeLoading = false;
       },
 
+      // 树里是否带 sn(润天同步的 BOM 才有)
+      treeHasSn(nodes) {
+        return (nodes || []).some(
+          (node) =>
+            (node.sn !== null && node.sn !== undefined && Number(node.sn) > 0) ||
+            this.treeHasSn(node.children)
+        );
+      },
+
+      // 是否润天环境(系统参数 is_runtian)
+      async isRuntianEnv() {
+        try {
+          const data = await parameterGetByCode({ code: 'is_runtian' });
+          const val =
+            typeof data === 'object' && data !== null
+              ? data.value ?? data.paramValue ?? data.val
+              : data;
+          return val === '1' || val === 1 || val === true;
+        } catch (e) {
+          return false;
+        }
+      },
+
+      // 递归按 sn 升序(空/0 排最后,同 sn 按 id 兜底)
+      sortTreeBySn(nodes) {
+        if (!Array.isArray(nodes) || !nodes.length) {
+          return nodes;
+        }
+        const snOf = (node) => {
+          const sn = Number(node && node.sn);
+          return isNaN(sn) || sn <= 0 ? Number.MAX_SAFE_INTEGER : sn;
+        };
+        const sortRecursive = (list) => {
+          list.sort((a, b) => {
+            const diff = snOf(a) - snOf(b);
+            if (diff !== 0) {
+              return diff;
+            }
+            return String(a.id) < String(b.id) ? -1 : String(a.id) > String(b.id) ? 1 : 0;
+          });
+          list.forEach((item) => {
+            if (Array.isArray(item.children) && item.children.length) {
+              sortRecursive(item.children);
+            }
+          });
+        };
+        sortRecursive(nodes);
+        return nodes;
+      },
+
       handleNodeClick(data) {
         this.treeId = data.id;
         this.resourceBomId =

+ 1 - 0
src/views/rulesManagement/releaseRules/components/permitAdd.vue

@@ -973,6 +973,7 @@
           list = list.filter((i) => i.prop != 'formula');
         }
 
+        // 只有生产管控类才显示设备信息
         if (this.formData.reportWorkType != 5) {
           list = list.filter(
             (i) => !['substanceName', 'substanceCode'].includes(i.prop)

+ 19 - 139
src/views/system/organization/components/org-user-edit.vue

@@ -16,7 +16,7 @@
       :model="form"
       class="el-form-box"
       :rules="rules"
-      label-width="82px"
+      label-width="110px"
       :disabled="disabled"
     >
       <el-row :gutter="15">
@@ -46,9 +46,9 @@
               ></el-option>
             </el-select>
           </el-form-item>
-          <el-form-item label="所属机构:" prop="groupId">
+          <el-form-item label="主所属部门:" prop="groupId">
             <org-select
-              :data="institutionOptions"
+              :data="institutionList"
               placeholder="请选择所属机构"
               v-model="form.groupId"
               :disabled="!!form.loginName"
@@ -59,13 +59,13 @@
           <el-form-item label="隶属部门:">
             <el-cascader
               class="ele-block"
-              :options="deptOptions"
-              :placeholder="form.groupId ? '请选择隶属部门' : '请先选择所属机构'"
+              :options="organization"
+              placeholder="请选择隶属部门"
               :props="defaultProps"
               ref="deptRef"
               :show-all-levels="true"
               @change="handleChange"
-              :disabled="!!form.loginName || !form.groupId"
+              :disabled="!!form.loginName"
               v-model="form.deptIds"
               clearable
             ></el-cascader>
@@ -1422,8 +1422,6 @@
           value: 'id',
           label: 'name'
         },
-        // 上一次所属机构(用于判断用户是否真的换了机构,避免误清隶属部门)
-        lastGroupId: null,
 
         professionList: []
       };
@@ -1433,53 +1431,8 @@
       styleResponsive() {
         return this.$store.state.theme.styleResponsive;
       },
-      // 组织架构平铺数据(含父级,用于判断公司机构与部门归属)
-      orgFlatList() {
-        const result = [];
-        const walk = (nodes) => {
-          (nodes || []).forEach((item) => {
-            result.push(item);
-            walk(item.children);
-          });
-        };
-        walk(
-          this.institutionList && this.institutionList.length
-            ? this.institutionList
-            : this.organizationList
-        );
-        return result;
-      },
-      // 组织树全部 id 集合:parentId 不在其中的节点即公司机构
-      orgIdSet() {
-        return new Set(this.orgFlatList.map((item) => String(item.id)));
-      },
-      /*
-       * 所属机构下拉:只允许选择公司机构,非公司节点置灰保留层级;
-       * 已选节点即使不是公司也保留(置灰),避免回显成裸 id
-       */
-      institutionOptions() {
-        return this.buildInstitutionOptions(
-          this.institutionList && this.institutionList.length
-            ? this.institutionList
-            : this.organizationList
-        );
-      },
-      /*
-       * 隶属部门级联:与所属机构联动,只展示所选公司机构下的部门;
-       * 未选机构时为空(提示先选机构),所选机构不在组织树中时兜底展示整棵树
-       */
-      deptOptions() {
-        const groupId = this.form.groupId;
-        if (groupId == null || groupId === '') {
-          return [];
-        }
-        const company = this.orgFlatList.find(
-          (item) => String(item.id) === String(groupId)
-        );
-        if (!company) {
-          return this.copyOrgTree(this.organizationList);
-        }
-        return this.copyOrgTree(company.children || []);
+      organization() {
+        return this.setList(this.organizationList);
       },
       identityPhotosColumns() {
         return [
@@ -2020,74 +1973,15 @@
 
         this.professionList = res.list || [];
       },
-      /*
-       * 所属机构下拉数据:公司机构可选,其它节点置灰;
-       * 既不是公司又没有下级公司的纯部门节点直接丢弃,避免下拉被部门撑满
-       */
-      buildInstitutionOptions(list) {
-        const result = [];
-        // 编辑回显的机构(不限公司)保留在选项中,避免历史数据回显成裸 id
-        const selectedId = this.data ? this.data.groupId : null;
-        (list || []).forEach((item) => {
-          const children = this.buildInstitutionOptions(item.children);
-          const isCompany = this.isCompanyOrg(item);
-          const isSelected = String(item.id) === String(selectedId);
-          if (!isCompany && !isSelected && !children.length) {
-            return;
-          }
-          const node = { ...item, disabled: !isCompany };
-          if (children.length) {
-            node.children = children;
-          } else {
-            delete node.children;
-          }
-          result.push(node);
-        });
-        return result;
-      },
-      /* 组织树浅拷贝,避免直接改动父组件传入的数据 */
-      copyOrgTree(list) {
-        return (list || []).map((item) => {
-          const node = { ...item };
-          if (item.children && item.children.length) {
-            node.children = this.copyOrgTree(item.children);
-          } else {
-            delete node.children;
+      setList(list) {
+        return list.map((val) => {
+          val['disabled'] = val.id == this.form.groupId;
+          if (val.children) {
+            val.children = this.setList(val.children);
           }
-          return node;
+          return val;
         });
       },
-      /*
-       * 是否公司机构:上级不在组织树内的节点即顶层机构(公司)。
-       * 组织机构列表已在页面过滤「超级管理员」,故顶层节点就是公司机构
-       */
-      isCompanyOrg(node) {
-        if (!node || node.name === '超级管理员') {
-          return false;
-        }
-        return !this.orgIdSet.has(String(node.parentId));
-      },
-      /* 沿父级上溯取所属公司机构 id(新增时把树里选中的部门换算成公司) */
-      resolveCompanyId(id) {
-        if (id == null || id === '') {
-          return id;
-        }
-        const byId = new Map(
-          this.orgFlatList.map((item) => [String(item.id), item])
-        );
-        let node = byId.get(String(id));
-        const seen = new Set();
-        while (
-          node &&
-          !this.isCompanyOrg(node) &&
-          byId.has(String(node.parentId)) &&
-          !seen.has(String(node.id))
-        ) {
-          seen.add(String(node.id));
-          node = byId.get(String(node.parentId));
-        }
-        return node && this.isCompanyOrg(node) ? node.id : id;
-      },
       addIdentityPhotos() {
         this.form.identityPhotos.push({
           holder: this.form.name,
@@ -2247,24 +2141,15 @@
         this.form.deptIds = this.form.deptIds || [];
       },
       checkedKeys(value) {
-        const groupId = this.form.groupId;
         this.getLabelName(this.institutionList, (i) => {
-          if (String(i.id) === String(groupId)) {
+          if (i.id == this.form.groupId) {
             return (this.form.groupName = i.name);
           }
         });
-        // 所属机构变化:清空隶属部门(部门选项已按新机构重建)
-        if (
-          this.lastGroupId != null &&
-          String(this.lastGroupId) !== String(groupId)
-        ) {
-          this.form.deptIds = [];
-          this.form.deptName = '';
-        }
-        this.lastGroupId = groupId;
-        this.form.deptIds = (this.form.deptIds || []).filter(
-          (item) => String(item) != String(groupId)
+        this.form.deptIds = this.form.deptIds.filter(
+          (item) => item != this.form.groupId
         );
+        console.log(this.form.groupName);
       },
       getLabelName(data, callback) {
         data.some((i) => {
@@ -2285,8 +2170,6 @@
                 res.postId = res.postId.split(',');
               }
               this.form = { ...res };
-              // 记录回显的所属机构,避免后续误判为「换了机构」而清空隶属部门
-              this.lastGroupId = this.form.groupId ?? null;
               if (Array.isArray(this.form.signature)) {
                 this.form.signature = this.form.signature[0];
               }
@@ -2312,14 +2195,11 @@
             // console.log('this.form',this.form)
           } else {
             this.city = null;
-            // 新增时默认带入左侧树选中的机构:若选中的是部门,上溯到所属公司机构
-            this.form.groupId = this.resolveCompanyId(this.organizationId);
-            this.lastGroupId = this.form.groupId ?? null;
+            this.form.groupId = this.organizationId;
             this.isUpdate = false;
           }
         } else {
           this.city = null;
-          this.lastGroupId = null;
           this.$refs.form.clearValidate();
           this.form = { ...this.defaultForm };
         }

+ 1 - 1
src/views/system/organization/components/org-user-list.vue

@@ -289,7 +289,7 @@
           },
           {
             prop: 'groupName',
-            label: '所属机构',
+            label: '主所属部门',
             showOverflowTooltip: true,
             minWidth: 110
           },