|
|
@@ -1,11 +1,341 @@
|
|
|
-<script setup lang="ts">
|
|
|
+<template>
|
|
|
+ <!-- 搜索筛选区域 -->
|
|
|
+ <ContentWrap>
|
|
|
+ <el-form :model="queryParams" ref="queryFormRef" :inline="true" class="-mb-15px">
|
|
|
+ <el-form-item label="姓名:" prop="name">
|
|
|
+ <el-input
|
|
|
+ v-model="queryParams.name"
|
|
|
+ placeholder="请输入"
|
|
|
+ clearable
|
|
|
+ @keyup.enter="handleQuery"
|
|
|
+ class="!w-180px"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="手机号码:" prop="phone">
|
|
|
+ <el-input
|
|
|
+ v-model="queryParams.phone"
|
|
|
+ placeholder="请输入"
|
|
|
+ clearable
|
|
|
+ @keyup.enter="handleQuery"
|
|
|
+ class="!w-180px"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="服务区域:" prop="serviceArea">
|
|
|
+ <el-select
|
|
|
+ v-model="queryParams.serviceArea"
|
|
|
+ placeholder="全部"
|
|
|
+ clearable
|
|
|
+ class="!w-180px"
|
|
|
+ >
|
|
|
+ <el-option label="全部" value="" />
|
|
|
+ <el-option
|
|
|
+ v-for="item in serviceAreaOptions"
|
|
|
+ :key="item"
|
|
|
+ :label="item"
|
|
|
+ :value="item"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="在职状态:" prop="status">
|
|
|
+ <el-select
|
|
|
+ v-model="queryParams.status"
|
|
|
+ placeholder="全部"
|
|
|
+ clearable
|
|
|
+ class="!w-180px"
|
|
|
+ >
|
|
|
+ <el-option label="全部" value="" />
|
|
|
+ <el-option label="在职" value="在职" />
|
|
|
+ <el-option label="离职" value="离职" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" @click="handleQuery">
|
|
|
+ <Icon icon="ep:search" class="mr-5px" /> 查询
|
|
|
+ </el-button>
|
|
|
+ <el-button @click="resetQuery">
|
|
|
+ <Icon icon="ep:refresh" class="mr-5px" /> 重置
|
|
|
+ </el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </ContentWrap>
|
|
|
|
|
|
-</script>
|
|
|
+ <!-- 列表 -->
|
|
|
+ <ContentWrap>
|
|
|
+ <div class="flex justify-between items-center mb-4">
|
|
|
+ <div class="text-base font-medium">服务人员列表</div>
|
|
|
+ <div>
|
|
|
+ <el-button type="primary" @click="openForm('create')">
|
|
|
+ <Icon icon="ep:plus" class="mr-5px" /> 新增
|
|
|
+ </el-button>
|
|
|
+ <el-button type="danger" @click="handleBatchDelete" :disabled="!selectedIds.length">
|
|
|
+ <Icon icon="ep:delete" class="mr-5px" /> 删除
|
|
|
+ </el-button>
|
|
|
+ <el-button type="primary" plain @click="handleExport">
|
|
|
+ <Icon icon="ep:download" class="mr-5px" /> 导出
|
|
|
+ </el-button>
|
|
|
+ <el-button type="primary" plain @click="handleImport">
|
|
|
+ <Icon icon="ep:upload" class="mr-5px" /> 导入服务人员
|
|
|
+ </el-button>
|
|
|
+ <el-button type="primary" plain @click="handleDownloadTemplate">
|
|
|
+ <Icon icon="ep:document" class="mr-5px" /> 下载导入模板
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <el-table
|
|
|
+ v-loading="loading"
|
|
|
+ :data="list"
|
|
|
+ @selection-change="handleSelectionChange"
|
|
|
+ >
|
|
|
+ <el-table-column type="selection" width="55" />
|
|
|
+ <el-table-column type="index" label="序号" width="80" />
|
|
|
+ <el-table-column prop="name" label="姓名" />
|
|
|
+ <el-table-column prop="idCard" label="身份证号" />
|
|
|
+ <el-table-column prop="gender" label="性别" width="80" />
|
|
|
+ <el-table-column prop="age" label="年龄" width="80" />
|
|
|
+ <el-table-column prop="phone" label="手机号码" />
|
|
|
+ <el-table-column prop="elderCount" label="关联长者" width="100" />
|
|
|
+ <el-table-column prop="serviceArea" label="服务区域" show-overflow-tooltip/>
|
|
|
+ <el-table-column prop="organization" label="所属组织" show-overflow-tooltip/>
|
|
|
+ <el-table-column label="操作" align="center" width="350">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-button link type="primary" @click="handleDetail(scope.row)">
|
|
|
+ <Icon icon="ep:view" class="mr-5px" /> 详情
|
|
|
+ </el-button>
|
|
|
+ <el-button link type="primary" @click="openForm('update', scope.row.id)">
|
|
|
+ <Icon icon="ep:edit" class="mr-5px" /> 编辑
|
|
|
+ </el-button>
|
|
|
+ <el-button link type="primary" @click="handleRelateElder(scope.row)">
|
|
|
+ <Icon icon="ep:connection" class="mr-5px" /> 关联长者设置
|
|
|
+ </el-button>
|
|
|
+ <el-button link type="danger" @click="handleResign(scope.row)">
|
|
|
+ <Icon icon="ep:close" class="mr-5px" /> 离职
|
|
|
+ </el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </ContentWrap>
|
|
|
|
|
|
-<template>
|
|
|
-a
|
|
|
+ <!-- 表单弹窗:添加/修改 -->
|
|
|
+ <ServicePersonForm ref="formRef" @success="getList" />
|
|
|
+
|
|
|
+ <!-- 关联长者设置弹窗 -->
|
|
|
+ <RelateElderDialog ref="relateElderRef" />
|
|
|
</template>
|
|
|
+<script lang="ts" setup>
|
|
|
+import * as ServicePersonApi from '@/api/living-home/elderly'
|
|
|
+import ServicePersonForm from './ServicePersonForm.vue'
|
|
|
+import RelateElderDialog from './RelateElderDialog.vue'
|
|
|
+
|
|
|
+defineOptions({ name: 'ServicePersonnelManage' })
|
|
|
+
|
|
|
+const message = useMessage() // 消息弹窗
|
|
|
+const { t } = useI18n() // 国际化
|
|
|
+
|
|
|
+const loading = ref(true) // 列表的加载中
|
|
|
+const list = ref<ServicePersonApi.ServicePersonVO[]>([]) // 列表的数据
|
|
|
+const selectedIds = ref<number[]>([]) // 选中的ID列表
|
|
|
+const queryFormRef = ref() // 搜索表单Ref
|
|
|
+
|
|
|
+// 查询参数
|
|
|
+const queryParams = reactive({
|
|
|
+ name: '',
|
|
|
+ phone: '',
|
|
|
+ serviceArea: '',
|
|
|
+ status: ''
|
|
|
+})
|
|
|
+
|
|
|
+// 服务区域选项(从默认数据中提取)
|
|
|
+const serviceAreaOptions = computed(() => {
|
|
|
+ const areas = new Set(defaultData.map(item => item.serviceArea))
|
|
|
+ return Array.from(areas)
|
|
|
+})
|
|
|
+
|
|
|
+// 默认数据
|
|
|
+const defaultData: ServicePersonApi.ServicePersonVO[] = [
|
|
|
+ {
|
|
|
+ id: 1,
|
|
|
+ name: '张磊',
|
|
|
+ idCard: '43********30',
|
|
|
+ gender: '男',
|
|
|
+ age: '36',
|
|
|
+ phone: '198****9999',
|
|
|
+ personType: '服务人员',
|
|
|
+ elderCount: 0,
|
|
|
+ serviceArea: '东莞市/茶山镇',
|
|
|
+ organization: '客服部',
|
|
|
+ status: '在职'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 2,
|
|
|
+ name: '李华',
|
|
|
+ idCard: '44********21',
|
|
|
+ gender: '女',
|
|
|
+ age: '32',
|
|
|
+ phone: '139****8888',
|
|
|
+ personType: '服务人员',
|
|
|
+ elderCount: 3,
|
|
|
+ serviceArea: '深圳市/南山区',
|
|
|
+ organization: '护理部',
|
|
|
+ status: '在职'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 3,
|
|
|
+ name: '王强',
|
|
|
+ idCard: '11********55',
|
|
|
+ gender: '男',
|
|
|
+ age: '45',
|
|
|
+ phone: '136****6666',
|
|
|
+ personType: '应急人员',
|
|
|
+ elderCount: 5,
|
|
|
+ serviceArea: '广州市/天河区',
|
|
|
+ organization: '应急部',
|
|
|
+ status: '在职'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 4,
|
|
|
+ name: '赵敏',
|
|
|
+ idCard: '31********88',
|
|
|
+ gender: '女',
|
|
|
+ age: '28',
|
|
|
+ phone: '158****7777',
|
|
|
+ personType: '志愿者',
|
|
|
+ elderCount: 2,
|
|
|
+ serviceArea: '佛山市/禅城区',
|
|
|
+ organization: '志愿者协会',
|
|
|
+ status: '在职'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 5,
|
|
|
+ name: '刘洋',
|
|
|
+ idCard: '22********99',
|
|
|
+ gender: '男',
|
|
|
+ age: '38',
|
|
|
+ phone: '137****5555',
|
|
|
+ personType: '服务人员',
|
|
|
+ elderCount: 1,
|
|
|
+ serviceArea: '中山市/石岐区',
|
|
|
+ organization: '服务部',
|
|
|
+ status: '在职'
|
|
|
+ }
|
|
|
+]
|
|
|
+
|
|
|
+/** 查询服务人员列表 */
|
|
|
+const getList = async () => {
|
|
|
+ loading.value = true
|
|
|
+ try {
|
|
|
+ // 先尝试从接口获取数据
|
|
|
+ const data = await ServicePersonApi.getServicePersonList(queryParams)
|
|
|
+ // 如果接口返回数据为空,则使用默认数据
|
|
|
+ let result = data && data.length > 0 ? data : defaultData
|
|
|
+
|
|
|
+ // 前端筛选(如果使用默认数据)
|
|
|
+ if (result === defaultData) {
|
|
|
+ result = result.filter(item => {
|
|
|
+ const matchName = !queryParams.name || item.name.includes(queryParams.name)
|
|
|
+ const matchPhone = !queryParams.phone || item.phone.includes(queryParams.phone)
|
|
|
+ const matchArea = !queryParams.serviceArea || item.serviceArea === queryParams.serviceArea
|
|
|
+ const matchStatus = !queryParams.status || item.status === queryParams.status
|
|
|
+ return matchName && matchPhone && matchArea && matchStatus
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ list.value = result
|
|
|
+ } catch (error) {
|
|
|
+ // 接口调用失败时,使用默认数据并筛选
|
|
|
+ console.log('使用默认数据')
|
|
|
+ list.value = defaultData.filter(item => {
|
|
|
+ const matchName = !queryParams.name || item.name.includes(queryParams.name)
|
|
|
+ const matchPhone = !queryParams.phone || item.phone.includes(queryParams.phone)
|
|
|
+ const matchArea = !queryParams.serviceArea || item.serviceArea === queryParams.serviceArea
|
|
|
+ const matchStatus = !queryParams.status || item.status === queryParams.status
|
|
|
+ return matchName && matchPhone && matchArea && matchStatus
|
|
|
+ })
|
|
|
+ } finally {
|
|
|
+ loading.value = false
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
-<style scoped lang="scss">
|
|
|
+/** 搜索按钮操作 */
|
|
|
+const handleQuery = () => {
|
|
|
+ getList()
|
|
|
+}
|
|
|
|
|
|
-</style>
|
|
|
+/** 重置按钮操作 */
|
|
|
+const resetQuery = () => {
|
|
|
+ queryFormRef.value?.resetFields()
|
|
|
+ queryParams.name = ''
|
|
|
+ queryParams.phone = ''
|
|
|
+ queryParams.serviceArea = ''
|
|
|
+ queryParams.status = ''
|
|
|
+ getList()
|
|
|
+}
|
|
|
+
|
|
|
+/** 多选框选中数据 */
|
|
|
+const handleSelectionChange = (selection: ServicePersonApi.ServicePersonVO[]) => {
|
|
|
+ selectedIds.value = selection.map((item) => item.id)
|
|
|
+}
|
|
|
+
|
|
|
+/** 添加/修改操作 */
|
|
|
+const formRef = ref()
|
|
|
+const openForm = (type: string, id?: number) => {
|
|
|
+ formRef.value.open(type, id)
|
|
|
+}
|
|
|
+
|
|
|
+/** 批量删除按钮操作 */
|
|
|
+const handleBatchDelete = async () => {
|
|
|
+ if (selectedIds.value.length === 0) {
|
|
|
+ message.warning('请选择要删除的数据')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ await message.delConfirm()
|
|
|
+ await ServicePersonApi.deleteServicePerson(selectedIds.value)
|
|
|
+ message.success(t('common.delSuccess'))
|
|
|
+ await getList()
|
|
|
+ } catch {}
|
|
|
+}
|
|
|
+
|
|
|
+/** 导出 */
|
|
|
+const handleExport = () => {
|
|
|
+ // TODO: 实现导出功能
|
|
|
+ message.info('导出功能开发中')
|
|
|
+}
|
|
|
+
|
|
|
+/** 导入 */
|
|
|
+const handleImport = () => {
|
|
|
+ // TODO: 实现导入功能
|
|
|
+ message.info('导入功能开发中')
|
|
|
+}
|
|
|
+
|
|
|
+/** 下载导入模板 */
|
|
|
+const handleDownloadTemplate = () => {
|
|
|
+ // TODO: 实现下载模板功能
|
|
|
+ message.info('下载模板功能开发中')
|
|
|
+}
|
|
|
+
|
|
|
+/** 详情 */
|
|
|
+const handleDetail = (row: ServicePersonApi.ServicePersonVO) => {
|
|
|
+ openForm('detail', row.id)
|
|
|
+}
|
|
|
+
|
|
|
+/** 关联长者设置 */
|
|
|
+const relateElderRef = ref()
|
|
|
+const handleRelateElder = (row: ServicePersonApi.ServicePersonVO) => {
|
|
|
+ relateElderRef.value.open(row.id)
|
|
|
+}
|
|
|
+
|
|
|
+/** 离职 */
|
|
|
+const handleResign = async (row: ServicePersonApi.ServicePersonVO) => {
|
|
|
+ try {
|
|
|
+ await message.confirm('确认将该服务人员设为离职状态?')
|
|
|
+ await ServicePersonApi.resignServicePerson(row.id)
|
|
|
+ message.success('操作成功')
|
|
|
+ await getList()
|
|
|
+ } catch {}
|
|
|
+}
|
|
|
+
|
|
|
+/** 初始化 **/
|
|
|
+onMounted(async () => {
|
|
|
+ await getList()
|
|
|
+})
|
|
|
+</script>
|