loki 3 роки тому
батько
коміт
264bc6d1c2

+ 0 - 2
src/api/help/info.js

@@ -8,5 +8,3 @@ export const saveItem = params =>
 	api.post(`/yxl-back-end/framework/help/content/save`, params);
 export const delItem = ({ id, params }) =>
 	api.del(`/yxl-back-end/framework/help/content/${id}`, params);
-// export const getSMSCode = params =>
-//   api.post(`/yxl-back-end/framework/uiac/admin/mobile-number-sms/code`, params);

+ 0 - 2
src/api/help/type.js

@@ -8,5 +8,3 @@ export const saveItem = params =>
   api.post(`/yxl-back-end/framework/help/group/save`, params);
 export const delItem = ({ id, params }) =>
   api.del(`/yxl-back-end/framework/help/group/${id}`, params);
-// export const getSMSCode = params =>
-//   api.post(`/yxl-back-end/framework/uiac/admin/mobile-number-sms/code`, params);

+ 6 - 0
src/containers/ToolbarContainer.vue

@@ -70,6 +70,12 @@
               end-placeholder="结束日期"
             >
             </el-date-picker>
+
+            <!-- 追加 -->
+            <IssueTypeSelect
+              v-if="field.type === 'issueTypeSelect'"
+              v-model="form[field.name]"
+            ></IssueTypeSelect>
           </el-form-item>
         </el-col>
       </el-row>

+ 2 - 0
src/containers/index.js

@@ -1,4 +1,6 @@
 import Vue from 'vue';
+import IssueTypeSelect from './issueType/IssueTypeSelect.vue';
 import ToolbarContainer from './ToolbarContainer.vue';
 
+Vue.component('IssueTypeSelect', IssueTypeSelect);
 Vue.component('ToolbarContainer', ToolbarContainer);

+ 56 - 0
src/containers/issueType/IssueTypeSelect.vue

@@ -0,0 +1,56 @@
+<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>
+</template>
+
+<script>
+export default {
+  name: 'IssueTypeSelect',
+
+  model: {
+    prop: 'value',
+    event: 'change'
+  },
+
+  props: {
+    value: {
+      type: String,
+      default: ''
+    },
+    params: {
+      type: Object,
+      default: () => {}
+    }
+  },
+
+  data() {
+    return {
+      options: []
+    };
+  },
+
+  // mounted() {
+  //   this.loadData()
+  // },
+
+  methods: {
+    // async loadData() {
+    //   const { success, data, msg } = await (params)
+    //   if (success) {
+    //     this.options = data
+    //   } else {
+    //     this.$error(msg)
+    //   }
+    // }
+  }
+};
+</script>
+
+<style lang="scss" scoped></style>

+ 1 - 1
src/store/modules/user.js

