Commit 30c24b9f authored by wuhao's avatar wuhao 🎯

asder

parent 4f5c7fb1
...@@ -14,6 +14,7 @@ import Coltext from "@/components/Coltext"; ...@@ -14,6 +14,7 @@ import Coltext from "@/components/Coltext";
import RenderItemType from "@/components/RenderItemType"; import RenderItemType from "@/components/RenderItemType";
import TreeRender from '@/components/TreeRender' import TreeRender from '@/components/TreeRender'
import { set } from "lodash"; import { set } from "lodash";
import { useEffect } from "react";
const initState = { const initState = {
vs: false, vs: false,
...@@ -26,7 +27,6 @@ const initState = { ...@@ -26,7 +27,6 @@ const initState = {
}, },
visible: false, visible: false,
specificFileds: {}, specificFileds: {},
defaultSpecificFileds: [],
commonFields: {}, commonFields: {},
defaultCommonFields: [], defaultCommonFields: [],
}, },
...@@ -67,7 +67,6 @@ function reducer(state, action) { ...@@ -67,7 +67,6 @@ function reducer(state, action) {
commonFields: action.commonFields, commonFields: action.commonFields,
specificFileds: action.specificFileds, specificFileds: action.specificFileds,
defaultCommonFields: action.defaultCommonFields, defaultCommonFields: action.defaultCommonFields,
defaultSpecificFileds: action.defaultSpecificFileds,
}; };
break; break;
case "bom": case "bom":
...@@ -105,12 +104,6 @@ function reducer(state, action) { ...@@ -105,12 +104,6 @@ function reducer(state, action) {
fields: action.fields, fields: action.fields,
}; };
break; break;
case "changeDefaultSpecificFileds":
newState = {
...state,
defaultSpecificFileds: action.defaultSpecificFileds,
};
break;
case "changeCommonFields": case "changeCommonFields":
newState = { newState = {
...state, ...state,
...@@ -135,7 +128,6 @@ function reducer(state, action) { ...@@ -135,7 +128,6 @@ function reducer(state, action) {
}, },
visible: false, visible: false,
specificFileds: {}, specificFileds: {},
defaultSpecificFileds: [],
}; };
break; break;
} }
...@@ -149,6 +141,7 @@ const Materiel = (props) => { ...@@ -149,6 +141,7 @@ const Materiel = (props) => {
[formRef] = Form.useForm(), [formRef] = Form.useForm(),
[formRefs] = Form.useForm(); [formRefs] = Form.useForm();
const [materieTypeId, setmaterieTypeId] = useState(); const [materieTypeId, setmaterieTypeId] = useState();
const [defaultSpecificFileds, setdefaultSpecificFileds] = useState();
function reload() { function reload() {
actionRef?.current?.reload(); actionRef?.current?.reload();
ChildRef?.onRefresh(); ChildRef?.onRefresh();
...@@ -172,7 +165,6 @@ const Materiel = (props) => { ...@@ -172,7 +165,6 @@ const Materiel = (props) => {
detail, detail,
visible, visible,
specificFileds, specificFileds,
defaultSpecificFileds,
commonFields, commonFields,
defaultCommonFields, defaultCommonFields,
markKey, markKey,
...@@ -259,8 +251,8 @@ const Materiel = (props) => { ...@@ -259,8 +251,8 @@ const Materiel = (props) => {
dataIndex: "qualityGuaranteePeriod", dataIndex: "qualityGuaranteePeriod",
key: "qualityGuaranteePeriod", key: "qualityGuaranteePeriod",
search: false, search: false,
render:(text,row)=>{ render: (text, row) => {
return row.qualityGuaranteePeriod+" "+row.qualityGuaranteePeriodUnitName return row.qualityGuaranteePeriod + " " + row.qualityGuaranteePeriodUnitName
} }
}, },
{ {
...@@ -300,6 +292,14 @@ const Materiel = (props) => { ...@@ -300,6 +292,14 @@ const Materiel = (props) => {
render: (text, row, _, action) => extraAction(text, row, _, action), render: (text, row, _, action) => extraAction(text, row, _, action),
}, },
]; ];
useEffect(() => {
doFetch({ url: "/ngic-workmanship/pmMaterieChar/queryCommonList", params: {} }).then(res => {
setdefaultSpecificFileds(res?.data?.dataList)
})
}, [])
function extraAction(text, record, _, action) { function extraAction(text, record, _, action) {
return [ return [
getPrem("sysDepartment_save", action, "修改", () => { getPrem("sysDepartment_save", action, "修改", () => {
...@@ -336,18 +336,10 @@ const Materiel = (props) => { ...@@ -336,18 +336,10 @@ const Materiel = (props) => {
let common = await doFetch({ let common = await doFetch({
url: "/ngic-workmanship/pmMaterieChar/queryCommonList", url: "/ngic-workmanship/pmMaterieChar/queryCommonList",
params: { id: record.id }, params: { id: record.id },
}),
other = await doFetch({
url: "/ngic-workmanship/pmMaterieChar/queryListBykey",
params: {
id: record.id,
materieControl: record.materieControl,
},
}); });
return { return {
commonData: common?.data?.dataList, commonData: common?.data?.dataList,
otherData: other?.data?.dataList,
}; };
}; };
all().then((res) => { all().then((res) => {
...@@ -355,18 +347,16 @@ const Materiel = (props) => { ...@@ -355,18 +347,16 @@ const Materiel = (props) => {
res?.commonData, res?.commonData,
"common" "common"
)?.obj, )?.obj,
otherDataFields = formatFieds(res?.otherData, "other")?.obj, newCommonData = formatFieds(res?.commonData, "common")?.data;
newCommonData = formatFieds(res?.commonData, "common")?.data,
newOtherData = formatFieds(res?.otherData, "other")?.data;
dispatch({ dispatch({
type: "edit", type: "edit",
fields: defaultFields, fields: defaultFields,
curitem: record, curitem: record,
commonFields: commonDataFields, commonFields: commonDataFields,
specificFileds: { ...commonDataFields, ...otherDataFields }, specificFileds: { ...commonDataFields },
defaultCommonFields: newCommonData, defaultCommonFields: newCommonData,
defaultSpecificFileds: [...newCommonData, ...newOtherData],
}); });
setdefaultSpecificFileds([...newCommonData])
}); });
} }
}); });
...@@ -388,29 +378,14 @@ const Materiel = (props) => { ...@@ -388,29 +378,14 @@ const Materiel = (props) => {
params, params,
url; url;
if (iftype.val != "bom") { if (iftype.val != "bom") {
let firstValues = formRef?.getFieldsValue(),
secondFields = formRefs?.getFieldsValue();
formRef formRef
.validateFields() .validateFields()
.then((res) => { .then((firstValues) => {
formRefs formRefs
.validateFields() .validateFields()
.then((res) => { .then((secondFields) => {
const { unitList } = firstValues;
let materieProductUnitList = [],
materieCharList;
unitList?.map((it, i) => {
if (i != 0) {
materieProductUnitList.push({
productionUnit: it.productionUnit,
productionUnitType: it.productionUnitType,
});
}
});
let productionUnit = unitList[0].productionUnit,
productionUnitType = unitList[0].productionUnitType;
let secondFieldsKeys = Object.keys(secondFields); let secondFieldsKeys = Object.keys(secondFields);
materieCharList = defaultSpecificFileds.map((it) => { let materieCharList = defaultSpecificFileds.map((it) => {
if (secondFieldsKeys.indexOf(it.fieldsKey) != -1) { if (secondFieldsKeys.indexOf(it.fieldsKey) != -1) {
it.fieldRealValue = secondFields[it.fieldsKey]; it.fieldRealValue = secondFields[it.fieldsKey];
} }
...@@ -431,14 +406,18 @@ const Materiel = (props) => { ...@@ -431,14 +406,18 @@ const Materiel = (props) => {
}; };
return el; return el;
}); });
delete firstValues.unitList; let materieProductUnitList = firstValues.materieProductUnitList.map(it => {
return {
productionUnit: it.productionUnit,
conversionRate: it.conversionRate
}
})
params = { params = {
...firstValues, ...firstValues,
materieProductUnitList,
materieCharList, materieCharList,
productionUnit,
productionUnitType,
...difrid, ...difrid,
materieProductUnitList,
}; };
url = "/ngic-workmanship/pmMaterie/save"; url = "/ngic-workmanship/pmMaterie/save";
run({ url, params }); run({ url, params });
...@@ -588,52 +567,6 @@ const Materiel = (props) => { ...@@ -588,52 +567,6 @@ const Materiel = (props) => {
formRef={formRef} formRef={formRef}
fields={fields} fields={fields}
onChange={(changedValues, allValues) => { onChange={(changedValues, allValues) => {
for (let i in changedValues) {
if (i == "materieControl") {
doFetch({
url: "/ngic-workmanship/pmMaterieChar/queryListBykey",
params: {
materieControl: changedValues[i],
id: iftype.val == "edit" ? curitem.id : "",
},
}).then((res) => {
if (res.code == "0000") {
let data = res?.data?.dataList,
otherFields = formatFieds(data, "other")?.obj,
newData = formatFieds(data, "other")?.data;
dispatch({
type: "changeDefaultSpecificFileds",
defaultSpecificFileds: [
...defaultCommonFields,
...newData,
],
});
dispatch({
type: "changeSpecificFileds",
specificFileds: { ...commonFields, ...otherFields },
});
}
});
}
if (i == "materieType") {
for (let j in fields) {
if (
j == "materieControl" ||
j == "serialNumberRuleId" ||
j == "processLineId" ||
j == "labelTemplateId"
) {
if (changedValues[i] == 0) {
fields[j].required = true;
dispatch({ type: "changeFields", fields });
} else {
fields[j].required = false;
dispatch({ type: "changeFields", fields });
}
}
}
}
}
}} }}
actions={() => { actions={() => {
return null; return null;
......
...@@ -5,6 +5,8 @@ import { ...@@ -5,6 +5,8 @@ import {
processLineSelect, processLineSelect,
bmTableSelect, bmTableSelect,
} from "@/services/craft"; } from "@/services/craft";
import { doFetch } from "@/utils/doFetch";
export default { export default {
materieCode: { materieCode: {
value: null, value: null,
...@@ -20,208 +22,137 @@ export default { ...@@ -20,208 +22,137 @@ export default {
name: ["materieName"], name: ["materieName"],
required: true, required: true,
}, },
materieType: { materieTypeId: {
value: null, value: null,
type: "select", type: "treeselect",
title: "物料类别", title: "物料类别",
name: ["materieType"], name: ["materieTypeId"],
required: false,
options: {
database: (params) => doFetch({ url: "/ngic-workmanship/pmMaterieType/queryTreeList", params }),
params: {}
},
},
materieControl: {
value: null,
type: "select",
title: "管控方式",
name: ["materieControl"],
required: true, required: true,
options: {
database: (params) => doFetch({ url: "/ngic-base-business/sysDic/queryMaterieControlSelect", params }),
params: {}
},
},
inventoryMin: {
value: null,
type: "inputnumber",
title: "库存最小值",
name: ["inventoryMin"],
required: false,
},
inventoryMax: {
value: null,
type: "inputnumber",
title: "库存最大值",
name: ["inventoryMax"],
required: false,
},
productionUnit: {
value: null,
type: "select",
title: "库存单位",
name: ["productionUnit"],
required: false,
options: {
database: (params) => doFetch({ url: "/ngic-base-business/sysDic/queryMaterieUnitSelect", params }),
params: {}
},
},
qualityGuaranteePeriod: {
value: null,
type: "inputnumber",
title: "保质期",
name: ["qualityGuaranteePeriod"],
required: false,
},
qualityGuaranteePeriodUnit: {
value: null,
type: "radio",
title: "保质期单位",
name: ["qualityGuaranteePeriodUnit"],
required: false,
options: [ options: [
{ {
label: "自制件", label: "",
value: 0, value: 1,
}, },
{ {
label: "采购件", label: "月",
value: 2,
},
{
label: "年",
value: 3,
}
],
},
issueType: {
value: null,
type: "radio",
title: "发料类型",
name: ["issueType"],
required: true,
options: [
{
label: "散发",
value: 1, value: 1,
}, },
{ {
label: "虚拟件", label: "整发",
value: 2, value: 2,
}, }
], ],
}, },
unitList: { materieProductUnitList: {
value: [], value: [],
title: "生产单位", title: "转换单位",
type: "table", type: "table",
col: { span: 24 }, col: { span: 24 },
name: ["unitList"], name: ["materieProductUnitList"],
required: true, required: true,
columns: [ columns: [
{ {
title: "主次", title: "辅助单位",
dataIndex: "index",
key: "index",
search: false,
render: (_, row, index) => {
return <span>{index == 0 ? "主单位" : `第${index + 1}单位`}</span>;
},
editable: false,
width: 120,
},
{
title: "单位类型",
dataIndex: "productionUnit", dataIndex: "productionUnit",
key: "productionUnit", key: "productionUnit",
search: false, search: false,
valueType: "select", valueType: "select",
request: async () => [ request: async () => {
{ let res = await doFetch({url:"/ngic-base-business/sysDic/queryMaterieUnitSelect",params:{}})
value: 0, return res?.data?.dataList
label: "数量(PCS)",
},
{
value: 1,
label: "重量",
},
{
value: 2,
label: "面积",
},
{
value: 3,
label: "容积",
}, },
],
}, },
{ {
title: "单位", title: "转换比",
dataIndex: "productionUnitType", dataIndex: "conversionRate",
key: "productionUnitType", key: "conversionRate",
search: false, search: false,
valueType: "select", valueType: "digit",
request: async () => { width:200
let res = await unitSelect({ dicKey: "material_unit" });
return res?.data?.dataList ?? [];
},
}, },
{ {
title: "操作", title: "操作",
valueType: "option", valueType: "option",
width: 70, width: 70,
render: (text, record, _, action) => [ render: (text, record, _, action) => [
<a key="delete" onClick={() => {}}> <a key="delete" onClick={() => { }}>
删除 删除
</a>, </a>,
], ],
}, },
], ],
maxLength: 3,
rowKey: "id", rowKey: "id",
}, },
enableDualUnits: {
value: null,
type: "radio",
title: "启用双单位",
name: ["enableDualUnits"],
required: false,
options: [
{
label: "否",
value: 0,
},
{
label: "是",
value: 1,
},
],
linked: true,
},
inventoryUnit: {
value: null,
type: "select",
title: "库存单位",
name: ["inventoryUnit"],
required: false,
belinked: {
options: {
database: unitSelect,
params: { dicKey: "material_unit" },
},
hides: [
{
name: "enableDualUnits",
equalvalue: [0, null],
required: true,
},
],
},
},
unitConversion: {
value: null,
title: "单位转换(生产单位=库存单位*系数)",
type: "inputnumber",
name: ["unitConversion"],
required: false,
...regValue(null, 6, 3),
belinked: {
hides: [
{
name: "enableDualUnits",
equalvalue: [0, null],
required: true,
},
],
},
},
processLineId: {
value: null,
type: "select",
title: "工艺路线",
name: ["processLineId"],
required: false,
options: {
database: processLineSelect,
params: {},
},
},
materialControl: {
value: null,
type: "select",
title: "物料管控",
name: ["materialControl"],
required: false,
options: [
{
label: "单品管控",
value: 0,
},
{
label: "批次管控",
value: 1,
},
],
linked: true,
},
serialNumberRuleId: {
value: null,
type: "select",
title: "序列号规则",
name: ["serialNumberRuleId"],
required: false,
options: {
database: serialNumberRuleSelect,
params: { noTypeCode: "materials_no" },
},
},
labelTemplateId: {
value: null,
type: "select",
title: "标签模板",
name: ["labelTemplateId"],
required: false,
options: {
database: bmTableSelect,
params: { tableType: 0 },
},
},
remark: {
value: null,
type: "textarea",
title: "描述",
name: ["remark"],
required: false,
col: { span: 24 },
},
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment