From c5eec0a94612d82d7c480ea31094cb27a6b3c65e Mon Sep 17 00:00:00 2001 From: zhaoy <137053305@qq.com> Date: Tue, 27 Feb 2024 15:02:38 +0800 Subject: [PATCH] z --- .../components/goodstechnologymaken.jsx | 105 ++++++++++-------- src/pages/device/deviceVesion/index.jsx | 12 +- .../productmanage/components/CreateForm.jsx | 34 +++++- src/pages/device/productmanage/index.jsx | 44 ++++---- .../components/CreateForm.jsx | 18 +-- src/pages/device/warehousepostion/index.jsx | 2 +- 6 files changed, 121 insertions(+), 94 deletions(-) diff --git a/src/pages/database/goods/goodstechnology/components/goodstechnologymaken.jsx b/src/pages/database/goods/goodstechnology/components/goodstechnologymaken.jsx index 4448e59..331b79b 100644 --- a/src/pages/database/goods/goodstechnology/components/goodstechnologymaken.jsx +++ b/src/pages/database/goods/goodstechnology/components/goodstechnologymaken.jsx @@ -50,7 +50,6 @@ const goodstechnologymaken = (props) => { interdata() }, []) const interdata = () => { - console.log("props.goodsid",props.goodsid) if(props.goodsid!=undefined){ getbyidgoods(props.goodsid).then((res) => { if (res.succeeded) { @@ -125,8 +124,6 @@ const goodstechnologymaken = (props) => { }) } const onChangevalue = (e) => { - console.log(checkvalue) - const { name, value } = e.target; let names = ""; let updatedValues = [...checkvalue]; @@ -169,21 +166,27 @@ const goodstechnologymaken = (props) => { setdefaultValue(item.deviceId) setddevideId(item.deviceId) GetGoodsTechnologyvalue(item.deviceId,"edit",item) + var atrid=[] var gg=goodsinfo.goodsAttributeList.map(x => { + x.goodsAttributeValueList.forEach(t=>{ var da=item.goodsAttributeId.split(',') var df=da.find(g=>g==t.goodsAttributeValuId) if(df){ t.check=true; x.defalutvalue=t.goodsAttributeValuId + atrid.push(t.goodsAttributeValuId) + } - }) + return x }) const nextItems = {...goodsinfo,goodsAttributeList:gg}; var goodsinfos=nextItems - console.log("goods",goodsinfos) + setCheckvalue(atrid) + console.log("checkvalue",atrid) + setCheckvalue(atrid) setGoodsinfo(goodsinfos) //console.log("attr", attr) @@ -229,20 +232,11 @@ const goodstechnologymaken = (props) => { } const GetGoodsTechnologyvalue=(value,va,item)=>{ let godata=[] - console.log("va",va) - console.log("value",value) - console.log("item",item) - console.log("goodsinfo.goodsAttributeList",goodsinfo.goodsAttributeList) - if(item){ GetwarehousetemplateData(item.deviceId) setWarehousrTemplateId(item.warehousrTemplateId) setdefaulttemplateValue(item.warehousrTemplateId) - - } - - GetGoodsTechnology(value).then((r)=>{ if (r.data.length > 0) { var Technologyacton=[]; @@ -255,7 +249,6 @@ const goodstechnologymaken = (props) => { } return { value: x.id, label: x.name } }) - console.log("godata",godata) setTechnologyattralldata(Technologyacton) setgoodstechnologydata(godata) }else{ @@ -274,8 +267,6 @@ const goodstechnologymaken = (props) => { DeleteGoodsTechnologyAction(item.id).then((res) => { if (res.data) { message.success("删除成功") - console.log(fromdata) - //formRef?.current?.resetFields(...props.technologyattrdata) updadata() } else { message.error("删除失败") @@ -283,12 +274,37 @@ const goodstechnologymaken = (props) => { }) } //删除设备工艺 - const onClickDevicedele = (e, devideId, action) => { - deletebydevidegoodstechnologyaction({ devideId: devideId, goodsId: props.goodsid }).then((res) => { + const onClickDevicedele = (e, devideId,goodsAttributeId, action) => { + if(goodstechnologydata.length>0){ + setgoodstechnologydata([]) + } + if(fromdata.length>0){ + setfromdata([]) + } + if(defaultValue==devideId){ + setdefaultValue('') + setcwdis("none") + setdefaulttemplateValue() + } + if(checkvalue.find(x=>goodsAttributeId.includes(x))){ + var gg=goodsinfo.goodsAttributeList.map(x => { + x.goodsAttributeValueList.forEach(t=>{ + t.check=false; + x.defalutvalue="" + setCheckvalue([]) + }) + return x + }) + const nextItems = {...goodsinfo,goodsAttributeList:gg}; + var goodsinfos=nextItems + setGoodsinfo(goodsinfos) + setCheckvalue([]) + } + //console.log(goodstechnologydata) + deletebydevidegoodstechnologyaction({ devideId: devideId, goodsId: props.goodsid,goodsAttributeId:goodsAttributeId }).then((res) => { if (res.data) { message.success("删除成功") setgoodstechnolog([]) - //formRef?.current?.resetFields(...props.technologyattrdata) updadata() } else { message.error("删除失败") @@ -316,14 +332,10 @@ const goodstechnologymaken = (props) => { const GetwarehousetemplateData=(deviceId)=>{ setcwdis('block') GetwarehousetemplateList(deviceId).then((r)=>{ - // var data= r.data.map(x=>{ - // return {id:x.id,label:x.templateName} - // }) setwarehousetemplatedata(r.data) }) } const handleChange = (value) => { - console.log("进来了", value) setdefaulttemplateValue("") if(value){ setdefaultValue(value) @@ -335,30 +347,14 @@ const goodstechnologymaken = (props) => { setdefaultValue("") setddevideId('') } - - // let sd = DeviceTechnologydata.find(x => x.id == value); - // if (sd) { - // if (sd.goodsTechnologyInfo.length > 0) { - // godata = sd.goodsTechnologyInfo.map(x => { - // return { value: x.deviceTechnologyId, label: x.name } - // }) - - // setgoodstechnologydata(godata) - // } - // setfromdata([]) - // } - // console.log("godata", godata) - // setgoodstechnologydata(godata) } const onUpdataStatus = (val) => { setUpdataStatus(val) } const onSaveClick = (val) => { - console.log("222",val) setfromdata(val) } const onSubmitSaveClick = () => { - console.log("保存的数据", fromdata) let check = true; var data = [] var msg="没有要保存的数据或数据格式不正确"; @@ -393,22 +389,22 @@ const goodstechnologymaken = (props) => { } }) - - - // var vacheck=x.optiondata.find(x=>x.actionValue=='') - item.goodsId = props.goodsid item.warehousrTemplateId=WarehousrTemplateId; item.goodsAttributeId = checkvalue.join(',') if (x.chnologyId == "") { check = false; } + if(item.warehousrTemplateId==undefined || item.warehousrTemplateId==""){ + check = false; + msg="请选择仓位模板" + } + if(item.goodsAttributeId==undefined || item.goodsAttributeId==""){ + check = false; + msg="请选择商品属性" + } data.push(item) }) - if(WarehousrTemplateId==""){ - check = false; - msg="请选择仓位模板" - } if (data.length > 0 && check) { if (UpdataStatus == "add") { AddGoodsTechnologyAction(data).then((res) => { @@ -433,6 +429,17 @@ const goodstechnologymaken = (props) => { }) } + var gg=goodsinfo.goodsAttributeList.map(x => { + x.goodsAttributeValueList.forEach(t=>{ + t.check=false; + x.defalutvalue="" + }) + return x + }) + const nextItems = {...goodsinfo,goodsAttributeList:gg}; + var goodsinfos=nextItems + setGoodsinfo(goodsinfos) + setCheckvalue([]) setUpdataStatus("view") setdisabled(false) setopreaction("add") @@ -557,7 +564,7 @@ const goodstechnologymaken = (props) => { { onClickDevicedele(e, x.deviceId) }} + onConfirm={(e) => { onClickDevicedele(e, x.deviceId,x.goodsAttributeId) }} onCancel={cancel} okText="确定" cancelText="取消" diff --git a/src/pages/device/deviceVesion/index.jsx b/src/pages/device/deviceVesion/index.jsx index eda0339..fcef156 100644 --- a/src/pages/device/deviceVesion/index.jsx +++ b/src/pages/device/deviceVesion/index.jsx @@ -203,14 +203,16 @@ const handleRemove = async (selectedRows) => { setCurrentRow(record); const tempUploadImage = JSON.parse(JSON.stringify([ { - uid: '-1', - name: 'image.png', - status: 'done', url: '', }, ])); - tempUploadImage[0].url=record.productUrl; - setFileList(tempUploadImage); + if(record.productUrl){ + tempUploadImage[0].url=record.productUrl; + setFileList(tempUploadImage); + }else{ + setFileList([]) + } + // form.setFielsValue(record) }} > 更新, { const { Option, OptGroup } = Select; @@ -14,6 +15,7 @@ const CreateForm = (props) => { const [displaylength,setdisplaylength]=useState('none'); const [displaytxtjson,setdisplaytxtjson]=useState('none'); const [disabledname,setdisabledname]=useState('false'); + const [displayleventType,setdisplayleventType]=useState('none'); const [minnumber, setminnumber] = useState(0); const [maxnumber, setmaxnumber] = useState(1); const [ReadWrite, setReadWrite] = useState(0); @@ -106,7 +108,6 @@ const CreateForm = (props) => { } },[props?.values]) const onchagetype=(e)=>{ - console.log(e) setarttue(e.target.value) form.setFieldsValue({ type: e.target.value @@ -117,12 +118,23 @@ const onchagetype=(e)=>{ setdisplaybool('none') setdisaenumbled('none') setdisanumbled('none') + setdisplayleventType("none") }else if(e.target.value==0){ setdisplay("block") + setdisplayleventType("none") form.setFieldsValue({ dataType: "digit" }); setdisanumbled("block") + }else if(e.target.value==2){ + setdisplayleventType("block") + setdisplay("none") + setdisanumbled('none') + setdisplaylength('none') + setdisplaybool('none') + form.setFieldsValue({ + eventType: 0 + }); } } const onChangemix=(value)=>{ @@ -187,6 +199,11 @@ const onChangeboolLabel0=(e)=>{ const onChangeboolLabel1=(e)=>{ setboolLabel1(e.target.value) +} +const onChangeeventType=(e)=>{ + form.setFieldsValue({ + eventType: e.target.value + }); } return ( { boolLabel: boolLabel0+":"+boolLabel1 }); } - - console.log(form.getFieldsValue()) + console.log("form.getFieldsValue()",form.getFieldsValue()) props?.onFinish(form.getFieldsValue()) }} > @@ -235,6 +251,7 @@ const onChangeboolLabel1=(e)=>{ 属性 服务 + 事件 @@ -303,6 +320,13 @@ const onChangeboolLabel1=(e)=>{ + 事件类型} rules={[{ required: false }]}> + + 信息 + 告警 + 故障 + +