ソースを参照

字典职工完善

zcy 4 年 前
コミット
7caf01bccd

+ 2 - 2
src/components/RightModel/index.vue

@@ -51,7 +51,7 @@
 
 </template>
 <script>
-  import { getAction } from '@/api/request'
+import { getAction } from '@/api/request'
 
 export default {
   name: 'RoleModal',
@@ -145,7 +145,7 @@ export default {
         permissionIds: that.checkedKeys.join(','),
         lastpermissionIds: that.defaultCheckedKeys.join(',')
       }
-      console.log(params);
+      console.log(params)
     },
     loadData() {
       getAction(this.treeList).then((res) => {

+ 27 - 19
src/mixin/listMixin.js

@@ -4,7 +4,7 @@
  * data中url定义 list为查询列表  delete为删除单条记录  deleteBatch为批量删除
  */
 import { filterObj } from '@/utils/util'
-import { postAction, getAction, deleteAction, downFile } from '@/api/request'
+import { getDicAction, postAction, getAction, deleteAction, downFile } from '@/api/request'
 import store from '@/store'
 
 export const listMixin = {
@@ -50,7 +50,6 @@ export const listMixin = {
     }
   },
   created() {
-    console.log(' -- mixin created -- ')
     this.loadData()
   },
   computed: {
@@ -72,22 +71,35 @@ export const listMixin = {
       }
       var params = this.getQueryParams()// 查询条件
       this.loading = true
-      getAction(this.url.list, params).then((res) => {
-        if (res.code === 200) {
-          // update-begin---author:zhangyafei    Date:20201118  for:适配不分页的数据列表------------
-          this.dataSource = res.rows || res.data
-          if (res.total) {
-            this.ipagination.total = res.total
+      if (this.isDict) {
+        this.loading = true
+        getDicAction(this.url.list, this.model.dictType).then((res) => {
+          if (res.code === 200) {
+            this.dataSource = res.rows || res.data
           } else {
-            this.ipagination.total = 0
+            this.$message.warning(res.msg)
           }
+        }).finally(() => {
+          this.loading = false
+        })
+      } else {
+        getAction(this.url.list, params).then((res) => {
+          if (res.code === 200) {
+          // update-begin---author:zhangyafei    Date:20201118  for:适配不分页的数据列表------------
+            this.dataSource = res.rows || res.data
+            if (res.total) {
+              this.ipagination.total = res.total
+            } else {
+              this.ipagination.total = 0
+            }
           // update-end---author:zhangyafei    Date:20201118  for:适配不分页的数据列表------------
-        } else {
-          this.$message.warning(res.msg)
-        }
-      }).finally(() => {
-        this.loading = false
-      })
+          } else {
+            this.$message.warning(res.msg)
+          }
+        }).finally(() => {
+          this.loading = false
+        })
+      }
     },
     handleSuperQuery(params, matchType) {
       // 高级查询方法
@@ -142,7 +154,6 @@ export const listMixin = {
       this.loadData(1)
     },
     batchDel: function() {
-      debugger
       if (!this.url.delete) {
         this.$message.error('请设置url.deleteBatch属性!')
         return
@@ -212,9 +223,6 @@ export const listMixin = {
       this.$refs.modalForm.disableSubmit = false
     },
     handleAdd: function() {
-      console.log(this.$refs)
-      debugger
-      console.log(this.$refs.modalForm)
       this.$refs.modalForm.add()
       this.$refs.modalForm.title = '新增'
       this.$refs.modalForm.disableSubmit = false

+ 2 - 2
src/views/sys/dict/CheckAndEditModel.vue

@@ -42,8 +42,8 @@ export default {
         dictType: [{ required: true, message: '请输入' }]
       },
       url: {
-        add: '/system/dict/type/add',
-        edit: '/system/dict/type/update'
+        add: '/system/dict/type',
+        edit: '/system/dict/type'
       }
     }
   },

+ 10 - 18
src/views/sys/dict/DictItemList.vue

@@ -32,7 +32,7 @@
             <span slot="action" slot-scope="text, record">
               <a @click="handleEdit(record)">编辑</a>
               <a-divider type="vertical" />
-              <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.dictId)">
+              <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.dictCode)">
                 <a>删除</a>
               </a-popconfirm>
             </span>
@@ -48,13 +48,14 @@
 <script>
 import DictItemModal from './DictItemModal'
 import { listMixin } from '@/mixin/listMixin'
-import { getDicAction } from '@/api/request'
+
 export default {
   name: 'DictItemList',
   components: { DictItemModal },
   mixins: [listMixin],
   data() {
     return {
+      createMixin: true,
       columns: [
         {
           title: '名称',
@@ -73,6 +74,7 @@ export default {
           scopedSlots: { customRender: 'action' }
         }
       ],
+      isDict: true,
       title: '操作',
       visible: false,
       screenWidth: 800,
@@ -92,6 +94,7 @@ export default {
         itemValue: { rules: [{ required: true, message: '请输入数据值!' }] }
       },
       url: {
+        list: '/system/dict/data/type/',
         delete: '/system/dict/data/'
       }
     }
@@ -102,21 +105,22 @@ export default {
   },
   methods: {
     edit(record) {
+      debugger
       if (record.dictId) {
         this.dictId = record.dictId
       }
       this.model = Object.assign({}, record)
       this.visible = true
       // 当其它模块调用该模块时,调用此方法加载字典数据
-      this.loadDataTree()
+      this.loadData()
     },
     // 添加字典数据
     handleAdd() {
-      this.$refs.modalForm.add(this.dictId)
+      this.$refs.modalForm.add(this.dictId, this.model)
       this.$refs.modalForm.title = '新增'
     },
-    handleEdit(record){
-      this.$refs.modalForm.edit(this.dictId,record)
+    handleEdit(record) {
+      this.$refs.modalForm.edit(this.dictId, record)
       this.$refs.modalForm.title = '编辑'
     },
     onClose() {
@@ -132,18 +136,6 @@ export default {
       } else {
         this.screenWidth = 600
       }
-    },
-    loadDataTree() {
-      this.loading = true
-      getDicAction('/system/dict/data/type/', this.model.dictType).then((res) => {
-        if (res.code === 200) {
-          this.dataSource = res.rows || res.data
-        } else {
-          this.$message.warning(res.msg)
-        }
-      }).finally(() => {
-        this.loading = false
-      })
     }
   }
 }

+ 7 - 6
src/views/sys/dict/DictItemModal.vue

@@ -56,18 +56,18 @@ export default {
         dictValue: [{ required: true, message: '请输入数据值!' }]
       },
       url: {
-        add: '/system/dict/data/add',
-        edit: '/system/dict/data/update'
+        add: '/system/dict/data',
+        edit: '/system/dict/data'
       }
     }
   },
   created() {
   },
   methods: {
-    add(dictId) {
-      this.dictId = dictId
+    add(dictId, record) {
+      this.model = { dictType: record.dictType }
+      this.dictId = null
       this.visible = true
-      // 初始化默认值
     },
     edit(dictId, record) {
       this.model = Object.assign({}, record)
@@ -82,6 +82,7 @@ export default {
           this.model.dictLabel = (this.model.dictLabel || '').trim()
           this.model.dictValue = (this.model.dictValue || '').trim()
           let url, type
+          debugger
           if (!this.dictId) {
             url = this.url.add
             type = 'post'
@@ -89,7 +90,7 @@ export default {
             url = this.url.edit
             type = 'put'
           }
-          httpAction(url, { ...this.model, dictId: this.dictId }, type).then((res) => {
+          httpAction(url, { ...this.model }, type).then((res) => {
             if (res.code === 200) {
               this.$message.success(res.msg)
               this.$emit('ok')

+ 2 - 2
src/views/sys/dict/index.vue

@@ -40,7 +40,7 @@
         ref="table"
         size="middle"
         bordered
-        row-key="id"
+        row-key="dictId"
         :columns="columns"
         :data-source="dataSource"
         :pagination="ipagination"
@@ -58,7 +58,7 @@
             字典配置
           </a-button>
           <a-divider type="vertical" />
-          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
+          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.dictId)">
             <a-button size="small" type="danger">
               删除
             </a-button>

+ 2 - 2
src/views/sys/job/index.vue

@@ -105,8 +105,8 @@ export default {
       // 表头
       columns: columns(this),
       url: {
-        list: '/business/catenary/bus/zzdzxx/list',
-        delete: '/business/catenary/bus/zzdzxx/',
+        list: '/system/role/list',
+        delete: '/system/role/{roleIds}',
         exportXlsUrl: '/exportXlsUrl',
         importExcelUrl: `${process.env.VUE_APP_BASE_API}/importExcelUrl`
       }

+ 6 - 6
src/views/sys/job/indexColumns.js

@@ -2,8 +2,8 @@ function columns(vm) {
   const cols = [
     {
       title: '职务名称',
-      dataIndex: 'xb',
-      key: 'xb'
+      dataIndex: 'roleName',
+      key: 'roleName'
     },
     {
       title: '状态',
@@ -21,14 +21,14 @@ function columns(vm) {
     {
       title: '职务描述',
       align: 'center',
-      dataIndex: 'hb',
-      key: 'hb'
+      dataIndex: 'remark',
+      key: 'remark'
     },
     {
       title: '更新时间',
       align: 'center',
-      dataIndex: 'zzh',
-      key: 'zzh'
+      dataIndex: 'updateTime',
+      key: 'updateTime'
     },
     {
       title: '操作',

+ 4 - 4
src/views/sys/worker/CheckAndEditModel.vue

@@ -8,8 +8,8 @@
     @close="close"
   >
     <a-form-model ref="form" :label-col="labelCol" :wrapper-col="wrapperCol" :rules="validatorRules" :model="model">
-      <a-form-model-item label="员工姓名:" prop="zzh">
-        <a-input v-model="model.zzh" />
+      <a-form-model-item label="员工姓名:" prop="nickName">
+        <a-input v-model="model.nickName" />
       </a-form-model-item>
       <a-form-model-item label="数据权限" prop="qj">
         <j-dict-select-tag
@@ -81,8 +81,8 @@ export default {
         type: [{ required: true, message: '请选择' }]
       },
       url: {
-        add: '/business/catenary/bus/zzdzxx/add',
-        edit: '/business/catenary/bus/zzdzxx/update'
+        add: '/system/user',
+        edit: '/system/user'
       }
     }
   },

+ 82 - 13
src/views/sys/worker/index.vue

@@ -48,17 +48,31 @@
         <div class="table-operator" style="margin: 15px 0">
           <a-button type="primary" icon="plus" @click="handleAdd">新增</a-button>
           <a-button ghost type="danger" icon="download" @click="handleExportXls('角色信息')">导出</a-button>
-          <a-upload name="file" :show-upload-list="false" :multiple="false" :headers="tokenHeader" :action="url.importExcelUrl" @change="handleImportExcel">
+          <a-upload
+            name="file"
+            :show-upload-list="false"
+            :multiple="false"
+            :headers="tokenHeader"
+            :action="url.importExcelUrl"
+            @change="handleImportExcel"
+          >
             <a-button ghost type="danger" icon="import">导入</a-button>
           </a-upload>
 
           <a-dropdown v-if="selectedRowKeys.length > 0">
             <a-menu slot="overlay">
-              <a-menu-item key="1"><a-icon type="highlight" />重置密码</a-menu-item>
-              <a-menu-item key="2" @click="batchDel"><a-icon type="delete" />批量删除</a-menu-item>
+              <a-menu-item key="1">
+                <a-icon type="highlight" />
+                重置密码
+              </a-menu-item>
+              <a-menu-item key="2" @click="batchDel">
+                <a-icon type="delete" />
+                批量删除
+              </a-menu-item>
             </a-menu>
             <a-button style="margin-left: 8px">
-              批量操作 <a-icon type="down" />
+              批量操作
+              <a-icon type="down" />
             </a-button>
           </a-dropdown>
         </div>
@@ -66,7 +80,8 @@
         <!-- table区域-begin -->
         <div>
           <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
-            <i class="anticon anticon-info-circle ant-alert-icon" /> 已选择&nbsp;<a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项&nbsp;&nbsp;
+            <i class="anticon anticon-info-circle ant-alert-icon" /> 已选择&nbsp;<a style="font-weight: 600">{{
+              selectedRowKeys.length }}</a>项&nbsp;&nbsp;
             <a style="margin-left: 24px" @click="onClearSelected">清空</a>
           </div>
 
@@ -82,7 +97,20 @@
             :row-selection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
             @change="handleTableChange"
           >
-
+            <template slot="dept" slot-scope="text, record">
+              {{ record['dept'].deptName }}
+            </template>
+            <template slot="leader" slot-scope="text, record">
+              {{ record['dept'].leader }}
+            </template>
+            <template slot="status" slot-scope="text, record">
+              <a-switch
+                :checked="record.status==='0'?false:true"
+                checked-children="启用"
+                un-checked-children="停用"
+                @change="changeStatus({$event,record})"
+              />
+            </template>
             <span slot="action" slot-scope="text, record">
               <a-button size="small" type="primary" @click="handleEdit(record)">
                 编辑
@@ -94,7 +122,12 @@
                 </a-button>
                 <a-menu slot="overlay">
                   <a-menu-item>
-                    <a href="javascript:;" @click="handlePer(record)">操作权限</a>
+                    <a-popconfirm title="确认重置密码吗?" @confirm="() => rePwd(record)">
+                      <a href="javascript:;">重置密码</a>
+                    </a-popconfirm>
+                  </a-menu-item>
+                  <a-menu-item>
+                    <a href="javascript:;" @click="handlePer(record)">角色分配</a>
                   </a-menu-item>
                   <a-menu-item>
                     <a href="javascript:;" @click="loginLog(record)">登录日志</a>
@@ -113,6 +146,7 @@
             </span>
           </a-table>
           <check-and-edit-model ref="modalForm" @ok="modalFormOk" />
+          <right-Tree ref="rightTree" @ok="updateQueryParam" />
         </div>
         <!-- table区域-end -->
         <!-- 表单区域 -->
@@ -125,10 +159,14 @@ import { listMixin } from '@/mixin/listMixin'
 import columns from './indexColumns'
 import CheckAndEditModel from './CheckAndEditModel'
 import leftTree from '@/components/leftTree'
+import { httpAction } from '@/api/request'
+import rightTree from './rightTree'
+
 export default {
   components: {
     CheckAndEditModel,
-    leftTree
+    leftTree,
+    rightTree
   },
   mixins: [listMixin],
   data() {
@@ -138,8 +176,8 @@ export default {
       // 表头
       columns: columns(this),
       url: {
-        list: '/business/catenary/bus/zzdzxx/list',
-        delete: '/business/catenary/bus/zzdzxx/',
+        list: '/system/user/list',
+        delete: '/system/user/',
         exportXlsUrl: '/exportXlsUrl',
         importExcelUrl: `${process.env.VUE_APP_BASE_API}/importExcelUrl`
       }
@@ -152,9 +190,40 @@ export default {
       this.queryParam.cate = data.id
       this.loadData()
     },
-    handleLog() {},
-    loginLog() {},
-    handlePer() {}
+    rePwd(record) {
+      httpAction('/system/user/resetPwd', record, 'put').then((res) => {
+        if (res.code === 200) {
+          this.$message.success(res.msg)
+        } else {
+          console.log(res)
+        }
+      })
+    },
+    changeStatus({ $event, record }) {
+      console.log($event, record)
+      record.status = $event ? '1' : '0'
+      httpAction('/system/user/changeStatus', record, 'put').then((res) => {
+        if (res.code === 200) {
+          this.$message.success(res.msg)
+        } else {
+          console.log(res)
+        }
+      })
+    },
+    handleLog() {
+    },
+    loginLog() {
+    },
+    handlePer() {
+      this.$refs.rightTree.title = '操作权限'
+      this.$refs.rightTree.treeKey = '/treeKey'
+      this.$refs.rightTree.treeList = '/system/user/authRole'
+      this.$refs.rightTree.show()
+    },
+    updateQueryParam(data) {
+      this.queryParam.unit = data.id
+      this.queryParam.unitName = data.departName
+    }
   }
 }
 </script>

+ 19 - 39
src/views/sys/worker/indexColumns.js

@@ -10,62 +10,42 @@ function columns(vm) {
       }
     },
     {
-      title: '线别',
+      title: '姓名',
       align: 'center',
-      dataIndex: 'xb',
-      key: 'xb'
+      dataIndex: 'nickName',
+      key: 'nickName'
     },
     {
-      title: '区间/站场',
+      title: '部门',
       align: 'center',
-      dataIndex: 'qj',
-      key: 'qj'
+      dataIndex: 'dept',
+      scopedSlots: { customRender: 'dept' },
+      key: 'dept'
     },
     {
-      title: '车间/工区',
+      title: '职务',
       align: 'center',
-      dataIndex: 'bm',
-      key: 'bm'
+      dataIndex: 'leader',
+      scopedSlots: { customRender: 'leader' },
+      key: 'leader'
     },
     {
-      title: '行别',
+      title: '手机号',
       align: 'center',
-      dataIndex: 'hb',
-      key: 'hb'
+      dataIndex: 'phonenumber',
+      key: 'phonenumber'
     },
     {
-      title: '支柱号',
+      title: '状态',
       align: 'center',
-      dataIndex: 'zzh',
-      key: 'zzh'
-    },
-    {
-      title: '公里标',
-      align: 'center',
-      dataIndex: 'glb',
-      key: 'glb'
-    },
-    {
-      title: '规格型号',
-      align: 'center',
-      dataIndex: 'zzxh',
-      key: 'zzxh'
-    },
-    {
-      title: '支柱类型',
-      align: 'center',
-      dataIndex: 'zzlx',
-      key: 'zzlx'
-    },
-    {
-      title: '安装时间',
-      align: 'center',
-      dataIndex: 'ccrq',
-      key: 'ccrq'
+      dataIndex: 'status',
+      scopedSlots: { customRender: 'status' },
+      key: 'status'
     },
     {
       title: '操作',
       dataIndex: 'action',
+      width: 350,
       align: 'center',
       slots: { title: 'actionName' },
       scopedSlots: { customRender: 'action' }

+ 179 - 0
src/views/sys/worker/rightTree.vue

@@ -0,0 +1,179 @@
+<template>
+  <a-drawer
+    :title="title"
+    :mask-closable="true"
+    width="500"
+    placement="right"
+    :closable="true"
+    :visible="visible"
+    style="overflow: auto;padding-bottom: 53px;"
+    @close="close"
+  >
+
+    <a-form>
+      <a-form-item label="所拥有的权限">
+        <a-tree
+          checkable
+          :checked-keys="checkedKeys"
+          :tree-data="treeData"
+          :selected-keys="selectedKeys"
+          :expanded-keys="expandedKeysss"
+          :check-strictly="checkStrictly"
+          @check="onCheck"
+          @expand="onExpand"
+          @select="onTreeNodeSelect"
+        >
+          <span slot="hasDatarule" slot-scope="{slotTitle,ruleFlag}">
+            {{ slotTitle }}<a-icon v-if="ruleFlag" type="align-left" style="margin-left:5px;color: red;" />
+          </span>
+        </a-tree>
+      </a-form-item>
+    </a-form>
+
+    <div class="drawer-bootom-button">
+      <a-dropdown style="float: left" :trigger="['click']" placement="topCenter">
+        <a-menu slot="overlay">
+          <a-menu-item key="5" @click="expandAll">展开所有</a-menu-item>
+          <a-menu-item key="6" @click="closeAll">合并所有</a-menu-item>
+        </a-menu>
+        <a-button>
+          树操作 <a-icon type="up" />
+        </a-button>
+      </a-dropdown>
+      <a-popconfirm title="确定放弃编辑?" ok-text="确定" cancel-text="取消" @confirm="close">
+        <a-button style="margin-right: .8rem">取消</a-button>
+      </a-popconfirm>
+      <a-button type="primary" :loading="loading" ghost style="margin-right: 0.8rem" @click="handleSubmit(false)">仅保存</a-button>
+      <a-button type="primary" :loading="loading" @click="handleSubmit(true)">保存并关闭</a-button>
+    </div>
+
+  </a-drawer>
+
+</template>
+<script>
+import { getAction } from '@/api/request'
+
+export default {
+  name: 'RoleModal',
+  components: {
+  },
+  data() {
+    return {
+      jobId: '',
+      title: '',
+      treeList: '',
+      treeKey: '',
+      treeData: [],
+      defaultCheckedKeys: [],
+      checkedKeys: [],
+      expandedKeysss: [],
+      allTreeKeys: [],
+      autoExpandParent: true,
+      checkStrictly: true,
+      visible: false,
+      loading: false,
+      selectedKeys: []
+    }
+  },
+  watch: {
+    visible() {
+      if (this.visible) {
+        this.loadData()
+      }
+    }
+  },
+  methods: {
+    onTreeNodeSelect(id) {
+      if (id && id.length > 0) {
+        this.selectedKeys = id
+      }
+      this.$refs.datarule.show(this.selectedKeys[0], this.jobId)
+    },
+    onCheck(o) {
+      if (this.checkStrictly) {
+        this.checkedKeys = o.checked
+      } else {
+        this.checkedKeys = o
+      }
+    },
+    show(jobId) {
+      this.jobId = jobId
+      this.visible = true
+    },
+    close() {
+      this.reset()
+      this.$emit('close')
+      this.visible = false
+    },
+    onExpand(expandedKeys) {
+      this.expandedKeysss = expandedKeys
+      this.autoExpandParent = false
+    },
+    reset() {
+      this.expandedKeysss = []
+      this.checkedKeys = []
+      this.defaultCheckedKeys = []
+      this.loading = false
+    },
+    expandAll() {
+      this.expandedKeysss = this.allTreeKeys
+    },
+    closeAll() {
+      this.expandedKeysss = []
+    },
+    checkALL() {
+      this.checkedKeys = this.allTreeKeys
+    },
+    cancelCheckALL() {
+      // this.checkedKeys = this.defaultCheckedKeys
+      this.checkedKeys = []
+    },
+    switchCheckStrictly(v) {
+      if (v == 1) {
+        this.checkStrictly = false
+      } else if (v == 2) {
+        this.checkStrictly = true
+      }
+    },
+    handleCancel() {
+      this.close()
+    },
+    handleSubmit(exit) {
+      const that = this
+      const params = {
+        jobId: that.jobId,
+        permissionIds: that.checkedKeys.join(','),
+        lastpermissionIds: that.defaultCheckedKeys.join(',')
+      }
+      console.log(params)
+    },
+    loadData() {
+      getAction(this.treeList).then((res) => {
+        this.treeData = res.result.treeList
+        this.allTreeKeys = res.result.ids
+        getAction({ jobId: this.jobId }).then((res) => {
+          this.checkedKeys = [...res.result]
+          this.defaultCheckedKeys = [...res.result]
+          this.expandedKeysss = this.allTreeKeys
+          console.log(this.defaultCheckedKeys)
+        })
+      })
+    }
+  }
+}
+
+</script>
+<style lang="less" scoped>
+  .drawer-bootom-button {
+    position: absolute;
+    bottom: 0;
+    width: 100%;
+    border-top: 1px solid #e8e8e8;
+    padding: 10px 16px;
+    text-align: right;
+    left: 0;
+    background: #fff;
+    border-radius: 0 0 2px 2px;
+  }
+
+</style>