312 lines
8.3 KiB
TypeScript
312 lines
8.3 KiB
TypeScript
|
import { TableProMaxProps, TableProMaxSlots } from '@/types/components/table'
|
||
|
import { EnterprisesUnitPagerQueryParams, securityUnitIdListPagerVo, securityUnitIdListParams, PoliceUnitPagerVo } from '@/types/views/unitManage/police/policeUnit.ts'
|
||
|
import { reactive, ref } from 'vue'
|
||
|
import { FormExpose } from 'ant-design-vue/es/form/Form'
|
||
|
import { ComponentExposed } from 'vue-component-type-helpers'
|
||
|
import { FormProMaxItemOptions } from '@/types/components/form'
|
||
|
import { dictSelectNodes } from '@/config/dict.ts'
|
||
|
import { Button, message, Modal, Space, Tag } from 'ant-design-vue'
|
||
|
import api from '@/axios'
|
||
|
import TableProMax from '@/components/table/TableProMax.vue'
|
||
|
import { deleteDataModal } from '@/components/tsx/ModalPro.tsx'
|
||
|
import { PageParams } from '@/types/hooks/useTableProMax.ts'
|
||
|
import FormProMax from '@/components/form/FormProMax.vue'
|
||
|
|
||
|
type _TableProps = TableProMaxProps<securityUnitIdListPagerVo, EnterprisesUnitPagerQueryParams>
|
||
|
|
||
|
const _formParams = reactive<securityUnitIdListParams>({
|
||
|
snowFlakeId: '', //
|
||
|
serviceProjectId: '', // 服务项目id
|
||
|
securityUnitId: '', // 保安单位id
|
||
|
name: '', //
|
||
|
photo: '',
|
||
|
telephone: '',
|
||
|
workPost: '',
|
||
|
sex: '',
|
||
|
nativePlace: '',
|
||
|
idCard: '',
|
||
|
dateOfBirth: '',
|
||
|
securityNumber: '',
|
||
|
noSecurityNumberDesc: '',
|
||
|
homeAddress: '',
|
||
|
remark: '',
|
||
|
})
|
||
|
const saveOrUpdateEnterprisesUnit = (callback: Function, params, type: string) => {
|
||
|
console.log('🚀 ~ saveOrUpdateEnterprisesUnit ~ params:', params)
|
||
|
if (type === 'add') {
|
||
|
_formParams.serviceProjectId = params.snowFlakeId
|
||
|
_formParams.securityUnitId = params.securityUnitId
|
||
|
} else {
|
||
|
_formParams.snowFlakeId = params.snowFlakeId
|
||
|
_formParams.serviceProjectId = params.serviceProjectId
|
||
|
_formParams.securityUnitId = params.securityUnitId
|
||
|
_formParams.name = params.name
|
||
|
_formParams.photo = params?.photo
|
||
|
_formParams.telephone = params.telephone.originalValue
|
||
|
_formParams.workPost = params.workPost
|
||
|
_formParams.sex = params.sex.value
|
||
|
_formParams.nativePlace = params.nativePlace
|
||
|
_formParams.idCard = params.idCard.originalValue
|
||
|
_formParams.dateOfBirth = params.dateOfBirth
|
||
|
_formParams.securityNumber = params.securityNumber
|
||
|
_formParams.noSecurityNumberDesc = params?.noSecurityNumberDesc
|
||
|
_formParams.homeAddress = params.homeAddress
|
||
|
_formParams.remark = params.remark
|
||
|
}
|
||
|
|
||
|
const _formRef = ref<FormExpose>(null)
|
||
|
|
||
|
const _formOptions = ref<FormProMaxItemOptions<any>>({
|
||
|
name: {
|
||
|
type: 'input',
|
||
|
label: '姓名',
|
||
|
required: true,
|
||
|
},
|
||
|
idCard: {
|
||
|
type: 'input',
|
||
|
label: '身份证',
|
||
|
required: true,
|
||
|
},
|
||
|
telephone: {
|
||
|
type: 'input',
|
||
|
label: '手机号',
|
||
|
required: true,
|
||
|
},
|
||
|
sex: {
|
||
|
type: 'radioGroup',
|
||
|
label: '性别',
|
||
|
required: true,
|
||
|
options: [...dictSelectNodes('Sex')],
|
||
|
},
|
||
|
securityNumber: {
|
||
|
type: 'input',
|
||
|
label: '保安证号',
|
||
|
required: true,
|
||
|
},
|
||
|
dateOfBirth: {
|
||
|
type: 'datePicker',
|
||
|
label: '出生日期',
|
||
|
componentsProps: {
|
||
|
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
||
|
},
|
||
|
required: true,
|
||
|
},
|
||
|
|
||
|
workPost: {
|
||
|
type: 'input',
|
||
|
label: '工作岗位',
|
||
|
},
|
||
|
nativePlace: {
|
||
|
type: 'input',
|
||
|
label: '籍贯',
|
||
|
},
|
||
|
homeAddress: {
|
||
|
type: 'input',
|
||
|
label: '家庭住址',
|
||
|
},
|
||
|
noSecurityNumberDesc: {
|
||
|
type: 'input',
|
||
|
label: '无证说明',
|
||
|
},
|
||
|
|
||
|
remark: {
|
||
|
type: 'inputTextArea',
|
||
|
label: '备注',
|
||
|
},
|
||
|
})
|
||
|
Modal.confirm({
|
||
|
title: params.name ? `【${params.name}】 编辑保安信息` : '新增保安人员',
|
||
|
width: 600,
|
||
|
icon: ' ',
|
||
|
centered: true,
|
||
|
content: () => <FormProMax ref={_formRef} v-model:value={_formParams} formItemOptions={_formOptions.value} />,
|
||
|
onOk: async () => {
|
||
|
await _formRef.value?.validate()
|
||
|
|
||
|
const resp = await api.post('/m2/eu/add_upd_sec_user', {
|
||
|
..._formParams,
|
||
|
})
|
||
|
message.success(resp.message)
|
||
|
callback && callback()
|
||
|
},
|
||
|
onCancel: async () => {
|
||
|
console.log('onCancel')
|
||
|
|
||
|
_formParams.snowFlakeId = ''
|
||
|
_formParams.serviceProjectId = ''
|
||
|
_formParams.securityUnitId = ''
|
||
|
_formParams.name = ''
|
||
|
_formParams.photo = ''
|
||
|
_formParams.telephone = ''
|
||
|
_formParams.workPost = ''
|
||
|
_formParams.sex = ''
|
||
|
_formParams.nativePlace = ''
|
||
|
_formParams.idCard = ''
|
||
|
_formParams.dateOfBirth = ''
|
||
|
_formParams.securityNumber = ''
|
||
|
_formParams.noSecurityNumberDesc = ''
|
||
|
_formParams.homeAddress = ''
|
||
|
_formParams.remark = ''
|
||
|
},
|
||
|
})
|
||
|
}
|
||
|
// record_
|
||
|
export const showEnterprisesUnit = (record_) => {
|
||
|
console.log('🚀 ~ showEnterprisesUnit ~ record_:', record_)
|
||
|
const _tableRef = ref<ComponentExposed<typeof TableProMax>>(null)
|
||
|
const _columns: _TableProps['columns'] = [
|
||
|
{
|
||
|
dataIndex: 'name',
|
||
|
title: '姓名',
|
||
|
width: 100,
|
||
|
ellipsis: true,
|
||
|
},
|
||
|
|
||
|
{
|
||
|
dataIndex: 'idCard',
|
||
|
title: '身份证',
|
||
|
customRender: ({ text }) => {
|
||
|
return text.desensitizedValue
|
||
|
},
|
||
|
width: 160,
|
||
|
ellipsis: true,
|
||
|
},
|
||
|
|
||
|
{
|
||
|
dataIndex: 'sex',
|
||
|
title: '性别',
|
||
|
width: 60,
|
||
|
customRender: ({ record }) => {
|
||
|
return <Tag color={'success'}>{record.sex.label}</Tag>
|
||
|
},
|
||
|
},
|
||
|
{
|
||
|
dataIndex: 'dateOfBirth',
|
||
|
title: '出生日期',
|
||
|
width: 100,
|
||
|
ellipsis: true,
|
||
|
},
|
||
|
{
|
||
|
dataIndex: 'telephone',
|
||
|
title: '手机号',
|
||
|
width: 120,
|
||
|
ellipsis: true,
|
||
|
customRender: ({ text }) => text?.originalValue,
|
||
|
},
|
||
|
{
|
||
|
dataIndex: 'securityNumber',
|
||
|
title: '保安证号',
|
||
|
width: 120,
|
||
|
ellipsis: true,
|
||
|
},
|
||
|
{
|
||
|
dataIndex: 'nativePlace',
|
||
|
title: '籍贯',
|
||
|
width: 120,
|
||
|
ellipsis: true,
|
||
|
},
|
||
|
{
|
||
|
dataIndex: 'workPost',
|
||
|
title: '工作岗位',
|
||
|
width: 120,
|
||
|
ellipsis: true,
|
||
|
},
|
||
|
|
||
|
{
|
||
|
dataIndex: 'homeAddress',
|
||
|
title: '家庭住址',
|
||
|
width: 120,
|
||
|
ellipsis: true,
|
||
|
},
|
||
|
{
|
||
|
dataIndex: 'remark',
|
||
|
title: '备注',
|
||
|
width: 120,
|
||
|
},
|
||
|
{
|
||
|
dataIndex: 'createTime',
|
||
|
title: '创建时间',
|
||
|
width: 120,
|
||
|
ellipsis: true,
|
||
|
},
|
||
|
|
||
|
{
|
||
|
dataIndex: 'opt',
|
||
|
title: '操作',
|
||
|
width: 200,
|
||
|
fixed: 'right',
|
||
|
customRender: ({ record }) => (
|
||
|
<Space>
|
||
|
<Button class='btn-warn' onClick={() => saveOrUpdateEnterprisesUnit(_tableRef.value?.requestGetTableData, record, 'edit')}>
|
||
|
编辑
|
||
|
</Button>
|
||
|
<Button
|
||
|
class='btn-danger'
|
||
|
onClick={() =>
|
||
|
deleteDataModal(record.name, async () => {
|
||
|
const resp = await api.delete('/m2/eu/del_security_user_id', {
|
||
|
enterprisesUnitId: record.snowFlakeId,
|
||
|
})
|
||
|
message.success(resp.message)
|
||
|
await _tableRef.value?.requestGetTableData()
|
||
|
})
|
||
|
}
|
||
|
>
|
||
|
删除
|
||
|
</Button>
|
||
|
</Space>
|
||
|
),
|
||
|
},
|
||
|
]
|
||
|
const x: number = _columns.reduce((a, b) => a + (b.width as number), 0)
|
||
|
const _reqApi: _TableProps['requestApi'] = (params) => {
|
||
|
// console.log(record_);
|
||
|
|
||
|
;(params as PageParams<EnterprisesUnitPagerQueryParams>).params.serviceProjectId = record_.snowFlakeId
|
||
|
return api.post('/m2/eu/sec_user_pager', params)
|
||
|
}
|
||
|
Modal.info({
|
||
|
title: `【${record_.name}】 管理保安人员`,
|
||
|
width: '80%',
|
||
|
centered: true,
|
||
|
maskClosable: true,
|
||
|
content: () => (
|
||
|
<TableProMax
|
||
|
scroll={{ x: x }}
|
||
|
ref={_tableRef}
|
||
|
size='small'
|
||
|
columns={_columns}
|
||
|
requestApi={_reqApi}
|
||
|
searchFormOptions={{
|
||
|
name: {
|
||
|
type: 'input',
|
||
|
label: '姓名',
|
||
|
},
|
||
|
securityNumber: {
|
||
|
type: 'input',
|
||
|
label: '保安证号',
|
||
|
},
|
||
|
telephone: {
|
||
|
type: 'input',
|
||
|
label: '手机号',
|
||
|
},
|
||
|
}}
|
||
|
v-slots={
|
||
|
{
|
||
|
tableHeader: (_) => {
|
||
|
return (
|
||
|
<Space>
|
||
|
<Button class='btn-success' onClick={() => saveOrUpdateEnterprisesUnit(_tableRef.value?.requestGetTableData, record_, 'add')}>
|
||
|
新增
|
||
|
</Button>
|
||
|
<Button disabled>导入</Button>
|
||
|
</Space>
|
||
|
)
|
||
|
},
|
||
|
} as TableProMaxSlots<PoliceUnitPagerVo>
|
||
|
}
|
||
|
/>
|
||
|
),
|
||
|
})
|
||
|
}
|