@@ -123,7 +123,7 @@ const actions = {
     resetRouter();
     commit('RESET_STATE');
     commit('SET_ROLES', []);
-    resolve();
+    // resolve();
     //     })
     //     .catch(error => {
     //       reject(error);

+ 8 - 0
src/utils/dialog-helper.js

@@ -1,6 +1,7 @@
 import Vue from 'vue';
 import store from 'store';
 import IssueTypeItem from 'views/helpInfo/issueType/modal/ItemModal.vue';
+import InformationItem from 'views/helpInfo/information/modal/ItemModal.vue';
 
 const modal = (Component, props) => {
   let _component = null;
@@ -29,3 +30,10 @@ let IssueTypeItemModal = data => {
 Vue.prototype.$IssueTypeItemModal = params => {
   IssueTypeItemModal(params);
 };
+
+let InformationItemModal = data => {
+  modal(InformationItem, data);
+};
+Vue.prototype.$InformationItemModal = params => {
+  InformationItemModal(params);
+};

+ 1 - 4
src/utils/request.js

@@ -20,10 +20,9 @@ const service = axios.create({
 });
 
 // request interceptor
-service.interceptors.request.use(
+axios.interceptors.request.use(
   config => {
     // do something before request is sent
-
     if (store.getters.token) {
       // let each request carry token
       // ['X-Token'] is a custom headers key
@@ -299,8 +298,6 @@ const delData = (url, data = {}, params, config) => {
 };
 
 const post = (url, data = {}, config) => {
-  console.log(data);
-  console.log(config);
   config = pretreatConfig(config);
   config = Object.assign(
     {

+ 61 - 11
src/views/helpInfo/information/index.vue

@@ -3,7 +3,7 @@
     <toolbar @onSearch="filterData" />
 
     <div class="m-10 bg-w p-20 br-10">
-      <el-button type="primary" icon="el-icon-plus" @click="handleSubmit"
+      <el-button type="primary" icon="el-icon-plus" @click="handleAdd"
         >新增</el-button
       >
       <base-table
@@ -28,7 +28,7 @@ export default {
 
   mixins: [
     mxFilterList({
-      // fetchList: iGetList // 在下方data再声明一个 fetchList: iGetList 同等效果
+      fetchList: getList // 在下方data再声明一个 fetchList: iGetList 同等效果
     })
   ],
 
@@ -41,12 +41,12 @@ export default {
           width: '160'
         },
         {
-          key: 'region',
+          key: 'helpGroupName',
           name: '分类名称',
           width: '180'
         },
         {
-          key: 'region',
+          key: 'sort',
           name: '排序',
           minWidth: '120'
         },
@@ -56,22 +56,72 @@ export default {
           width: '180'
         },
         {
-          key: 'region',
-          name: '备注',
-          width: '180'
-        },
-        {
           key: 'isShow',
           name: '状态',
           width: '180'
         },
         {
-          key: 'region',
+          key: 'action',
           name: '操作',
-          width: '180'
+          width: '180',
+          render: (h, { row }) => {
+            const action = [];
+            action.push(
+              h(
+                'el-button',
+                {
+                  props: {
+                    type: 'text'
+                  },
+                  on: {
+                    click: () =>
+                      this.$InformationItemModal({
+                        id: row.id
+                      })
+                  }
+                },
+                '编辑'
+              )
+            );
+            action.push(
+              h(
+                'BaseBtn',
+                {
+                  props: {
+                    popip: true,
+                    txt: '删除',
+                    type: 'text'
+                  },
+                  class: 'ml-10',
+                  on: {
+                    ok: () => this.handleDelItem(row)
+                  }
+                },
+                '删除'
+              )
+            );
+
+            return h('div', action);
+          }
         }
       ]
     };
+  },
+
+  methods: {
+    handleAdd() {
+      this.$InformationItemModal();
+    },
+    async handleDelItem(item) {
+      const { success, msg } = await delItem({
+        id: item.id
+      });
+      if (success) {
+        this.$success('删除成功!');
+      } else {
+        this.$error(msg);
+      }
+    }
   }
 };
 </script>

+ 134 - 0
src/views/helpInfo/information/modal/ItemModal.vue

@@ -0,0 +1,134 @@
+<template>
+  <el-dialog
+    :title="title"
+    :visible.sync="modal"
+    width="800px"
+    :close-on-click-modal="false"
+    @close="
+      res => {
+        $emit('cancel');
+      }
+    "
+  >
+    <el-form ref="form" :model="form" :rules="rules" label-width="100px">
+      <el-form-item label="标题" prop="name">
+        <el-input v-model="form.name"></el-input>
+      </el-form-item>
+      <el-form-item label="内容" prop="content">
+        <!-- TODO 富文本编辑框 -->
+        <el-input v-model="form.content"></el-input>
+      </el-form-item>
+      <el-form-item label="分类" prop="helpGroupId">
+        <IssueTypeSelect v-model="form.helpGroupId"></IssueTypeSelect>
+      </el-form-item>
+      <el-form-item label="状态">
+        <el-radio-group v-model="form.isShow" prop="isShow">
+          <el-radio :label="true">显示</el-radio>
+          <el-radio :label="false">隐藏</el-radio>
+        </el-radio-group>
+      </el-form-item>
+      <el-form-item label="排序" prop="sort">
+        <el-input-number
+          v-model="form.sort"
+          :min="1"
+          :max="10"
+          label="序号"
+        ></el-input-number>
+      </el-form-item>
+    </el-form>
+    <span slot="footer" class="dialog-footer">
+      <el-button @click="modal = false">取消</el-button>
+      <el-button type="primary" @click="handleConfirm">确定</el-button>
+    </span>
+  </el-dialog>
+</template>
+
+<script>
+import { getItem, saveItem } from '@/api/help/info';
+
+export default {
+  name: 'InformationItemModal',
+
+  props: {
+    id: {
+      type: String,
+      default: ''
+    }
+  },
+
+  data() {
+    return {
+      modal: true,
+
+      form: {
+        name: '',
+        content: '',
+        helpGroupId: null,
+        isShow: false,
+        sort: 1
+      },
+      rules: {
+        name: [{ required: true, message: '请输入活动名称', trigger: 'blur' }],
+        content: [
+          { required: true, message: '请输入活动内容', trigger: 'blur' }
+        ],
+        helpGroupId: [
+          { required: true, message: '请选择所属分类', trigger: 'change' }
+        ]
+      }
+    };
+  },
+
+  computed: {
+    title() {
+      if (this.id) {
+        return '编辑资讯';
+      } else {
+        return '新增资讯';
+      }
+    }
+  },
+
+  watch: {
+    id: {
+      handler(id) {
+        id && this.loadData();
+      },
+      immediate: true
+    }
+  },
+
+  mounted() {},
+
+  methods: {
+    async loadData() {
+      const { success, data, msg } = await getItem({
+        id: this.id
+      });
+      if (success) {
+        this.form = data;
+      } else {
+        this.$error(msg);
+      }
+    },
+
+    handleConfirm() {
+      this.$refs.form.validate(async valid => {
+        if (valid) {
+          const params = Object.assign({}, this.form);
+          if (this.id) params.id = this.id;
+          const { success, msg } = await saveItem(params);
+          if (success) {
+            this.$success('保存成功!');
+            this.modal = false;
+          } else {
+            this.$error(msg);
+          }
+        }
+      });
+    }
+  }
+};
+</script>
+
+<style lang="scss" scoped></style>

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

@@ -3,6 +3,8 @@
 </template>
 
 <script>
+import TYPE from '@/const/type';
+
 export default {
   name: 'InformationToolbar',
 
@@ -15,10 +17,18 @@ export default {
           label: '分类名称'
         },
         {
+          type: 'issueTypeSelect',
+          name: 'type',
+          label: '分类',
+          labelWidth: '100px'
+        },
+        {
           type: 'select',
           name: 'status',
           label: '状态',
-          labelWidth: '100px'
+          labelWidth: '100px',
+          options: TYPE,
+          format: val => (val !== null ? !!val : null)
         }
       ]
     };