From 3784cc5b9f62d0397c3036126c014fe4070e8a7d Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期二, 13 六月 2023 20:39:05 +0800
Subject: [PATCH] 1.组织架构和用户清单引入分车间概念

---
 src/permission.js                            |    3 +
 src/store/modules/user.js                    |    8 ++
 src/api/basicInfo.js                         |    9 +++
 src/views/basicSettings/roleList.vue         |    2 
 src/views/login/index.vue                    |   10 +++
 src/settings.js                              |    4 +
 src/views/basicSettings/userList.vue         |   89 ++++++++++++++++++++++++-----
 src/views/basicSettings/organizationList.vue |   46 +++++++++++----
 8 files changed, 138 insertions(+), 33 deletions(-)

diff --git a/src/api/basicInfo.js b/src/api/basicInfo.js
index eae7e13..268faa2 100644
--- a/src/api/basicInfo.js
+++ b/src/api/basicInfo.js
@@ -49,3 +49,12 @@
     method: 'get'
   })
 }
+
+// 閫氳繃閫夋嫨鐨勬墍灞炵粍缁囨煡璇㈡墍灞炵彮缁�
+export function StorgGroupSelect(data) {
+  return request({
+    url: 'BaseDate/StorgGroupSelect',
+    method: 'get',
+    params: data
+  })
+}
diff --git a/src/permission.js b/src/permission.js
index fd55dde..f24dfce 100644
--- a/src/permission.js
+++ b/src/permission.js
@@ -38,6 +38,9 @@
           // 鐢熸垚鍙闂殑璺敱琛�
           await store.dispatch('permission/generateRoutes', menu)
 
+          // eslint-disable-next-line require-atomic-updates
+          store.state.settings.orgType = getCookie('description')
+
           // 鍔ㄦ�佹坊鍔犲彲璁块棶璺敱琛�
           router.addRoutes(store.getters.addRouters)
 
diff --git a/src/settings.js b/src/settings.js
index 1b3876e..36efd85 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -32,6 +32,8 @@
 
   leftBackgroundColorValue: true, // 宸︿晶鏍忚儗鏅鑹�
 
-  animationType: 'fade-transform'// 鍔ㄧ敾绫诲瀷     鍒濆绫诲瀷:fade-transform
+  animationType: 'fade-transform', // 鍔ㄧ敾绫诲瀷     鍒濆绫诲瀷:fade-transform
+
+  orgType: ''// 缁勭粐绫诲瀷  D 閮ㄩ棬   W 杞﹂棿  '' 绠$悊鍛�
 
 }
diff --git a/src/store/modules/user.js b/src/store/modules/user.js
index 8bc6bd3..e557416 100644
--- a/src/store/modules/user.js
+++ b/src/store/modules/user.js
@@ -48,6 +48,8 @@
         setCookie('userid', res.data.userid)
         setCookie('rediskey', res.data.rediskey)
         setCookie('guid', res.data.guid)
+        setCookie('stu_torgcode', res.data.stu_torgcode)
+        setCookie('description', res.data.description)
         // }
         // console.log(res.code === '302', 8989)
         // if (res.code === '302') {
@@ -119,11 +121,13 @@
       const username = getCookie('admin')
       const usertype = getCookie('usertype')
       const userid = getCookie('userid')
