Browse Source

添加工艺判断是否已经存在

kitchenmanage
zhaoy 7 months ago
parent
commit
a06d005130
2 changed files with 58 additions and 48 deletions
  1. +46
    -25
      src/pages/database/goods/goodstechnology/components/EditFrom.jsx
  2. +12
    -23
      src/pages/database/goods/goodstechnology/components/goodstechnologymaken.jsx

+ 46
- 25
src/pages/database/goods/goodstechnology/components/EditFrom.jsx View File

@@ -5,10 +5,16 @@ import { DeleteOutlined, CloseOutlined } from '@ant-design/icons';
import From from '../components/From' import From from '../components/From'
import FromBatch from '../components/FromBatch' import FromBatch from '../components/FromBatch'
import { useFetchData } from '@ant-design/pro-utils'; import { useFetchData } from '@ant-design/pro-utils';
import {
GetGoodsTechnologyAction,
} from '../../goodsInfo/service';

const EditFrom = (props) => { const EditFrom = (props) => {
const [fromdata, setfromdata] = useState([]) const [fromdata, setfromdata] = useState([])
//const [disabled, setdisabled] = useState(false) //const [disabled, setdisabled] = useState(false)
const [sort, setsort] = useState(1) const [sort, setsort] = useState(1)
//工艺值
const [goodstechnolog, setgoodstechnolog] = useState([]);
useEffect(() => { useEffect(() => {
//setfromdata(props.fromdata) //setfromdata(props.fromdata)
//props.fromdata=fromdata //props.fromdata=fromdata
@@ -25,36 +31,51 @@ const EditFrom = (props) => {
} }
} }

GetGoodsTechnologyAction(props.goodsId).then((r) => {
setgoodstechnolog(r.data)
})
},[props.fromdata]) },[props.fromdata])
//添加工艺步骤 //添加工艺步骤
const onAddClick = (value, option) => { const onAddClick = (value, option) => {
//setdisabled(false);
if(props.devideId=="0"){
message.error("请选择设备后在新增");
// else if(props.UpdataStatus=="update"){
// props.onUpdataStatus("update")
// message.error("当前处于编辑状态无法新增,删除当前编辑工艺后在新增");
}else{
let so=sort;
console.log("fromdata",fromdata)
setsort(sort+1)
let data = [...fromdata]
let index = fromdata.length
if(fromdata.length==0){
so=1;
}else{
var max = fromdata.reduce(function (prev, current) {
return (prev.sort > current.sort) ? prev : current;
});
console.log("最大序号:", max.sort)
so=max.sort+1;
//判断是否已存在当前属性
if(props.devideId=="0")
{
message.error("请选择设备后在新增")
}
else{
const exist=goodstechnolog.find(item=>item.deviceId==props.devideId && item.goodsAttributeId==props.goodsAttributeId)
if(exist!=null)
{
message.error("已存在该工艺,请编辑")

} }
data.push({ index: index+1, id: '', stepName: '', chnologyId: '', actionJson: '', sort: so, goodsId: '', goodsAttributeId: '',optiondata: [], propsdata: [], isBatch: true, typeName: '',disabled:false })
setfromdata(data)
props.onUpdataStatus("add")
else
{
let so=sort;
console.log("fromdata",fromdata)
setsort(sort+1)
let data = [...fromdata]
let index = fromdata.length
if(fromdata.length==0){
so=1;
}else{
var max = fromdata.reduce(function (prev, current) {
return (prev.sort > current.sort) ? prev : current;
});
console.log("最大序号:", max.sort)
so=max.sort+1;
}
data.push({ index: index+1, id: '', stepName: '', chnologyId: '', actionJson: '', sort: so, goodsId: '', goodsAttributeId: '',optiondata: [], propsdata: [], isBatch: true, typeName: '',disabled:false })
setfromdata(data)
props.onUpdataStatus("add")
}

} }
} }
//删除工艺 //删除工艺
const onDelClick = (val) => { const onDelClick = (val) => {


+ 12
- 23
src/pages/database/goods/goodstechnology/components/goodstechnologymaken.jsx View File

@@ -36,6 +36,7 @@ const goodstechnologymaken = (props) => {
const [technologyattralldata, setTechnologyattralldata] = useState([]); const [technologyattralldata, setTechnologyattralldata] = useState([]);
const [goodsinfo, setGoodsinfo] = useState({}); const [goodsinfo, setGoodsinfo] = useState({});
const [cardcount, setCardcount] = useState([]); const [cardcount, setCardcount] = useState([]);
//工艺值
const [goodstechnolog, setgoodstechnolog] = useState([]); const [goodstechnolog, setgoodstechnolog] = useState([]);
const [maxsort, setmaxsort] = useState(1); const [maxsort, setmaxsort] = useState(1);
const [batchingdata, setbatchingdata] = useState([]); const [batchingdata, setbatchingdata] = useState([]);
@@ -58,28 +59,19 @@ const goodstechnologymaken = (props) => {
//新建/分布式弹窗 //新建/分布式弹窗
const [showPopup, setShowPopup] = useState(false) const [showPopup, setShowPopup] = useState(false)
const [isModalOpen, setIsModalOpen] = useState(false); const [isModalOpen, setIsModalOpen] = useState(false);
const [title, setTitle] = useState('初始标题');
const handleCancel = () => { const handleCancel = () => {
setShowPopup(false); setShowPopup(false);
setIsModalOpen(false); setIsModalOpen(false);
}; };

const actionRef = useRef(); const actionRef = useRef();
//打开弹窗
const handleButtonClick = () => { const handleButtonClick = () => {
setShowPopup(true); setShowPopup(true);
setIsModalOpen(true); setIsModalOpen(true);
};

const handleOk = () => {
showPopup(false);
setIsModalOpen(false);


}; };


useEffect(() => { useEffect(() => {
interdata() interdata()
@@ -105,7 +97,6 @@ const goodstechnologymaken = (props) => {
}) })
}) })
} }
console.log("商品属性", res.data)
setGoodsinfo(res.data) setGoodsinfo(res.data)
var it = [ var it = [
// {key:'1',label:'',children:(<div><img style={{width:100,height:100}} src={res.data.imgUrl}></img></div>)}, // {key:'1',label:'',children:(<div><img style={{width:100,height:100}} src={res.data.imgUrl}></img></div>)},
@@ -123,8 +114,10 @@ const goodstechnologymaken = (props) => {


GetGoodsTechnologyAction(props.goodsid).then((r) => { GetGoodsTechnologyAction(props.goodsid).then((r) => {
if (r.data.length > 0) {
if (r.data.length > 0)
{
setgoodstechnolog(r.data) setgoodstechnolog(r.data)
// 查询最大值 // 查询最大值
var max = r.data.reduce(function (prev, current) { var max = r.data.reduce(function (prev, current) {
return (prev.sort > current.sort) ? prev : current; return (prev.sort > current.sort) ? prev : current;
@@ -147,7 +140,6 @@ const goodstechnologymaken = (props) => {
}) })
} }
const onChangevalue = (e) => { const onChangevalue = (e) => {

const { name, value } = e.target; const { name, value } = e.target;
let names = ""; let names = "";
let updatedValues = [...checkvalue]; let updatedValues = [...checkvalue];
@@ -159,8 +151,6 @@ const goodstechnologymaken = (props) => {
} }


} }


let newId = null; let newId = null;
goodsinfo.goodsAttributeList.forEach(item => { goodsinfo.goodsAttributeList.forEach(item => {
for (let index = 0; index < updatedValues.length; index++) { for (let index = 0; index < updatedValues.length; index++) {
@@ -382,9 +372,9 @@ const goodstechnologymaken = (props) => {
}) })
} }
//选择设备 //选择设备
const handleChange = (value) => {
const handleChange = (value) =>
{
//判断多属性是都选择完成 //判断多属性是都选择完成
console.log(goodsinfo);
let ischeck=false; let ischeck=false;
goodsinfo.goodsAttributeList.forEach(x => goodsinfo.goodsAttributeList.forEach(x =>
{ {
@@ -567,6 +557,7 @@ const goodstechnologymaken = (props) => {
OldgoodsId: record.goodsId, OldgoodsId: record.goodsId,
goodsAttributeId: record.goodsAttributeId, goodsAttributeId: record.goodsAttributeId,
NewgoodsId: props.goodsid, NewgoodsId: props.goodsid,
DevideId:devideId,
NewgoodsAttributeId: checkvalue.join(',') NewgoodsAttributeId: checkvalue.join(',')
}; };
await CopyTechnologyaction(data).then((r) => { await CopyTechnologyaction(data).then((r) => {
@@ -633,7 +624,7 @@ const goodstechnologymaken = (props) => {
{ {
item.goodsAttributeValueList.map((x, index) => { item.goodsAttributeValueList.map((x, index) => {
return ( return (
<Radio.Button key={index} name={index} checked={true} value={x.goodsAttributeValuId} style={{ marginRight: 22, marginTop: 10 }}>{x.attributeValue}</Radio.Button>
<Radio.Button key={index} name={index} checked={false} value={x.goodsAttributeValuId} style={{ marginRight: 22, marginTop: 10 }}>{x.attributeValue}</Radio.Button>
) )
}) })
} }
@@ -703,7 +694,7 @@ const goodstechnologymaken = (props) => {
] ]
}> }>
<div style={{ textAlign: 'center', marginBottom: 10, color: 'brown' }}>{attrvalue}</div> <div style={{ textAlign: 'center', marginBottom: 10, color: 'brown' }}>{attrvalue}</div>
<EditFrom devideId={devideId} disabled={disabled} fromdata={fromdata} maxsort={maxsort} UpdataStatus={UpdataStatus} onUpdataStatus={onUpdataStatus} onSaveClick={onSaveClick} goodstechnologydata={goodstechnologydata} technologyattralldata={technologyattralldata} batchingdata={batchingdata} />
<EditFrom devideId={devideId} goodsId={props.goodsid} goodsAttributeId={checkvalue.join(',')} disabled={disabled} fromdata={fromdata} maxsort={maxsort} UpdataStatus={UpdataStatus} onUpdataStatus={onUpdataStatus} onSaveClick={onSaveClick} goodstechnologydata={goodstechnologydata} technologyattralldata={technologyattralldata} batchingdata={batchingdata} />
</ProCard> </ProCard>
<ProCard title="查看工艺" type='inner' headStyle={{ paddingLeft: '45%' }} bodyStyle={{ padding: 5, width: '1072px', 'overflow-x': 'scroll' }} headerBordered> <ProCard title="查看工艺" type='inner' headStyle={{ paddingLeft: '45%' }} bodyStyle={{ padding: 5, width: '1072px', 'overflow-x': 'scroll' }} headerBordered>
<div style={{ width: 'max-content' }}> <div style={{ width: 'max-content' }}>
@@ -775,12 +766,10 @@ const goodstechnologymaken = (props) => {
<Modal title="工艺属性" open={isModalOpen} onCancel={handleCancel} width={1040} bodyStyle={{ padding: '32px 40px 1px 48px' }} visible={showPopup} footer={null}> <Modal title="工艺属性" open={isModalOpen} onCancel={handleCancel} width={1040} bodyStyle={{ padding: '32px 40px 1px 48px' }} visible={showPopup} footer={null}>
{( {(
<ProTable <ProTable
actionRef={actionRef}
pagination={false} pagination={false}
request={async (params) => { request={async (params) => {
var goodsData = []; var goodsData = [];
params.deviceId=devideId; params.deviceId=devideId;
debugger
await GeDeviceTechnologyaction(params).then((r) => { await GeDeviceTechnologyaction(params).then((r) => {
goodsData =r.data; goodsData =r.data;
}); });


Loading…
Cancel
Save