|
|
@@ -1,5 +1,5 @@ |
|
|
|
import React, { useState, useRef, useEffect } from 'react'; |
|
|
|
import { Modal, Button, message, Popconfirm, Typography, Select } from 'antd'; |
|
|
|
import { Modal, Button, message, Popconfirm, Typography, Select,Form,Input,Radio,DatePicker} from 'antd'; |
|
|
|
import { PageContainer, FooterToolbar } from '@ant-design/pro-layout'; |
|
|
|
import { PlusOutlined } from '@ant-design/icons'; |
|
|
|
import ProTable from '@ant-design/pro-table'; |
|
|
@@ -12,13 +12,14 @@ dayjs.extend(localeData); |
|
|
|
const dateFormat = 'YYYY/MM/DD'; |
|
|
|
const { Paragraph, Text } = Typography; |
|
|
|
|
|
|
|
import { PageStoreAuthorization, AddStoreAuthorization, UpdateStoreAuthorization, UpdateStoreAuthTime, GetStoreList } from "./services" |
|
|
|
import { PageStoreAuthorization, AddStoreAuthorization, UpdateStoreAuthorization, UpdateStoreAuthTime, GetStoreList,DelStoreAuthTime } from "./services" |
|
|
|
const App = () => { |
|
|
|
|
|
|
|
const actionRef = useRef(); |
|
|
|
const [ModalVisible, handleModalVisible] = useState(false); |
|
|
|
const [currentRow, setCurrentRow] = useState(); |
|
|
|
const [storeList, setStoreList] = useState([]); |
|
|
|
const [form] = Form.useForm(); |
|
|
|
|
|
|
|
//初始化数据 |
|
|
|
useEffect(() => { |
|
|
@@ -51,32 +52,36 @@ const App = () => { |
|
|
|
tip: '规则名称是唯一的 key' |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '授权码', |
|
|
|
dataIndex: 'key', |
|
|
|
title: '店铺', |
|
|
|
dataIndex: 'storeName', |
|
|
|
valueType: 'textarea', |
|
|
|
width:200, |
|
|
|
search: false, |
|
|
|
render: (text) => <Paragraph style={{ display: 'inline' }} copyable>{text}</Paragraph>, |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '店铺', |
|
|
|
dataIndex: 'storeName', |
|
|
|
title: '授权码', |
|
|
|
dataIndex: 'key', |
|
|
|
valueType: 'textarea', |
|
|
|
search: false, |
|
|
|
render: (text) => <Paragraph style={{ display: 'inline' }} copyable>{text}</Paragraph>, |
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
title: '有效日期', |
|
|
|
dataIndex: 'periodValidity', |
|
|
|
valueType: 'textarea', |
|
|
|
valueType: 'date', |
|
|
|
width:150, |
|
|
|
search: false, |
|
|
|
render: (_, record) => { |
|
|
|
return <span>{record.periodValidity == null ? "长期有效" : record.periodValidity}</span> |
|
|
|
var time=dayjs(record.periodValidity, dateFormat).format('YYYY-MM-DD'); |
|
|
|
return <span>{record.periodValidity == null ? "长期有效" : time}</span> |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '修改时间', |
|
|
|
dataIndex: 'updateAt', |
|
|
|
valueType: 'textarea', |
|
|
|
width: 200, |
|
|
|
width: 150, |
|
|
|
search: false |
|
|
|
}, |
|
|
|
{ |
|
|
@@ -84,7 +89,7 @@ const App = () => { |
|
|
|
dataIndex: 'option', |
|
|
|
valueType: 'option', |
|
|
|
fixed: 'right', |
|
|
|
width: 450, |
|
|
|
width: 250, |
|
|
|
render: (_, record) => [ |
|
|
|
<Popconfirm |
|
|
|
type="primary" |
|
|
@@ -105,7 +110,36 @@ const App = () => { |
|
|
|
}} |
|
|
|
onCancel={() => { }} |
|
|
|
> |
|
|
|
<a href="#">更新</a> |
|
|
|
<a href="#">更新授权码</a> |
|
|
|
</Popconfirm>, |
|
|
|
<a href="#" onClick={() => { |
|
|
|
setCurrentRow(record); |
|
|
|
var aa = record.periodValidity == null ? "cqyx" : "gdsj"; |
|
|
|
var time=record.periodValidity == null ?null:dayjs(record.periodValidity, dateFormat); |
|
|
|
|
|
|
|
form.setFieldsValue({ id: record.id, autho:aa, periodValidity: time,storeId:record.storeId }); |
|
|
|
handleModalVisible(true); |
|
|
|
}}>更新授权时间</a>, |
|
|
|
<Popconfirm |
|
|
|
type="primary" |
|
|
|
key="primary" |
|
|
|
title="确认删除吗?" |
|
|
|
okText="是" |
|
|
|
cancelText="否" |
|
|
|
onConfirm={async () => { |
|
|
|
await DelStoreAuthTime(record.id).then((r) => { |
|
|
|
if (r.statusCode == 200 && r.data) { |
|
|
|
message.success("删除成功"); |
|
|
|
actionRef.current.reload(); |
|
|
|
|
|
|
|
} else { |
|
|
|
message.error(r.errors || "删除失败"); |
|
|
|
} |
|
|
|
}); |
|
|
|
}} |
|
|
|
onCancel={() => { }} |
|
|
|
> |
|
|
|
<a href="#">删除</a> |
|
|
|
</Popconfirm>, |
|
|
|
|
|
|
|
], |
|
|
@@ -155,7 +189,7 @@ const App = () => { |
|
|
|
|
|
|
|
<Form form={form} onFinish={(values) => { |
|
|
|
if (values.id) { |
|
|
|
UpdateAuthTime(values).then((r) => { |
|
|
|
UpdateStoreAuthTime(values).then((r) => { |
|
|
|
if (r.statusCode == 200 && r.data) { |
|
|
|
message.success("修改成功"); |
|
|
|
actionRef.current.reload(); |
|
|
@@ -167,7 +201,7 @@ const App = () => { |
|
|
|
}); |
|
|
|
|
|
|
|
} else { |
|
|
|
AddAuthorization(values).then((r) => { |
|
|
|
AddStoreAuthorization(values).then((r) => { |
|
|
|
if (r.statusCode == 200 && r.data) { |
|
|
|
message.success("添加成功"); |
|
|
|
actionRef.current.reload(); |
|
|
@@ -185,11 +219,9 @@ const App = () => { |
|
|
|
<Form.Item name="id" hidden={true}> |
|
|
|
<Input /> |
|
|
|
</Form.Item> |
|
|
|
<Form.Item name="id" hidden={true}> |
|
|
|
<Select style={{ width: 470, }} onChange={(value) => { setCurrentRow(value); }} options={storeList} /> |
|
|
|
<Form.Item name="storeId" label="店铺" rules={[{ required: true, }]}> |
|
|
|
<Select style={{ width: 330, }} onChange={(value) => { setCurrentRow(value); }} options={storeList} /> |
|
|
|
</Form.Item> |
|
|
|
|
|
|
|
|
|
|
|
<Form.Item name="autho" label="授权时间" rules={[{ required: true, }]} > |
|
|
|
<Radio.Group > |
|
|
|
<Radio value="cqyx"> 长期有效 </Radio> |
|
|
|