修改车辆类型新增模态框

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

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

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

Loading…
Cancel
Save