policeSecurity/superManagement/src/views/unitManage/policeUnit/index.vue

122 lines
3.5 KiB
Vue
Raw Normal View History

2024-08-30 17:03:25 +08:00
<template>
<TableProMax
ref="tableRef"
:request-api="reqApi"
:columns="columns"
:searchFormOptions="searchFormOptions"
>
</TableProMax>
</template>
2024-09-02 11:48:12 +08:00
<script setup lang="tsx">
2024-08-30 17:03:25 +08:00
import TableProMax from "@/components/table/TableProMax.vue";
import {ref} from "vue";
import {ComponentExposed} from "vue-component-type-helpers";
import {TableProMaxProps} from "@/types/components/table";
import {PoliceUnitPagerQueryParams, PoliceUnitPagerVo} from "@/types/views/unitManage/policeUnit.ts";
import api from "@/axios";
2024-09-03 10:51:15 +08:00
import {dictSelectNodes} from "@/config/dict.ts";
2024-09-02 11:48:12 +08:00
import {message} from "ant-design-vue";
2024-09-03 10:51:15 +08:00
import {UNIT_TYPE} from "@/config";
2024-08-30 17:03:25 +08:00
type TableProps = TableProMaxProps<PoliceUnitPagerVo, PoliceUnitPagerQueryParams>
const tableRef = ref<ComponentExposed<typeof TableProMax>>(null!)
const reqApi: TableProps['requestApi'] = (params) => api.post('/policeUnit/pager', params)
const columns: TableProps['columns'] = [
{
dataIndex: 'name',
title: '名称'
}, {
dataIndex: 'code',
title: '代码'
}, {
2024-09-02 11:48:12 +08:00
dataIndex: 'contactPersonInfo',
title: '联系人',
customRender({record}) {
return record.contactPersonInfo?.name + "/" + record.contactPersonInfo?.telephone
},
2024-08-30 17:03:25 +08:00
}, {
dataIndex: 'provinceName',
title: '行政区划',
customRender: ({record}) => [record.provinceName, record.cityName, record.districtsName, record.streetName].filter(Boolean).join('/')
}, {
dataIndex: 'isEnable',
2024-09-02 11:48:12 +08:00
title: '是否启用',
customRender: ({text}) => <a-tag color={text?.extData?.color}>{text?.label}</a-tag>,
2024-08-30 17:03:25 +08:00
}, {
dataIndex: 'checkStatus',
2024-09-02 11:48:12 +08:00
title: '审核状态',
customRender: ({text}) => <a-tag color={text?.extData?.color}>{text?.label}</a-tag>,
2024-08-30 17:03:25 +08:00
}, {
dataIndex: 'createTime',
title: '创建时间'
2024-09-02 11:48:12 +08:00
}, {
dataIndex: 'opt',
title: '操作',
customRender({record}) {
return <a-space>
{record.checkStatus.value === 1 && <a-popconfirm
title="确认审核通过嘛?"
onConfirm={async () => {
const resp = await api.post('/management/checkPass', {
checkDataId: record.snowFlakeId,
2024-09-03 10:51:15 +08:00
unitOptType: UNIT_TYPE.police
2024-09-02 11:48:12 +08:00
})
message.success(resp.message)
await tableRef.value?.requestGetTableData()
}}>
<a-button type="primary">审核通过
</a-button>
</a-popconfirm>
}
2024-09-03 10:51:15 +08:00
<a-button
class={record.isEnable.value === 0 ? 'btn-danger' : 'btn-success'}
onClick={async () => {
const resp = await api.post('/management/disableOrEnable', {
unitId: record.snowFlakeId,
unitOptType: UNIT_TYPE.police
})
message.success(resp.message)
await tableRef.value?.requestGetTableData()
}}
>{record.isEnable.value === 0 ? '禁用' : '启用'}</a-button>
2024-09-02 11:48:12 +08:00
</a-space>
},
2024-08-30 17:03:25 +08:00
}
]
const searchFormOptions: TableProps["searchFormOptions"] = {
name: {
type: 'input',
label: '名称'
}, code: {
type: 'input',
label: '代码'
}, isEnable: {
type: 'select',
label: '是否启用',
options: [
{
value: null,
label: '全部'
2024-09-03 10:51:15 +08:00
}, ...dictSelectNodes('IsEnable')
2024-08-30 17:03:25 +08:00
]
}, checkStatus: {
type: 'select',
label: '审核状态',
options: [
{
value: null,
label: '全部'
2024-09-03 10:51:15 +08:00
}, ...dictSelectNodes('CheckStatus')
2024-08-30 17:03:25 +08:00
]
}
}
</script>
<style scoped lang="scss">
</style>