|
|
@@ -1,8 +1,8 @@ |
|
|
|
import { PlusOutlined } from '@ant-design/icons'; |
|
|
|
import { Popconfirm, Modal, Button, message, Card, Col, Row,List,Select,Form,Input } from 'antd'; |
|
|
|
import { Popconfirm, Modal, Button, message, Card, Col, Row,List,Select,Form,Input,Checkbox, } from 'antd'; |
|
|
|
import React, { useEffect, useState, useRef } from 'react'; |
|
|
|
import { PageContainer, FooterToolbar } from '@ant-design/pro-layout'; |
|
|
|
import ProTable from '@ant-design/pro-table'; |
|
|
|
import ProForm from '@ant-design/pro-form'; |
|
|
|
import api from '../services'; |
|
|
|
|
|
|
|
import { BetaSchemaForm } from '@ant-design/pro-form'; |
|
|
@@ -15,13 +15,13 @@ const BomTechnology = (props) => { |
|
|
|
const [currentRow, setCurrentRow] = useState(); |
|
|
|
const [datalist, setdatalist] = useState([]); |
|
|
|
const [total, setTotal] = useState(0); |
|
|
|
const [bomtechnoVisible, setbomtechnoVisible] = useState(false); |
|
|
|
// const [check, setcheck] = useState(false); |
|
|
|
const [stockGoods, setstockGoods] = useState([]); |
|
|
|
const [technologydata, settechnologydata] = useState([]); |
|
|
|
const [gyname, setgyname] = useState(); |
|
|
|
const [goodstechnologydata, setgoodstechnologydata] = useState([]); |
|
|
|
const [goodstechnologydatabom, setgoodstechnologydatabom] = useState([]); |
|
|
|
const [datacloum, setdatacloum] = useState([]); |
|
|
|
const [datacheckbatcloum, setdatacheckbatcloum] = useState([]); |
|
|
|
const [isBatch, setisBatch] = useState(false); |
|
|
|
const [stepName,setstepName]=useState('') |
|
|
|
const [technologyId,settechnologyId]=useState(); |
|
|
@@ -51,7 +51,6 @@ const BomTechnology = (props) => { |
|
|
|
}) |
|
|
|
} |
|
|
|
if(props.bomTechnologyModalVisible){ |
|
|
|
setdatacloum() |
|
|
|
initStockGoods(); //回调原料信息 |
|
|
|
initTechnilogy(); |
|
|
|
getgetGoodstechnology(); |
|
|
@@ -79,6 +78,8 @@ const BomTechnology = (props) => { |
|
|
|
setgoodstechnologydatabom(sd) |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
//var check=false; |
|
|
|
//选择步骤事件 |
|
|
|
const onclockgan=async (id,stepName,actionjson,chnologyId,isBatch)=>{ |
|
|
|
setcolumns([]) |
|
|
@@ -94,7 +95,8 @@ const BomTechnology = (props) => { |
|
|
|
} |
|
|
|
//工艺下拉事件 |
|
|
|
const interdata=(id,option)=>{ |
|
|
|
setcolumns([]) |
|
|
|
setcolumns([]); |
|
|
|
//setdatacheckbatcloum([]); |
|
|
|
settechnologyId(id) |
|
|
|
var name=option.label; |
|
|
|
setstepName(name); |
|
|
@@ -160,6 +162,17 @@ const BomTechnology = (props) => { |
|
|
|
setcolumns(clo) |
|
|
|
}); |
|
|
|
}; |
|
|
|
const onChange=(value,e)=>{ |
|
|
|
console.log(e) |
|
|
|
console.log(value) |
|
|
|
if(e.target.checked){ |
|
|
|
datacheckbatcloum.push(value) |
|
|
|
}else{ |
|
|
|
datacheckbatcloum.splice(datacheckbatcloum.indexOf(value),1) |
|
|
|
} |
|
|
|
//check=e.target.checked |
|
|
|
console.log(datacheckbatcloum) |
|
|
|
} |
|
|
|
//处理动态表单函数(物料动态表单) |
|
|
|
const BomForminitialValue =async (value,datalist) => { |
|
|
|
var clo=[]; |
|
|
@@ -170,25 +183,84 @@ const BomTechnology = (props) => { |
|
|
|
let defaltvaluewl=''; |
|
|
|
for (let index = 0; index < data.length; index++) { |
|
|
|
defaltvaluewl=datalist?.find(it=>it.TechnologyactionId==data[index].id)?.ActionValue; |
|
|
|
//console.log(defaltvaluewl) |
|
|
|
// let check=false; |
|
|
|
// if(defaltvaluewl){ |
|
|
|
// check=true; |
|
|
|
// //datacheckbatcloum.push(this,data[index].id+':'+data[index].batchingName) |
|
|
|
// } |
|
|
|
// console.log(check) |
|
|
|
// const valueEnum = [{ label: data[index].batchingName,value:data[index].id,checked:true}]; |
|
|
|
|
|
|
|
// //const titles=()=> <Checkbox checked={check} key={data[index].id} onChange={onChange.bind(this,data[index].id+':'+data[index].batchingName)}>{data[index].batchingName}</Checkbox> |
|
|
|
// const checkboc = |
|
|
|
// { |
|
|
|
// key:data[index].id, |
|
|
|
// // title: data[index].batchingName, |
|
|
|
// valueType:"checkbox", |
|
|
|
// width: 'md', |
|
|
|
// // checked:true, |
|
|
|
// // defaultChecked:true, |
|
|
|
// //valueEnum:valueEnum, |
|
|
|
// fieldProps:{ |
|
|
|
// options:valueEnum, |
|
|
|
// }, |
|
|
|
// formItemProps:{ |
|
|
|
// checked:true, |
|
|
|
// onChange: (e) => { |
|
|
|
// onChange(e,data[index].id+':'+data[index].batchingName) |
|
|
|
// }, |
|
|
|
// } |
|
|
|
// }; |
|
|
|
// clo.push(checkboc) |
|
|
|
const titles=()=> <Checkbox key={data[index].id} onChange={onChange.bind(this,data[index].id+':'+data[index].batchingName)}>{data[index].batchingName}</Checkbox> |
|
|
|
const element = |
|
|
|
{ |
|
|
|
title: data[index].batchingName, |
|
|
|
title: titles, |
|
|
|
dataIndex:data[index].id+':'+data[index].batchingName, |
|
|
|
valueType:"text", |
|
|
|
width: 'md', |
|
|
|
initialValue:defaltvaluewl??data[index].bomQty |
|
|
|
initialValue:defaltvaluewl??0 |
|
|
|
}; |
|
|
|
clo.push(element) |
|
|
|
|
|
|
|
} |
|
|
|
console.log(clo) |
|
|
|
// const elementss = [ |
|
|
|
// { |
|
|
|
// title: '列表', |
|
|
|
// valueType: 'formList', |
|
|
|
// dataIndex: 'list', |
|
|
|
// colProps: { |
|
|
|
// xs: 24, |
|
|
|
// sm: 12, |
|
|
|
// }, |
|
|
|
// columns:clo |
|
|
|
// }]; |
|
|
|
//console.log(clo) |
|
|
|
setcolumns(clo) |
|
|
|
}; |
|
|
|
//保存数据 |
|
|
|
const onFinish=async (value)=>{ |
|
|
|
console.log(technologyId) |
|
|
|
//console.log(datacheckbatcloum) |
|
|
|
var data=[]; |
|
|
|
var parmdata={BomId:props.values.id,ChnologyId:technologyId,ActionJson:'',StepName:value.stepName,isBatch:!isBatch} |
|
|
|
var parmwldata=[] |
|
|
|
var keys=Object.keys(value); |
|
|
|
var datas=Object.keys(value); |
|
|
|
var keys=[]; |
|
|
|
if(!isBatch){ |
|
|
|
for (let index = 0; index < datas.length; index++) { |
|
|
|
let key = datas[index]; |
|
|
|
for (let y = 0; y < datacheckbatcloum.length; y++) { |
|
|
|
let fg = datacheckbatcloum[y]; |
|
|
|
if(key==fg){ |
|
|
|
keys.push(key); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}else{ |
|
|
|
keys=datas; |
|
|
|
} |
|
|
|
for (var i in keys) { |
|
|
|
if(keys[i]!="stepName"){ |
|
|
|
var parm={TechnologyactionId:'',ActionName:'',ActionValue:''} |
|
|
@@ -207,10 +279,6 @@ const BomTechnology = (props) => { |
|
|
|
} |
|
|
|
} |
|
|
|
parmdata.ActionJson=JSON.stringify(data) |
|
|
|
// console.log(parmdata.ActionJson.length) |
|
|
|
// console.log(parmwldata) |
|
|
|
// console.log(parmdata) |
|
|
|
|
|
|
|
if(parmdata.ActionJson.length<=2){ |
|
|
|
message.error("请选择工艺并配置相关动作步骤"); |
|
|
|
return false; |
|
|
@@ -298,12 +366,12 @@ const BomTechnology = (props) => { |
|
|
|
<BetaSchemaForm |
|
|
|
layoutType="Embed" |
|
|
|
grid={true} |
|
|
|
rowProps={{gutter: [16,16]}} |
|
|
|
colProps={{span: 12}} |
|
|
|
// rowProps={{gutter: [17,17]}} |
|
|
|
// colProps={{span: 20}} |
|
|
|
shouldUpdate={true} |
|
|
|
formItemProps={{ |
|
|
|
forceRender: true, |
|
|
|
labelAlign:'right', |
|
|
|
labelAlign:'left', |
|
|
|
}} |
|
|
|
columns={columns} |
|
|
|
/> |
|
|
@@ -311,7 +379,7 @@ const BomTechnology = (props) => { |
|
|
|
<Button type="primary" htmlType="submit" style={{right:10}} >保存</Button> |
|
|
|
<Button htmlType="button" onClick={props.onCancel} >取消</Button> |
|
|
|
</Form.Item> |
|
|
|
</Form> |
|
|
|
</Form> |
|
|
|
</Card> |
|
|
|
</Col> |
|
|
|
</Row> |
|
|
|