修改车辆类型新增模态框

master
夜笙歌 2 years ago
parent 7ea793908b
commit 605f212130

@ -67,13 +67,13 @@
<!-- 表格主体-->
<el-table v-loading="loading" :data="postList" @selection-change="handleSelectionChange">
<el-table-column :label="t('baseCar.carType.title')" align="center" prop="title" width="150"/>
<el-table-column :label="t('baseCar.carType.title')" align="center" prop="title"/>
<el-table-column :label="t('baseCar.carType.state')" align="center" prop="state"
width="150"/>
<el-table-column :label="t('baseCar.carType.axleTotal')" align="center" prop="axleTotal"
width="150"/>
<el-table-column :label="t('common.createTime')" align="center" prop="createTime" width="160"/>
<el-table-column :label="t('common.createBy')" align="center" prop="createBy" width="150"/>
<el-table-column :label="t('common.createTime')" align="center" prop="createTime"/>
<el-table-column :label="t('common.createBy')" align="center" prop="createBy"/>
<el-table-column :label="t('option.option')" align="center" class-name="small-padding fixed-width" fixed="right"
width="160">
<template #default="scope">
@ -108,8 +108,8 @@
<el-dialog v-model="open" :title="title" append-to-body width="80vw">
<el-form ref="postRef" :inline="true" :label-width=" locale ? '100px':'140px'" :model="form"
:rules="rules">
<el-form-item label="轮胎排数" prop="param1">
<el-select v-model="form.param1" placeholder="Select" size="large" @change="TireRowChange">
<el-form-item label="轮胎排数" prop="axleTotal">
<el-select v-model="form.axleTotal" placeholder="Select" size="large" @change="TireRowChange">
<el-option
v-for="item in TireRow"
:key="item.value"
@ -118,8 +118,8 @@
/>
</el-select>
</el-form-item>
<el-form-item label="是否启用" prop="param2">
<el-switch v-model="form.param2"/>
<el-form-item label="是否启用" prop="state">
<el-switch v-model="form.state"/>
</el-form-item>
</el-form>
<div style="width: 100%;text-align: center;height: 50px;line-height: 50px">轮胎布局图</div>
@ -140,14 +140,14 @@
<div style="width: 100%;height: 80px;background-color: #eee">
<div
v-for="(item,index) in TireRowInfo"
:style='"width:calc((80vw - 40px)/"+TireRowInfo.length+" );padding:20px;display:inline-block;text-align:center"'>
:style='"width:calc((80vw - 40px)/"+TireRowInfo.length+" );padding:4px 20px;display:inline-block;text-align:center"'>
<img alt="" src="@/assets/images/tyre.png">
</div>
</div>
<div style="width: 100%;height: auto;background-color: #eee">
<div
v-for="(item,index) in TireRowInfo"
:style='"width:calc((80vw - 40px)/"+TireRowInfo.length+" );padding:20px;display:inline-block;text-align:center"'>
:style='"width:calc((80vw - 40px)/"+TireRowInfo.length+" );padding:4px 20px;display:inline-block;text-align:center"'>
<img v-if="TireRowInfo[index] === 2" alt="" src="@/assets/images/tyre.png">
</div>
</div>
@ -254,7 +254,7 @@ const TireRowOptions = [
const TireRowChange = () => {
let arr = []
arr.length = form.value.param1
arr.length = form.value.axleTotal
arr.fill(1)
TireRowInfo.value = arr
}
@ -284,7 +284,7 @@ const queryParams = ref({
//
const rules = {
param1: [{required: true, message: "请选择轮胎排数", trigger: "blur"}],
axleTotal: [{required: true, message: "请选择轮胎排数", trigger: "blur"}],
type: [{required: true, message: "轮胎型号不能为空", trigger: "blur"}],
serialNumber: [{required: true, message: "轮胎编号不能为空", trigger: "blur"}],
depth: [{required: true, message: "花纹深度不能为空", trigger: "blur"}],
@ -293,8 +293,8 @@ const rules = {
//
const form = ref({
id: null,
param1: 2,
param2: false,
axleTotal: 2,
state: false,
});
/** 查询岗位列表 */
@ -318,8 +318,8 @@ function cancel() {
function reset() {
form.value = {
id: null,
param1: 2,
param2: false,
axleTotal: 2,
state: false,
};
TireRowInfo.value = [1, 1]
proxy.resetForm("postRef");
@ -356,7 +356,15 @@ function handleUpdate(row) {
reset();
const postId = row.id || ids.value;
getCartype(postId).then(response => {
form.value = response.data;
let params = response.data
params.state === 1 ? params.state = true : params.state = false
let TireRow = params.title?.split('T')[1]?.split('|').filter(e => e !== '') || []
let title = []
TireRow.forEach((res) => {
title.push(parseInt(res.split('-')[1]))
})
TireRowInfo.value = title
form.value = params;
open.value = true;
title.value = t('baseCar.carType.editTitle');
});
@ -364,29 +372,28 @@ function handleUpdate(row) {
/** 提交按钮 */
function submitForm() {
let TireRowInfoStr = TireRowInfo.value.map((e, index) => {
let title = (2 * TireRowInfo.value.reduce((a, b) => a + b)) + 'T' + TireRowInfo.value.map((e, index) => {
return `${index + 1}-${e}|`
}).join('')
console.log(TireRowInfoStr)
let params = {...form.value, TireRowInfoStr}
console.log(params)
// proxy.$refs["postRef"].validate(valid => {
// if (valid) {
// if (form.value.id != undefined) {
// updateCartype(form.value).then(response => {
// proxy.$modal.msgSuccess(t('option.modificationSuccessful'));
// open.value = false;
// getList();
// });
// } else {
// addCartype(form.value).then(response => {
// proxy.$modal.msgSuccess(t('option.addedSuccessfully'));
// open.value = false;
// getList();
// });
// }
// }
// });
form.value.state ? form.value.state = 1 : form.value.state = 0
let params = {...form.value, title}
proxy.$refs["postRef"].validate(valid => {
if (valid) {
if (form.value.id != undefined) {
updateCartype(params).then(response => {
proxy.$modal.msgSuccess(t('option.modificationSuccessful'));
open.value = false;
getList();
});
} else {
addCartype(params).then(response => {
proxy.$modal.msgSuccess(t('option.addedSuccessfully'));
open.value = false;
getList();
});
}
}
});
}
/** 删除按钮操作 */

@ -31,8 +31,8 @@ export default defineConfig(({mode, command}) => {
proxy: {
// https://cn.vitejs.dev/config/#server-proxy
'/dev-api': {
target: 'http://10.11.41.249:8080',
// target: 'http://localhost:8080',
// target: 'http://10.11.41.249:8080',
target: 'http://localhost:8080',
changeOrigin: true,
rewrite: (p) => p.replace(/^\/dev-api/, '')
}

Loading…
Cancel
Save