【类 型】:feat

【原  因】:机型管理模块 添加
【过  程】:
【影  响】:

# 类型 包含:
# feat:新功能(feature)
# fix:修补bug
# docs:文档(documentation)
# style: 格式(不影响代码运行的变动)
# refactor:重构(即不是新增功能,也不是修改bug的代码变动)
# test:增加测试
# chore:构建过程或辅助工具的变动
This commit is contained in:
air 2025-06-18 22:25:35 +08:00
parent 86e72a64a7
commit 7a3a80f2b9
3 changed files with 398 additions and 29 deletions

View File

@ -59,12 +59,56 @@ const routes = [
hidden: true
}
},
{
path: '/model',
component: Layout,
redirect: '/model/index',
meta: {
title: '机型管理',
icon: 'el-icon-edit-outline',
roles: ['admin', 'editor'],
tapName: 'plane'
},
children: [
{
path: '/model/index',
component: () => import('@/views/layout/components/main/model/index'),
meta: {
title: '机型列表',
icon: 'el-icon-tickets',
roles: ['admin', 'editor'],
tapName: 'plane'
}
},
{
path: '/model/add',
component: () => import('@/views/layout/components/main/model/add'),
meta: {
title: '机型添加',
icon: 'el-icon-plus',
roles: ['admin', 'editor'],
tapName: 'plane'
}
},
{
path: '/model/edit/:id',
component: () => import('@/views/layout/components/main/model/add'),
meta: {
title: '机型更新',
icon: 'el-icon-edit',
roles: ['admin', 'editor'],
tapName: 'plane',
hidden: true
}
}
]
},
{
path: '/register',
component: Layout,
redirect: '/register/index',
meta: {
title: '管理飞机',
title: '飞机管理',
icon: 'el-icon-edit-outline',
roles: ['admin', 'editor'],
tapName: 'plane'
@ -84,7 +128,7 @@ const routes = [
path: '/register/add',
component: () => import('@/views/layout/components/main/register/add'),
meta: {
title: '添加飞机',
title: '飞机添加',
icon: 'el-icon-plus',
roles: ['admin', 'editor'],
tapName: 'plane'
@ -94,7 +138,7 @@ const routes = [
path: '/register/edit/:id',
component: () => import('@/views/layout/components/main/register/add'),
meta: {
title: '更新飞机',
title: '飞机更新',
icon: 'el-icon-edit',
roles: ['admin', 'editor'],
tapName: 'plane',
@ -129,7 +173,7 @@ const routes = [
component: Layout,
redirect: '/nofly/setNofly',
meta: {
title: '限制飞行',
title: '飞行限制',
icon: 'iconfont icon-jinfeiqu',
roles: ['admin', 'editor'],
tapName: 'plane'
@ -139,7 +183,7 @@ const routes = [
path: '/nofly/setNofly',
component: () => import('@/views/layout/components/main/nofly/setNofly'),
meta: {
title: '设置禁飞区',
title: '禁飞区设置',
icon: 'iconfont icon-huizhi',
roles: ['admin', 'editor'],
tapName: 'plane'
@ -149,7 +193,7 @@ const routes = [
path: '/nofly/setRestrictfly',
component: () => import('@/views/layout/components/main/nofly/setRestrictfly'),
meta: {
title: '设置限飞区',
title: '限飞区设置',
icon: 'iconfont icon-huizhi',
roles: ['admin', 'editor'],
tapName: 'plane'
@ -162,7 +206,7 @@ const routes = [
component: Layout,
redirect: '/route/index',
meta: {
title: '管理航线',
title: '航线管理',
icon: 'iconfont icon-feihangluxian',
roles: ['admin', 'editor'],
tapName: 'plane'
@ -182,7 +226,7 @@ const routes = [
path: '/route/add',
component: () => import('@/views/layout/components/main/route/add'),
meta: {
title: '设计航线',
title: '航线设计',
icon: 'iconfont icon-huizhi',
roles: ['admin', 'editor'],
tapName: 'plane'
@ -192,7 +236,7 @@ const routes = [
path: '/route/edit/:id',
component: () => import('@/views/layout/components/main/route/add'),
meta: {
title: '编辑航线',
title: '航线编辑',
icon: 'iconfont icon-huizhi',
roles: ['admin', 'editor'],
tapName: 'plane',
@ -206,7 +250,7 @@ const routes = [
component: Layout,
redirect: '/site/index',
meta: {
title: '管理站点',
title: '站点管理',
icon: 'iconfont icon-zhandianguanli',
roles: ['admin', 'editor'],
tapName: 'plane'
@ -226,7 +270,7 @@ const routes = [
path: '/site/add',
component: () => import('@/views/layout/components/main/site/add'),
meta: {
title: '添加站点',
title: '站点添加',
icon: 'el-icon-plus',
roles: ['admin', 'editor'],
tapName: 'plane'
@ -236,7 +280,7 @@ const routes = [
path: '/site/edit/:id',
component: () => import('@/views/layout/components/main/site/add'),
meta: {
title: '更新站点',
title: '站点更新',
icon: 'el-icon-edit',
roles: ['admin', 'editor'],
tapName: 'plane',
@ -273,7 +317,7 @@ const routes = [
component: Layout,
redirect: '/shop/edit',
meta: {
title: '管理商铺',
title: '商铺管理',
icon: 'iconfont icon-a-shanghu_choose2x1',
roles: ['admin', 'editor'],
tapName: 'admin'
@ -283,7 +327,7 @@ const routes = [
path: '/shop/edit',
component: () => import('@/views/layout/components/main/shop/add'),
meta: {
title: '设置商铺',
title: '商铺设置',
icon: 'iconfont icon-dianpuguanli',
roles: ['admin', 'editor'],
tapName: 'admin'
@ -293,7 +337,7 @@ const routes = [
path: '/shop/add',
component: () => import('@/views/layout/components/main/shop/add'),
meta: {
title: '添加商铺',
title: '商铺添加',
icon: 'iconfont icon-check',
roles: ['admin', 'editor'],
tapName: 'admin'
@ -326,7 +370,7 @@ const routes = [
path: '/admin/add',
component: () => import('@/views/layout/components/main/admin/add'),
meta: {
title: '添加账户',
title: '账户添加',
icon: 'iconfont icon-xinzengguanliyuan',
roles: ['admin', 'editor'],
tapName: 'admin'
@ -336,7 +380,7 @@ const routes = [
path: '/admin/edit/:id',
component: () => import('@/views/layout/components/main/admin/add'),
meta: {
title: '编辑账户',
title: '账户编辑',
icon: 'iconfont icon-huizhi',
roles: ['admin', 'editor'],
tapName: 'admin',
@ -347,7 +391,7 @@ const routes = [
path: '/admin/message',
component: () => import('@/views/layout/components/main/admin/message'),
meta: {
title: '发布公告',
title: '公告发布',
icon: 'el-icon-microphone',
roles: ['admin', 'editor'],
tapName: 'admin',
@ -361,7 +405,7 @@ const routes = [
component: Layout,
redirect: '/category/index',
meta: {
title: '管理分类',
title: '分类管理',
icon: 'iconfont icon-a-ziliaocaozuoxianshifenleishu',
roles: ['admin', 'editor'],
tapName: 'admin'
@ -371,7 +415,7 @@ const routes = [
path: '/category/index',
component: () => import('@/views/layout/components/main/category/index'),
meta: {
title: '管理分类',
title: '分类管理',
icon: 'iconfont icon-a-ziliaocaozuoxianshifenleishu',
roles: ['admin', 'editor'],
tapName: 'admin'
@ -384,7 +428,7 @@ const routes = [
component: Layout,
redirect: '/spu/index',
meta: {
title: '管理商品',
title: '商品管理',
icon: 'iconfont icon-chanpin',
roles: ['admin', 'editor'],
tapName: 'admin'
@ -404,7 +448,7 @@ const routes = [
path: '/spu/add',
component: () => import('@/views/layout/components/main/product/spu/add'),
meta: {
title: '添加SPU',
title: 'SPU添加',
icon: 'iconfont icon-huoquchanpin',
roles: ['admin', 'editor'],
tapName: 'admin'
@ -414,7 +458,7 @@ const routes = [
path: '/spu/edit/:id',
component: () => import('@/views/layout/components/main/product/spu/add'),
meta: {
title: '编辑SPU',
title: 'SPU编辑',
icon: 'iconfont icon-huoquchanpin',
roles: ['admin', 'editor'],
tapName: 'admin',
@ -435,7 +479,7 @@ const routes = [
path: '/sku/add',
component: () => import('@/views/layout/components/main/product/sku/add'),
meta: {
title: '添加SKU',
title: 'SKU添加',
icon: 'iconfont icon-sku1',
roles: ['admin', 'editor'],
tapName: 'admin'
@ -445,7 +489,7 @@ const routes = [
path: '/sku/edit/:id',
component: () => import('@/views/layout/components/main/product/sku/add'),
meta: {
title: '编辑SKU',
title: 'SKU编辑',
icon: 'iconfont icon-sku1',
roles: ['admin', 'editor'],
tapName: 'admin',
@ -459,7 +503,7 @@ const routes = [
component: Layout,
redirect: '/broadcast/banner',
meta: {
title: '管理广告',
title: '广告管理',
icon: 'iconfont icon-guanggao',
roles: ['admin', 'editor'],
tapName: 'admin'
@ -469,7 +513,7 @@ const routes = [
path: '/broadcast/banner',
component: () => import('@/views/layout/components/main/broadcast/banner'),
meta: {
title: '设置banner',
title: 'banner设置',
icon: 'iconfont icon-banner',
roles: ['admin', 'editor'],
tapName: 'admin'
@ -479,7 +523,7 @@ const routes = [
path: '/broadcast/notice',
component: () => import('@/views/layout/components/main/broadcast/notice'),
meta: {
title: '设置滚动通知',
title: '滚动通知设置',
icon: 'iconfont icon-m-gundongwenzi',
roles: ['admin', 'editor'],
tapName: 'admin'
@ -502,7 +546,7 @@ const routes = [
path: '/order/index',
component: () => import('@/views/layout/components/main/order/index'),
meta: {
title: '管理订单',
title: '订单管理',
icon: 'iconfont icon-a-SalesOrderManagement',
roles: ['admin', 'editor'],
tapName: 'admin'

View File

@ -0,0 +1,159 @@
<template>
<div class="app-container">
<el-row class="m-t-0">
<el-col :span="24">
<el-container>
<el-header height="42px" class="l-h-42 p-l-10 p-r-10 border border-b-n">
<div class="l">
<i v-if="pageState === 'add'" class="el-icon-plus f-s-20"></i>
<i v-else class="el-icon-edit f-s-20"></i>
<font class="m-l-10 f-s-18 fb">{{ $route.meta.title }}</font>
</div>
</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>
<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>
<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>
<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-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>
</el-button>
</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-main>
</el-container>
</el-col>
</el-row>
</div>
</template>
<script>
import SelectionShopId from '@/components/SelectionShopId'
export default {
name: 'RegisterAdd',
data () {
return {
form: {
shop_id: '',
name: '',
date: '',
onoff: true,
weight_max: '',
desc: ''
},
airId: this.$route.params.id, // get id
pageState: 'add', //
plane: null
}
},
components: {
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.weight_max = data.weight_max
this.form.desc = data.desc
if (Object.keys(data).length === 0) {
this.$message.warning('清空表单')
}
},
// or
initPage () {
if (this.airId === undefined) {
this.pageState = 'add'
} else {
this.pageState = 'edit'
this.plane = this.airList.find((item) => item.id === this.airId)
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',
weight_max: this.plane.weight_max,
desc: this.plane.describe
}
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)
if (res.data.status === 1) {
this.$router.push('/register/index')
}
}
},
watch: {
airList () {
this.initPage()//
}
},
created () {
if (this.airList.length > 0) {
this.initPage()//
}
}
}
</script>
<style scoped>
.line {
text-align: center;
}
</style>

View File

@ -0,0 +1,166 @@
<template>
<div class="app-container">
<!-- 组合按钮 -->
<el-button-group class="m-r-20 m-b-20">
<el-button type="primary" icon="el-icon-plus" @click="$router.replace('/register/add')">添加</el-button>
<el-button type="danger" icon="el-icon-delete" @click="deleteAir(countSelIdArr($refs.myTable.selection))">删除
</el-button>
<el-button type="warning" icon="el-icon-edit" @click="toEditPage()">编辑</el-button>
<el-button type="success" icon="el-icon-data-line" @click="toFlyDataPage(countSelIdArr($refs.myTable.selection))">飞行数据</el-button>
</el-button-group>
<!-- 用户select选项 -->
<el-button-group class="m-b-20">
<SelectionShopId v-model="form.shop_id" :allSel="true" />
</el-button-group>
<!-- 飞机表格 -->
<el-table class="w-100" ref="myTable"
:data="airListArr.slice((currentPage - 1) * pageSize, currentPage * pageSize)" border tooltip-effect="dark">
<el-table-column align="center" type="selection" width="40">
</el-table-column>
<el-table-column align="center" prop="id" label="id" width="50">
</el-table-column>
<el-table-column prop="name" label="名称" width="150" min-width="150">
</el-table-column>
<el-table-column label="macID" width="175" min-width="175">
<template slot-scope="scope">
<el-tag :type="scope.row.macadd !== '' ? 'success' : 'danger'">
<i style="" class="iconfont m-r-5 f-s-16 l-h-32"
:class="scope.row.macadd !== '' ? 'icon-jiekou' : 'icon-cuowu'"></i>
<font>{{ scope.row.macadd !== '' ? scope.row.macadd : '未对频' }}</font>
</el-tag>
</template>
</el-table-column>
<el-table-column label="状态" min-width="150" show-overflow-tooltip>
<template slot-scope="scope">
<el-tag :type="scope.row.onoff === '1' ? 'success' : 'danger'">
<i style="" class="iconfont m-r-5 f-s-16 l-h-32"
:class="scope.row.onoff === '1' ? 'icon-qiyong' : 'icon-ic_tingyong'"></i>
<font>{{ scope.row.onoff === '1' ? '启用' : '停用' }}</font>
</el-tag>
</template>
</el-table-column>
<el-table-column label="注册时间" width="100" min-width="80">
<template slot-scope="scope">
{{ scope.row.apply_time | parseTime('{y}-{m}-{d}') }}
</template>
</el-table-column>
<el-table-column prop="controler" label="操作" width="380" min-width="380">
<template slot-scope="scope">
<el-button-group>
<el-button type="primary" class="iconfont icon-youxishoubing"
@click="$router.replace(`/planes/index/${scope.row.id}/${scope.row.name}`)"><span
class="m-l-5">操作</span></el-button>
<el-button type="warning" icon="el-icon-edit"
@click="$router.replace(`/register/edit/${scope.row.id}`)">编辑</el-button>
<el-button type="danger" icon="el-icon-delete" @click="deleteAir([scope.row.id])">删除</el-button>
</el-button-group>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<el-pagination class="m-t-20" layout="prev, pager, next" :current-page.sync="currentPage" :page-size="pageSize"
:total="airListArr.length">
</el-pagination>
</div>
</template>
<script>
import { parseTime, countSelIdArr } from '@/utils'
import SelectionShopId from '@/components/SelectionShopId'
export default {
name: 'Register',
data () {
return {
pageSize: 8, //
currentPage: 1, //
form: {
shop_id: ''
}
}
},
components: {
SelectionShopId
},
computed: {
//
airList () {
return this.$store.state.airList
},
/**
* @description: 过滤掉 不对应客户的 飞机列表
* @return: 飞机列表
*/
airListArr () {
if (this.form.shop_id !== '') {
return this.airList.filter((item) => item.shop_id === this.form.shop_id)
} else {
return this.airList
}
}
},
methods: {
countSelIdArr,
/**
* @description: 跳转到编辑页面
*/
toEditPage () {
const selId = this.countSelIdArr(this.$refs.myTable.selection)
switch (selId.length) {
case 0:
this.$message.error('请选择一条需要编辑的记录')
break
case 1:
this.$router.push('/register/edit/' + selId['0'])
break
default:
this.$message.error('只能选择一条记录')
}
},
/**
* @description: 跳转到飞机数据统计页面
*/
toFlyDataPage (selIdArr) {
if (selIdArr.length === 0) {
this.$message.error('请选择至少一架飞机')
} else {
this.$store.commit('app/setToFlyDataIdArr', selIdArr)//
this.$router.push('/register/flyData/')
}
},
/**
* @description: 删除飞机
*/
deleteAir (idArr) {
this.$store.dispatch('fetchDelAir', idArr)
}
},
watch: {
},
created () {
},
filters: {
parseTime,
countSelIdArr
}
}
</script>
<style lang="scss" scoped>
@import "@/styles/theme.scss";
.el-tag {
i {
vertical-align: middle
}
}
.no-wrap-btn-group {
white-space: nowrap;
/* 禁止换行 */
overflow-x: auto;
/* 超出时可横向滚动 */
display: inline-block;
/* 或者用 flex 布局 */
}
</style>