hear 3 лет назад
Родитель
Сommit
e107a1033b

+ 140 - 1
src/pages/iot-card/Recharge/index.tsx

@@ -1,4 +1,143 @@
+import { PermissionButton } from '@/components';
+import SearchComponent from '@/components/SearchComponent';
+import useDomFullHeight from '@/hooks/document/useDomFullHeight';
+import { ExclamationCircleOutlined, EyeOutlined } from '@ant-design/icons';
+import { PageContainer } from '@ant-design/pro-layout';
+import ProTable, { ActionType, ProColumns } from '@jetlinks/pro-table';
+import { Tooltip } from 'antd';
+import moment from 'moment';
+import { useRef, useState } from 'react';
+import Service from '../CardManagement/service';
+import TopUp from './topUp';
+
+export const service = new Service('');
+
 const Recharge = () => {
-  return <>充值管理</>;
+  const { minHeight } = useDomFullHeight(`.record`, 24);
+  const actionRef = useRef<ActionType>();
+  const [param, setParam] = useState({});
+  const [visible, setVisible] = useState<boolean>(false);
+
+  const columns: ProColumns<any>[] = [
+    // {
+    //   title: '充值类型',
+    //   dataIndex: 'rechargeType',
+    //   ellipsis: true,
+    //   hideInSearch: true
+    // },
+    {
+      title: '充值金额',
+      dataIndex: 'chargeMoney',
+      ellipsis: true,
+    },
+    {
+      title: '支付方式',
+      dataIndex: 'paymentType',
+      ellipsis: true,
+    },
+    {
+      title: '订单号',
+      dataIndex: 'orderNumber',
+      ellipsis: true,
+    },
+    {
+      title: '支付URL',
+      dataIndex: 'url',
+      ellipsis: true,
+      hideInSearch: true,
+    },
+    {
+      title: '订单时间',
+      dataIndex: 'createTime',
+      ellipsis: true,
+      valueType: 'dateTime',
+      render: (_: any, record) => {
+        return record.createTime ? moment(record.createTime).format('YYYY-MM-DD HH:mm:ss') : '';
+      },
+    },
+    {
+      title: '操作',
+      key: 'action',
+      fixed: 'right',
+      align: 'center',
+      width: 200,
+      hideInSearch: true,
+      render: (_, record) => [
+        <a
+          key="editable"
+          onClick={() => {
+            console.log(record);
+            // setVisible(true);
+            // setCurrent(record);
+          }}
+        >
+          <Tooltip title="查看">
+            <EyeOutlined />
+          </Tooltip>
+        </a>,
+      ],
+    },
+  ];
+
+  return (
+    <PageContainer>
+      <SearchComponent
+        field={columns}
+        target="record"
+        onSearch={(data) => {
+          // 重置分页数据
+          actionRef.current?.reset?.();
+          setParam(data);
+        }}
+      />
+      <ProTable
+        actionRef={actionRef}
+        params={param}
+        columns={columns}
+        search={false}
+        rowKey="id"
+        tableClassName={'record'}
+        columnEmptyText={''}
+        tableStyle={{ minHeight }}
+        headerTitle={
+          <>
+            <PermissionButton
+              onClick={() => {
+                setVisible(true);
+              }}
+              isPermission={true}
+              key="button"
+              type="primary"
+            >
+              充值
+            </PermissionButton>
+            <div
+              style={{
+                paddingLeft: 24,
+                background: '#fff',
+                fontSize: 14,
+              }}
+            >
+              <span style={{ marginRight: 8, fontSize: 16 }}>
+                <ExclamationCircleOutlined />
+              </span>
+              本平台仅提供充值入口,具体充值结果需以运营商的充值结果为准
+            </div>
+          </>
+        }
+        // request={async (params) =>
+        //   service.getList({ ...params, sorts: [{ name: 'createTime', order: 'desc' }] })
+        // }
+      />
+      {visible && (
+        <TopUp
+          data={{}}
+          close={() => {
+            setVisible(false);
+          }}
+        />
+      )}
+    </PageContainer>
+  );
 };
 export default Recharge;

+ 0 - 0
src/pages/iot-card/Recharge/service.ts


+ 170 - 0
src/pages/iot-card/Recharge/topUp.tsx

