Browse Source

提交

master
gwbvipvip 6 months ago
parent
commit
e73b492922
3 changed files with 21349 additions and 17 deletions
  1. +100
    -17
      src/pages/authorization/platformAuthorization/index.jsx
  2. +9
    -0
      src/pages/authorization/platformAuthorization/services.js
  3. +21240
    -0
      yarn-error.log

+ 100
- 17
src/pages/authorization/platformAuthorization/index.jsx View File

@@ -1,16 +1,26 @@
import React, { useState, useRef } from 'react'; import React, { useState, useRef } from 'react';
import { Modal, Button, message, Popconfirm, Typography } from 'antd';
import { Modal, Button, message, Popconfirm, Typography, Form, Input, DatePicker, Select, Radio } from 'antd';
import { PageContainer, FooterToolbar } from '@ant-design/pro-layout'; import { PageContainer, FooterToolbar } from '@ant-design/pro-layout';
import { PlusOutlined } from '@ant-design/icons'; import { PlusOutlined } from '@ant-design/icons';
import ProTable from '@ant-design/pro-table'; import ProTable from '@ant-design/pro-table';
import dayjs from 'dayjs';
import weekday from "dayjs/plugin/weekday";
import localeData from "dayjs/plugin/localeData";
dayjs.extend(weekday);
dayjs.extend(localeData);
const dateFormat = 'YYYY/MM/DD';
const { Paragraph, Text } = Typography; const { Paragraph, Text } = Typography;


import { PageAuthorization, AddAuthorization, UpdateAuthorization } from "./services"
import { PageAuthorization, AddAuthorization, UpdateAuthorization, UpdateAuthTime } from "./services"
const App = () => { const App = () => {


const actionRef = useRef(); const actionRef = useRef();
const [ModalVisible, handleModalVisible] = useState(false); const [ModalVisible, handleModalVisible] = useState(false);
const [currentRow, setCurrentRow] = useState(); const [currentRow, setCurrentRow] = useState();
const [form] = Form.useForm();


const columns = [ const columns = [
{ {
title: '主键', title: '主键',
@@ -20,25 +30,35 @@ const App = () => {
tip: '规则名称是唯一的 key' tip: '规则名称是唯一的 key'
}, },
{ {
title: 'TenantId',
dataIndex: 'groupId',
title: '授权码',
dataIndex: 'key',
valueType: 'textarea', valueType: 'textarea',
search: false, search: false,
width:300,
render: (text) => <Paragraph style={{ display: 'inline' }} copyable>{text}</Paragraph>, render: (text) => <Paragraph style={{ display: 'inline' }} copyable>{text}</Paragraph>,
}, },
{ {
title: '授权码',
dataIndex: 'key',
title: '有效日期',
dataIndex: 'periodValidity',
valueType: 'textarea', valueType: 'textarea',
search: false, search: false,
render: (text) => <Paragraph style={{ display: 'inline' }} copyable>{text}</Paragraph>,
render: (_, record) => {
return <span>{record.periodValidity == null ? "长期有效" : record.periodValidity}</span>
}
},
{
title: '修改时间',
dataIndex: 'updateAt',
valueType: 'textarea',
width:200,
search: false
}, },
{ {
title: '操作', title: '操作',
dataIndex: 'option', dataIndex: 'option',
valueType: 'option', valueType: 'option',
fixed: 'right', fixed: 'right',
width: 450,
width: 300,
render: (_, record) => [ render: (_, record) => [
<Popconfirm <Popconfirm
type="primary" type="primary"
@@ -58,8 +78,16 @@ const App = () => {
}} }}
onCancel={() => { }} onCancel={() => { }}
> >
<a href="#">更新</a>
<a href="#">更新授权码</a>
</Popconfirm>, </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 });
handleModalVisible(true);
}}>更新授权时间</a>


], ],
}, },
@@ -79,14 +107,8 @@ const App = () => {
type="primary" type="primary"
key="primary" key="primary"
onClick={() => { onClick={() => {
AddAuthorization().then((r) => {
if (r.statusCode == 200 && r.data) {
message.success("添加成功");
actionRef.current.reload();
} else {
message.error(r.errors || "添加失败");
}
});
handleModalVisible(true);
form.setFieldsValue({ id: null, autho: "cqyx", periodValidity: null });
}} > }} >
<PlusOutlined /> 添加授权码 <PlusOutlined /> 添加授权码
</Button>, </Button>,
@@ -107,6 +129,67 @@ const App = () => {
columns={columns} columns={columns}
/> />


<Modal title="授权操作" open={ModalVisible}
onOk={() => {
form.submit();

}}
onCancel={() => {
handleModalVisible(false);
}}>

<Form form={form} onFinish={(values) => {
if (values.id) {
UpdateAuthTime(values).then((r) => {
if (r.statusCode == 200 && r.data) {
message.success("修改成功");
actionRef.current.reload();
handleModalVisible(false);

} else {
message.error(r.errors || "修改失败");
}
});

} else {
AddAuthorization(values).then((r) => {
if (r.statusCode == 200 && r.data) {
message.success("添加成功");
actionRef.current.reload();
handleModalVisible(false);

} else {
message.error(r.errors || "添加失败");
}
});
}
}}
style={{
maxWidth: 600,
}}>
<Form.Item name="id" hidden={true}>
<Input />
</Form.Item>
<Form.Item name="autho" label="授权时间" rules={[{ required: true, }]} >
<Radio.Group >
<Radio value="cqyx"> 长期有效 </Radio>
<Radio value="gdsj"> 固定时间 </Radio>
</Radio.Group>
</Form.Item>

<Form.Item noStyle shouldUpdate={(prevValues, currentValues) => prevValues.autho !== currentValues.autho} >
{({ getFieldValue }) =>
getFieldValue('autho') == 'gdsj' ? (
<Form.Item name="periodValidity" label="固定时间" rules={[{ required: true, }]}>
<DatePicker style={{ width: "300px" }} />
</Form.Item>
) : null
}
</Form.Item>
</Form>
</Modal>


</PageContainer> </PageContainer>
); );
}; };


+ 9
- 0
src/pages/authorization/platformAuthorization/services.js View File

@@ -26,5 +26,14 @@ export async function UpdateAuthorization(data) {
}); });
} }


/** 修改平台授权码时间 */
export async function UpdateAuthTime(data) {
return request(getDataBaseUrl()+`/api/authorization/updateauthtime`, {
method: 'POST',
data: data,
});
}






+ 21240
- 0
yarn-error.log
File diff suppressed because it is too large
View File


Loading…
Cancel
Save