Browse Source

feat(修改做法设置): 修改做法设置

修改做法设置

修改做法设置
tags/小炒逻辑变更前
txb 2 years ago
parent
commit
7b1d1bf11a
9 changed files with 1049 additions and 658 deletions
  1. +14
    -0
      config/routes.js
  2. +15
    -1
      src/app.jsx
  3. +308
    -657
      src/pages/goods/goodsPractice/index.jsx
  4. +0
    -0
      src/pages/goods/goodsPracticeInfo/components/createRecordForm.jsx
  5. +258
    -0
      src/pages/goods/goodsPracticeInfo/index.jsx
  6. +137
    -0
      src/pages/goods/goodsPracticeInfo/service.js
  7. +0
    -0
      src/pages/goods/goodsPracticeType/components/createTypeForm.jsx
  8. +180
    -0
      src/pages/goods/goodsPracticeType/index.jsx
  9. +137
    -0
      src/pages/goods/goodsPracticeType/service.js

+ 14
- 0
config/routes.js View File

@@ -228,6 +228,20 @@ export default [
component: './goods/goodsPractice',
access: 'k9',
},
{
name: '商品做法类别',
icon: 'smile',
path: '/goods/goodsPracticeType',
component: './goods/goodsPracticeType',
access: 'k9',
},
{
name: '商品做法基础信息',
icon: 'smile',
path: '/goods/goodsPracticeInfo',
component: './goods/goodsPracticeInfo',
access: 'k9',
},


],


+ 15
- 1
src/app.jsx View File

