Kaynağa Gözat

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

kitchenmanage
zhaoy 7 ay önce
ebeveyn
işleme
a06d005130
2 değiştirilmiş dosya ile 58 ekleme ve 48 silme
  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 Dosyayı Görüntüle

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

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

GetGoodsTechnologyAction(props.goodsId).then((r) => {
setgoodstechnolog(r.data)
})
},[props.fromdata])
//添加工艺步骤
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) => {


+ 12
- 23
src/pages/database/goods/goodstechnology/components/goodstechnologymaken.jsx Dosyayı Görüntüle

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

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

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


};

useEffect(() => {
interdata()
@@ -105,7 +97,6 @@ const goodstechnologymaken = (props) => {
})
})
}
console.log("商品属性", res.data)
setGoodsinfo(res.data)
var it = [
// {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) => {
if (r.data.length > 0) {
if (r.data.length > 0)
{
setgoodstechnolog(r.data)
// 查询最大值
var max = r.data.reduce(function (prev, current) {
return (prev.sort > current.sort) ? prev : current;
@@ -147,7 +140,6 @@ const goodstechnologymaken = (props) => {
})
}
const onChangevalue = (e) => {

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

}


let newId = null;
goodsinfo.goodsAttributeList.forEach(item => {
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;
goodsinfo.goodsAttributeList.forEach(x =>
{
@@ -567,6 +557,7 @@ const goodstechnologymaken = (props) => {
OldgoodsId: record.goodsId,
goodsAttributeId: record.goodsAttributeId,
NewgoodsId: props.goodsid,
DevideId:devideId,
NewgoodsAttributeId: checkvalue.join(',')
};
await CopyTechnologyaction(data).then((r) => {
@@ -633,7 +624,7 @@ const goodstechnologymaken = (props) => {
{
item.goodsAttributeValueList.map((x, index) => {
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>
<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 title="查看工艺" type='inner' headStyle={{ paddingLeft: '45%' }} bodyStyle={{ padding: 5, width: '1072px', 'overflow-x': 'scroll' }} headerBordered>
<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}>
{(
<ProTable
actionRef={actionRef}
pagination={false}
request={async (params) => {
var goodsData = [];
params.deviceId=devideId;
debugger
await GeDeviceTechnologyaction(params).then((r) => {
goodsData =r.data;
});


Yükleniyor…
İptal
Kaydet