cfel-base-components 2.0.1 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,7 @@ import { SwapOutlined, } from '@ant-design/icons';
6
6
  import './index.scss';
7
7
  import PageContainer from '../../src/components/base-component/PageContainer';
8
8
  import Layout from '../../src/components/layout';
9
- // import Account from '../../src/components/universal-pages/account';
9
+ import Account from '../../src/components/universal-pages/account';
10
10
  // import AccountInfo from '../../src/components/universal-pages/accountInfo';
11
11
  // import Role from '../../src/components/universal-pages/role';
12
12
  // import RoleInfo from '../../src/components/universal-pages/roleInfo';
@@ -146,7 +146,9 @@ const App = () => {
146
146
  type:'img',
147
147
  content:'运营平台'
148
148
  }}
149
- ></Layout>
149
+ >
150
+ <Account></Account>
151
+ </Layout>
150
152
  </PageContainer>
151
153
  }
152
154
  const container = document.getElementById('root');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cfel-base-components",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "cfel-base-components",
5
5
  "main": "/src/index.tsx",
6
6
  "types": "src/index.d.ts",
@@ -57,8 +57,8 @@ body {
57
57
  line-height: 48px;
58
58
  font-family: Lucida Calligraphy, cursive, serif, sans-serif;
59
59
  margin-right: 12px;
60
- width: 100px;
61
- height: 33px;
60
+ height: 40px;
61
+ object-fit: cover;
62
62
  }