+      const stu_torgcode = getCookie('stu_torgcode')
       const data = {
         usercode,
         username,
         usertype,
-        userid
+        userid,
+        stu_torgcode
       }
 
       logout(data).then(res => {
@@ -139,6 +143,8 @@
           removeCookie('userid')
           removeCookie('rediskey')
           removeCookie('code')
+          removeCookie('stu_torgcode')
+          removeCookie('description')
 
           removeCookie('guid')
 
diff --git a/src/views/basicSettings/organizationList.vue b/src/views/basicSettings/organizationList.vue
index 04678a1..d0bae78 100644
--- a/src/views/basicSettings/organizationList.vue
+++ b/src/views/basicSettings/organizationList.vue
@@ -201,11 +201,10 @@
       @close="handleClose"
     >
       <el-form ref="dialogForm" :rules="dialogFormRules" :model="dialogForm" label-width="80px">
-        <el-form-item label="缁勭粐绫诲瀷" prop="OrgType">
+        <el-form-item v-if="$store.state.settings.orgType===''" label="缁勭粐绫诲瀷" prop="OrgType">
           <el-radio-group
             v-model="dialogForm.OrgType"
             :disabled="operation==='edit'"
-            @change="changeRadio"
           >
             <el-radio
               v-for="item in OrgTypeArr"
@@ -232,7 +231,7 @@
             <el-option
               v-for="item in SupUnitArr"
               :key="item.id"
-              :label="item.org_name"
+              :label="item.org_name+' / '+item.org_code"
               :value="item.id"
             />
           </el-select>
@@ -442,7 +441,7 @@
   //   }
   // },
   created() {
-    this.getOrganizationSearch()
+    this.handleRequest()
   },
   mounted() {
     window.addEventListener('resize', this.getHeight)
@@ -472,10 +471,24 @@
       this.tableTimeStampKey = new Date().getTime()
       this.$refs.tableDataRef.doLayout()
     },
+
+    handleRequest() {
+      this.getOrganizationSearch().then(res => {
+        if (res.code === '200') {
+          this.getPrentOrganization()
+        }
+      })
+    },
     async getOrganizationSearch() {
       const res = await OrganizationSearch(this.form)
       this.tableData = res.data
       this.total = res.count
+
+      return { code: res.code }
+    },
+    async getPrentOrganization() {
+      const { data: res } = await PrentOrganization({ orgcode: 'W' })
+      this.SupUnitArr = res
     },
     // 鎺掑簭鏀瑰彉鏃�
     sortChange({ column, prop, order }) {
@@ -502,15 +515,14 @@
       this.form.UserName = ''
       this.getOrganizationSearch()
     },
-    // 鍗曢�夋鏀瑰彉鏃�
-    async changeRadio(val) {
-      if (this.dialogForm.OrgType !== '閮ㄩ棬') {
-        const { data: res } = await PrentOrganization({ orgcode: this.OrgTypeArr.find(item => item.label === this.dialogForm.OrgType).value })
-        this.SupUnitArr = res
-      }
-    },
+
     // 鏂板鎸夐挳
     async add(operation) {
+      console.log(this.$store.state.settings.orgType, 987)
+      if (this.$store.state.settings.orgType === 'W') {
+        return this.$message.info('褰撳墠鐢ㄦ埛鏃犳柊澧炴潈闄愶紒')
+      }
+
       this.operation = operation
       this.dialogVisible = true
 
@@ -520,6 +532,10 @@
     },
     // 淇敼鎸夐挳
     edit(operation, row) {
+      if (this.$store.state.settings.orgType === 'W') {
+        return this.$message.info('褰撳墠鐢ㄦ埛鏃犱慨鏀规潈闄愶紒')
+      }
+
       this.operation = operation
       this.dialogVisible = true
       // if (row.description === 'F') {
@@ -544,6 +560,10 @@
     },
     // 鍒犻櫎鎸夐挳
     async del(id) {
+      if (this.$store.state.settings.orgType === 'W') {
+        return this.$message.info('褰撳墠鐢ㄦ埛鏃犲垹闄ゆ潈闄愶紒')
+      }
+
       this.$confirm('鏄惁纭鍒犻櫎?', '鎻愮ず', {
         confirmButtonText: '纭畾',
         cancelButtonText: '鍙栨秷',
@@ -580,14 +600,14 @@
         if (valid) {
           this.$store.state.app.buttonIsDisabled = true
           const data = {
-            OrganType: this.dialogForm.OrgType === '閮ㄩ棬' ? 'D' : 'W',
+            OrganType: this.$store.state.settings.orgType !== '' ? 'W' : (this.dialogForm.OrgType === '閮ㄩ棬' ? 'D' : 'W'),
             OrganCode: this.dialogForm.OrgCode,
             OrganName: this.dialogForm.OrgName,
             RightCode: '',
             numvalue: '',
             // RightCode: this.operation === 'add' ? getCookie('ruleCode') : '',
             // numvalue: this.operation === 'add' ? this.numvalue : '',
-            SupUnit: this.dialogForm.OrgType === '閮ㄩ棬' ? '0' : this.dialogForm.SupUnit,
+            SupUnit: this.$store.state.settings.orgType !== '' ? this.SupUnitArr.find(i => i.org_code === getCookie('stu_torgcode')).id : (this.dialogForm.OrgType === '閮ㄩ棬' ? '0' : this.dialogForm.SupUnit),
             OperType: this.operation === 'add' ? 'Add' : 'Update',
             Operator: getCookie('admin')
           }
diff --git a/src/views/basicSettings/roleList.vue b/src/views/basicSettings/roleList.vue
index f43c7dc..2ec9f6e 100644
--- a/src/views/basicSettings/roleList.vue
+++ b/src/views/basicSettings/roleList.vue
@@ -706,7 +706,7 @@
           prop: 'is_user',
           label: '鍏宠仈鐢ㄦ埛',
           id: 8,
-          show: true,
+          show: false,
           fixed: false,
           sortable: true
         },
diff --git a/src/views/basicSettings/userList.vue b/src/views/basicSettings/userList.vue
index fbb0235..1f9fc34 100644
--- a/src/views/basicSettings/userList.vue
+++ b/src/views/basicSettings/userList.vue
@@ -29,12 +29,13 @@
             <el-form-item label="鎵�灞炵粍缁�" style=" display: flex;">
               <el-cascader
                 ref="cascader"
+                v-model="form.StuOrg"
                 filterable
                 popper-class="elCascader"
                 :options="StuOrgArr"
                 :props="defaultProps"
-                @change="cascaderChange"
               />
+              <!--              @change="cascaderChange"-->
               <!--              @focus="getUserOrganization"-->
 
             </el-form-item>
@@ -364,6 +365,7 @@
           <el-cascader
             ref="dialogCascader"
             key="cascaderKey"
+            v-model="dialogForm.StuOrg"
             filterable
             popper-class="elCascader"
             :options="StuOrgArr2"
@@ -371,6 +373,7 @@
             style="width: 200px;"
             @change="dialogCascaderChange"
           />
+
         </el-form-item>
         <el-form-item label="鎵�灞炵彮缁�" prop="groupcode">
           <el-select
@@ -518,7 +521,7 @@
       v-el-drag-dialog
       title="鐢熶骇鐝粍"
       :visible.sync="workingDialogVisible"
-      width="800px"
+      width="1000px"
       top="15vh"
       :close-on-click-modal="false"
       class="workingDialogVisible"
@@ -555,6 +558,36 @@
           label="搴忓彿"
           prop="RowNum"
         />
+        <el-table-column
+          v-if="$store.state.settings.orgType!=='W'"
+          prop="stu_torgcode"
+          label="杞﹂棿鍚嶇О"
+
+          sortable="custom"
+          show-tooltip-when-overflow
+        >
+          <template slot-scope="{row}">
+            <!--            <el-input-->
+            <!--              v-if="row.isVisible===1"-->
+            <!--              v-model="row.group_code"-->
+            <!--              oninput="value=value.replace(/[^0-9a-zA-Z]/g,'')"-->
+            <!--              placeholder="璇疯緭鍏�"-->
+            <!--            />-->
+            <el-cascader
+              v-if="row.isVisible===1"
+              ref="dialogCascader"
+              key="cascaderKey"
+              v-model="row.storg_code"
+              filterable
+              popper-class="elCascader"
+              :options="StuOrgArr2"
+              :props="defaultProps"
+              style="width: 200px;"
+            />
+            <div v-else> {{ row.org_name }}</div>
+          </template>
+        </el-table-column>
+
         <el-table-column
           prop="group_code"
           label="鐝粍缂栫爜"
@@ -657,6 +690,7 @@
 import { MesOrderStepReportSelectUserGroup } from '@/api/produceManager'
 import elDragDialog from '@/directive/el-drag-dialog'
 import TableColumnSettings from '@/components/TableColumnSettings'
+import { StorgGroupSelect } from '@/api/basicInfo'
 
 export default {
   name: 'YYQD',
@@ -703,7 +737,7 @@
       form: {
         UserCode: '', // 鐢ㄦ埛缂栫爜
         UserName: '', // 鐢ㄦ埛鍚嶇О
-        StuOrg: '', // 鎵�灞炵粍缁�
+        StuOrg: getCookie('stu_torgcode'), // 鎵�灞炵粍缁�
         wagetype: '', // 宸ヨ祫绫诲瀷
         Enable: '', // 鍦ㄨ亴鐘舵��
         prop: 'lm_date', // 鎺掑簭瀛楁
@@ -717,7 +751,8 @@
         checkStrictly: true,
         value: 'code',
         label: 'name',
-        children: 'children'
+        children: 'children',
+        emitPath: false
       },
       EnableArr: [
         { value: 'Y', label: '鍦ㄨ亴' },
@@ -816,7 +851,7 @@
         UserName: '',
         Password: '123456',
         Enable: 'Y',
-        StuOrg: '',
+        StuOrg: getCookie('stu_torgcode'),
         Mobile: '',
         Email: '',
         groupcode: '',
@@ -931,6 +966,7 @@
     // 鑾峰彇鎵�灞炵粍缁�
     async getUserOrganization() {
       const { data: res } = await UserOrganization()
+
       this.StuOrgArr = clearAllChildren(res)
     },
     // 鑾峰彇鎵�灞炵粍缁囧璇濇
@@ -967,30 +1003,45 @@
     reset() {
       this.form.UserCode = ''
       this.form.UserName = ''
-      this.form.StuOrg = ''
-      this.form.Enable = 'Y'
+      this.form.Enable = ''
       this.form.wagetype = ''
+      this.form.StuOrg = getCookie('stu_torgcode')
       this.$refs.cascader.checkedValue = ''// 绾ц仈閫夋嫨鍣ㄧ殑娓呯┖
       this.getUserSearch()
     },
     // 绾ц仈閫夋嫨鍣ㄦ敼鍙樹簨浠�
     cascaderChange(val) {
+      console.log(val)
       this.form.StuOrg = val[val.length - 1]
+      // this.$refs.cascader.checkValue
     },
     dialogCascaderChange(val) {
-      this.dialogForm.StuOrg = val[val.length - 1]
+      console.log(val)
+      this.dialogForm.groupcode = ''
+      this.getStorgGroupSelect(val)
     },
     // 鑾峰彇涓嬫媺鐢熶骇鐝粍
-    async getMesOrderStepReportSelectUserGroup() {
-      const { data: res } = await MesOrderStepReportSelectUserGroup()
+    async getStorgGroupSelect(stu_torgcode) {
+      const data = {
+        stu_torgcode,
+        description: this.StuOrgArr2.find(i => i.code === stu_torgcode) ? 'D' : 'W'
+      }
+      const { data: res } = await StorgGroupSelect(data)
       this.usergroupArr = res
     },
     // 鏂板鎸夐挳
     add(operation) {
       this.operation = operation
       this.dialogVisible = true
+
+      // this.dialogForm.StuOrg = getCookie('stu_torgcode')
+      // this.$refs.dialogCascader.checkedValue = [getCookie('stu_torgcode')]
+
       this.getUserOrganization2()
-      this.getMesOrderStepReportSelectUserGroup()
+
+      if (this.$store.state.settings.orgType !== '') {
+        this.getStorgGroupSelect(getCookie('stu_torgcode'), this.StuOrgArr2.find(i => i.code === getCookie('stu_torgcode')) ? 'D' : 'W')
+      }
     },
     // 淇敼鎸夐挳
     edit(operation, row) {
@@ -1011,7 +1062,7 @@
         this.dialogForm.Email = row.email
         this.dialogForm.wagetype = row.wagetype
       })
-      this.getMesOrderStepReportSelectUserGroup()
+      this.getStorgGroupSelect()
       this.getUserOrganization2()
     },
     // 鍒犻櫎鎸夐挳
@@ -1041,12 +1092,13 @@
       this.dialogForm.UserName = ''
       this.dialogForm.Password = '123456'
       this.dialogForm.Enable = 'Y'
-      this.$refs.dialogCascader.checkedValue = ''
-      this.dialogForm.StuOrg = ''
+      this.$refs.dialogCascader.checkedValue = getCookie('stu_torgcode')
+      this.dialogForm.StuOrg = getCookie('stu_torgcode')
       this.dialogForm.Mobile = ''
       this.dialogForm.Email = ''
       this.dialogForm.groupcode = ''
       this.dialogForm.wagetype = '2'
+      this.usergroupArr = []
       this.$refs.dialogForm.clearValidate()
     },
     // 瀵硅瘽妗嗗彇娑�
@@ -1409,6 +1461,7 @@
     workingTramClick() {
       this.workingDialogVisible = true
       this.getUserGroupSearch()
+      this.getUserOrganization2()
       // 椤甸潰鍔犺浇瀹屽悗閲嶆柊娓叉煋琛ㄦ牸
       this.$nextTick(() => {
         this.$refs.workingTableData.doLayout()
@@ -1421,7 +1474,7 @@
           this.workingTableData.splice(index, 1)
         }
       })
-      this.getMesOrderStepReportSelectUserGroup()
+      // this.getStorgGroupSelect()
     },
     // 鐢熶骇鐝粍鎺掑簭
     sortChangeOfWorking({ column, prop, order }) {
@@ -1453,7 +1506,7 @@
 
       let number = Math.random() * Math.random()// 浣滀负鍒犻櫎鏃剁殑鏍囪瘑绗�
       number = number === 0 ? (10 + Math.random()) : number
-      const data = { group_code: '', group_name: '', description: '', isVisible: 1, number: number }
+      const data = { storg_code: getCookie('stu_torgcode'), group_code: '', group_name: '', description: '', isVisible: 1, number: number }
       this.workingTableData.unshift(data)
     },
     // 鍒犻櫎
@@ -1478,6 +1531,9 @@
     },
     // 淇濆瓨
     async saveWorking(row) {
+      if (row.storg_code.trim().length < 1) {
+        return this.$message.info('杞﹂棿涓嶈兘涓虹┖锛�')
+      }
       if (row.group_code.trim().length < 1) {
         return this.$message.info('鐝粍缂栫爜涓嶈兘涓虹┖锛�')
       }
@@ -1488,6 +1544,7 @@
       //   return this.$message.info('鐝粍鎻忚堪涓嶈兘涓虹┖锛�')
       // }
       const data = {
+        storg_code: row.storg_code,
         code: row.group_code,
         name: row.group_name,
         flag: row.description
diff --git a/src/views/login/index.vue b/src/views/login/index.vue
index 094e3e5..bb0b14f 100644
--- a/src/views/login/index.vue
+++ b/src/views/login/index.vue
@@ -221,6 +221,10 @@
             if (getCookie('code') === '302') {
               this.dialogVisible = true
             } else {
+              // console.log(typeof getCookie('description'))
+              // console.log(getCookie('description') === '')
+              // this.$store.state.settings.orgType = getCookie('description')// 缁勭粐绫诲瀷
+              // console.log(this.$store.state.settings.orgType, 88)
               this.$router.push({ path: this.redirect || '/' })
             }
             this.loading = false
@@ -241,6 +245,8 @@
       removeCookie('usertype')
       removeCookie('userid')
       removeCookie('code')
+      removeCookie('stu_torgcode')
+      removeCookie('description')
       this.dialogVisible = false
     },
     async dialogVisibleConfirm() {
@@ -248,12 +254,14 @@
       const username = getCookie('admin')
       const usertype = getCookie('usertype')
       const userid = getCookie('userid')
+      const stu_torgcode = getCookie('stu_torgcode')
       const data = {
         usercode,
         username,
         usertype,
         userid,
-        rid: ''
+        rid: '',
+        stu_torgcode
       }
       const res = await ForcedOffline(data)
       if (res.code === '200') {

--
Gitblit v1.9.3