فهرست منبع

fix(客户管理):2列表页详情页权限分离,字典命名变更,领取分配使用昵称

wanglj 3 سال پیش
والد
کامیت
8832b2f9e9

+ 14 - 10
src/store/modules/user.js

@@ -12,12 +12,14 @@ const state = () => ({
   id: '',
   token: getToken(),
   username: '游客',
+  nickName: '',
   avatar: 'https://i.gtimg.cn/club/item/face/img/2/15922_100.gif',
 })
 const getters = {
   id: (state) => state.id,
   token: (state) => state.token,
   username: (state) => state.username,
+  nickName: (state) => state.nickName,
   avatar: (state) => state.avatar,
 }
 const mutations = {
@@ -38,6 +40,9 @@ const mutations = {
   setUsername(state, username) {
     state.username = username
   },
+  setNickName(state, nickName) {
+    state.nickName = nickName
+  },
   setUserId(state, id) {
     state.id = id
   },
@@ -93,11 +98,8 @@ const actions = {
     // console.log(username, avatar, roles, permissions)
 
     const res = await userApi.getUserInfo()
-    const userId = res.data.entity.id
-    const username = res.data.entity.userName
-    const avatar = res.data.entity.avatar
-    let roles = res.data.roleIds
-    let permissions = res.data.permissions
+    const { id, userName, nickName, avatar } = res.data.entity
+    const { roleIds, permissions } = res.data
     /**
      * 检验返回数据是否正常,无对应参数,将使用默认用户名,头像,Roles和Permissions
      * username {String}
@@ -106,9 +108,10 @@ const actions = {
      * ability {List}
      */
     if (
-      (username && !isString(username)) ||
+      (userName && !isString(userName)) ||
       (avatar && !isString(avatar)) ||
-      (roles && !isArray(roles)) ||
+      (nickName && !isString(nickName)) ||
+      (roleIds && !isArray(roleIds)) ||
       (permissions && !isArray(permissions))
     ) {
       const err = 'getUserInfo核心接口异常,请检查返回JSON格式是否正确'
@@ -116,13 +119,14 @@ const actions = {
       throw err
     } else {
       // 如不使用username用户名,可删除以下代码
-      if (userId) commit('setUserId', userId)
+      if (id) commit('setUserId', id)
       // 如不使用username用户名,可删除以下代码
-      if (username) commit('setUsername', username)
+      if (userName) commit('setUsername', userName)
+      if (nickName) commit('setNickName', nickName)
       // 如不使用avatar头像,可删除以下代码
       if (avatar) commit('setAvatar', avatar)
       // 如不使用roles权限控制,可删除以下代码
-      if (roles) dispatch('acl/setRole', roles, { root: true })
+      if (roleIds) dispatch('acl/setRole', roleIds, { root: true })
       // 如不使用permissions权限控制,可删除以下代码
       if (permissions) dispatch('acl/setPermission', permissions, { root: true })
     }

+ 1 - 1
src/views/base/region/index.vue

@@ -199,7 +199,7 @@
         }
       },
       getOptions() {
-        Promise.all([this.getDicts('CustomerIndustry')])
+        Promise.all([this.getDicts('cust_idy')])
           .then(([industry]) => {
             this.industryOptions = industry.data.values || []
           })

+ 2 - 2
src/views/customer/components/Allocate.vue

@@ -2,7 +2,7 @@
  * @Author: wanglj 471442253@qq.com
  * @Date: 2022-12-26 14:34:34
  * @LastEditors: wanglj
- * @LastEditTime: 2023-01-12 16:36:20
+ * @LastEditTime: 2023-01-13 09:41:38
  * @Description: file content
  * @FilePath: \opms_frontend\src\views\customer\components\allocate.vue
 -->
@@ -78,7 +78,7 @@
         let params = {
           salesId: this.userList[0].id,
           ids: this.ids,
-          salesName: this.userList[0].userName,
+          salesName: this.userList[0].nickName,
         }
         const [err, res] = await to(api.receiveCustomer(params))
         if (err) return

+ 3 - 3
src/views/customer/components/Edit.vue

@@ -177,9 +177,9 @@
       getOptions() {
         Promise.all([
           api.getProvinceDetail(),
-          this.getDicts('CustomerLevel'),
-          this.getDicts('CustomerIndustry'),
-          this.getDicts('CustomerSource'),
+          this.getDicts('cust_level'),
+          this.getDicts('cust_idy'),
+          this.getDicts('cust_source'),
         ])
           .then(([province, level, industry, source]) => {
             this.provinceOptions = province.data.list || []

+ 18 - 12
src/views/customer/detail.vue

@@ -2,7 +2,7 @@
  * @Author: wanglj 471442253@qq.com
  * @Date: 2022-12-26 09:30:47
  * @LastEditors: wanglj
- * @LastEditTime: 2023-01-12 16:40:08
+ * @LastEditTime: 2023-01-13 10:32:49
  * @Description: file content
  * @FilePath: \opms_frontend\src\views\customer\detail.vue
 -->
@@ -15,14 +15,14 @@
           <h3>
             {{ detail.custName }}
             <span>
-              <template v-if="privateCus == 1">
-                <el-button v-permissions="['customer:shift']" @click="handleShift">转移客户</el-button>
-                <el-button v-permissions="['customer:open']" @click="handleToOpen">移入公海</el-button>
-                <el-button v-permissions="['customer:business']" @click="handleBusiness">创建项目</el-button>
+              <template v-if="detail.salesId > 0">
+                <el-button v-permissions="['cust:list:shift']" @click="handleShift">转移客户</el-button>
+                <el-button v-permissions="['cust:list:open']" @click="handleToOpen">移入公海</el-button>
+                <el-button v-permissions="['cust:list:business']" @click="handleBusiness">创建项目</el-button>
               </template>
               <template v-else>
-                <el-button v-permissions="['customer:receive']" @click="handleReceive">领取客户</el-button>
-                <el-button v-permissions="['customer:allocate']" @click="handleAllocate">分配客户</el-button>
+                <el-button v-permissions="['cust:open:receive']" @click="handleReceive">领取客户</el-button>
+                <el-button v-permissions="['cust:open:allocate']" @click="handleAllocate">分配客户</el-button>
               </template>
             </span>
           </h3>
@@ -266,8 +266,8 @@
       </div>
       <div class="info-side">
         <div class="buttons">
-          <el-button v-permissions="['customer:edit']" type="primary" @click="handleEdit">编辑</el-button>
-          <el-button v-permissions="['customer:delete']" @click="handleDelete">删除</el-button>
+          <el-button v-if="checkPermi('edit')" type="primary" @click="handleEdit">编辑</el-button>
+          <el-button v-if="checkPermi('delete')" @click="handleDelete">删除</el-button>
           <el-button @click="$router.go(-1)">返回</el-button>
         </div>
         <ul class="records">
@@ -319,6 +319,7 @@
 </template>
 
 <script>
+  import { hasPermission } from '@/utils/permission'
   import { mapGetters } from 'vuex'
   import api from '@/api/customer'
   import follow from '@/api/customer/follow'
@@ -347,7 +348,6 @@
     data() {
       return {
         id: '',
-        privateCus: '',
         detail: {
           custCode: '', //客户编码
           abbrName: '', //助记名
@@ -388,12 +388,18 @@
     },
     mounted() {
       this.id = this.$route.query.id
-      this.privateCus = this.$route.query.privateCus
       this.init()
       this.getDynamics()
       this.handleClick({ name: 'follow' })
     },
     methods: {
+      checkPermi(val) {
+        let str = 'cust:'
+        if (this.detail.salesId) str += 'list:'
+        else str += 'open:'
+        str += val
+        return hasPermission([str])
+      },
       async init() {
         Promise.all([
           api.getDetail({ ids: [parseInt(this.id)] }),
@@ -544,7 +550,7 @@
               api.receiveCustomer({
                 ids: [parseInt(this.id)],
                 salesId: this.$store.state.user.id,
-                salesName: this.$store.state.user.username,
+                salesName: this.$store.state.user.nickName,
                 receive: '1',
               })
             )

+ 40 - 25
src/views/customer/list.vue

@@ -2,7 +2,7 @@
  * @Author: wanglj 471442253@qq.com
  * @Date: 2022-12-26 16:34:37
  * @LastEditors: wanglj
- * @LastEditTime: 2023-01-05 13:39:44
+ * @LastEditTime: 2023-01-13 11:13:29
  * @Description: file content
  * @FilePath: \opms_frontend\src\views\customer\list.vue
 -->
@@ -45,10 +45,38 @@
     </el-row>
     <vab-query-form>
       <vab-query-form-left-panel :span="12">
-        <el-button icon="el-icon-plus" size="mini" type="primary" @click="$refs.edit.init()">新建</el-button>
-        <el-button icon="el-icon-plus" size="mini" type="primary" @click="handleShift">转移客户</el-button>
-        <el-button icon="el-icon-plus" size="mini" type="primary" @click="handleToOpen">移入公海</el-button>
-        <el-button icon="el-icon-plus" size="mini" type="primary" @click="handleMerge">合并客户</el-button>
+        <el-button
+          v-permissions="['cust:list:add']"
+          icon="el-icon-plus"
+          size="mini"
+          type="primary"
+          @click="$refs.edit.init()">
+          新建
+        </el-button>
+        <el-button
+          v-permissions="['cust:list:shift']"
+          icon="el-icon-plus"
+          size="mini"
+          type="primary"
+          @click="handleShift">
+          转移客户
+        </el-button>
+        <el-button
+          v-permissions="['cust:list:open']"
+          icon="el-icon-plus"
+          size="mini"
+          type="primary"
+          @click="handleToOpen">
+          移入公海
+        </el-button>
+        <el-button
+          v-permissions="['cust:list:merge']"
+          icon="el-icon-plus"
+          size="mini"
+          type="primary"
+          @click="handleMerge">
+          合并客户
+        </el-button>
       </vab-query-form-left-panel>
       <vab-query-form-right-panel :span="12">
         <el-button icon="el-icon-download" />
@@ -62,21 +90,6 @@
       height="calc(100vh - 394px)"
       @selection-change="setSelectRows">
       <el-table-column align="center" show-overflow-tooltip type="selection" />
-
-      <el-table-column align="center" label="客户编码" prop="custCode" />
-      <el-table-column align="center" label="客户名称" prop="custName" />
-      <el-table-column align="center" label="助记名" prop="abbrName" />
-      <el-table-column align="center" label="所在地区" prop="custLocation" />
-
-      <el-table-column align="center" label="客户行业" prop="custIndustry" />
-
-      <el-table-column align="center" label="客户级别" prop="custLevel" />
-      <el-table-column align="center" label="客户状态" prop="custStatus">
-        <template slot-scope="scope">
-          {{ scope.row.custStatus == 10 ? '正常' : '异常' }}
-        </template>
-      </el-table-column>
-
       <el-table-column
         v-for="(item, index) in finallyColumns"
         :key="index"
@@ -93,13 +106,16 @@
           <span v-else-if="item.prop === 'custStatus'">
             {{ row.custStatus == 10 ? '正常' : '异常' }}
           </span>
+          <span v-else-if="item.prop === 'followUpDate'">
+            {{ parseTime(row.followUpDate, '{y}-{m}-{d} {h}-{i}') }}
+          </span>
           <span v-else>{{ row[item.prop] }}</span>
         </template>
       </el-table-column>
       <el-table-column align="center" label="操作">
         <template slot-scope="scope">
-          <el-button type="text" @click="handleEdit(scope.row)">编辑</el-button>
-          <el-button type="text" @click="handleDelete(scope.row)">删除</el-button>
+          <el-button v-permissions="['cust:list:edit']" type="text" @click="handleEdit(scope.row)">编辑</el-button>
+          <el-button v-permissions="['cust:list:delete']" type="text" @click="handleDelete(scope.row)">删除</el-button>
         </template>
       </el-table-column>
     </el-table>
@@ -241,7 +257,7 @@
     },
     methods: {
       getOptions() {
-        Promise.all([this.getDicts('CustomerLevel'), this.getDicts('CustomerIndustry')])
+        Promise.all([this.getDicts('cust_level'), this.getDicts('cust_idy')])
           .then(([level, industry]) => {
             this.levelOptions = level.data.values || []
             this.industryOptions = industry.data.values || []
@@ -304,7 +320,6 @@
           path: '/customer/detail',
           query: {
             id: row.id,
-            privateCus: 1,
           },
         })
       },
@@ -316,7 +331,7 @@
           type: 'warning',
         })
           .then(async () => {
-            const [err, res] = await to(api.deleteCustomer({ Ids: row.id }))
+            const [err, res] = await to(api.deleteCustomer({ Ids: [row.id] }))
             if (err) return
             if (res.code == 200) {
               this.$message({

+ 8 - 8
src/views/customer/openSea.vue

@@ -2,7 +2,7 @@
  * @Author: wanglj 471442253@qq.com
  * @Date: 2022-12-15 15:38:21
  * @LastEditors: wanglj
- * @LastEditTime: 2023-01-11 18:05:30
+ * @LastEditTime: 2023-01-13 10:12:12
  * @Description: file content
  * @FilePath: \opms_frontend\src\views\customer\openSea.vue
 -->
@@ -42,13 +42,13 @@
         </el-form>
       </vab-query-form-top-panel>
       <vab-query-form-left-panel :span="12">
-        <el-button v-permissions="['customer:add']" icon="el-icon-plus" type="primary" @click="$refs.edit.init()">
+        <el-button v-permissions="['cust:open:add']" icon="el-icon-plus" type="primary" @click="$refs.edit.init()">
           新建
         </el-button>
-        <el-button v-permissions="['customer:allocate']" icon="el-icon-plus" type="primary" @click="handleAllocate">
+        <el-button v-permissions="['cust:open:allocate']" icon="el-icon-plus" type="primary" @click="handleAllocate">
           分配
         </el-button>
-        <el-button v-permissions="['customer:receive']" icon="el-icon-plus" type="primary" @click="handleReceive">
+        <el-button v-permissions="['cust:open:receive']" icon="el-icon-plus" type="primary" @click="handleReceive">
           领取
         </el-button>
       </vab-query-form-left-panel>
@@ -127,8 +127,8 @@
         prop="createdTime" /> -->
       <el-table-column align="center" label="操作">
         <template slot-scope="scope">
-          <el-button v-permissions="['customer:edit']" type="text" @click="handleEdit(scope.row)">编辑</el-button>
-          <el-button v-permissions="['customer:delete']" type="text" @click="handleDelete(scope.row)">删除</el-button>
+          <el-button v-permissions="['cust:open:edit']" type="text" @click="handleEdit(scope.row)">编辑</el-button>
+          <el-button v-permissions="['cust:open:delete']" type="text" @click="handleDelete(scope.row)">删除</el-button>
         </template>
       </el-table-column>
     </el-table>
@@ -271,7 +271,7 @@
     },
     methods: {
       getOptions() {
-        Promise.all([this.getDicts('CustomerLevel'), this.getDicts('CustomerIndustry')])
+        Promise.all([this.getDicts('cust_level'), this.getDicts('cust_idy')])
           .then(([level, industry]) => {
             this.levelOptions = level.data.values || []
             this.industryOptions = industry.data.values || []
@@ -392,7 +392,7 @@
               api.receiveCustomer({
                 ids: arr,
                 salesId: this.$store.state.user.id,
-                salesName: this.$store.state.user.username,
+                salesName: this.$store.state.user.nickName,
                 receive: '1',
               })
             )

+ 1 - 1
src/views/plat/task/detail.vue

@@ -219,7 +219,7 @@
       // 初始化数据
       async initData() {
         const [err, [type, user]] = await to(
-          Promise.all([dictApi.getDictDataList({ dictType: 'TaskType' }), userApi.getList()])
+          Promise.all([dictApi.getDictDataList({ dictType: 'task_type' }), userApi.getList()])
         )
         if (err) return
         this.types = type.data.list

+ 1 - 1
src/views/plat/task/index.vue

@@ -327,7 +327,7 @@
       // 初始化数据
       async initData() {
         await dictApi
-          .getDictDataList({ dictType: 'TaskType' })
+          .getDictDataList({ dictType: 'task_type' })
           .then((res) => {
             if (res.data.list) {
               this.types = res.data.list