update 物料

This commit is contained in:
lb
2023-02-06 14:24:12 +08:00
parent 6b292d9a47
commit f568f2056a
4 changed files with 267 additions and 82 deletions

View File

@@ -46,8 +46,8 @@
'el-icon-s-data': tab.key === 'attr',
'el-icon-folder-opened': tab.key === 'attachment',
}"
></i
> {{ tab.name }}
></i>
{{ tab.name }}
</span>
<div v-if="tab.key === 'info'">
@@ -56,12 +56,12 @@
<el-row v-for="(row, rowIndex) in configs.form.rows" :key="'row_' + rowIndex" :gutter="20">
<el-col v-for="(col, colIndex) in row" :key="colIndex" :span="24 / row.length">
<el-form-item :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.input" v-model="dataForm[col.prop]" clearable :disabled="disableCondition(col.prop)" v-bind="col.elparams" />
<el-select
v-if="col.select"
v-model="dataForm[col.prop]"
clearable
:disabled="detailMode"
:disabled="disableCondition(col.prop)"
v-bind="col.elparams"
@change="handleSelectChange(col, $event)"
>
@@ -73,9 +73,15 @@
:active-value="1"
:inactive-value="0"
@change="handleSwitchChange"
:disabled="detailMode"
:disabled="disableCondition(col.prop)"
/>
<el-input
v-if="col.textarea"
type="textarea"
v-model="dataForm[col.prop]"
:disabled="disableCondition(col.prop)"
v-bind="col.elparams"
/>
<el-input v-if="col.textarea" type="textarea" v-model="dataForm[col.prop]" :disabled="detailMode" v-bind="col.elparams" />
<!-- add more... -->
</el-form-item>
</el-col>
@@ -134,22 +140,33 @@ export default {
inject: ["urls"],
data() {
const dataForm = {};
const autoDisabledList = [];
this.configs.form.rows.forEach((row) => {
row.forEach((col) => {
if (col.upload) dataForm[col.prop] = col.default ?? [];
else dataForm[col.prop] = col.default ?? null;
if (col.autoDisabled) autoDisabledList.push(col.prop);
if (col.fetchData)
col.fetchData().then(({ data: res }) => {
console.log("[Fetch Data]", res.data.list);
if (res.code === 0 && res.data.list) {
this.$set(
col,
"options",
res.data.list.map((i) => ({ label: i.name, value: i.id }))
);
if (!col.options || !col.options.length)
this.$set(
col,
"options",
res.data.list.map((i) => ({ label: i.name, value: i.id }))
);
// col.options = res.data.list;
else if (col.options.length) {
res.data.list.unshift(...col.options);
this.$set(
col,
"options",
res.data.list.map((i) => ({ label: i.name, value: i.id }))
);
}
} else {
col.options.splice(0);
}
@@ -184,11 +201,12 @@ export default {
activeMenu: this.configs.menu[0].name,
dataForm,
detailMode: false,
autoDisabledList,
showBaseDialog: false,
baseDialogConfig: null,
subList: [],
showSubDialog: false,
disableXXX: false,
};
},
computed: {
@@ -204,7 +222,29 @@ export default {
return this.detailMode ? this.configs.table.props.filter((v) => v.prop !== "operations") : this.configs.table.props;
},
},
watch: {
// "dataForm.parentId": function (val, old) {
// if (val && val !== "0") {
// // 如果不是 '无' 选项,就锁定 typeDictValue(物料类别),和 typeId(物料类型)
// this.$http.get(`/pms/material/${val}`).then(({ data: res }) => {
// if (res.code === 0) {
// const { typeDictValue, typeId } = res.data;
// this.dataForm.typeDictValue = typeDictValue;
// this.dataForm.typeId = typeId;
// this.disableXXX = true;
// }
// });
// } else {
// this.dataForm.typeDictValue = null;
// this.dataForm.typeId = null;
// this.disableXXX = false;
// }
// },
},
methods: {
disableCondition(prop) {
return this.detailMode || (this.disableXXX && this.autoDisabledList.indexOf(prop) !== -1);
},
/** utitilities */
showButton(operate) {
const notDetailMode = !this.detailMode;