|
@@ -115,24 +115,48 @@
|
|
trigger: 'blur'
|
|
trigger: 'blur'
|
|
}],
|
|
}],
|
|
},
|
|
},
|
|
|
|
+ isCache: true
|
|
}
|
|
}
|
|
},
|
|
},
|
|
created() {
|
|
created() {
|
|
- this.customerForm['organizationId'] = this.$store.getters.user.organization.id;
|
|
|
|
if (this.isUpdate) {
|
|
if (this.isUpdate) {
|
|
|
|
+ this.isCache = false;
|
|
getCustomerDetailById(this.detailId).then(res => {
|
|
getCustomerDetailById(this.detailId).then(res => {
|
|
if (res.state) {
|
|
if (res.state) {
|
|
this.customerForm = res.data;
|
|
this.customerForm = res.data;
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
+ } else {
|
|
|
|
+ console.log(this.$store.getters.customerData);
|
|
|
|
+ if (this.$store.getters.customerData && JSON.stringify(this.$store.getters.customerData) != '{}') {
|
|
|
|
+ if (this.$store.getters.customerData.organizationId != this.$store.getters.user.organization.id) {
|
|
|
|
+ return this.$store.dispatch('projectBase/changeCustomerData', {});
|
|
|
|
+ }
|
|
|
|
+ this.initForm(this.$store.getters.customerData);
|
|
|
|
+ }
|
|
|
|
+ this.customerForm['organizationId'] = this.$store.getters.user.organization.id;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ beforeDestroy() {
|
|
|
|
+ this.cacheData();
|
|
|
|
+ },
|
|
methods: {
|
|
methods: {
|
|
|
|
+ initForm(data) {
|
|
|
|
+ this.customerForm = data;
|
|
|
|
+ },
|
|
|
|
+ cacheData() {
|
|
|
|
+ if (!this.isCache) return;
|
|
|
|
+ this.$store.dispatch('projectBase/changeCustomerData', this.setData());
|
|
|
|
+ },
|
|
|
|
+ setData() {
|
|
|
|
+ let postData = JSON.parse(JSON.stringify(this.customerForm));
|
|
|
|
+ postData['firsTimeRoom'] = this.$refs.selectHouse.selectNodeId;
|
|
|
|
+ return postData;
|
|
|
|
+ },
|
|
submit() {
|
|
submit() {
|
|
this.$refs.customerForm.validate((valid) => {
|
|
this.$refs.customerForm.validate((valid) => {
|
|
if (valid) {
|
|
if (valid) {
|
|
- let postData = JSON.parse(JSON.stringify(this.customerForm));
|
|
|
|
- postData['firsTimeRoom'] = this.$refs.selectHouse.selectNodeId;
|
|
|
|
|
|
+ let postData = this.setData();
|
|
if (this.isUpdate) {
|
|
if (this.isUpdate) {
|
|
updateCustomer(postData).then(this.successFunc);
|
|
updateCustomer(postData).then(this.successFunc);
|
|
} else {
|
|
} else {
|