Compare commits

..

No commits in common. "e99471379a4aa28240b72edddc6859addaf4051b" and "92b120380e3dc3600704c3761f327e0b9e83265c" have entirely different histories.

1 changed files with 86 additions and 86 deletions

View File

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