浏览代码

从编辑跳到新建页面数据不清空,列表页添加复制

zhoujump 1 月之前
父节点
当前提交
9b8ad3c927

+ 1 - 1
src/layout/index.vue

@@ -82,7 +82,7 @@
       </div>
       <div class="layout-body">
         <div class="body-inner" :class="{'animation':isAnimation}">
-          <router-view :is-completion-init="isCompletionInit" class="view-inner" @completion-init="$emit('completionInit')" />
+          <router-view :key="$route.fullPath" :is-completion-init="isCompletionInit" class="view-inner" @completion-init="$emit('completionInit')" />
         </div>
         <div class="body-inner trans" :class="{'animation':isAnimation}" />
       </div>

文件差异内容过多而无法显示
+ 1 - 1
src/permission.js


+ 8 - 0
src/router/index.js

@@ -92,6 +92,10 @@ export const constantRoutes = [
                   name: '表单编辑'
                 },
                 {
+                  roles: 'preReg.handelCopy',
+                  name: '表单复制'
+                },
+                {
                   roles: 'preReg.handelDisable',
                   name: '表单禁用'
                 },
@@ -220,6 +224,10 @@ export const constantRoutes = [
                   name: '编辑展会'
                 },
                 {
+                  roles: 'exhibitor.handelCopy',
+                  name: '复制展会'
+                },
+                {
                   roles: 'exhibitor.handelDisable',
                   name: '禁用展会'
                 },

+ 26 - 10
src/views/exhibitorManage/exhibitorList.vue

@@ -2,8 +2,12 @@
 import Vue from 'vue'
 import expoPopover from '@/views/components/expoPopover.vue'
 import { getExpoList, deleteExpo, setExpoStatus } from '@/api/expo'
