浏览代码

feat: #修正

loki 3 年之前
父节点
当前提交
50b61f0753

+ 61 - 29
src/containers/issueType/IssueTypeSelect.vue

@@ -1,54 +1,86 @@
 <template>
 <template>
-  <el-select v-model="value" :clearable="true" placeholder="请选择分类">
-    <el-option
-      v-for="item in options"
-      :key="item.value"
-      :label="item.label"
-      :value="item.value"
-    >
-    </el-option>
-  </el-select>
+  <el-cascader
+    :value="vModel"
+    :options="options"
+    :clearable="true"
+    :show-all-levels="false"
+    @change="onChange"
+  ></el-cascader>
 </template>
 </template>
 
 
 <script>
 <script>
+import { getList } from '@/api/help/type';
+
+const resetList = (arr = []) => {
+  const reuslt = arr.map(x => ({
+    value: x.id,
+    label: x.name,
+    children: x.children && x.children.length > 0 ? resetList(x.children) : null
+  }));
+  return reuslt;
+};
+
+const checkList = (list = []) => {
+  list = list.reduce((init, item) => {
+    if (item.children) {
+      init.push(item);
+    }
+    return init;
+  }, []);
+  return list;
+};
+
 export default {
 export default {
   name: 'IssueTypeSelect',
   name: 'IssueTypeSelect',
 
 
-  model: {
-    prop: 'value',
-    event: 'change'
-  },
-
   props: {
   props: {
     value: {
     value: {
       type: String,
       type: String,
       default: ''
       default: ''
-    },
-    params: {
-      type: Object,
-      default: () => {}
     }
     }
   },
   },
 
 
   data() {
   data() {
     return {
     return {
+      vModel: this.value,
       options: []
       options: []
     };
     };
   },
   },
 
 
-  // mounted() {
-  //   this.loadData()
-  // },
+  watch: {
+    value: {
+      handler(val) {
+        this.vModel = val;
+      },
+      immediate: true
+    }
+  },
+
+  mounted() {
+    this.loadData();
+  },
 
 
   methods: {
   methods: {
-    // async loadData() {
-    //   const { success, data, msg } = await (params)
-    //   if (success) {
-    //     this.options = data
-    //   } else {
-    //     this.$error(msg)
-    //   }
-    // }
+    onChange(value) {
+      console.log(value);
+      this.$emit('input', value[1] || null);
+    },
+
+    async loadData() {
+      const { success, data, msg } = await getList({
+        data: {
+          isShow: null
+        },
+        limit: 999999,
+        start: 1
+      });
+      if (success) {
+        let result = resetList(data.data);
+        this.options = checkList(result);
+      } else {
+        this.$error(msg);
+      }
+    }
   }
   }
 };
 };
 </script>
 </script>

+ 13 - 0
src/main.js

@@ -23,6 +23,19 @@ import '@/plugins/viewerjs';
 
 
 import message from '@/utils/message';
 import message from '@/utils/message';
 
 
