@@ -166,10 +166,17 @@ export default [ | |||
access: 'k7', | |||
}, | |||
{ | |||
name: '配方下发', | |||
name: '小炒工序', | |||
icon: 'smile', | |||
path: '/bom/push', | |||
component: './bom/push', | |||
path: '/bom/cookingwork', | |||
component: './bom/cookingwork', | |||
access: 'k8', | |||
}, | |||
{ | |||
name: '机械臂,炒锅配置', | |||
icon: 'smile', | |||
path: '/bom/cookingentry', | |||
component: './bom/cookingentry', | |||
access: 'k8', | |||
}, | |||
], | |||
@@ -358,6 +365,13 @@ export default [ | |||
component: './device/deviceFood', | |||
access: 'k14', | |||
}, | |||
{ | |||
name: '小炒', | |||
icon: 'smile', | |||
path: '/device/deviceStirFryTime', | |||
component: './device/deviceStirFryTime', | |||
access: 'k14', | |||
}, | |||
{ | |||
code: 'deviceBOM', | |||
name: '设备配方管理', | |||
@@ -70,6 +70,14 @@ export async function getInitialState() { | |||
component: './device/deviceFood', | |||
access: 'k14', | |||
}, | |||
{ | |||
code: 'deviceStirFryTime', | |||
name: '小炒', | |||
icon: 'smile', | |||
path: '/device/deviceStirFryTime', | |||
component: './device/deviceStirFryTime', | |||
access: 'k14', | |||
}, | |||
{ | |||
code: 'deviceBOM', | |||
name: '设备配方管理', | |||
@@ -238,6 +246,14 @@ export async function getInitialState() { | |||
component: './bom/bomtype', | |||
access: 'k7', | |||
}, | |||
{ | |||
code: 'cookingwork', | |||
name: '小炒工序', | |||
icon: 'smile', | |||
path: '/bom/cookingwork', | |||
component: './bom/cookingwork', | |||
access: 'k7', | |||
}, | |||
], | |||
}, | |||
{ | |||
@@ -0,0 +1,77 @@ | |||
import React, { useState, useEffect } from 'react'; | |||
import { Modal, Form, Input, Button, Select, InputNumber } from 'antd'; | |||
import api from '../services'; | |||
const CreateForm = (props) => { | |||
const { Option, OptGroup } = Select; | |||
const [options, setoptions] = useState(); | |||
//每次触发 | |||
useEffect(() => { | |||
const initoptions = async (value) => { | |||
var data = await api.getStirFryArray("stirfrytime"); | |||
if (data != undefined) { | |||
setoptions(data.data); | |||
} | |||
}; | |||
initoptions(); | |||
}, []); | |||
return ( | |||
<Modal | |||
title={props.values.id ? '编辑' : '新建'} | |||
width={640} | |||
visible={props.createModalVisible} | |||
bodyStyle={{ padding: '32px 40px 48px' }} | |||
footer={null} | |||
onCancel={() => { | |||
props.onCancel(); | |||
}} | |||
destroyOnClose | |||
> | |||
<Form | |||
layout="vertical" | |||
preserve={false} | |||
initialValues={props.values} | |||
onFinish={props.onFinish} | |||
> | |||
<Form.Item name="id" hidden={true}> | |||
<Input /> | |||
</Form.Item> | |||
<Form.Item name="status" hidden={true}> | |||
<Input /> | |||
</Form.Item> | |||
<Form.Item name="fryTime" label="步骤名称" rules={[{ required: true, max: 64, whitespace: true }]}> | |||
<Select style={{ width: 200 }} | |||
showSearch | |||
optionFilterProp="children" | |||
filterOption={(input, option) => | |||
option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0 | |||
} > | |||
{options?.map((item, index) => { | |||
return ( | |||
<Option | |||
index={item} | |||
value={item} | |||
key={index} | |||
> | |||
{item} | |||
</Option> | |||
); | |||
})} | |||
</Select> | |||
</Form.Item> | |||
<Form.Item name="during" label="持续时间" rules={[{ required: true }]}> | |||
<InputNumber min={0} /> | |||
</Form.Item> | |||
<span style={{ color: '#FFCC52' }}> | |||
注: 持续时间(s),若为0,则等待该流程走完结束 | |||
</span> | |||
<Form.Item> | |||
<Button type="primary" htmlType="submit"> | |||
保存 | |||
</Button> | |||
</Form.Item> | |||
</Form> | |||
</Modal> | |||
); | |||
}; | |||
export default CreateForm; |
@@ -0,0 +1,137 @@ | |||
import React, { useState, useEffect } from 'react'; | |||
import { | |||
InputNumber, | |||
Row, | |||
Col, | |||
Switch, | |||
Checkbox, | |||
Space, | |||
Steps, | |||
message, | |||
Modal, | |||
Form, | |||
Input, | |||
Button, | |||
Select, | |||
DatePicker, | |||
Upload | |||
} from 'antd'; | |||
import { MinusCircleOutlined, PlusOutlined, UploadOutlined } from '@ant-design/icons'; | |||
import api from '../services'; | |||
const PotActions = (props) => { | |||
const { Option, OptGroup } = Select; | |||
const [options, setoptions] = useState(); | |||
const [options11, setoptions11] = useState({potActions:[]}); | |||
//每次触发 | |||
useEffect(() => { | |||
const initoptions = async (value) => { | |||
var data = await api.getStirFryArray("stirfrypotaction"); | |||
if (data != undefined) { | |||
setoptions(data.data); | |||
} | |||
}; | |||
initoptions(); | |||
}, []); | |||
return ( | |||
<Modal | |||
title={'炒锅配置'} | |||
width={500} | |||
visible={props.createModalVisible} | |||
footer={null} //底部内容 | |||
onCancel={() => { | |||
props.onCancel(); | |||
}} | |||
//关闭时销毁 Modal 里的子元素 | |||
destroyOnClose={true} | |||
> | |||
<Form | |||
preserve={false} | |||
form={props.form} | |||
labelCol={{ span: 4 }} | |||
layout="Horizontal" | |||
// initialValues={props.values} | |||
onFinish={props.onFinish} | |||
initialValues={props.values} | |||
> | |||
<span> | |||
<Form.Item name="id" hidden={true}> | |||
<Input /> | |||
</Form.Item> | |||
<Form.Item | |||
noStyle | |||
shouldUpdate={(prevValues, currentValues) => | |||
prevValues.activityType !== currentValues.activityType | |||
} > | |||
{({ getFieldValue }) => | |||
(<Form.Item > | |||
<Form.List name="potActions"> | |||
{(fields, { add, remove }) => ( | |||
<> | |||
{fields?.map(({ key, name, fieldKey, ...restField }, index) => ( | |||
<Space | |||
key={index} | |||
style={{ display: 'flex', marginBottom: 8 }} | |||
align="baseline" | |||
> | |||
<Form.Item | |||
{...restField} | |||
label={"炒锅动作"} | |||
name={[name, 'value']} | |||
fieldKey={[fieldKey, 'value']} | |||
rules={[{ required: true, message: '请选择' }]} > | |||
{ | |||
<Select style={{ width: 200 }} | |||
showSearch | |||
optionFilterProp="children" | |||
filterOption={(input, option) => | |||
option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0 | |||
} > | |||
{options.map((item, index) => { | |||
return ( | |||
<Option | |||
index={item} | |||
value={item} | |||
key={index} | |||
> | |||
{item} | |||
</Option> | |||
); | |||
})} | |||
</Select> | |||
} | |||
</Form.Item> | |||
<MinusCircleOutlined onClick={() => remove(name)} /> | |||
</Space > | |||
)) | |||
} | |||
<Form.Item> | |||
<Button type="dashed" onClick={() => add()} block icon={<PlusOutlined />}> | |||
添加 | |||
</Button> | |||
</Form.Item> | |||
</> | |||
)} | |||
</Form.List > | |||
</Form.Item > | |||
) | |||
} | |||
</Form.Item > | |||
<Form.Item> | |||
<Button type="primary" htmlType="submit" style={{ float: 'right' }}> | |||
保存 | |||
</Button> | |||
</Form.Item> | |||
</span > | |||
</Form > | |||
</Modal > | |||
); | |||
}; | |||
export default PotActions; |
@@ -0,0 +1,138 @@ | |||
import React, { useState, useEffect } from 'react'; | |||
import { | |||
InputNumber, | |||
Row, | |||
Col, | |||
Switch, | |||
Checkbox, | |||
Space, | |||
Steps, | |||
message, | |||
Modal, | |||
Form, | |||
Input, | |||
Button, | |||
Select, | |||
DatePicker, | |||
Upload | |||
} from 'antd'; | |||
import { MinusCircleOutlined, PlusOutlined, UploadOutlined } from '@ant-design/icons'; | |||
import api from '../services'; | |||
const RobotActions = (props) => { | |||
const { Option, OptGroup } = Select; | |||
const [options, setoptions] = useState(); | |||
//每次触发 | |||
useEffect(() => { | |||
const initoptions = async (value) => { | |||
var data = await api.getStirFryArray("sirfryrobotaction"); | |||
if (data != undefined) { | |||
setoptions(data.data); | |||
} | |||
}; | |||
initoptions(); | |||
}, []); | |||
return ( | |||
<Modal | |||
title={'机械臂配置'} | |||
width={500} | |||
visible={props.createModalVisible} | |||
//visible={options11} | |||
footer={null} //底部内容 | |||
onCancel={() => { | |||
props.onCancel(); | |||
}} | |||
//关闭时销毁 Modal 里的子元素 | |||
destroyOnClose={true} | |||
> | |||
<Form | |||
preserve={false} | |||
form={props.form} | |||
labelCol={{ span: 4 }} | |||
layout="Horizontal" | |||
onFinish={props.onFinish} | |||
initialValues={props.values} | |||
> | |||
<span > | |||
<Form.Item name="id" hidden={true}> | |||
<Input /> | |||
</Form.Item> | |||
<Form.Item | |||
noStyle | |||
shouldUpdate={(prevValues, currentValues) => | |||
prevValues.activityType !== currentValues.activityType | |||
} > | |||
{({ getFieldValue }) => | |||
(<Form.Item> | |||
<Form.List name="robotActions"> | |||
{(fields, { add, remove }) => ( | |||
<> | |||
{fields?.map(({ key, name, fieldKey, ...restField },index) => ( | |||
<Space | |||
key={index} | |||
style={{ display: 'flex', marginBottom: 8 }} | |||
align="baseline" | |||
> | |||
<Form.Item | |||
{...restField} | |||
label={"机械臂动作"} | |||
name={[name, 'value']} | |||
fieldKey={[fieldKey, 'value']} | |||
rules={[{ required: true, message: '请选择' }]} > | |||
{ | |||
<Select style={{ width: 200 }} | |||
showSearch | |||
optionFilterProp="children" | |||
filterOption={(input, option) => | |||
option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0 | |||
} > | |||
{options?.map((item, index) => { | |||
return ( | |||
<Option | |||
index={item} | |||
value={item} | |||
key={index} | |||
> | |||
{item} | |||
</Option> | |||
); | |||
})} | |||
</Select> | |||
} | |||
</Form.Item> | |||
<MinusCircleOutlined onClick={() => remove(name)} /> | |||
</Space > | |||
)) | |||
} | |||
<Form.Item> | |||
<Button type="dashed" onClick={() => add()} block icon={<PlusOutlined />}> | |||
添加 | |||
</Button> | |||
</Form.Item> | |||
</> | |||
)} | |||
</Form.List > | |||
</Form.Item > | |||
) | |||
} | |||
</Form.Item > | |||
<Form.Item> | |||
<Button type="primary" htmlType="submit" style={{ float: 'right' }}> | |||
保存 | |||
</Button> | |||
</Form.Item> | |||
</span > | |||
</Form > | |||
</Modal > | |||
); | |||
}; | |||
export default RobotActions; |
@@ -0,0 +1,330 @@ | |||
import { PlusOutlined } from '@ant-design/icons'; | |||
import { Button, message, Input, Drawer, Modal, Popconfirm } from 'antd'; | |||
import React, { useState, useRef, useEffect } from 'react'; | |||
import { PageContainer, FooterToolbar } from '@ant-design/pro-layout'; | |||
import ProTable from '@ant-design/pro-table'; | |||
import ProDescriptions from '@ant-design/pro-descriptions'; | |||
import CreateForm from './components/CreateForm'; | |||
import PotActions from './components/PotActions'; | |||
import RobotActions from './components/RobotActions'; | |||
import api from './services'; | |||
//页面 相当于 class | |||
/** | |||
* 添加节点 | |||
* | |||
* @param fields | |||
*/ | |||
const handleAdd = async (fields) => { | |||
try { | |||
api.addupdate(JSON.stringify(fields)).then((r) => { | |||
if (r.data) { | |||
message.success('添加成功'); | |||
} else { | |||
message.error('添加失败请重试!'); | |||
} | |||
}); | |||
return true; | |||
} catch (error) { | |||
message.error('添加失败请重试!'); | |||
return false; | |||
} | |||
} | |||
/** | |||
* 批量删除节点 | |||
* | |||
* @param selectedRows | |||
*/ | |||
const handleRemove = async (fields) => { | |||
try { | |||
api.delete(fields.id).then((r) => { | |||
if (r.data) { | |||
message.success('删除成功,即将刷新'); | |||
} else { | |||
message.error('删除失败,请重试'); | |||
} | |||
}); | |||
return true; | |||
} catch (error) { | |||
message.error('删除失败,请重试'); | |||
} | |||
} | |||
/** | |||
* 更新节点 | |||
* | |||
* @param fields | |||
*/ | |||
const handlePotUpdate = async (fields) => { | |||
try { | |||
api.UpdatePot(fields).then((r) => { | |||
if (r.data) { | |||
message.success('修改成功'); | |||
} else { | |||
message.error('修改失败请重试!'); | |||
} | |||
}); | |||
return true; | |||
} catch (error) { | |||
message.error('修改失败请重试!'); | |||
return false; | |||
} | |||
} | |||
const handleRobotUpdate = async (fields) => { | |||
try { | |||
api.UpdateRobot(fields).then((r) => { | |||
if (r.data) { | |||
message.success('修改成功'); | |||
} else { | |||
message.error('修改失败请重试!'); | |||
} | |||
}); | |||
return true; | |||
} catch (error) { | |||
message.error('修改失败请重试!'); | |||
return false; | |||
} | |||
} | |||
const handleUpdate = async (fields) => { | |||
try { | |||
api.addupdate(fields).then((r) => { | |||
if (r.data) { | |||
message.success('修改成功'); | |||
} else { | |||
message.error('修改失败请重试!'); | |||
} | |||
}); | |||
return true; | |||
} catch (error) { | |||
message.error('修改失败请重试!'); | |||
return false; | |||
} | |||
} | |||
const cookingwork = (props) => { | |||
const [values, setUrl] = useState(props.location.query.values ? props.location.query.values : null); | |||
/** 新建/更新窗口的弹窗 */ | |||
const [createModalVisible, handleModalVisible] = useState(false); | |||
/** 分布更新窗口的弹窗 */ | |||
const [createPotActionsModalVisible, handlePotActionsModalVisible] = useState(false); | |||
const [createRobotActionsModalVisible, handleRobotActionsModalVisible] = useState(false); | |||
//绑定 | |||
const actionRef = useRef(); | |||
const [currentRow, setCurrentRow] = useState(); | |||
const [selectedRowsState, setSelectedRows] = useState([]); | |||
// 监控数据变化 | |||
useEffect(() => { | |||
}, []); | |||
/** 国际化配置 */ | |||
const columns = [ | |||
{ | |||
title: '主键', | |||
dataIndex: 'id', | |||
hideInTable: true, | |||
hideInSearch: true, | |||
}, | |||
{ | |||
title: '步骤名称', | |||
dataIndex: 'fryTime', | |||
hideInForm: true, | |||
hideInSearch: true, | |||
}, | |||
{ | |||
title: '持续时间(秒)', | |||
dataIndex: 'during', | |||
hideInForm: true, | |||
hideInSearch: true, | |||
}, | |||
{ | |||
title: '操作', | |||
dataIndex: 'option', | |||
valueType: 'option', | |||
render: (_, record) => [ | |||
<a | |||
key="config" | |||
onClick={() => { | |||
handleModalVisible(true); | |||
setCurrentRow(record); | |||
}} | |||
> | |||
修改 | |||
</a>, | |||
<a | |||
key="config" | |||
onClick={() => { | |||
handleRobotActionsModalVisible(true); | |||
if (typeof (record.robotActions) == 'string') { | |||
record.robotActions = JSON.parse(record.robotActions) | |||
} | |||
setCurrentRow(record); | |||
}} | |||
> | |||
机器人配置 | |||
</a>, | |||
<a | |||
key="config" | |||
onClick={() => { | |||
handlePotActionsModalVisible(true); | |||
if (typeof (record.potActions) == 'string') { | |||
record.potActions = JSON.parse(record.potActions) | |||
} | |||
setCurrentRow(record); | |||
}} | |||
> | |||
炒锅配置 | |||
</a>, | |||
<Popconfirm | |||
type="primary" | |||
key="primary" | |||
title="确认删除吗?" | |||
okText="是" | |||
cancelText="否" | |||
onConfirm={() => { | |||
handleRemove(record); | |||
actionRef.current?.reloadAndRest(); | |||
}} | |||
onCancel={() => { }} | |||
> | |||
<a href="#">删除</a> | |||
</Popconfirm>, | |||
], | |||
}, | |||
]; | |||
return ( | |||
<PageContainer> | |||
<ProTable | |||
pagination={{ defaultPageSize: 50 }} | |||
headerTitle="小炒步骤设置" | |||
actionRef={actionRef} | |||
rowKey="id" | |||
search={false} | |||
columns={columns} | |||
toolBarRender={() => [ | |||
<Button | |||
type="primary" | |||
key="primary" | |||
onClick={() => { | |||
handleModalVisible(true); | |||
setCurrentRow({}); | |||
}} | |||
> | |||
<PlusOutlined /> 新建 | |||
</Button>, | |||
]} | |||
//数据绑定 | |||
request={async (params) => { | |||
params.CookingWorkId = props.location.query.values.id; | |||
var data = []; | |||
var total = 0; | |||
await api.getpage(params).then((r) => { | |||
data = r.data.data; | |||
total = r.data.total; | |||
}); | |||
return { | |||
data: data, | |||
success: true, | |||
total: total, | |||
}; | |||
}} | |||
// 每行选择点击事件 | |||
rowSelection={{ | |||
onChange: (_, selectedRows) => { | |||
setSelectedRows(selectedRows); | |||
}, | |||
}} | |||
></ProTable> | |||
{selectedRowsState?.length > 0 && ( | |||
<FooterToolbar | |||
extra={ | |||
<div> | |||
已选择{' '} | |||
<a | |||
style={{ | |||
fontWeight: 600, | |||
}} | |||
> | |||
{selectedRowsState.length} | |||
</a>{' '} | |||
项 | |||
</div> | |||
} | |||
> | |||
<Button | |||
onClick={async () => { | |||
await handleRemove(selectedRowsState); | |||
setSelectedRows([]); | |||
actionRef.current?.reloadAndRest?.(); | |||
}} | |||
> | |||
批量删除 | |||
</Button> | |||
</FooterToolbar> | |||
)} | |||
<PotActions | |||
onFinish={async (value) => { | |||
var success = false; | |||
success = await handlePotUpdate(value); | |||
if (success) { | |||
handlePotActionsModalVisible(false); | |||
if (actionRef.current) { | |||
actionRef.current.reload(); | |||
} | |||
} | |||
}} | |||
onCancel={() => { | |||
setCurrentRow(undefined); | |||
handlePotActionsModalVisible(false); | |||
}} | |||
createModalVisible={createPotActionsModalVisible} | |||
values={currentRow || {}} | |||
/> | |||
<RobotActions | |||
onFinish={async (value) => { | |||
var success = false; | |||
success = await handleRobotUpdate(value); | |||
if (success) { | |||
handleRobotActionsModalVisible(false); | |||
if (actionRef.current) { | |||
actionRef.current.reload(); | |||
} | |||
} | |||
}} | |||
onCancel={() => { | |||
setCurrentRow(undefined); | |||
handleRobotActionsModalVisible(false); | |||
}} | |||
createModalVisible={createRobotActionsModalVisible} | |||
values={currentRow || {}} | |||
/> | |||
<CreateForm | |||
onFinish={async (value) => { | |||
var success = false; | |||
if (value.id) { | |||
success = await handleUpdate(value); | |||
} else { | |||
success = await handleAdd(value); | |||
} | |||
if (success) { | |||
handleModalVisible(false); | |||
if (actionRef.current) { | |||
actionRef.current.reload(); | |||
} | |||
} | |||
}} | |||
onCancel={() => { | |||
setCurrentRow(undefined); | |||
handleModalVisible(false); | |||
}} | |||
createModalVisible={createModalVisible} | |||
values={currentRow || {}} | |||
/> | |||
</PageContainer> | |||
); | |||
}; | |||
export default cookingwork; |
@@ -0,0 +1,42 @@ | |||
// @ts-ignore | |||
/* eslint-disable */ | |||
import { request } from 'umi'; | |||
export default { | |||
getpage(data) { | |||
return request(`/kitchen/api/stirFryTime/getpage`, { | |||
method: 'Post', | |||
data: data, | |||
}); | |||
}, | |||
getStirFryArray(data) { | |||
return request(`/kitchen/api/stirFryTime/getStirFryArray?type=`+data, { | |||
method: 'GET', | |||
}); | |||
}, | |||
addupdate(data) { | |||
return request('/kitchen/api/stirFryTime/AddUpdate', { | |||
method: 'POST', | |||
data: data, | |||
}); | |||
}, | |||
UpdatePot(data) { | |||
return request('/kitchen/api/stirFryTime/UpdatePot', { | |||
method: 'POST', | |||
data: data, | |||
}); | |||
}, | |||
UpdateRobot(data) { | |||
return request('/kitchen/api/stirFryTime/UpdateRobot', { | |||
method: 'POST', | |||
data: data, | |||
}); | |||
}, | |||
delete(data) { | |||
return request('/kitchen/api/stirFryTime/delete?id='+data, { | |||
method: 'GET', | |||
}); | |||
}, | |||
}; |
@@ -0,0 +1,45 @@ | |||
import React, { useState, useEffect } from 'react'; | |||
import { Modal, Form, Input, Button, Switch,InputNumber } from 'antd'; | |||
const CreateForm = (props) => { | |||
return ( | |||
<Modal | |||
title={props.values.id ? '编辑' : '新建'} | |||
width={640} | |||
visible={props.createModalVisible} | |||
bodyStyle={{ padding: '32px 40px 48px' }} | |||
footer={null} | |||
onCancel={() => { | |||
props.onCancel(); | |||
}} | |||
destroyOnClose | |||
> | |||
<Form | |||
layout="vertical" | |||
preserve={false} | |||
initialValues={props.values} | |||
onFinish={props.onFinish} | |||
> | |||
<Form.Item name="id" hidden={true}> | |||
<Input /> | |||
</Form.Item> | |||
<Form.Item name="status" hidden={true}> | |||
<Input /> | |||
</Form.Item> | |||
<Form.Item name="name" label="工序名称" rules={[{ required: true, max: 64, whitespace: true }]}> | |||
<Input placeholder="请输入工序名称" /> | |||
</Form.Item> | |||
<Form.Item name="remark" label="工序描述" rules={[{ required: true, max: 64, whitespace: true }]}> | |||
<Input placeholder="请输入工序描述" /> | |||
</Form.Item> | |||
<Form.Item> | |||
<Button type="primary" htmlType="submit"> | |||
保存 | |||
</Button> | |||
</Form.Item> | |||
</Form> | |||
</Modal> | |||
); | |||
}; | |||
export default CreateForm; |
@@ -0,0 +1,280 @@ | |||
import { PlusOutlined } from '@ant-design/icons'; | |||
import { Button, message, Input, Drawer, Modal,Popconfirm } from 'antd'; | |||
import React, { useState, useRef, useEffect } from 'react'; | |||
import { PageContainer, FooterToolbar } from '@ant-design/pro-layout'; | |||
import ProTable from '@ant-design/pro-table'; | |||
import ProDescriptions from '@ant-design/pro-descriptions'; | |||
import CreateForm from './components/CreateForm'; | |||
import { history } from 'umi'; | |||
import api from './services'; | |||
//页面 相当于 class | |||
/** | |||
* 添加节点 | |||
* | |||
* @param fields | |||
*/ | |||
const handleAdd = async (fields) => { | |||
try { | |||
api.addupdate(JSON.stringify(fields)).then((r) => { | |||
if (r.data) { | |||
message.success('添加成功'); | |||
} else { | |||
message.error('添加失败请重试!'); | |||
} | |||
}); | |||
return true; | |||
} catch (error) { | |||
message.error('添加失败请重试!'); | |||
return false; | |||
} | |||
} | |||
/** | |||
* 批量删除节点 | |||
* | |||
* @param selectedRows | |||
*/ | |||
const handleRemove = async (ids) => { | |||
console.log(ids); | |||
try { | |||
// api.delete(ids).then((r) => { | |||
// if (r.data) { | |||
// message.success('删除成功,即将刷新'); | |||
// } else { | |||
// message.error('删除失败,请重试'); | |||
// } | |||
// }); | |||
return true; | |||
} catch (error) { | |||
message.error('删除失败,请重试'); | |||
} | |||
} | |||
/** | |||
* 更新节点 | |||
* | |||
* @param fields | |||
*/ | |||
const handleUpdate = async (fields) => { | |||
try { | |||
api.addupdate(fields).then((r) => { | |||
if (r.data) { | |||
message.success('修改成功'); | |||
} else { | |||
message.error('修改失败请重试!'); | |||
} | |||
}); | |||
return true; | |||
} catch (error) { | |||
message.error('修改失败请重试!'); | |||
return false; | |||
} | |||
} | |||
const cookingwork = (props) => { | |||
/** 新建/更新窗口的弹窗 */ | |||
const [createModalVisible, handleModalVisible] = useState(false); | |||
/** 分布更新窗口的弹窗 */ | |||
//绑定 | |||
const actionRef = useRef(); | |||
const [currentRow, setCurrentRow] = useState(); | |||
const [selectedRowsState, setSelectedRows] = useState([]); | |||
// 监控数据变化 | |||
useEffect(() => { | |||
}, []); | |||
/** 国际化配置 */ | |||
const columns = [ | |||
{ | |||
title: '主键', | |||
dataIndex: 'id', | |||
hideInTable: true, | |||
hideInSearch: true, | |||
}, | |||
{ | |||
title: '工序名称', | |||
dataIndex: 'name', | |||
hideInForm: true, | |||
}, | |||
{ | |||
title: '状态', | |||
dataIndex: 'status', | |||
hideInForm: true, | |||
search: false, | |||
valueEnum: { | |||
0: { | |||
text: '正常', | |||
status: 'Processing', | |||
}, | |||
1: { | |||
text: '停用', | |||
status: 'Success', | |||
}, | |||
}, | |||
}, | |||
{ | |||
title: '工序描述', | |||
dataIndex: 'remark', | |||
hideInForm: true, | |||
hideInSearch: true, | |||
}, | |||
{ | |||
title: '操作', | |||
dataIndex: 'option', | |||
valueType: 'option', | |||
render: (_, record) => [ | |||
<a | |||
key="config" | |||
onClick={() => { | |||
history.push({ | |||
pathname: '/bom/cookingentry', | |||
query: { | |||
isAdd: false, | |||
values:record | |||
}, | |||
}); | |||
}} | |||
> | |||
配置 | |||
</a>, | |||
<a | |||
key="config" | |||
onClick={() => { | |||
handleModalVisible(true); | |||
setCurrentRow(record); | |||
}} | |||
> | |||
更新 | |||
</a>, | |||
<Popconfirm | |||
type="primary" | |||
key="primary" | |||
title={record.status == 0 ? '确认停用吗?' : '确认启用吗?'} | |||
okText="是" | |||
cancelText="否" | |||
onConfirm={() => { | |||
record.status = record.status == 0 ? 1 : 0; | |||
handleUpdate(record); | |||
actionRef.current?.reloadAndRest(); | |||
}} | |||
onCancel={() => { }} | |||
><a>{record.status == 1 ? '启用' : '停用'}</a> | |||
</Popconfirm>, | |||
<Popconfirm | |||
type="primary" | |||
key="primary" | |||
title="确认删除吗?" | |||
okText="是" | |||
cancelText="否" | |||
onConfirm={() => { | |||
handleRemove(record); | |||
actionRef.current?.reloadAndRest(); | |||
}} | |||
onCancel={() => { }} | |||
> | |||
<a href="#">删除</a> | |||
</Popconfirm>, | |||
], | |||
}, | |||
]; | |||
return ( | |||
<PageContainer> | |||
<ProTable | |||
headerTitle="小炒工序" | |||
actionRef={actionRef} | |||
rowKey="id" | |||
search={{ | |||
labelWidth: 120, | |||
}} | |||
columns={columns} | |||
toolBarRender={() => [ | |||
<Button | |||
type="primary" | |||
key="primary" | |||
onClick={() => { | |||
handleModalVisible(true); | |||
setCurrentRow({}); | |||
}} | |||
> | |||
<PlusOutlined /> 新建 | |||
</Button>, | |||
]} | |||
//数据绑定 | |||
request={async (params) => { | |||
var data = []; | |||
var total = 0; | |||
await api.getpage(params).then((r) => { | |||
data = r.data.data; | |||
total = r.data.total; | |||
}); | |||
return { | |||
data: data, | |||
success: true, | |||
total: total, | |||
}; | |||
}} | |||
// 每行选择点击事件 | |||
rowSelection={{ | |||
onChange: (_, selectedRows) => { | |||
setSelectedRows(selectedRows); | |||
}, | |||
}} | |||
></ProTable> | |||
{selectedRowsState?.length > 0 && ( | |||
<FooterToolbar | |||
extra={ | |||
<div> | |||
已选择{' '} | |||
<a | |||
style={{ | |||
fontWeight: 600, | |||
}} | |||
> | |||
{selectedRowsState.length} | |||
</a>{' '} | |||
项 | |||
</div> | |||
} | |||
> | |||
<Button | |||
onClick={async () => { | |||
await handleRemove(selectedRowsState); | |||
setSelectedRows([]); | |||
actionRef.current?.reloadAndRest?.(); | |||
}} | |||
> | |||
批量删除 | |||
</Button> | |||
</FooterToolbar> | |||
)} | |||
<CreateForm | |||
onFinish={async (value) => { | |||
var success = false; | |||
if (value.id) { | |||
success = await handleUpdate(value); | |||
} else { | |||
success = await handleAdd(value); | |||
} | |||
if (success) { | |||
handleModalVisible(false); | |||
if (actionRef.current) { | |||
actionRef.current.reload(); | |||
} | |||
} | |||
}} | |||
onCancel={() => { | |||
setCurrentRow(undefined); | |||
handleModalVisible(false); | |||
}} | |||
createModalVisible={createModalVisible} | |||
values={currentRow || {}} | |||
/> | |||
</PageContainer> | |||
); | |||
}; | |||
export default cookingwork; |
@@ -0,0 +1,25 @@ | |||
// @ts-ignore | |||
/* eslint-disable */ | |||
import { request } from 'umi'; | |||
export default { | |||
getpage(data) { | |||
return request(`/kitchen/api/cookingwork/getpage`, { | |||
method: 'Post', | |||
data: data, | |||
}); | |||
}, | |||
addupdate(data) { | |||
return request('/kitchen/api/cookingwork/addupdate', { | |||
method: 'POST', | |||
data: data, | |||
}); | |||
}, | |||
delete(data) { | |||
return request('/kitchen/api/cookingwork/delete', { | |||
method: 'POST', | |||
data: data, | |||
}); | |||
}, | |||
}; |
@@ -1,61 +0,0 @@ | |||
import React, { useState, useEffect } from 'react'; | |||
import { Modal, Form, Input, Button, Select, Switch,InputNumber } from 'antd'; | |||
const CreateForm = (props) => { | |||
const { Option, OptGroup } = Select; | |||
return ( | |||
<Modal | |||
title={props.values.id ? '编辑' : '新建'} | |||
width={640} | |||
visible={props.createModalVisible} | |||
bodyStyle={{ padding: '32px 40px 48px' }} | |||
footer={null} | |||
onCancel={() => { | |||
props.onCancel(); | |||
}} | |||
destroyOnClose | |||
> | |||
<Form | |||
layout="vertical" | |||
preserve={false} | |||
initialValues={props.values} | |||
onFinish={props.onFinish} | |||
> | |||
<Form.Item name="id" hidden={true}> | |||
<Input /> | |||
</Form.Item> | |||
<Form.Item | |||
name="stockGoodsCode" | |||
label="原料名称" | |||
rules={[{ required: true, message: '请选择原料名称' }]} | |||
> | |||
<Select placeholder="请选择原料名称"> | |||
{props.stockGoodsData.map((item, index) => { | |||
return ( | |||
<Select.Option index={index} value={item.id} key={item.id}> | |||
{item.name} | |||
</Select.Option> | |||
); | |||
})} | |||
</Select> | |||
</Form.Item> | |||
<Form.Item name="bomQty" label="配方用量" defaultValue={props.values.bomQty}> | |||
<InputNumber placeholder="配方用量" min={0} /> | |||
</Form.Item> | |||
<Form.Item name="isMain" label="主要原料" > | |||
<Switch checkedChildren="否" unCheckedChildren="是" defaultChecked /> | |||
</Form.Item> | |||
<Form.Item name="isReplace" label="是否可以替换" > | |||
<Switch checkedChildren="否" unCheckedChildren="是" defaultChecked /> | |||
</Form.Item> | |||
<Form.Item> | |||
<Button type="primary" htmlType="submit"> | |||
保存 | |||
</Button> | |||
</Form.Item> | |||
</Form> | |||
</Modal> | |||
); | |||
}; | |||
export default CreateForm; |
@@ -1,437 +0,0 @@ | |||
import { PlusOutlined } from '@ant-design/icons'; | |||
import { Button, message, Input, Drawer, Modal } from 'antd'; | |||
import React, { useState, useRef, useEffect } from 'react'; | |||
import { PageContainer, FooterToolbar } from '@ant-design/pro-layout'; | |||
import ProTable from '@ant-design/pro-table'; | |||
import ProDescriptions from '@ant-design/pro-descriptions'; | |||
import CreateForm from './components/CreateForm'; | |||
import api from './services'; | |||
const GoodsBomsManage = (props) => { | |||
/** 新建/更新窗口的弹窗 */ | |||
const [createModalVisible, handleModalVisible] = useState(false); | |||
const [BomReplaclVisible, BomReplacVisible] = useState(false); | |||
/** 分布更新窗口的弹窗 */ | |||
const [dicData, setDicData] = useState([]); | |||
const [dicDataAny, setDicDataAny] = useState([]); | |||
const [showDetail, setShowDetail] = useState(false); | |||
const actionRef = useRef(); | |||
const [currentRow, setCurrentRow] = useState(); | |||
const [selectedRowsState, setSelectedRows] = useState([]); | |||
// //获取商品数据 | |||
const [goods, setgoods] = useState([]); | |||
//获取原料名称 | |||
const [stockGoods, setstockGoods] = useState([]); | |||
// 监控数据变化 | |||
useEffect(() => { | |||
function initgoods() { | |||
api.goodList({ current: 1, pageSize: 20, status: '0' }).then((r) => { | |||
var arr = r.data.data; | |||
arr.forEach((element) => { | |||
element.text = element.name; | |||
element.goodsId = element.id; | |||
}); | |||
setgoods(arr); | |||
}); | |||
} | |||
initgoods(); | |||
/** 获取原料名称*/ | |||
function initStockGoods() { | |||
api.postStockGoods().then((r) => { | |||
var arr = r.data; | |||
arr.forEach((element) => { | |||
element.text = element.name; | |||
element.stockGoodsId = element.value; | |||
}); | |||
setstockGoods(arr); | |||
}); | |||
} | |||
initStockGoods(); //回调原料信息 | |||
function intDicData() { | |||
api.GetDicList('BatchingType').then((r) => { | |||
var arr = r.data; | |||
// arr.forEach((element) => { | |||
// //element.text = element.remark; | |||
// // element.batchingTypeId = element.value; | |||
// }); | |||
let data = {}; | |||
if (r.succeeded) { | |||
arr.forEach((item) => { | |||
data[item.value] = { text: item.remark }; | |||
}); | |||
} | |||
setDicDataAny(data); | |||
console.log(arr); | |||
setDicData(arr); | |||
}); | |||
} | |||
intDicData(); | |||
}, []); | |||
/** | |||
* 添加节点 | |||
* | |||
* @param fields | |||
*/ | |||
function handleAdd(fields) { | |||
try { | |||
api.addGoodsBom(JSON.stringify(fields)).then((r) => { | |||
if (r.data) { | |||
message.success('添加成功'); | |||
//刷新数据 | |||
actionRef.current.reload(); | |||
} else { | |||
message.error('添加失败请重试!'); | |||
} | |||
}); | |||
return true; | |||
} catch (error) { | |||
message.error('添加失败请重试!'); | |||
return false; | |||
} | |||
} | |||
/** | |||
* 更新节点 | |||
* | |||
* @param fields | |||
*/ | |||
function handleUpdate(fields) { | |||
console.log(fields); | |||
try { | |||
api | |||
.updateGoodsBom({ | |||
id: fields.id, | |||
goodsID: fields.goods_Id, | |||
stockGoodsCode: fields.stockGoodsCode, | |||
remark: fields.remark, | |||
status: fields.status, | |||
batchingType: fields.batchingType, | |||
isReplace: fields.isReplace, | |||
isMain: fields.isMain, | |||
bomQty: fields.bomQty | |||
}) | |||
.then((r) => { | |||
if (r.data) { | |||
message.success('配置成功'); | |||
} else { | |||
message.error('配置失败请重试!'); | |||
} | |||
//刷新数据 | |||
actionRef.current.reload(); | |||
}); | |||
return true; | |||
} catch (error) { | |||
message.error('配置失败请重试!'); | |||
return false; | |||
} | |||
} | |||
/** | |||
* 删除节点 | |||
* | |||
* | |||
*/ | |||
function handleRemove() { | |||
if (!selectedRowsState) return true; | |||
try { | |||
api.removeGoodsBom(selectedRowsState.map((row) => row.id)).then((r) => { | |||
if (r.data) { | |||
message.success('删除成功,即将刷新'); | |||
} else { | |||
message.error('删除失败,请重试'); | |||
} | |||
//刷新数据 | |||
actionRef.current.reload(); | |||
}); | |||
return true; | |||
} catch (error) { | |||
message.error('删除失败,请重试'); | |||
return false; | |||
} | |||
} | |||
/** 国际化配置 */ | |||
const columns = [ | |||
{ | |||
title: '主键', | |||
dataIndex: 'id', | |||
hideInTable: true, | |||
hideInSearch: true, | |||
tip: '规则名称是唯一的 key', | |||
render: (dom, entity) => { | |||
return ( | |||
<a | |||
onClick={() => { | |||
setCurrentRow(entity); | |||
setShowDetail(true); | |||
}} | |||
> | |||
{dom} | |||
</a> | |||
); | |||
}, | |||
}, | |||
{ | |||
title: '原料名称', | |||
dataIndex: 'stockGoodsName', | |||
hideInForm: true, | |||
hideInSearch: true, | |||
}, | |||
{ | |||
title: '原料名称', | |||
dataIndex: 'stockGoodsCode', | |||
hideInForm: true, | |||
hideInTable: true, | |||
valueType: 'select', | |||
valueEnum: stockGoods, | |||
}, | |||
{ | |||
title: '配料类型', | |||
dataIndex: 'batchingType', | |||
hideInForm: true, | |||
valueEnum: dicDataAny, | |||
}, | |||
{ | |||
title: '状态', | |||
dataIndex: 'status', | |||
hideInForm: true, | |||
valueEnum: { | |||
0: { | |||
text: '正常', | |||
status: 'Processing', | |||
}, | |||
1: { | |||
text: '停用', | |||
status: 'Error', | |||
}, | |||
2: { | |||
text: '删除', | |||
status: 'Error', | |||
}, | |||
}, | |||
}, | |||
{ | |||
title: '主要原料', | |||
dataIndex: 'isMain', | |||
hideInForm: true, | |||
valueEnum: { | |||
false: { | |||
text: '辅料', | |||
status: 'Processing', | |||
}, | |||
true: { | |||
text: '主料', | |||
status: 'Success', | |||
}, | |||
}, | |||
}, | |||
{ | |||
title: '配方用量', | |||
dataIndex: 'bomQty', | |||
hideInSearch: true, | |||
width: 120, | |||
}, | |||
{ | |||
title: '是否可以替换', | |||
dataIndex: 'isReplace', | |||
hideInForm: true, | |||
valueEnum: { | |||
false: { | |||
text: '不可替换', | |||
status: 'Processing', | |||
}, | |||
true: { | |||
text: '可替换', | |||
status: 'Success', | |||
}, | |||
}, | |||
}, | |||
{ | |||
title: '创建时间', | |||
dataIndex: 'createAt', | |||
valueType: 'date', | |||
}, | |||
{ | |||
title: '操作', | |||
dataIndex: 'option', | |||
valueType: 'option', | |||
render: (_, record) => [ | |||
record.status === '0' && ( | |||
<a | |||
key="link" | |||
onClick={() => { | |||
record.status = '1'; | |||
handleUpdate(record); | |||
}} | |||
> | |||
停用 | |||
</a> | |||
), | |||
(record.status === '1' || record.status === '2') && ( | |||
<a | |||
key="warn" | |||
onClick={() => { | |||
record.status = '0'; | |||
handleUpdate(record); | |||
}} | |||
> | |||
启用 | |||
</a> | |||
), | |||
record.status === '0' && record.isReplace && ( | |||
<a | |||
key="link" | |||
onClick={() => { | |||
record.isReplace = false; | |||
handleUpdate(record); | |||
}} | |||
> | |||
不启用 | |||
</a> | |||
), | |||
record.status === '0' && !record.isReplace && ( | |||
<a | |||
key="warn" | |||
onClick={() => { | |||
record.isReplace = true; | |||
handleUpdate(record); | |||
}} | |||
> | |||
启用替换 | |||
</a> | |||
), | |||
record.status === '0' && record.isReplace && ( | |||
<a | |||
key="link" | |||
onClick={() => { | |||
BomReplacVisible(true); | |||
setCurrentRow(record); | |||
}} | |||
> | |||
替换物料 | |||
</a> | |||
), | |||
<a | |||
key="link" | |||
onClick={() => { | |||
handleModalVisible(true); | |||
setCurrentRow(record); | |||
}} | |||
> | |||
修改 | |||
</a>, | |||
], | |||
}, | |||
]; | |||
return ( | |||
<Modal | |||
width={1200} | |||
bodyStyle={{ padding: '32px 40px 48px' }} | |||
destroyOnClose | |||
title="商品配方" | |||
visible={props.setGoodsBomModalVisible} | |||
footer={false} | |||
onCancel={() => props.onCancel()} | |||
maskClosable={false} | |||
> | |||
<ProTable | |||
headerTitle="商品配方信息查询" | |||
actionRef={actionRef} | |||
rowKey="id" | |||
pagination={{ defaultPageSize: 20 }} | |||
search={false} | |||
toolBarRender={() => [ | |||
<Button type="primary" key="create" onClick={() => handleModalVisible(true)}> | |||
<PlusOutlined /> 新增商品配方 | |||
</Button>, | |||
]} | |||
//数据绑定 | |||
request={async (params) => { | |||
var goodsBomsData = []; | |||
var total = 0; | |||
//商品编号 | |||
if (props.values.id != undefined) { | |||
params['goodsId'] = props.values.id; | |||
} | |||
await api.goodsBoms(params).then((r) => { | |||
goodsBomsData = r.data.data; | |||
total = r.data.total; | |||
}); | |||
return { | |||
data: goodsBomsData, | |||
success: true, | |||
total: total, | |||
}; | |||
}} | |||
columns={columns} | |||
/> | |||
{/*商品配方(新增,修改) */} | |||
<CreateForm | |||
dicData={dicData} | |||
stockGoodsData={stockGoods} | |||
onFinish={async (value) => { | |||
var success = false; | |||
value['goodsId'] = props.values.id; | |||
value['goods_Id'] = props.values.id; | |||
if (value.id) { | |||
success = await handleUpdate(value); | |||
} else { | |||
success = await handleAdd(value); | |||
} | |||
if (success) { | |||
handleModalVisible(false); | |||
setCurrentRow(undefined); | |||
if (actionRef.current) { | |||
actionRef.current.reload(); | |||
} | |||
} | |||
}} | |||
onCancel={() => { | |||
handleModalVisible(false); | |||
setCurrentRow(undefined); | |||
}} | |||
createModalVisible={createModalVisible} | |||
values={currentRow || {}} | |||
/> | |||
{/**物料替换 */} | |||
<GoodsBomReplace | |||
stockGoodsData={stockGoods} | |||
onFinish={async (value) => { | |||
var success = false; | |||
value['goodsId'] = props.values.id; | |||
if (value.id) { | |||
success = await handleUpdate(value); | |||
} else { | |||
success = await handleAdd(value); | |||
} | |||
if (success) { | |||
BomReplacVisible(false); | |||
setCurrentRow(undefined); | |||
if (actionRef.current) { | |||
actionRef.current.reload(); | |||
} | |||
} | |||
}} | |||
onCancel={() => { | |||
BomReplacVisible(false); | |||
setCurrentRow(undefined); | |||
}} | |||
createModalVisible={BomReplaclVisible} | |||
values={currentRow || {}} | |||
/> | |||
</Modal> | |||
); | |||
}; | |||
export default GoodsBomsManage; |
@@ -1,65 +0,0 @@ | |||
// @ts-ignore | |||
/* eslint-disable */ | |||
import { request } from 'umi'; | |||
export default { | |||
/** 获取商品物料 sdsa GET /kitchen/api/rule */ | |||
goodsBoms(data) { | |||
return request(`/kitchen/api/goods-bom/goods-boms`, { | |||
method: 'Post', | |||
data: data, | |||
// params: { ...params }, | |||
// ...(options || {}), | |||
}); | |||
}, | |||
GetDicList(TypeCode) { | |||
return request(`/kitchen/api/dict-data/dic-list/${TypeCode}`, { | |||
method: 'Get', | |||
}); | |||
}, | |||
/** 更新商品物料 PUT /kitchen/api/rule */ | |||
updateGoodsBom(data) { | |||
return request('/kitchen/api/goods-bom', { | |||
method: 'PUT', | |||
data: data, | |||
// ...(options || {}), | |||
}); | |||
}, | |||
/** 新建商品物料清单 POST /kitchen/api/rule */ | |||
addGoodsBom(data) { | |||
// http://localhost:7002 | |||
return request('/kitchen/api/goods-bom', { | |||
method: 'POST', | |||
// type:'json', | |||
data: data, | |||
// ...(options || {}), | |||
}); | |||
}, | |||
/** 删除商品物料 DELETE /kitchen/api/rule */ | |||
removeGoodsBom(data) { | |||
return request(`/kitchen/api/goods-bom`, { | |||
method: 'DELETE', | |||
data: data, | |||
// ...(options || {}), | |||
}); | |||
}, | |||
/** 获取商品商品 sdsa GET /kitchen/api/rule */ | |||
goodList(data) { | |||
return request(`/kitchen/api/goods/goodss`, { | |||
method: 'Post', | |||
data: data, | |||
// params: { ...params }, | |||
// ...(options || {}), | |||
}); | |||
}, | |||
/** 获取原料信息 POST /kitchen/api/rule */ | |||
postStockGoods() { | |||
return request(`/kitchen/api/frachisee-stock-adjust/product-list`, { | |||
method: 'Get', | |||
// ...(options || {}), | |||
}); | |||
}, | |||
}; |
@@ -0,0 +1,64 @@ | |||
import {Modal } from 'antd'; | |||
import React, { useState} from 'react'; | |||
import ProTable from '@ant-design/pro-table'; | |||
import { GetGoods } from '../service'; | |||
const CreateForm = (props) => { | |||
const [selectedRowsState, setSelectedRows] = useState([]); | |||
const columns = [ | |||
{ | |||
title: '商品id', | |||
dataIndex: 'goodsId', | |||
tip: '规则名称是唯一的 key', | |||
hideInSearch: true, | |||
hideInTable: true, | |||
}, | |||
{ | |||
title: '商品名称', | |||
dataIndex: 'goodsName', | |||
}, | |||
]; | |||
return ( | |||
<Modal | |||
width={700} | |||
bodyStyle={{ padding: '32px 40px 48px' }} | |||
destroyOnClose | |||
title="选择商品" | |||
visible={props.modalVisible} | |||
onCancel={() => props.onCancel()} | |||
onOk={() => props.onSubmit(selectedRowsState)} | |||
maskClosable={false} | |||
> | |||
<ProTable | |||
headerTitle="商品信息" | |||
rowKey="goodsId" | |||
pagination={{ defaultPageSize: 5000 }} | |||
search={false} | |||
toolBarRender={false} | |||
params={{ | |||
DeviceId:props.values, | |||
}} | |||
//数据绑定 | |||
request={async (params) => { | |||
var Data = []; | |||
var total = 0; | |||
await GetGoods(params).then((r) => { | |||
Data = r.data; | |||
total = 1; | |||
}); | |||
return { | |||
data: Data, | |||
success: true, | |||
total: total, | |||
}; | |||
}} | |||
columns={columns} | |||
rowSelection={{ | |||
onChange: (_, selectedRows) => setSelectedRows(selectedRows), | |||
}} | |||
/> | |||
</Modal> | |||
); | |||
}; | |||
export default CreateForm; |
@@ -0,0 +1,237 @@ | |||
import { PlusOutlined } from '@ant-design/icons'; | |||
import { Card, Tree, Button, message, Input, Drawer, Divider } from 'antd'; | |||
import React, { useState, useRef, useEffect } from 'react'; | |||
import { PageContainer, FooterToolbar } from '@ant-design/pro-layout'; | |||
import ProTable from '@ant-design/pro-table'; | |||
import ProDescriptions from '@ant-design/pro-descriptions'; | |||
import CreateForm from './components/CreateForm'; | |||
import { add, getpage, gettree, DelDeviceGood } from './service'; | |||
import DeviceStock from '../deviceStirFryTimeStock'; | |||
/** | |||
* 添加节点 | |||
* | |||
* @param fields | |||
*/ | |||
const handleAdd = async (fields) => { | |||
const hide = message.loading('正在添加'); | |||
try { | |||
await add({ ...fields }).then((r) => { | |||
if (!r.succeeded) { | |||
message.error(r.errors); | |||
return false; | |||
} | |||
}); | |||
hide(); | |||
message.success('添加成功'); | |||
return true; | |||
} catch (error) { | |||
hide(); | |||
message.error('添加失败请重试!'); | |||
return false; | |||
} | |||
}; | |||
/** | |||
* 删除节点 | |||
* | |||
* @param selectedRows | |||
*/ | |||
const handleRemove = async (selectedRows) => { | |||
try { | |||
message.loading('正在删除'); | |||
let ids = []; | |||
selectedRows.forEach((item) => { | |||
ids.push(item.id); | |||
}); | |||
await DelDeviceGood(ids).then((r) => { | |||
if (r.data) { | |||
message.success('删除成功'); | |||
return true; | |||
} else { | |||
message.success('删除失败'); | |||
return false; | |||
} | |||
}); | |||
} catch (error) { | |||
message.error('删除失败请重试!'); | |||
return false; | |||
} | |||
}; | |||
const TableList = () => { | |||
/** 新建窗口的弹窗 */ | |||
const [createModalVisible, handleModalVisible] = useState(); | |||
/*绑定数据 */ | |||
const actionRef = useRef(); | |||
const [treeData, setTreeData] = useState(); | |||
/*选中*/ | |||
const [selectedRowsState, setSelectedRows] = useState(); | |||
const [stockModalVisible, setStockModalVisible] = useState(false); | |||
const [DeviceInfo, setDeviceInfo] = useState(); | |||
const [DeviceId, setKey] = useState(); | |||
/** 国际化配置 */ | |||
useEffect(() => { | |||
function initfranchiseeType() { | |||
gettree().then((r) => { | |||
setTreeData(r.data); | |||
}); | |||
} | |||
initfranchiseeType(); | |||
}, []); | |||
const columns = [ | |||
{ | |||
title: '商品名称', | |||
dataIndex: 'goods_Name', | |||
} | |||
]; | |||
return ( | |||
<PageContainer> | |||
<ProTable | |||
headerTitle="商品列表" | |||
actionRef={actionRef} | |||
rowKey="id" | |||
search={{ | |||
labelWidth: 120, | |||
}} | |||
tableRender={(_, dom) => ( | |||
<div | |||
style={{ | |||
display: 'flex', | |||
width: '100%', | |||
}} | |||
> | |||
<Card title="店铺设备列表"> | |||
<Tree defaultExpandAll={true} onSelect={(e, info) => [ | |||
setKey(e[0]), | |||
setDeviceInfo(info.node) | |||
] | |||
} treeData={treeData} /> | |||
</Card> | |||
<div | |||
style={{ | |||
flex: 1, | |||
}} | |||
> | |||
{dom} | |||
</div> | |||
</div> | |||
)} | |||
toolBarRender={() => [ | |||
<Button | |||
type="primary" | |||
key="primary" | |||
onClick={() => { | |||
handleModalVisible(true); | |||
}} | |||
> | |||
<PlusOutlined /> 上架菜品商品 | |||
</Button>, | |||
<Button | |||
type="primary" | |||
key="primary" | |||
onClick={() => { | |||
if (DeviceId == undefined) { | |||
message.error('请选择设备'); | |||
return; | |||
} | |||
if (DeviceInfo.parentId != "0") { setStockModalVisible(true); } | |||
}} | |||
> | |||
设备库存管理 | |||
</Button>, | |||
]} | |||
params={{ | |||
DeviceId, | |||
}} | |||
request={async (params) => { | |||
let UserData = []; | |||
var total = 0; | |||
await getpage(params).then((r) => { | |||
UserData = r.data.data; | |||
total = r.data.total; | |||
}); | |||
return { | |||
data: UserData, | |||
success: true, | |||
total: total, | |||
}; | |||
}} | |||
columns={columns} | |||
rowSelection={{ | |||
onChange: (_, selectedRows) => { | |||
setSelectedRows(selectedRows); | |||
}, | |||
}} | |||
/> | |||
{selectedRowsState?.length > 0 && ( | |||
<FooterToolbar | |||
extra={ | |||
<div> | |||
已选择{' '} | |||
<a | |||
style={{ | |||
fontWeight: 600, | |||
}} | |||
> | |||
{selectedRowsState.length} | |||
</a>{' '} | |||
项 | |||
</div> | |||
} | |||
> | |||
<Button | |||
onClick={async () => { | |||
await handleRemove(selectedRowsState); | |||
setSelectedRows([]); | |||
actionRef.current?.reloadAndRest?.(); | |||
}} | |||
> | |||
批量删除 | |||
</Button> | |||
</FooterToolbar> | |||
)} | |||
<CreateForm | |||
onSubmit={async (value) => { | |||
if (DeviceId == undefined) { | |||
message.error('请选择设备'); | |||
handleModalVisible(false); | |||
} else { | |||
const defaultData = []; | |||
value.map((data) => { | |||
defaultData.push({ FoodId: data.goodsId }); | |||
}); | |||
const valuejson = { DeviceId: DeviceId, Foodss: defaultData } | |||
var success = false; | |||
success = await handleAdd(valuejson); | |||
if (success) { | |||
handleModalVisible(false); | |||
if (actionRef.current) { | |||
actionRef.current.reload(); | |||
} | |||
} | |||
} | |||
}} | |||
onCancel={() => { | |||
handleModalVisible(false); | |||
}} | |||
modalVisible={createModalVisible} | |||
values={DeviceId} | |||
/> | |||
{/* 库存调拨 */} | |||
<DeviceStock | |||
onCancel={() => { | |||
setStockModalVisible(false); | |||
}} | |||
stockModalVisible={stockModalVisible} | |||
values={DeviceInfo} | |||
/> | |||
</PageContainer> | |||
); | |||
}; | |||
export default TableList; |
@@ -0,0 +1,40 @@ | |||
import { request } from 'umi'; | |||
export async function getpage(params, options) { | |||
return request('/kitchen/api/Device/GetDeviceGoods', { | |||
method: 'POST', | |||
data: { | |||
...params, | |||
}, | |||
}); | |||
} | |||
export async function add(params) { | |||
return request('/kitchen/api/Device/AddDeviceGood', { | |||
method: 'POST', | |||
data: { | |||
...params, | |||
}, | |||
}); | |||
} | |||
export async function DelDeviceGood(data) { | |||
return request(`/kitchen/api/Device/DelDeviceGood`, { | |||
method: 'POST', | |||
data: data, | |||
}); | |||
} | |||
export async function gettree(params) { | |||
return request('/kitchen/api/Device/StoreDeviceTree?isTMC=false', { | |||
data: { | |||
...params, | |||
}, | |||
}); | |||
} | |||
export async function GetGoods(params) { | |||
return request('/kitchen/api/Device/GetGoods', { | |||
method: 'POST', | |||
data: { | |||
...params, | |||
}, | |||
}); | |||
} |
@@ -0,0 +1,94 @@ | |||
import React, { useState, useEffect } from 'react'; | |||
import { InputNumber, Modal, Form, Input, Button, Select } from 'antd'; | |||
import { GetBatchingAsync,GetProductListByBom } from '../services'; | |||
const CreateForm = (props) => { | |||
const { Option, OptGroup } = Select; | |||
const [batchingList, setBatchingList] = useState([]); | |||
//原料 | |||
//初始化数据 | |||
useEffect(() => { | |||
const initBatching = () => { | |||
if(props.isbom){ | |||
GetProductListByBom({ DeviceId: props.DeviceId,BomIds:props.bomIds }).then((data) => { | |||
setBatchingList(data.data); | |||
}); | |||
}else { | |||
GetBatchingAsync({ DeviceId: props.DeviceId }).then((data) => { | |||
setBatchingList(data.data); | |||
}); | |||
} | |||
}; | |||
initBatching(); | |||
}, []); | |||
return ( | |||
<Modal | |||
title={props.values.id ? '编辑' : '新建'} | |||
width={640} | |||
visible={props.createModalVisible} | |||
bodyStyle={{ padding: '32px 40px 48px' }} | |||
footer={null} | |||
onCancel={() => { | |||
props.onCancel(); | |||
}} | |||
destroyOnClose | |||
> | |||
<Form | |||
layout="vertical" | |||
preserve={false} | |||
initialValues={props.values} | |||
onFinish={props.onFinish} | |||
> | |||
<Form.Item name="id" hidden={true}> | |||
<Input /> | |||
</Form.Item> | |||
<Form.Item | |||
name="batching_Id" | |||
label="原料名称" | |||
rules={[{ required: true, message: '请选择原料名称' }]} | |||
> | |||
<Select placeholder="请选择原料名称" showSearch | |||
optionFilterProp="children" | |||
filterOption={(input, option) => | |||
option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0 | |||
}> | |||
{batchingList.map((item, index) => { | |||
return ( | |||
<Select.Option index={index} value={item.id} key={item.id}> | |||
{item.name} | |||
</Select.Option> | |||
); | |||
})} | |||
</Select> | |||
</Form.Item> | |||
<Form.Item | |||
name="batching_Loc" | |||
label="库存位置" | |||
rules={[{ required: true }]} | |||
defaultValue="0" | |||
> | |||
<Input placeholder="输入库存位置编码" /> | |||
</Form.Item> | |||
<Form.Item | |||
name="batching_Count" | |||
label="原料数量" | |||
rules={[{ required: true }]} | |||
defaultValue="0" | |||
> | |||
<InputNumber min={0} placeholder="请输入原料数量" /> | |||
</Form.Item> | |||
<Form.Item> | |||
<Button type="primary" htmlType="submit"> | |||
保存 | |||
</Button> | |||
</Form.Item> | |||
</Form> | |||
</Modal> | |||
); | |||
}; | |||
export default CreateForm; |
@@ -0,0 +1,349 @@ | |||
import { PlusOutlined } from '@ant-design/icons'; | |||
import { Popconfirm, Modal, Button, message, Input, Drawer } 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 ProDescriptions from '@ant-design/pro-descriptions'; | |||
import CreateForm from './components/CreateForm'; | |||
import { | |||
GetStoreBatchingStockPageAsync, | |||
AddStoreBatchingStocAsync, | |||
UpdateStoreBatchingStocAsync, | |||
PushStockAsync, | |||
CheckStockAdjust, | |||
removeSingleStockAdjust, | |||
PushDeviceTMC, | |||
CheckStockTMCAdjust | |||
} from './services'; | |||
const key = 'message'; | |||
const DeviceStockManager = (props) => { | |||
/** 新建/更新窗口的弹窗 */ | |||
const [createModalVisible, handleModalVisible] = useState(false); | |||
const actionRef = useRef(); | |||
const [currentRow, setCurrentRow] = useState(); | |||
const [selectedRowsState, setSelectedRows] = useState([]); | |||
const [total, setTotal] = useState(0); | |||
//添加 | |||
const handleAdd = async (fields) => { | |||
try { | |||
fields.DeviceId = props.values.key; | |||
message.loading('正在添加', key); | |||
await AddStoreBatchingStocAsync(JSON.stringify(fields)).then((r) => { | |||
message.destroy(key); | |||
if (r.data) { | |||
message.success('添加成功'); | |||
actionRef.current.reload(); | |||
return true; | |||
} else { | |||
message.error('添加失败' + r.errors); | |||
actionRef.current.reload(); | |||
return false; | |||
} | |||
}); | |||
} catch (error) { | |||
message.error('添加失败请重试!'); | |||
actionRef.current.reload(); | |||
return false; | |||
} | |||
}; | |||
//同步 | |||
const pushStock = async (id) => { | |||
try { | |||
message.loading('正在同步', key); | |||
if (props.isbom) { | |||
await PushDeviceTMC(id).then((r) => { | |||
message.destroy(key); | |||
if (r.data) { | |||
setSelectedRows([]); | |||
message.success('同步成功'); | |||
actionRef.current.reload(); | |||
return true; | |||
} else { | |||
message.success('同步失败'); | |||
actionRef.current.reload(); | |||
return false; | |||
} | |||
}); | |||
} else { | |||
await PushStockAsync(id).then((r) => { | |||
message.destroy(key); | |||
if (r.data) { | |||
setSelectedRows([]); | |||
message.success('同步成功'); | |||
actionRef.current.reload(); | |||
return true; | |||
} else { | |||
message.success('同步失败'); | |||
actionRef.current.reload(); | |||
return false; | |||
} | |||
}); | |||
} | |||
} catch (error) { | |||
message.error('同步失败请重试!'); | |||
actionRef.current.reload(); | |||
return false; | |||
} | |||
}; | |||
//获取实时库存 | |||
const handleCheckStockAdjust = async (id) => { | |||
console.log("fdsfds"); | |||
try { | |||
if (props.isbom) { | |||
await CheckStockTMCAdjust(id).then((r) => { | |||
message.destroy(key); | |||
if (r.data) { | |||
message.success('获取成功'); | |||
actionRef.current.reload(); | |||
return true; | |||
} else { | |||
message.error('获取失败' + r.errors); | |||
actionRef.current.reload(); | |||
return false; | |||
} | |||
}); | |||
} else { | |||
await CheckStockAdjust(id).then((r) => { | |||
message.destroy(key); | |||
if (r.data) { | |||
message.success('获取成功'); | |||
actionRef.current.reload(); | |||
return true; | |||
} else { | |||
message.error('获取失败' + r.errors); | |||
actionRef.current.reload(); | |||
return false; | |||
} | |||
}); | |||
} | |||
} catch (error) { | |||
message.error("获取失败!"); | |||
actionRef.current.reload(); | |||
return false; | |||
} | |||
}; | |||
const handleRemoveSingle = async (value) => { | |||
try { | |||
await removeSingleStockAdjust(value).then((r) => { | |||
if (r.data) { | |||
message.success('删除成功,即将刷新'); | |||
//刷新数据 | |||
actionRef.current.reload(); | |||
} else { | |||
message.error('删除失败,请重试'); | |||
actionRef.current.reload(); | |||
} | |||
}); | |||
return true; | |||
} catch (error) { | |||
message.error('删除失败,请重试'); | |||
actionRef.current.reload(); | |||
} | |||
}; | |||
//修改 | |||
const handleUpdate = async (fields) => { | |||
try { | |||
message.loading('正在修改', key); | |||
message.destroy(key); | |||
fields.DeviceId = props.values.key; | |||
await UpdateStoreBatchingStocAsync(JSON.stringify(fields)).then((r) => { | |||
message.destroy(key); | |||
if (r.data) { | |||
message.success('修改成功'); | |||
return true; | |||
} else { | |||
message.error('修改失败' + r.errors); | |||
return false; | |||
} | |||
}); | |||
} catch (error) { | |||
message.error('修改失败请重试!'); | |||
return false; | |||
} | |||
}; | |||
const columns = [ | |||
{ | |||
title: '主键', | |||
dataIndex: 'id', | |||
hideInSearch: true, | |||
hideInTable: true, | |||
tip: '规则名称是唯一的 key', | |||
}, | |||
{ | |||
title: '物料', | |||
dataIndex: 'batching_Name', | |||
valueType: 'textarea', | |||
}, | |||
{ | |||
title: '数量', | |||
dataIndex: 'batching_Count', | |||
valueType: 'textarea', | |||
}, | |||
{ | |||
title: '库位', | |||
dataIndex: 'batching_Loc', | |||
}, | |||
{ | |||
title: '操作', | |||
dataIndex: 'option', | |||
valueType: 'option', | |||
render: (_, record) => [ | |||
<a | |||
key="config" | |||
onClick={() => { | |||
handleModalVisible(true); | |||
setCurrentRow(record); | |||
}} | |||
> | |||
{' '} | |||
修改 | |||
</a>, | |||
<Popconfirm | |||
type="primary" | |||
key="primary" | |||
title="确认删除吗?" | |||
okText="是" | |||
cancelText="否" | |||
onConfirm={() => { | |||
handleRemoveSingle(record.id); | |||
}} | |||
onCancel={() => { }} | |||
> | |||
<a href="#">删除</a> | |||
</Popconfirm>, | |||
], | |||
}, | |||
]; | |||
return ( | |||
<Modal | |||
width={1200} | |||
bodyStyle={{ padding: '32px 40px 48px' }} | |||
destroyOnClose | |||
//(props.values == undefined ? '' : props.values.store_Name) + | |||
title={(props.values == undefined ? '' : props.values.title) + '库存原料调整'} | |||
search={false} | |||
visible={props.stockModalVisible} | |||
footer={false} | |||
onCancel={() => props.onCancel()} | |||
maskClosable={false} | |||
> | |||
<PageContainer | |||
header={{ | |||
title: '', | |||
breadcrumb: {}, | |||
}} | |||
> | |||
<ProTable | |||
headerTitle="" | |||
actionRef={actionRef} | |||
rowKey="id" | |||
search={false} | |||
toolBarRender={() => [ | |||
<Popconfirm | |||
type="primary" | |||
key="primary" | |||
title="获取实时库存会覆盖本次补货数据" | |||
okText="是" | |||
cancelText="否" | |||
onConfirm={() => { | |||
handleCheckStockAdjust(props.values.key); | |||
}} | |||
onCancel={() => { }} | |||
> | |||
<Button type="primary" key="primary"> | |||
获取实时库存 | |||
</Button> | |||
</Popconfirm>, | |||
<Button | |||
type="primary" | |||
key="primary" | |||
onClick={() => { | |||
if (selectedRowsState.length == 0) { | |||
message.error('请选择需要同步的数据!!'); | |||
} | |||
// else if (selectedRowsState.length < 6) { | |||
// message.error('必须同步6个库存位置的数据,现在条件不满足不能同步!!'); | |||
// } | |||
else { | |||
pushStock(props.values.key); | |||
actionRef.current?.reloadAndRest?.(); | |||
} | |||
}} | |||
> | |||
同步库存原料 | |||
</Button>, | |||
<Button | |||
disabled={props.isbom && total > 14} | |||
type="primary" | |||
key="primary" | |||
onClick={() => { | |||
handleModalVisible(true); | |||
}} | |||
> | |||
<PlusOutlined /> 新增库存原料 | |||
</Button>, | |||
]} | |||
request={async (params) => { | |||
var data = []; | |||
var total = 0; | |||
//params.DeviceId ='263971c3-38d6-43a2-a2df-bb5be147d05e'; //props.values.key; | |||
params.DeviceId = props.values.key; | |||
await GetStoreBatchingStockPageAsync(params).then((r) => { | |||
data = r.data.data; | |||
total = r.data.total; | |||
setTotal(total); | |||
}); | |||
return { | |||
data: data, | |||
success: true, | |||
total: total, | |||
}; | |||
}} | |||
columns={columns} | |||
rowSelection={{ | |||
onChange: (_, selectedRows) => { | |||
setSelectedRows(selectedRows); | |||
}, | |||
}} | |||
/> | |||
<CreateForm | |||
isbom={props.isbom} | |||
bomIds={props.bomIds} | |||
DeviceId={props.values == undefined ? '' : props.values.key} | |||
onFinish={async (value) => { | |||
var success = false; | |||
if (value.id) { | |||
success = handleUpdate(value); | |||
} else { | |||
success = handleAdd(value); | |||
} | |||
if (success) { | |||
handleModalVisible(false); | |||
setCurrentRow(undefined); | |||
actionRef.current.reload(); | |||
} | |||
}} | |||
onCancel={() => { | |||
handleModalVisible(false); | |||
setCurrentRow(undefined); | |||
}} | |||
createModalVisible={createModalVisible} | |||
values={currentRow || {}} | |||
/> | |||
</PageContainer> | |||
</Modal> | |||
); | |||
}; | |||
export default DeviceStockManager; |
@@ -0,0 +1,79 @@ | |||
import { request } from 'umi'; | |||
/** 获取商品物料库存 */ | |||
export async function GetStoreBatchingStockPageAsync(data) { | |||
return request(`/kitchen/api/Device/GetDeviceStorePage`, { | |||
method: 'POST', | |||
data: data, | |||
}); | |||
} | |||
/** 同步库存 */ | |||
export async function PushDeviceTMC(data) { | |||
return request(`/kitchen/api/Device/PushDeviceTMC?DeviceId=${data}`, { | |||
method: 'post', | |||
}); | |||
} | |||
/** 同步库存 */ | |||
export async function PushStockAsync(data) { | |||
return request(`/kitchen/api/Device/PushStirFryTimeAsync?DeviceId=${data}`, { | |||
method: 'post', | |||
}); | |||
} | |||
/** 获取实时库存 */ | |||
export async function CheckStockAdjust(data) { | |||
return request(`/kitchen/api/Device/CheckStockAdjust?DeviceId=${data}`, { | |||
method: 'POST', | |||
}); | |||
} | |||
/** 获取实时库存 */ | |||
export async function CheckStockTMCAdjust(data) { | |||
return request(`/kitchen/api/Device/CheckStockTMCAdjust?DeviceId=${data}`, { | |||
method: 'POST', | |||
}); | |||
} | |||
/** 添加商品物料库存 */ | |||
export async function AddStoreBatchingStocAsync(data) { | |||
return request(`/kitchen/api/Device/AddUpdateDeviceStocAsync`, { | |||
method: 'POST', | |||
data: data, | |||
}); | |||
} | |||
/** 获取原料 */ | |||
export async function GetProductListByBom(data) { | |||
return request(`/kitchen/api/Device/GetProductListByBom`, { | |||
method: 'post', | |||
data: data, | |||
}); | |||
} | |||
/** 获取原料 */ | |||
export async function GetBatchingAsync(data) { | |||
return request(`/kitchen/api/Device/GetProductList`, { | |||
method: 'post', | |||
data: data, | |||
}); | |||
} | |||
/** 修改商品物料库存 */ | |||
export async function UpdateStoreBatchingStocAsync(data) { | |||
return request(`/kitchen/api/Device/AddUpdateDeviceStocAsync`, { | |||
method: 'put', | |||
data: data, | |||
}); | |||
} | |||
export async function removeSingleStockAdjust(data) { | |||
return request(`/kitchen/api/Device/DelStockAdjust?Id=${data}`, { | |||
method: 'DELETE', | |||
// data: data, | |||
// ...(options || {}), | |||
}); | |||
} | |||
@@ -1,25 +1,24 @@ | |||
import React, { useState, useEffect } from 'react'; | |||
import { Modal, Form, Input, Button, Select, InputNumber,message } from 'antd'; | |||
import { getGoods } from '../services'; | |||
import { Modal, Form, Input, Button, Select, InputNumber, message } from 'antd'; | |||
import { getGoods, GetCokingWorkList } from '../services'; | |||
const CreateForm = (props) => { | |||
const { Option, OptGroup } = Select; | |||
const [CokingWorks, setCokingWorks] = useState([]); | |||
const [goods, setGoods] = useState([]); | |||
//初始化数据 | |||
useEffect(() => { | |||
const initGoods = () => { | |||
getGoods().then((data) => { | |||
let list = []; | |||
data.data?.data?.forEach((item) => { | |||
list.push({ | |||
text: item.name, | |||
id: item.id, | |||
}); | |||
}); | |||
setGoods(list); | |||
}); | |||
const initCokingWorks = () => { | |||
GetCokingWorkList().then(r => { | |||
var arr = []; | |||
for (var key in r.data) { | |||
arr.push(<Select.Option value={key}>{r.data[key]}</Select.Option>) | |||
} | |||
setCokingWorks(arr); | |||
}) | |||
}; | |||
initGoods(); | |||
initCokingWorks(); | |||
}, []); | |||
return ( | |||
@@ -43,23 +42,20 @@ const CreateForm = (props) => { | |||
<Form.Item name="id" hidden={true}> | |||
<Input /> | |||
</Form.Item> | |||
{/* <Form.Item label={'商品'} name="goods_Id" rules={[{ required: true }]}> | |||
<Select> | |||
{goods.map((item, index) => { | |||
return ( | |||
<Select.Option index={index} value={item.id} key={item.id}> | |||
{item.text} | |||
</Select.Option> | |||
); | |||
})} | |||
</Select> | |||
</Form.Item> */} | |||
<Form.Item label={'价格'} name="price" rules={[{ required: true }]}> | |||
<InputNumber placeholder="价格" min={0} /> | |||
</Form.Item> | |||
<Form.Item label={'价格'} name="vipPrice" rules={[{ required: true }]}> | |||
<Form.Item label={'会员价格'} name="vipPrice" rules={[{ required: true }]}> | |||
<InputNumber placeholder="价格" min={0} /> | |||
</Form.Item> | |||
<Form.Item label={'小炒工序'} name="cookingWorkId"> | |||
<Select | |||
style={{ width: '100%' }} | |||
placeholder="请选择小炒工序"> | |||
{CokingWorks} | |||
</Select> | |||
</Form.Item> | |||
<Form.Item label={'状态'} name="status" rules={[{ required: true }]}> | |||
<Select placeholder="状态"> | |||
<Option value={1}>下架</Option> | |||
@@ -3,7 +3,7 @@ import { Tabs, Card, Pagination, Table, message, Button, Popconfirm, Modal } fro | |||
const { TabPane } = Tabs; | |||
import React, { useState, useRef, useEffect } from 'react'; | |||
import { PageContainer, FooterToolbar } from '@ant-design/pro-layout'; | |||
import { GetStoreInfoPage, GetStoreGoods, AddStoreGood, UpdateStoreGoods, DelStoreGoods, UpdateStoreGoodsStatusAsync, stopgoods,StoreGoodsAllUpdate } from "./services" | |||
import { GetStoreInfoPage, GetStoreGoods, GetCokingWorkList, AddStoreGood, UpdateStoreGoods, DelStoreGoods, UpdateStoreGoodsStatusAsync, stopgoods,StoreGoodsAllUpdate } from "./services" | |||
import ProTable from '@ant-design/pro-table'; | |||
import CreateForm from './components/CreateForm'; | |||
import LogForm from './components/Logs'; | |||
@@ -68,12 +68,23 @@ const storeGoodsInfo = (props) => { | |||
const [currentTabRow, setCurrentTabRow] = useState(); | |||
const actionRef = useRef(); | |||
const [logVisible, SetLogVisible] = useState(false); | |||
const [CokingWorks, setCokingWorks] = useState([]); | |||
useEffect(() => { | |||
getStoreInfoPageInfo(1); | |||
}, []) | |||
const [goods, setGoods] = useState([]); | |||
//初始化数据 | |||
useEffect(() => { | |||
const initCokingWorks = () => { | |||
GetCokingWorkList().then(r => { | |||
var arr = r.data; | |||
setCokingWorks(arr); | |||
}) | |||
}; | |||
initCokingWorks(); | |||
}, []); | |||
//添加 | |||
const handleAdd = async (fields) => { | |||
try { | |||
@@ -134,6 +145,11 @@ const storeGoodsInfo = (props) => { | |||
valueType: 'money', | |||
}, | |||
{ | |||
title: '小炒工序', | |||
dataIndex: 'cookingWorkId', | |||
valueEnum: CokingWorks, | |||
}, | |||
{ | |||
title: '是否设备制作', | |||
@@ -9,7 +9,9 @@ export async function GetStoreInfoPage(data) { | |||
// ...(options || {}), | |||
}); | |||
} | |||
export async function GetCokingWorkList(data) { | |||
return request(`/kitchen/api/select/GetCokingWorkList`); | |||
} | |||
/** 获取店铺上架商品 */ | |||
export async function GetStoreGoods(data) { | |||
return request(`/kitchen/api/Store/GetStoreGoods`, { | |||