2023-02-03 16:28:52 +08:00
|
|
|
|
import TableOperaionComponent from "@/components/noTemplateComponents/operationComponent";
|
|
|
|
|
import TableTextComponent from "@/components/noTemplateComponents/detailComponent";
|
|
|
|
|
import StatusComponent from "@/components/noTemplateComponents/statusComponent";
|
|
|
|
|
import { timeFilter, dictFilter } from "@/utils/filters";
|
2023-01-29 10:01:31 +08:00
|
|
|
|
|
|
|
|
|
export default function () {
|
|
|
|
|
const tableProps = [
|
2023-02-06 14:24:12 +08:00
|
|
|
|
{ type: 'index', label: '序号' },
|
|
|
|
|
// { prop: "createTime", label: "添加时间", filter: timeFilter },
|
2023-02-03 16:28:52 +08:00
|
|
|
|
{ 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: "enName", label: "英文名称" },
|
|
|
|
|
{ prop: "enAb", label: "英文缩写" },
|
|
|
|
|
{ prop: "description", label: "详情", subcomponent: TableTextComponent },
|
|
|
|
|
{ prop: "remark", label: "备注" },
|
2023-01-29 10:01:31 +08:00
|
|
|
|
/** TODO: parentId 是用来前端重构成树形结构的... */
|
|
|
|
|
{
|
2023-02-03 16:28:52 +08:00
|
|
|
|
prop: "operations",
|
|
|
|
|
name: "操作",
|
|
|
|
|
fixed: "right",
|
2023-01-29 10:01:31 +08:00
|
|
|
|
width: 120,
|
|
|
|
|
subcomponent: TableOperaionComponent,
|
2023-02-03 16:28:52 +08:00
|
|
|
|
options: ["edit", { name: "delete", permission: "pms:material:save" }],
|
|
|
|
|
},
|
|
|
|
|
];
|
2023-01-29 10:01:31 +08:00
|
|
|
|
|
|
|
|
|
const headFormFields = [
|
|
|
|
|
{
|
2023-02-03 16:28:52 +08:00
|
|
|
|
label: "物料名称/编码",
|
|
|
|
|
prop: "key",
|
2023-01-29 10:01:31 +08:00
|
|
|
|
input: true,
|
2023-02-03 16:28:52 +08:00
|
|
|
|
default: { value: "" },
|
|
|
|
|
bind: { placeholder: "请输入物料名称或编码" },
|
2023-01-29 10:01:31 +08:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
button: {
|
2023-02-03 16:28:52 +08:00
|
|
|
|
type: "primary",
|
|
|
|
|
name: "查询",
|
|
|
|
|
},
|
2023-01-29 10:01:31 +08:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
button: {
|
2023-02-03 16:28:52 +08:00
|
|
|
|
type: "primary",
|
|
|
|
|
name: "新增",
|
|
|
|
|
permission: "",
|
2023-01-30 14:12:45 +08:00
|
|
|
|
},
|
|
|
|
|
bind: {
|
|
|
|
|
plain: true,
|
2023-02-03 16:28:52 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
];
|
2023-01-29 10:01:31 +08:00
|
|
|
|
|
2023-01-29 15:27:38 +08:00
|
|
|
|
/**
|
|
|
|
|
* dialog config 有两个版本,一个适用于 DialogWithMenu 组件,另一个适用于 DialogJustForm 组件
|
|
|
|
|
* 适用于 DialogWithMenu 组件的配置示例详见 blenderStep/config.js
|
|
|
|
|
* 此为后者的配置:
|
|
|
|
|
*/
|
2023-02-03 16:28:52 +08:00
|
|
|
|
const dictList = JSON.parse(localStorage.getItem("dictList"));
|
2023-01-29 10:01:31 +08:00
|
|
|
|
const dialogConfigs = {
|
2023-02-03 16:28:52 +08:00
|
|
|
|
menu: [
|
|
|
|
|
{ name: "物料信息", key: "info" },
|
|
|
|
|
{ name: "物料属性信息", key: "attr", onlyEditMode: true },
|
2023-02-06 14:24:12 +08:00
|
|
|
|
// { name: "添加子类", key: "add-sub", onlyEditMode: true },
|
2023-02-03 16:28:52 +08:00
|
|
|
|
],
|
2023-01-29 10:01:31 +08:00
|
|
|
|
form: {
|
|
|
|
|
rows: [
|
|
|
|
|
[
|
2023-02-03 16:28:52 +08:00
|
|
|
|
{
|
|
|
|
|
input: true,
|
|
|
|
|
label: "物料名称",
|
|
|
|
|
prop: "name",
|
|
|
|
|
rules: { required: true, message: "not empty", trigger: "blur" },
|
|
|
|
|
elparams: { placeholder: "请输入物料名称" },
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
input: true,
|
|
|
|
|
label: "物料编码",
|
|
|
|
|
prop: "code",
|
|
|
|
|
rules: { required: true, message: "not empty", trigger: "blur" },
|
|
|
|
|
elparams: { placeholder: "请输入物料编码" },
|
|
|
|
|
},
|
2023-02-06 14:24:12 +08:00
|
|
|
|
{ input: true, label: "规格", prop: "description", elparams: { placeholder: "规格" } },
|
2023-02-03 16:28:52 +08:00
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
{
|
|
|
|
|
select: true,
|
|
|
|
|
label: "父级物料",
|
|
|
|
|
prop: "parentId",
|
2023-02-06 14:24:12 +08:00
|
|
|
|
// TODO: 待解决:DialogWithMenu 中设置default只在初始化的时候有效,一旦清空过就无效了
|
|
|
|
|
// default: '0',
|
|
|
|
|
// rules: { required: true, message: "not empty", trigger: "blur" },
|
|
|
|
|
options: [{ id: '0', name: '无' }], // 手动注入额外选项,用到的场景不多...
|
2023-02-03 16:28:52 +08:00
|
|
|
|
fetchData: () => this.$http.get('/pms/material/page', { params: { page: 1, limit: 999, key: '' } }),
|
|
|
|
|
elparams: { placeholder: "请选择父级物料" },
|
|
|
|
|
},
|
|
|
|
|
{
|
2023-02-06 14:24:12 +08:00
|
|
|
|
select: true,
|
|
|
|
|
label: "物料类型",
|
|
|
|
|
prop: "typeId",
|
|
|
|
|
rules: { required: true, message: "not empty", trigger: "blur" },
|
|
|
|
|
options: [],
|
|
|
|
|
fetchData: () => this.$http.get('/pms/materialType/page', { params: { page: 1, limit: 999 } }),
|
|
|
|
|
elparams: { placeholder: "请输入物料类型" },
|
|
|
|
|
// autoDisabled: true, // 有某个条件触发后,自动变成 disabled 状态
|
2023-02-03 16:28:52 +08:00
|
|
|
|
},
|
|
|
|
|
{
|
2023-02-06 14:24:12 +08:00
|
|
|
|
select: true,
|
|
|
|
|
label: "物料类别",
|
|
|
|
|
prop: "typeDictValue",
|
|
|
|
|
options: dictList["material_category"].map((u) => ({ label: u.dictLabel, value: u.dictValue })),
|
|
|
|
|
elparams: { placeholder: "物料类别" },
|
|
|
|
|
// autoDisabled: true
|
2023-02-03 16:28:52 +08:00
|
|
|
|
},
|
2023-02-06 14:24:12 +08:00
|
|
|
|
|
2023-02-03 16:28:52 +08:00
|
|
|
|
// {
|
|
|
|
|
// input: true,
|
|
|
|
|
// label: "设备类型",
|
|
|
|
|
// prop: "eqTypeId",
|
|
|
|
|
// rules: { required: true, message: "not empty", trigger: "blur" },
|
|
|
|
|
// elparams: { placeholder: "请输入设备类型" },
|
|
|
|
|
// },
|
|
|
|
|
],
|
|
|
|
|
[
|
2023-02-06 14:24:12 +08:00
|
|
|
|
|
2023-02-03 16:28:52 +08:00
|
|
|
|
{
|
|
|
|
|
select: true,
|
|
|
|
|
label: "单位",
|
|
|
|
|
prop: "unitDictValue",
|
|
|
|
|
options: dictList["unit"].map((u) => ({ label: u.dictLabel, value: u.dictValue })),
|
|
|
|
|
elparams: { placeholder: "单位" },
|
|
|
|
|
},
|
2023-02-06 14:24:12 +08:00
|
|
|
|
{
|
|
|
|
|
input: true,
|
|
|
|
|
label: "英文名称",
|
|
|
|
|
prop: "enName",
|
|
|
|
|
elparams: { placeholder: "请输入英文名称" },
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
input: true,
|
|
|
|
|
label: "缩写",
|
|
|
|
|
prop: "enAb",
|
|
|
|
|
elparams: { placeholder: "请输入缩写" },
|
|
|
|
|
},
|
|
|
|
|
|
2023-01-29 10:01:31 +08:00
|
|
|
|
],
|
2023-02-03 16:28:52 +08:00
|
|
|
|
[{ textarea: true, label: "备注", prop: "remark", elparams: { placeholder: "备注" } }],
|
2023-01-29 10:01:31 +08:00
|
|
|
|
],
|
|
|
|
|
operations: [
|
2023-02-03 16:28:52 +08:00
|
|
|
|
{ name: "add", label: "保存", type: "primary", permission: "pms:material:save", showOnEdit: false },
|
|
|
|
|
{ name: "update", label: "更新", type: "primary", permission: "pms:material:save", showOnEdit: true },
|
|
|
|
|
{ name: "reset", label: "重置", type: "warning", showAlways: true },
|
2023-01-29 10:01:31 +08:00
|
|
|
|
// { name: 'cancel', label: '取消', showAlways: true },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
table: {
|
|
|
|
|
// extraParams: ['stepId'],
|
2023-02-03 16:28:52 +08:00
|
|
|
|
extraParams: "materialId",
|
2023-01-29 10:01:31 +08:00
|
|
|
|
props: [
|
2023-02-03 16:28:52 +08:00
|
|
|
|
{ prop: "createTime", label: "添加时间", filter: timeFilter, isEditField: true },
|
|
|
|
|
{ prop: "name", label: "属性名", isEditField: true },
|
|
|
|
|
{ prop: "value", label: "属性值", isEditField: true },
|
2023-01-29 10:01:31 +08:00
|
|
|
|
{
|
2023-02-03 16:28:52 +08:00
|
|
|
|
prop: "operations",
|
|
|
|
|
name: "操作",
|
|
|
|
|
fixed: "right",
|
2023-01-29 10:01:31 +08:00
|
|
|
|
width: 120,
|
|
|
|
|
subcomponent: TableOperaionComponent,
|
|
|
|
|
options: [
|
2023-02-03 16:28:52 +08:00
|
|
|
|
{ name: "edit", permission: "pms:materialArrt:save" },
|
|
|
|
|
{ name: "delete", permission: "pms:materialArrt:save" },
|
|
|
|
|
],
|
|
|
|
|
},
|
2023-01-29 10:01:31 +08:00
|
|
|
|
],
|
|
|
|
|
data: [
|
|
|
|
|
// TOOD 暂时用不到,但获取可以考虑把拉取接口数据的函数迁移到此文件(没有太大必要)
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
subDialog: {
|
2023-02-03 16:28:52 +08:00
|
|
|
|
extraParam: "materialId",
|
|
|
|
|
forceAttachCode: true,
|
2023-01-29 10:01:31 +08:00
|
|
|
|
rows: [
|
|
|
|
|
[
|
2023-02-03 16:28:52 +08:00
|
|
|
|
{ input: true, label: "属性名", prop: "name", elparams: { placeholder: "请输入属性名" } }
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
{ input: true, label: "属性值", prop: "value", elparams: { placeholder: "请输入属性值" } }
|
2023-01-29 10:01:31 +08:00
|
|
|
|
],
|
|
|
|
|
[
|
2023-02-03 16:28:52 +08:00
|
|
|
|
{ input: true, label: "备注", prop: "remark", elparams: { placeholder: "请输入备注" } },
|
2023-01-29 10:01:31 +08:00
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
operations: [
|
2023-02-03 16:28:52 +08:00
|
|
|
|
{ name: "add", label: "保存", type: "primary", permission: "pms:materialArrt:save", showOnEdit: false },
|
|
|
|
|
{ name: "update", label: "更新", type: "primary", permission: "pms:materialArrt:update", showOnEdit: true },
|
2023-01-29 10:01:31 +08:00
|
|
|
|
// { name: 'reset', label: '重置', type: 'warning', showAlways: true },
|
|
|
|
|
// { name: 'cancel', label: '取消', showAlways: true },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
dialogConfigs,
|
|
|
|
|
tableConfig: {
|
|
|
|
|
table: null, // 此处可省略,el-table 上的配置项
|
|
|
|
|
column: tableProps, // el-column-item 上的配置项
|
|
|
|
|
},
|
|
|
|
|
headFormConfigs: {
|
|
|
|
|
rules: null, // 名称是由 BaseSearchForm.vue 组件固定的
|
2023-02-03 16:28:52 +08:00
|
|
|
|
fields: headFormFields, // 名称是由 BaseSearchForm.vue 组件固定的
|
2023-01-29 10:01:31 +08:00
|
|
|
|
},
|
|
|
|
|
urls: {
|
2023-02-03 16:28:52 +08:00
|
|
|
|
base: "/pms/material",
|
|
|
|
|
page: "/pms/material/page",
|
2023-02-06 14:24:12 +08:00
|
|
|
|
tree: "/pms/material/tree",
|
2023-02-03 16:28:52 +08:00
|
|
|
|
subase: "/pms/materialArrt",
|
|
|
|
|
subpage: "/pms/materialArrt/page",
|
2023-01-29 10:01:31 +08:00
|
|
|
|
// more...
|
2023-02-03 16:28:52 +08:00
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|