+import bus from './utils/bus';
+
+Vue.prototype.$Bus = bus;
+Vue.prototype.$g_emit = (eventName, payload) => {
+  bus.$emit(eventName, payload);
+};
+Vue.prototype.$g_on = (eventName, func) => {
+  bus.$on(eventName, func);
+};
+Vue.prototype.$g_off = (eventName, func) => {
+  bus.$off(eventName, func);
+};
+
 /**
 /**
  * If you don't want to use mock-server
  * If you don't want to use mock-server
  * you want to use MockJs for mock api
  * you want to use MockJs for mock api

+ 1 - 1
src/mixins/filterList.js

@@ -44,7 +44,7 @@ const filterList = (params = {}) => ({
         limit: this.pagination.pageSize,
         limit: this.pagination.pageSize,
         start: this.pagination.page
         start: this.pagination.page
       });
       });
-      if (data in data) {
+      if ('data' in data) {
         const items = data.data;
         const items = data.data;
         const total = {
         const total = {
           page: data.page,
           page: data.page,

+ 3 - 0
src/utils/bus.js

@@ -0,0 +1,3 @@
+import Vue from 'vue';
+
+export default new Vue();

+ 14 - 3
src/views/helpInfo/information/index.vue

@@ -1,6 +1,6 @@
 <template>
 <template>
   <div class="">
   <div class="">
-    <toolbar @onSearch="filterData" />
+    <toolbar @on-filter="filterData" @on-reset="filterData" />
 
 
     <div class="m-10 bg-w p-20 br-10">
     <div class="m-10 bg-w p-20 br-10">
       <el-button type="primary" icon="el-icon-plus" @click="handleAdd"
       <el-button type="primary" icon="el-icon-plus" @click="handleAdd"
@@ -51,14 +51,17 @@ export default {
           minWidth: '120'
           minWidth: '120'
         },
         },
         {
         {
-          key: 'region',
+          key: 'createAt',
           name: '创建时间',
           name: '创建时间',
           width: '180'
           width: '180'
         },
         },
         {
         {
           key: 'isShow',
           key: 'isShow',
           name: '状态',
           name: '状态',
-          width: '180'
+          width: '180',
+          type: 'tag',
+          fetchTagType: val => (val ? 'success' : 'info'),
+          tagName: row => (row.isShow ? '显示' : '隐藏')
         },
         },
         {
         {
           key: 'action',
           key: 'action',
@@ -108,6 +111,14 @@ export default {
     };
     };
   },
   },
 
 
+  created() {
+    this.$g_on('information_reload', this.reload);
+  },
+
+  beforeDestroy() {
+    this.$g_off('information_reload', this.reload);
+  },
+
   methods: {
   methods: {
     handleAdd() {
     handleAdd() {
       this.$InformationItemModal();
       this.$InformationItemModal();

+ 2 - 1
src/views/helpInfo/information/modal/ItemModal.vue

@@ -16,7 +16,7 @@
       </el-form-item>
       </el-form-item>
       <el-form-item label="内容" prop="content">
       <el-form-item label="内容" prop="content">
         <!-- TODO 富文本编辑框 -->
         <!-- TODO 富文本编辑框 -->
-        <el-input v-model="form.content"></el-input>
+        <RichText v-model="form.content"></RichText>
       </el-form-item>
       </el-form-item>
       <el-form-item label="分类" prop="helpGroupId">
       <el-form-item label="分类" prop="helpGroupId">
         <IssueTypeSelect v-model="form.helpGroupId"></IssueTypeSelect>
         <IssueTypeSelect v-model="form.helpGroupId"></IssueTypeSelect>
@@ -121,6 +121,7 @@ export default {
           if (success) {
           if (success) {
             this.$success('保存成功!');
             this.$success('保存成功!');
             this.modal = false;
             this.modal = false;
+            this.$g_emit('information_reload');
           } else {
           } else {
             this.$error(msg);
             this.$error(msg);
           }
           }

+ 1 - 1
src/views/helpInfo/information/toolbar.vue

@@ -28,7 +28,7 @@ export default {
           label: '状态',
           label: '状态',
           labelWidth: '100px',
           labelWidth: '100px',
           options: TYPE,
           options: TYPE,
-          format: val => (val !== null ? !!val : null)
+          format: val => (val !== null && val !== '' ? !!val : null)
         }
         }
       ]
       ]
     };
     };

+ 24 - 50
src/views/helpInfo/issueType/index.vue

@@ -39,7 +39,7 @@ export default {
         {
         {
           key: 'id',
           key: 'id',
           name: 'ID',
           name: 'ID',
-          width: '160'
+          width: '200'
         },
         },
         {
         {
           key: 'name',
           key: 'name',
@@ -88,23 +88,24 @@ export default {
                 '编辑'
                 '编辑'
               )
               )
             );
             );
-            action.push(
-              h(
-                'el-button',
-                {
-                  props: {
-                    type: 'text'
+            row.parentId == -1 &&
+              action.push(
+                h(
+                  'el-button',
+                  {
+                    props: {
+                      type: 'text'
+                    },
+                    on: {
+                      click: () =>
+                        this.$IssueTypeItemModal({
+                          parentId: row.id
+                        })
+                    }
                   },
                   },
-                  on: {
-                    click: () =>
-                      this.$IssueTypeItemModal({
-                        parentId: row.parentId
-                      })
-                  }
-                },
-                '添加下级分类'
-              )
-            );
+                  '添加下级分类'
+                )
+              );
             action.push(
             action.push(
               h(
               h(
                 'BaseBtn',
                 'BaseBtn',
@@ -130,39 +131,12 @@ export default {
     };
     };
   },
   },
 
 
-  mounted() {
-    setTimeout(() => {
-      this.items = [
-        {
-          id: 998,
-          name: 'sex',
-          isShow: true,
-          sort: 10,
-          children: [
-            {
-              id: 31,
-              name: 'man',
-              isShow: false,
-              sort: 9,
-              children: [
-                {
-                  id: 312,
-                  name: 'man',
-                  isShow: true,
-                  sort: 9
-                }
-              ]
-            },
-            {
-              id: 9,
-              name: 'woman',
-              isShow: true,
-              sort: 7
-            }
-          ]
-        }
-      ];
-    }, 1000);
+  created() {
+    this.$g_on('issue_type_reload', this.reload);
+  },
+
+  beforeDestroy() {
+    this.$g_off('issue_type_reload', this.reload);
   },
   },
 
 
   methods: {
   methods: {

+ 1 - 0
src/views/helpInfo/issueType/modal/ItemModal.vue

@@ -113,6 +113,7 @@ export default {
           if (success) {
           if (success) {
             this.$success('保存成功!');
             this.$success('保存成功!');
             this.modal = false;
             this.modal = false;
+            this.$g_emit('issue_type_reload');
           } else {
           } else {
             this.$error(msg);
             this.$error(msg);
           }
           }

+ 1 - 1
src/views/helpInfo/issueType/toolbar.vue

@@ -22,7 +22,7 @@ export default {
           label: '状态',
           label: '状态',
           labelWidth: '100px',
           labelWidth: '100px',
           options: TYPE,
           options: TYPE,
-          format: val => (val !== null ? !!val : null)
+          format: val => (val !== null && val !== '' ? !!val : null)
         }
         }
       ]
       ]
     };
     };