Bläddra i källkod

feat:增加企业信息填写缓存。修改优化讲解员选择弹窗

徐志豪 5 år sedan
förälder
incheckning
423f78dd17

+ 11 - 1
admin/src/components/Modal/index.vue

@@ -1,5 +1,5 @@
 <template>
-  <Modal :width="width" v-model="show" footer-hide >
+  <Modal :width="width" v-model="showStatus" footer-hide >
     <div slot="header" class="modal-header">
       {{ title }}
     </div>
@@ -25,6 +25,16 @@ export default {
       default: '保存'
     }
   },
+  computed: {
+    showStatus: {
+      set (val) {
+        this.$emit('close')
+      },
+      get () {
+        return this.show
+      }
+    }
+  },
   methods: {
     close () {
       this.$emit('close')

+ 13 - 5
admin/src/views/enterprise/components/baseForm.vue

@@ -17,6 +17,11 @@
             </FormItem>
           </i-col>
           <i-col :span="12" class="">
+            <FormItem label="企业类型">
+              <Input type="text" size="large" v-model="form.companyType" :disabled="isDetail" />
+            </FormItem>
+          </i-col>
+          <i-col :span="12" class="">
             <FormItem label="成立时间" prop="registerDate1">
               <Date-picker v-model="form.registerDate1" type="year" size="large" placeholder=""  :disabled="isDetail" @on-change="changeDate"></Date-picker>
             </FormItem>
@@ -101,7 +106,7 @@
         <div style="height:20px"></div>
       </template>
     </cModal>
-    <cModal :show="guideModalShow"  class="scene-modal" :width="960" title="选择讲解员" @close="guideModalShow=false" @submit="changeGuide">
+    <cModal :show.sync="guideModalShow"  class="scene-modal" :width="960" title="选择讲解员" @hide="guideModalShow=false" @close="guideModalShow=false" @submit="changeGuide">
       <template>
         <tables 
           :data-api="getGuideList"
@@ -253,6 +258,13 @@ export default {
       }
     }
   },
+  watch: {
+    guideModalShow (val) {
+      if (val) {
+        this.$refs['guideTable'].handleTableData()
+      }
+    }
+  },
   async mounted () {
     await this.getIndustryList()
     this.$watch('form.companyLogo', function (newVal) {
@@ -279,10 +291,8 @@ export default {
     },
     async submit () {
       let res = await this.$refs['logoUpload'].uploadfiles()
-      console.log(this.hasLogoUploads)
       this.form.companyLogo = res[0]
       this.form.registerDate = new Date(this.form.registerDate).getFullYear()
-      console.log(this.hasLogoUploads)
     },
     changeScene () {
       this.vrLink = this.select_scene_num ? `${process.env.VUE_APP_4DKANKAN_URL}/kanzhan.html?m=${this.select_scene_num}` : ''
@@ -313,7 +323,6 @@ export default {
       })
     },
     clickMap (value) {
-      console.log(value)
       this.form.companyAddress = value.address
       this.form.latitude = value.location.lat
       this.form.longitude = value.location.lng
@@ -322,7 +331,6 @@ export default {
       this.form.registerDate = date
     },
     fetchAllScene (data) {
-      console.log(data)
       return CompanyApi.fetchAllScene(data).then(res => {
         return {
           data: {

+ 0 - 2
admin/src/views/enterprise/components/videoForm.vue

@@ -32,7 +32,6 @@ export default {
   },
   mounted () {
     this.$watch('form.introduceVideo', function (newVal) {
-      console.log(newVal, 'new')
       if (this.isDetail) {
         this.hasUploads = [{img: `${newVal}?x-oss-process=video/snapshot,t_7000,f_jpg,w_800,h_600,m_fast`, url: newVal}]
       }
@@ -47,7 +46,6 @@ export default {
     },
     async submit () {
       let res = await this.$refs['videoUpload'].uploadfiles()
-      console.log(res, 'res')
       if (res[0]) {
         this.form.introduceVideo = res[0].data.url
       }

+ 26 - 7
admin/src/views/enterprise/index.vue

@@ -23,7 +23,20 @@ import videoForm from './components/videoForm'
 import introPicForm from './components/introPicForm'
 import { getAdmin, setAdmin } from '@/libs/token'
 import { refreshAdminerInfo } from '@/api/index'
-// import { getGuideById } from '@/api/guide'
+import { remove } from 'js-cookie'
+
+const cacheKey = 'cacheForm'
+function saveForm (form) {
+  localStorage.setItem(cacheKey, JSON.stringify(form))
+}
+
+function removeForm () {
+  localStorage.removeItem(cacheKey)
+}
+
+function loadForm () {
+  return localStorage.getItem(cacheKey)
+}
 
 export default {
   data () {
@@ -32,8 +45,8 @@ export default {
       form: {
         companyName: '',
         companyType: '',
-        sceneNum: '',
-        vrLink: '',
+        sceneNum: '123123',
+        vrLink: '13123',
         registerDate: ''
       },
       
@@ -53,14 +66,18 @@ export default {
       return getAdmin().admin.adminId
     }
   },
-  mounted () {
-    this.getCompanyDetail()
+  async mounted () {
+    await this.getCompanyDetail()
+    if (!this.form.companyId && loadForm()) {
+      this.form = JSON.parse(loadForm())
+    }
   },
   methods: {
     async handleSubmitClick () {
        return this.validate()
     },
     async validate () {
+      saveForm(this.form)
       let res = await Promise.all([this.$refs['base-form'].validate()])
       let item = res.find(item => !item)
       if (item === false) {
@@ -75,9 +92,12 @@ export default {
       return api(this.form).then(() => {
         this.$Message.success(this.form.companyId ? '修改成功' : '新增成功')
         this.isDetail = true
+        removeForm()
         setTimeout(() => {
           this.refreshAdminerInfo()
         }, 500)
+      }).catch(err => {
+        saveForm(this.form)
       })
     },
     cancle () {
@@ -86,12 +106,11 @@ export default {
     getCompanyDetail (companyId) {
       let id = companyId || this.companyId
       if (!id) return
-      CompanyApi.getCompanyDetail(id).then(res => {
+      return CompanyApi.getCompanyDetail(id).then(res => {
         this.isDetail = true
         res.data.company.registerDate1 = new Date(res.data.company.registerDate)
         
         this.form = res.data.company
-        console.log(this.form)
       })
     },
     refreshAdminerInfo () {

+ 3 - 3
admin/vue.config.js

@@ -24,9 +24,9 @@ module.exports = {
     },
     proxy: {
       '/admin': {
-        // target: 'http://120.24.85.77:8087', // 正式环境
-        target: 'http://192.168.0.83:8165'  // 伟玉本地环境
-        // target: 'http://haowantest.4dkankan.com'    // 测试环境
+        // target: 'https://haowan.4dkankan.com', // 正式环境
+        // target: 'http://192.168.0.83:8165'  // 伟玉本地环境
+        target: 'http://haowantest.4dkankan.com'    // 测试环境
       },
       '/node-upload': {
         target: 'http://haowantest.4dkankan.com',