+import { copyValue } from '@/utils'
 export default Vue.extend({
   name: 'Index',
+  components: {
+    expoPopover
+  },
   data() {
     return {
       expoList: [],
@@ -18,13 +22,11 @@ export default Vue.extend({
       ossUrl: process.env.VUE_APP_OSS_DOMAIN
     }
   },
-  components: {
-    expoPopover
-  },
   mounted() {
     this.getList()
   },
   methods: {
+    copyValue,
     search(event) {
       if (this.searchTimer) {
         clearTimeout(this.searchTimer)
@@ -35,8 +37,19 @@ export default Vue.extend({
       }, 500)
     },
     edit(row) {
+      if (row.form_count) {
+        this.$notify({
+          title: '提示',
+          message: '此展会已经有人报名了,无法修改',
+          type: 'warning'
+        })
+        return
+      }
       this.$router.push({ path: '/exhibitor/edit/' + row.id })
     },
+    copy(row) {
+      this.$router.push({ path: '/exhibitor/add?copy=' + row.id })
+    },
     setStatus(row) {
       this.loading = true
       setExpoStatus(row.id, row.status ? 0 : 1).then(res => {
@@ -95,7 +108,7 @@ export default Vue.extend({
 <template>
   <div class="main-box">
     <div class="head">
-      <el-input v-permission="'exhibitor.search'" v-model="searchWord" prefix-icon="el-icon-search" placeholder="搜索展商名称" class="input" @input="search">
+      <el-input v-model="searchWord" v-permission="'exhibitor.search'" prefix-icon="el-icon-search" placeholder="搜索展商名称" class="input" @input="search">
         <el-button v-if="searchWord" slot="append" icon="el-icon-delete" @click="searchWord='';search()" />
       </el-input>
       <el-button v-permission="'exhibitor.addList'" icon="el-icon-plus" type="primary" @click="add">添加展商</el-button>
@@ -122,8 +135,7 @@ export default Vue.extend({
           label="预约观众"
           width="80"
           prop="form_count"
-        >
-        </el-table-column>
+        />
         <el-table-column
           label="展会地点"
           prop="location"
@@ -164,14 +176,15 @@ export default Vue.extend({
         <el-table-column
           label="操作"
           fixed="right"
-          width="200"
+          width="210"
         >
           <template slot-scope="scope">
             <expo-popover placement="left" trigger="click" :expo-id="''+scope.row.id">
               <span v-permission="'exhibitor.handelView'" class="button">预览</span>
             </expo-popover>
-            <span v-permission="'exhibitor.handelEdit'" class="button" @click="edit(scope.row)">编辑</span>
-            <span v-permission="'exhibitor.handelDisable'" class="button" @click="setStatus(scope.row)">{{scope.row.status?'启用':'禁用'}}</span>
+            <span v-permission="'exhibitor.handelEdit'" :class="['button',scope.row.form_count?'disable':'']" @click="edit(scope.row)">编辑</span>
+            <span v-permission="'exhibitor.handelCopy'" class="button" @click="copy(scope.row)">复制</span>
+            <span v-permission="'exhibitor.handelDisable'" class="button" @click="setStatus(scope.row)">{{ scope.row.status?'启用':'禁用' }}</span>
             <span v-permission="'exhibitor.handelDelete'" class="button del" @click="del(scope.row)">删除</span>
           </template>
         </el-table-column>
@@ -186,11 +199,11 @@ export default Vue.extend({
       />
       <el-pagination
         v-permission="'exhibitor.handel'"
-        @current-change="current_page=$event;getList()"
         background
         :page-size="page_size"
         layout="prev, pager, next"
         :total="total"
+        @current-change="current_page=$event;getList()"
       />
     </div>
   </div>
@@ -226,6 +239,9 @@ export default Vue.extend({
           &.del{
             color: #DC2626;
           }
+          &.disable{
+            color: grey;
+          }
         }
         .status{
           padding: 0 12px;

+ 49 - 6
src/views/exhibitorManage/exhibitorSetting.vue

@@ -50,12 +50,39 @@ export default Vue.extend({
           this.exhibitorSetting.social_links = JSON.parse(this.exhibitorSetting.social_links)
           this.loading = false
         }).catch(err => {
+          this.$notify({
+            title: '提示',
+            message: '获取被复制展会数据失败',
+            type: 'error'
+          })
+          this.loading = false
+        })
+      }
+      if (this.$route.query.copy) {
+        this.loading = true
+        getMyExpoInfo(this.$route.query.copy).then(res => {
+          this.exhibitorSetting = res.data
+          this.exhibitorSetting.images = JSON.parse(this.exhibitorSetting.images)
+          this.exhibitorSetting.social_links = JSON.parse(this.exhibitorSetting.social_links)
+          this.exhibitorSetting.id = ''
+          this.loading = false
+        }).catch(err => {
+          this.$notify({
+            title: '提示',
+            message: '获取被复制展会数据失败',
+            type: 'error'
+          })
           this.loading = false
         })
       }
       getFormList(1, 1000).then(res => {
         this.formList = res.data.data
       }).catch(err => {
+        this.$notify({
+          title: '提示',
+          message: '获取预登记表单数据失败',
+          type: 'error'
+        })
       })
     },
     uploadImage(event, type) {
@@ -71,7 +98,11 @@ export default Vue.extend({
         this.loading = false
       }).catch(err => {
         this.loading = false
-        this.$message.error('上传图片时遇到问题')
+        this.$notify({
+          title: '提示',
+          message: '图片上传失败',
+          type: 'error'
+        })
       })
     },
     save() {
@@ -85,7 +116,11 @@ export default Vue.extend({
         this.exhibitorSetting.contact_email === '' ||
         this.exhibitorSetting.urla === ''
       ) {
-        this.$message.error('请将信息填写完整')
+        this.$notify({
+          title: '提示',
+          message: '请将展会数据填写完整',
+          type: 'warning'
+        })
         return
       }
       if (this.loading) {
@@ -112,12 +147,20 @@ export default Vue.extend({
         this.exhibitorSetting.seo_description,
         this.exhibitorSetting.seo_keywords
       ).then(res => {
-        this.$message.success('保存成功')
+        this.$notify({
+          title: '提示',
+          message: '展会保存成功',
+          type: 'success'
+        })
         this.loading = false
         this.$router.push('/exhibitor/list')
       }).catch(err => {
         this.loading = false
-        this.$message.error('保存失败')
+        this.$notify({
+          title: '提示',
+          message: '保存展会失败',
+          type: 'error'
+        })
       })
     }
   }
@@ -193,12 +236,12 @@ export default Vue.extend({
         <div class="form-item required">
           <div class="label">表单模板</div>
           <el-select v-model="exhibitorSetting.form_template_id">
-            <el-option v-for="item in formList" :key="item.id" :value="item.id" :label="item.template_name"></el-option>
+            <el-option v-for="item in formList" :key="item.id" :value="item.id" :label="item.template_name" />
           </el-select>
         </div>
         <div v-permission="'exhibitor.copyright'" class="form-item required">
           <div class="label">表单底部显示系统信息</div>
-          <el-switch active-value="1" inactive-value="0" v-model="exhibitorSetting.show_official_footer" class="input" />
+          <el-switch v-model="exhibitorSetting.show_official_footer" active-value="1" inactive-value="0" class="input" />
         </div>
         <div class="form-item required">
           <div class="label">url短名称</div>

+ 32 - 0
src/views/preRegManage/edit.vue

@@ -516,12 +516,39 @@ export default Vue.extend({
           this.formInfo.desc = res.data.description
           this.loading = false
         }).catch(() => {
+          this.$notify({
+            title: '提示',
+            message: '获取被复制表单数据失败',
+            type: 'error'
+          })
+          this.loading = false
+        })
+      }
+      if (this.$route.query.copy) {
+        this.loading = true
+        getFormInfo(this.$route.query.copy).then(res => {
+          this.formData = res.data.fields
+          this.formInfo.name = res.data.template_name
+          this.formInfo.desc = res.data.description
+          this.formInfo.id = ''
+          this.loading = false
+        }).catch(() => {
+          this.$notify({
+            title: '提示',
+            message: '获取被复制表单数据失败',
+            type: 'error'
+          })
           this.loading = false
         })
       }
       getMyFields().then(res => {
         this.customComp = res.data
       }).catch(() => {
+        this.$notify({
+          title: '提示',
+          message: '获取我的组件失败',
+          type: 'error'
+        })
       })
       document.addEventListener('keydown', this.KeyHandel)
     },
@@ -565,6 +592,11 @@ export default Vue.extend({
         this.loading = false
         this.$router.push({ path: '/preRegister/edit/' + res.data })
       }).catch(() => {
+        this.$notify({
+          title: '提示',
+          message: '创建表单副本失败',
+          type: 'error'
+        })
         this.loading = false
       })
     },

+ 4 - 1
src/views/preRegManage/list.vue

@@ -34,6 +34,9 @@ export default Vue.extend({
     edit(row) {
       this.$router.push({ path: '/preRegister/edit/' + row.id })
     },
+    copy(row) {
+      this.$router.push({ path: '/preRegister/add?copy=' + row.id })
+    },
     setStatus(row) {
       this.loading = true
       setFormStatus(row.id, row.status ? 0 : 1).then(res => {
@@ -117,7 +120,6 @@ export default Vue.extend({
           :show-overflow-tooltip="true"
           label="表单描述"
           prop="description"
-          width="300"
         />
         <el-table-column
           label="最后编辑"
@@ -131,6 +133,7 @@ export default Vue.extend({
         >
           <template slot-scope="scope">
             <span v-permission="'preReg.handelEdit'" class="button" @click="edit(scope.row)">编辑</span>
+            <span v-permission="'preReg.handelCopy'" class="button" @click="copy(scope.row)">复制</span>
             <span v-permission="'preReg.handelDisable'" class="button" @click="setStatus(scope.row)">{{ scope.row.status?'启用':'禁用' }}</span>
             <span v-permission="'preReg.handelDelete'" class="button del" @click="del(scope.row)">删除</span>
           </template>