Bladeren bron

update 物料的添加子类逻辑

docs_0727
lb 1 jaar geleden
bovenliggende
commit
20806b355d
3 gewijzigde bestanden met toevoegingen van 104 en 57 verwijderingen
  1. +13
    -0
      src/views/modules/pms/material/components/DialogJustForm.vue
  2. +50
    -10
      src/views/modules/pms/material/components/ListViewWithHead.vue
  3. +41
    -47
      src/views/modules/pms/material/config.js

+ 13
- 0
src/views/modules/pms/material/components/DialogJustForm.vue Bestand weergeven

@@ -112,6 +112,19 @@ export default {
this.configs.form.rows.forEach((row) => {
row.forEach((col) => {
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 {


+ 50
- 10
src/views/modules/pms/material/components/ListViewWithHead.vue Bestand weergeven

@@ -57,6 +57,7 @@ import DialogJustForm from "./DialogJustForm.vue";

const DIALOG_WITH_MENU = "DialogWithMenu";
const DIALOG_JUST_FORM = "DialogJustForm";
const dictList = JSON.parse(localStorage.getItem("dictList"));

export default {
name: "ListViewWithHead",
@@ -109,24 +110,63 @@ export default {
[
{
input: true,
label: "料名称",
label: "料名称",
prop: "name",
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请输入料名称" },
elparams: { placeholder: "请输入料名称" },
},
],
[
{
input: true,
label: "料编码",
label: "料编码",
prop: "code",
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请输入物料编码" },
elparams: { placeholder: "请输入原料编码" },
},
{
select: true,
label: "单位",
prop: "unitDictValue",
options: dictList["unit"].map((u) => ({ label: u.dictLabel, value: u.dictValue })),
elparams: { placeholder: "单位" },
},
],
[
{
select: true,
label: "原料类型",
prop: "typeId",
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
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: "enName",
elparams: { placeholder: "请输入英文名称" },
},
{
input: true,
label: "缩写",
prop: "enAb",
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, prop: "parentId", elparams: { type: "hidden" }, hidden: true }],
[{ input: true, label: "中文描述", prop: "remark", elparams: { placeholder: "备注" } }],
],
operations: [
{ name: "add", label: "保存", type: "primary", permission: "pms:material:save", showOnEdit: false },
@@ -197,7 +237,7 @@ export default {
// page 场景:
if ("list" in res.data) {
// 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.totalPage = res.data.total;


+ 41
- 47
src/views/modules/pms/material/config.js Bestand weergeven

@@ -7,10 +7,10 @@ export default function () {
const tableProps = [
{ type: 'index', label: '序号' },
{ prop: "createTime", label: "添加时间", filter: timeFilter },
{ prop: "name", label: "料名称" },
{ prop: "code", label: "料编码" },
{ prop: "name", label: "料名称" },
{ prop: "code", label: "料编码" },
{ 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: "enAb", label: "英文缩写" },
{ prop: "density", label: "堆积密度" },
@@ -30,11 +30,11 @@ export default function () {

const headFormFields = [
{
label: "料名称/编码",
label: "料名称/编码",
prop: "key",
input: true,
default: { value: "" },
bind: { placeholder: "请输入料名称或编码" },
bind: { placeholder: "请输入料名称或编码" },
},
{
button: {
@@ -62,8 +62,8 @@ export default function () {
const dictList = JSON.parse(localStorage.getItem("dictList"));
const dialogConfigs = {
menu: [
{ name: "料信息", key: "info" },
{ name: "料属性信息", key: "attr", onlyEditMode: true },
{ name: "料信息", key: "info" },
{ name: "料属性信息", key: "attr", onlyEditMode: true },
// { name: "添加子类", key: "add-sub", onlyEditMode: true },
],
form: {
@@ -71,59 +71,64 @@ export default function () {
[
{
input: true,
label: "料名称",
label: "料名称",
prop: "name",
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请输入料名称" },
elparams: { placeholder: "请输入料名称" },
},
{
input: true,
label: "料编码",
label: "料编码",
prop: "code",
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,
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: "物料类型",
label: "料类型",
prop: "typeId",
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
options: [],
fetchData: () => this.$http.get('/pms/materialType/page', { params: { page: 1, limit: 999 } }),
elparams: { placeholder: "请输入物料类型" },
elparams: { placeholder: "请输入料类型" },
// autoDisabled: true, // 有某个条件触发后,自动变成 disabled 状态
},
{
select: true,
label: "物料类别",
label: "料类别",
prop: "typeDictValue",
options: dictList["material_category"].map((u) => ({ label: u.dictLabel, value: u.dictValue })),
elparams: { placeholder: "物料类别" },
elparams: { placeholder: "料类别" },
// autoDisabled: true
},

{ input: true, label: "堆积密度(g/cm³)", prop: "density", elparams: { placeholder: "堆积密度" } },
// {
// input: true,
// 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,
label: "英文名称",
@@ -153,9 +150,6 @@ export default function () {
prop: "enAb",
elparams: { placeholder: "请输入缩写" },
},

],
[
{ input: true, label: "原料描述", prop: "description", elparams: { placeholder: "原料描述" } },
],
[{ input: true, label: "中文描述", prop: "remark", elparams: { placeholder: "备注" } }],


Laden…
Annuleren
Opslaan