From 2ca84c11f1d60de514eadf2853151ce20b99e1ff Mon Sep 17 00:00:00 2001 From: zhaoy <137053305@qq.com> Date: Fri, 26 Jan 2024 16:23:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E9=85=8D=E6=96=B9=E5=AE=8C?= =?UTF-8?q?=E5=96=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../goodsInfo/components/BomBatching.jsx | 148 ++++++++++++++++++ .../goods/goodsInfo/components/CreateBom.jsx | 6 +- .../goods/goodsInfo/components/UpdateBom.jsx | 108 +++++++++++++ src/pages/database/goods/goodsInfo/index.jsx | 85 ++++++---- src/pages/database/goods/goodsInfo/service.js | 18 +++ 5 files changed, 328 insertions(+), 37 deletions(-) create mode 100644 src/pages/database/goods/goodsInfo/components/BomBatching.jsx create mode 100644 src/pages/database/goods/goodsInfo/components/UpdateBom.jsx diff --git a/src/pages/database/goods/goodsInfo/components/BomBatching.jsx b/src/pages/database/goods/goodsInfo/components/BomBatching.jsx new file mode 100644 index 0000000..4435a14 --- /dev/null +++ b/src/pages/database/goods/goodsInfo/components/BomBatching.jsx @@ -0,0 +1,148 @@ +import React, { useState,useRef,useEffect } from 'react'; +import { PlusOutlined} from '@ant-design/icons'; +import { Modal, Form, Input, Button, Select,Radio,message,Tag,Divider,Space } from 'antd'; +import { GetByidBomList } from '../service'; +import { + EditableProTable, + ProTable +} from '@ant-design/pro-table'; +const GoodsbomFrom = (props) => { + const { Option, OptGroup } = Select; + const [dataSource, setDataSource] = useState([]); + const [editableKeys, setEditableRowKeys] = useState([]); + const [form] = Form.useForm(); + + useEffect(() => { + let soredata=[]; + if(props.BomId){ + GetByidBomList(props.BomId).then((t)=>{ + var data=t.data + if(data.bomEntry.length>0){ + data.bomEntry.map(x=>{ + var item={ + id:x.id, + bomId:x.bomId, + batchingId:x.batchingId, + dosage:x.bomQty + } + console.log("item",item) + soredata.push(item) + }) + } + console.log("soredata",soredata) + if(soredata.length>0){ + setEditableRowKeys(soredata.map((item) => item.id)) + setDataSource(soredata); + } + }) + } + + + },[props]) + const columns=[ + { + title: '主键', + dataIndex: 'id', + key: 'id', + hideInTable: true, + hideInSearch: true, + tip: '规则名称是唯一的 key', + }, + { + title: '配方', + dataIndex: 'bomId', + hideInTable: true, + hideInSearch: true, + }, + { + title: '物料名称', + dataIndex: 'batchingId', + formItemProps: (form, { rowIndex }) => { + return { + rules: + rowIndex > 1 ? [{ required: true, message: '此项为必填项' }] : [], + }; + }, + valueType: 'select', + fieldProps: { + showSearch:true, + options: props.matedata.map((item, index) => {return {label:item.name,value:item.id}}) + }, + width: '25%', + }, + { + title: '用量', + dataIndex: 'dosage', + valueType:'digit', + width: '15%', + }, + { + title: '操作', + valueType: 'option', + width: '15%', + render: () => { + return null; + }, + }, +] + const headleOk=()=>{ + if(dataSource.length==0){ + check=false; + message.error("请选择物料") + }else{ + props.onBomBatchingFinish(dataSource); + setDataSource([]) + } + + + } + return ( + { + props.onBomBatchingCancel(); + }} + destroyOnClose + > + ({ + id: Date.now(), + bomId:props.BomId + }), + }} + + editable={{ + type: 'multiple', + editableKeys, + actionRender: (row, config, defaultDoms) => { + return [defaultDoms.delete,defaultDoms.Button]; + }, + onValuesChange: (record, recordList) => { + setDataSource(recordList); + }, + onDelete:async (key, row) =>{ + console.log(key) + console.log(row) + + }, + onChange: setEditableRowKeys, + }}/> + + + //vessels + ); +}; + +export default GoodsbomFrom; diff --git a/src/pages/database/goods/goodsInfo/components/CreateBom.jsx b/src/pages/database/goods/goodsInfo/components/CreateBom.jsx index e322a06..bb952ff 100644 --- a/src/pages/database/goods/goodsInfo/components/CreateBom.jsx +++ b/src/pages/database/goods/goodsInfo/components/CreateBom.jsx @@ -8,15 +8,11 @@ import { } from '@ant-design/pro-table'; const GoodsbomFrom = (props) => { const { Option, OptGroup } = Select; - const [selectedRows, setSelectedRows] = useState([]); - const [getGoodsBoms, setGoodsBoms] = useState([]); const [checkvalue, setCheckvalue] = useState([]); const [dataSource, setDataSource] = useState([]); const [editableKeys, setEditableRowKeys] = useState([]); - const actionRef = useRef(); const [form] = Form.useForm(); const [typename, settypename] = useState(''); - const inputRef = useRef(null); const onNameChange=(event)=>{ settypename(event.target.value); @@ -56,7 +52,7 @@ const GoodsbomFrom = (props) => { setEditableRowKeys(soredata.map((item) => item.id)) setDataSource(soredata); } - },[]) + },[props]) const columns=[ { title: '物料名称', diff --git a/src/pages/database/goods/goodsInfo/components/UpdateBom.jsx b/src/pages/database/goods/goodsInfo/components/UpdateBom.jsx new file mode 100644 index 0000000..4fbb8c1 --- /dev/null +++ b/src/pages/database/goods/goodsInfo/components/UpdateBom.jsx @@ -0,0 +1,108 @@ +import React, { useState,useRef,useEffect } from 'react'; +import { PlusOutlined} from '@ant-design/icons'; +import { Modal, Form, Input, Button, Select,Divider,Space,message} from 'antd'; +import { GetByidBomList,AddBomType } from '../service'; +const UpdateBom = (props) => { + const { Option, OptGroup } = Select; + const [form] = Form.useForm(); + const [typename, settypename] = useState(''); + const inputRef = useRef(null); + useEffect(() => { + if(props.BomId){ + GetByidBomList(props.BomId).then((t)=>{ + var data=t.data + form.setFieldsValue({ + bomName:data.name, + bomTypeList:data.bomTypeIds, + bomType:data.isMain?'1':'0' + }) + }) + } + + }) + const onNameChange=(event)=>{ + settypename(event.target.value); + } + const addItem=(e)=>{ + e.preventDefault(); + settypename(''); + var parm={name:typename} + AddBomType(parm).then((r)=>{ + if(r.succeeded){ + message.success('添加成功'); + props.initTypeList() + }else{ + message.error(r.errors); + } + }) + } + const headleOk=()=>{ + props.onUpdateBomSave(form) + } + return ( + { + props.onUpdateBomCancel(); + }} + destroyOnClose + > +
+ + + + + + e.stopPropagation()} + /> + + + + )} + /> + + + + + +
+
+ ); +}; + +export default UpdateBom; diff --git a/src/pages/database/goods/goodsInfo/index.jsx b/src/pages/database/goods/goodsInfo/index.jsx index 89d0894..b55ae4d 100644 --- a/src/pages/database/goods/goodsInfo/index.jsx +++ b/src/pages/database/goods/goodsInfo/index.jsx @@ -7,8 +7,10 @@ import ProTable from '@ant-design/pro-table'; import GoodsbomFrom from './components/GoodsbomFrom'; import CreateBom from './components/CreateBom'; import GoodsTechnologyMaken from './components/goodstechnologymaken' -import { addGoods, goodsType, goodsbigType, getgoodsTaste } from '../newgoods/service'; -import { GetGoodsBom, AddBomApi, DelGoodsBom, GetCosRequestURL,gettree, unitList,getbygoodsidattribute,addgoodsbomattribute,GetbomTypelist,getproductpage,addunit,getbomlist,addgoodsbom } from './service' +import UpdateBom from './components/UpdateBom' +import BomBatching from './components/BomBatching' +import { addGoods} from '../newgoods/service'; +import { GetGoodsBom, UpdateBomInfo, DelGoodsBom, GetCosRequestURL,gettree, unitList,getbygoodsidattribute,addgoodsbomattribute,GetbomTypelist,getproductpage,addunit,getbomlist,addgoodsbom,UpdateBomBatcing } from './service' import axios from 'axios'; import { history } from 'umi'; const { Step } = Steps; @@ -36,7 +38,9 @@ const Advanced = (props) => { const inputRef = useRef(null); const [Bomdata, setBomdata] = useState([]); const [BomIds, setBomIds] = useState([]); - + const [BomId, setBomId] = useState(); + const [UpdateBomVisible, setUpdateBomVisible] = useState(false); + const [BomBatchingVisible,setBomBatchingVisible]= useState(false); //事件 const onFinish = async (values) => { const hide = message.loading('正在执行'); @@ -225,7 +229,46 @@ const Advanced = (props) => { tab: '商品工艺', }, ]; - + const onUpdateBomCancel=()=>{ + setUpdateBomVisible(false); + setBomId('') + } + const onBomBatchingCancel=()=>{ + setBomBatchingVisible(false); + setBomId('') + } + const onUpdateBomSave=(form)=>{ + form + .validateFields() + .then((values) => { + console.log(values) + var parm={id:BomId,name:values.bomName,IsMain:values.bomType=='1'?true:false,bomTypeIds:values.bomTypeList} + UpdateBomInfo(parm).then((r)=>{ + if(r.succeeded){ + message.success('修改成功'); + setUpdateBomVisible(false); + actionRef.current.reload(); + setBomId('') + }else{ + message.error(r.errors); + } + }) + }) + } + const onBomBatchingFinish=(form)=>{ + console.log("form",form) + var parm={bomId:BomId,bomEntry:form}; + UpdateBomBatcing(parm).then((r)=>{ + if(r.succeeded){ + message.success('修改成功'); + setBomBatchingVisible(false); + actionRef.current.reload(); + setBomId('') + }else{ + message.error(r.errors); + } + }) + } const bomcolumns = [ { @@ -266,20 +309,8 @@ const Advanced = (props) => { key="primary" type="primary" onClick={() => { - // const hide = message.loading('正在删除'); - // try { - // DelGoodsBom(record.id); - // hide(); - // message.success('删除成功,即将刷新'); - // actionRef.current.reload(); - // return true; - // } catch (error) { - // hide(); - // message.error('删除失败,请重试'); - // actionRef.current.reload(); - // return false; - // } - + setUpdateBomVisible(true); + setBomId(record.bomId) }} > 更新 @@ -288,20 +319,8 @@ const Advanced = (props) => { key="primary" type="primary" onClick={() => { - // const hide = message.loading('正在删除'); - // try { - // DelGoodsBom(record.id); - // hide(); - // message.success('删除成功,即将刷新'); - // actionRef.current.reload(); - // return true; - // } catch (error) { - // hide(); - // message.error('删除失败,请重试'); - // actionRef.current.reload(); - // return false; - // } - + setBomBatchingVisible(true); + setBomId(record.bomId) }} > 配方详情 @@ -580,6 +599,8 @@ const Advanced = (props) => { setHandleCreateoodsBomModalVisible(false); }} /> + + ), diff --git a/src/pages/database/goods/goodsInfo/service.js b/src/pages/database/goods/goodsInfo/service.js index d7bf1ac..01be0cc 100644 --- a/src/pages/database/goods/goodsInfo/service.js +++ b/src/pages/database/goods/goodsInfo/service.js @@ -164,4 +164,22 @@ export async function GetByTypebatching() { return request(`/saasbase/api/batching/getbytypebatching`, { method: 'Get', }); +} +export async function GetByidBomList(data) { + return request(`/saasbase/api/bom/getbyidbomlist?bomId=`+data, { + method: 'Get', + }); +} + +export async function UpdateBomInfo(data) { + return request(`/saasbase/api/bom/update`, { + method: 'Post', + data: data, + }); +} +export async function UpdateBomBatcing(data) { + return request(`/saasbase/api/bom/updatebombatcing`, { + method: 'Post', + data: data, + }); } \ No newline at end of file