Merge branch 'master' of https://git.code.tencent.com/beijing-rtss-test/bj-rtss-client
This commit is contained in:
commit
eab04e706b
189
src/api/TrainModelApi.ts
Normal file
189
src/api/TrainModelApi.ts
Normal file
@ -0,0 +1,189 @@
|
||||
import { api } from 'src/boot/axios';
|
||||
import { PageDto, PageQueryDto } from './ApiCommon';
|
||||
|
||||
const UriBase = '/api/v1/trainManage';
|
||||
|
||||
export class PagingQueryParams extends PageQueryDto {
|
||||
name?: string;
|
||||
}
|
||||
|
||||
export interface ModelCreateParams {
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface TrainModelItem extends ModelCreateParams {
|
||||
id: number;
|
||||
created_at: string;
|
||||
update_at: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 列车型号分页查询
|
||||
* @param params
|
||||
* @returns
|
||||
*/
|
||||
export async function modelPageQuery(
|
||||
params: PagingQueryParams
|
||||
): Promise<PageDto<TrainModelItem>> {
|
||||
const response = await api.get(`${UriBase}/model/paging`, {
|
||||
params: params,
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建列车型号
|
||||
* @param params
|
||||
* @returns
|
||||
*/
|
||||
export function createTrainModel(data: ModelCreateParams) {
|
||||
return api.post(`${UriBase}/model`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除列车型号
|
||||
* @param id 列车型号id
|
||||
*/
|
||||
export function deleteTrainModel(id: number) {
|
||||
return api.delete(`${UriBase}/model/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改列车型号数据
|
||||
* @param id 列车型号id
|
||||
*/
|
||||
export function saveTrainModelData(id: number, data: ModelCreateParams) {
|
||||
return api.put(`${UriBase}/model/${id}`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取列车型号数据详情
|
||||
* @param params
|
||||
* @returns
|
||||
*/
|
||||
export async function getTrainModelInfo(id: number): Promise<TrainModelItem> {
|
||||
const response = await api.get(`${UriBase}/model/${id}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export interface SizeCreateParams {
|
||||
name: string;
|
||||
carriage_length: number;
|
||||
description: string;
|
||||
total_length: number;
|
||||
}
|
||||
|
||||
export interface TrainSizeItem extends SizeCreateParams {
|
||||
id: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 列车尺寸分页查询
|
||||
* @param params
|
||||
* @returns
|
||||
*/
|
||||
export async function sizePageQuery(
|
||||
params: PagingQueryParams
|
||||
): Promise<PageDto<TrainSizeItem>> {
|
||||
const response = await api.get(`${UriBase}/size/paging`, {
|
||||
params: params,
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建列车尺寸
|
||||
* @param params
|
||||
* @returns
|
||||
*/
|
||||
export function createTrainSize(data: SizeCreateParams) {
|
||||
return api.post(`${UriBase}/size`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除列车尺寸
|
||||
* @param id 列车尺寸id
|
||||
*/
|
||||
export function deleteTrainSize(id: number) {
|
||||
return api.delete(`${UriBase}/size/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改列车尺寸数据
|
||||
* @param id 列车尺寸id
|
||||
*/
|
||||
export function saveTrainSizeData(id: number, data: SizeCreateParams) {
|
||||
return api.put(`${UriBase}/size/${id}`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取列车尺寸数据详情
|
||||
* @param params
|
||||
* @returns
|
||||
*/
|
||||
export async function getTrainSizeInfo(id: number): Promise<TrainSizeItem> {
|
||||
const response = await api.get(`${UriBase}/size/${id}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export interface WheelCreateParams {
|
||||
name: string;
|
||||
axial_position: number;
|
||||
diameter: number;
|
||||
install_direction: string;
|
||||
max_diameter: number;
|
||||
min_diameter: number;
|
||||
}
|
||||
|
||||
export interface TrainWheelItem extends WheelCreateParams {
|
||||
id: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 列车轮径分页查询
|
||||
* @param params
|
||||
* @returns
|
||||
*/
|
||||
export async function wheelPageQuery(
|
||||
params: PagingQueryParams
|
||||
): Promise<PageDto<TrainWheelItem>> {
|
||||
const response = await api.get(`${UriBase}/wheelDiameter/paging`, {
|
||||
params: params,
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建列车轮径
|
||||
* @param params
|
||||
* @returns
|
||||
*/
|
||||
export function createTrainWheel(data: WheelCreateParams) {
|
||||
return api.post(`${UriBase}/wheelDiameter`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除列车轮径
|
||||
* @param id 列车轮径id
|
||||
*/
|
||||
export function deleteTrainWheel(id: number) {
|
||||
return api.delete(`${UriBase}/wheelDiameter/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改列车轮径数据
|
||||
* @param id 列车轮径id
|
||||
*/
|
||||
export function saveTrainWheelData(id: number, data: WheelCreateParams) {
|
||||
return api.put(`${UriBase}/wheelDiameter/${id}`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取列车轮径数据详情
|
||||
* @param params
|
||||
* @returns
|
||||
*/
|
||||
export async function getTrainWheelInfo(id: number): Promise<TrainWheelItem> {
|
||||
const response = await api.get(`${UriBase}/wheelDiameter/${id}`);
|
||||
return response.data;
|
||||
}
|
@ -67,12 +67,17 @@ const list = reactive([
|
||||
{
|
||||
path: '/dataManage/publish',
|
||||
label: '发布管理',
|
||||
icon: 'app_registration',
|
||||
icon: 'playlist_add_check',
|
||||
},
|
||||
{
|
||||
path: '/dataManage/categoryInfo',
|
||||
label: '厂家信息管理',
|
||||
icon: 'app_registration',
|
||||
icon: 'category',
|
||||
},
|
||||
{
|
||||
path: '/dataManage/trainModel',
|
||||
label: '列车管理',
|
||||
icon: 'train',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
935
src/pages/TrainModelManage.vue
Normal file
935
src/pages/TrainModelManage.vue
Normal file
@ -0,0 +1,935 @@
|
||||
<template>
|
||||
<div class="q-pa-md">
|
||||
<q-tabs v-model="tab" inline-label align="left">
|
||||
<q-tab name="model" icon="model_training" label="型号" />
|
||||
<q-tab name="size" icon="linear_scale" label="尺寸" />
|
||||
<q-tab name="wheel" icon="blur_circular" label="轮径" />
|
||||
</q-tabs>
|
||||
<q-separator />
|
||||
<q-tab-panels
|
||||
v-model="tab"
|
||||
animated
|
||||
swipeable
|
||||
transition-prev="jump-up"
|
||||
transition-next="jump-up"
|
||||
>
|
||||
<q-tab-panel name="model" class="fit-width">
|
||||
<q-table
|
||||
ref="modelTableRef"
|
||||
title="型号管理"
|
||||
:style="{ height: tableHeight + 'px' }"
|
||||
:rows="modelRows"
|
||||
:columns="modelColumnDefs"
|
||||
row-key="id"
|
||||
v-model:pagination="modelPagination"
|
||||
:rows-per-page-options="[10, 20, 50, 100]"
|
||||
:loading="modelLoading"
|
||||
:filter="modelFilter"
|
||||
binary-state-sort
|
||||
@request="modelOnRequest"
|
||||
>
|
||||
<template v-slot:top-right>
|
||||
<q-input
|
||||
dense
|
||||
debounce="1000"
|
||||
v-model="modelFilter.name"
|
||||
label="名称"
|
||||
></q-input>
|
||||
<q-btn flat round color="primary" icon="search" />
|
||||
<q-btn
|
||||
color="primary"
|
||||
label="新建"
|
||||
@click="modelCreateFormShow = true"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<template v-slot:body-cell-operations="props">
|
||||
<q-td :props="props">
|
||||
<div class="q-gutter-sm row justify-center">
|
||||
<q-btn
|
||||
color="primary"
|
||||
:disable="modelOperateDisabled"
|
||||
label="编辑"
|
||||
@click="modelEditData(props.row)"
|
||||
/>
|
||||
<q-btn
|
||||
color="red"
|
||||
:disable="modelOperateDisabled"
|
||||
label="删除"
|
||||
@click="modelDeleteData(props.row)"
|
||||
/>
|
||||
</div>
|
||||
</q-td>
|
||||
</template>
|
||||
</q-table>
|
||||
|
||||
<q-dialog
|
||||
v-model="modelCreateFormShow"
|
||||
persistent
|
||||
transition-show="scale"
|
||||
transition-hide="scale"
|
||||
>
|
||||
<q-card style="width: 300px">
|
||||
<q-card-section>
|
||||
<q-form
|
||||
ref="modelForm"
|
||||
@submit="modelOnCreate"
|
||||
@reset="modelOnReset"
|
||||
class="q-gutter-md"
|
||||
>
|
||||
<div class="text-h6">
|
||||
{{ modelEditInfo.id ? '编辑型号' : '新建型号' }}
|
||||
</div>
|
||||
<q-input
|
||||
outlined
|
||||
label="型号名称"
|
||||
v-model="modelEditInfo.name"
|
||||
lazy-rules
|
||||
:rules="[(val) => val.length > 0 || '请输入型号名称!']"
|
||||
/>
|
||||
|
||||
<q-card-actions align="right">
|
||||
<q-btn color="primary" label="保存" type="submit" />
|
||||
<q-btn label="取消" type="reset" v-close-popup />
|
||||
</q-card-actions>
|
||||
</q-form>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</q-tab-panel>
|
||||
|
||||
<q-tab-panel name="size">
|
||||
<q-table
|
||||
ref="sizeTableRef"
|
||||
title="尺寸管理"
|
||||
:style="{ height: tableHeight + 'px' }"
|
||||
:rows="sizeRows"
|
||||
:columns="sizeColumnDefs"
|
||||
row-key="id"
|
||||
v-model:pagination="sizePagination"
|
||||
:rows-per-page-options="[10, 20, 50, 100]"
|
||||
:loading="sizeLoading"
|
||||
:filter="sizeFilter"
|
||||
binary-state-sort
|
||||
@request="sizeOnRequest"
|
||||
>
|
||||
<template v-slot:top-right>
|
||||
<q-input
|
||||
dense
|
||||
debounce="1000"
|
||||
v-model="sizeFilter.name"
|
||||
label="名称"
|
||||
></q-input>
|
||||
<q-btn flat round color="primary" icon="search" />
|
||||
<q-btn
|
||||
color="primary"
|
||||
label="新建"
|
||||
@click="sizeCreateFormShow = true"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<template v-slot:body-cell-operations="props">
|
||||
<q-td :props="props">
|
||||
<div class="q-gutter-sm row justify-center">
|
||||
<q-btn
|
||||
color="primary"
|
||||
:disable="sizeOperateDisabled"
|
||||
label="编辑"
|
||||
@click="sizeEditData(props.row)"
|
||||
/>
|
||||
<q-btn
|
||||
color="red"
|
||||
:disable="sizeOperateDisabled"
|
||||
label="删除"
|
||||
@click="sizeDeleteData(props.row)"
|
||||
/>
|
||||
</div>
|
||||
</q-td>
|
||||
</template>
|
||||
</q-table>
|
||||
|
||||
<q-dialog
|
||||
v-model="sizeCreateFormShow"
|
||||
persistent
|
||||
transition-show="scale"
|
||||
transition-hide="scale"
|
||||
>
|
||||
<q-card style="width: 300px">
|
||||
<q-card-section>
|
||||
<q-form
|
||||
ref="sizeForm"
|
||||
@submit="sizeOnCreate"
|
||||
@reset="sizeOnReset"
|
||||
class="q-gutter-md"
|
||||
>
|
||||
<div class="text-h6">
|
||||
{{ sizeEditInfo.id ? '编辑尺寸' : '新建尺寸' }}
|
||||
</div>
|
||||
<q-input
|
||||
outlined
|
||||
label="尺寸名称"
|
||||
v-model="sizeEditInfo.name"
|
||||
lazy-rules
|
||||
:rules="[(val) => val.length > 0 || '请输入尺寸名称!']"
|
||||
/>
|
||||
<q-input
|
||||
outlined
|
||||
label="车厢长度"
|
||||
v-model.number="sizeEditInfo.carriage_length"
|
||||
type="number"
|
||||
lazy-rules
|
||||
:rules="[(val) => val > 0 || '请输入大于0的数字!']"
|
||||
/>
|
||||
<q-input
|
||||
outlined
|
||||
label="总长度"
|
||||
v-model.number="sizeEditInfo.total_length"
|
||||
type="number"
|
||||
lazy-rules
|
||||
:rules="[(val) => val > 0 || '请输入大于0的数字!']"
|
||||
/>
|
||||
<q-input
|
||||
outlined
|
||||
label="描述"
|
||||
v-model="sizeEditInfo.description"
|
||||
lazy-rules
|
||||
:rules="[(val) => val.length > 0 || '请输入描述!']"
|
||||
/>
|
||||
|
||||
<q-card-actions align="right">
|
||||
<q-btn color="primary" label="保存" type="submit" />
|
||||
<q-btn label="取消" type="reset" v-close-popup />
|
||||
</q-card-actions>
|
||||
</q-form>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</q-tab-panel>
|
||||
|
||||
<q-tab-panel name="wheel">
|
||||
<q-table
|
||||
ref="wheelTableRef"
|
||||
title="轮径管理"
|
||||
:style="{ height: tableHeight + 'px' }"
|
||||
:rows="wheelRows"
|
||||
:columns="wheelColumnDefs"
|
||||
row-key="id"
|
||||
v-model:pagination="wheelPagination"
|
||||
:rows-per-page-options="[10, 20, 50, 100]"
|
||||
:loading="wheelLoading"
|
||||
:filter="wheelFilter"
|
||||
binary-state-sort
|
||||
@request="wheelOnRequest"
|
||||
>
|
||||
<template v-slot:top-right>
|
||||
<q-input
|
||||
dense
|
||||
debounce="1000"
|
||||
v-model="wheelFilter.name"
|
||||
label="名称"
|
||||
></q-input>
|
||||
<q-btn flat round color="primary" icon="search" />
|
||||
<q-btn
|
||||
color="primary"
|
||||
label="新建"
|
||||
@click="wheelCreateFormShow = true"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<template v-slot:body-cell-operations="props">
|
||||
<q-td :props="props">
|
||||
<div class="q-gutter-sm row justify-center">
|
||||
<q-btn
|
||||
color="primary"
|
||||
:disable="wheelOperateDisabled"
|
||||
label="编辑"
|
||||
@click="wheelEditData(props.row)"
|
||||
/>
|
||||
<q-btn
|
||||
color="red"
|
||||
:disable="wheelOperateDisabled"
|
||||
label="删除"
|
||||
@click="wheelDeleteData(props.row)"
|
||||
/>
|
||||
</div>
|
||||
</q-td>
|
||||
</template>
|
||||
</q-table>
|
||||
|
||||
<q-dialog
|
||||
v-model="wheelCreateFormShow"
|
||||
persistent
|
||||
transition-show="scale"
|
||||
transition-hide="scale"
|
||||
>
|
||||
<q-card style="width: 300px">
|
||||
<q-card-section>
|
||||
<q-form
|
||||
ref="wheelForm"
|
||||
@submit="wheelOnCreate"
|
||||
@reset="wheelOnReset"
|
||||
class="q-gutter-md"
|
||||
>
|
||||
<div class="text-h6">
|
||||
{{ wheelEditInfo.id ? '编辑轮径' : '新建轮径' }}
|
||||
</div>
|
||||
<q-input
|
||||
outlined
|
||||
label="轮径名称"
|
||||
v-model="wheelEditInfo.name"
|
||||
lazy-rules
|
||||
:rules="[(val) => val.length > 0 || '请输入名称!']"
|
||||
/>
|
||||
<q-input
|
||||
outlined
|
||||
label="轮径安装轴位"
|
||||
v-model.number="wheelEditInfo.axial_position"
|
||||
type="number"
|
||||
lazy-rules
|
||||
:rules="[(val) => val > 0 || '请输入大于0的数字!']"
|
||||
/>
|
||||
<q-input
|
||||
outlined
|
||||
label="车轮直径(mm)"
|
||||
v-model.number="wheelEditInfo.diameter"
|
||||
type="number"
|
||||
lazy-rules
|
||||
:rules="[(val) => val > 0 || '请输入大于0的数字!']"
|
||||
/>
|
||||
<q-select
|
||||
outlined
|
||||
class="q-mt-md"
|
||||
v-model="wheelEditInfo.install_direction"
|
||||
:options="directionOptions"
|
||||
map-options
|
||||
emit-value
|
||||
label="安装方向"
|
||||
lazy-rules
|
||||
:rules="[(val) => val.length > 0 || '请输入左侧或者右侧!']"
|
||||
></q-select>
|
||||
|
||||
<q-input
|
||||
outlined
|
||||
label="车轮的最大直径(mm)"
|
||||
v-model.number="wheelEditInfo.max_diameter"
|
||||
type="number"
|
||||
lazy-rules
|
||||
:rules="[(val) => val > 0 || '请输入大于0的数字!']"
|
||||
/>
|
||||
<q-input
|
||||
outlined
|
||||
label="车轮的最小直径(mm)"
|
||||
v-model.number="wheelEditInfo.min_diameter"
|
||||
type="number"
|
||||
lazy-rules
|
||||
:rules="[(val) => val > 0 || '请输入大于0的数字!']"
|
||||
/>
|
||||
|
||||
<q-card-actions align="right">
|
||||
<q-btn color="primary" label="保存" type="submit" />
|
||||
<q-btn label="取消" type="reset" v-close-popup />
|
||||
</q-card-actions>
|
||||
</q-form>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</q-tab-panel>
|
||||
</q-tab-panels>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, computed, watch, nextTick } from 'vue';
|
||||
import { useQuasar, type QTableColumn, QForm } from 'quasar';
|
||||
import {
|
||||
modelPageQuery,
|
||||
createTrainModel,
|
||||
deleteTrainModel,
|
||||
saveTrainModelData,
|
||||
ModelCreateParams,
|
||||
TrainModelItem,
|
||||
getTrainModelInfo,
|
||||
SizeCreateParams,
|
||||
saveTrainSizeData,
|
||||
createTrainSize,
|
||||
sizePageQuery,
|
||||
TrainSizeItem,
|
||||
deleteTrainSize,
|
||||
getTrainSizeInfo,
|
||||
wheelPageQuery,
|
||||
WheelCreateParams,
|
||||
saveTrainWheelData,
|
||||
createTrainWheel,
|
||||
TrainWheelItem,
|
||||
deleteTrainWheel,
|
||||
getTrainWheelInfo,
|
||||
} from '../api/TrainModelApi';
|
||||
import { ApiError } from 'src/boot/axios';
|
||||
|
||||
const $q = useQuasar();
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
sizeHeight: number;
|
||||
}>(),
|
||||
{ sizeHeight: 500 }
|
||||
);
|
||||
|
||||
const tableHeight = computed(() => {
|
||||
return props.sizeHeight - 32 - 32 - 48;
|
||||
});
|
||||
|
||||
const tab = ref('model');
|
||||
watch(
|
||||
() => tab.value,
|
||||
(val) => {
|
||||
nextTick(() => {
|
||||
if (val == 'model') {
|
||||
modelTableRef.value.requestServerInteraction();
|
||||
} else if (val == 'size') {
|
||||
sizeTableRef.value.requestServerInteraction();
|
||||
} else if (val == 'wheel') {
|
||||
wheelTableRef.value.requestServerInteraction();
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
onMounted(() => {
|
||||
modelTableRef.value.requestServerInteraction();
|
||||
});
|
||||
|
||||
const modelColumnDefs: QTableColumn[] = [
|
||||
{
|
||||
name: 'name',
|
||||
label: '名称',
|
||||
field: 'name',
|
||||
required: true,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
name: 'created_at',
|
||||
label: '创建时间',
|
||||
field: 'created_at',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
name: 'update_at',
|
||||
label: '更新时间',
|
||||
field: 'update_at',
|
||||
align: 'center',
|
||||
},
|
||||
{ name: 'operations', label: '操作', field: 'operations', align: 'center' },
|
||||
];
|
||||
|
||||
const modelOperateDisabled = ref(false);
|
||||
const modelTableRef = ref();
|
||||
const modelRows = reactive([]);
|
||||
const modelFilter = reactive({
|
||||
name: '',
|
||||
});
|
||||
const modelLoading = ref(false);
|
||||
const modelPagination = ref({
|
||||
sortBy: 'desc',
|
||||
descending: false,
|
||||
page: 1,
|
||||
rowsPerPage: 10,
|
||||
rowsNumber: 10,
|
||||
});
|
||||
|
||||
// eslint-disable-next-line
|
||||
async function modelOnRequest(props: any) {
|
||||
const { page, rowsPerPage, sortBy, descending } = props.pagination;
|
||||
const modelFilter = props.filter;
|
||||
|
||||
modelLoading.value = true;
|
||||
try {
|
||||
let response = await modelPageQuery({
|
||||
current: page,
|
||||
size: rowsPerPage,
|
||||
name: modelFilter.name,
|
||||
});
|
||||
const pageData = response;
|
||||
modelPagination.value.rowsNumber = pageData.total;
|
||||
modelPagination.value.page = page;
|
||||
modelPagination.value.rowsPerPage = rowsPerPage;
|
||||
modelPagination.value.sortBy = sortBy;
|
||||
modelPagination.value.descending = descending;
|
||||
modelRows.splice(0, modelRows.length, ...(pageData.records as []));
|
||||
} catch (err) {
|
||||
console.log(
|
||||
'🚀 ~ file: TrainModelManage.vue:441 ~ modelOnRequest ~ err:',
|
||||
err
|
||||
);
|
||||
const error = err as ApiError;
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: error.title,
|
||||
});
|
||||
} finally {
|
||||
modelLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
const modelCreateFormShow = ref(false);
|
||||
const modelForm = ref<QForm | null>(null);
|
||||
function modelOnCreate() {
|
||||
modelForm.value?.validate().then(async (res) => {
|
||||
if (res) {
|
||||
modelOperateDisabled.value = true;
|
||||
try {
|
||||
const params: ModelCreateParams = {
|
||||
name: modelEditInfo.name,
|
||||
};
|
||||
if (modelEditInfo.id) {
|
||||
await saveTrainModelData(+modelEditInfo.id, params);
|
||||
} else {
|
||||
await createTrainModel(params);
|
||||
}
|
||||
modelOnReset();
|
||||
modelCreateFormShow.value = false;
|
||||
modelTableRef.value.requestServerInteraction(); // 刷新列表
|
||||
} catch (err) {
|
||||
const error = err as ApiError;
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: error.title,
|
||||
});
|
||||
} finally {
|
||||
modelOperateDisabled.value = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function modelOnReset() {
|
||||
modelEditInfo.id = '';
|
||||
modelEditInfo.name = '';
|
||||
modelForm.value?.resetValidation();
|
||||
}
|
||||
|
||||
async function modelDeleteData(row: TrainModelItem) {
|
||||
modelOperateDisabled.value = true;
|
||||
$q.dialog({
|
||||
title: '确认',
|
||||
message: `确认删除列车型号 "${row.name}" 吗?`,
|
||||
cancel: true,
|
||||
})
|
||||
.onOk(async () => {
|
||||
try {
|
||||
await deleteTrainModel(row.id);
|
||||
modelTableRef.value.requestServerInteraction(); // 刷新列表
|
||||
} catch (err) {
|
||||
const error = err as ApiError;
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: error.title,
|
||||
});
|
||||
}
|
||||
})
|
||||
.onDismiss(() => {
|
||||
modelOperateDisabled.value = false;
|
||||
});
|
||||
}
|
||||
|
||||
const modelEditInfo = reactive({
|
||||
id: '',
|
||||
name: '',
|
||||
});
|
||||
function modelEditData(row: TrainModelItem) {
|
||||
getTrainModelInfo(row.id)
|
||||
.then((res: TrainModelItem) => {
|
||||
modelEditInfo.id = res.id + '';
|
||||
modelEditInfo.name = res.name;
|
||||
modelCreateFormShow.value = true;
|
||||
})
|
||||
.catch((err) => {
|
||||
const error = err as ApiError;
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: error.title,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 尺寸
|
||||
const sizeColumnDefs: QTableColumn[] = [
|
||||
{
|
||||
name: 'name',
|
||||
label: '名称',
|
||||
field: 'name',
|
||||
required: true,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
name: 'carriage_length',
|
||||
label: '车厢长度',
|
||||
field: 'carriage_length',
|
||||
required: true,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
name: 'total_length',
|
||||
label: '总长度',
|
||||
field: 'total_length',
|
||||
required: true,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
name: 'description',
|
||||
label: '描述',
|
||||
field: 'description',
|
||||
required: true,
|
||||
align: 'center',
|
||||
},
|
||||
{ name: 'operations', label: '操作', field: 'operations', align: 'center' },
|
||||
];
|
||||
|
||||
const sizeOperateDisabled = ref(false);
|
||||
const sizeTableRef = ref();
|
||||
const sizeRows = reactive([]);
|
||||
const sizeFilter = reactive({
|
||||
name: '',
|
||||
});
|
||||
const sizeLoading = ref(false);
|
||||
const sizePagination = ref({
|
||||
sortBy: 'desc',
|
||||
descending: false,
|
||||
page: 1,
|
||||
rowsPerPage: 10,
|
||||
rowsNumber: 10,
|
||||
});
|
||||
|
||||
// eslint-disable-next-line
|
||||
async function sizeOnRequest(props: any) {
|
||||
const { page, rowsPerPage, sortBy, descending } = props.pagination;
|
||||
const sizeFilter = props.filter;
|
||||
|
||||
sizeLoading.value = true;
|
||||
try {
|
||||
let response = await sizePageQuery({
|
||||
current: page,
|
||||
size: rowsPerPage,
|
||||
name: sizeFilter.name,
|
||||
});
|
||||
const pageData = response;
|
||||
sizePagination.value.rowsNumber = pageData.total;
|
||||
sizePagination.value.page = page;
|
||||
sizePagination.value.rowsPerPage = rowsPerPage;
|
||||
sizePagination.value.sortBy = sortBy;
|
||||
sizePagination.value.descending = descending;
|
||||
sizeRows.splice(0, sizeRows.length, ...(pageData.records as []));
|
||||
} catch (err) {
|
||||
const error = err as ApiError;
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: error.title,
|
||||
});
|
||||
} finally {
|
||||
sizeLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
const sizeCreateFormShow = ref(false);
|
||||
const sizeForm = ref<QForm | null>(null);
|
||||
function sizeOnCreate() {
|
||||
sizeForm.value?.validate().then(async (res) => {
|
||||
if (res) {
|
||||
sizeOperateDisabled.value = true;
|
||||
try {
|
||||
const params: SizeCreateParams = {
|
||||
name: sizeEditInfo.name,
|
||||
carriage_length: sizeEditInfo.carriage_length,
|
||||
description: sizeEditInfo.description,
|
||||
total_length: sizeEditInfo.total_length,
|
||||
};
|
||||
if (sizeEditInfo.id) {
|
||||
await saveTrainSizeData(+sizeEditInfo.id, params);
|
||||
} else {
|
||||
await createTrainSize(params);
|
||||
}
|
||||
sizeOnReset();
|
||||
sizeCreateFormShow.value = false;
|
||||
sizeTableRef.value.requestServerInteraction(); // 刷新列表
|
||||
} catch (err) {
|
||||
const error = err as ApiError;
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: error.title,
|
||||
});
|
||||
} finally {
|
||||
sizeOperateDisabled.value = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function sizeOnReset() {
|
||||
sizeEditInfo.id = '';
|
||||
sizeEditInfo.name = '';
|
||||
sizeEditInfo.carriage_length = 0;
|
||||
sizeEditInfo.description = '';
|
||||
sizeEditInfo.total_length = 0;
|
||||
sizeForm.value?.resetValidation();
|
||||
}
|
||||
|
||||
async function sizeDeleteData(row: TrainSizeItem) {
|
||||
sizeOperateDisabled.value = true;
|
||||
$q.dialog({
|
||||
title: '确认',
|
||||
message: `确认删除尺寸 "${row.name}" 吗?`,
|
||||
cancel: true,
|
||||
})
|
||||
.onOk(async () => {
|
||||
try {
|
||||
await deleteTrainSize(row.id);
|
||||
sizeTableRef.value.requestServerInteraction(); // 刷新列表
|
||||
} catch (err) {
|
||||
const error = err as ApiError;
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: error.title,
|
||||
});
|
||||
}
|
||||
})
|
||||
.onDismiss(() => {
|
||||
sizeOperateDisabled.value = false;
|
||||
});
|
||||
}
|
||||
|
||||
const sizeEditInfo = reactive({
|
||||
id: '',
|
||||
name: '',
|
||||
carriage_length: 0,
|
||||
description: '',
|
||||
total_length: 0,
|
||||
});
|
||||
function sizeEditData(row: TrainSizeItem) {
|
||||
getTrainSizeInfo(row.id)
|
||||
.then((res: TrainSizeItem) => {
|
||||
sizeEditInfo.id = res.id + '';
|
||||
sizeEditInfo.name = res.name;
|
||||
sizeEditInfo.carriage_length = res.carriage_length;
|
||||
sizeEditInfo.description = res.description;
|
||||
sizeEditInfo.total_length = res.total_length;
|
||||
sizeCreateFormShow.value = true;
|
||||
})
|
||||
.catch((err) => {
|
||||
const error = err as ApiError;
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: error.title,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const directionOptions = [
|
||||
{ label: '左侧', value: 'LEFT' },
|
||||
{ label: '右侧', value: 'RIGHT' },
|
||||
];
|
||||
function getDirectionName(val: string) {
|
||||
let n = '';
|
||||
if (val) {
|
||||
const find = directionOptions.find((item) => {
|
||||
return item.value == val;
|
||||
});
|
||||
n = find ? find.label : '';
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
// 轮径
|
||||
const wheelColumnDefs: QTableColumn[] = [
|
||||
{
|
||||
name: 'name',
|
||||
label: '名称',
|
||||
field: 'name',
|
||||
required: true,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
name: 'axial_position',
|
||||
label: '安装轴位',
|
||||
field: 'axial_position',
|
||||
required: true,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
name: 'diameter',
|
||||
label: '车轮直径(mm)',
|
||||
field: 'diameter',
|
||||
required: true,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
name: 'install_direction',
|
||||
label: '安装方向',
|
||||
field: (row) => {
|
||||
return getDirectionName(row.install_direction);
|
||||
},
|
||||
required: true,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
name: 'max_diameter',
|
||||
label: '车轮的最大直径(mm)',
|
||||
field: 'max_diameter',
|
||||
required: true,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
name: 'min_diameter',
|
||||
label: '车轮的最小直径(mm)',
|
||||
field: 'min_diameter',
|
||||
required: true,
|
||||
align: 'center',
|
||||
},
|
||||
{ name: 'operations', label: '操作', field: 'operations', align: 'center' },
|
||||
];
|
||||
|
||||
const wheelOperateDisabled = ref(false);
|
||||
const wheelTableRef = ref();
|
||||
const wheelRows = reactive([]);
|
||||
const wheelFilter = reactive({
|
||||
name: '',
|
||||
});
|
||||
const wheelLoading = ref(false);
|
||||
const wheelPagination = ref({
|
||||
sortBy: 'desc',
|
||||
descending: false,
|
||||
page: 1,
|
||||
rowsPerPage: 10,
|
||||
rowsNumber: 10,
|
||||
});
|
||||
|
||||
// eslint-disable-next-line
|
||||
async function wheelOnRequest(props: any) {
|
||||
const { page, rowsPerPage, sortBy, descending } = props.pagination;
|
||||
const wheelFilter = props.filter;
|
||||
|
||||
wheelLoading.value = true;
|
||||
try {
|
||||
let response = await wheelPageQuery({
|
||||
current: page,
|
||||
size: rowsPerPage,
|
||||
name: wheelFilter.name,
|
||||
});
|
||||
const pageData = response;
|
||||
wheelPagination.value.rowsNumber = pageData.total;
|
||||
wheelPagination.value.page = page;
|
||||
wheelPagination.value.rowsPerPage = rowsPerPage;
|
||||
wheelPagination.value.sortBy = sortBy;
|
||||
wheelPagination.value.descending = descending;
|
||||
wheelRows.splice(0, wheelRows.length, ...(pageData.records as []));
|
||||
} catch (err) {
|
||||
const error = err as ApiError;
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: error.title,
|
||||
});
|
||||
} finally {
|
||||
wheelLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
const wheelCreateFormShow = ref(false);
|
||||
const wheelForm = ref<QForm | null>(null);
|
||||
function wheelOnCreate() {
|
||||
wheelForm.value?.validate().then(async (res) => {
|
||||
if (res) {
|
||||
wheelOperateDisabled.value = true;
|
||||
try {
|
||||
const params: WheelCreateParams = {
|
||||
name: wheelEditInfo.name,
|
||||
axial_position: wheelEditInfo.axial_position,
|
||||
diameter: wheelEditInfo.diameter,
|
||||
install_direction: wheelEditInfo.install_direction,
|
||||
max_diameter: wheelEditInfo.max_diameter,
|
||||
min_diameter: wheelEditInfo.min_diameter,
|
||||
};
|
||||
if (wheelEditInfo.id) {
|
||||
await saveTrainWheelData(+wheelEditInfo.id, params);
|
||||
} else {
|
||||
await createTrainWheel(params);
|
||||
}
|
||||
wheelOnReset();
|
||||
wheelCreateFormShow.value = false;
|
||||
wheelTableRef.value.requestServerInteraction(); // 刷新列表
|
||||
} catch (err) {
|
||||
const error = err as ApiError;
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: error.title,
|
||||
});
|
||||
} finally {
|
||||
wheelOperateDisabled.value = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function wheelOnReset() {
|
||||
wheelEditInfo.id = '';
|
||||
wheelEditInfo.name = '';
|
||||
wheelEditInfo.axial_position = 0;
|
||||
wheelEditInfo.diameter = 0;
|
||||
wheelEditInfo.install_direction = '';
|
||||
wheelEditInfo.max_diameter = 0;
|
||||
wheelEditInfo.min_diameter = 0;
|
||||
wheelForm.value?.resetValidation();
|
||||
}
|
||||
|
||||
async function wheelDeleteData(row: TrainWheelItem) {
|
||||
wheelOperateDisabled.value = true;
|
||||
$q.dialog({
|
||||
title: '确认',
|
||||
message: `确认删除轮径 "${row.name}" 吗?`,
|
||||
cancel: true,
|
||||
})
|
||||
.onOk(async () => {
|
||||
try {
|
||||
await deleteTrainWheel(row.id);
|
||||
wheelTableRef.value.requestServerInteraction(); // 刷新列表
|
||||
} catch (err) {
|
||||
const error = err as ApiError;
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: error.title,
|
||||
});
|
||||
}
|
||||
})
|
||||
.onDismiss(() => {
|
||||
wheelOperateDisabled.value = false;
|
||||
});
|
||||
}
|
||||
|
||||
const wheelEditInfo = reactive({
|
||||
id: '',
|
||||
name: '',
|
||||
axial_position: 0,
|
||||
diameter: 0,
|
||||
install_direction: '',
|
||||
max_diameter: 0,
|
||||
min_diameter: 0,
|
||||
});
|
||||
function wheelEditData(row: TrainWheelItem) {
|
||||
getTrainWheelInfo(row.id)
|
||||
.then((res: TrainWheelItem) => {
|
||||
wheelEditInfo.id = res.id + '';
|
||||
wheelEditInfo.name = res.name;
|
||||
wheelEditInfo.axial_position = res.axial_position;
|
||||
wheelEditInfo.diameter = res.diameter;
|
||||
wheelEditInfo.install_direction = res.install_direction;
|
||||
wheelEditInfo.max_diameter = res.max_diameter;
|
||||
wheelEditInfo.min_diameter = res.min_diameter;
|
||||
wheelCreateFormShow.value = true;
|
||||
})
|
||||
.catch((err) => {
|
||||
const error = err as ApiError;
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: error.title,
|
||||
});
|
||||
});
|
||||
}
|
||||
</script>
|
@ -44,6 +44,11 @@ const routes: RouteRecordRaw[] = [
|
||||
name: 'categoryInfo',
|
||||
component: () => import('pages/CategoryManage.vue'),
|
||||
},
|
||||
{
|
||||
path: 'trainModel',
|
||||
name: 'trainModel',
|
||||
component: () => import('pages/TrainModelManage.vue'),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user