Ver código fonte

update

docs_0727
lb 1 ano atrás
pai
commit
4a6f395119
2 arquivos alterados com 37 adições e 2 exclusões
  1. +28
    -2
      src/components/DialogJustForm.vue
  2. +9
    -0
      src/views/modules/pms/palletizingLine/config.js

+ 28
- 2
src/components/DialogJustForm.vue Ver arquivo

@@ -21,6 +21,8 @@
<!-- 通过多个 col === null 可以控制更灵活的 span 大小 -->
<el-form-item v-if="col !== null" :label="col.label" :prop="col.prop" :rules="col.rules || null">
<el-input v-if="col.input" v-model="dataForm[col.prop]" clearable :disabled="detailMode" v-bind="col.elparams" />
<el-input v-if="col.forceDisabled && col.eraseOnSubmit" v-model="shadowDataForm[col.prop]" disabled v-bind="col.elparams" />
<el-input v-if="col.forceDisabled && !col.eraseOnSubmit" v-model="dataForm[col.prop]" disabled v-bind="col.elparams" />
<el-cascader
v-if="col.cascader"
v-model="dataForm[col.prop]"
@@ -130,10 +132,17 @@ export default {
inject: ["urls"],
data() {
const dataForm = {};
const shadowDataForm = {};
const savedDatalist = {};

this.configs.form.rows.forEach((row) => {
row.forEach((col) => {
if (col.prop) dataForm[col.prop] = col.default ?? null;
if (!col.eraseOnSubmit && col.prop) dataForm[col.prop] = col.default ?? null;
else shadowDataForm[col.prop] = col.default ?? null;

if ("autoUpdateProp" in col) {
savedDatalist[col.prop] = [];
}

if (col.fetchData)
col.fetchData().then(({ data: res }) => {
@@ -148,6 +157,10 @@ export default {
value: col.optionValue ? i[col.optionValue] : i.id,
}))
);

if ("autoUpdateProp" in col) {
this.$set(savedDatalist, col.prop, res.data.list);
}
} else if (Array.isArray(res.data)) {
this.$set(
col,
@@ -157,6 +170,9 @@ export default {
value: col.optionValue ? i[col.optionValue] : i.id,
}))
);
if ("autoUpdateProp" in col) {
this.$set(savedDatalist, col.prop, res.data);
}
}
// col.options = res.data.list;
} else {
@@ -184,6 +200,8 @@ export default {
return {
loadingStatus: false,
dataForm,
shadowDataForm,
savedDatalist,
detailMode: false,
baseDialogConfig: null,
defaultQuillConfig: {
@@ -258,6 +276,9 @@ export default {
if (excludeId && key === "id") return;
this.dataForm[key] = null;
});
Object.keys(this.shadowDataForm).forEach((key) => {
this.shadowDataForm[key] = null;
});
console.log("[DialogJustForm resetForm()] clearing form...");
this.$refs.dataForm.clearValidate();
this.$emit("dialog-closed"); // 触发父组件销毁自己
@@ -332,7 +353,12 @@ export default {

/** handlers */
handleSelectChange(col, eventValue) {
// console.log("[dialog] select change: ", col, eventValue);
if ("autoUpdateProp" in col) {
// 自动更新 相关联 的字段
// console.log(col.options, eventValue, this.savedDatalist);
const item = this.savedDatalist[col.prop].find(item => item.id === eventValue)
this.shadowDataForm[col.autoUpdateProp] = item.cate ?? null
}
this.$forceUpdate();
},



+ 9
- 0
src/views/modules/pms/palletizingLine/config.js Ver arquivo

@@ -141,8 +141,17 @@ export default function () {
label: "订单号",
options: [],
fetchData: () => this.$http.post('/pms/order/pageCom', { limit: 999, page: 1, code: '', type: 1 }),
optionLabel: 'code',
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { filterable: true, placeholder: "请选择订单" },
autoUpdateProp: 'cate' // 改变时自动更新 cate 字段
},
{
forceDisabled: true,
prop: 'cate',
label: '订单子号',
elparams: {},
eraseOnSubmit: true
},
{
input: true,


Carregando…
Cancelar
Salvar