Ver Fonte

1、修改工具栏事件

周兴 há 3 anos atrás
pai
commit
6435028a70

+ 1 - 0
src/api/pages/core/staff.js

@@ -19,6 +19,7 @@ export default {
 export const routeUrl = {
   staff: {
     dimission: {key: 'dimission', method: 'dimission'},
+    import:{key:'import',method:'importExcel'}
   }
 }
 

+ 7 - 1
src/components/base/index-button-group/base-index-button-group.vue

@@ -18,7 +18,13 @@ export default {
   data() {
     return {
       leftData: null,
-      rightData: null
+      rightData: null,
+      items: []    //子组件
+    }
+  },
+  provide() {
+    return{
+      buttonGroup:this,
     }
   },
   methods: {

+ 16 - 2
src/components/base/index-button-group/base-index-button.vue

@@ -3,7 +3,7 @@
   <Button ref="button"  :loading="loading"
           :disabled="disabled"
           :icon="'iconfont iconfont icon-' + (!this.$config.buttonIcon[name]?'':this.$config.buttonIcon[name].icon)"
-          :type="name==='create'?'success':'default'" @click="handleClick">{{ vm.$t(name) }}
+          :type="name==='add'?'success':'default'" @click="handleClick">{{ vm.$t(name) }}
   </Button>
 <!--  v-if="vm.$libaray.checkButtonHasRight(rightButton,this)"-->
 </template>
@@ -12,6 +12,7 @@
 
 export default {
   name: 'BaseIndexButton',
+  inject: ['buttonGroup'],
   props: {
     name: {
       type: String,
@@ -48,7 +49,20 @@ export default {
     handleClick() {
       this.$refs.button.$el.focus();
       this.$emit('click')
-    }
+    },
+    /**
+     * @desc   : 添加到组中
+     * @author : 周兴
+     * @date   : 2023/3/3 17:26
+     */
+    addGroup(){
+      if(this.buttonGroup ){
+        this.buttonGroup.items.push(this);
+      }
+    },
+  },
+  mounted() {
+    this.addGroup();  // 添加到组中
   },
   created() {
   }

+ 0 - 1
src/locale/lang/zh-CN.js

@@ -67,7 +67,6 @@ export const button = {
   close: '关闭(X)',
   quotation: '报价单(Q)',
   editBatch: '批量修改(M)',
-  create: '新建(N)',
   init: '初始化(I)',
   syncResume: '同步履历(L)',
   index: '列表(L)',

+ 58 - 30
src/mixins/index.js

@@ -22,14 +22,14 @@ export const indexMixin = {
       loading: false,
       searchButtonName: null, // 查询按钮的权限名称
       initSearchFlag: true, // 初始查询标识
-      formType:null,// 如果是同一个路由,要记录类型
+      formType: null,// 如果是同一个路由,要记录类型
       pageFlag: true,    // 是否进行分页查询
       pageInfo: {
         total: 0,
         pageSize: this.$config.pageSize,
         currentPage: 1
       },
-      split:0.5,// 分区的默认
+      split: 0.5,// 分区的默认
       formDataInit: {},  // 记录页面初始化的数据
       tableData: [],
       searchInfo: [], // 记录的查询的实体
@@ -44,8 +44,9 @@ export const indexMixin = {
       tableSwitch: true, // 开关是否开启
       allScreenFlag: false, // 列表是否最大化
       params: {},
-      primaryKey:null, // 主键Id,
-      exportCondition:null,// 额外导出条件
+      primaryKey: null, // 主键Id,
+      routeObjName: '', // 页面路由名称
+      exportCondition: null,// 额外导出条件
       modalParams: {      // 打开modal传入的参数
         modalRef: 'modal_editAdd',
         button: 'add',
@@ -54,15 +55,15 @@ export const indexMixin = {
       },
     }
   },
-  watch:{
-    $route:{
-      handler:'resetData',
+  watch: {
+    $route: {
+      handler: 'resetData',
     }
   },
   methods: {
-    resetData(route,oldRoute){
-      if(route.meta.flgSameRoute && oldRoute && oldRoute.meta.flgSameRoute
-        && this && this.formType){
+    resetData(route, oldRoute) {
+      if (route.meta.flgSameRoute && oldRoute && oldRoute.meta.flgSameRoute
+        && this && this.formType) {
         this._createdInit();  // 加载创建的初始方法
         this._mountedInit();  // 加载加载完后的初始方法
       }
@@ -90,6 +91,7 @@ export const indexMixin = {
      * @date   : 2022/12/9 8:36
      */
     open(routeUrl, tableRef = 'table-select', isMustChooseFlag = true) {
+      console.log('rrr', routeUrl)
       if (!routeUrl || !routeUrl.key) {
         return;
       }
@@ -97,7 +99,7 @@ export const indexMixin = {
       let url = routeUrl.url
       let chooseKeys = tableRef ? this.$refs[tableRef].batchKeys : []
       // 校验
-      if (isMustChooseFlag && name.indexOf('add') < 0  && name !== 'search' && name !== 'clear') {
+      if (isMustChooseFlag && name.indexOf('add') < 0 && name !== 'search' && name !== 'clear') {
         // 新建不用校验
         if (!chooseKeys || chooseKeys.length === 0) {
           this.$Message.error(this.$t('W_013'))
@@ -122,7 +124,7 @@ export const indexMixin = {
               chooseKeys = []
             }
             if (chooseKeys && chooseKeys.length > 0) {
-              localSave(this.$route.name + '-edit',JSON.stringify({editKeys:chooseKeys.copy()}) )
+              localSave(this.$route.name + '-edit', JSON.stringify({editKeys: chooseKeys.copy()}))
               this.$router.push(url.endsWith('/') ? (url + chooseKeys[0]) : (url + '/' + chooseKeys[0]))
             } else {
               this.$router.push(url)
@@ -153,6 +155,14 @@ export const indexMixin = {
       }
     },
     /**
+     * @desc   : 打开窗体
+     * @author : 周兴
+     * @date   : 2023/3/3 17:47
+     */
+    _open(ref,) {
+
+    },
+    /**
      * @desc   : 打开窗体时校验数据(不给外部调用)
      * @author : 周兴
      * @date   : 2022/12/9 8:52
@@ -249,7 +259,7 @@ export const indexMixin = {
         this.setParams(arg);
         this.params.ftyId = this.$store.state.user.ftyId;// 给工厂赋默认值
         // 如果主键id有值需要在新建时清空主键Id
-        if(this.primaryKey && button === 'add' && this.params[this.primaryKey]){
+        if (this.primaryKey && button === 'add' && this.params[this.primaryKey]) {
           this.params[this.primaryKey] = null;
         }
         // 3、保存数据
@@ -309,7 +319,7 @@ export const indexMixin = {
                   this.$Message.success(this.$t('I_001', {'param': this.$v(button)}))
                 }
               } else {
-                if(res.message){
+                if (res.message) {
                   this.$Message.error(res.message)
                 }
               }
@@ -369,17 +379,17 @@ export const indexMixin = {
      * @author : 周兴
      * @date   : 2023/2/23 13:41
      */
-    cellMenu(e,tableRef = 'table-select'){
+    cellMenu(e, tableRef = 'table-select') {
       // 只有右键点击可以进行
-      if(e.button === 2 &&  this.$refs[tableRef]){
+      if (e.button === 2 && this.$refs[tableRef]) {
         //查询条件
         this.setCondition(this.searchCond)
         let params = this.searchList
         params.name = this.$route.name
         params.title = this.$route.meta.title
         // 合并实体
-        if(this.exportCondition){
-          this.objectMerge(params,this.exportCondition);
+        if (this.exportCondition) {
+          this.objectMerge(params, this.exportCondition);
         }
         this.$refs[tableRef].exportCondition = params;
       }
@@ -435,7 +445,6 @@ export const indexMixin = {
         if (key === 18) {
           code = 18
         }
-
         let btList = []
         for (let itKey in buttonList) {
           if (!buttonList[itKey].includes('(')) {
@@ -465,6 +474,7 @@ export const indexMixin = {
         }
         // Q:code = 81 查询
         btList.forEach(forIt => {
+          console.log('eee',code != 18,forIt.hotKey.toLowerCase() , e.key.toLowerCase())
           if (code != 18 || forIt.hotKey.toLowerCase() != e.key.toLowerCase()) return
           e.returnValue = false
           // 如果模块开着,在前面加上模块的ref名
@@ -490,6 +500,7 @@ export const indexMixin = {
       document.onkeyup = function (e) {
         const evn = e || event
         const key = evn.keyCode || evn.which || evn.charCode
+        console.log('eee',e.key,key)
         if (key === 18) {
           code = 0
         }
@@ -631,7 +642,7 @@ export const indexMixin = {
      * @author : 周兴
      * @date   : 2023/2/8 11:50
      */
-    _createdInit(){
+    _createdInit() {
       let _this = this
       // 初始化页面所需要的数据
       if (_this.initData) {
@@ -649,11 +660,11 @@ export const indexMixin = {
         })
       })
       // 记录formType
-      if(_this.$route.meta && _this.$route.meta.flgSameRoute){
+      if (_this.$route.meta && _this.$route.meta.flgSameRoute) {
         _this.formType = _this.$route.meta.formCode
       }
       // 初始化页面数据
-      if(_this.createdInit){
+      if (_this.createdInit) {
         _this.createdInit();
       }
     },
@@ -662,7 +673,7 @@ export const indexMixin = {
      * @author : 周兴
      * @date   : 2023/2/8 11:51
      */
-    _mountedInit(){
+    _mountedInit() {
       let _this = this
       // 初始时,需要查询数据库
       if (_this.initSearchFlag && _this.searchData) {
@@ -680,21 +691,38 @@ export const indexMixin = {
         _this.resizeTable()
       })
       // 初始化页面数据
-      if(_this.mountedInit){
+      if (_this.mountedInit) {
         _this.mountedInit();
       }
       // 给dk-table列表注册cellMenu事件
-      if(_this.$refs){
+      if (_this.$refs) {
         let arr = Object.keys(_this.$refs);
-        if(arr && arr.length > 0){
-          arr.forEach(it=>{
+        if (arr && arr.length > 0) {
+          arr.forEach(it => {
             // 说明是dk-table列表 增加右键事件 为了导出做准备
-            if(_this.$refs[it].$vnode && _this.$refs[it].$vnode.tag &&
-              _this.$refs[it].$vnode.tag.endsWith('DkTable')){
-              _this.$refs[it].$el.addEventListener('mousedown', function(e) {
+            if (_this.$refs[it].$vnode && _this.$refs[it].$vnode.tag &&
+              _this.$refs[it].$vnode.tag.endsWith('DkTable')) {
+              _this.$refs[it].$el.addEventListener('mousedown', function (e) {
                 _this.cellMenu(e, it);
               });
             }
+            // 说明是buttonGroup
+            if (_this.$refs[it].$vnode && _this.$refs[it].$vnode.tag &&
+              _this.$refs[it].$vnode.tag.endsWith('BaseIndexButton')
+              && this.routeObjName && _this.$config.routeUrl[this.routeObjName]) {
+              // _this.$refs[it].$vnode.componentInstance.$el.click();
+              let buttonRef = _this.$refs[it].$vnode?.data.ref;
+              // 查询特殊处理
+              if (buttonRef && (_this.$config.routeUrl[this.routeObjName][buttonRef] || buttonRef === 'search')) {
+                let obj = _this.$config.routeUrl[this.routeObjName][buttonRef];
+                if(buttonRef === 'search'){
+                  obj = _this.$config.routeUrl[buttonRef]
+                }
+                _this.$refs[it].$vnode.componentInstance.$el.addEventListener('click', function (e) {
+                  _this.open(obj)
+                });
+              }
+            }
           })
         }
       }

+ 6 - 9
src/view/core/factory/index.vue

@@ -1,22 +1,18 @@
 <template>
   <div class="main-div">
     <!--按钮区-->
-    <BaseIndexButtonGroup id="BaseIndexButtonGroup">
+    <BaseIndexButtonGroup ref="BaseIndexButtonGroup" id="BaseIndexButtonGroup">
       <template #left>
         <!--    查询    -->
-        <BaseIndexButton right-button="role-select" ref="search" name="search"
-                         @click="open($config.routeUrl.search)"></BaseIndexButton>
+        <BaseIndexButton right-button="role-select" ref="search" name="search"></BaseIndexButton>
         <!--    清空条件    -->
-        <BaseIndexButton right-button="role-clear" ref="clear" name="clear"
-                         @click="open($config.routeUrl.factory.clear)"></BaseIndexButton>
+        <BaseIndexButton right-button="role-clear" ref="clear" name="clear"></BaseIndexButton>
         <!--    编辑    -->
-        <BaseIndexButton right-button="role-edit" ref="edit" name="edit"
-                         @click="open($config.routeUrl.factory.edit)"></BaseIndexButton>
+        <BaseIndexButton right-button="role-edit" ref="edit" name="edit"></BaseIndexButton>
       </template>
       <template #right>
         <!--   新建     -->
-        <BaseIndexButton right-button="role-add" ref="create" name="create"
-                         @click="open($config.routeUrl.factory.add)"></BaseIndexButton>
+        <BaseIndexButton right-button="role-add" ref="add" name="add"></BaseIndexButton>
       </template>
     </BaseIndexButtonGroup>
 
@@ -245,6 +241,7 @@ export default {
   },
   created() {
     this.primaryKey = 'factoryId'  // 设置主键Id
+    this.routeObjName = 'factory'  // 设置路由名称
   }
 }
 </script>

+ 5 - 8
src/view/core/job/index.vue

@@ -5,19 +5,15 @@
     <BaseIndexButtonGroup id="BaseIndexButtonGroup">
       <template #left>
         <!--    查询    -->
-        <BaseIndexButton right-button="post-select" ref="search" name="search"
-                         @click="open($config.routeUrl.search)"></BaseIndexButton>
+        <BaseIndexButton right-button="post-select" ref="search" name="search"></BaseIndexButton>
         <!--    清空条件    -->
-        <BaseIndexButton right-button="post-clear" ref="clear" name="clear"
-                         @click="open($config.routeUrl.job.clear)"></BaseIndexButton>
+        <BaseIndexButton right-button="post-clear" ref="clear" name="clear"></BaseIndexButton>
         <!--    编辑    -->
-        <BaseIndexButton right-button="post-edit" ref="edit" name="edit"
-                         @click="open($config.routeUrl.job.edit)"></BaseIndexButton>
+        <BaseIndexButton right-button="post-edit" ref="edit" name="edit"></BaseIndexButton>
       </template>
       <template #right>
         <!--   新建     -->
-        <BaseIndexButton right-button="post-add" ref="create" name="create"
-                         @click="open($config.routeUrl.job.add)"></BaseIndexButton>
+        <BaseIndexButton right-button="post-add" ref="add" name="add"></BaseIndexButton>
       </template>
     </BaseIndexButtonGroup>
 
@@ -239,6 +235,7 @@ export default {
   },
   created() {
     this.primaryKey = 'jobId'  // 设置主键Id
+    this.routeObjName = 'job'  // 设置路由名称
   }
 }
 </script>

+ 5 - 4
src/view/core/organization/index.vue

@@ -4,15 +4,15 @@
     <BaseIndexButtonGroup id="BaseIndexButtonGroup">
       <template #left>
         <!--    查询    -->
-        <BaseIndexButton right-button="role-select" ref="search" name="search" @click="open($config.routeUrl.search)"></BaseIndexButton>
+        <BaseIndexButton right-button="role-select" ref="search" name="search"></BaseIndexButton>
         <!--    清空条件    -->
-        <BaseIndexButton right-button="role-clear" ref="clear" name="clear" @click="open($config.routeUrl.organization.clear)"></BaseIndexButton>
+        <BaseIndexButton right-button="role-clear" ref="clear" name="clear"></BaseIndexButton>
         <!--    编辑    -->
-        <BaseIndexButton right-button="role-edit" ref="edit" name="edit" @click="open($config.routeUrl.organization.edit)"></BaseIndexButton>
+        <BaseIndexButton right-button="role-edit" ref="edit" name="edit"></BaseIndexButton>
       </template>
       <template #right>
         <!--   新建     -->
-        <BaseIndexButton right-button="role-add" ref="create" name="create" @click="open($config.routeUrl.organization.add)"></BaseIndexButton>
+        <BaseIndexButton right-button="role-add" ref="add" name="add"></BaseIndexButton>
       </template>
     </BaseIndexButtonGroup>
 
@@ -278,6 +278,7 @@ export default {
   created() {
     this.pageFlag = false; // 不进行分页查询
     this.primaryKey = 'orgId'  // 设置主键Id
+    this.routeObjName = 'organization'  // 设置路由名称
   }
 }
 </script>

+ 5 - 8
src/view/core/post/index.vue

@@ -5,19 +5,15 @@
     <BaseIndexButtonGroup id="BaseIndexButtonGroup">
       <template #left>
         <!--    查询    -->
-        <BaseIndexButton right-button="post-select" ref="search" name="search"
-                         @click="open($config.routeUrl.search)"></BaseIndexButton>
+        <BaseIndexButton right-button="post-select" ref="search" name="search"></BaseIndexButton>
         <!--    清空条件    -->
-        <BaseIndexButton right-button="post-clear" ref="clear" name="clear"
-                         @click="open($config.routeUrl.post.clear)"></BaseIndexButton>
+        <BaseIndexButton right-button="post-clear" ref="clear" name="clear"></BaseIndexButton>
         <!--    编辑    -->
-        <BaseIndexButton right-button="post-edit" ref="edit" name="edit"
-                         @click="open($config.routeUrl.post.edit)"></BaseIndexButton>
+        <BaseIndexButton right-button="post-edit" ref="edit" name="edit"></BaseIndexButton>
       </template>
       <template #right>
         <!--   新建     -->
-        <BaseIndexButton right-button="post-add" ref="create" name="create"
-                         @click="open($config.routeUrl.post.add)"></BaseIndexButton>
+        <BaseIndexButton right-button="post-add" ref="add" name="add"></BaseIndexButton>
       </template>
     </BaseIndexButtonGroup>
 
@@ -237,6 +233,7 @@ export default {
   },
   created() {
     this.primaryKey = 'postId'  // 设置主键Id
+    this.routeObjName = 'post'  // 设置路由名称
   }
 }
 </script>

+ 6 - 10
src/view/core/role/index.vue

@@ -5,23 +5,18 @@
     <BaseIndexButtonGroup id="BaseIndexButtonGroup">
       <template #left>
         <!--    查询    -->
-        <BaseIndexButton right-button="role-select" ref="search" name="search"
-                         @click="open($config.routeUrl.search)"></BaseIndexButton>
+        <BaseIndexButton right-button="role-select" ref="search" name="search"></BaseIndexButton>
         <!--    清空条件    -->
-        <BaseIndexButton right-button="role-clear" ref="clear" name="clear"
-                         @click="open($config.routeUrl.role.clear)"></BaseIndexButton>
+        <BaseIndexButton right-button="role-clear" ref="clear" name="clear"></BaseIndexButton>
         <!--    编辑    -->
-        <BaseIndexButton right-button="role-edit" ref="edit" name="edit" :disabled="isEditDisable"
-                         @click="open($config.routeUrl.role.edit)"></BaseIndexButton>
+        <BaseIndexButton right-button="role-edit" ref="edit" name="edit" :disabled="isEditDisable"></BaseIndexButton>
         <!--    功能权限    -->
         <BaseIndexButton right-button="role-module-rights" ref="moduleRights" name="moduleRights"
-                         :disabled="isPowerDisable"
-                         @click="open($config.routeUrl.role.moduleRights)"></BaseIndexButton>
+                         :disabled="isPowerDisable"></BaseIndexButton>
       </template>
       <template #right>
         <!--   新建     -->
-        <BaseIndexButton right-button="role-add" ref="create" name="create"
-                         @click="open($config.routeUrl.role.add)"></BaseIndexButton>
+        <BaseIndexButton right-button="role-add" ref="add" name="add"></BaseIndexButton>
       </template>
     </BaseIndexButtonGroup>
 
@@ -436,6 +431,7 @@ export default {
   created() {
     this.pageFlag = false;
     this.primaryKey = 'roleId'  // 设置主键Id
+    this.routeObjName = 'role'  // 设置路由名称
   }
 }
 </script>

+ 7 - 11
src/view/core/staff/index.vue

@@ -13,24 +13,19 @@
     <BaseIndexButtonGroup id="BaseIndexButtonGroup">
       <template #left>
         <!--    查询    -->
-        <BaseIndexButton right-button="staff-select" ref="search" name="search"
-                         @click="open($config.routeUrl.search)"></BaseIndexButton>
+        <BaseIndexButton right-button="staff-select" ref="search" name="search"></BaseIndexButton>
         <!--    清空条件    -->
-        <BaseIndexButton right-button="staff-clear" ref="clear" name="clear"
-                         @click="open($config.routeUrl.staff.clear)"></BaseIndexButton>
+        <BaseIndexButton right-button="staff-clear" ref="clear" name="clear"></BaseIndexButton>
         <!--    编辑    -->
-        <BaseIndexButton right-button="staff-edit" ref="edit" name="edit"
-                         @click="open($config.routeUrl.staff.edit)"></BaseIndexButton>
+        <BaseIndexButton right-button="staff-edit" ref="edit" name="edit"></BaseIndexButton>
         <!--    批量离职    -->
-        <BaseIndexButton right-button="staff-dimission" ref="dimission" name="dimission"
-                         @click="open($config.routeUrl.staff.dimission)"/>
+        <BaseIndexButton right-button="staff-dimission" ref="dimission" name="dimission"/>
         <!--    导入    -->
-        <BaseIndexButton right-button="staff-import" ref="import" name="import" @click="importExcel"></BaseIndexButton>
+        <BaseIndexButton right-button="staff-import" ref="import" name="import"></BaseIndexButton>
       </template>
       <template #right>
         <!--   新建     -->
-        <BaseIndexButton right-button="post-add" ref="create" name="create"
-                         @click="open($config.routeUrl.staff.add)"></BaseIndexButton>
+        <BaseIndexButton right-button="post-add" ref="add" name="add"></BaseIndexButton>
       </template>
     </BaseIndexButtonGroup>
 
@@ -448,6 +443,7 @@ export default {
   ,
   created() {
     this.primaryKey = 'staffId'  // 设置主键Id
+    this.routeObjName = 'staff'  // 设置路由名称
   }
 }
 </script>