From 133cfa50d6429504b6c18a36c20472a6a872805a Mon Sep 17 00:00:00 2001
From: long <515897141@qq.com>
Date: 星期一, 07 六月 2021 15:08:05 +0800
Subject: [PATCH] 添加规则模板页

---
 src/icons/svg/agreement.svg                 |    1 
 src/mixins/bannerOpts.js                    |   52 ++++----
 src/pages/login/index.vue                   |    2 
 src/pages/agreement/index.vue               |  156 ++++++++++++++++++++++++++
 src/router/index.js                         |    2 
 src/router/agreement_router.js              |   37 ++++++
 src/components_simple/UploadSingleVideo.vue |    2 
 src/pages/system/banner.vue                 |    2 
 src/pages/system/basic.vue                  |   83 +------------
 9 files changed, 235 insertions(+), 102 deletions(-)

diff --git a/src/components_simple/UploadSingleVideo.vue b/src/components_simple/UploadSingleVideo.vue
index e7320c4..ad8356b 100644
--- a/src/components_simple/UploadSingleVideo.vue
+++ b/src/components_simple/UploadSingleVideo.vue
@@ -86,7 +86,7 @@
       const formData = new FormData()
       formData.append('file', file)
       this.postFN({
-        url: 'admin/image/upload?type=1',
+        url: 'admin/image/upload?folderCode=Video',
         header: { 'Content-Type': 'multipart/form-data' },
         params: formData,
         mockData: {
diff --git a/src/icons/svg/agreement.svg b/src/icons/svg/agreement.svg
new file mode 100644
index 0000000..838dbd1
--- /dev/null
+++ b/src/icons/svg/agreement.svg
@@ -0,0 +1 @@
+<svg t="1606903520459" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="13206" width="40" height="40"><path d="M600.76158 68.191078 245.714238 68.191078c-49.040926 0-88.317465 39.720653-88.317465 88.76158l-0.444115 710.09366c0 49.040926 39.277562 88.76158 88.317465 88.76158l533.014616 0c49.040926 0 88.76158-39.720653 88.76158-88.76158L867.046319 334.476841 600.76158 68.191078zM689.523159 778.284739 334.475817 778.284739l0-88.76158 355.047342 0L689.523159 778.284739zM689.523159 600.76158 334.475817 600.76158l0-88.76158 355.047342 0L689.523159 600.76158zM556.38079 378.857631 556.38079 134.762263 800.475134 378.857631 556.38079 378.857631z" p-id="13207"></path></svg>
\ No newline at end of file
diff --git a/src/mixins/bannerOpts.js b/src/mixins/bannerOpts.js
index 452c93a..a1408fe 100644
--- a/src/mixins/bannerOpts.js
+++ b/src/mixins/bannerOpts.js
@@ -5,31 +5,31 @@
  */
 
 export default {
-    data () {
-        return {
-            // 璺宠浆绫诲瀷閫夐」
-            jumpTypeOpt: [{
-                label: '涓嶈烦杞�',
-                value: 0
-            },{
-                label: '灏忕▼搴忛〉闈�',
-                value: 1
-            },{
-                label: 'H5椤甸潰',
-                value: 2
-            },{
-                label: '鍏朵粬灏忕▼搴�',
-                value: 3
-            }],
+  data() {
+    return {
+      // 璺宠浆绫诲瀷閫夐」
+      jumpTypeOpt: [{
+        label: '涓嶈烦杞�',
+        value: 0
+      }, {
+        label: '灏忕▼搴忛〉闈�',
+        value: 1
+      }, {
+        label: 'H5椤甸潰',
+        value: 2
+      }, {
+        label: '鍏朵粬灏忕▼搴�',
+        value: 3
+      }],
 
-            // 灏忕▼搴忕増鏈�
-            envVersionOpt: [{
-                label: '寮�鍙戠増锛坉evelop锛�', value: 'develop'
-            },{
-                label: '浣撻獙鐗堬紙trial锛�', value: 'trial'
-            },{
-                label: '姝e紡鐗堬紙release锛�', value: 'release'
-            }],
-        }
+      // 灏忕▼搴忕増鏈�
+      envVersionOpt: [{
+        label: '寮�鍙戠増锛坉evelop锛�', value: 'develop'
+      }, {
+        label: '浣撻獙鐗堬紙trial锛�', value: 'trial'
+      }, {
+        label: '姝e紡鐗堬紙release锛�', value: 'release'
+      }]
     }
-}
\ No newline at end of file
+  }
+}
diff --git a/src/pages/agreement/index.vue b/src/pages/agreement/index.vue
new file mode 100644
index 0000000..e9a5fda
--- /dev/null
+++ b/src/pages/agreement/index.vue
@@ -0,0 +1,156 @@
+<!-- 鏂囨。缂栬緫 -->
+<template>
+  <div class="app-container">
+    <el-form ref="agreementForm" label-position="left" :model="mData" label-width="150px" :rules="rules">
+      <el-form-item v-if="haveTitle" label="鏍囬锛�">
+        <!-- <el-input v-model="mData.title" placeholder="璇疯緭鍏ユ爣棰�" class="com-edit-input" /> -->
+        <div class="com-edit-input">{{ titleOptions[type-1] }}</div>
+      </el-form-item>
+      <el-form-item v-if="haveContent" label="鏂囨。璇︽儏锛�" prop="content">
+        <WangEnduit :catchdata="catchData" :content="mData.content" :rangenum="rangenum" />
+      </el-form-item>
+    </el-form>
+    <div class="com-edit-bottom-btns flex flex-align-center">
+      <el-button size="small" @click="jumpBack">鍙栨秷</el-button>
+      <el-button type="primary" size="small" @click="submit">淇濆瓨</el-button>
+    </div>
+  </div>
+</template>
+
+<script>
+import mixin_upload from '@/mixins/upload.js' // 閫氱敤涓婁紶鍥剧墖棰勮
+import WangEnduit from '@/components/WangEnduit' // 瀵屾枃鏈�
+export default {
+  name: 'Agreement',
+  components: { WangEnduit },
+  mixins: [mixin_upload],
+  data() {
+    return {
+      type: this.$route.meta.type, // 鍗忚绫诲瀷
+      // 瀵屾枃鏈�
+      rangenum: null,
+
+      titleOptions: ['鎶ヤ环鍏憡鍙婅繚瑙勮鍒�', '绔炰环骞冲彴涓爣鍘熷垯鍙婂叕鍛�', '鎿嶄綔娴佺▼璇存槑'],
+
+      mData: {
+        title: '', // 鏍囬
+        content: '' // 瀵屾枃鏈�
+      },
+
+      // 琛ㄥ崟鏍¢獙
+      rules: {
+        title: [
+          { required: true, message: '鏍囬涓嶈兘涓虹┖', trigger: 'change' }
+        ],
+        content: [
+          { required: true, message: '鏂囨。璇︽儏涓嶈兘涓虹┖' }
+        ],
+        uploadImgs: [
+          { required: true, message: '璇烽�夋嫨鍥剧墖', trigger: 'change' }
+        ]
+      }
+    }
+  },
+  computed: {
+    haveTitle() {
+      return true
+    },
+    haveContent() {
+      return true
+    }
+  },
+  watch: {
+    $route() {
+      this.init()
+    }
+  },
+  mounted() {
+    this.init()
+  },
+  methods: {
+    init() {
+      this.getAgreementData()
+    },
+
+    // 鑾峰彇鏂囩珷璇︽儏
+    getAgreementData() {
+      this.postFN({
+        url: 'admin/sysTextExplain/detail',
+        params: { type: this.type },
+        udData: {},
+        mockData: {
+          code: 100, msg: '',
+          data: {
+            id: 'xxx',
+            content: '<p>鏂囨湰</p>'
+          }
+        }
+      }, (inf) => {
+        if (inf) this.$set(this.mData, 'content', inf.content || '')
+        // 娓呯┖瀵屾枃鏈�
+        this.rangenum = null
+      })
+    },
+
+    // 瀵屾枃鏈浉鍏�
+    // 瀵屾枃鏈紪杈戝櫒鐨勫唴瀹硅祴鍊�
+    catchData(content) {
+      if (content === '<p><br></p>') content = ''
+      try {
+        const currentRange = window.getSelection().getRangeAt(0)
+        this.rangenum = currentRange
+      } catch (e) {
+        //
+      }
+      this.mData.content = content
+      this.$refs.agreementForm.validateField('content')
+    },
+    // 瀵屾枃鏈浉鍏�
+
+    jumpBack() {
+      this.$router.go(-1)
+    },
+
+    // 琛ㄥ崟楠岃瘉
+    submit() {
+      this.$refs['agreementForm'].validate(valid => {
+        if (valid) {
+          this.submitReq()
+        }
+      })
+    },
+    // 鎻愪氦
+    submitReq() {
+      var { mData } = this
+      var params = {
+        type: this.type,
+        // title: mData.title,
+        content: mData.content
+      }
+
+      if (!this.haveContent) {
+        params.content = '鏃�'
+      }
+      // if (!this.haveTitle) {
+      //   params.title = '鏃�'
+      // }
+
+      this.postFN({
+        url: 'admin/sysTextExplain/edit',
+        params: params,
+        mockData: {
+          code: 100,
+          msg: '',
+          data: {}
+        }
+      }, () => {
+        this.$messageSuc('淇濆瓨鎴愬姛')
+      })
+    }
+  }
+}
+</script>
+
+<style lang="less">
+
+</style>
diff --git a/src/pages/login/index.vue b/src/pages/login/index.vue
index 61d0696..8ffdfc2 100644
--- a/src/pages/login/index.vue
+++ b/src/pages/login/index.vue
@@ -223,7 +223,7 @@
                 name: '娼樺鎷夌殑鑷槾', // 鐢ㄦ埛鍚嶇О
                 // arr: ['sys_admin_see'], // 鏉冮檺鍒楄〃
                 arr: ['sys_admin_see', 'sys_admin_add', 'sys_admin_edit', 'sys_admin_del', 'sys_admin_role_see', 'sys_admin_role_add', 'sys_admin_role_edit', 'sys_admin_role_del', 'corp_user_schedule_see', 'corp_user_schedule_add', 'corp_user_schedule_edit', 'corp_user_schedule_del', 'user_mp_banner_see', 'user_mp_banner_add', 'user_mp_banner_edit', 'user_mp_banner_del', 'shop_see', 'shop_add', 'shop_edit', 'shop_del', 'shop_device', 'corp_user_see', 'corp_user_add', 'corp_user_edit', 'corp_user_del', 'change_assistant_see', 'ser_pro_material_see', 'service_project_see', 'service_project_add', 'service_project_edit', 'service_project_del', 'service_topic_see', 'service_topic_add', 'service_topic_edit', 'service_topic_del', 'service_project_order_see', 'service_project_order_edit', 'goods_type_see', 'goods_type_add', 'goods_type_edit', 'goods_type_del', 'goods_see', 'goods_add', 'goods_edit', 'goods_del', 'goods_inventory', 'goods_order_see', 'goods_order_edit', 'goods_index_banner_see', 'goods_index_banner_add', 'goods_index_banner_edit', 'goods_index_banner_del', 'user_see', 'user_edit', 'user_cash_see', 'user_cash_edit', 'distribute_relate', 'distribute_order', 'document_edit', 'operation_see',
-                  'coupon_see', 'coupon_add', 'coupon_edit', 'coupon_del', 'activity_see', 'activity_add', 'activity_edit', 'activity_del', 'banner_see', 'banner_add', 'banner_edit', 'banner_del'
+                  'coupon_see', 'coupon_add', 'coupon_edit', 'coupon_del', 'activity_see', 'activity_add', 'activity_edit', 'activity_del', 'banner_see', 'banner_add', 'banner_edit', 'banner_del', 'sys_text_explain_edit'
                 ]
               }
             }
diff --git a/src/pages/system/banner.vue b/src/pages/system/banner.vue
index 8fd46ed..73d5cf6 100644
--- a/src/pages/system/banner.vue
+++ b/src/pages/system/banner.vue
@@ -68,7 +68,7 @@
             <!-- 灏哄 -->
             杞挱鍥撅細<br><span style="color: #999;font-size: 12px">(xxx*xxx鍍忕礌)</span>
           </span>
-          <!-- 涓婁紶鍥剧墖缁勪欢(澶氬浘) -->
+          <!-- 涓婁紶鍥剧墖缁勪欢(鍗曞浘) -->
           <UploadSingleImg
             ref="refUploadImg"
             v-model="dialogData.uploadImgs"
diff --git a/src/pages/system/basic.vue b/src/pages/system/basic.vue
index ebcdc98..0a1403c 100644
--- a/src/pages/system/basic.vue
+++ b/src/pages/system/basic.vue
@@ -13,22 +13,11 @@
           鍒嗕韩鍥剧墖锛�<br><span>(500*400鍍忕礌)</span>
         </span>
         <!-- 涓婁紶鍥剧墖缁勪欢(鍗曞浘) -->
-        <el-upload
-          ref="refUploadShareImg"
-          :auto-upload="false"
-          list-type="picture-card"
-          :class="{disabled:uploadDisabled}"
-          action="#"
-          :limit="1"
-          :file-list="basicData.uploadShareImgs"
-          :on-change="addUploadFiles"
-          :on-remove="delUploadFiles"
-          :http-request="uploadFileHandle"
-          :on-preview="uploadPreview"
-          :before-upload="beforeUploadImg"
-        >
-          <i class="el-icon-plus" />
-        </el-upload>
+        <UploadSingleImg
+          ref="refUploadImg"
+          v-model="dialogData.uploadShareImgs"
+          @change.capture="$refs['basicForm'].clearValidate()"
+        />
       </el-form-item>
     </el-form>
 
@@ -46,9 +35,10 @@
 
 <script>
 import mixin_upload from '@/mixins/upload.js' // 閫氱敤涓婁紶鍥剧墖棰勮
+import UploadSingleImg from '@/components_simple/UploadSingleImg'
 export default {
   components: {},
-  mixins: [mixin_upload],
+  mixins: [mixin_upload, UploadSingleImg],
   data() {
     return {
       basicData: {
@@ -65,11 +55,6 @@
           required: true, message: '璇烽�夋嫨鍥剧墖'
         }]
       }
-    }
-  },
-  computed: {
-    uploadDisabled() {
-      return this.basicData.uploadShareImgs.length > 0
     }
   },
   mounted() {
@@ -103,61 +88,13 @@
       this.$router.go(-1)
     },
 
