pms-aomei/src/views/modules/pms/materialUpload/config.js
2023-03-17 10:31:11 +08:00

217 lines
7.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import TableOperaionComponent from "@/components/noTemplateComponents/operationComponent";
// import switchBtn from "@/components/noTemplateComponents/switchBtn";
import QuillRichInput from "@/components/noTemplateComponents/richInput";
import request from "@/utils/request";
import { timeFilter, dictFilter } from "@/utils/filters";
export default function () {
const tableProps = [
{ type: "index", label: "序号" },
{ prop: "createTime", label: "添加时间", filter: timeFilter },
{ prop: "startTime", label: "上料时间", filter: timeFilter },
{ prop: "endTime", label: "结束上料时间", filter: timeFilter },
{ prop: "material", label: "物料" },
{ prop: "qty", label: "上料数量" },
{ prop: "storeCode", label: "料仓" },
{ prop: "upPos", label: "上料位点" },
// { prop: "typeDictValue", label: "过渡车", filter: val => ['否', '是'][val] },
// { prop: "enabled", label: "状态", subcomponent: switchBtn }, // subcomponent
// { prop: "currentQty", label: "载量" },
// { prop: "currentPos", label: "当前位置" },
// { prop: "description", label: "描述" },
{ prop: "remark", label: "备注" },
{
prop: "operations",
name: "操作",
fixed: "right",
width: 120,
subcomponent: TableOperaionComponent,
options: ["edit", { name: "delete", emitFull: true, permission: "pms:materialUpload:delete" }],
},
];
/**
* 数据字典hack
* @param {object} row 行数据
* @param {string} dictId 从哪个数据字典映射数据
* @param {string} dataProp 把字典值附加到哪个 prop 字段上
* @param {string} dictProp 哪个prop是字典数据
**/
let dictList;
tableProps.attachDictValue = (row, dictId, dataProp, dictProp, forceFlushDictList = false) => {
/** 缓存一下 dictList **/
if (!dictList || (dictList && forceFlushDictList)) dictList = dictFilter(dictId)
if (typeof row === 'object' && dictList) {
const value = dictList(row[dictProp])
const data = row[dataProp]
row[dataProp] = data + ' ' + (value === '-' ? '' : value)
} else {
this.$message({
message: 'tableProps.attachDictValue() 出错!',
type: 'error',
duration: 1500
})
}
}
const headFormFields = [
{
prop: "materialId",
label: "物料",
// default: { value: "" },
select: [],
// 绑定数据获取函数
fn: () => this.$http.get("/pms/material/page", { params: { page: 1, limit: 999 } }),
bind: {
placeholder: "请选择物料",
filterable: true,
},
},
{
prop: "storeId",
label: "日料仓",
fieldOptionLabel: 'code', // 把料仓筛选条件的label改为展示code而不是展示name
select: [],
// default: { value: "" },
fn: () => this.$http.get("/pms/materialStorage/page", { params: { page: 1, limit: 999, typeDictValue: "1" } }),
bind: {
placeholder: "请选择日料仓",
filterable: true,
},
},
{
timerange: true,
prop: "timerange", // 应该是个数组,在提交数据时需单独处理
label: "时间段",
bind: {
placeholder: "选择日期时间",
type: "datetimerange",
"start-placeholder": "开始时间",
"end-placeholder": "结束时间",
},
},
{
button: {
type: "primary",
name: "查询",
},
},
{
button: {
type: "primary",
name: "新增",
permission: "pms:materialStorage:save",
},
bind: {
plain: true,
},
},
];
/**
* dialog config 有两个版本,一个适用于 DialogWithMenu 组件,另一个适用于 DialogJustForm 组件
* 适用于 DialogWithMenu 组件的配置示例详见 blenderStep/config.js
* 此为后者的配置:
*/
const dialogJustFormConfigs = {
clickModalToClose: true,
form: {
rows: [
[
{
datetime: true,
label: "上料时间",
prop: "startTime",
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请选择上料时间", type: "datetime" },
},
{
datetime: true,
label: "结束上料时间",
prop: "endTime",
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请选择结束上料时间", type: "datetime" },
},
],
[
{
select: true,
label: "物料",
prop: "materialId",
options: [],
fetchData: () => this.$http("/pms/material/page", { params: { page: 1, size: 999 } }),
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请选择物料", filterable: true },
},
{
input: true,
label: "上料数量",
prop: "qty",
// options: [],
// fetchData: () => this.$http('/pms/material/page', { params: { page: 1, size: 999 } }),
rules: [
{ required: true, message: "必填项不能为空", trigger: "blur" },
{ type: "number", message: "请输入正确的数字", trigger: "blur", transform: (val) => Number(val) },
],
elparams: { placeholder: "请输入上料数量" },
},
],
// [{ component: QuillRichInput, label: "描述信息", prop: "description" }],
[
{
select: true,
label: "料仓",
prop: "storeId",
options: [],
fetchData: () => this.$http("/pms/materialStorage/page", { params: { page: 1, size: 999, typeDictValue: '1' } }),
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请选择料仓", filterable: true },
},
{
input: true,
label: "上料位点",
prop: "upPos",
// options: [],
// fetchData: () => this.$http('/pms/material/page', { params: { page: 1, size: 999 } }),
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请输入上料位点" },
},
],
// [{ component: QuillRichInput, label: "描述信息", prop: "description" }],
// [{
// richInput: true, label: "描述信息", prop: "description"
// }],
[{ input: true, label: "备注", prop: "remark", elparams: { placeholder: "备注" } }],
],
operations: [
{ name: "add", label: "保存", type: "primary", permission: "pms:materialUpload:save", showOnEdit: false },
{ name: "update", label: "更新", type: "primary", permission: "pms:materialUpload:update", showOnEdit: true },
{ name: "reset", label: "重置", type: "warning", showAlways: true },
// { name: 'cancel', label: '取消', showAlways: true },
],
},
};
// 备注:弹窗弹出的时间和网速有关......
return {
dialogConfigs: dialogJustFormConfigs,
tableConfig: {
table: null, // 此处可省略el-table 上的配置项
column: tableProps, // el-column-item 上的配置项
},
headFormConfigs: {
rules: null, // 名称是由 BaseSearchForm.vue 组件固定的
fields: headFormFields, // 名称是由 BaseSearchForm.vue 组件固定的
},
urls: {
base: "/pms/materialUpload",
page: "/pms/materialUpload/page",
// subase: '/pms/blenderStepParam',
// subpage: '/pms/blenderStepParam/page',
// more...
},
};
}