@@ -0,0 +1,170 @@
+import { createForm } from '@formily/core';
+import { createSchemaField } from '@formily/react';
+import { Form, FormGrid, FormItem, Input, Select, NumberPicker } from '@formily/antd';
+import type { ISchema } from '@formily/json-schema';
+import { Modal } from '@/components';
+// import { onlyMessage } from '@/utils/util';
+import { ExclamationCircleOutlined } from '@ant-design/icons';
+
+interface Props {
+  data: any;
+  close: () => void;
+}
+
+const TopUp = (props: Props) => {
+  const form = createForm({});
+
+  const SchemaField = createSchemaField({
+    components: {
+      FormItem,
+      Input,
+      Select,
+      FormGrid,
+      NumberPicker,
+    },
+  });
+
+  const schema: ISchema = {
+    type: 'object',
+    properties: {
+      layout: {
+        type: 'void',
+        'x-decorator': 'FormGrid',
+        'x-decorator-props': {
+          maxColumns: 2,
+          minColumns: 2,
+          columnGap: 24,
+        },
+        properties: {
+          configId: {
+            title: '平台对接',
+            type: 'string',
+            'x-decorator': 'FormItem',
+            'x-component': 'Select',
+            'x-decorator-props': {
+              gridSpan: 2,
+            },
+            'x-component-props': {
+              placeholder: '请输入平台对接',
+            },
+
+            'x-validator': [
+              {
+                max: 64,
+                message: '最多可输入64个字符',
+              },
+              {
+                required: true,
+                message: '请选择平台对接',
+              },
+            ],
+          },
+          rechargeId: {
+            title: '账户id',
+            type: 'string',
+            'x-decorator': 'FormItem',
+            'x-component': 'Input',
+            'x-decorator-props': {
+              gridSpan: 2,
+            },
+            'x-component-props': {
+              placeholder: '请输入账户id',
+            },
+
+            'x-validator': [
+              {
+                max: 64,
+                message: '最多可输入64个字符',
+              },
+              {
+                required: true,
+                message: '请输入账户id',
+              },
+            ],
+          },
+          chargeMoney: {
+            title: '充值金额',
+            type: 'string',
+            'x-decorator': 'FormItem',
+            'x-component': 'NumberPicker',
+            'x-decorator-props': {
+              gridSpan: 2,
+            },
+            'x-component-props': {
+              placeholder: '请输入充值金额',
+            },
+
+            'x-validator': [
+              {
+                min: 1,
+                message: '请输入1~500之间的数字',
+              },
+              {
+                max: 500,
+                message: '请输入1~500之间的数字',
+              },
+              {
+                required: true,
+                message: '请输入充值金额',
+              },
+            ],
+          },
+          paymentType: {
+            title: '支付方式',
+            type: 'string',
+            'x-decorator': 'FormItem',
+            'x-component': 'Select',
+            'x-decorator-props': {
+              gridSpan: 2,
+            },
+            'x-component-props': {
+              placeholder: '请选择支付方式',
+            },
+            name: 'name',
+            'x-validator': [
+              {
+                required: true,
+                message: '请选择支付方式',
+              },
+            ],
+          },
+        },
+      },
+    },
+  };
+
+  const save = async () => {
+    const value = await form.submit<any>();
+    console.log(value);
+  };
+
+  return (
+    <Modal
+      title={'充值'}
+      maskClosable={false}
+      visible
+      onCancel={props.close}
+      onOk={save}
+      width="35vw"
+    >
+      <div
+        style={{
+          padding: 5,
+          background: '#f6f6f6',
+          fontSize: 14,
+          color: '#00000091',
+          marginBottom: 10,
+        }}
+      >
+        <span style={{ fontSize: 16, marginRight: 5 }}>
+          <ExclamationCircleOutlined />
+        </span>
+        暂只支持移动OneLink平台
+      </div>
+      <Form form={form} layout="vertical">
+        <SchemaField schema={schema} scope={{}} />
+      </Form>
+    </Modal>
+  );
+};
+export default TopUp;

+ 1 - 1
src/pages/oauth/index.tsx

@@ -203,7 +203,7 @@ const Oauth = () => {
         if (items.redirect_uri) {
           const orgin = items.redirect_uri.split('/').slice(0, 3);
           const url = `${orgin.join('/')}/%23/${items.redirect_uri?.split('redirect=')[1]}`;
-          redirectUrl = `${items.redirect_uri?.split('redirect=')[0]}redirect=${url}`;
+          redirectUrl = `${items.redirect_uri?.split('redirect=')[0]}?redirect=${url}`;
         }
         getLoginUser({
           ...items,