update 物料的添加子类逻辑

このコミットが含まれているのは:
lb 2023-02-17 17:03:12 +08:00
コミット 20806b355d
3個のファイルの変更106行の追加59行の削除

ファイルの表示

@ -112,6 +112,19 @@ export default {
this.configs.form.rows.forEach((row) => { this.configs.form.rows.forEach((row) => {
row.forEach((col) => { row.forEach((col) => {
dataForm[col.prop] = col.default ?? null; dataForm[col.prop] = col.default ?? null;
if (col.fetchData)
col.fetchData().then(({ data: res }) => {
if (res.code === 0 && res.data.list) {
this.$set(
col,
"options",
res.data.list.map((i) => ({ label: i.name, value: i.id }))
);
} else {
col.options.splice(0);
}
});
}); });
}); });
return { return {

ファイルの表示

@ -57,6 +57,7 @@ import DialogJustForm from "./DialogJustForm.vue";
const DIALOG_WITH_MENU = "DialogWithMenu"; const DIALOG_WITH_MENU = "DialogWithMenu";
const DIALOG_JUST_FORM = "DialogJustForm"; const DIALOG_JUST_FORM = "DialogJustForm";
const dictList = JSON.parse(localStorage.getItem("dictList"));
export default { export default {
name: "ListViewWithHead", name: "ListViewWithHead",
@ -109,24 +110,63 @@ export default {
[ [
{ {
input: true, input: true,
label: "料名称", label: "料名称",
prop: "name", prop: "name",
rules: { required: true, message: "必填项不能为空", trigger: "blur" }, rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请输入物料名称" }, elparams: { placeholder: "请输入原料名称" },
},
{
input: true,
label: "原料编码",
prop: "code",
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请输入原料编码" },
},
{
select: true,
label: "单位",
prop: "unitDictValue",
options: dictList["unit"].map((u) => ({ label: u.dictLabel, value: u.dictValue })),
elparams: { placeholder: "单位" },
}, },
], ],
[ [
{ {
input: true, select: true,
label: "物料编码", label: "原料类型",
prop: "code", prop: "typeId",
rules: { required: true, message: "必填项不能为空", trigger: "blur" }, rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请输入物料编码" }, options: [],
fetchData: () => this.$http.get("/pms/materialType/page", { params: { page: 1, limit: 999 } }),
elparams: { placeholder: "请输入原料类型" },
// autoDisabled: true, // disabled
}, },
{
select: true,
label: "原料类别",
prop: "typeDictValue",
options: dictList["material_category"].map((u) => ({ label: u.dictLabel, value: u.dictValue })),
elparams: { placeholder: "原料类别" },
// autoDisabled: true
},
{ input: true, label: "堆积密度(g/cm³)", prop: "density", elparams: { placeholder: "堆积密度" } },
], ],
[{ input: true, label: "规格", prop: "description", elparams: { placeholder: "规格" } }], [
[{ input: true, label: "备注", prop: "remark", elparams: { placeholder: "备注" } }], {
[{ input: true, prop: "parentId", elparams: { type: "hidden" }, hidden: true }], input: true,
label: "英文名称",
prop: "enName",
elparams: { placeholder: "请输入英文名称" },
},
{
input: true,
label: "缩写",
prop: "enAb",
elparams: { placeholder: "请输入缩写" },
},
{ input: true, label: "原料描述", prop: "description", elparams: { placeholder: "原料描述" } },
],
[{ input: true, label: "中文描述", prop: "remark", elparams: { placeholder: "备注" } }],
], ],
operations: [ operations: [
{ name: "add", label: "保存", type: "primary", permission: "pms:material:save", showOnEdit: false }, { name: "add", label: "保存", type: "primary", permission: "pms:material:save", showOnEdit: false },
@ -197,7 +237,7 @@ export default {
// page : // page :
if ("list" in res.data) { if ("list" in res.data) {
// real env: // real env:
this.dataList = res.data.list.map((_) => ({ ..._, hasChildren: Array.isArray(_.children) && _.children.length > 0 ? true : false })); this.dataList = res.data.list;
// this.dataList = res.data.records; // this.dataList = res.data.records;
this.totalPage = res.data.total; this.totalPage = res.data.total;

ファイルの表示

@ -7,10 +7,10 @@ export default function () {
const tableProps = [ const tableProps = [
{ type: 'index', label: '序号' }, { type: 'index', label: '序号' },
{ prop: "createTime", label: "添加时间", filter: timeFilter }, { prop: "createTime", label: "添加时间", filter: timeFilter },
{ prop: "name", label: "料名称" }, { prop: "name", label: "料名称" },
{ prop: "code", label: "料编码" }, { prop: "code", label: "料编码" },
{ prop: "typeDictValue", label: "类别", filter: dictFilter("material_category") }, // subcomponent: {/** TODO: create a new component for this option */} }, { prop: "typeDictValue", label: "类别", filter: dictFilter("material_category") }, // subcomponent: {/** TODO: create a new component for this option */} },
{ prop: "type", label: "料类型" }, { prop: "type", label: "料类型" },
{ prop: "enName", label: "英文名称" }, { prop: "enName", label: "英文名称" },
{ prop: "enAb", label: "英文缩写" }, { prop: "enAb", label: "英文缩写" },
{ prop: "density", label: "堆积密度" }, { prop: "density", label: "堆积密度" },
@ -30,11 +30,11 @@ export default function () {
const headFormFields = [ const headFormFields = [
{ {
label: "料名称/编码", label: "料名称/编码",
prop: "key", prop: "key",
input: true, input: true,
default: { value: "" }, default: { value: "" },
bind: { placeholder: "请输入料名称或编码" }, bind: { placeholder: "请输入料名称或编码" },
}, },
{ {
button: { button: {
@ -62,8 +62,8 @@ export default function () {
const dictList = JSON.parse(localStorage.getItem("dictList")); const dictList = JSON.parse(localStorage.getItem("dictList"));
const dialogConfigs = { const dialogConfigs = {
menu: [ menu: [
{ name: "料信息", key: "info" }, { name: "料信息", key: "info" },
{ name: "料属性信息", key: "attr", onlyEditMode: true }, { name: "料属性信息", key: "attr", onlyEditMode: true },
// { name: "添加子类", key: "add-sub", onlyEditMode: true }, // { name: "添加子类", key: "add-sub", onlyEditMode: true },
], ],
form: { form: {
@ -71,59 +71,64 @@ export default function () {
[ [
{ {
input: true, input: true,
label: "料名称", label: "料名称",
prop: "name", prop: "name",
rules: { required: true, message: "必填项不能为空", trigger: "blur" }, rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请输入料名称" }, elparams: { placeholder: "请输入料名称" },
}, },
{ {
input: true, input: true,
label: "料编码", label: "料编码",
prop: "code", prop: "code",
rules: { required: true, message: "必填项不能为空", trigger: "blur" }, rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请输入物料编码" }, elparams: { placeholder: "请输入原料编码" },
},
{ input: true, label: "堆积密度(g/cm³)", prop: "density", elparams: { placeholder: "堆积密度" } },
],
[
{
cascader: true,
label: "父级物料",
prop: "parentId",
// TODO: 待解决DialogWithMenu 中设置default只在初始化的时候有效一旦清空过就无效了
// default: '0',
// rules: { required: true, message: "必填项不能为空", trigger: "blur" },
options: [{ id: '0', name: '无' }], // 手动注入额外选项,用到的场景不多...
fetchData: () => this.$http.get('/pms/material/page', { params: { page: 1, limit: 999, key: '' } }),
elparams: { placeholder: "请选择父级物料", filterable: true, clearable: true },
// fetchTreeData: () => {
// // TODO前提是工厂里总的设备类型数不会超过 999
// return this.$http.get('/pms/material/tree', {
// params: { rootId: '0' }
// })
// },
// elparams: { placeholder: "请选择父级物料", 'show-all-levels': false, props: { checkStrictly: true } },
}, },
{ {
select: true, select: true,
label: "物料类型", label: "单位",
prop: "unitDictValue",
options: dictList["unit"].map((u) => ({ label: u.dictLabel, value: u.dictValue })),
elparams: { placeholder: "单位" },
},
],
[
// {
// cascader: true,
// label: "父级原料",
// prop: "parentId",
// // TODO: 待解决DialogWithMenu 中设置default只在初始化的时候有效一旦清空过就无效了
// // default: '0',
// // rules: { required: true, message: "必填项不能为空", trigger: "blur" },
// options: [{ id: '0', name: '无' }], // 手动注入额外选项,用到的场景不多...
// fetchData: () => this.$http.get('/pms/material/page', { params: { page: 1, limit: 999, key: '' } }),
// elparams: { placeholder: "请选择父级原料", filterable: true, clearable: true },
// // fetchTreeData: () => {
// // // TODO前提是工厂里总的设备类型数不会超过 999
// // return this.$http.get('/pms/material/tree', {
// // params: { rootId: '0' }
// // })
// // },
// // elparams: { placeholder: "请选择父级原料", 'show-all-levels': false, props: { checkStrictly: true } },
// },
{
select: true,
label: "原料类型",
prop: "typeId", prop: "typeId",
rules: { required: true, message: "必填项不能为空", trigger: "blur" }, rules: { required: true, message: "必填项不能为空", trigger: "blur" },
options: [], options: [],
fetchData: () => this.$http.get('/pms/materialType/page', { params: { page: 1, limit: 999 } }), fetchData: () => this.$http.get('/pms/materialType/page', { params: { page: 1, limit: 999 } }),
elparams: { placeholder: "请输入物料类型" }, elparams: { placeholder: "请输入料类型" },
// autoDisabled: true, // 有某个条件触发后,自动变成 disabled 状态 // autoDisabled: true, // 有某个条件触发后,自动变成 disabled 状态
}, },
{ {
select: true, select: true,
label: "物料类别", label: "料类别",
prop: "typeDictValue", prop: "typeDictValue",
options: dictList["material_category"].map((u) => ({ label: u.dictLabel, value: u.dictValue })), options: dictList["material_category"].map((u) => ({ label: u.dictLabel, value: u.dictValue })),
elparams: { placeholder: "物料类别" }, elparams: { placeholder: "料类别" },
// autoDisabled: true // autoDisabled: true
}, },
{ input: true, label: "堆积密度(g/cm³)", prop: "density", elparams: { placeholder: "堆积密度" } },
// { // {
// input: true, // input: true,
// label: "设备类型", // label: "设备类型",
@ -133,14 +138,6 @@ export default function () {
// }, // },
], ],
[ [
{
select: true,
label: "单位",
prop: "unitDictValue",
options: dictList["unit"].map((u) => ({ label: u.dictLabel, value: u.dictValue })),
elparams: { placeholder: "单位" },
},
{ {
input: true, input: true,
label: "英文名称", label: "英文名称",
@ -153,9 +150,6 @@ export default function () {
prop: "enAb", prop: "enAb",
elparams: { placeholder: "请输入缩写" }, elparams: { placeholder: "请输入缩写" },
}, },
],
[
{ input: true, label: "原料描述", prop: "description", elparams: { placeholder: "原料描述" } }, { input: true, label: "原料描述", prop: "description", elparams: { placeholder: "原料描述" } },
], ],
[{ input: true, label: "中文描述", prop: "remark", elparams: { placeholder: "备注" } }], [{ input: true, label: "中文描述", prop: "remark", elparams: { placeholder: "备注" } }],