Kaynağa Gözat

商品配方完善功能

master
zhaoy 11 ay önce
ebeveyn
işleme
2ca84c11f1
5 değiştirilmiş dosya ile 328 ekleme ve 37 silme
  1. +148
    -0
      src/pages/database/goods/goodsInfo/components/BomBatching.jsx
  2. +1
    -5
      src/pages/database/goods/goodsInfo/components/CreateBom.jsx
  3. +108
    -0
      src/pages/database/goods/goodsInfo/components/UpdateBom.jsx
  4. +53
    -32
      src/pages/database/goods/goodsInfo/index.jsx
  5. +18
    -0
      src/pages/database/goods/goodsInfo/service.js

+ 148
- 0
src/pages/database/goods/goodsInfo/components/BomBatching.jsx Dosyayı Görüntüle

@@ -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 (
<Modal
title={'配方详情'}
width={1040}
visible={props.BomBatchingVisible}
bodyStyle={{ padding: '32px 40px 1px 48px' }}
okText="确认"
cancelText="取消"
onOk={headleOk}
onCancel={() => {
props.onBomBatchingCancel();
}}
destroyOnClose
>
<EditableProTable
columns={columns}
rowKey="id"
value={dataSource}
onChange={setDataSource}
recordCreatorProps={{
newRecordType: 'dataSource',
record: () => ({
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,
}}/>
</Modal>
//vessels
);
};

export default GoodsbomFrom;

+ 1
- 5
src/pages/database/goods/goodsInfo/components/CreateBom.jsx Dosyayı Görüntüle

@@ -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: '物料名称',


+ 108
- 0
src/pages/database/goods/goodsInfo/components/UpdateBom.jsx Dosyayı Görüntüle

@@ -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 (
<Modal
title={'编辑配方'}
width={640}
visible={props.UpdateBomVisible}
bodyStyle={{ padding: '32px 40px 1px 48px' }}
okText="确认"
cancelText="取消"
onOk={headleOk}
onCancel={() => {
props.onUpdateBomCancel();
}}
destroyOnClose
>
<Form labelCol={{ span: 4 }} layout="horizontal" form={form} preserve={false}>
<Form.Item name="bomName" label="配方名称" rules={[{ required: true, message: '配方名称' }]}>
<Input placeholder="请输入配方名称"/>
</Form.Item>
<Form.Item name="bomTypeList" rules={[{ required: true, message: '配方分类' }]} label="配方分类" >
<Select
style={{width: '100%'}}
mode="tags"
placeholder="请选配方分类"
options={props.bomTypeData}
dropdownRender={(menu) => (
<>
{menu}
<Divider style={{margin: '8px 0'}}/>
<Space style={{padding: '0 8px 4px'}}>
<Input
placeholder="请输入配方分类"
ref={inputRef}
value={typename}
onChange={onNameChange}
onKeyDown={(e) => e.stopPropagation()}
/>
<Button type="text" icon={<PlusOutlined />} onClick={addItem}>
新增
</Button>
</Space>
</>
)}
/>
</Form.Item>
<Form.Item name="bomType" label="配方类型" initialValue='1' rules={[{ required: true, message: '配方类型' }]}>
<Select
placeholder="请选配方类型"
onChange={(value) => {
form.setFieldsValue({
bomType:value
});
}}
>
<OptGroup>
<Select.Option value="1">主料配方</Select.Option>
<Select.Option value="0">辅料配方</Select.Option>
</OptGroup>
</Select>
</Form.Item>
</Form>
</Modal>
);
};

export default UpdateBom;

+ 53
- 32
src/pages/database/goods/goodsInfo/index.jsx Dosyayı Görüntüle

@@ -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);
}}
/>
<UpdateBom onUpdateBomCancel={onUpdateBomCancel} bomtype={bomtype} BomId={BomId} UpdateBomVisible={UpdateBomVisible} bomTypeData={bomTypeData} onUpdateBomSave={onUpdateBomSave}/>
<BomBatching matedata={matedata} onBomBatchingCancel={onBomBatchingCancel} BomId={BomId} BomBatchingVisible={BomBatchingVisible} onBomBatchingFinish={onBomBatchingFinish}/>
</Card>
),


+ 18
- 0
src/pages/database/goods/goodsInfo/service.js Dosyayı Görüntüle

@@ -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,
});
}

Yükleniyor…
İptal
Kaydet