-    // 涓婁紶鏀粯鏂囦欢 鈫撯啌鈫撯啌鈫撯啌鈫撯啌鈫撯啌鈫撯啌鈫撯啌鈫撯啌鈫撯啌鈫撯啌鈫撯啌鈫撯啌鈫撯啌鈫撯啌鈫撯啌
-    // 涓婁紶鍓嶇‘璁ゆ牸寮�
-    beforeUploadImg(file) {
-      const isImg = file.type.indexOf('image/') > -1
-      if (!isImg) {
-        this.$message.error('蹇呴』鏄�夋嫨鍥剧墖鏂囦欢')
-      }
-      return isImg
-    },
-    // 澧炲姞鏂囦欢
-    addUploadFiles(file) {
-      this.basicData.uploadShareImgs = [file]
-    },
-    // 鍒犻櫎鏂囦欢
-    delUploadFiles(file, fileList) {
-      this.basicData.uploadShareImgs = fileList
-    },
-    // 鎵ц涓婁紶鍗曟枃浠�
-    runUploadFiles(cb) {
-      if (this.checkNeedUpload(this.basicData.uploadShareImgs)) {
-        this.$refs.refUploadShareImg.submit()
-      } else {
-        cb && cb()
-      }
-    },
-    // 涓婁紶鍒嗕韩鍥�
-    uploadFileHandle(res) {
-      const file = res.file
-      const formData = new FormData()
-      formData.append('file', file)
-      console.log(formData)
-      this.postFN({
-        url: 'admin/image/upload',
-        header: { 'Content-Type': 'multipart/form-data' },
-        params: formData,
-        mockData: {
-          code: 100,
-          msg: '',
-          data: {
-            imgUrl: 'xxx'
-          }
-        }
-      }, (inf) => {
-        this.basicData.shareImg = inf.imgUrl
-        // this.$refs.refUploadShareImg.clearFiles();
-        this.submitReq()
-      })
-    },
-    // 涓婁紶鏀粯鏂囦欢 鈫戔啈鈫戔啈鈫戔啈鈫戔啈鈫戔啈鈫戔啈鈫戔啈鈫戔啈鈫戔啈鈫戔啈鈫戔啈鈫戔啈鈫戔啈鈫戔啈鈫戔啈
-
     // 鎻愪氦缂栬緫
     submit() {
       this.$refs['basicForm'].validate(valid => {
         if (valid) {
-          this.runUploadFiles(() => {
+          // 涓婁紶鍥剧墖
+          this.$refs.refUploadImg.runUploadImg((imgUrl) => {
+            imgUrl && this.$set(this.dialogData, 'shareImg', imgUrl)
             this.submitReq()
           })
         }
diff --git a/src/router/agreement_router.js b/src/router/agreement_router.js
new file mode 100644
index 0000000..8889638
--- /dev/null
+++ b/src/router/agreement_router.js
@@ -0,0 +1,37 @@
+// 璺敱閰嶇疆鏂囦欢
+import Layout from '@/layout'
+
+export default {
+  path: '/agreement',
+  component: Layout,
+  redirect: 'noRedirect',
+  name: 'agreement',
+  meta: {
+    title: '鏂囨。璇存槑',
+    icon: 'agreement'
+  },
+  children: [
+    {
+      path: 'index0',
+      component: () => import('@/pages/agreement/index'), // Parent router-view
+      name: 'agreement0',
+      meta: { title: '鎶ヤ环鍏憡鍙婅繚瑙勮鍒�', type: 1 },
+      auth: 'sys_text_explain_edit'
+    },
+    {
+      path: 'index1',
+      component: () => import('@/pages/agreement/index'), // Parent router-view
+      name: 'agreement1',
+      meta: { title: '绔炰环骞冲彴涓爣鍘熷垯鍙婂叕鍛�', type: 2 },
+      auth: 'sys_text_explain_edit'
+    },
+    {
+      path: 'index2',
+      component: () => import('@/pages/agreement/index'), // Parent router-view
+      name: 'agreement2',
+      meta: { title: '鎿嶄綔娴佺▼璇存槑', type: 3 },
+      auth: 'sys_text_explain_edit'
+    }
+  ]
+}
+
diff --git a/src/router/index.js b/src/router/index.js
index 378e515..1696681 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -9,6 +9,7 @@
 import demo_router from './demo_router'
 import system_router from './system_router'
 import op_router from './op_router'
+import agreement_router from './agreement_router'
 
 /**
  * 娉�:瀛愯彍鍗曞彧鍑虹幇鍦ㄨ矾绾垮瓙鏃躲�傞暱搴�> = 1
@@ -61,6 +62,7 @@
 
   system_router,
   demo_router,
+  agreement_router,
 
   {
     path: 'external-link',

--
Gitblit v1.8.0