diff --git a/src/views/layout/components/main/model/add.vue b/src/views/layout/components/main/model/add.vue index 564fea1..69dd451 100644 --- a/src/views/layout/components/main/model/add.vue +++ b/src/views/layout/components/main/model/add.vue @@ -11,33 +11,48 @@ - + + + - - + + + + - - - - - + + + + + + + + - - + + + + + + + + + + + - - + + + + - - - - + + + 创建 重填 @@ -63,14 +78,16 @@ export default { return { form: { shop_id: '', - name: '', - date: '', - onoff: true, + class_name: '', + category: '四旋翼', + wheelbase: '', weight_max: '', - desc: '' + module: '', + describe: '', + onoff: true }, - airId: this.$route.params.id, // get参数 获取飞机id 没有为添加页面 - pageState: 'add', // 页面状态 + airId: this.$route.params.id, + pageState: 'add', plane: null } }, @@ -78,28 +95,24 @@ export default { SelectionShopId }, computed: { - // 获取飞机列表 airList () { return this.$store.state.airList } }, methods: { - // 设置表单 setForm (data) { - if (data.desc == null) { - data.desc = '' - } this.form.shop_id = data.shop_id - this.form.name = data.name - this.form.date = data.date - this.form.onoff = data.onoff + this.form.class_name = data.class_name + this.form.category = data.category + this.form.wheelbase = data.wheelbase this.form.weight_max = data.weight_max - this.form.desc = data.desc + this.form.module = data.module + this.form.describe = data.describe || '' + this.form.onoff = data.onoff === '1' || data.onoff === true if (Object.keys(data).length === 0) { this.$message.warning('清空表单') } }, - // 初始化页面 添加or编辑 initPage () { if (this.airId === undefined) { this.pageState = 'add' @@ -109,28 +122,24 @@ export default { if (this.plane) { const data = { shop_id: this.plane.shop_id, - name: this.plane.name, - date: this.plane.apply_time + '000', - onoff: this.plane.onoff === '1', + class_name: this.plane.class_name, + category: this.plane.category, + wheelbase: this.plane.wheelbase, weight_max: this.plane.weight_max, - desc: this.plane.describe + module: this.plane.module, + describe: this.plane.describe, + onoff: this.plane.onoff } this.setForm(data) } } }, - /** - * @description: 创建新飞机 - */ async addAir () { const res = await this.$store.dispatch('fetchAddAir', this.form) if (res.data.status === 1) { this.$router.push('/register/index') } }, - /** - * @description: 更新飞机 - */ async saveAir () { this.form.id = this.airId const res = await this.$store.dispatch('fetchSaveAir', this.form) @@ -141,12 +150,12 @@ export default { }, watch: { airList () { - this.initPage()// 初始化页面 + this.initPage() } }, created () { if (this.airList.length > 0) { - this.initPage()// 初始化页面 + this.initPage() } } }