63
63
  .text{
64
64
  color: #1677ff;
@@ -0,0 +1,137 @@
1
+ import React, { useEffect, useState } from 'react'
2
+ import {
3
+ Button, Modal, Form, Input, Row,
4
+ Col, InputNumber, Switch, Select, Cascader, Divider
5
+ } from 'antd';
6
+ import { } from '../api'
7
+ export default function index({
8
+ ModalOpen, //弹框状态
9
+ editOpenStatus, //关闭弹框
10
+ editingData, //编辑数据
11
+ actionFunc, //新增ecs事件
12
+ }: any) {
13
+ const { TextArea } = Input;
14
+ const [form] = Form.useForm();
15
+
16
+ const [hypervisorValue, setHypervisorValue] = useState(null) // 厂商list
17
+ const [RAZValue, setRAZValue] = useState([]) // 可用区list
18
+
19
+ const formDom = [
20
+ { title: "名称", key: 'name', type: 'string', required: true },
21
+ { title: "手机号", key: 'mobile', type: 'mobileint', required: true },
22
+ { title: "邮箱", key: 'email', type: 'emailstring', required: false },
23
+ ]
24
+ useEffect(() => {
25
+ if (!ModalOpen) return
26
+
27
+ if (editingData) {
28
+ console.log(editingData,"editingData")
29
+ form.setFieldsValue({
30
+ ...editingData
31
+ })
32
+ }
33
+ }, [ModalOpen])
34
+
35
+
36
+ const showCom = ({ title, key, type, required }: any) => {
37
+ let dom: any = null
38
+ switch (type) {
39
+ case 'string':
40
+ dom = (<Form.Item
41
+ label={title}
42
+ name={key}
43
+ rules={[{ required: required, message: '请输入' }]}
44
+ >
45
+ <Input placeholder="请输入" />
46
+ </Form.Item>)
47
+ break;
48
+ case 'emailstring':
49
+ dom = (<Form.Item
50
+ label={title}
51
+ name={key}
52
+ rules={[
53
+ { required: required, message: '请输入' },
54
+ { pattern: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/, message: '请输入正确的邮箱' }
55
+ ]}
56
+ >
57
+ <Input placeholder="请输入" />
58
+ </Form.Item>)
59
+ break;
60
+ case 'mobileint':
61
+ dom = (<Form.Item
62
+ label={title}
63
+ name={key}
64
+ rules={
65
+ editingData?[{ required: required, message: '请输入' }]:[
66
+ { required: required, message: '请输入' },
67
+ { pattern: /1[0-9]{10}$/, message: '请输入正确的电话号码' }
68
+ ]}
69
+ >
70
+ <Input placeholder="请输入"
71
+ disabled={editingData?true:false} />
72
+ </Form.Item>)
73
+ break;
74
+ default:
75
+ break;
76
+ }
77
+ return dom
78
+ }
79
+
80
+ const closeModel = () => {
81
+ form.resetFields()
82
+ editOpenStatus(false)
83
+ }
84
+
85
+ const modelSubmit = () => {
86
+ form.validateFields().then((value) => {
87
+ console.log(value, "value")
88
+ if (editingData) {
89
+ value.id = editingData.id
90
+ }
91
+ actionFunc(value, editingData ? "edit" : "add").then(() => {
92
+ form.resetFields()
93
+ })
94
+ })
95
+ }
96
+ return (
97
+ <Modal title={ editingData ? "编辑账号" : "新增账号"}
98
+ destroyOnClose={true}
99
+ open={ModalOpen}
100
+ onCancel={() => {
101
+ closeModel()
102
+ }}
103
+ footer={[
104
+ <Button
105
+ key="refresh"
106
+ onClick={() => {
107
+ closeModel()
108
+ }}
109
+ >
110
+ 取消
111
+ </Button>,
112
+ <Button
113
+ key="submit"
114
+ type="primary"
115
+ onClick={() => {
116
+ modelSubmit()
117
+ }}
118
+ >
119
+ 确定
120
+ </Button>,
121
+ ]}
122
+ >
123
+ <Form
124
+ form={form}
125
+ layout={'vertical'}
126
+ initialValues={{ remember: true }}
127
+ autoComplete="off"
128
+ >
129
+ {
130
+ formDom.map((item: any, index: number) => {
131
+ return showCom(item)
132
+ })
133
+ }
134
+ </Form>
135
+ </Modal>
136
+ )
137
+ }
@@ -0,0 +1,18 @@
1
+ import request from "@/api/config"
2
+
3
+ //分页查询账号
4
+ export const accountPage= (data?: any) => {
5
+ return request.post("/api/permission/account/page.json", { ...data })
6
+ }
7
+ //指定租户下创建账号
8
+ export const accountCreateAccount = (data?: any) => {
9
+ return request.post("/api/permission/account/createAccount.json", { ...data })
10
+ }
11
+ //指定租户下修改账号
12
+ export const accountUpdateAccount = (data?: any) => {
13
+ return request.post("/api/permission/account/updateAccount.json", { ...data })
14
+ }
15
+ //指定租户下删除账号
16
+ export const accountDeleteAccount = (data?: any) => {
17
+ return request.get("/api/permission/account/deleteAccount.json", { params:{...data} })
18
+ }
@@ -0,0 +1,225 @@
1
+ import React, { useEffect, useRef, useState } from 'react';
2
+ import PageContainer from '../../base-component/PageContainer';
3
+ import QueryFilter from '../../base-component/QueryFilter';
4
+ import ProTable from '../../base-component/ProTable';
5
+ import Pagination from '../../base-component/Pagination';
6
+ import { ProFormText, } from '@ant-design/pro-components';
7
+ import { Space, Button, message,Modal } from 'antd';
8
+ import { get } from 'lodash';
9
+ import { timeFormatter } from '../../../utils';
10
+ import useTableHooks from "../../../hooks/useTableHooks"
11
+ import {
12
+ accountPage, accountCreateAccount,
13
+ accountUpdateAccount, accountDeleteAccount
14
+ } from "./api"
15
+ import AddModal from './AddModal'
16
+ import "./index.scss"
17
+
18
+ export interface AccountProps {
19
+ historyAction: any;
20
+ }
21
+
22
+ export default function Account({
23
+ historyAction
24
+ }: AccountProps) {
25
+ const searchFormRef: any = useRef()
26
+
27
+ const [ModalOpen, setModalOpen] = useState(false)
28
+ const [editingData, setEditingData] = useState(null);//编辑数据
29
+
30
+ useEffect(() => {
31
+ execute()
32
+ }, [])
33
+
34
+ const columns: any = [
35
+ {
36
+ title: '名称',
37
+ dataIndex: 'name',
38
+ key: 'name',
39
+ render: (text: any) => {
40
+ return <span>{text}</span>
41
+ }
42
+ },
43
+ {
44
+ title: '账号',
45
+ dataIndex: 'account',
46
+ key: 'account',
47
+ },
48
+ {
49
+ title: '工号',
50
+ dataIndex: 'jobNumber',
51
+ key: 'jobNumber',
52
+ },
53
+ {
54
+ title: '手机号',
55
+ dataIndex: 'mobile',
56
+ key: 'mobile',
57
+ },
58
+ {
59
+ title: '邮箱',
60
+ dataIndex: 'email',
61
+ key: 'email',
62
+ ellipsis: true,
63
+ },
64
+ {
65
+ title: '是否企业管理员',
66
+ dataIndex: 'isAdmin',
67
+ key: 'isAdmin',
68
+ render: (text: any, rowData: any) => {
69
+ if (rowData.isAdmin) {
70
+ return '是'
71
+ } else {
72
+ return '否'
73
+ }
74
+ }
75
+ },
76
+
77
+ {
78
+ title: '创建时间',
79
+ dataIndex: 'gmtCreate',
80
+ key: 'gmtCreate',
81
+ render: (cell: any) => {
82
+ return timeFormatter(cell)
83
+ }
84
+ },
85
+ {
86
+ title: '修改时间',
87
+ dataIndex: 'gmtModified',
88
+ key: 'gmtModified',
89
+ render: (cell: any) => {
90
+ return timeFormatter(cell)
91
+ }
92
+ },
93
+ {
94
+ title: '操作',
95
+ fixed: 'right',
96
+ width: 150,
97
+ render: (rowdata: any) => (
98
+
99
+ <Space>
100
+ <a onClick={() => {
101
+ setEditingData(rowdata)
102
+ setModalOpen(true)
103
+ }} >编辑</a>
104
+ <a
105
+ onClick={() => {
106
+ historyAction?.push({
107
+ pathname: `/account-info`,
108
+ search: `?id=${rowdata.id}`,
109
+ });
110
+ }}
111
+ >
112
+ 配置
113
+ </a>
114
+ <a onClick={() => {
115
+ Modal.confirm({
116
+ title: "确认删除吗?",
117
+ content: '',
118
+ onOk: () => {
119
+ DeleteFunc(rowdata?.id)
120
+ }
121
+ })
122
+ }} >删除</a>
123
+ </Space>
124
+ ),
125
+ },
126
+ ];
127
+
128
+ const handleOnReset: any = async (values: any) => {
129
+ searchFormRef.current = { ...values }
130
+ execute({
131
+ innerPageNo: 1,
132
+ })
133
+ }
134
+
135
+ const handleOnFinish: any = async (values: any) => {
136
+ searchFormRef.current = { ...values }
137
+ execute()
138
+ }
139
+
140
+ const readDataList = ({
141
+ innerPageNo,
142
+ innerPageSize,
143
+ }: any) => {
144
+ return accountPage({
145
+ currentPage: innerPageNo,
146
+ pageSize: innerPageSize,
147
+ ...searchFormRef.current,
148
+ }).then((res: any) => {
149
+ let records = get(res, "records", [])
150
+ let total = get(res, "total", 0)
151
+ return {
152
+ dataList: records,
153
+ totalCount: total
154
+ }
155
+ })
156
+ }
157
+
158
+ const { execute, dataList, isLoading, pagination } = useTableHooks({
159
+ asyncFunction: readDataList
160
+ })
161
+
162
+ const handleRoload = () => {
163
+ execute()
164
+ }
165
+ const setModalOpenFunc = (type: boolean) => {
166
+ setModalOpen(type)
167
+ setEditingData(null)
168
+ }
169
+ const actionFunc = (data: any, type: string) => {
170
+ return (type == 'add' ? accountCreateAccount : accountUpdateAccount)({ ...data }).then((res) => {
171
+ message.success(`${type == 'add' ? '新增' : '更新'}成功`)
172
+ setModalOpen(false)
173
+ setEditingData(null)
174
+ execute()
175
+ })
176
+ }
177
+ const DeleteFunc = (id:any)=>{
178
+ accountDeleteAccount({
179
+ id,
180
+ }).then((res: any) => {
181
+ message.success('删除成功')
182
+ execute()
183
+ })
184
+ }
185
+ return (
186
+ <PageContainer>
187
+ <QueryFilter
188
+ onReset={handleOnReset}
189
+ onFinish={handleOnFinish}
190
+ >
191
+ <ProFormText name="name" label="名称" />
192
+ <ProFormText name="account" label="账号" />
193
+ </QueryFilter>
194
+ <ProTable
195
+ toolBarRender={() => {
196
+ return [
197
+ <Button
198
+ type="primary"
199
+ onClick={() => {
200
+ setModalOpen(true)
201
+ }}
202
+ >
203
+ 新增账号
204
+ </Button>,
205
+ ];
206
+ }}
207
+ headerTitle={"账号列表"}
208
+ dataSource={dataList}
209
+ loading={isLoading}
210
+ columns={columns}
211
+ rowKey="id"
212
+ options={{
213
+ reload: handleRoload
214
+ }}
215
+ />
216
+ <AddModal
217
+ ModalOpen={ModalOpen}
218
+ editOpenStatus={setModalOpenFunc} //修改状态事件
219
+ editingData={editingData} //当前数据
220
+ actionFunc={actionFunc}//事件
221
+ />
222
+ <Pagination {...pagination} />
223
+ </PageContainer>
224
+ )
225
+ }
package/src/index.tsx CHANGED
@@ -11,6 +11,7 @@ import RoleInfo from './components/universal-pages/roleInfo'
11
11
  import request from './apiRequest/config'
12
12
  import iotRequest from './apiRequest/iotConfig'
13
13
  import { hosts } from './apiRequest/hosts'
14
+ import CpcAccount from './components/universal-pages/cpcAccount' //cp列表c账号
14
15
 
15
16
  import { getUrlParams, downloadFile, timeFormatter } from './utils/index'
16
17
  export {
@@ -26,6 +27,8 @@ export {
26
27
  Role,
27
28
  RoleInfo,
28
29
 
30
+ CpcAccount,
31
+
29
32
  request,
30
33
  iotRequest,
31
34
  hosts,