Commit 30c24b9f authored by wuhao's avatar wuhao 🎯

asder

parent 4f5c7fb1
......@@ -14,6 +14,7 @@ import Coltext from "@/components/Coltext";
import RenderItemType from "@/components/RenderItemType";
import TreeRender from '@/components/TreeRender'
import { set } from "lodash";
import { useEffect } from "react";
const initState = {
vs: false,
......@@ -26,7 +27,6 @@ const initState = {
},
visible: false,
specificFileds: {},
defaultSpecificFileds: [],
commonFields: {},
defaultCommonFields: [],
},
......@@ -67,7 +67,6 @@ function reducer(state, action) {
commonFields: action.commonFields,
specificFileds: action.specificFileds,
defaultCommonFields: action.defaultCommonFields,
defaultSpecificFileds: action.defaultSpecificFileds,
};
break;
case "bom":
......@@ -105,12 +104,6 @@ function reducer(state, action) {
fields: action.fields,
};
break;
case "changeDefaultSpecificFileds":
newState = {
...state,
defaultSpecificFileds: action.defaultSpecificFileds,
};
break;
case "changeCommonFields":
newState = {
...state,
......@@ -135,7 +128,6 @@ function reducer(state, action) {
},
visible: false,
specificFileds: {},
defaultSpecificFileds: [],
};
break;
}
......@@ -149,6 +141,7 @@ const Materiel = (props) => {
[formRef] = Form.useForm(),
[formRefs] = Form.useForm();
const [materieTypeId, setmaterieTypeId] = useState();
const [defaultSpecificFileds, setdefaultSpecificFileds] = useState();
function reload() {
actionRef?.current?.reload();
ChildRef?.onRefresh();
......@@ -172,7 +165,6 @@ const Materiel = (props) => {
detail,
visible,
specificFileds,
defaultSpecificFileds,
commonFields,
defaultCommonFields,
markKey,
......@@ -259,8 +251,8 @@ const Materiel = (props) => {
dataIndex: "qualityGuaranteePeriod",
key: "qualityGuaranteePeriod",
search: false,
render:(text,row)=>{
return row.qualityGuaranteePeriod+" "+row.qualityGuaranteePeriodUnitName
render: (text, row) => {
return row.qualityGuaranteePeriod + " " + row.qualityGuaranteePeriodUnitName
}
},
{
......@@ -289,8 +281,8 @@ const Materiel = (props) => {
name: "productionUnit",
},
},
{
title: "操作",
dataIndex: "option_dataindex",
......@@ -300,6 +292,14 @@ const Materiel = (props) => {
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) {
return [
getPrem("sysDepartment_save", action, "修改", () => {
......@@ -336,18 +336,10 @@ const Materiel = (props) => {
let common = await doFetch({
url: "/ngic-workmanship/pmMaterieChar/queryCommonList",
params: { id: record.id },
}),
other = await doFetch({
url: "/ngic-workmanship/pmMaterieChar/queryListBykey",
params: {
id: record.id,
materieControl: record.materieControl,
},
});
});
return {
commonData: common?.data?.dataList,
otherData: other?.data?.dataList,
};
};
all().then((res) => {
......@@ -355,18 +347,16 @@ const Materiel = (props) => {
res?.commonData,
"common"
)?.obj,
otherDataFields = formatFieds(res?.otherData, "other")?.obj,
newCommonData = formatFieds(res?.commonData, "common")?.data,
newOtherData = formatFieds(res?.otherData, "other")?.data;
newCommonData = formatFieds(res?.commonData, "common")?.data;
dispatch({
type: "edit",
fields: defaultFields,
curitem: record,
commonFields: commonDataFields,
specificFileds: { ...commonDataFields, ...otherDataFields },
specificFileds: { ...commonDataFields },
defaultCommonFields: newCommonData,
defaultSpecificFileds: [...newCommonData, ...newOtherData],
});
setdefaultSpecificFileds([...newCommonData])
});
}
});
......@@ -388,29 +378,14 @@ const Materiel = (props) => {
params,
url;
if (iftype.val != "bom") {
let firstValues = formRef?.getFieldsValue(),
secondFields = formRefs?.getFieldsValue();
formRef
.validateFields()
.then((res) => {
.then((firstValues) => {
formRefs
.validateFields()
.then((res) => {
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;
.then((secondFields) => {
let secondFieldsKeys = Object.keys(secondFields);
materieCharList = defaultSpecificFileds.map((it) => {
let materieCharList = defaultSpecificFileds.map((it) => {
if (secondFieldsKeys.indexOf(it.fieldsKey) != -1) {
it.fieldRealValue = secondFields[it.fieldsKey];
}
......@@ -431,14 +406,18 @@ const Materiel = (props) => {
};
return el;
});
delete firstValues.unitList;
let materieProductUnitList = firstValues.materieProductUnitList.map(it => {
return {
productionUnit: it.productionUnit,
conversionRate: it.conversionRate
}
})
params = {
...firstValues,
materieProductUnitList,
materieCharList,
productionUnit,
productionUnitType,
...difrid,
materieProductUnitList,
};
url = "/ngic-workmanship/pmMaterie/save";
run({ url, params });
......@@ -588,52 +567,6 @@ const Materiel = (props) => {
formRef={formRef}
fields={fields}
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={() => {
return null;
......
......@@ -5,6 +5,8 @@ import {
processLineSelect,
bmTableSelect,
} from "@/services/craft";
import { doFetch } from "@/utils/doFetch";
export default {
materieCode: {
value: null,
......@@ -20,208 +22,137 @@ export default {
name: ["materieName"],
required: true,
},
materieType: {
materieTypeId: {
value: null,
type: "select",
type: "treeselect",
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,
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: [
{
label: "自制件",
value: 0,
label: "天",
value: 1,
},
{
label: "月",
value: 2,
},
{
label: "采购件",
label: "年",
value: 3,
}
],
},
issueType: {
value: null,
type: "radio",
title: "发料类型",
name: ["issueType"],
required: true,
options: [
{
label: "散发",
value: 1,
},
{
label: "虚拟件",
label: "整发",
value: 2,
},
}
],
},
unitList: {
materieProductUnitList: {
value: [],
title: "生产单位",
title: "转换单位",
type: "table",
col: { span: 24 },
name: ["unitList"],
name: ["materieProductUnitList"],
required: true,
columns: [
{
title: "主次",
dataIndex: "index",
key: "index",
search: false,
render: (_, row, index) => {
return <span>{index == 0 ? "主单位" : `第${index + 1}单位`}</span>;
},
editable: false,
width: 120,
},
{
title: "单位类型",
title: "辅助单位",
dataIndex: "productionUnit",
key: "productionUnit",
search: false,
valueType: "select",
request: async () => [
{
value: 0,
label: "数量(PCS)",
},
{
value: 1,
label: "重量",
},
{
value: 2,
label: "面积",
},
{
value: 3,
label: "容积",
},
],
request: async () => {
let res = await doFetch({url:"/ngic-base-business/sysDic/queryMaterieUnitSelect",params:{}})
return res?.data?.dataList
},
},
{
title: "单位",
dataIndex: "productionUnitType",
key: "productionUnitType",
title: "转换比",
dataIndex: "conversionRate",
key: "conversionRate",
search: false,
valueType: "select",
request: async () => {
let res = await unitSelect({ dicKey: "material_unit" });
return res?.data?.dataList ?? [];
},
valueType: "digit",
width:200
},
{
title: "操作",
valueType: "option",
width: 70,
render: (text, record, _, action) => [
<a key="delete" onClick={() => {}}>
<a key="delete" onClick={() => { }}>
删除
</a>,
],
},
],
maxLength: 3,
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