Browse Source

修复车辆编辑回显问题

dev-xx
qb 7 months ago
parent
commit
fd7f662f58
  1. 25
      src/views/basicdata/vehicle/basicdataVehicleAddForm.vue

25
src/views/basicdata/vehicle/basicdataVehicleAddForm.vue

@ -136,7 +136,7 @@
<!-- 底部控件 -->
<div class="footer_container">
<el-button icon="CircleClose"> </el-button>
<el-button icon="CircleClose" @click="back"> </el-button>
<el-button type="primary" icon="Position" @click="handleSubmit"> </el-button>
</div>
</div>
@ -623,7 +623,7 @@ const initData = async () => {
console.log(' details.form :>> ', details.form);
if (details.pageInfo.type === 'add') return;
//
const res = await getDetail(details.pageInfo.id);
const { code, data } = res.data;
if (code !== 200) return;
@ -633,15 +633,21 @@ const initData = async () => {
const value = details.carBasicForm[i];
if (value.type === 3 && value.multiple) {
details.form[value.prop] = details.form[value.prop]
? details.form[value.prop].split(',')
: [];
details.form[value.prop] = data[value.prop] ? data[value.prop].split(',') : [];
continue;
}
if (value.type === 2) {
let _num = Number(data[value.prop]);
details.form[value.prop] = isNumber(_num) ? _num : 0;
continue;
}
details.form[value.prop] = data[value.prop] || '';
}
console.log('details.form :>> ', details.form);
for (let i = 0; i < details.imgArr.length; i++) {
const value = details.imgArr[i];
@ -708,6 +714,11 @@ const handleEmpty = item => {
.catch(() => {});
};
/** 返回 */
const back = () => {
$router.back();
};
/** 提交 */
const handleSubmit = async () => {
try {
@ -745,8 +756,10 @@ const handleSubmit = async () => {
details.pageInfo.id && (submitData.id = details.pageInfo.id);
const res = details.pageInfo.type === 'add' ? await add(submitData) : await update(submitData);
const { code, data } = res.data;
const { code, data, msg } = res.data;
if (code !== 200) return;
ElMessage.success(msg);
back();
console.log('details.form :>> ', details.form);
console.log('_flag :>> ', _flag);
} catch (error) {

Loading…
Cancel
Save