公安后台服务项目 的增删改

This commit is contained in:
TimSpan 2024-11-28 14:11:08 +08:00
parent 99ccb3e734
commit 7347a38429
3 changed files with 410 additions and 6 deletions

View File

@ -97,6 +97,9 @@ interface OptionsResponse {
DeleteFlag: Option[]; DeleteFlag: Option[];
} }
interface TypeEnum<T> {
value: string;
label: string
}

View File

@ -0,0 +1,24 @@
import { BaseTableRowRecord } from "@/types/components/table";
export interface serviceProjectSaveOrUpdateParams_ extends BaseTableRowRecord {
snowFlakeId: string
enterprisesUnitId: string,
enterprisesUnitName: string,
projectManagerMiniProgramUserId: string,
projectManagerMiniProgramUserName: string,
name: string,
type: TypeEnum<string>,
twoType: BaseEnum<any>,
outsourceName: string,
isFiling: BaseEnum<number>,
idNumber: string,
serviceArea: number,
buildingTotal: number,
houseTotal: number,
staffTotal: number,
securityUserTotal: number,
remark: string,
createUserName: string,
createTime: string,
enterprisesUnitAdministrativeDivisionCodes: Record<string, any>
}

View File

@ -1,12 +1,29 @@
<template> <template>
<div> <div>
<TableProMax ref="tableRef" :request-api="reqApi" :columns="columns" :searchFormOptions="searchFormOptions" :scroll="{ x }"> <!-- expand-column-widt 展开按钮宽度-->
<!-- :expandRowByClick="true" 点击行展开 -->
<TableProMax
:expandedRowRender="expandedRowRender"
:expand-column-width="50"
:defaultExpandAllRows="false"
ref="tableRef"
:request-api="reqApi"
:columns="columns"
:searchFormOptions="searchFormOptions"
:scroll="{ x }"
>
<template #tableHeader> <template #tableHeader>
<a-space> <a-space>
<a-button type="primary" @click="saveOrUpdateEnterprisesUnit">新增企事业单位</a-button> <a-button type="primary" @click="saveOrUpdateEnterprisesUnit">新增企事业单位</a-button>
</a-space> </a-space>
</template> </template>
<!-- <template #expandedRowRender="{ record }">
<p>{{ record }}</p>
</template> -->
</TableProMax> </TableProMax>
<a-modal v-model:open="visible" :title="serviceTitle" @ok="submit" @cancel="closeModal">
<FormProMax ref="formRef" v-model:value="formParams" :form-item-options="formItemOptions" />
</a-modal>
</div> </div>
</template> </template>
@ -18,7 +35,7 @@ import { AutoComplete, Button, Input, message, Modal, Space } from 'ant-design-v
import { debounce } from 'lodash-es' import { debounce } from 'lodash-es'
import FormProMax from '@/components/form/FormProMax.vue' import FormProMax from '@/components/form/FormProMax.vue'
import api from '@/axios' import api from '@/axios'
import { ref, reactive } from 'vue' import { ref, reactive, computed, onMounted } from 'vue'
import TableProMax from '@/components/table/TableProMax.vue' import TableProMax from '@/components/table/TableProMax.vue'
import { TableProMaxProps } from '@/types/components/table/index.ts' import { TableProMaxProps } from '@/types/components/table/index.ts'
import { ComponentExposed } from 'vue-component-type-helpers' import { ComponentExposed } from 'vue-component-type-helpers'
@ -26,13 +43,13 @@ import { dictSelectNodes } from '@/config/dict.ts'
import { publicUnitPagerQueryParams } from '@/types/views/publicUnit.ts' import { publicUnitPagerQueryParams } from '@/types/views/publicUnit.ts'
import { FormProMaxItemOptions } from '@/types/components/form//index.ts' import { FormProMaxItemOptions } from '@/types/components/form//index.ts'
import { FormExpose } from 'ant-design-vue/es/form/Form' import { FormExpose } from 'ant-design-vue/es/form/Form'
import { serviceProjectSaveOrUpdateParams_ } from '@/types/views/serviceManagement'
type _FormType = EnterprisesUnitSaveOrUpdateParams & { type _FormType = EnterprisesUnitSaveOrUpdateParams & {
contactPersonInfoName?: string contactPersonInfoName?: string
contactPersonInfoTelephone?: string contactPersonInfoTelephone?: string
} }
type TableProps = TableProMaxProps<publicUnitPagerQueryParams> type TableProps = TableProMaxProps<publicUnitPagerQueryParams>
// const reqApi: TableProps['requestApi'] = (params) => api.post('/enterprisesUnit/pager', params) //
const reqApi: TableProps['requestApi'] = (params) => api.post('/eu/pager', params) // const reqApi: TableProps['requestApi'] = (params) => api.post('/eu/pager', params) //
const tableRef = ref<ComponentExposed<typeof TableProMax>>(null) const tableRef = ref<ComponentExposed<typeof TableProMax>>(null)
const columns: TableProps['columns'] = [ const columns: TableProps['columns'] = [
@ -281,7 +298,7 @@ const saveOrUpdateEnterprisesUnit = (params: _FormType, callback: Function) => {
content: () => <FormProMax ref={_formRef} v-model:value={_formParams.value} formItemOptions={_formOptions.value} />, content: () => <FormProMax ref={_formRef} v-model:value={_formParams.value} formItemOptions={_formOptions.value} />,
onOk: async () => { onOk: async () => {
await _formRef.value?.validate() await _formRef.value?.validate()
// const resp = await api.post('/enterprisesUnit/saveOrUpdate', {
const resp = await api.post('/eu/add_upd', { const resp = await api.post('/eu/add_upd', {
..._formParams.value, ..._formParams.value,
contactPersonInfo: { contactPersonInfo: {
@ -292,7 +309,6 @@ const saveOrUpdateEnterprisesUnit = (params: _FormType, callback: Function) => {
message.success(resp.message) message.success(resp.message)
await tableRef.value?.requestGetTableData() await tableRef.value?.requestGetTableData()
// reqApi(params)
callback && callback() callback && callback()
}, },
}) })
@ -313,4 +329,365 @@ const searchFormOptions = reactive<TableProps['searchFormOptions']>({
label: '手机号', label: '手机号',
}, },
}) })
type _TableProps = TableProMaxProps<any>
const isRecruitSecurityHidden = ref<boolean>(false)
const visible = ref(false)
const serviceTitle = ref('新增服务项目')
const idNumberDisabled = ref<boolean>(true)
const formRef = ref<FormExpose>(null)
const enterprisesUnitId = ref('')
const netType = computed(() => {
//@ts-ignore
return formParams.value.type === 'security' ? dictSelectNodes('ServiceProjectTwoType') : dictSelectNodes('UserType' as any)
})
const formParams = ref<{
snowFlakeId?: string
enterprisesUnitId: string
securityUnitId: string
administrativeDivisionCodes?: null
projectManagerMiniProgramUserId?: string
projectManagerMiniProgramUserName?: string
name: string
type: string
twoType?: number
outsourceName?: string
isFiling?: number
idNumber?: string
serviceArea?: number
buildingTotal?: number
houseTotal?: number
staffTotal?: number
securityUserTotal?: number
remark?: string
}>({
name: '',
enterprisesUnitId: null,
type: 'security',
securityUnitId: null,
})
const securityUnitIdList = ref<any>([])
const formItemOptions = ref<FormProMaxItemOptions<serviceProjectSaveOrUpdateParams_>>({
name: {
type: 'input',
label: '服务项目名称',
required: true,
},
securityUnitId: {
type: 'select',
label: '保安单位',
required: true,
options: securityUnitIdList,
},
type: {
type: 'radioGroup',
label: '服务类型',
//@ts-ignore
options: dictSelectNodes('ServiceProjectType'),
required: true,
componentsProps: {
onChange: (e) => {
if (e.target?.value === 'security') {
isRecruitSecurityHidden.value = false
formParams.value.twoType = null
} else {
formParams.value.twoType = null
isRecruitSecurityHidden.value = true
}
},
},
},
twoType: {
required: true,
type: 'radioGroup',
label: '二级类型',
options: netType,
componentsProps: {
onChange: (e) => {
if (e.target.value !== 'outsource') {
idNumberDisabled.value = true
formParams.value.outsourceName = ''
} else {
idNumberDisabled.value = false
}
},
},
},
outsourceName: {
type: 'input',
label: '外包公司名称',
hidden: idNumberDisabled as any,
},
isFiling: {
required: true,
type: 'radioGroup',
label: '是否备案',
options: dictSelectNodes('IsOrNot'),
},
idNumber: {
type: 'input',
label: '保安服务许可证',
},
serviceArea: {
type: 'inputNumber',
label: '服务区域面积',
},
buildingTotal: {
type: 'inputNumber',
label: '楼栋数量',
componentsProps: {
formatter: (value: any) => {
return Math.round(value) ? Math.round(value) : ('' as any)
},
min: 0,
},
},
houseTotal: {
type: 'inputNumber',
label: '户数',
componentsProps: {
formatter: (value: any) => {
return Math.round(value) ? Math.round(value) : ('' as any)
},
min: 0,
},
},
staffTotal: {
type: 'inputNumber',
label: '工作人员数量',
componentsProps: {
formatter: (value: any) => {
return Math.round(value) ? Math.round(value) : ('' as any)
},
min: 0,
},
},
securityUserTotal: {
type: 'inputNumber',
label: '保安人员数量',
componentsProps: {
formatter: (value: any) => {
return Math.round(value) ? Math.round(value) : ('' as any)
},
min: 0,
},
},
remark: {
type: 'inputTextArea',
label: '备注',
},
})
const _tableRef = ref<ComponentExposed<typeof TableProMax>>(null)
const expandedRowRender: TableProMaxProps['expandedRowRender'] = ({ record }) => {
console.log('🚀 ~ record:', record)
const _columns: _TableProps['columns'] = [
{
dataIndex: 'name',
title: '服务项目名称',
},
{
dataIndex: 'type',
title: '服务类型',
customRender: ({ text }) => <a-tag>{text?.label}</a-tag>,
},
{
dataIndex: 'twoType',
title: '二级类型',
customRender: ({ text }) => <a-tag>{text?.label}</a-tag>,
},
{
dataIndex: 'outsourceName',
title: '外包公司名称',
customRender: ({ record }) => {
if (record.twoType.value === 'outsource') {
return record.outsourceName
}
},
},
{
dataIndex: 'isFiling',
title: '是否备案',
customRender: ({ text }) => <a-tag>{text?.label}</a-tag>,
},
{
dataIndex: 'idNumber',
title: '保安服务许可证',
},
{
dataIndex: 'serviceArea',
title: '服务区域面积',
},
{
dataIndex: 'buildingTotal',
title: '楼栋数量',
},
{
dataIndex: 'houseTotal',
title: '户数',
},
{
dataIndex: 'staffTotal',
title: '工作人员数量',
},
{
dataIndex: 'securityUserTotal',
title: '保安人员数量',
},
{
dataIndex: 'remark',
title: '备注',
},
{
dataIndex: 'createUserInfo',
title: '创建人',
customRender: ({ record }) => {
return (
<div>
<p>创建人{record.createUserInfo.name} </p>
<p>创建人单位{record.createUserInfo.unitName} </p>
</div>
)
},
},
{
dataIndex: 'createTime',
title: '创建时间',
},
{
dataIndex: 'opt',
title: '操作',
fixed: 'right',
customRender({ record }) {
return (
<a-space>
<a-button
type='primary'
onClick={async () => {
console.log('🚀 ~ customRender ~ record:编辑回显参数', record)
visible.value = true
serviceTitle.value = '编辑服务项目'
idNumberDisabled.value = record.twoType.value !== 'outsource'
{
/* */
}
formParams.value.securityUnitId = record.securityUnitId //id
formParams.value.enterprisesUnitId = record.enterprisesUnitId //id
formParams.value.snowFlakeId = record.snowFlakeId //id
formParams.value.projectManagerMiniProgramUserId = record.projectManagerMiniProgramUserId //id
formParams.value.name = record.name
formParams.value.type = record.type.value //
formParams.value.twoType = record.twoType.value //
formParams.value.outsourceName = record.outsourceName //
formParams.value.isFiling = record.isFiling.value //
formParams.value.remark = record.remark //
formParams.value.idNumber = record.idNumber //(/
formParams.value.serviceArea = record.serviceArea //
formParams.value.buildingTotal = record.buildingTotal //
formParams.value.houseTotal = record.houseTotal //
formParams.value.staffTotal = record.staffTotal //
formParams.value.securityUserTotal = record.securityUserTotal //
{
/* formParams.value.administrativeDivisionCodes = record.enterprisesUnitAdministrativeDivisionCodes */
}
}}
>
编辑
</a-button>
<a-popconfirm
title='确认删除账号吗?'
onConfirm={async () => {
const resp = await api.delete('/m2/eu/deleteSpById', {
serviceProjectId: record.snowFlakeId,
})
message.success(resp.message)
await _tableRef.value?.requestGetTableData()
}}
>
<a-button danger>删除</a-button>
</a-popconfirm>
</a-space>
)
},
},
]
const _reqApi: _TableProps['requestApi'] = async (params) => {
console.log('🚀 ~ params:', params)
// @ts-ignore
return await api.get('/m2/eu/listSp', { enterprisesUnitId: record?.snowFlakeId })
}
return (
<TableProMax
ref={_tableRef}
size='small'
columns={_columns}
requestApi={_reqApi}
isPagination={false}
v-slots={{
tableHeader: (_) => {
return (
<Space>
<Button class='btn-success' onClick={() => addService(record)}>
新增服务项目
</Button>
</Space>
)
},
}}
/>
)
}
const closeModal = async () => {
visible.value = false
formParams.value = {
securityUnitId: '',
enterprisesUnitId: '',
administrativeDivisionCodes: '',
name: '',
type: 'security',
idNumber: '',
serviceArea: null,
buildingTotal: null,
houseTotal: null,
staffTotal: null,
securityUserTotal: null,
remark: '',
}
formRef.value.resetFields()
enterprisesUnitId.value = ''
serviceTitle.value = '新增服务项目'
idNumberDisabled.value = false
}
const submit = async () => {
console.log('formParams.value____________________', formParams.value)
await formRef.value.validate()
const serviceProjectSaveOrUpdateParams = { ...formParams.value }
const resp = await api.post('/m2/eu/add_upd_sp', serviceProjectSaveOrUpdateParams)
message.success(resp.message)
await _tableRef.value.requestGetTableData()
await closeModal()
}
onMounted(async () => {
const res = await api.get('/management/listSecurityUnit')
securityUnitIdList.value = res.data
})
const addService = function (record) {
console.log('🚀 ~ addService ~ record:', record)
formParams.value.enterprisesUnitId = record.snowFlakeId //Id
visible.value = true
}
</script> </script>