sunlupeng 1 year ago
parent
commit
6ad70a1809
4 changed files with 139 additions and 0 deletions
  1. 1 0
      src/permission.js
  2. 2 0
      src/router/index.js
  3. 51 0
      src/utils/index.js
  4. 85 0
      src/views/certManage/certRules.vue

+ 1 - 0
src/permission.js

@@ -45,6 +45,7 @@ const myRoles = [
   'festivalManage', 
   'festivalList', 
   'certManage', 
+  'certRules',
   'certList', 
   'dictManage', 
   'dictList', 

+ 2 - 0
src/router/index.js

@@ -213,7 +213,9 @@ export const asyncRouterMap = [
       icon: 'lipin'
     },
     children: [
+      { path: 'certRules', component: _import('certManage/certRules'), name: 'certRules', meta: { title: '积分获取规则', icon: 'lipin', noCache: true }},
       { path: 'certList', component: _import('certManage/certList'), name: 'certList', meta: { title: '证书列表', icon: 'lipin', noCache: true }},
+      
     ]
   },
   {

+ 51 - 0
src/utils/index.js

@@ -2,6 +2,57 @@
  * Created by jiachenpan on 16/11/18.
  */
 
+/**
+ * 构造树型结构数据
+ * @param {*} data 数据源
+ * @param {*} id id字段 默认 'id'
+ * @param {*} parentId 父节点字段 默认 'parentId'
+ * @param {*} children 孩子节点字段 默认 'children'
+ */
+export function handleTree(data, id, parentId, children) {
+  let config = {
+    id: id || 'id',
+    parentId: parentId || 'parentId',
+    childrenList: children || 'children'
+  };
+
+  var childrenListMap = {};
+  var nodeIds = {};
+  var tree = [];
+
+  for (let d of data) {
+    let parentId = d[config.parentId];
+    if (childrenListMap[parentId] == null) {
+      childrenListMap[parentId] = [];
+    }
+    nodeIds[d[config.id]] = d;
+    childrenListMap[parentId].push(d);
+  }
+
+  for (let d of data) {
+    let parentId = d[config.parentId];
+    if (nodeIds[parentId] == null) {
+      tree.push(d);
+    }
+  }
+
+  for (let t of tree) {
+    adaptToChildrenList(t);
+  }
+
+  function adaptToChildrenList(o) {
+    if (childrenListMap[o[config.id]] !== null) {
+      o[config.childrenList] = childrenListMap[o[config.id]];
+    }
+    if (o[config.childrenList]) {
+      for (let c of o[config.childrenList]) {
+        adaptToChildrenList(c);
+      }
+    }
+  }
+  return tree;
+}
+
 export function parseTime(time, cFormat) {
   if (arguments.length === 0) {
     return null

+ 85 - 0
src/views/certManage/certRules.vue

@@ -0,0 +1,85 @@
+<template>
+    <div class="app-container calendar-list-container" style="padding-bottom: 80px;">
+        <el-form v-loading="loading" :rules="rules" ref="dataForm" :model="dataForm" status-icon label-position="left" label-width="100px" style='width: 85%; margin-left:50px;'>
+         <el-form-item  label="标题" prop="title">
+              <el-input v-model="dataForm.title"></el-input>
+            </el-form-item>
+            <el-form-item
+              style="width: 100%"
+              label="内容"
+              prop="content"
+            >
+              <tinymce v-model="dataForm.content" ref="tinymce"></tinymce>
+            </el-form-item>
+  
+        </el-form>
+        <el-button style="float: right;margin-right: 120px;" type="primary" @click="updateData">修改</el-button>
+    
+        
+    </div>
+   
+  </template>
+  
+  <style>
+    
+  </style>
+  
+  
+  <script>
+   import {goodsExchangeRulesDetail, updateGoodsExchangeRules} from "@/api/goodsManage";
+    import waves from "@/directive/waves"; // 水波纹指令
+    import Tinymce from '@/components/Tinymce'
+    export default {
+    components: { Tinymce },
+    directives: { waves },
+    data() {
+      return {
+        dataForm: {
+          type:'certificatNotice',
+          title: '',
+          content: "",
+        },
+        loading: false,
+        rules: {
+            title: [{ required: true, message: "标题不能为空", trigger: "blur" }],
+            content: [{ required: true, message: "积分规则不能为空", trigger: "blur" }],
+        },
+      }
+    },
+    created() {
+        this.getDetail();
+    },
+    methods: {
+    
+      getDetail() {
+          this.loading = true
+          goodsExchangeRulesDetail({noticeType:'certificatNotice'}).then(response => {
+            this.dataForm.title = response.data.data.title;
+            this.dataForm.content = response.data.data.content;
+            this.dataForm.id = response.data.data.id;
+            this.loading = false;
+          }).catch(() => {})
+      },
+      updateData() {
+        this.$refs['dataForm'].validate((valid) => {
+          if (valid) {
+            this.loading = true;
+            updateGoodsExchangeRules(this.dataForm).then(() => {
+              this.loading = false;
+                this.$notify({
+                  title: '成功',
+                  message: '更新成功',
+                  type: 'success',
+                  duration: 2000
+                })
+                this.getDetail();
+              }) 
+          }
+        })
+      },
+  
+      
+    }
+  }
+  </script>
+