|
@@ -22,20 +22,30 @@ export default {
|
|
|
},
|
|
|
data: function () {
|
|
|
return {
|
|
|
- form: {
|
|
|
- questions: {},
|
|
|
- },
|
|
|
+ form: {},
|
|
|
};
|
|
|
},
|
|
|
async created() {
|
|
|
- if (this.id) await this.search();
|
|
|
+ await this.search();
|
|
|
},
|
|
|
methods: {
|
|
|
...patentanalysis(['fetch', 'create', 'update']),
|
|
|
async search() {
|
|
|
- let res = await this.fetch(this.id);
|
|
|
- if (this.$checkRes(res)) {
|
|
|
- this.$set(this, `form`, res.data);
|
|
|
+ if (this.id) {
|
|
|
+ let res = await this.fetch(this.id);
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ if (!res.data.questions) res.data.questions = {};
|
|
|
+ this.$set(this, `form`, res.data);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ let data = this.form;
|
|
|
+ data.user_id = this.user._id;
|
|
|
+ data.apply_name = this.user.name;
|
|
|
+ data.status = '0';
|
|
|
+ data.inventer = this.user.name;
|
|
|
+ data.contact = this.user.name;
|
|
|
+ data.questions = {};
|
|
|
+ this.$set(this, `form`, data);
|
|
|
}
|
|
|
},
|
|
|
async onSubmit({ data }) {
|
|
@@ -49,8 +59,6 @@ export default {
|
|
|
this.$toast({ type: `success`, message: `${res.errmsg}` });
|
|
|
}
|
|
|
} else {
|
|
|
- data.status = '0';
|
|
|
- data.user_id = this.user._id;
|
|
|
let res = await this.create(data);
|
|
|
if (this.$checkRes(res)) {
|
|
|
this.$toast({ type: `success`, message: `专利分析申请成功` });
|