|
@@ -1,12 +1,37 @@
|
|
-import { PageContainer, ProTable } from "@ant-design/pro-components"
|
|
|
|
|
|
+import { ActionType, BetaSchemaForm, PageContainer, ProFormInstance, ProTable } from "@ant-design/pro-components"
|
|
import { columns } from "./tableConfig"
|
|
import { columns } from "./tableConfig"
|
|
import { useAjax } from "@/Hook/useAjax"
|
|
import { useAjax } from "@/Hook/useAjax"
|
|
-import { distributorAccountList } from "@/services/distributor/account"
|
|
|
|
|
|
+import { distributorAccountAdd, distributorAccountList, distributorAccountUpdate } from "@/services/distributor/account"
|
|
|
|
+import { Button, message } from "antd"
|
|
|
|
+import { useRef, useState } from "react"
|
|
|
|
+import { PlusCircleOutlined } from "@ant-design/icons"
|
|
|
|
|
|
const Page: React.FC = () => {
|
|
const Page: React.FC = () => {
|
|
|
|
+ const actionRef = useRef<ActionType>();
|
|
|
|
+ const formRef = useRef<ProFormInstance>();
|
|
|
|
+ const [open, setOpen] = useState(false)
|
|
let getList = useAjax((params) => distributorAccountList(params), { type: 'table' })
|
|
let getList = useAjax((params) => distributorAccountList(params), { type: 'table' })
|
|
|
|
+ let DistributorAccountUpdate = useAjax((params) => distributorAccountUpdate(params));
|
|
|
|
+ let add = useAjax((params) => distributorAccountAdd(params));
|
|
|
|
+ const upDate = (id: any, enabled: boolean) => {
|
|
|
|
+ DistributorAccountUpdate.run({ id, enabled }).then(res => {
|
|
|
|
+ if (res.code === 200) {
|
|
|
|
+ message.success(enabled ? '启动成功' : '停用成功');
|
|
|
|
+ actionRef.current?.reload()
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ const submit = async (values: any) => {
|
|
|
|
+ console.log(values)
|
|
|
|
+ add.run(values).then(res => {
|
|
|
|
+ actionRef?.current?.reload();
|
|
|
|
+ message.success('操作成功!');
|
|
|
|
+ setOpen(false);
|
|
|
|
+ })
|
|
|
|
+ }
|
|
return <PageContainer>
|
|
return <PageContainer>
|
|
<ProTable<any, any>
|
|
<ProTable<any, any>
|
|
|
|
+ actionRef={actionRef}
|
|
headerTitle={"账号列表"}
|
|
headerTitle={"账号列表"}
|
|
rowKey={(r) => r.id}
|
|
rowKey={(r) => r.id}
|
|
search={{
|
|
search={{
|
|
@@ -15,9 +40,88 @@ const Page: React.FC = () => {
|
|
request={async (params) => {
|
|
request={async (params) => {
|
|
return await getList.run(params)
|
|
return await getList.run(params)
|
|
}}
|
|
}}
|
|
- columns={columns()}
|
|
|
|
|
|
+ columns={columns(upDate)}
|
|
scroll={{ x: "auto" }}
|
|
scroll={{ x: "auto" }}
|
|
- // bordered
|
|
|
|
|
|
+ toolBarRender={() => {
|
|
|
|
+ return [
|
|
|
|
+ <Button
|
|
|
|
+ type="primary"
|
|
|
|
+ onClick={() => {
|
|
|
|
+ setOpen(true);
|
|
|
|
+ }}
|
|
|
|
+ >
|
|
|
|
+ <PlusCircleOutlined />
|
|
|
|
+ 新增账号
|
|
|
|
+ </Button>,
|
|
|
|
+ ];
|
|
|
|
+ }}
|
|
|
|
+ // bordered
|
|
|
|
+ />
|
|
|
|
+ <BetaSchemaForm
|
|
|
|
+ title={'新增账号'}
|
|
|
|
+ formRef={formRef}
|
|
|
|
+ width={600}
|
|
|
|
+ open={open}
|
|
|
|
+ modalProps={{ destroyOnClose: true }}
|
|
|
|
+ onOpenChange={(b) => {
|
|
|
|
+ !b && setOpen(b);
|
|
|
|
+ }}
|
|
|
|
+ layoutType={'ModalForm'}
|
|
|
|
+ labelCol={{ span: 6 }}
|
|
|
|
+ wrapperCol={{ span: 14 }}
|
|
|
|
+ // grid={true}
|
|
|
|
+ layout="horizontal"
|
|
|
|
+ onFinish={submit}
|
|
|
|
+ columns={[
|
|
|
|
+ {
|
|
|
|
+ title: '账号昵称',
|
|
|
|
+ dataIndex: 'nickname',
|
|
|
|
+ formItemProps: {
|
|
|
|
+ style: { marginBottom: 10 },
|
|
|
|
+ rules: [
|
|
|
|
+ {
|
|
|
|
+ required: true,
|
|
|
|
+ message: '此项为必填项',
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: '账号密码',
|
|
|
|
+ dataIndex: 'password',
|
|
|
|
+ formItemProps: {
|
|
|
|
+ style: { marginBottom: 10 },
|
|
|
|
+ rules: [
|
|
|
|
+ {
|
|
|
|
+ required: true,
|
|
|
|
+ message: '此项为必填项',
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: '联系人电话',
|
|
|
|
+ dataIndex: 'phoneNum',
|
|
|
|
+ formItemProps: {
|
|
|
|
+ style: { marginBottom: 10 },
|
|
|
|
+ rules: [
|
|
|
|
+ {
|
|
|
|
+ required: true,
|
|
|
|
+ message: '此项为必填项',
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: '备注',
|
|
|
|
+ dataIndex: 'remark',
|
|
|
|
+ valueType: 'textarea',
|
|
|
|
+ formItemProps: {
|
|
|
|
+ style: { marginBottom: 10 },
|
|
|
|
+ },
|
|
|
|
+ }
|
|
|
|
+ ]}
|
|
|
|
+ loading={add?.loading}
|
|
/>
|
|
/>
|
|
</PageContainer>
|
|
</PageContainer>
|
|
|
|
|