fubin 1 год назад
Родитель
Сommit
c72f36f7a4

+ 16 - 8
src/components/modal/dk-function/master-slave-checkbox.vue

@@ -52,19 +52,20 @@ export default {
     }
   },
   watch: {
-    data: {
-      handler(val) {
-        this.data = val
-        this.$emit('input', val)
-        this.$emit('on-change')
-      },
-      deep: true
-    },
+    // data: {
+    //   handler(val) {
+    //     this.data = val
+    //     this.$emit('input', val)
+    //     this.$emit('on-change')
+    //   },
+    //   deep: true
+    // },
     checked(n, o) {
       this.checkedData = n;
       if (!this.clickItemFlag) {
         // 需要把对应的子级勾上
         this.data.update(this.itemData, 'id', 'checked', 'parentId')
+        this.$emit('on-change')
         this.$forceUpdate()
       }
     },
@@ -78,6 +79,7 @@ export default {
     changeMaster(flag) {
       this.itemData.checked = flag;
       this.data.update(this.itemData, 'id', 'checked', 'parentId')
+      this.$emit('on-change')
       this.$forceUpdate()
     },
     /**
@@ -90,6 +92,12 @@ export default {
       if (flag) {
         this.clickItemFlag = true;
         this.itemData.checked = true;
+        this.$emit('on-change')
+        this.$forceUpdate()
+      }else{
+        // this.clickItemFlag = false;
+        this.itemData.checked = false;
+        this.$emit('on-change')
         this.$forceUpdate()
       }
     }

+ 2 - 2
src/mixins/index.js

@@ -374,8 +374,8 @@ export const indexMixin = {
     save(arg) {
       let modalRef = (this.modalParams && this.modalParams.modalRef) ? this.modalParams.modalRef : 'modal_editAdd';
       let button = (this.modalParams && this.modalParams.button) ? this.modalParams.button : 'add';
-      let clearFlag = (this.modalParams && this.modalParams.clearFlag) ? this.modalParams.clearFlag : true;
-      let closeFlag = (this.modalParams && this.modalParams.closeFlag) ? this.modalParams.closeFlag : false;
+      let clearFlag = (this.modalParams && this.modalParams.clearFlag != null) ? this.modalParams.clearFlag : true;
+      let closeFlag = (this.modalParams && this.modalParams.closeFlag != null) ? this.modalParams.closeFlag : false;
       // 1、校验
       this._validData(arg).then(res => {
         if (!res) {

+ 66 - 122
src/view/mst/com-menu/index.vue

@@ -4,9 +4,7 @@
     <loading :loading="loading" v-if="!modalVisible"></loading>
     <BaseIndexButtonGroup ref="BaseIndexButtonGroup" id="BaseIndexButtonGroup">
       <template #left>
-        <!--    查询    -->
         <BaseIndexButton ref="search" name="search"></BaseIndexButton>
-        <!--    编辑    -->
         <BaseIndexButton ref="edit" name="edit"></BaseIndexButton>
       </template>
       <template #right>
@@ -24,7 +22,7 @@
           <DkTableColumn field="gradeCode" :filter="false" :sortable="false" :center-flag="true"/>
           <DkTableColumn field="gradeName" :filter="false" :sortable="false" :center-flag="true"/>
         </DkTable>
-        <!-- 数据字典   -->
+        <!-- 常用功能   -->
         <DkTable slot="right" :id="'table-' + $options.name" ref="right-table"
                  :data="menuData"
                  :pageFlag="true"
@@ -73,7 +71,7 @@
                         <MasterSlaveCheckbox v-if="tIt[funcFlag]" :item="tIt" :name="name" :checked="tIt.checked"
                                              :disabled="disabled"
                                              :child-data="data.filter(item=>item.parentId == tIt.id)"
-                                             @on-change="handleChangeCheckbox1(tIt)"
+                                             @on-change="handleChangeCheckbox1()"
                                              ref="checkbox"></MasterSlaveCheckbox>
                       </div>
                     </dk-el-collapse-item>
@@ -85,7 +83,7 @@
           <!--常用功能-->
           <Col>
             <DkRow style="margin-left: 0px">
-              <DkTable :id="'table-' + $options.name" ref="table-select"
+              <DkTable v-show="showTable" :id="'table-' + $options.name" ref="table-select"
                        :data="useMenuData"
                        :width="500"
                        :pageFlag="false"
@@ -114,19 +112,18 @@ export default {
   data() {
     let self = this
     return {
+      showTable: true,
       modalTitle: '',//新建编辑弹窗名称
-      submitType: '',//新建编辑提交类型
       formData: {
         gradeCode: null,
         gradeName: null,
       },
       split: 0.15,
       minSplit: 0.15,
-      gradeList: [],
+      // gradeList: [],
       leftData: [],
       menuData: [],
       useMenuData: [],
-      documentKeyDownContent: Object,
       title: '',
       funcFlag: 'flgMenu',
       name: 'menuName',
@@ -137,14 +134,11 @@ export default {
       model: [],
       collapseFlag: true,
       parentData: [],
-      webData: [],
-      appData: [],
       data: [],
       collapseItems: [],
       collapseIds: [],
       disabled: false,
       tabValue: 'CP-WEB',
-      tabOptions: null,
       appList: [],
       tabList: [],
       tableRef: 'left-table',
@@ -153,6 +147,50 @@ export default {
   },
   methods: {
     /**
+     * @desc   : 加载数据
+     * @author : 常皓宁
+     * @date   : 2024/4/30 9:02
+     */
+    initData() {
+      // 获取应用
+      this.getApplication()
+    },
+    /**
+     * @desc   : 获取应用
+     * @author : 洪旭东
+     * @date   : 2023-06-30 15:02
+     */
+    getApplication() {
+      this.excute(this.$service.commonService, this.$service.commonService.getApplication, {}).then(res => {
+        if (res.code === this.$config.SUCCESS_CODE) {
+          let data = res.data.filter(it => it.appCode != 'DK-WEB')
+          this.appList = data
+          this.tabList = data.map(m => {
+            return {
+              label: m.appName,
+              name: m.appCode
+            }
+          })
+        }
+      })
+    },
+    /**
+     * @desc   : 获取数据
+     * @author : 常皓宁
+     * @date   : 2024/3/9 10:55
+     */
+    getData(params) {
+      // 查询数据
+      this.excute(this.$service.commonService, this.$service.commonService.getGrade, params).then(res => {
+        if (res.code === this.$config.SUCCESS_CODE) {
+          let gradeData = res.data.filter(it => it.gradeCode === 'STD' || it.gradeCode === 'PRO')
+          // this.gradeList = gradeData
+          this.leftData = gradeData
+        }
+      })
+      this.loading = false
+    },
+    /**
      * @desc   : 左侧列表行变化事件
      * @author : 常皓宁
      * @date   : 2024/1/31 9:03
@@ -169,17 +207,6 @@ export default {
         })
       }
     },
-
-    /**
-     * @desc   : 获取数据
-     * @author : 常皓宁
-     * @date   : 2024/3/9 10:55
-     */
-    getData(params) {
-      this.getGrade()
-      this.loading = false
-    },
-
     /**
      * @desc   : 新建按钮点击事件
      * @author : 常皓宁
@@ -193,62 +220,37 @@ export default {
         this.formData.gradeName = row.gradeName
       }
       this.getAppMenu(this.formData.gradeCode)
-      this.editAddModal = true
+      this.modalParams.clearFlag = false
+      this.modalParams.closeFlag = true
       this.modalParams.button = 'edit'
     },
-
     /**
-     * @desc   : 新建
+     * @desc   : 保存
      * @author : 常皓宁
      * @date   : 2024/3/9 15:51
      */
     saveData() {
-      // console.log('this.useMenuData', this.useMenuData)
       let useMenuData = this.useMenuData
       let displayNo = 1
       useMenuData.map(row => {
         let item = row
         this.$set(item, 'gradeCode', this.formData.gradeCode)
         this.$set(item, 'displayNo', displayNo)
-        // this.$set(item, 'appCode', displayNo)
         displayNo++
         return item
       })
       let params = useMenuData
-      // console.log('sadas', params)
       //编辑
       if (this.modalParams.button === this.$config.formMode.edit) {
         return this.excute(this.$service.comMenuService, this.$service.comMenuService.update, params)
       }
     },
-
-    /**
-     * @desc   : 获取版本代码
-     * @author : 常皓宁
-     * @date   : 2024/4/15 10:47
-     */
-    getGrade() {
-      // 查询数据
-      let params = {}
-      this.excute(this.$service.commonService, this.$service.commonService.getGrade, params).then(res => {
-        if (res.code === this.$config.SUCCESS_CODE) {
-          let gradeData = res.data.filter(it => it.gradeCode === 'STD' || it.gradeCode === 'PRO')
-          this.gradeList = gradeData
-          this.leftData = gradeData
-        }
-      })
-    },
-
     /**
      * @desc   : 勾选节点上的选择框
      * @author : 周兴
      * @date   : 2022/12/29 16:52
      */
     handleChangeCheckbox(checked, id, name) {
-      console.log("handleChangeCheckbox")
-
-
-      // console.log('1')
       let item = {id: id, checked: checked, menuName: name};
       let filterRows = this.data.filter(it => it.id === id);
       if (filterRows && filterRows.length > 0) {
@@ -262,23 +264,25 @@ export default {
         this.useMenuData = this.useMenuData.filter(it => it.id !== item.id)
       }
     },
-
     /**
      * @desc   : 勾选节点上的选择框
      * @author : 周兴
      * @date   : 2022/12/29 16:52
      */
     handleChangeCheckbox1() {
-      console.log("handleChangeCheckbox1")
-
       let list = []
-
-      for (let re of this.$refs.checkbox) {
-
-        list = list.concat(re.data.filter(item => item.checked))
+      if (this.appCode == 'CP-WEB') {
+        for (let re of this.$refs.checkbox) {
+          list = list.concat(re.data.filter(item => item.checked))
+        }
+        this.useMenuData = list
+      } else {
+        let filters = this.$refs.checkbox.filter(it => it.checked)
+        filters.forEach(it => {
+          list.push(it.itemData)
+        })
+        this.useMenuData = list
       }
-      // console.log('2', list)
-      this.useMenuData = list
     },
 
     /**
@@ -287,8 +291,6 @@ export default {
      * @date   : 2022/12/29 13:54
      */
     getCollapseItems() {
-      console.log("getCollapseItems")
-
       let items = this.data.filter(it => !it[this.funcFlag]);
       if (items && items.length > 0) {
         items.forEach(it => {
@@ -297,34 +299,6 @@ export default {
         })
       }
     },
-
-    /**
-     * @desc   : 重新计算位置
-     * @author : 周兴
-     * @date   : 2022/12/29 16:02
-     */
-    handleChange(id) {
-      // console.log('切换tab')
-      //
-      // this.$nextTick(() => {
-      //   debugger
-      //   if (this.collapseItems && this.collapseItems.length > 0) {
-      //     let index = 0;
-      //     if (id) {
-      //       index = this.collapseItems.findIndex(item => item == 'collapseItem_' + id)
-      //     }
-      //     for (let i = index + 1; i < this.collapseItems.length; i++) {
-      //       let it = this.collapseItems[i]
-      //       if (this.$refs[it] && this.$refs[it].length > 0) {
-      //         this.$refs[it][0].itemTop = null;
-      //         setTimeout(() => {
-      //           this.$refs[it][0].countCheckboxLocation();
-      //         }, 400)
-      //       }
-      //     }
-      //   }
-      // })
-    },
     /**
      * @desc   : 切换应用
      * @author : 付斌
@@ -335,26 +309,6 @@ export default {
       this.getAppMenu(this.formData.gradeCode)
     },
     /**
-     * @desc   : 获取应用
-     * @author : 洪旭东
-     * @date   : 2023-06-30 15:02
-     */
-    getApplication() {
-      this.excute(this.$service.commonService, this.$service.commonService.getApplication, {}).then(res => {
-        if (res.code === this.$config.SUCCESS_CODE) {
-          let data = res.data.filter(it => it.appCode != 'DK-WEB')
-          this.appList = data
-          this.tabList = data.map(m => {
-            return {
-              label: m.appName,
-              name: m.appCode
-            }
-          })
-        }
-      })
-    },
-
-    /**
      * @desc   : 获取功能
      * @author : 常皓宁
      * @date   : 2024/5/11 13:42
@@ -369,8 +323,9 @@ export default {
           this.data = res.data.list
           // 先过滤顶级
           this.parentData = this.data?.filter(it => !it.parentId);
-          this.webData = this.parentData.filter(f => f.appCode == 'CP-WEB')
-          this.appData = this.parentData.filter(f => f.appCode == 'CP-WXP')
+          this.editAddModal = true
+          this.useMenuData = this.data.filter(it => it.checked);
+          this.$refs['table-select'].reloadData(this.useMenuData);
           if (this.collapseFlag) {
             this.model = this.data.map(it => it.id)
           } else {
@@ -379,22 +334,11 @@ export default {
           this.$nextTick(() => {
             this.getCollapseItems();
           })
-          this.getApplication()
         } else {
           this.$Message.warning(res.message)
         }
       })
     },
-
-    /**
-     * @desc   : 加载数据
-     * @author : 常皓宁
-     * @date   : 2024/4/30 9:02
-     */
-    initData() {
-      // this.getGrade()
-      // this.getAppMenu();
-    },
   },
   created() {
     this.primaryKey = 'gradeCode'  // 设置主键Id