|
@@ -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 () {
|