@@ -308,6 +308,19 @@ export default [ | |||
}, | |||
], | |||
}, | |||
{ | |||
name: '优惠券管理', | |||
icon: 'BankFilled', | |||
path: '/shopmanage/coupon', | |||
routes: [ | |||
{ | |||
name: '纸质优惠券管理', | |||
icon: 'smile', | |||
path: '/shopmanage/coupon/paperCoupon', | |||
component: './shopmanage/coupon/paperCoupon', | |||
} | |||
], | |||
}, | |||
{ | |||
name: '门店会员管理', | |||
icon: 'BankFilled', | |||
@@ -495,10 +495,12 @@ const Material = () => { | |||
})() | |||
} | |||
</Upload> | |||
<Button htmlType="button" style={{ float: 'right', left: 10 }} onClick={() => setIsModalVisible(false)}> | |||
<Button type="primary" htmlType="submit" style={{ float: 'right', left: 10 }} onClick={() => onAddPageMaterial()}> | |||
确认 | |||
</Button> | |||
<Button htmlType="button" style={{ float: 'right' }} onClick={() => setIsModalVisible(false)} > | |||
取消 | |||
</Button> | |||
<Button type="primary" htmlType="submit" style={{ float: 'right' }} onClick={() => onAddPageMaterial()}>保存</Button> | |||
</div> | |||
@@ -255,13 +255,13 @@ const pageManage = () => { | |||
</Form.Item> | |||
<Form.Item> | |||
<Button htmlType="button" style={{float:'right',left:10}} onClick={() => setIsModalVisible(false)}> | |||
取消 | |||
<Button type="primary" htmlType="submit" style={{ float: 'right', left: 10 }} > | |||
确认 | |||
</Button> | |||
<Button type="primary" htmlType="submit" style={{float:'right'}} > | |||
保存 | |||
<Button htmlType="button" style={{ float: 'right' }} onClick={() => setIsModalVisible(false)}> | |||
取消 | |||
</Button> | |||
</Form.Item> | |||
</Form> | |||
</Modal> | |||
@@ -126,26 +126,26 @@ const goodspush = () => { | |||
> | |||
重发 | |||
</a>, | |||
<Popconfirm | |||
type="primary" | |||
key="primary" | |||
title="确认删除吗?" | |||
okText="是" | |||
cancelText="否" | |||
onConfirm={async () => { | |||
await DeleteGoodsType(record.id).then((r) => { | |||
if (r.succeeded) { | |||
message.success('删除成功'); | |||
actionRef.current.reloadAndRest(); | |||
} else { | |||
message.error(r.errors); | |||
} | |||
}); | |||
}} | |||
onCancel={() => {}} | |||
> | |||
<a href="#">删除</a> | |||
</Popconfirm>, | |||
// <Popconfirm | |||
// type="primary" | |||
// key="primary" | |||
// title="确认删除吗?" | |||
// okText="是" | |||
// cancelText="否" | |||
// onConfirm={async () => { | |||
// await DeleteGoodsType(record.id).then((r) => { | |||
// if (r.succeeded) { | |||
// message.success('删除成功'); | |||
// actionRef.current.reloadAndRest(); | |||
// } else { | |||
// message.error(r.errors); | |||
// } | |||
// }); | |||
// }} | |||
// onCancel={() => {}} | |||
// > | |||
// <a href="#">删除</a> | |||
// </Popconfirm>, | |||
], | |||
}, | |||
]; | |||
@@ -15,7 +15,7 @@ export async function GetDevicePushRecodePage(data) { | |||
} | |||
export async function DevicePushRecodeUpdate(data) { | |||
return request(getStoremanagement()+`/api/devicepushrecode/update?id=`+data, { | |||
method: 'POST', | |||
method: 'get', | |||
data: data, | |||
}); | |||
} | |||
@@ -126,26 +126,26 @@ const goodspush = () => { | |||
> | |||
重发 | |||
</a>, | |||
<Popconfirm | |||
type="primary" | |||
key="primary" | |||
title="确认删除吗?" | |||
okText="是" | |||
cancelText="否" | |||
onConfirm={async () => { | |||
await DeleteGoodsType(record.id).then((r) => { | |||
if (r.succeeded) { | |||
message.success('删除成功'); | |||
actionRef.current.reloadAndRest(); | |||
} else { | |||
message.error(r.errors); | |||
} | |||
}); | |||
}} | |||
onCancel={() => {}} | |||
> | |||
<a href="#">删除</a> | |||
</Popconfirm>, | |||
// <Popconfirm | |||
// type="primary" | |||
// key="primary" | |||
// title="确认删除吗?" | |||
// okText="是" | |||
// cancelText="否" | |||
// onConfirm={async () => { | |||
// await DeleteGoodsType(record.id).then((r) => { | |||
// if (r.succeeded) { | |||
// message.success('删除成功'); | |||
// actionRef.current.reloadAndRest(); | |||
// } else { | |||
// message.error(r.errors); | |||
// } | |||
// }); | |||
// }} | |||
// onCancel={() => {}} | |||
// > | |||
// <a href="#">删除</a> | |||
// </Popconfirm>, | |||
], | |||
}, | |||
]; | |||
@@ -15,7 +15,7 @@ export async function GetDevicePushRecodePage(data) { | |||
} | |||
export async function DevicePushRecodeUpdate(data) { | |||
return request(getStoremanagement()+`/api/devicepushrecode/update?id=`+data, { | |||
method: 'POST', | |||
method: 'get', | |||
data: data, | |||
}); | |||
} | |||
@@ -126,26 +126,26 @@ const goodspush = () => { | |||
> | |||
重发 | |||
</a>, | |||
<Popconfirm | |||
type="primary" | |||
key="primary" | |||
title="确认删除吗?" | |||
okText="是" | |||
cancelText="否" | |||
onConfirm={async () => { | |||
await DeleteGoodsType(record.id).then((r) => { | |||
if (r.succeeded) { | |||
message.success('删除成功'); | |||
actionRef.current.reloadAndRest(); | |||
} else { | |||
message.error(r.errors); | |||
} | |||
}); | |||
}} | |||
onCancel={() => {}} | |||
> | |||
<a href="#">删除</a> | |||
</Popconfirm>, | |||
// <Popconfirm | |||
// type="primary" | |||
// key="primary" | |||
// title="确认删除吗?" | |||
// okText="是" | |||
// cancelText="否" | |||
// onConfirm={async () => { | |||
// await DeleteGoodsType(record.id).then((r) => { | |||
// if (r.succeeded) { | |||
// message.success('删除成功'); | |||
// actionRef.current.reloadAndRest(); | |||
// } else { | |||
// message.error(r.errors); | |||
// } | |||
// }); | |||
// }} | |||
// onCancel={() => {}} | |||
// > | |||
// <a href="#">删除</a> | |||
// </Popconfirm>, | |||
], | |||
}, | |||
]; | |||
@@ -15,7 +15,7 @@ export async function GetDevicePushRecodePage(data) { | |||
} | |||
export async function DevicePushRecodeUpdate(data) { | |||
return request(getStoremanagement()+`/api/devicepushrecode/update?id=`+data, { | |||
method: 'POST', | |||
method: 'get', | |||
data: data, | |||
}); | |||
} | |||
@@ -0,0 +1,198 @@ | |||
import React, { useRef,useState, useEffect } from 'react'; | |||
import { Modal, Form, Input, Button, Select, InputNumber, Divider, Space,message } from 'antd'; | |||
import { PlusOutlined } from '@ant-design/icons'; | |||
import { GetPaperCouponType,AddPaperCouponType } from '../../service'; | |||
import GoodsList from '../GoodsList' | |||
let index = 0; | |||
const CreateForm = (props) => { | |||
const[form]=Form.useForm(); | |||
const [items, setItems] = useState(); | |||
const [visiblegoods, setvisiblegoods] = useState(false); | |||
const inputRef = useRef(null); | |||
const [name, setName] = useState(''); | |||
const [checkgoods,setcheckgoods]=useState([]); | |||
//初始化数据 | |||
useEffect(() => { | |||
//form.resetFields(); | |||
initcouponType(); | |||
}, []); | |||
useEffect(()=>{ | |||
form.setFieldsValue(props.values); | |||
},[props.values]) | |||
const initcouponType = async () => { | |||
var data = await GetPaperCouponType(); | |||
var op=[] | |||
data.data.map((item) => ( | |||
op.push({label:item.value,value:item.key}) | |||
)); | |||
setItems(op) | |||
}; | |||
const formItemLayout = { | |||
labelCol: { | |||
sm: { span: 4 }, | |||
}, | |||
wrapperCol: {}, | |||
}; | |||
const tailFormItemLayout = { | |||
wrapperCol: { | |||
sm: { | |||
span: 500, | |||
offset: 1, | |||
}, | |||
}, | |||
}; | |||
const onNameChange = (event) => { | |||
setName(event.target.value); | |||
}; | |||
const addItem = async (e) => { | |||
e.preventDefault(); | |||
setItems([...items, {label:name,value:index++} || `New item ${index++}`]); | |||
setName(''); | |||
setTimeout(() => { | |||
inputRef.current?.focus(); | |||
}, 0); | |||
await AddPaperCouponType(JSON.stringify({Name:name})).then((r) => { | |||
if (r.data) { | |||
message.success('添加成功'); | |||
initcouponType(); | |||
} else { | |||
message.error('添加失败请重试!'); | |||
} | |||
}) | |||
}; | |||
const ongoodsopen= () => { | |||
setvisiblegoods(true); | |||
} | |||
const oncheck=(data)=>{ | |||
console.log(data) | |||
setcheckgoods(data) | |||
} | |||
return <> | |||
<Modal | |||
maskClosable={false} | |||
title={props.values.id ? '编辑优惠卷' : '新建优惠卷'} | |||
width={700} | |||
visible={props.createModalVisible} | |||
// bodyStyle={{ padding: '32px 40px 48px' }} | |||
footer={null} //底部内容 | |||
//取消 | |||
onCancel={() => { | |||
props.onCancel(); | |||
}} | |||
//关闭时销毁 Modal 里的子元素 | |||
destroyOnClose | |||
> | |||
<Form | |||
{...formItemLayout} | |||
layout="Horizontal" | |||
preserve={false} | |||
form={form} | |||
onFinish={props.onFinish} | |||
> | |||
<Form.Item name="id" hidden={true}> | |||
<Input /> | |||
</Form.Item> | |||
<Form.Item name="storeId" hidden={true}> | |||
<Input /> | |||
</Form.Item> | |||
<Form.Item name="goodsId" hidden={true}> | |||
<Input /> | |||
</Form.Item> | |||
<Form.Item name="goodsName" label="商品" rules={[{ required: true, max: 200 }]}> | |||
<Input placeholder="请选择商品名称" onClick={ongoodsopen} /> | |||
</Form.Item> | |||
<Form.Item name="title" label="优惠卷标题" rules={[{ required: true, max: 200 }]}> | |||
<Input placeholder="请输入优惠卷标题" /> | |||
</Form.Item> | |||
<Form.Item | |||
name="cTypeId" | |||
label="优惠卷类型" | |||
defaultValue={props.values.cTypeId} | |||
rules={[{ required: true }]} | |||
> | |||
<Select placeholder="请选择优惠卷类型" | |||
dropdownRender={(menu) => ( | |||
<> | |||
{menu} | |||
<Divider | |||
style={{ | |||
margin: '8px 0', | |||
}} | |||
/> | |||
<Space | |||
style={{ | |||
padding: '0 8px 4px', | |||
}} | |||
> | |||
<Input | |||
placeholder="请输入选项" | |||
ref={inputRef} | |||
value={name} | |||
onChange={onNameChange} | |||
/> | |||
<Button type="text" icon={<PlusOutlined />} onClick={addItem}> | |||
新增 | |||
</Button> | |||
</Space> | |||
</> | |||
)} | |||
options={items} | |||
> | |||
{/* <OptGroup>{options}</OptGroup> */} | |||
</Select> | |||
</Form.Item> | |||
<Form.Item {...tailFormItemLayout} style={{ height: 32 }}> | |||
<Form.Item label="原始金额" style={{ float: 'left' }} rules={[{ required: true }]}> | |||
<Form.Item name="money" noStyle> | |||
<InputNumber placeholder="金额" min={0} precision={2} /> | |||
</Form.Item> | |||
</Form.Item> | |||
</Form.Item> | |||
<Form.Item {...tailFormItemLayout} style={{ height: 32 }}> | |||
<Form.Item label="平台金额" style={{ float: 'left' }} rules={[{ required: true }]}> | |||
<Form.Item name="soureMoney" noStyle> | |||
<InputNumber placeholder="金额" min={0} precision={2} /> | |||
</Form.Item> | |||
</Form.Item> | |||
</Form.Item> | |||
<Form.Item> | |||
<Button type="primary" htmlType="submit" style={{ float: 'right' }}> | |||
保存 | |||
</Button> | |||
</Form.Item> | |||
</Form> | |||
</Modal> | |||
<Modal title="商品列表" destroyOnClose maskClosable={false} visible={visiblegoods} width={900} onCancel={() => { | |||
setvisiblegoods(false) | |||
}} onOk={()=>{ | |||
var na=""; | |||
var naid=""; | |||
var money=0.00; | |||
var storeid=""; | |||
checkgoods.forEach((item,index)=>{ | |||
na=na+item.goods_Name | |||
naid=naid+item.goodsId; | |||
money=item.price; | |||
storeid=item.storeId; | |||
if(index<checkgoods.length-1){ | |||
na=na+","; | |||
naid=naid+","; | |||
} | |||
}) | |||
form.setFieldsValue({ | |||
goodsName: na, | |||
goodsId:naid, | |||
money:money, | |||
storeId:storeid | |||
}); | |||
setvisiblegoods(false); | |||
setcheckgoods([]) | |||
}} > | |||
<GoodsList oncheck={oncheck}></GoodsList> | |||
</Modal> | |||
</> | |||
}; | |||
export default CreateForm; |
@@ -0,0 +1,140 @@ | |||
import React, { useState, useEffect, useRef } from 'react'; | |||
import ProTable from '@ant-design/pro-table'; | |||
import { Form, Select,Card,Tabs,Pagination} from 'antd'; | |||
const { TabPane } = Tabs; | |||
import {GetStoreGoods,GetStoreInfoPage} from "../../service"; | |||
const key = 'message'; | |||
const GoodsList = (props) => { | |||
//编辑商品信息 form实例 | |||
const [dataLsit, SetDataLsit] = useState([]); | |||
const [total, SetTotal] = useState(0); | |||
const [loading, SetLoading] = useState(false); | |||
const goodscolumns = [ | |||
{ | |||
title: '主键', | |||
dataIndex: 'id', | |||
hideInSearch: true, | |||
hideInTable: true, | |||
tip: '规则名称是唯一的 key', | |||
}, | |||
{ | |||
title: '商品', | |||
dataIndex: 'goods_Name', | |||
valueType: 'textarea', | |||
}, | |||
{ | |||
title: '商品价格', | |||
dataIndex: 'price', | |||
valueType: 'money', | |||
}, | |||
{ | |||
title: '商品会员价格', | |||
dataIndex: 'vipPrice', | |||
valueType: 'money', | |||
}, | |||
{ | |||
title: '是否设备制作', | |||
dataIndex: 'isDevice', | |||
valueEnum: { | |||
0: { text: '店铺', status: 'Processing' }, | |||
1: { text: '设备', status: 'Success' }, | |||
}, | |||
}, | |||
{ | |||
title: '状态', | |||
dataIndex: 'status', | |||
valueEnum: { | |||
0: { text: '上架', status: 'Processing' }, | |||
1: { text: '下架', status: 'Success' }, | |||
}, | |||
}, | |||
{ | |||
title: '估清', | |||
dataIndex: 'stopSales', | |||
valueEnum: { | |||
0: { text: '销售', status: 'Processing' }, | |||
1: { text: '估清', status: 'Success' }, | |||
} | |||
} | |||
]; | |||
const getStoreInfoPageInfo = async (page) => { | |||
SetLoading(true); | |||
try { | |||
await GetStoreInfoPage({ current: page, pageSize: 10 }).then((r) => { | |||
SetTotal(1); | |||
SetDataLsit(r.data); | |||
SetLoading(false); | |||
}); | |||
} catch { | |||
SetLoading(false); | |||
} | |||
} | |||
const actionRef = useRef(); | |||
const goodsactionRef = useRef(); | |||
useEffect(() => { | |||
getStoreInfoPageInfo(1); | |||
}, []); | |||
return <> | |||
<Card headStyle={{ border: '0px ' }} title="店铺商品" style={{ marginTop: '17px' }}> | |||
<Tabs defaultActiveKey="1" tabPosition="left" onChange={(key) => { | |||
}}> | |||
{dataLsit?.map((item) => { | |||
return ( | |||
<TabPane tab={item.name} | |||
key={item.id}> | |||
<ProTable | |||
actionRef={goodsactionRef} | |||
rowKey="id" | |||
search={false} | |||
loading={loading} | |||
bordered | |||
columns={goodscolumns} | |||
key={item.id} | |||
request={async (params) => { | |||
var data = []; | |||
var total = 0; | |||
params.StoreId = item.id; | |||
await GetStoreGoods(params).then((r) => { | |||
data = r.data?.data; | |||
total = r.data?.total; | |||
}); | |||
return { | |||
data: data, | |||
success: true, | |||
total: total, | |||
}; | |||
}} | |||
rowSelection={{ | |||
type: "radio", | |||
onChange: (_, selectedRows) => { | |||
props.oncheck(selectedRows) | |||
//setSelectedRows(selectedRows); | |||
}, | |||
}} | |||
/> | |||
</TabPane> | |||
); | |||
})} | |||
</Tabs> | |||
<Pagination | |||
size='small' | |||
style={{ float: 'right' }} | |||
total={total} | |||
onChange={(page, pageSize) => { getStoreInfoPageInfo(page) }} | |||
showTotal={(total, range) => `总共 ${total} 条`} | |||
defaultPageSize={10} | |||
defaultCurrent={1} | |||
/> | |||
</Card> | |||
</> | |||
} | |||
export default GoodsList; |
@@ -0,0 +1,311 @@ | |||
import React, { useState, useRef, useEffect } from 'react'; | |||
import moment from 'moment'; | |||
import ProTable, { TableDropdown } from '@ant-design/pro-table'; | |||
import { PageContainer, FooterToolbar } from '@ant-design/pro-layout'; | |||
import { Select, Button, message, Drawer, Popconfirm,Modal } from 'antd'; | |||
import CreateForm from './components/CreateForm'; | |||
import { | |||
GetGoodsCouponPgage, | |||
AddGoodsCoupon, | |||
DeleteGoodsCoupon, | |||
UpdateGoodsCoupon, | |||
GetPaperCouponType, | |||
AddPaperCouponType | |||
} from './service'; | |||
const Coupon = () => { | |||
//绑定 | |||
const actionRef = useRef(); | |||
const [selectedRowsState, setSelectedRows] = useState([]); | |||
/** 新建/更新窗口的弹窗 */ | |||
const [createModalVisible, handleModalVisible] = useState(false); | |||
//记录分页列表 | |||
const [currentRow, setCurrentRow] = useState(); | |||
const key = 'coupon'; | |||
const [optyid, setOptyid] = useState(); | |||
const [items, setItems] = useState(); | |||
//初始化数据 | |||
useEffect(() => { | |||
initcouponType() | |||
}, []); | |||
const initcouponType = async () => { | |||
var data = await GetPaperCouponType(); | |||
var op=[] | |||
data.data.map((item) => ( | |||
op.push({label:item.value,value:item.key}) | |||
)); | |||
setItems(op) | |||
}; | |||
//新增 | |||
const handleAdd = async (fields) => { | |||
message.loading('正在添加...', key); | |||
try { | |||
if (fields.validEndTime < fields.validStartTime) { | |||
message.error('开始时间不能大于结束时间'); | |||
return false; | |||
} | |||
await AddGoodsCoupon(JSON.stringify(fields)).then((r) => { | |||
message.destroy(key); | |||
if (r.data) { | |||
message.success('添加成功'); | |||
} else { | |||
message.error('添加失败请重试!'); | |||
} | |||
}); | |||
//刷新数据 | |||
actionRef.current.reload(); | |||
return true; | |||
} catch (error) { | |||
message.destroy(key); | |||
message.error('添加失败请重试!'); | |||
return false; | |||
} | |||
}; | |||
//删除(支持批量删除) | |||
const handleRemove = async (value) => { | |||
message.loading('正在更新...', key); | |||
try { | |||
await DeleteGoodsCoupon(value).then((r) => { | |||
console.log(r) | |||
message.destroy(key); | |||
if (r.data) { | |||
message.destroy(key); | |||
message.success('更新成功'); | |||
} else { | |||
message.error(r.errors); | |||
} | |||
}); | |||
//刷新数据 | |||
actionRef.current.reload(); | |||
return true; | |||
} catch (error) { | |||
message.destroy(key); | |||
message.error('更新失败请重试!'); | |||
return false; | |||
} | |||
}; | |||
//修改 | |||
const handleUpdate = async (fields) => { | |||
message.loading('正在修改...', key); | |||
try { | |||
if (fields.validEndTime < fields.validStartTime) { | |||
message.error('开始时间不能大于结束时间'); | |||
return false; | |||
} | |||
await UpdateGoodsCoupon(JSON.stringify(fields)).then((r) => { | |||
message.destroy(key); | |||
if (r.data) { | |||
message.success('修改成功'); | |||
} else { | |||
message.error(JSON.sstringify(r.errors)); | |||
} | |||
}); | |||
//刷新数据 | |||
actionRef.current.reload(); | |||
return true; | |||
} catch (error) { | |||
message.destroy(key); | |||
message.error('修改失败请重试!'); | |||
return false; | |||
} | |||
}; | |||
const onchangevalue=(value)=>{ | |||
console.log(value) | |||
setOptyid(value) | |||
} | |||
//table的展示列 | |||
const columns = [ | |||
{ | |||
title: '主键', | |||
dataIndex: 'id', | |||
tip: '规则名称是唯一的 key', | |||
hideInSearch: true, | |||
hideInTable: true, | |||
}, | |||
{ | |||
title: '标题', | |||
dataIndex: 'title', | |||
valueType: 'textarea', | |||
}, | |||
{ | |||
title: '店铺名称', | |||
dataIndex: 'storeName', | |||
valueType: 'textarea', | |||
width: 120, | |||
}, | |||
{ | |||
title: '商品名称', | |||
dataIndex: 'goodsName', | |||
valueType: 'textarea', | |||
width: 120, | |||
}, | |||
{ | |||
title: '优惠平台', | |||
width: 90, | |||
dataIndex: 'cTypeName', | |||
key: 'cTypeName', | |||
renderFormItem: () => ( | |||
<Select options={items} onChange={onchangevalue} allowClear={true}/> | |||
), | |||
}, | |||
{ | |||
title: '原始金额', | |||
dataIndex: 'money', | |||
width: 90, | |||
valueType: 'money', | |||
}, | |||
{ | |||
title: '平台金额', | |||
dataIndex: 'soureMoney', | |||
width: 90, | |||
valueType: 'money', | |||
}, | |||
{ | |||
title: '创建时间', | |||
width: 90, | |||
dataIndex: 'crateTimeAt', | |||
valueType: 'date', | |||
hideInSearch: false, | |||
}, | |||
{ | |||
title: '操作', | |||
dataIndex: 'option', | |||
width: 250, | |||
valueType: 'option', | |||
render: (_, record) => { | |||
let template = [ | |||
<a | |||
key="primary" | |||
type="primary" | |||
onClick={() => { | |||
handleModalVisible(true); | |||
setCurrentRow(() => { | |||
// record.validStartTime = moment(record.validStartTime); | |||
// record.validEndTime = moment(record.validEndTime); | |||
return record; | |||
}); | |||
}} | |||
> | |||
更新 | |||
</a>, | |||
]; | |||
template.push( | |||
<a key="primary" | |||
type="primary" onClick={() => { | |||
handleRemove(record.id); | |||
}}>{record.enable?"禁用":"启用"}</a> | |||
); | |||
return template; | |||
}, | |||
}, | |||
]; | |||
return ( | |||
<PageContainer> | |||
<ProTable | |||
headerTitle="优惠卷" | |||
actionRef={actionRef} | |||
rowKey="id" | |||
search={{ | |||
labelWidth: 120, | |||
}} | |||
pagination={{ | |||
pageSize: 10, | |||
}} | |||
onReset={()=>{ | |||
setOptyid("") | |||
}} | |||
toolBarRender={() => [ | |||
<Button | |||
key="primary" | |||
type="primary" | |||
onClick={() => { | |||
handleModalVisible(true); | |||
}} | |||
> | |||
新建 | |||
</Button>, | |||
]} | |||
columns={columns} | |||
//数据绑定 | |||
request={async (params,e) => { | |||
var queryData = []; | |||
var total = 0; | |||
if (params.dateRange != undefined && params.dateRange.length >= 2) { | |||
params.validStartTime = params.dateRange[0]; | |||
params.validEndTime = params.dateRange[1]; | |||
} | |||
params.CTypeId=optyid; | |||
await GetGoodsCouponPgage(params).then((r) => { | |||
queryData = r.data.data; | |||
total = r.data.total; | |||
}); | |||
return { | |||
data: queryData, | |||
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={() => { | |||
handleRemove(selectedRowsState); | |||
setSelectedRows([]); | |||
actionRef.current?.reloadAndRest?.(); | |||
}} | |||
type="primary" | |||
key="primary" | |||
> | |||
批量删除 | |||
</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 Coupon; |
@@ -0,0 +1,86 @@ | |||
import { request } from 'umi'; | |||
/** 获取优惠卷 sdsa GET /kitchen/api/coupon/couponpgage */ | |||
export async function GetGoodsCouponPgage(data) { | |||
return request(`/kitchen/api/goodscoupon/getGoodsCouponPgage`, { | |||
method: 'POST', | |||
data: data, | |||
// params: { ...params }, | |||
// ...(options || {}), | |||
}); | |||
} | |||
/** 新增优惠卷 POST /kitchen/api/coupon/addCoupon */ | |||
export async function AddGoodsCoupon(data) { | |||
// http://localhost:7002 | |||
return request('/kitchen/api/goodscoupon/addGoodsCoupon', { | |||
method: 'POST', | |||
// type:'json', | |||
data: data, | |||
// ...(options || {}), | |||
}); | |||
} | |||
/** 删除优惠卷 POST /kitchen/api/coupon/deleteCoupon */ | |||
export async function DeleteGoodsCoupon(data) { | |||
// http://localhost:7002 | |||
return request('/kitchen/api/goodscoupon/updateGoodsCouponEnable?Ids='+data, { | |||
method: 'GET', | |||
// type:'json', | |||
//data: data, | |||
// ...(options || {}), | |||
}); | |||
} | |||
/** 修改优惠卷 POST /kitchen/api/coupon/updateCoupon */ | |||
export async function UpdateGoodsCoupon(data) { | |||
// http://localhost:7002 | |||
return request('/kitchen/api/goodscoupon/updateGoodsCoupon', { | |||
method: 'POST', | |||
// type:'json', | |||
data: data, | |||
// ...(options || {}), | |||
}); | |||
} | |||
/** 获取优惠卷类型 sdsa GET //kitchen/api/coupon/coupon-status-or-type/{type} */ | |||
export async function GetPaperCouponType() { | |||
return request(`/kitchen/api/papercoupon/getPaperCouponType`, { | |||
method: 'GET', | |||
//data: null, | |||
// params: { ...params }, | |||
// ...(options || {}), | |||
}); | |||
} | |||
/** 添加优惠卷类型 */ | |||
export async function AddPaperCouponType(data) { | |||
// http://localhost:7002 | |||
return request('/kitchen/api/papercoupon/addPaperCouponType', { | |||
method: 'POST', | |||
// type:'json', | |||
data: data, | |||
// ...(options || {}), | |||
}); | |||
} | |||
/** 获取店铺上架商品 */ | |||
export async function GetStoreGoods(data) { | |||
return request(`/kitchen/api/Store/GetStoreGoods`, { | |||
method: 'POST', | |||
data: data, | |||
// params: { ...params }, | |||
// ...(options || {}), | |||
}); | |||
} | |||
/** 获取 */ | |||
export async function GetStoreInfoPage(data) { | |||
return request(`/kitchen/api/Store/GetStoreList`, { | |||
method: 'POST', | |||
data: data, | |||
// params: { ...params }, | |||
// ...(options || {}), | |||
}); | |||
} | |||
@@ -0,0 +1,152 @@ | |||
import React, { useRef,useState, useEffect } from 'react'; | |||
import { Modal, Form, Input, Button, Select, InputNumber, Divider, Space,message } from 'antd'; | |||
import { PlusOutlined } from '@ant-design/icons'; | |||
import { GetPaperCouponType,AddPaperCouponType } from '../service'; | |||
let index = 0; | |||
const CreateForm = (props) => { | |||
const { Option, OptGroup } = Select; | |||
const [items, setItems] = useState(); | |||
const [options, setoptions] = useState(); | |||
const inputRef = useRef(null); | |||
const [name, setName] = useState(''); | |||
//初始化数据 | |||
useEffect(() => { | |||
initcouponType(); | |||
}, []); | |||
const initcouponType = async () => { | |||
var data = await GetPaperCouponType(); | |||
var op=[] | |||
data.data.map((item) => ( | |||
op.push({label:item.value,value:item.key}) | |||
)); | |||
setItems(op) | |||
}; | |||
const formItemLayout = { | |||
labelCol: { | |||
sm: { span: 4 }, | |||
}, | |||
wrapperCol: {}, | |||
}; | |||
const tailFormItemLayout = { | |||
wrapperCol: { | |||
sm: { | |||
span: 500, | |||
offset: 1, | |||
}, | |||
}, | |||
}; | |||
const onNameChange = (event) => { | |||
setName(event.target.value); | |||
}; | |||
const addItem = async (e) => { | |||
e.preventDefault(); | |||
setItems([...items, {label:name,value:index++} || `New item ${index++}`]); | |||
setName(''); | |||
setTimeout(() => { | |||
inputRef.current?.focus(); | |||
}, 0); | |||
await AddPaperCouponType(JSON.stringify({Name:name})).then((r) => { | |||
if (r.data) { | |||
message.success('添加成功'); | |||
initcouponType(); | |||
} else { | |||
message.error('添加失败请重试!'); | |||
} | |||
}) | |||
}; | |||
return ( | |||
<Modal | |||
maskClosable={false} | |||
title={props.values.id ? '编辑优惠卷' : '新建优惠卷'} | |||
width={700} | |||
visible={props.createModalVisible} | |||
// bodyStyle={{ padding: '32px 40px 48px' }} | |||
footer={null} //底部内容 | |||
//取消 | |||
onCancel={() => { | |||
props.onCancel(); | |||
}} | |||
//关闭时销毁 Modal 里的子元素 | |||
destroyOnClose | |||
> | |||
<Form | |||
{...formItemLayout} | |||
layout="Horizontal" | |||
preserve={false} | |||
initialValues={props.values} | |||
onFinish={props.onFinish} | |||
> | |||
<Form.Item name="id" hidden={true}> | |||
<Input /> | |||
</Form.Item> | |||
<Form.Item name="title" label="优惠卷标题" rules={[{ required: true, max: 200 }]}> | |||
<Input placeholder="请输入优惠卷标题" /> | |||
</Form.Item> | |||
<Form.Item | |||
name="cTypeId" | |||
label="优惠卷类型" | |||
defaultValue={props.values.cTypeId} | |||
rules={[{ required: true }]} | |||
> | |||
<Select placeholder="请选择优惠卷类型" | |||
dropdownRender={(menu) => ( | |||
<> | |||
{menu} | |||
<Divider | |||
style={{ | |||
margin: '8px 0', | |||
}} | |||
/> | |||
<Space | |||
style={{ | |||
padding: '0 8px 4px', | |||
}} | |||
> | |||
<Input | |||
placeholder="请输入选项" | |||
ref={inputRef} | |||
value={name} | |||
onChange={onNameChange} | |||
/> | |||
<Button type="text" icon={<PlusOutlined />} onClick={addItem}> | |||
新增 | |||
</Button> | |||
</Space> | |||
</> | |||
)} | |||
options={items} | |||
> | |||
{/* <OptGroup>{options}</OptGroup> */} | |||
</Select> | |||
</Form.Item> | |||
<Form.Item {...tailFormItemLayout} style={{ height: 32 }}> | |||
<Form.Item label="优惠金额" style={{ float: 'left' }} rules={[{ required: true }]}> | |||
<Form.Item name="money" noStyle> | |||
<InputNumber placeholder="金额" min={0} precision={2} /> | |||
</Form.Item> | |||
</Form.Item> | |||
</Form.Item> | |||
<Form.Item {...tailFormItemLayout} style={{ height: 32 }}> | |||
<Form.Item label="平台金额" style={{ float: 'left' }} rules={[{ required: true }]}> | |||
<Form.Item name="soureMoney" noStyle> | |||
<InputNumber placeholder="金额" min={0} precision={2} /> | |||
</Form.Item> | |||
</Form.Item> | |||
</Form.Item> | |||
<Form.Item> | |||
<Button type="primary" htmlType="submit" style={{ float: 'right', left: 10 }} > | |||
确认 | |||
</Button> | |||
<Button htmlType="button" style={{ float: 'right' }} onClick={props.onCancel} > | |||
取消 | |||
</Button> | |||
</Form.Item> | |||
</Form> | |||
</Modal> | |||
); | |||
}; | |||
export default CreateForm; |
@@ -0,0 +1,300 @@ | |||
import React, { useState, useRef, useEffect } from 'react'; | |||
import moment from 'moment'; | |||
import ProTable, { TableDropdown } from '@ant-design/pro-table'; | |||
import { PageContainer, FooterToolbar } from '@ant-design/pro-layout'; | |||
import { Select, Button, message, Drawer, Popconfirm,Modal } from 'antd'; | |||
import CreateForm from './components/CreateForm'; | |||
import { | |||
GetPaperCouponList, | |||
AddPaperCoupon, | |||
DeletePaperCoupon, | |||
UpdatePaperCoupon, | |||
GetPaperCouponType, | |||
AddPaperCouponType | |||
} from './service'; | |||
const Coupon = () => { | |||
//绑定 | |||
const actionRef = useRef(); | |||
const [selectedRowsState, setSelectedRows] = useState([]); | |||
/** 新建/更新窗口的弹窗 */ | |||
const [createModalVisible, handleModalVisible] = useState(false); | |||
//记录分页列表 | |||
const [currentRow, setCurrentRow] = useState(); | |||
const key = 'coupon'; | |||
const [optyid, setOptyid] = useState(); | |||
const [items, setItems] = useState(); | |||
//初始化数据 | |||
useEffect(() => { | |||
initcouponType() | |||
}, []); | |||
const initcouponType = async () => { | |||
var data = await GetPaperCouponType(); | |||
var op=[] | |||
data.data.map((item) => ( | |||
op.push({label:item.value,value:item.key}) | |||
)); | |||
setItems(op) | |||
}; | |||
//新增 | |||
const handleAdd = async (fields) => { | |||
message.loading('正在添加...', key); | |||
try { | |||
if (fields.validEndTime < fields.validStartTime) { | |||
message.error('开始时间不能大于结束时间'); | |||
return false; | |||
} | |||
await AddPaperCoupon(JSON.stringify(fields)).then((r) => { | |||
message.destroy(key); | |||
if (r.data) { | |||
message.success('添加成功'); | |||
} else { | |||
message.error('添加失败请重试!'); | |||
} | |||
}); | |||
//刷新数据 | |||
actionRef.current.reload(); | |||
return true; | |||
} catch (error) { | |||
message.destroy(key); | |||
message.error('添加失败请重试!'); | |||
return false; | |||
} | |||
}; | |||
//删除(支持批量删除) | |||
const handleRemove = async (value) => { | |||
message.loading('正在执行...', key); | |||
try { | |||
await DeletePaperCoupon(JSON.stringify(value)).then((r) => { | |||
console.log(r) | |||
message.destroy(key); | |||
if (r.data) { | |||
message.destroy(key); | |||
message.success('执行成功'); | |||
} else { | |||
message.error(r.errors); | |||
} | |||
}); | |||
//刷新数据 | |||
actionRef.current.reload(); | |||
return true; | |||
} catch (error) { | |||
message.destroy(key); | |||
message.error('执行失败请重试!'); | |||
return false; | |||
} | |||
}; | |||
//修改 | |||
const handleUpdate = async (fields) => { | |||
message.loading('正在修改...', key); | |||
try { | |||
if (fields.validEndTime < fields.validStartTime) { | |||
message.error('开始时间不能大于结束时间'); | |||
return false; | |||
} | |||
await UpdatePaperCoupon(JSON.stringify(fields)).then((r) => { | |||
message.destroy(key); | |||
if (r.data) { | |||
message.success('修改成功'); | |||
} else { | |||
message.error(JSON.sstringify(r.errors)); | |||
} | |||
}); | |||
//刷新数据 | |||
actionRef.current.reload(); | |||
return true; | |||
} catch (error) { | |||
message.destroy(key); | |||
message.error('修改失败请重试!'); | |||
return false; | |||
} | |||
}; | |||
const onchangevalue=(value)=>{ | |||
console.log(value) | |||
setOptyid(value) | |||
} | |||
//table的展示列 | |||
const columns = [ | |||
{ | |||
title: '主键', | |||
dataIndex: 'id', | |||
tip: '规则名称是唯一的 key', | |||
hideInSearch: true, | |||
hideInTable: true, | |||
}, | |||
{ | |||
title: '标题', | |||
dataIndex: 'title', | |||
valueType: 'textarea', | |||
}, | |||
{ | |||
title: '优惠卷类型', | |||
width: 90, | |||
dataIndex: 'cTypeName', | |||
key: 'cTypeName', | |||
renderFormItem: () => ( | |||
<Select options={items} onChange={onchangevalue} allowClear={true}/> | |||
), | |||
}, | |||
{ | |||
title: '优惠金额', | |||
dataIndex: 'money', | |||
width: 80, | |||
valueType: 'money', | |||
}, | |||
{ | |||
title: '平台金额', | |||
dataIndex: 'soureMoney', | |||
width: 80, | |||
valueType: 'soureMoney', | |||
}, | |||
{ | |||
title: '创建时间', | |||
width: 90, | |||
dataIndex: 'crateTimeAt', | |||
valueType: 'date', | |||
hideInSearch: false, | |||
}, | |||
{ | |||
title: '操作', | |||
dataIndex: 'option', | |||
width: 250, | |||
valueType: 'option', | |||
render: (_, record) => { | |||
let template = [ | |||
<a | |||
key="primary" | |||
type="primary" | |||
onClick={() => { | |||
handleModalVisible(true); | |||
setCurrentRow(() => { | |||
// record.validStartTime = moment(record.validStartTime); | |||
// record.validEndTime = moment(record.validEndTime); | |||
return record; | |||
}); | |||
}} | |||
> | |||
更新 | |||
</a>, | |||
]; | |||
template.push( | |||
<a key="primary" | |||
type="primary" onClick={() => { | |||
handleRemove(record.id); | |||
}}>{record.enable?"禁用":"启用"}</a> | |||
); | |||
return template; | |||
}, | |||
}, | |||
]; | |||
return ( | |||
<PageContainer> | |||
<ProTable | |||
headerTitle="优惠卷" | |||
actionRef={actionRef} | |||
rowKey="id" | |||
search={{ | |||
labelWidth: 120, | |||
}} | |||
pagination={{ | |||
pageSize: 10, | |||
}} | |||
onReset={()=>{ | |||
setOptyid("") | |||
}} | |||
toolBarRender={() => [ | |||
<Button | |||
key="primary" | |||
type="primary" | |||
onClick={() => { | |||
handleModalVisible(true); | |||
}} | |||
> | |||
新建 | |||
</Button>, | |||
]} | |||
columns={columns} | |||
//数据绑定 | |||
request={async (params,e) => { | |||
var queryData = []; | |||
var total = 0; | |||
if (params.dateRange != undefined && params.dateRange.length >= 2) { | |||
params.validStartTime = params.dateRange[0]; | |||
params.validEndTime = params.dateRange[1]; | |||
} | |||
params.CTypeId=optyid; | |||
console.log(e) | |||
console.log(params) | |||
await GetPaperCouponList(params).then((r) => { | |||
queryData = r.data.data; | |||
total = r.data.total; | |||
}); | |||
return { | |||
data: queryData, | |||
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={() => { | |||
handleRemove(selectedRowsState); | |||
setSelectedRows([]); | |||
actionRef.current?.reloadAndRest?.(); | |||
}} | |||
type="primary" | |||
key="primary" | |||
> | |||
批量删除 | |||
</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(); | |||
} | |||
} | |||
setCurrentRow({}); | |||
}} | |||
onCancel={() => { | |||
setCurrentRow({}); | |||
handleModalVisible(false); | |||
}} | |||
createModalVisible={createModalVisible} | |||
values={currentRow || {}} | |||
/> | |||
</PageContainer> | |||
); | |||
}; | |||
export default Coupon; |
@@ -0,0 +1,68 @@ | |||
import { request } from 'umi'; | |||
import { getDataBaseUrl,getStoremanagement } from '@/global_data'; | |||
/** 获取优惠卷 sdsa GET /kitchen/api/coupon/couponpgage */ | |||
export async function GetPaperCouponList(data) { | |||
return request(getStoremanagement()+`/api/papercoupon/paperCouponPgage`, { | |||
method: 'POST', | |||
data: data, | |||
// params: { ...params }, | |||
// ...(options || {}), | |||
}); | |||
} | |||
/** 新增优惠卷 POST /kitchen/api/coupon/addCoupon */ | |||
export async function AddPaperCoupon(data) { | |||
// http://localhost:7002 | |||
return request(getStoremanagement()+'/api/papercoupon/addPaperCoupon', { | |||
method: 'POST', | |||
// type:'json', | |||
data: data, | |||
// ...(options || {}), | |||
}); | |||
} | |||
/** 删除优惠卷 POST /kitchen/api/coupon/deleteCoupon */ | |||
export async function DeletePaperCoupon(data) { | |||
// http://localhost:7002 | |||
return request(getStoremanagement()+'/api/papercoupon/updatePaperCouponEnable?Ids='+data, { | |||
method: 'GET', | |||
// type:'json', | |||
//data: data, | |||
// ...(options || {}), | |||
}); | |||
} | |||
/** 修改优惠卷 POST /kitchen/api/coupon/updateCoupon */ | |||
export async function UpdatePaperCoupon(data) { | |||
// http://localhost:7002 | |||
return request(getStoremanagement()+'/api/papercoupon/updatePaperCoupon', { | |||
method: 'POST', | |||
// type:'json', | |||
data: data, | |||
// ...(options || {}), | |||
}); | |||
} | |||
/** 获取优惠卷类型 sdsa GET //kitchen/api/coupon/coupon-status-or-type/{type} */ | |||
export async function GetPaperCouponType() { | |||
return request(getStoremanagement()+`/api/papercoupon/getPaperCouponType`, { | |||
method: 'GET', | |||
//data: null, | |||
// params: { ...params }, | |||
// ...(options || {}), | |||
}); | |||
} | |||
/** 添加优惠卷类型 */ | |||
export async function AddPaperCouponType(data) { | |||
// http://localhost:7002 | |||
return request(getStoremanagement()+'/api/papercoupon/addPaperCouponType', { | |||
method: 'POST', | |||
// type:'json', | |||
data: data, | |||
// ...(options || {}), | |||
}); | |||
} | |||
@@ -148,10 +148,17 @@ const MenuGoods = (props) => { | |||
rowKey="id" | |||
headerTitle="商品列表" | |||
/> | |||
<Button htmlType="button" style={{float:'right',left:10}} onClick={props.onCancel}> | |||
{/* <Button htmlType="button" style={{float:'right',left:10}} onClick={props.onCancel}> | |||
取消 | |||
</Button> | |||
<Button type="primary" htmlType="submit" style={{float:'right'}} onClick={()=> handleOk()}>保存</Button> | |||
<Button type="primary" htmlType="submit" style={{float:'right'}} onClick={()=> handleOk()}>保存</Button> */} | |||
<Button type="primary" htmlType="submit" style={{ float: 'right', left: 10 }} onClick={()=> handleOk()} > | |||
确认 | |||
</Button> | |||
<Button htmlType="button" style={{ float: 'right' }} onClick={props.onCancel} > | |||
取消 | |||
</Button> | |||
</Modal> | |||
} | |||
@@ -22,15 +22,6 @@ const CreateForm = (props) => { | |||
<Form.Item name="id" hidden={true}> | |||
<Input /> | |||
</Form.Item> | |||
<Form.Item label={"名称"} name="name" rules={[{ required: true }]} > | |||
<Input /> | |||
</Form.Item> | |||
<Form.Item label={"电话"} name="phone" rules={[{ required: true }]} > | |||
<Input /> | |||
</Form.Item> | |||
<Form.Item label={"工号"} name="number" rules={[{ required: true }]} > | |||
<Input /> | |||
</Form.Item> | |||
<Form.Item label="门店" name="shopId" rules={[{ required: true, message: '请选择门店!', },]}> | |||
<Select allowClear placeholder="请选择门店" style={{ width: '100%' }}> | |||
{ | |||
@@ -40,7 +31,15 @@ const CreateForm = (props) => { | |||
} | |||
</Select> | |||
</Form.Item> | |||
<Form.Item label={"名称"} name="name" rules={[{ required: true }]} > | |||
<Input /> | |||
</Form.Item> | |||
<Form.Item label={"电话"} name="phone" rules={[{ required: true }]} > | |||
<Input /> | |||
</Form.Item> | |||
<Form.Item label={"工号"} name="number" rules={[{ required: true }]} > | |||
<Input /> | |||
</Form.Item> | |||
<Form.Item | |||
noStyle | |||
shouldUpdate={(prevValues, currentValues) => | |||
@@ -62,11 +61,17 @@ const CreateForm = (props) => { | |||
</Form.Item> | |||
<Form.Item> | |||
{/* <Form.Item> | |||
<Button type="primary" htmlType="submit"> | |||
保存 | |||
</Button> | |||
</Form.Item> | |||
</Form.Item> */} | |||
<Button type="primary" htmlType="submit" style={{ float: 'right', left: 10 }} > | |||
确认 | |||
</Button> | |||
<Button htmlType="button" style={{ float: 'right' }} onClick={props.onCancel} > | |||
取消 | |||
</Button> | |||
</Form> | |||
</Modal> | |||
); | |||