Compare commits
No commits in common. "e99471379a4aa28240b72edddc6859addaf4051b" and "92b120380e3dc3600704c3761f327e0b9e83265c" have entirely different histories.
e99471379a
...
92b120380e
|
@ -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 (
|
||||||
|
record.isAdmin.value === 1 ?
|
||||||
<a-space>
|
<a-space>
|
||||||
<a-popconfirm
|
<a-popconfirm
|
||||||
style='width:100%'
|
style="width:100%"
|
||||||
title='确认删除账号吗?'
|
title="确认删除账号吗?"
|
||||||
onConfirm={async () => {
|
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,
|
managementPoliceUnitUserId: record.snowFlakeId,
|
||||||
})
|
})
|
||||||
message.success(resp.message)
|
message.success(resp.message)
|
||||||
await tableRef.value?.requestGetTableData()
|
await tableRef.value?.requestGetTableData()
|
||||||
}}
|
}}>
|
||||||
>
|
<a-button type="primary" danger>删除</a-button>
|
||||||
<a-button type='primary' danger>
|
|
||||||
删除
|
|
||||||
</a-button>
|
|
||||||
</a-popconfirm>
|
</a-popconfirm>
|
||||||
<a-button
|
<a-button type="primary" onClick={async () => {
|
||||||
type='primary'
|
|
||||||
onClick={async () => {
|
|
||||||
visible.value = true
|
visible.value = true
|
||||||
title.value = '编辑用户'
|
title.value = "编辑用户"
|
||||||
formParams.value.snowFlakeId = record.snowFlakeId
|
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-button>
|
||||||
</a-space>
|
</a-space>
|
||||||
) : (
|
:
|
||||||
<div>超级管理员不能编辑</div>
|
<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 = '新增用户'
|
||||||
|
|
Loading…
Reference in New Issue