Przeglądaj źródła

商品工艺

dev
zhaoy 11 miesięcy temu
rodzic
commit
ce4816b013
4 zmienionych plików z 75 dodań i 31 usunięć
  1. +13
    -9
      src/pages/goods/goodsInfo/components/EditFrom.jsx
  2. +31
    -9
      src/pages/goods/goodsInfo/components/From.jsx
  3. +25
    -10
      src/pages/goods/goodsInfo/components/FromBatch.jsx
  4. +6
    -3
      src/pages/goods/goodsInfo/components/goodstechnologymaken.jsx

+ 13
- 9
src/pages/goods/goodsInfo/components/EditFrom.jsx Wyświetl plik

@@ -6,18 +6,22 @@ import From from './From'
import FromBatch from './FromBatch'
const EditFrom = (props) => {
const [fromdata, setfromdata] = useState([])
const [disabled, setdisabled] = useState(false)
//const [disabled, setdisabled] = useState(false)
const [sort, setsort] = useState(0)
useEffect(() => {
//setfromdata(props.fromdata)
//props.fromdata=fromdata
console.log("加载",props.UpdataStatus)
console.log("增加编辑状态值",props.UpdataStatus)
setsort(0)
if(props.fromdata.length==0){
setfromdata([])
}else{
if(props.UpdataStatus=="update"){
setdisabled(true);
//setdisabled(true);
props.fromdata.forEach(x=>{
x.disabled=true;
})
setfromdata(props.fromdata)
}
@@ -26,7 +30,7 @@ const EditFrom = (props) => {
//添加工艺步骤
const onAddClick = (value, option) => {
//setdisabled(false);
if(disabled){
if(props.UpdataStatus=="update"){
props.onUpdataStatus("update")
message.error("当前处于编辑状态无法新增,删除当前编辑工艺后在新增");
}else{
@@ -39,7 +43,7 @@ const EditFrom = (props) => {
let data = [...fromdata]
let index = fromdata.length
console.log(data)
data.push({ index: index+1, id: '', stepName: '', chnologyId: '', actionJson: '', sort: sort, goodsId: '', goodsAttributeId: '',optiondata: [], propsdata: [], isBatch: true, typeName: '' })
data.push({ index: index+1, id: '', stepName: '', chnologyId: '', actionJson: '', sort: sort, goodsId: '', goodsAttributeId: '',optiondata: [], propsdata: [], isBatch: true, typeName: '',disabled:false })
setfromdata(data)
props.onUpdataStatus("add")
}
@@ -49,8 +53,8 @@ const EditFrom = (props) => {
const onDelClick = (val) => {
let data = fromdata.filter(x => x.index != val)
setfromdata(data);
setdisabled(false);
props.onUpdataStatus("update")
//setdisabled(false);
props.onUpdataStatus("view")
}
//选择工艺步骤事件
const onHandleChange = (value, option, index) => {
@@ -90,9 +94,9 @@ const EditFrom = (props) => {
fromdata.length > 0 ?
fromdata.map((x, index) => {
return (
<ProCard title={"工序号"+x.index} bordered bodyStyle={{ padding: 15 }} headStyle={{ padding: '0px 24px' }} style={{ marginBlockEnd: 8 }} extra={<DeleteOutlined onClick={() => { onDelClick(x.index) }} />}>
<ProCard title={"工序号"+x.sort} bordered bodyStyle={{ padding: 15 }} headStyle={{ padding: '0px 24px' }} style={{ marginBlockEnd: 8 }} extra={<DeleteOutlined onClick={() => { onDelClick(x.index) }} />}>
<div style={{ float: 'left', height: '70px', lineHeight: '65px',width: '20%' }}>
<Select name="chnologyId" key={sort} style={{ width: '90px' }} defaultValue={x.chnologyId} disabled={disabled} options={props.goodstechnologydata} onChange={async (value, option) => { onHandleChange(value, option, x.index) }}></Select>
<Select name="chnologyId" key={sort} style={{ width: '90px' }} defaultValue={x.chnologyId} disabled={x.disabled} options={props.goodstechnologydata} onChange={async (value, option) => { onHandleChange(value, option, x.index) }}></Select>
</div>
<div style={{ float: 'left',width: '80%'}}>
{


+ 31
- 9
src/pages/goods/goodsInfo/components/From.jsx Wyświetl plik

@@ -6,14 +6,36 @@ import style from '../style.less'
import { useFetchData } from '@ant-design/pro-utils';
const From = (props) => {
const handleChange=(e,id)=>{
props.optiondata.forEach(x=>{
if(x.technologyactionId==id){
x.actionValue=e.target.value
}
console.log("id",id);
console.log("props.optiondata",props.optiondata);
console.log("props.fromdata",props.fromdata);
props.fromdata.forEach(v=>{
v.optiondata.forEach(x=>{
if(x.technologyactionId==id){
console.log("e.target.value",e.target.value)
x.actionValue=e.target.value
}
})
})
props.onSaveClick(props.fromdata)
console.log(props.fromdata)
}
const handlenumChange=(e,id)=>{
console.log("id",id);
console.log("props.optiondata",props.optiondata);
console.log("props.fromdata",props.fromdata);
props.fromdata.forEach(v=>{
v.optiondata.forEach(x=>{
if(x.technologyactionId==id){
console.log("e.target.value",e)
x.actionValue=e
}
})
})
console.log(props.fromdata)
props.onSaveClick(props.fromdata)
}
const handleselectChange=(e,id)=>{
console.log(e)
console.log(id)
@@ -34,25 +56,25 @@ const handleselectChange=(e,id)=>{
if(x.actionType=="text"){
return <>
<div className={style['formlable']} style={{ display: 'block', float: 'left' }}>{x.actionName}</div>
<div style={{ display: 'block', float: 'left' }}><Input defaultValue={props.optiondata[index].actionValue} style={{width:260}} onChange={(value)=>{handleChange(value,x.id)}}/></div>
<div style={{ display: 'block', float: 'left' }}><Input key={x.id} defaultValue={props.optiondata[index].actionValue} style={{width:260}} onChange={(value)=>{handleChange(value,x.id)}}/></div>
</>
}
if(x.actionType=="digit"){
return <>
<div className={style['formlable']} style={{ display: 'block', float: 'left' }}>{x.actionName}</div>
<div style={{ display: 'block', float: 'left' }}><InputNumber defaultValue={props.optiondata[index].actionValue} style={{width:260}} onChange={(value)=>{handleChange(value,x.id)}}/></div>
<div style={{ display: 'block', float: 'left' }}><InputNumber key={x.id} defaultValue={props.optiondata[index].actionValue} style={{width:260}} onChange={(value)=>{handlenumChange(value,x.id)}}/></div>
</>
}
if(x.actionType=="textarea"){
return <>
<div className={style['formlable']} style={{ display: 'block', float: 'left' }}>{x.actionName}</div>
<div style={{ display: 'block', float: 'left' }}><TextArea defaultValue={props.optiondata[index].actionValue} style={{width:260}} onChange={(value)=>{handleChange(value,x.id)}}/></div>
<div style={{ display: 'block', float: 'left' }}><TextArea key={x.id} defaultValue={props.optiondata[index].actionValue} style={{width:260}} onChange={(value)=>{handleChange(value,x.id)}}/></div>
</>
}
if(x.actionType=="switch"){
return <>
<div className={style['formlable']} style={{ display: 'block', float: 'left' }}>{x.actionName}</div>
<div style={{ display: 'block', float: 'left' }}><Switch defaultValue={props.optiondata[index].actionValue} onChange={(value)=>{handleChange(value,x.id)}}/></div>
<div style={{ display: 'block', float: 'left' }}><Switch key={x.id} defaultValue={props.optiondata[index].actionValue} onChange={(value)=>{handleChange(value,x.id)}}/></div>
</>
}
if(x.actionType=="select"){
@@ -65,7 +87,7 @@ const handleselectChange=(e,id)=>{
})
return <>
<div className={style['formlable']} style={{ display: 'block', float: 'left' }}>{x.actionName}</div>
<div style={{ display: 'block', float: 'left' }}><Select defaultValue={props.optiondata[index].actionValue} labelInValue options={op} style={{width:260}} onChange={(value)=>{handleselectChange(value,x.id)}}/></div>
<div style={{ display: 'block', float: 'left' }}><Select key={x.id} defaultValue={props.optiondata[index].actionValue} labelInValue options={op} style={{width:260}} onChange={(value)=>{handleselectChange(value,x.id)}}/></div>
</>
}
}):""


+ 25
- 10
src/pages/goods/goodsInfo/components/FromBatch.jsx Wyświetl plik

@@ -39,7 +39,7 @@ const FromBatch = (props) => {
]
useEffect(() => {
//setmodalVisible(props.modalVisible)
console.log("液态料",props.fromdata)
console.log("液态料",props.optiondata)
if(props.fromdata[0].optiondata.length>0){
let df=[]
props.fromdata[0].optiondata.forEach(x=>{
@@ -48,15 +48,30 @@ const FromBatch = (props) => {
setselectedRowKeys(df.map(x=>{return x.id}))
setSelectedRows(df)
}
setSelectedRows([])
setselectedRowKeys([])
},[props.modalVisible])
const handleChange=(e,id)=>{
props.optiondata.forEach(x=>{
if(x.technologyactionId==id){
x.actionValue=e.target.value
}
console.log("id",id)
console.log("props.optiondata",props.optiondata)
console.log("props.fromdata",props.fromdata)
props.fromdata.forEach(v=>{
v.optiondata.forEach(x=>{
if(x.technologyactionId==id){
console.log("e.target.value",e.target.value)
x.actionValue=e.target.value
}
})
})
props.onSaveClick(props.fromdata)
// props.fromdata[0].optiondata.forEach(x=>{
// if(x.technologyactionId==id){
// console.log("e.target.value",e.target.value)
// x.actionValue=e.target.value
// }
// })
console.log(props.fromdata)
props.onSaveClick(props.fromdata)
}
const onAddClick=()=>{
setmodalVisible(true)
@@ -64,11 +79,11 @@ const FromBatch = (props) => {
return (
<div>
{
selectedRowsState.length>0?
selectedRowsState.map((x,index)=>{
props.optiondata.length>0?
props.optiondata.map((x,index)=>{
return <>
<div className={style['formlable']} style={{ display: 'block', float: 'left' }}>{x.name}</div>
<div style={{ display: 'block', float: 'left' }}><Input defaultValue={props.optiondata[index]?.actionValue} style={{width:260}} onChange={(value)=>{handleChange(value,x.id)}}/></div>
<div className={style['formlable']} style={{ display: 'block', float: 'left' }}>{x.actionName}</div>
<div style={{ display: 'block', float: 'left' }}><Input key={x.technologyactionId} defaultValue={x.actionValue} style={{width:260}} onChange={(value)=>{handleChange(value,x.technologyactionId)}}/></div>
</>
}):""


+ 6
- 3
src/pages/goods/goodsInfo/components/goodstechnologymaken.jsx Wyświetl plik

@@ -34,7 +34,8 @@ const goodstechnologymaken = (props) => {
const [DeviceTechnologyoption, setDeviceTechnologyoption] = useState([])
const [display, setdisplay] = useState("block")
const [fromdata, setfromdata] = useState([])
const [UpdataStatus,setUpdataStatus] = useState('update')
const [UpdataStatus,setUpdataStatus] = useState('view')
const [disabled, setdisabled] = useState(false)
useEffect(() => {
interdata()
}, [])
@@ -74,6 +75,7 @@ const goodstechnologymaken = (props) => {
})
GetGoodsTechnologyAction(props.goodsid).then((r) => {
if (r.data.length > 0) {
console.log("已绑定工艺信息",r.data)
setgoodstechnolog(r.data)
// 查询最大值
var max = r.data.reduce(function (prev, current) {
@@ -232,7 +234,8 @@ const goodstechnologymaken = (props) => {
} else {
message.error("没有要保存的数据或数据格式不正确")
}
setUpdataStatus("add")
setUpdataStatus("view")
setdisabled(false)
}
return <>

@@ -301,7 +304,7 @@ const goodstechnologymaken = (props) => {
{/* extra={<Button type="primary">保存</Button>} */}
<ProCard title="编辑工艺" type='inner' colSpan="33%" bodyStyle={{ padding: 5 }} headerBordered headStyle={{ paddingLeft: '45%' }} extra={<Button onClick={() => { onSubmitSaveClick() }}>保存</Button>}>
<div style={{ textAlign: 'center', marginBottom: 10, color: 'brown' }}>{attrvalue}</div>
<EditFrom fromdata={fromdata} maxsort={maxsort} UpdataStatus={UpdataStatus} onUpdataStatus={onUpdataStatus} onSaveClick={onSaveClick} goodstechnologydata={goodstechnologydata} technologyattralldata={technologyattralldata} batchingdata={batchingdata} />
<EditFrom disabled={disabled} fromdata={fromdata} maxsort={maxsort} UpdataStatus={UpdataStatus} onUpdataStatus={onUpdataStatus} onSaveClick={onSaveClick} goodstechnologydata={goodstechnologydata} technologyattralldata={technologyattralldata} batchingdata={batchingdata} />
{/* <EditCarTable maxsort={maxsort} batchingdata={batchingdata} updadata={updadata} goodsid={props.goodsid} technologyattralldata={technologyattralldata} checkvalue={checkvalue} technologyattrdata={technologyattrdata} goodstechnologydata={goodstechnologydata} /> */}
{/* <Button type="dashed" style={{ marginTop: 10 }} onClick={onClickadd} icon={<PlusOutlined />} block>添加工艺</Button> */}
</ProCard>


Ładowanie…
Anuluj
Zapisz