Compare commits

..

2 Commits

1 changed files with 86 additions and 86 deletions

View File

@ -2,13 +2,7 @@
<!-- 后台用户 -->
<!-- template 内部必须有一个根节点 div否则<Transition>将会失效所以这个<a-modal></a-modal> div -->
<div>
<TableProMax
ref="tableRef"
:request-api="reqApi"
:columns="columns"
:searchFormOptions="searchFormOptions"
:scroll="{x}"
>
<TableProMax ref="tableRef" :request-api="reqApi" :columns="columns" :searchFormOptions="searchFormOptions" :scroll="{ x }">
<template #tableHeader>
<a-space>
<a-button type="primary" @click="addUserManagement">新增用户</a-button>
@ -23,30 +17,31 @@
</template>
<script setup lang="tsx">
import TableProMax from "@/components/table/TableProMax.vue";
import {TableProMaxProps} from "@/types/components/table";
import TableProMax from '@/components/table/TableProMax.vue'
import { TableProMaxProps } from '@/types/components/table'
import { message } from 'ant-design-vue'
import { dictSelectNodes } from '@/config/dict.ts'
// const enumsSex = ref<any[]>(dictSelectNodes('Sex'))
// const enumsIsEnable = ref<any[]>(dictSelectNodes('IsEnable'))
import api from '@/axios/index.ts'
import { ref, reactive, onMounted } from 'vue'
import FormProMax from "@/components/form/FormProMax.vue";
import {FormProMaxItemOptions} from "@/types/components/form";
import {FormExpose} from "ant-design-vue/es/form/Form";
import {publicUnitPagerQueryParams, FromItem} from "@/types/views/publicUnit.ts";
import FormProMax from '@/components/form/FormProMax.vue'
import { FormProMaxItemOptions } from '@/types/components/form'
import { FormExpose } from 'ant-design-vue/es/form/Form'
import { publicUnitPagerQueryParams, FromItem } from '@/types/views/publicUnit.ts'
const tableRef = ref<ComponentExposed<typeof TableProMax>>(null!)
const formRef = ref<FormExpose>(null)
type TableProps = TableProMaxProps<publicUnitPagerQueryParams>
const reqApi: TableProps['requestApi'] = (params) => api.post('/management/police/user/pager', params) //
const formParams = ref<{
snowFlakeId?: string,
name: string,
sex: number,
telephone: string,
isEnable: any,
// const reqApi: TableProps['requestApi'] = (params) => api.post('/management/police/user/pager', params) //
const reqApi: TableProps['requestApi'] = (params) => api.post('/m2/user/pager', params) //
const formParams = ref<{
snowFlakeId?: string
name: string
sex: number
telephone: string
isEnable: any
}>({
name: '',
sex: 0,
@ -58,9 +53,7 @@ const formItemOptions = ref<FormProMaxItemOptions<FromItem>>({
type: 'input',
label: '姓名',
required: true,
rules: [
{required: true, message: '请输入姓名'}
],
rules: [{ required: true, message: '请输入姓名' }],
},
sex: {
type: 'radioGroup',
@ -78,11 +71,11 @@ const formItemOptions = ref<FormProMaxItemOptions<FromItem>>({
validator: (rule, value) => {
const phoneRegex = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/
if (!value) {
return Promise.reject('手机号不能为空');
return Promise.reject('手机号不能为空')
} else if (!phoneRegex.test(value)) {
return Promise.reject('手机号格式不正确');
return Promise.reject('手机号格式不正确')
} else {
return Promise.resolve();
return Promise.resolve()
}
},
trigger: 'blur',
@ -101,25 +94,25 @@ const columns: TableProps['columns'] = [
dataIndex: 'account',
title: '账号',
width: 100,
ellipsis: true
ellipsis: true,
},
{
dataIndex: 'name',
title: '名称',
width: 200,
ellipsis: true
ellipsis: true,
},
{
dataIndex: 'sex',
title: '性别',
customRender: ({ text }) => <a-tag>{text?.label}</a-tag>,
width: 150
width: 150,
},
{
dataIndex: 'telephone',
title: '手机号码',
width: 150,
ellipsis: true
ellipsis: true,
},
{
dataIndex: 'createTime',
@ -132,65 +125,71 @@ const columns: TableProps['columns'] = [
dataIndex: 'isEnable',
title: '是否启用',
customRender: ({ text }) => <a-tag color={text?.extData?.color}>{text?.label}</a-tag>,
width: 150
width: 150,
},
{
dataIndex: 'opt',
title: '操作',
fixed: "right",
fixed: 'right',
customRender({ record }) {
return (
record.isAdmin.value === 1 ?
return record.isAdmin.value === 1 ? (
<a-space>
<a-popconfirm
style="width:100%"
title="确认删除账号吗?"
style='width:100%'
title='确认删除账号吗?'
onConfirm={async () => {
const resp = await api.delete('/management/police/user/deleteById', {
{
/* const resp = await api.delete('/management/police/user/deleteById', { */
}
const resp = await api.delete('/m2/user/del_id', {
managementPoliceUnitUserId: record.snowFlakeId,
})
message.success(resp.message)
await tableRef.value?.requestGetTableData()
}}>
<a-button type="primary" danger>删除</a-button>
}}
>
<a-button type='primary' danger>
删除
</a-button>
</a-popconfirm>
<a-button type="primary" onClick={async () => {
<a-button
type='primary'
onClick={async () => {
visible.value = true
title.value = "编辑用户"
title.value = '编辑用户'
formParams.value.snowFlakeId = record.snowFlakeId
formParams.value.name = record.name,
formParams.value.sex = record.sex.value,
formParams.value.telephone = record.telephone,
formParams.value.isEnable = record.isEnable?.value
}}>
;(formParams.value.name = record.name), (formParams.value.sex = record.sex.value), (formParams.value.telephone = record.telephone), (formParams.value.isEnable = record.isEnable?.value)
}}
>
编辑
</a-button>
</a-space>
:
) : (
<div>超级管理员不能编辑</div>
)
}
},
},
]
const x: number = columns.reduce((a, b) => a + (b.width as number), 0)
const searchFormOptions: TableProps["searchFormOptions"] = {
const searchFormOptions: TableProps['searchFormOptions'] = {
name: {
type: 'input',
label: '名称'
}, sex: {
label: '名称',
},
sex: {
type: 'select',
label: '性别',
options: [
{
value: null,
label: '全部'
}, ...dictSelectNodes('Sex')
]
label: '全部',
},
...dictSelectNodes('Sex'),
],
},
telephone: {
type: 'input',
label: '手机号'
label: '手机号',
},
isEnable: {
type: 'select',
@ -198,10 +197,11 @@ const searchFormOptions: TableProps["searchFormOptions"] = {
options: [
{
value: null,
label: '全部'
}, ...dictSelectNodes('IsEnable')
]
}
label: '全部',
},
...dictSelectNodes('IsEnable'),
],
},
}
const visible = ref(false)
const title = ref('新增用户')
@ -222,13 +222,13 @@ const submit = async () => {
sex: formParams.value.sex,
telephone: formParams.value.telephone,
isEnable: formParams.value.isEnable,
}
const resp = await api.post('/management/police/user/saveOrUpdate', managementSecurityUnitUserSaveOrUpdateParams)
// const resp = await api.post('/management/police/user/saveOrUpdate', managementSecurityUnitUserSaveOrUpdateParams)
const resp = await api.post('/m2/user/add_upd', managementSecurityUnitUserSaveOrUpdateParams)
message.success(resp.message)
tableRef.value?.requestGetTableData()
closeModal()
}
const closeModal = () => {
@ -236,7 +236,7 @@ const closeModal = () => {
name: '',
sex: 0,
telephone: '',
isEnable: 0
isEnable: 0,
}
visible.value = false
title.value = '新增用户'