@@ -303,12 +303,26 @@ export async function getInitialState() {
access: 'k11',
},
{
name: '商品做法',
name: '做法关联设置',
icon: 'smile',
path: '/goods/goodsPractice',
component: './goods/goodsPractice',
access: 'k9',
},
{
name: '商品做法类别',
icon: 'smile',
path: '/goods/goodsPracticeType',
component: './goods/goodsPracticeType',
access: 'k9',
},
{
name: '商品做法基础信息',
icon: 'smile',
path: '/goods/goodsPracticeInfo',
component: './goods/goodsPracticeInfo',
access: 'k9',
},
],
},
{


+ 308
- 657
src/pages/goods/goodsPractice/index.jsx View File

@@ -7,683 +7,334 @@ import ProDescriptions from '@ant-design/pro-descriptions';
import moment from 'moment';
const { TabPane } = Tabs;
import {
addPracticeType,
getPracticeType,
editPracticeType,
editPracticeRecord,
addPracticeRecord,
getPracticeRecord,
getPracticeRelevance,
addPracticeRelevance,
editPracticeRelevance,
GetAllType,
GetAllSmallType,
GetAllGoods,
GetAllPractice
addPracticeType,
getPracticeType,
editPracticeType,
editPracticeRecord,
addPracticeRecord,
getPracticeRecord,
getPracticeRelevance,
addPracticeRelevance,
editPracticeRelevance,
GetAllType,
GetAllSmallType,
GetAllGoods,
GetAllPractice
} from './service';

import CreateTypeForm from './components/createTypeForm';
import CreateRecordForm from './components/createRecordForm';
import CreateRelevanceForm from './components/createRelevanceForm';

import { set } from 'lodash';
import record from '@/pages/crm/coupon/coupon-Batch/components/ShowRecord';

const PageIndex = (props) => {
const actionRef = useRef();
const [createTypeModalVisible, handleTypeModalVisible] = useState();
const [createRecordModalVisible, handleRecordModalVisible] = useState();
const [createRelevanceModalVisible, handleRelevanceModalVisible] = useState();
const [thisItemId, setthisItemId] = useState();
const [TypecurrentRow, setTypecurrentRow] = useState();
const [RecordCurrentRow, setRecordCurrentRow] = useState();
const [RelevanceCurrentRow, setRelevanceCurrentRow] = useState();

const [AllTypeList, setAllTypeList] = useState([]);
const [domrelevanceType, setdomrelevanceType] = useState(1);

const [Support, setSupport] = useState({
allType: [],
allSmallType: [],
allGoods: [],
allPractice: []
});


/**
* 数据操作
*/
/**
* 添加节点
*
* @param fields
*/
function handleRecordAdd(fields) {
try {
addPracticeRecord(fields)
.then((r) => {
if (r.data) {
message.success('添加成功');
//刷新数据
actionRef.current.reload();
} else {
message.error('添加失败请重试!');
}
});
return true;
} catch (error) {
const actionRef = useRef();
const [createTypeModalVisible, handleTypeModalVisible] = useState();
const [createRecordModalVisible, handleRecordModalVisible] = useState();
const [createRelevanceModalVisible, handleRelevanceModalVisible] = useState();
const [thisItemId, setthisItemId] = useState();
const [TypecurrentRow, setTypecurrentRow] = useState();
const [RecordCurrentRow, setRecordCurrentRow] = useState();
const [RelevanceCurrentRow, setRelevanceCurrentRow] = useState();

const [AllTypeList, setAllTypeList] = useState([]);
const [domrelevanceType, setdomrelevanceType] = useState(1);

const [Support, setSupport] = useState({
allType: [],
allSmallType: [],
allGoods: [],
allPractice: []
});


/**
* 数据操作
*/
function handleRelevanceAdd(fields) {
try {
addPracticeRelevance(fields)
.then((r) => {
if (r.data) {
message.success('添加成功');
//刷新数据
actionRef.current.reload();
} else {
message.error('添加失败请重试!');
return false;
}
}

function handleTypeAdd(fields) {
try {
addPracticeType(fields)
.then((r) => {
if (r.data) {
message.success('添加成功');
//刷新数据
actionRef.current.reload();
} else {
message.error('添加失败请重试!');
}
});
return true;
} catch (error) {
message.error('添加失败请重试!');
return false;
}
}

function handleRelevanceAdd(fields) {
try {
addPracticeRelevance(fields)
.then((r) => {
if (r.data) {
message.success('添加成功');
//刷新数据
actionRef.current.reload();
} else {
message.error('添加失败请重试!');
}
});
return true;
} catch (error) {
message.error('添加失败请重试!');
return false;
}
}
});
return true;
} catch (error) {
message.error('添加失败请重试!');
return false;
}
}



/**
* 更新节点
*
* @param fields
*/
/**
* 更新节点
*
* @param fields
*/

function handleRecordUpdate(fields) {
try {
editPracticeRecord(fields)
.then((r) => {
if (r.data) {
message.success('配置成功');
} else {
message.error('配置失败请重试!');
}
setRecordCurrentRow(undefined);
//刷新数据
actionRef.current.reload();
});
return true;
} catch (error) {
function handleRelevanceUpdate(fields) {
try {
editPracticeRelevance(fields)
.then((r) => {
if (r.data) {
message.success('配置成功');
} else {
message.error('配置失败请重试!');
return false;
}
}

function handleTypeUpdate(fields) {
try {
editPracticeType(fields)
.then((r) => {
if (r.data) {
message.success('配置成功');
} else {
message.error('配置失败请重试!');
}
setTypecurrentRow(undefined);
//刷新数据
actionRef.current.reload();
});
return true;
} catch (error) {
message.error('配置失败请重试!');
return false;
}
}

function handleRelevanceUpdate(fields) {
try {
editPracticeRelevance(fields)
.then((r) => {
if (r.data) {
message.success('配置成功');
} else {
message.error('配置失败请重试!');
}
setTypecurrentRow(undefined);
//刷新数据
actionRef.current.reload();
});
return true;
} catch (error) {
message.error('配置失败请重试!');
return false;
}
}



useEffect(() => {
const parmar = {
current: 1,
pagesize: 99999
};
GetAllType(parmar).then((r) => {
Support.allType = r.data.data;
});
GetAllSmallType(parmar).then((r) => {
Support.allSmallType = r.data.data;
});
GetAllGoods(parmar).then((r) => {
Support.allGoods = r.data.data;
});
GetAllPractice(parmar).then((r) => {
Support.allPractice = r.data.data;
}
setTypecurrentRow(undefined);
//刷新数据
actionRef.current.reload();
});
getPracticeType(parmar).then((r) => {
setAllTypeList(r.data.data);
});

}, []);


/**
* 做法类别列表
*/
const PracticeTypecolumns = [
{
title: '规则id',
dataIndex: 'id',
tip: '规则名称是唯一的 key',
hideInSearch: true,
hideInTable: true,
},
{
title: '做法名称',
dataIndex: 'typeName',
},
{
title: '操作',
dataIndex: 'option',
valueType: 'option',
render: (_, record) => [
<a
key="primary"
onClick={() => {
handleTypeModalVisible(true);
setTypecurrentRow(record);
}}
>
{' '}
修改
</a>,
<a
key="primary"
onClick={() => {
record.status = record.status == 0 ? 1 : 0;
editPracticeType(record);
}}
>
{' '}
{record.status == 0 ? '停用' : '启用'}
</a>,

],
},
];
return true;
} catch (error) {
message.error('配置失败请重试!');
return false;
}
}

/**
* 做法档案列表
*/
const PracticeRecordcolumns = [
{
title: '规则id',
dataIndex: 'id',
tip: '规则名称是唯一的 key',
hideInSearch: true,
hideInTable: true,
},
{
title: '做法名称',
dataIndex: 'practiceName',
},
{
title: '做法编码',
dataIndex: 'code',
},
{
title: '做法类别',
dataIndex: 'practiceTypeName',
},
{
title: '加价',
dataIndex: 'raise',
},
{
title: '加价方式',
dataIndex: 'raiseType',
render: (_, record) => {
if (record.raiseType == 1) {
return (
<label>按出品数量加价</label>
);

} else
if (record.raiseType == 1) {
return (
<label>加价与出品数量无关 </label>
);

} else {
return (
<CloseOutlined />
);
}
}
},
{
title: '操作',
dataIndex: 'option',
valueType: 'option',
render: (_, record) => [
<a
key="primary"
onClick={() => {
handleRecordModalVisible(true);
setRecordCurrentRow(record);
}}
>
{' '}
修改
</a>,
<a
key="primary"
onClick={() => {
record.status = record.status == 0 ? 1 : 0;
editPracticeRecord(record);
}}
>
{' '}
{record.status == 0 ? '停用' : '启用'}
</a>,

],
},
];
useEffect(() => {
const parmar = {
current: 1,
pagesize: 99999
};
GetAllType(parmar).then((r) => {
Support.allType = r.data.data;
});
GetAllSmallType(parmar).then((r) => {
Support.allSmallType = r.data.data;
});
GetAllGoods(parmar).then((r) => {
Support.allGoods = r.data.data;
});
GetAllPractice(parmar).then((r) => {
Support.allPractice = r.data.data;
});
getPracticeType(parmar).then((r) => {
setAllTypeList(r.data.data);
});

/**
* 出品做法关联设置
*/
const relevanceColumns = [
{
title: '规则id',
dataIndex: 'id',
tip: '规则名称是唯一的 key',
hideInSearch: true,
hideInTable: true,
},
{
title: '关联类型',
dataIndex: 'relevanceType',
render: (_, record) => {
switch (record.relevanceType) {
case 1:
return (
<label>出品类别与做法类别关联</label>
);
break;
case 2:
return (
<label>出品与做法关联</label>
);
break;
default:
return (
<CloseOutlined />
);
break;
}
}, []);


/**
* 出品做法关联设置
*/
const TyperelevanceColumns = [
{
title: '规则id',
dataIndex: 'id',
tip: '规则名称是唯一的 key',
hideInSearch: true,
hideInTable: true,
},
{
title: '类别',
dataIndex: 'values1Name',
},
{
title: '做法',
dataIndex: 'values2Name',
},
{
title: '操作',
dataIndex: 'option',
valueType: 'option',
render: (_, record) => [
<a
key="primary"
onClick={() => {
handleRelevanceModalVisible(true);
setRelevanceCurrentRow(record);
}}
>
{' '}
修改
</a>,
<a
key="primary"
onClick={() => {
record.status = record.status == 0 ? 1 : 0;
editPracticeRecord(record);
}}
>
{' '}
{record.status == 0 ? '停用' : '启用'}
</a>,

],
},
];
const GoodsrelevanceColumns = [
{
title: '规则id',
dataIndex: 'id',
tip: '规则名称是唯一的 key',
hideInSearch: true,
hideInTable: true,
},
{
title: '商品',
dataIndex: 'values1Name',
},
{
title: '做法',
dataIndex: 'values2Name',
},
{
title: '操作',
dataIndex: 'option',
valueType: 'option',
render: (_, record) => [
<a
key="primary"
onClick={() => {
handleRelevanceModalVisible(true);
setRelevanceCurrentRow(record);
}}
>
{' '}
修改
</a>,
<a
key="primary"
onClick={() => {
record.status = record.status == 0 ? 1 : 0;
editPracticeRecord(record);
}}
>
{' '}
{record.status == 0 ? '停用' : '启用'}
</a>,

],
},
];

return (
<Tabs defaultActiveKey="1" >

<CreateRelevanceForm
onFinish={async (value) => {
var success = false;
if (value.id) {
success = handleRelevanceUpdate(value);
} else {
success = handleRelevanceAdd(value);
}
if (success) {
handleRelevanceModalVisible(false);
setRelevanceCurrentRow(undefined);
if (actionRef.current) {
actionRef.current.reload();
}
},
{
title: '商品',
dataIndex: 'values1Name',
},
{
title: '做法',
dataIndex: 'values2Name',
},
{
title: '操作',
dataIndex: 'option',
valueType: 'option',
render: (_, record) => [
<a
key="primary"
onClick={() => {
handleRelevanceModalVisible(true);
setRelevanceCurrentRow(record);
}}
>
{' '}
修改
</a>,
<a
key="primary"
onClick={() => {
record.status = record.status == 0 ? 1 : 0;
editPracticeRecord(record);
}}
>
{' '}
{record.status == 0 ? '停用' : '启用'}
</a>,

],
},
];

return (
<Tabs defaultActiveKey="1" >

<CreateTypeForm
onFinish={async (value) => {
debugger;
var success = false;
if (value.id) {
success = handleTypeUpdate(value);
} else {
success = handleTypeAdd(value);
}
if (success) {
handleTypeModalVisible(false);
setTypecurrentRow(undefined);
if (actionRef.current) {
actionRef.current.reload();
}
}
}}
onCancel={() => {
setTypecurrentRow(undefined);
handleTypeModalVisible(false);
actionRef.current.reload();
}}
createModalVisible={createTypeModalVisible}
values={TypecurrentRow || {}}
}
}}
onCancel={() => {
setRelevanceCurrentRow(undefined);
handleRelevanceModalVisible(false);
actionRef.current.reload();
}}
Support={Support}
domrelevanceType={domrelevanceType}
createModalVisible={createRelevanceModalVisible}
values={RelevanceCurrentRow || {}}
>
</CreateRelevanceForm>
<TabPane tab="出品类别与做法类别关联" key="1" style={{ float: 'left' }} >
<ProTable
actionRef={actionRef}
rowKey="id"
search={{
labelWidth: 120,
}}
toolBarRender={() => [
<Button
type="primary"
key="primary"
onClick={() => {
handleRelevanceModalVisible(true);
}}
>
</CreateTypeForm>

<CreateRecordForm
onFinish={async (value) => {
var success = false;
if (value.id) {
success = handleRecordUpdate(value);
} else {
success = handleRecordAdd(value);
}
if (success) {
handleRecordModalVisible(false);
setRecordCurrentRow(undefined);
if (actionRef.current) {
actionRef.current.reload();
}
}
}}
onCancel={() => {
setRecordCurrentRow(undefined);
handleRecordModalVisible(false);
actionRef.current.reload();
}}
TypeList={AllTypeList || []}
createModalVisible={createRecordModalVisible}
values={RecordCurrentRow || {}}
<PlusOutlined /> 添加
</Button>
]}
params={{
relevanceType: 1,
}}
request={async (params) => {
var datas = [];
var total = 0;
await getPracticeRelevance(params).then((r) => {
datas = r.data.data;
total = r.data.total;
});
return {
data: datas,
success: true,
total: total,
};
}}
modalVisible={createRelevanceModalVisible}
columns={TyperelevanceColumns}
rowSelection={{
onChange: (_, selectedRows) => {
setTypecurrentRow(selectedRows);
},
}}
/>
</TabPane>

<TabPane tab="出品与做法关联" key="2" style={{ float: 'left' }} >
<ProTable
actionRef={actionRef}
rowKey="id"
search={{
labelWidth: 120,
}}
toolBarRender={() => [
<Button
type="primary"
key="primary"
onClick={() => {
handleRelevanceModalVisible(true);
}}
>
</CreateRecordForm>

<CreateRelevanceForm
onFinish={async (value) => {
var success = false;
if (value.id) {
success = handleRelevanceUpdate(value);
} else {
success = handleRelevanceAdd(value);
}
if (success) {
handleRelevanceModalVisible(false);
setRelevanceCurrentRow(undefined);
if (actionRef.current) {
actionRef.current.reload();
}
}
}}
onCancel={() => {
setRelevanceCurrentRow(undefined);
handleRelevanceModalVisible(false);
actionRef.current.reload();
}}
Support={Support}
domrelevanceType={domrelevanceType}
createModalVisible={createRelevanceModalVisible}
values={RelevanceCurrentRow || {}}
>
</CreateRelevanceForm>

<TabPane tab="出品做法关联设置" key="1" style={{ float: 'left' }} >
<Tabs onTabClick={(_,record) => {
setdomrelevanceType(_);
}}>
<TabPane tab="出品类别与做法类别关联" key="1" style={{ float: 'left' }} >
<ProTable
actionRef={actionRef}
rowKey="id"
search={{
labelWidth: 120,
}}
toolBarRender={() => [
<Button
type="primary"
key="primary"
onClick={() => {
handleRelevanceModalVisible(true);
}}
>
<PlusOutlined /> 添加
</Button>
]}
params={{
relevanceType: 1,
}}
request={async (params) => {
var datas = [];
var total = 0;
await getPracticeRelevance(params).then((r) => {
datas = r.data.data;
total = r.data.total;
});
return {
data: datas,
success: true,
total: total,
};
}}
modalVisible={createRelevanceModalVisible}
columns={relevanceColumns}
rowSelection={{
onChange: (_, selectedRows) => {
setTypecurrentRow(selectedRows);
},
}}
/>
</TabPane>

<TabPane tab="出品与做法关联" key="2" style={{ float: 'left' }} >
<ProTable
actionRef={actionRef}
rowKey="id"
search={{
labelWidth: 120,
}}
toolBarRender={() => [
<Button
type="primary"
key="primary"
onClick={() => {
handleRelevanceModalVisible(true);
}}
>
<PlusOutlined /> 添加
</Button>
]}
params={{
relevanceType: 2,
}}
request={async (params) => {
var datas = [];
var total = 0;

await getPracticeRelevance(params).then((r) => {
datas = r.data.data;
total = r.data.total;
});
return {
data: datas,
success: true,
total: total,
};
}}
modalVisible={createRelevanceModalVisible}
columns={relevanceColumns}
rowSelection={{
onChange: (_, selectedRows) => {
setTypecurrentRow(selectedRows);
},
}}
/>
</TabPane>
</Tabs>

</TabPane>

<TabPane tab="做法档案" key="2" style={{ float: 'left' }}>
<ProTable
actionRef={actionRef}
rowKey="id"
search={{
labelWidth: 120,
}}
toolBarRender={() => [
<Button
type="primary"
key="primary"
onClick={() => {
if (AllTypeList.length == 0) {
getPracticeType({
thisItemId,
}).then((r) => {
setAllTypeList(r.data.data);
});
}
handleRecordModalVisible(true);
}}
>
<PlusOutlined /> 添加
</Button>
]}
params={{
thisItemId,
}}
request={async (params) => {
var datas = [];
var total = 0;
await getPracticeRecord(params).then((r) => {
datas = r.data.data;
total = r.data.total;
});
return {
data: datas,
success: true,
total: total,
};
}}
modalVisible={createRecordModalVisible}
columns={PracticeRecordcolumns}
rowSelection={{
onChange: (_, selectedRows) => {
setRecordCurrentRow(selectedRows);
},
}}
/>
</TabPane>

<TabPane tab="做法类型" key="3" style={{ float: 'left' }}>
<ProTable
actionRef={actionRef}
rowKey="id"
search={{
labelWidth: 120,
}}
toolBarRender={() => [
<Button
type="primary"
key="primary"
onClick={() => {
handleTypeModalVisible(true);
}}
>
<PlusOutlined /> 添加
</Button>
]}
params={{
thisItemId,
}}
request={async (params) => {
var datas = [];
var total = 0;
await getPracticeType(params).then((r) => {
// setAllTypeList(r.data.data);
datas = r.data.data;
total = r.data.total;
});
return {
data: datas,
success: true,
total: total,
};
}}
modalVisible={createTypeModalVisible}
columns={PracticeTypecolumns}
rowSelection={{
onChange: (_, selectedRows) => {
setTypecurrentRow(selectedRows);
},
}}
/>
</TabPane>

</Tabs>
);
<PlusOutlined /> 添加
</Button>
]}
params={{
relevanceType: 2,
}}
request={async (params) => {
var datas = [];
var total = 0;

await getPracticeRelevance(params).then((r) => {
datas = r.data.data;
total = r.data.total;
});
return {
data: datas,
success: true,
total: total,
};
}}
modalVisible={createRelevanceModalVisible}
columns={GoodsrelevanceColumns}
rowSelection={{
onChange: (_, selectedRows) => {
setTypecurrentRow(selectedRows);
},
}}
/>
</TabPane>
</Tabs>
);
};

export default PageIndex;

src/pages/goods/goodsPractice/components/createRecordForm.jsx → src/pages/goods/goodsPracticeInfo/components/createRecordForm.jsx View File


+ 258
- 0
src/pages/goods/goodsPracticeInfo/index.jsx View File

@@ -0,0 +1,258 @@
import { FontColorsOutlined, PlusOutlined, DownOutlined, CheckOutlined, CloseOutlined } from '@ant-design/icons';
import { Modal, Form, Input, Button, Select, TreeSelect, Space, Checkbox, Col, Row, DatePicker, Card, List, Tree, message, Drawer, Divider, Tag, Tabs } 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 moment from 'moment';
const { TabPane } = Tabs;
import {
addPracticeType,
getPracticeType,
editPracticeType,
editPracticeRecord,
addPracticeRecord,
getPracticeRecord,
getPracticeRelevance,
addPracticeRelevance,
editPracticeRelevance,
GetAllType,
GetAllSmallType,
GetAllGoods,
GetAllPractice
} from './service';

import CreateRecordForm from './components/createRecordForm';

const PageIndex = (props) => {
const actionRef = useRef();
const [createRecordModalVisible, handleRecordModalVisible] = useState();
const [RecordCurrentRow, setRecordCurrentRow] = useState();

const [AllTypeList, setAllTypeList] = useState([]);



/**
* 数据操作
*/
/**
* 添加节点
*
* @param fields
*/
function handleRecordAdd(fields) {
try {
addPracticeRecord(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 handleRecordUpdate(fields) {
try {
editPracticeRecord(fields)
.then((r) => {
if (r.data) {
message.success('配置成功');
} else {
message.error('配置失败请重试!');
}
setRecordCurrentRow(undefined);
//刷新数据
actionRef.current.reload();
});
return true;
} catch (error) {
message.error('配置失败请重试!');
return false;
}
}



useEffect(() => {
const parmar = {
current: 1,
pagesize: 99999
};
function initPracticeType() {
GetAllType(parmar).then((r) => {
setAllTypeList(r.data.data);
});
}
initPracticeType();
}, []);


/**
* 做法档案列表
*/
const PracticeRecordcolumns = [
{
title: '规则id',
dataIndex: 'id',
tip: '规则名称是唯一的 key',
hideInSearch: true,
hideInTable: true,
},
{
title: '做法名称',
dataIndex: 'practiceName',
},
{
title: '做法编码',
dataIndex: 'code',
},
{
title: '做法类别',
dataIndex: 'practiceTypeName',
},
{
title: '加价',
dataIndex: 'raise',
},
{
title: '加价方式',
dataIndex: 'raiseType',
render: (_, record) => {
if (record.raiseType == 1) {
return (
<label>按出品数量加价</label>
);

} else
if (record.raiseType == 1) {
return (
<label>加价与出品数量无关 </label>
);

} else {
return (
<CloseOutlined />
);
}
}
},
{
title: '操作',
dataIndex: 'option',
valueType: 'option',
render: (_, record) => [
<a
key="primary"
onClick={() => {
handleRecordModalVisible(true);
setRecordCurrentRow(record);
}}
>
{' '}
修改
</a>,
<a
key="primary"
onClick={() => {
record.status = record.status == 0 ? 1 : 0;
editPracticeRecord(record);
}}
>
{' '}
{record.status == 0 ? '停用' : '启用'}
</a>,

],
},
];

return (

<PageContainer>
<CreateRecordForm
onFinish={async (value) => {
var success = false;
if (value.id) {
success = handleRecordUpdate(value);
} else {
success = handleRecordAdd(value);
}
if (success) {
handleRecordModalVisible(false);
setRecordCurrentRow(undefined);
if (actionRef.current) {
actionRef.current.reload();
}
}
}}
onCancel={() => {
setRecordCurrentRow(undefined);
handleRecordModalVisible(false);
actionRef.current.reload();
}}
TypeList={AllTypeList || []}
createModalVisible={createRecordModalVisible}
values={RecordCurrentRow || {}}
>
</CreateRecordForm>
<ProTable
actionRef={actionRef}
rowKey="id"
search={{
labelWidth: 120,
}}
toolBarRender={() => [
<Button
type="primary"
key="primary"
onClick={() => {
handleRecordModalVisible(true);
}}
>
<PlusOutlined /> 添加
</Button>
]}
request={async (params) => {
var datas = [];
var total = 0;
await getPracticeRecord(params).then((r) => {
datas = r.data.data;
total = r.data.total;
});
return {
data: datas,
success: true,
total: total,
};
}}
modalVisible={createRecordModalVisible}
columns={PracticeRecordcolumns}
rowSelection={{
onChange: (_, selectedRows) => {
setRecordCurrentRow(selectedRows);
},
}}
/>
</PageContainer>
);
};

export default PageIndex;

+ 137
- 0
src/pages/goods/goodsPracticeInfo/service.js View File

@@ -0,0 +1,137 @@
import { request } from 'umi';


/**
* 添加做法
*/

export async function addPracticeType(data) {
return request(`/kitchen/api/goodspracticetype/add`, {
method: 'POST',
data: data,
});
}



/**
* 获取做法分页
*/

export async function getPracticeType(data) {
return request(`/kitchen/api/goodspracticetype/get`, {
method: 'POST',
data: data,
});
}



/**
* 修改做法
*/

export async function editPracticeType(data) {
return request(`/kitchen/api/goodspracticetype/edit`, {
method: 'POST',
data: data,
});
}


/**
* 修改做法档案
*/

export async function editPracticeRecord(data) {
return request(`/kitchen/api/goodspractice/edit`, {
method: 'POST',
data: data,
});
}

/**
* 添加做法档案
*/

export async function addPracticeRecord(data) {
return request(`/kitchen/api/goodspractice/add`, {
method: 'POST',
data: data,
});
}


/**
* 获取做法档案
*/

export async function getPracticeRecord(data) {
return request(`/kitchen/api/goodspractice/get`, {
method: 'POST',
data: data,
});
}





/**
* 获取做法商品关联
*/

export async function getPracticeRelevance(data) {
return request(`/kitchen/api/goodspracticerelevance/get`, {
method: 'POST',
data: data,
});
}

export async function addPracticeRelevance(data) {
return request(`/kitchen/api/goodspracticerelevance/add`, {
method: 'POST',
data: data,
});
}

export async function editPracticeRelevance(data) {
return request(`/kitchen/api/goodspracticerelevance/edit`, {
method: 'POST',
data: data,
});
}



/**
* 支撑数据
*/

export async function GetAllSmallType(data) {
return request(`/kitchen/api/goods-type/goods-types`, {
method: 'POST',
data: data,
});
}

export async function GetAllType(data) {
return request(`/kitchen/api/goodspracticetype/get`, {
method: 'POST',
data: data,
});
}

export async function GetAllGoods(data) {
return request(`/kitchen/api/goods/goodss`, {
method: 'Post',
data: data,
});
}

export async function GetAllPractice(data) {
return request(`/kitchen/api/goodspractice/get`, {
method: 'POST',
data: data,
});
}

src/pages/goods/goodsPractice/components/createTypeForm.jsx → src/pages/goods/goodsPracticeType/components/createTypeForm.jsx View File


+ 180
- 0
src/pages/goods/goodsPracticeType/index.jsx View File

@@ -0,0 +1,180 @@
import { FontColorsOutlined, PlusOutlined, DownOutlined, CheckOutlined, CloseOutlined } from '@ant-design/icons';
import { Modal, Form, Input, Button, Select, TreeSelect, Space, Checkbox, Col, Row, DatePicker, Card, List, Tree, message, Drawer, Divider, Tag, Tabs } 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 moment from 'moment';
const { TabPane } = Tabs;
import {
addPracticeType,
getPracticeType,
editPracticeType,
} from './service';

import CreateTypeForm from './components/createTypeForm';

const PageIndex = (props) => {
const actionRef = useRef();
const [createTypeModalVisible, handleTypeModalVisible] = useState()

const [TypecurrentRow, setTypecurrentRow] = useState();

function handleTypeAdd(fields) {
try {
addPracticeType(fields)
.then((r) => {
if (r.data) {
message.success('添加成功');
//刷新数据
actionRef.current.reload();
} else {
message.error('添加失败请重试!');
}
});
return true;
} catch (error) {
message.error('添加失败请重试!');
return false;
}
}


function handleTypeUpdate(fields) {
try {
editPracticeType(fields)
.then((r) => {
if (r.data) {
message.success('配置成功');
} else {
message.error('配置失败请重试!');
}
setTypecurrentRow(undefined);
//刷新数据
actionRef.current.reload();
});
return true;
} catch (error) {
message.error('配置失败请重试!');
return false;
}
}

/**
* 做法类别列表
*/
const PracticeTypecolumns = [
{
title: '规则id',
dataIndex: 'id',
tip: '规则名称是唯一的 key',
hideInSearch: true,
hideInTable: true,
},
{
title: '做法名称',
dataIndex: 'typeName',
},
{
title: '操作',
dataIndex: 'option',
valueType: 'option',
render: (_, record) => [
<a
key="primary"
onClick={() => {
handleTypeModalVisible(true);
setTypecurrentRow(record);
}}
>
{' '}
修改
</a>,
<a
key="primary"
onClick={() => {
record.status = record.status == 0 ? 1 : 0;
editPracticeType(record);
}}
>
{' '}
{record.status == 0 ? '停用' : '启用'}
</a>,

],
},
];

return (
<PageContainer>
<ProTable
actionRef={actionRef}
rowKey="id"
search={{
labelWidth: 120,
}}
toolBarRender={() => [
<Button
type="primary"
key="primary"
onClick={() => {
handleTypeModalVisible(true);
}}
>
<PlusOutlined /> 添加
</Button>
]}
request={async (params) => {
var datas = [];
var total = 0;
await getPracticeType(params).then((r) => {
// setAllTypeList(r.data.data);
datas = r.data.data;
total = r.data.total;
});
return {
data: datas,
success: true,
total: total,
};
}}
modalVisible={createTypeModalVisible}
columns={PracticeTypecolumns}
rowSelection={{
onChange: (_, selectedRows) => {
setTypecurrentRow(selectedRows);
},
}}
/>
<CreateTypeForm
onFinish={async (value) => {
debugger;
var success = false;
if (value.id) {
success = handleTypeUpdate(value);
} else {
success = handleTypeAdd(value);
}
if (success) {
handleTypeModalVisible(false);
setTypecurrentRow(undefined);
if (actionRef.current) {
actionRef.current.reload();
}
}
}}
onCancel={() => {
setTypecurrentRow(undefined);
handleTypeModalVisible(false);
actionRef.current.reload();
}}
createModalVisible={createTypeModalVisible}
values={TypecurrentRow || {}}
>
</CreateTypeForm>

</PageContainer>
);
};

export default PageIndex;

+ 137
- 0
src/pages/goods/goodsPracticeType/service.js View File

@@ -0,0 +1,137 @@
import { request } from 'umi';


/**
* 添加做法
*/

export async function addPracticeType(data) {
return request(`/kitchen/api/goodspracticetype/add`, {
method: 'POST',
data: data,
});
}



/**
* 获取做法分页
*/

export async function getPracticeType(data) {
return request(`/kitchen/api/goodspracticetype/get`, {
method: 'POST',
data: data,
});
}



/**
* 修改做法
*/

export async function editPracticeType(data) {
return request(`/kitchen/api/goodspracticetype/edit`, {
method: 'POST',
data: data,
});
}


/**
* 修改做法档案
*/

export async function editPracticeRecord(data) {
return request(`/kitchen/api/goodspractice/edit`, {
method: 'POST',
data: data,
});
}

/**
* 添加做法档案
*/

export async function addPracticeRecord(data) {
return request(`/kitchen/api/goodspractice/add`, {
method: 'POST',
data: data,
});
}


/**
* 获取做法档案
*/

export async function getPracticeRecord(data) {
return request(`/kitchen/api/goodspractice/get`, {
method: 'POST',
data: data,
});
}





/**
* 获取做法商品关联
*/

export async function getPracticeRelevance(data) {
return request(`/kitchen/api/goodspracticerelevance/get`, {
method: 'POST',
data: data,
});
}

export async function addPracticeRelevance(data) {
return request(`/kitchen/api/goodspracticerelevance/add`, {
method: 'POST',
data: data,
});
}

export async function editPracticeRelevance(data) {
return request(`/kitchen/api/goodspracticerelevance/edit`, {
method: 'POST',
data: data,
});
}



/**
* 支撑数据
*/

export async function GetAllSmallType(data) {
return request(`/kitchen/api/goods-type/goods-types`, {
method: 'POST',
data: data,
});
}

export async function GetAllType(data) {
return request(`/kitchen/api/goodspracticetype/get`, {
method: 'POST',
data: data,
});
}

export async function GetAllGoods(data) {
return request(`/kitchen/api/goods/goodss`, {
method: 'Post',
data: data,
});
}

export async function GetAllPractice(data) {
return request(`/kitchen/api/goodspractice/get`, {
method: 'POST',
data: data,
});
}

Loading…
Cancel
Save