【类 型】:feat
【原 因】:增加了机型管理里面 添加和更新 功能 【过 程】:新增表单页面组件,实现添加与编辑逻辑,支持 shop_id、机型类型、载重等字段的录入和更新 【影 响】:
This commit is contained in:
parent
7f2b2c4ed6
commit
8e5a6428e3
@ -15,6 +15,7 @@ const store = new Vuex.Store({
|
|||||||
shopList: [], // 商铺列表
|
shopList: [], // 商铺列表
|
||||||
adminList: [], // 管理员列表
|
adminList: [], // 管理员列表
|
||||||
airList: [], // 所有飞机列表
|
airList: [], // 所有飞机列表
|
||||||
|
planeClassList: [], // 机型列表
|
||||||
siteList: [], // 站点列表
|
siteList: [], // 站点列表
|
||||||
routeList: [], // 航线列表
|
routeList: [], // 航线列表
|
||||||
noflyData: [[], [], []], // [0]禁飞区数据 [1]限制飞区 [2]限飞区高度
|
noflyData: [[], [], []], // [0]禁飞区数据 [1]限制飞区 [2]限飞区高度
|
||||||
@ -66,6 +67,12 @@ const store = new Vuex.Store({
|
|||||||
setRouteList (state, list) {
|
setRouteList (state, list) {
|
||||||
state.routeList = list
|
state.routeList = list
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* @description: 设置机型列表
|
||||||
|
*/
|
||||||
|
setPlaneClassList (state, list) {
|
||||||
|
state.planeClassList = list
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* @description: 设置禁飞区列表
|
* @description: 设置禁飞区列表
|
||||||
*/
|
*/
|
||||||
@ -431,6 +438,64 @@ const store = new Vuex.Store({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* @description: 获取机型列表
|
||||||
|
*/
|
||||||
|
async fetchPlaneClassList ({ commit }) {
|
||||||
|
const res = await api.get('getPlaneClassList')
|
||||||
|
if (res.data.status === 1) {
|
||||||
|
commit('setPlaneClassList', res.data.planeClassList)
|
||||||
|
} else {
|
||||||
|
commit('setPlaneClassList', [])
|
||||||
|
Message.warning(res.data.msg)
|
||||||
|
}
|
||||||
|
return res.data.planeClassList
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* @description: 创建新机型
|
||||||
|
* @param {*} form 表单.机型信息
|
||||||
|
* @return {*} 服务器返回信息
|
||||||
|
*/
|
||||||
|
async fetchAddPlaneClass ({ dispatch }, form) {
|
||||||
|
const params = new URLSearchParams()
|
||||||
|
params.append('shop_id', form.shop_id)
|
||||||
|
params.append('class_name', form.class_name)
|
||||||
|
params.append('wheelbase', form.wheelbase)
|
||||||
|
params.append('category', form.category)
|
||||||
|
params.append('weight_max', form.weight_max)
|
||||||
|
params.append('describe', form.describe)
|
||||||
|
const res = await api.post('addPlaneClass', params)
|
||||||
|
if (res.data.status === 1) {
|
||||||
|
await dispatch('fetchPlaneClassList')// 刷新 机型列表
|
||||||
|
Message.success(res.data.msg)
|
||||||
|
} else {
|
||||||
|
Message.error(res.data.msg)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* @description: 创建新机型
|
||||||
|
* @param {*} form 表单.机型信息
|
||||||
|
* @return {*} 服务器返回信息
|
||||||
|
*/
|
||||||
|
async fetchSavePlaneClass ({ dispatch }, form) {
|
||||||
|
const params = new URLSearchParams()
|
||||||
|
params.append('id', form.id)
|
||||||
|
params.append('shop_id', form.shop_id)
|
||||||
|
params.append('class_name', form.class_name)
|
||||||
|
params.append('wheelbase', form.wheelbase)
|
||||||
|
params.append('category', form.category)
|
||||||
|
params.append('weight_max', form.weight_max)
|
||||||
|
params.append('describe', form.describe)
|
||||||
|
const res = await api.post('savePlaneClass', params)
|
||||||
|
if (res.data.status === 1) {
|
||||||
|
await dispatch('fetchPlaneClassList')// 刷新 机型列表
|
||||||
|
Message.success(res.data.msg)
|
||||||
|
} else {
|
||||||
|
Message.error(res.data.msg)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* @description: 获取站点列表
|
* @description: 获取站点列表
|
||||||
*/
|
*/
|
||||||
|
@ -266,6 +266,7 @@ export default {
|
|||||||
refreshPage () {
|
refreshPage () {
|
||||||
/* init 数据接口 */
|
/* init 数据接口 */
|
||||||
this.$store.commit('app/setIsMobile') // 获取客户端平台类型
|
this.$store.commit('app/setIsMobile') // 获取客户端平台类型
|
||||||
|
this.$store.dispatch('fetchPlaneClassList')// 获取机型列表
|
||||||
this.$store.dispatch('fetchAirList') // 获取飞机列表
|
this.$store.dispatch('fetchAirList') // 获取飞机列表
|
||||||
this.$store.dispatch('fetchShopList') // 获取商铺列表
|
this.$store.dispatch('fetchShopList') // 获取商铺列表
|
||||||
this.$store.dispatch('fetchAdminList') // 获取管理员列表
|
this.$store.dispatch('fetchAdminList') // 获取管理员列表
|
||||||
|
@ -35,14 +35,14 @@
|
|||||||
<!-- 轴距 -->
|
<!-- 轴距 -->
|
||||||
<el-form-item label="轴距">
|
<el-form-item label="轴距">
|
||||||
<el-input v-model="form.wheelbase" placeholder="单位:厘米">
|
<el-input v-model="form.wheelbase" placeholder="单位:厘米">
|
||||||
<template slot="append">cm</template>
|
<template #append>cm</template>
|
||||||
</el-input>
|
</el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<!-- 最大载重 -->
|
<!-- 最大载重 -->
|
||||||
<el-form-item label="最大载重">
|
<el-form-item label="最大载重">
|
||||||
<el-input v-model="form.weight_max" placeholder="单位:克">
|
<el-input v-model="form.weight_max" placeholder="单位:克">
|
||||||
<template slot="append">克</template>
|
<template #append>克</template>
|
||||||
</el-input>
|
</el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
@ -52,15 +52,19 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<!-- 提交按钮 -->
|
<!-- 提交按钮 -->
|
||||||
<el-form-item v-if="pageState === 'add'">
|
<el-form-item>
|
||||||
<el-button type="primary" icon="el-icon-plus" @click="addAir">创建</el-button>
|
<el-button
|
||||||
<el-button @click="setForm({ shop_id: form.shop_id })" class="iconfont icon-qingchu">
|
type="primary"
|
||||||
|
:icon="pageState === 'add' ? 'el-icon-plus' : 'el-icon-edit'"
|
||||||
|
@click="pageState === 'add' ? addPlaneClass() : savePlaneClass()"
|
||||||
|
>
|
||||||
|
{{ pageState === 'add' ? '创建' : '更新' }}
|
||||||
|
</el-button>
|
||||||
|
<el-button v-if="pageState === 'add'" @click="setForm({ shop_id: form.shop_id })" class="iconfont icon-qingchu">
|
||||||
<font class="m-l-5">重填</font>
|
<font class="m-l-5">重填</font>
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item v-else>
|
|
||||||
<el-button type="primary" icon="el-icon-edit" @click="saveAir">更新</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-main>
|
</el-main>
|
||||||
</el-container>
|
</el-container>
|
||||||
@ -73,7 +77,10 @@
|
|||||||
import SelectionShopId from '@/components/SelectionShopId'
|
import SelectionShopId from '@/components/SelectionShopId'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'RegisterAdd',
|
name: 'PlaneClassAdd',
|
||||||
|
components: {
|
||||||
|
SelectionShopId
|
||||||
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
form: {
|
form: {
|
||||||
@ -82,79 +89,67 @@ export default {
|
|||||||
category: '四旋翼',
|
category: '四旋翼',
|
||||||
wheelbase: '',
|
wheelbase: '',
|
||||||
weight_max: '',
|
weight_max: '',
|
||||||
module: '',
|
describe: ''
|
||||||
describe: '',
|
|
||||||
onoff: true
|
|
||||||
},
|
},
|
||||||
airId: this.$route.params.id,
|
planeClassId: this.$route.params.id,
|
||||||
pageState: 'add',
|
pageState: 'add',
|
||||||
plane: null
|
planeClass: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
|
||||||
SelectionShopId
|
|
||||||
},
|
|
||||||
computed: {
|
computed: {
|
||||||
airList () {
|
planeClassList () {
|
||||||
return this.$store.state.airList
|
return this.$store.state.planeClassList || []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
setForm (data) {
|
setForm (data = {}) {
|
||||||
this.form.shop_id = data.shop_id
|
this.form.shop_id = data.shop_id || ''
|
||||||
this.form.class_name = data.class_name
|
this.form.class_name = data.class_name || ''
|
||||||
this.form.category = data.category
|
this.form.category = data.category || '四旋翼'
|
||||||
this.form.wheelbase = data.wheelbase
|
this.form.wheelbase = data.wheelbase || ''
|
||||||
this.form.weight_max = data.weight_max
|
this.form.weight_max = data.weight_max || ''
|
||||||
this.form.module = data.module
|
|
||||||
this.form.describe = data.describe || ''
|
this.form.describe = data.describe || ''
|
||||||
this.form.onoff = data.onoff === '1' || data.onoff === true
|
|
||||||
if (Object.keys(data).length === 0) {
|
if (Object.keys(data).length === 0) {
|
||||||
this.$message.warning('清空表单')
|
this.$message.warning('清空表单')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
initPage () {
|
initPage () {
|
||||||
if (this.airId === undefined) {
|
if (!this.planeClassId) {
|
||||||
this.pageState = 'add'
|
this.pageState = 'add'
|
||||||
} else {
|
} else {
|
||||||
this.pageState = 'edit'
|
this.pageState = 'edit'
|
||||||
this.plane = this.airList.find((item) => item.id === this.airId)
|
this.planeClass = this.planeClassList.find(item => item.id === this.planeClassId)
|
||||||
if (this.plane) {
|
if (this.planeClass) {
|
||||||
const data = {
|
this.setForm({ ...this.planeClass })
|
||||||
shop_id: this.plane.shop_id,
|
} else {
|
||||||
class_name: this.plane.class_name,
|
this.$message.error('找不到对应机型信息')
|
||||||
category: this.plane.category,
|
|
||||||
wheelbase: this.plane.wheelbase,
|
|
||||||
weight_max: this.plane.weight_max,
|
|
||||||
module: this.plane.module,
|
|
||||||
describe: this.plane.describe,
|
|
||||||
onoff: this.plane.onoff
|
|
||||||
}
|
|
||||||
this.setForm(data)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async addAir () {
|
async addPlaneClass () {
|
||||||
const res = await this.$store.dispatch('fetchAddAir', this.form)
|
const res = await this.$store.dispatch('fetchAddPlaneClass', this.form)
|
||||||
if (res.data.status === 1) {
|
if (res?.data?.status === 1) {
|
||||||
this.$router.push('/register/index')
|
this.$router.push('/model/index')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async saveAir () {
|
async savePlaneClass () {
|
||||||
this.form.id = this.airId
|
this.form.id = this.planeClassId
|
||||||
const res = await this.$store.dispatch('fetchSaveAir', this.form)
|
const res = await this.$store.dispatch('fetchSavePlaneClass', this.form)
|
||||||
if (res.data.status === 1) {
|
if (res?.data?.status === 1) {
|
||||||
this.$router.push('/register/index')
|
this.$router.push('/model/index')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
airList () {
|
planeClassList: {
|
||||||
|
handler () {
|
||||||
this.initPage()
|
this.initPage()
|
||||||
|
},
|
||||||
|
immediate: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
if (this.airList.length > 0) {
|
if (this.planeClassList.length > 0) {
|
||||||
this.initPage()
|
this.initPage()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,6 +107,7 @@ export default {
|
|||||||
created () {
|
created () {
|
||||||
/* init */
|
/* init */
|
||||||
this.$store.commit('app/setIsMobile')// 获取客户端平台类型
|
this.$store.commit('app/setIsMobile')// 获取客户端平台类型
|
||||||
|
this.$store.dispatch('fetchPlaneClassList')// 获取机型列表
|
||||||
this.$store.dispatch('fetchAirList')// 获取飞机列表
|
this.$store.dispatch('fetchAirList')// 获取飞机列表
|
||||||
this.$store.dispatch('fetchShopList')// 获取商铺列表
|
this.$store.dispatch('fetchShopList')// 获取商铺列表
|
||||||
this.$store.dispatch('fetchAdminList')// 获取管理员列表
|
this.$store.dispatch('fetchAdminList')// 获取管理员列表
|
||||||
|
Loading…
Reference in New Issue
Block a user