diff --git a/src/api/sys/user.ts b/src/api/sys/user.ts
index 44671a46..e4d62080 100644
--- a/src/api/sys/user.ts
+++ b/src/api/sys/user.ts
@@ -120,3 +120,113 @@ export function deleteRoles(id: string, mode: ErrorMessageMode = 'modal') {
},
)
}
+/**
+ * @description:管理员列表
+ */
+export function getUsers(params, mode: ErrorMessageMode = 'modal') {
+ return defHttp.get(
+ {
+ url: '/api/admin-users',
+ params,
+ },
+ {
+ errorMessageMode: mode,
+ },
+ )
+}
+/**
+ * @description:基地数据
+ */
+export function getAgriculturalBasic(mode: ErrorMessageMode = 'modal') {
+ const params = { type: 1, per_page: 999999, page: 1 }
+ return defHttp.get(
+ {
+ url: '/api/agricultural-basic',
+ params,
+ },
+ {
+ errorMessageMode: mode,
+ },
+ )
+}
+/**
+ * @description:新增管理员
+ */
+export function addUser(params, mode: ErrorMessageMode = 'modal') {
+ return defHttp.post(
+ {
+ url: '/api/admin-users',
+ params,
+ },
+ {
+ errorMessageMode: mode,
+ },
+ )
+}
+/**
+ * @description:启用/禁用
+ */
+export function editEnable(id: string, mode: ErrorMessageMode = 'modal') {
+ return defHttp.put(
+ {
+ url: `/api/admin-users/${id}/enable `,
+ },
+ {
+ errorMessageMode: mode,
+ },
+ )
+}
+/**
+ * @description:获取详情
+ */
+export function getUsersInfo(id: string, mode: ErrorMessageMode = 'modal') {
+ return defHttp.get(
+ {
+ url: `/api/admin-users/${id} `,
+ },
+ {
+ errorMessageMode: mode,
+ },
+ )
+}
+/**
+ * @description:删除管理员
+ */
+export function deleteUser(id: string, mode: ErrorMessageMode = 'modal') {
+ return defHttp.delete(
+ {
+ url: `/api/admin-users/${id}`,
+ },
+ {
+ errorMessageMode: mode,
+ },
+ )
+}
+/**
+ * @description:编辑管理员
+ */
+export function editUser(id: string, data, mode: ErrorMessageMode = 'modal') {
+ return defHttp.put(
+ {
+ url: `/api/admin-users/${id}`,
+ data,
+ },
+ {
+ errorMessageMode: mode,
+ },
+ )
+}
+/**
+ * @description:修改管理员密码
+ */
+export function editPassword(id: string, data, mode: ErrorMessageMode = 'modal') {
+ return defHttp.put(
+ {
+ url: `/api/admin-users/${id}/edit-password`,
+ data,
+ },
+ {
+ errorMessageMode: mode,
+ },
+ )
+}
diff --git a/src/router/routes/modules/device.ts b/src/router/routes/modules/device.ts
index 95ca1027..a1efc9c3 100644
--- a/src/router/routes/modules/device.ts
+++ b/src/router/routes/modules/device.ts
@@ -1,5 +1,5 @@
-import type { AppRouteModule } from '/@/router/types';
-import { LAYOUT } from '/@/router/constant';
+import type { AppRouteModule } from '/@/router/types'
+import { LAYOUT } from '/@/router/constant'
const main: AppRouteModule = {
path: '/device',
name: 'Device',
@@ -20,6 +20,6 @@ const main: AppRouteModule = {
},
},
],
-};
+}
-export default main;
+export default main
diff --git a/src/router/routes/modules/system.ts b/src/router/routes/modules/system.ts
index 3e2ba40d..84f1bdc8 100644
--- a/src/router/routes/modules/system.ts
+++ b/src/router/routes/modules/system.ts
@@ -11,14 +11,6 @@ const main: AppRouteModule = {
title: '系统管理',
},
children: [
- {
- path: 'management',
- name: 'SystemManagement',
- component: () => import('/@/views/system/management/index.vue'),
- meta: {
- title: '设备管理',
- },
- },
{
path: 'role',
name: 'SystemRole',
diff --git a/src/utils/is.ts b/src/utils/is.ts
index fe55760e..fa170856 100644
--- a/src/utils/is.ts
+++ b/src/utils/is.ts
@@ -97,3 +97,9 @@ export function isUrl(path: string): boolean {
/^(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?(\/#\/)?(?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/
return reg.test(path)
}
+/**
+ * 验证手机格式
+ */
+export function isMobile(value: string) {
+ return /^1[3-9]\d{9}$/.test(value)
+}
diff --git a/src/views/device/management/DeviceDrawer.vue b/src/views/device/management/DeviceDrawer.vue
index 9d07becd..72c97765 100644
--- a/src/views/device/management/DeviceDrawer.vue
+++ b/src/views/device/management/DeviceDrawer.vue
@@ -7,107 +7,40 @@
width="500px"
@ok="handleSubmit"
>
-
+
-
diff --git a/src/views/device/management/index.vue b/src/views/device/management/index.vue
index efd11c50..fde6ea80 100644
--- a/src/views/device/management/index.vue
+++ b/src/views/device/management/index.vue
@@ -1,187 +1,73 @@
-
+
- 新增
+ 新增设备
-
+
+ ]"
+ />
+
-
-
-
+ const handleSuccess = () => {
+ message.success('操作成功')
+ reload()
+ }
+ const handleCreate = () => {
+ openDrawer(true, {
+ id: false,
+ })
+ }
+ const handleEdit = (record: Recordable) => {
+ openDrawer(true, {
+ ...record,
+ isUpdate: true,
+ })
+ }
+ const handleDelete = async (record: Recordable) => {
+ await deleteDevice(record.id)
+ message.success('删除成功')
+ reload()
+ }
+
diff --git a/src/views/device/management/management.data.ts b/src/views/device/management/management.data.ts
new file mode 100644
index 00000000..567c066b
--- /dev/null
+++ b/src/views/device/management/management.data.ts
@@ -0,0 +1,224 @@
+import { BasicColumn } from '/@/components/Table'
+import { FormSchema } from '/@/components/Table'
+import { getAgriculturalBasic } from '/@/api/sys/user'
+import { getDeviceTypes } from '/@/api/sys/other'
+import { h } from 'vue'
+import { Tag } from 'ant-design-vue'
+function formatDataByObject(obj): any[] {
+ const arr: any[] = []
+ Object.keys(obj).forEach((e) => {
+ arr.push({
+ label: obj[e],
+ value: e,
+ })
+ })
+ return arr
+}
+export const columns: BasicColumn[] = [
+ {
+ title: '类型',
+ dataIndex: 'type',
+ },
+ {
+ title: '设备编号',
+ dataIndex: 'sn',
+ },
+ {
+ title: '基地',
+ dataIndex: 'base_name',
+ },
+ {
+ title: '监控点',
+ dataIndex: 'monitoring_point',
+ },
+ {
+ title: '状态',
+ dataIndex: 'status',
+ customRender: ({ record }) => {
+ const status = record.status
+ // 状态: 0 禁用, 1 在线, 2 离线, 3 故障
+ const list = [
+ {
+ value: 0,
+ color: 'red',
+ label: '禁用',
+ },
+ {
+ value: 1,
+ color: 'green',
+ label: '在线',
+ },
+ {
+ value: 2,
+ color: 'pink',
+ label: '离线',
+ },
+ {
+ value: 3,
+ color: 'orange',
+ label: '故障',
+ },
+ ]
+ const item = list.find((e) => e.value === status)
+ const color = item?.color ?? 'red'
+ const text = item?.label ?? status
+ return h(Tag, { color: color }, () => text)
+ },
+ },
+ {
+ width: 180,
+ title: '操作',
+ dataIndex: 'action',
+ align: 'center',
+ fixed: undefined,
+ },
+]
+
+export const searchFormSchema: FormSchema[] = [
+ {
+ field: 'base',
+ label: '基地',
+ component: 'ApiSelect',
+ componentProps: {
+ api: getAgriculturalBasic,
+ labelField: 'name',
+ valueField: 'id',
+ },
+ colProps: { span: 6 },
+ },
+ {
+ field: 'type',
+ label: '类型',
+ component: 'ApiSelect',
+ componentProps: {
+ api: async () => {
+ const res = await getDeviceTypes()
+ return formatDataByObject(res)
+ },
+ },
+ colProps: { span: 6 },
+ },
+ {
+ field: 'status',
+ label: '状态',
+ component: 'Select',
+ componentProps: {
+ options: [
+ { label: '禁用', value: '0' },
+ { label: '在线', value: '1' },
+ { label: '离线', value: '2' },
+ { label: '故障', value: '3' },
+ ],
+ },
+ colProps: { span: 6 },
+ },
+ {
+ field: 'point',
+ label: '监控点',
+ component: 'Input',
+ colProps: { span: 6 },
+ },
+]
+
+export const accountFormSchema: FormSchema[] = [
+ {
+ field: 'id',
+ label: '设备ID',
+ required: false,
+ dynamicDisabled: true,
+ component: 'Input',
+ ifShow: ({ values }) => {
+ return !!values.id
+ },
+ },
+ {
+ field: 'type',
+ label: '设备类型',
+ required: true,
+ component: 'ApiSelect',
+ componentProps: {
+ api: async () => {
+ const res = await getDeviceTypes()
+ return formatDataByObject(res)
+ },
+ },
+ },
+ {
+ field: 'agricultural_base_id',
+ label: '基地',
+ required: true,
+ component: 'ApiSelect',
+ componentProps: {
+ api: getAgriculturalBasic,
+ labelField: 'name',
+ valueField: 'id',
+ },
+ },
+ {
+ field: 'sn',
+ label: '设备编号',
+ required: true,
+ component: 'Input',
+ },
+ {
+ field: 'monitoring_point',
+ label: '监控点',
+ required: true,
+ component: 'Input',
+ },
+ {
+ field: 'extends.ip',
+ label: '设备IP',
+ required: true,
+ component: 'Input',
+ ifShow: ({ values }) => {
+ return !!(values.type == 1)
+ },
+ },
+ {
+ field: 'extends.port',
+ label: '设备端口',
+ required: true,
+ component: 'Input',
+ ifShow: ({ values }) => {
+ return !!(values.type == 1)
+ },
+ },
+ {
+ field: 'extends.rtsp_url',
+ label: 'RTSP地址',
+ required: true,
+ component: 'Input',
+ ifShow: ({ values }) => {
+ return !!(values.type == 1)
+ },
+ },
+
+ {
+ field: 'extends.username',
+ label: '设备登录名',
+ required: true,
+ component: 'Input',
+ ifShow: ({ values }) => {
+ return !!(values.type == 1)
+ },
+ },
+ {
+ field: 'extends.password',
+ label: '设备登录密码',
+ required: true,
+ component: 'Input',
+ ifShow: ({ values }) => {
+ return !!(values.type == 1)
+ },
+ },
+ {
+ field: 'extends.passage',
+ label: '设备播放通道',
+ required: true,
+ component: 'Input',
+ ifShow: ({ values }) => {
+ return !!(values.type == 1)
+ },
+ },
+]
diff --git a/src/views/system/account/AccountDrawer.vue b/src/views/system/account/AccountDrawer.vue
new file mode 100644
index 00000000..4faf32d8
--- /dev/null
+++ b/src/views/system/account/AccountDrawer.vue
@@ -0,0 +1,60 @@
+
+
+
+
+
+
diff --git a/src/views/system/account/account.data.ts b/src/views/system/account/account.data.ts
index 1ac4d189..cd877f61 100644
--- a/src/views/system/account/account.data.ts
+++ b/src/views/system/account/account.data.ts
@@ -1,18 +1,99 @@
import { BasicColumn } from '/@/components/Table'
import { FormSchema } from '/@/components/Table'
+import { getRoles, getAgriculturalBasic, editEnable } from '/@/api/sys/user'
+import { isMobile } from '/@/utils/is'
+import { h } from 'vue'
+import { Tag, Switch, message } from 'ant-design-vue'
export const columns: BasicColumn[] = [
{
- title: '角色名称',
- dataIndex: 'name',
- width: 200,
- },
- {
- title: '角色编码',
- dataIndex: 'slug',
+ title: '用户名',
+ dataIndex: 'username',
width: 180,
},
{
- width: 80,
+ title: '昵称',
+ dataIndex: 'name',
+ width: 180,
+ },
+ {
+ title: '电话',
+ dataIndex: 'phone',
+ width: 180,
+ customRender: ({ text }) => {
+ if (!text) return '-'
+ return text
+ },
+ },
+ {
+ title: '部门',
+ dataIndex: 'department',
+ width: 180,
+ customRender: ({ text }) => {
+ if (!text) return '-'
+ return text
+ },
+ },
+ {
+ title: '是否启用',
+ dataIndex: 'is_enable',
+ width: 180,
+ customRender: ({ record }) => {
+ if (!Reflect.has(record, 'pendingStatus')) {
+ record.pendingStatus = false
+ }
+ return h(Switch, {
+ checked: record.is_enable == 1,
+ checkedChildren: '正常',
+ unCheckedChildren: '禁用',
+ loading: record.pendingStatus,
+ onChange: (e) => {
+ record.pendingStatus = true
+ editEnable(record.id)
+ .then(() => {
+ record.is_enable = e ? 1 : 0
+ message.success('状态修改成功')
+ })
+ .catch(({ msg }) => {
+ message.error(msg)
+ })
+ .finally(() => {
+ record.pendingStatus = false
+ })
+ },
+ })
+ },
+ },
+ {
+ title: '状态',
+ dataIndex: 'status',
+ width: 180,
+ customRender: ({ record }) => {
+ const status = record.status
+ const list = [
+ {
+ value: 1,
+ color: 'green',
+ label: '在职',
+ },
+ {
+ value: 2,
+ color: 'pink',
+ label: '离职',
+ },
+ {
+ value: 3,
+ color: 'orange',
+ label: '休假',
+ },
+ ]
+ const item = list.find((e) => e.value === status)
+ const color = item?.color ?? 'red'
+ const text = item?.label ?? status
+ return h(Tag, { color: color }, () => text)
+ },
+ },
+ {
+ width: 180,
title: '操作',
dataIndex: 'action',
align: 'center',
@@ -20,31 +101,12 @@ export const columns: BasicColumn[] = [
},
]
-export const searchFormSchema: FormSchema[] = [
- // {
- // field: 'roleNme',
- // label: '角色名称',
- // component: 'Input',
- // colProps: { span: 8 },
- // },
- // {
- // field: 'status',
- // label: '状态',
- // component: 'Select',
- // componentProps: {
- // options: [
- // { label: '启用', value: '0' },
- // { label: '停用', value: '1' },
- // ],
- // },
- // colProps: { span: 8 },
- // },
-]
+export const searchFormSchema: FormSchema[] = []
-export const formSchema: FormSchema[] = [
+export const accountFormSchema: FormSchema[] = [
{
field: 'id',
- label: '角色ID',
+ label: '用户ID',
required: false,
dynamicDisabled: true,
component: 'Input',
@@ -53,24 +115,115 @@ export const formSchema: FormSchema[] = [
},
},
{
- field: 'name',
- label: '角色名',
+ field: 'username',
+ label: '用户名',
required: true,
component: 'Input',
},
{
- field: 'slug',
- label: '角色编码',
+ field: 'password',
+ label: '密码',
required: true,
- component: 'Input',
- },
- {
- label: ' ',
- field: 'permission_ids',
- slot: 'menu',
- component: 'Input',
+ component: 'InputPassword',
ifShow: ({ values }) => {
- return !!values.id
+ return !values.id
+ },
+ },
+ {
+ field: 'name',
+ label: '姓名',
+ required: true,
+ component: 'Input',
+ },
+ {
+ field: 'role_id',
+ label: '角色选择',
+ required: true,
+ component: 'ApiSelect',
+ componentProps: {
+ api: getRoles,
+ labelField: 'name',
+ valueField: 'id',
+ },
+ },
+ {
+ field: 'status',
+ label: '状态',
+ required: true,
+ component: 'RadioGroup',
+ componentProps: {
+ options: [
+ {
+ label: '在职',
+ value: 1,
+ },
+ {
+ label: '离职',
+ value: 2,
+ },
+ {
+ label: '休假',
+ value: 3,
+ },
+ ],
+ },
+ },
+ {
+ field: 'department',
+ label: '部门',
+ required: false,
+ component: 'Input',
+ },
+ {
+ field: 'phone',
+ label: '手机号',
+ component: 'Input',
+ componentProps: {
+ type: 'number',
+ },
+ rules: [
+ {
+ required: false,
+ message: '请输入',
+ },
+ {
+ validator(_, value) {
+ return new Promise((resolve, reject) => {
+ if (!value) return resolve()
+ if (isMobile(value)) {
+ return resolve()
+ } else reject('手机号格式不正确')
+ })
+ },
+ },
+ ],
+ },
+
+ {
+ field: 'base_ids',
+ label: '基地数据',
+ required: false,
+ component: 'ApiSelect',
+ componentProps: {
+ api: getAgriculturalBasic,
+ labelField: 'name',
+ valueField: 'id',
+ mode: 'multiple',
},
},
]
+
+export const passwordFormSchema: FormSchema[] = [
+ {
+ field: 'password',
+ label: '密码',
+ required: true,
+ component: 'InputPassword',
+ },
+ {
+ field: 'password_confirmation',
+ label: '确认密码',
+ required: true,
+ component: 'InputPassword',
+ },
+]
diff --git a/src/views/system/account/index.vue b/src/views/system/account/index.vue
index e9930ee0..5025821e 100644
--- a/src/views/system/account/index.vue
+++ b/src/views/system/account/index.vue
@@ -2,7 +2,7 @@
- 新增角色
+ 新增账号
@@ -10,6 +10,7 @@
+
+
+
-
diff --git a/src/views/system/account/passwordModel.vue b/src/views/system/account/passwordModel.vue
new file mode 100644
index 00000000..52d7bf63
--- /dev/null
+++ b/src/views/system/account/passwordModel.vue
@@ -0,0 +1,45 @@
+
+
+
+
+
+
diff --git a/src/views/system/management/index.vue b/src/views/system/management/index.vue
deleted file mode 100644
index 2790f392..00000000
--- a/src/views/system/management/index.vue
+++ /dev/null
@@ -1,15 +0,0 @@
-
- 设备管理
-
-
-
-
-
diff --git a/src/views/system/role/role.data.ts b/src/views/system/role/role.data.ts
index 1ac4d189..e7ee9efc 100644
--- a/src/views/system/role/role.data.ts
+++ b/src/views/system/role/role.data.ts
@@ -69,8 +69,5 @@ export const formSchema: FormSchema[] = [
field: 'permission_ids',
slot: 'menu',
component: 'Input',
- ifShow: ({ values }) => {
- return !!values.id
- },
},
]