zhaoy 9 månader sedan
förälder
incheckning
49471136c7
4 ändrade filer med 185 tillägg och 14 borttagningar
  1. +48
    -12
      src/pages/scene/foodmenu/components/FoodMenuGoods.jsx
  2. +88
    -0
      src/pages/scene/foodmenu/components/PushDevice.jsx
  3. +32
    -2
      src/pages/scene/foodmenu/index.jsx
  4. +17
    -0
      src/pages/scene/foodmenu/services.js

+ 48
- 12
src/pages/scene/foodmenu/components/FoodMenuGoods.jsx Visa fil

@@ -4,27 +4,29 @@ import { Modal, Form,message} from 'antd';
import ProTable from '@ant-design/pro-table';
import {
GetGoodsList,
gettree
gettree,
GetFoodMenuGoods
} from '../services';
const FoodMenuGoods = (props) => {
const [form] = Form.useForm();
const actionRef = useRef();
const [treeData, setTreeData] = useState();
const [selectedRowsState, setSelectedRows] = useState([]);
const [selectedRowKeys, setselectedRowKeys] = useState([])
useEffect(() => {
console.log(props.values)
if(props?.values?.id){
form.setFieldsValue({
id:props?.values?.id,
name:props?.values?.name,
code:props?.values?.code,
})
}else{
form.resetFields();
}
gettree().then((r) => {
setTreeData(r.data);
});
});
GetFoodMenuGoods(props?.values?.id).then((r) => {
if(r.data.length>0){
var goodsids=r.data.map(x=>{
return x.goodsId;
})
setselectedRowKeys(goodsids)
}else{
setselectedRowKeys([])
}
})
},[props.values])
const columns=[
{
@@ -103,6 +105,40 @@ const FoodMenuGoods = (props) => {
}}
columns={columns}
rowSelection={{
type: 'checkbox',
selectedRowKeys,
onSelect: (record, selected) => {
const tempArray = [...selectedRowKeys];
console.log(record)
console.log(tempArray)
const findIndex = tempArray.findIndex(item => item === record.id);
if (selected) {
findIndex < 0 && tempArray.push(record.id);
} else {
findIndex > -1 && tempArray.splice(findIndex, 1);
}
setselectedRowKeys(tempArray);
},
onSelectAll: (selected, selectedRows, changeRows) => {
const tempArray = [...selectedRowKeys];
if (selected) {
selectedRows.forEach(item => {
if (!item) return;
const findIndex = tempArray.findIndex(fItem => fItem === item.id);
if (findIndex < 0) {
tempArray.push(item.id);
}
});
} else {
changeRows.forEach(item => {
const findIndex = tempArray.findIndex(fItem => fItem === item.id);
if (findIndex > -1) {
tempArray.splice(findIndex, 1);
}
});
}
setselectedRowKeys(tempArray);
},
onChange: (_, selectedRows) => {
setSelectedRows(selectedRows);
},


+ 88
- 0
src/pages/scene/foodmenu/components/PushDevice.jsx Visa fil

@@ -0,0 +1,88 @@
import React, { useState, useEffect,useRef } from 'react';
import { PlusOutlined } from '@ant-design/icons';
import { Modal, Form,message,Row,Col,Select,Checkbox} from 'antd';
import ProTable from '@ant-design/pro-table';
import {
GetDeviceList,
} from '../services';
const PushDevice = (props) => {
const [form] = Form.useForm();
const [deviceData, setdeviceData] = useState([]);
const options = [
{
label: '商品',
value: '1',
},
{
label: '物料',
value: '2',
},
{
label: '工艺',
value: '3',
},
{
label: '配方',
value: '4',
},
];
useEffect(() => {
console.log(props.values)
GetDeviceList().then((r)=>{
var data=r.data.map(x=>{
return {value:x.id,label:x.name}
})
setdeviceData(data)
})
},[props.values])
const handleChange=()=>{

}
const onChangedata=()=>{

}
return (
<Modal
title={'下发数据'}
width={840}
visible={props.pushdeviceModalVisible}
bodyStyle={{ padding: '14px 20px 18px' }}
okText="保存"
cancelText="取消"
onOk={() => {
}}
onCancel={() => {
props.onCancel();
}}
destroyOnClose
>
<Row gutter={26}>
<Col lg={24} md={24} sm={24}>
选择设备:
<Select
mode="multiple"
allowClear
style={{width: '60%'}}
placeholder="请选择要下发设备"
onChange={handleChange}
options={deviceData}
/>
</Col>
</Row>
<Row gutter={26}>
<Col span={24}>
选择数据:
<Checkbox.Group defaultValue={['1','2']} onChange={onChangedata} >
<Checkbox value="1">商品</Checkbox><a style={{marginLeft:2,marginRight:30}}>【选择商品】</a>
<Checkbox value="2">物料 </Checkbox><a style={{marginLeft:2,marginRight:30}}>【选择物料】</a>
<Checkbox value="3">工艺</Checkbox><a style={{marginLeft:2,marginRight:30}}>【选择工艺】</a>
<Checkbox value="4">配方</Checkbox><a style={{marginLeft:2,marginRight:30}}>【选择配方】</a>
</Checkbox.Group>
</Col>
</Row>
</Modal>
);
};

export default PushDevice;

+ 32
- 2
src/pages/scene/foodmenu/index.jsx Visa fil

@@ -5,11 +5,13 @@ import { PageContainer, FooterToolbar } from '@ant-design/pro-layout';
import ProTable from '@ant-design/pro-table';
import CreateForm from './components/CreateForm';
import FoodMenuGoods from './components/FoodMenuGoods'
import PushDevice from './components/PushDevice'
import {
GetFoodPage,
FoodAdd,
FoodUpdate,
FoodDelete,
EditFoodMenuGoods
} from './services';
import { gettree } from '../../org/orgamange/service';
const key = 'message';
@@ -27,6 +29,7 @@ const FoodMenu = () => {
/** 新建/更新窗口的弹窗 */
const [createModalVisible, handleModalVisible] = useState(false);
const [foodMenuGoodsModalVisible,setfoodMenuGoodsModalVisible] = useState(false);
const [pushdeviceModalVisible,setpushdeviceModalVisible] = useState(false);
/** 分布更新窗口的弹窗 */
const actionRef = useRef();
const [currentRow, setCurrentRow] = useState();
@@ -89,6 +92,15 @@ const FoodMenu = () => {
>
关联商品
</a>,
<a
key="update"
onClick={() => {
setpushdeviceModalVisible(true);
setCurrentRow(record);
}}
>
下发
</a>,
],
},
];
@@ -230,8 +242,26 @@ const handleRemove = async (selectedRows) => {
setfoodMenuGoodsModalVisible(false);
setCurrentRow(undefined);
}}
handleOk={()=>{
handleOk={(values)=>{
console.log(values)
EditFoodMenuGoods(values).then((r)=>{
if (r.succeeded) {
message.success('保存成功');
setfoodMenuGoodsModalVisible(false);
setCurrentRow(undefined);
} else {
message.error(r.errors);
}
})
}}
/>
<PushDevice pushdeviceModalVisible={pushdeviceModalVisible} values={currentRow || {}}
onCancel={() => {
setpushdeviceModalVisible(false);
setCurrentRow(undefined);
}}
handleOk={(values)=>{

}}
/>
</PageContainer>


+ 17
- 0
src/pages/scene/foodmenu/services.js Visa fil

@@ -25,12 +25,24 @@ export async function FoodAdd(data) {
data: data,
});
}
export async function EditFoodMenuGoods(data) {
return request(`/saasstore/api/foodmenu/editfoodmenugoods`, {
method: 'POST',
data: data,
});
}
export async function GetFoodMenuGoods(data) {
return request(`/saasstore/api/foodmenu/getfoodmenugoods?foodMenuId=`+data, {
method: 'GET',
});
}
export async function GetGoodsList(data) {
return request(`/saasbase/api/goods/page`, {
method: 'POST',
data: data,
});
}
export async function gettree(params) {
return request('​/saasbase/api​/goodstype/tree', {
method: 'GET',
@@ -38,4 +50,9 @@ export async function FoodAdd(data) {
...params,
},
});
}
export async function GetDeviceList() {
return request(`/saasbase/api/device/list`, {
method: 'GET',
});
}

Laddar…
Avbryt
Spara