This commit is contained in:
Leo_Ding 2025-11-06 14:25:38 +08:00
commit 5db5db8778
2 changed files with 128 additions and 107 deletions

View File

@ -1,135 +1,134 @@
<template>
<a-modal :open="modal.open" :title="modal.title" :width="600" :confirm-loading="modal.confirmLoading"
:after-close="onAfterClose" :cancel-text="cancelText" @ok="handleOk" @cancel="handleCancel">
<a-form ref="formRef" :model="formData" :rules="formRules">
<a-row :gutter="24">
<!-- 姓名 -->
<a-col :span="24">
<a-form-item label="分配到" name="name" :rules="[{ required: true, message: '请选择节点' }]">
<a-tree-select v-model:value="formData.name" style="width: 100%" :tree-data="treeData" tree-checkable
allow-clear :show-checked-strategy="SHOW_PARENT" placeholder="请选择站点"
tree-node-filter-prop="label" />
</a-form-item>
</a-col>
</a-row>
</a-form>
</a-modal>
<a-modal
:open="modal.open"
:title="modal.title"
:width="600"
:confirm-loading="modal.confirmLoading"
:after-close="onAfterClose"
:cancel-text="cancelText"
@ok="handleOk"
@cancel="handleCancel"
>
<a-form ref="formRef" :model="formData" :rules="formRules">
<a-row :gutter="24">
<!-- 分配到 -->
<a-col :span="24">
<a-form-item
label="分配到"
name="name"
:rules="[{ required: true, message: '请选择节点' }]"
>
<a-select
v-model:value="formData.name"
style="width: 100%"
:options="options"
placeholder="请选择站点"
allow-clear
/>
</a-form-item>
</a-col>
</a-row>
</a-form>
</a-modal>
</template>
<script setup>
import { cloneDeep } from 'lodash-es'
import { ref, defineProps } from 'vue'
import { ref } from 'vue'
import { config } from '@/config'
import apis from '@/apis'
import { useForm, useModal } from '@/hooks'
import { useDicsStore } from '@/store'
import AreaCascader from '@/components/AreaCascader/index.vue'
const emit = defineEmits(['ok'])
const activeKey = ref('1')
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
const { formRecord, formData, formRef, formRules, resetForm } = useForm()
const cancelText = ref('取消')
const treeData = [
{
label: 'Node1',
value: '0-0',
children: [
{
label: 'Child Node1',
value: '0-0-0',
},
],
},
{
label: 'Node2',
value: '0-1',
import { useForm, useModal,usePagination } from '@/hooks'
children: [
{
label: 'Child Node3',
value: '0-1-0',
disabled: true,
},
{
label: 'Child Node4',
value: '0-1-1',
},
{
label: 'Child Node5',
value: '0-1-2',
},
],
},
];
const emit = defineEmits(['ok'])
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
const { listData, loading, paginationState, resetPagination, searchFormData } = usePagination()
const { formData, formRef, resetForm } = useForm()
const cancelText = ref('取消')
// value + label
const options = ref([]);
const currentRecord = ref(null)
/**
* 新建
* 新建暴露给父组件调用
*/
function handleCreate() {
showModal({
type: 'create',
title: '分配节点',
})
function handleCreate(record) {
currentRecord.value = record // 👈
showModal({
type: 'create',
title: '分配节点',
})
getData() //
}
getData()
async function getData() {
try {
const { data, success } = await apis.serviceMenu.getServiceSiteList({
pageSize: 999,
current: 1
})
if (success) {
options.value = data.map(item => ({ value: item.id, label: item.name }))
}
} catch (error) {
console.error('获取服务站点列表失败:', error)
}
}
/**
* 确定
*/
function handleOk() {
formRef.value
.validateFields()
.then(async (values) => {
try {
showLoading()
const params = {
...formData.value,
}
let result = null
switch (modal.value.type) {
case 'create':
result = await apis.serverObj.createItem(params).catch(() => {
throw new Error()
})
break
case 'edit':
result = await apis.serverObj.updateItem(params).catch(() => {
throw new Error()
})
break
}
hideLoading()
if (config('http.code.success') === result?.code) {
hideModal()
emit('ok')
}
} catch (error) {
hideLoading()
}
})
.catch(() => {
hideLoading()
})
async function handleOk() {
console.log("formData",modal.value.type)
try {
await formRef.value.validateFields()
showLoading()
const params = { ...formData.value }
let result
if (modal.value.type === 'create') {
console.log("====",params)
result = await apis.serverObj.changeItem(currentRecord.value?.id,{stationId:formData.value.name})
if (result.success) {
emit('ok')
hideModal()
}
} else if (modal.value.type === 'edit') {
console.log("====",params)
result = await apis.serverObj.updateItem(params)
}
hideLoading()
if (config('http.code.success') === result?.code) {
hideModal()
emit('ok')
}
} catch (error) {
hideLoading()
}
}
/**
* 取消
*/
function handleCancel() {
hideModal()
hideModal()
}
/**
* 关闭后
* 关闭后重置表单
*/
function onAfterClose() {
resetForm()
hideLoading()
resetForm()
}
//
defineExpose({
handleCreate,
handleCreate,
})
</script>

View File

@ -51,7 +51,7 @@
</x-search-bar>
<a-row :gutter="8" :wrap="false">
<a-col flex="auto">
<a-card title="待分配对象列表">
<a-card title="生存状态列表">
<template #extra>
<a-space>
<a-button type="primary">导入</a-button>
@ -67,6 +67,18 @@
<span>{{ index + 1 }}</span>
</template>
<template v-if="column.key === 'livingStatus'">
<span>{{ record.livingStatus.passWayAt == null ? '在世' : '已去世' }}</span>
</template>
<template v-if="column.key === 'diedTime'">
<span>{{ record.livingStatus.passWayAt == null ? '--' : dayjs(record.livingStatus.passWayAt).format('YYYY-MM-DD') }}</span>
</template>
<template v-if="column.key === 'diedReason'">
<span>{{ record.livingStatus.passWayReason != '' ? record.livingStatus.passWayReason : '--' }}</span>
</template>
</template>
</a-table>
</a-card>
@ -123,11 +135,18 @@ const columns = [
},
{
title: '身份证号',
dataIndex: 'idNumber',
key: 'idNumber',
dataIndex: 'identityNo',
key: 'identityNo',
align: 'center',
width: 180,
},
{
title: '是否在世',
dataIndex: 'livingStatus',
key: 'livingStatus',
align: 'center',
width: 150,
},
{
title: '去世时间',
@ -149,6 +168,9 @@ const columns = [
key: 'updateTime',
align: 'center',
width: 120,
customRender: ({ text, record }) => {
return text ? dayjs(text).format('YYYY-MM-DD') : '-';
},
},
// --- ---