使用dd下拉框,无法给code赋值的问题

本文解决了一个在使用dd下拉时,无法给code字段赋值的问题。关键在于避免在datatype模型中为字段设定默认值。通过移除defaultValue的设置,问题得以解决。

使用dd下拉,无法给code赋值的问题

在datatype模型中,不要给字段赋予默认的值。

解决办法:

去除datatype中defaultValue的设置

/** * 新增修改库存管理页面 * * @author gucw * @date 2025-06-09 */ <template> <div> <dialog-edit :visible.sync="open" :title="title" @close="handleCancel" dialogType="dialog_edit" width="800px" height="600px" > <div slot="content" class="dialog_content"> <formlist :form="form" :form2="form2" ref="formList" @submit="formListSubmit" :readonly="false" :width="`120px`" ></formlist> <div slot="footer" class="dialog_footer"> <e-submit :option="{ name: '确定', submit: formListSubmit, }" ></e-submit> <el-button @click="handleCancel">取 消</el-button> </div> </div> </dialog-edit> </div> </template> <script> import { addCmmsInventoryManagement, updateCmmsInventoryManagement, } from "@/api/cmmsInventoryManagement/cmmsInventoryManagement.js"; export default { data() { return { form: [ { arr: [ { code: "equipmentCategory", title: "设备大类", type: 1, readlyOnly: false, verification: true, rule: "0", customTips: " ", regular: " ", dictionary: "", multiple: false, fileNum: 0, single: true, dateType: "date", dateFormat: "yyyy-MM-dd", }, { code: "equipmentSubcategory", title: "设备小类", type: 1, readlyOnly: false, verification: true, rule: "0", customTips: " ", regular: " ", dictionary: "", multiple: false, fileNum: 0, single: true, dateType: "date", dateFormat: "yyyy-MM-dd", }, { code: "specificationModel", title: "规格型号", type: 1, readlyOnly: false, verification: true, rule: "0", customTips: " ", regular: " ", dictionary: "", multiple: false, fileNum: 0, single: true, dateType: "date", dateFormat: "yyyy-MM-dd", }, { code: "quantity", title: "设备数量", type: 0, readlyOnly: false, verification: true, rule: "0", customTips: " ", regular: " ", dictionary: "", multiple: false, fileNum: 0, single: true, dateType: "date", dateFormat: "yyyy-MM-dd", }, { code: "alarmThreshold", title: "告警阈值", type: 0, readlyOnly: false, verification: true, rule: "0", customTips: " ", regular: " ", dictionary: "", multiple: false, fileNum: 0, single: true, dateType: "date", dateFormat: "yyyy-MM-dd", }, { code: "hasAlarm", title: "是否存在告警信息(0-否,1-是)", type: 0, readlyOnly: false, verification: true, rule: "0", customTips: " ", regular: " ", dictionary: "", multiple: false, fileNum: 0, single: true, dateType: "date", dateFormat: "yyyy-MM-dd", }, { code: "remarks", title: "备注", type: 0, readlyOnly: false, verification: true, rule: "0", customTips: " ", regular: " ", dictionary: "", multiple: false, fileNum: 0, single: true, dateType: "date", dateFormat: "yyyy-MM-dd", }, ], }, ], form2: {}, open: false, }; }, methods: { init(row) { this.open = true; this.form2 = {}; this.title = "新增库存管理"; if (row && row.id) { this.title = "修改库存管理"; this.form2 = row; } }, // 表单提交的时候 async formListSubmit() { await this.$refs.formList.submit(); await this.submission(); }, submission() { let params = JSON.parse(JSON.stringify(this.form2)); if (this.form2.id) { updateCmmsInventoryManagement(params).then((res) => { if (res.data.code == 0) { this.$emit("refreshDataList"); this.open = false; this.$message.success("修改成功"); } else { this.$message.error(res.data.msg); } }); } else { addCmmsInventoryManagement(params).then((res) => { if (res.data.code == 0) { this.$emit("refreshDataList"); this.open = false; this.$message.success("新增成功"); } else { this.$message.error(res.data.msg); } }); } }, // 关闭弹框 handleCancel() { this.$emit("refreshDataList"); this.open = false; }, }, }; </script> 这个也新增的时候字典没回显
最新发布
06-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值