Selaa lähdekoodia

提交

master
gwbvipvip 8 kuukautta sitten
vanhempi
commit
e73b492922
3 muutettua tiedostoa jossa 21349 lisäystä ja 17 poistoa
  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 Näytä tiedosto

@@ -1,16 +1,26 @@
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 { PlusOutlined } from '@ant-design/icons';
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;

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

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


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

],
},
@@ -79,14 +107,8 @@ const App = () => {
type="primary"
key="primary"
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 /> 添加授权码
</Button>,
@@ -107,6 +129,67 @@ const App = () => {
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>
);
};


+ 9
- 0
src/pages/authorization/platformAuthorization/services.js Näytä tiedosto

@@ -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
Näytä tiedosto


Ladataan…
Peruuta
Tallenna