【类 型】:

【原  因】:
【过  程】:
【影  响】:
This commit is contained in:
air 2025-06-19 00:40:40 +08:00
parent 7a3a80f2b9
commit 7f2b2c4ed6

View File

@ -12,32 +12,47 @@
</el-header>
<el-main class="border p-20 m-b-20">
<el-form ref="form" :model="form" label-width="120px" :label-position="$store.state.app.isWideScreen ? 'top' : 'right'">
<!-- 商铺选择 -->
<el-form-item v-if="pageState === 'add'" label="所属商铺">
<SelectionShopId v-model="form.shop_id" />
</el-form-item>
<el-form-item label="飞机名称">
<el-input v-model="form.name" placeholder="起名可以是中文" />
<!-- 类别名称 -->
<el-form-item label="机型名称">
<el-input v-model="form.class_name" placeholder="例如:运输型无人机" />
</el-form-item>
<el-form-item label="购买日期">
<el-date-picker v-if="pageState == 'add' ? true : false" v-model="form.date" type="date"
placeholder="选择日期" format="yyyy 年 MM 月 dd 日" value-format="timestamp">
</el-date-picker>
<el-date-picker v-else v-model="form.date" type="date" placeholder="选择日期" format="yyyy 年 MM 月 dd 日"
value-format="timestamp" disabled>
</el-date-picker>
<!-- 飞机类型 -->
<el-form-item label="机型类型">
<el-select v-model="form.category" placeholder="请选择类型">
<el-option label="四旋翼" value="四旋翼" />
<el-option label="固定翼" value="固定翼" />
<el-option label="垂直起降" value="垂直起降" />
</el-select>
</el-form-item>
<el-form-item label="运载极限重量">
<el-input v-model="form.weight_max" placeholder="运载的重量上限">
<!-- 轴距 -->
<el-form-item label="轴距">
<el-input v-model="form.wheelbase" placeholder="单位:厘米">
<template slot="append">cm</template>
</el-input>
</el-form-item>
<!-- 最大载重 -->
<el-form-item label="最大载重">
<el-input v-model="form.weight_max" placeholder="单位:克">
<template slot="append"></template>
</el-input>
</el-form-item>
<el-form-item :label="form.onoff === true ? '启用' : '停用'">
<el-switch v-model="form.onoff" />
<!-- 描述 -->
<el-form-item label="机型描述">
<el-input v-model="form.describe" type="textarea" placeholder="描述备注,非必填" />
</el-form-item>
<el-form-item label="飞机描述">
<el-input v-model="form.desc" type="textarea" placeholder="描述备注,非必填" />
</el-form-item>
<el-form-item v-if="pageState == 'add' ? true : false">
<!-- 提交按钮 -->
<el-form-item v-if="pageState === 'add'">
<el-button type="primary" icon="el-icon-plus" @click="addAir">创建</el-button>
<el-button @click="setForm({ shop_id: form.shop_id })" class="iconfont icon-qingchu">
<font class="m-l-5">重填</font>
@ -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()
}
}
}