yxh
2026-10-18 01ee694a3bb8048372fc793a8de314d70b688b35
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
<template>
  <ContentWrap>
    <!-- 搜索工作栏 -->
    <el-form class="-mb-15px" :model="queryParams" ref="queryFormRef" :inline="true" label-width="80px">
      <el-form-item label="项目名称" prop="name">
        <el-input v-model="queryParams.name" placeholder="请输入检查项目名称" clearable @keyup.enter="handleQuery"
          class="!w-240px" />
      </el-form-item>
      <el-form-item>
        <el-button @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-button type="primary" plain @click="openForm('create')" v-hasPermi="['ecg:check-type:create']">
          <Icon icon="ep:plus" class="mr-5px" /> 新增
        </el-button>
        <el-button type="success" plain @click="handleExport" :loading="exportLoading"
          v-hasPermi="['ecg:check-type:export']">
          <Icon icon="ep:download" class="mr-5px" /> 导出
        </el-button>
      </el-form-item>
    </el-form>
  </ContentWrap>
 
  <!-- 列表 -->
  <ContentWrap>
    <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
      <!-- 需求9:不再显示数据库 id;改为显示**可编辑**的「排序序号」(越小越靠前) -->
      <el-table-column label="序号" align="center" prop="sort" width="130px">
        <template #default="scope">
          <el-input-number v-model="scope.row.sort" :min="0" :controls="false" size="small" style="width: 100%"
            @change="handleSortChange(scope.row)" />
        </template>
      </el-table-column>
      <el-table-column label="项目名称" align="center" prop="name" width="180px" />
      <el-table-column label="项目编码" align="center" prop="value" />
      <el-table-column label="亲和项目" align="center" prop="affinityCheckTypes">
        <template #default="scope">
          <div v-for="(checkType, subIndex) in scope.row.affinityCheckTypes" :key="subIndex">
            {{ getCheckTypeName(checkType) }}
          </div>
        </template>
      </el-table-column>
      <!--      <el-table-column label="创建时间" align="center" prop="createTime" :formatter="dateFormatter" width="180px />-->
      <el-table-column label="设备领用" align="center" prop="needDevReady">
        <template #default="scope">
          {{ scope.row.needDevReady === 0 ? "不需要" : "需要" }}
        </template>
      </el-table-column>
      <!-- 需求:库里存的是 0/1,直接渲染会显示数字,这里按中文展示(与上一列「设备领用」写法一致) -->
      <el-table-column label="需要确费" align="center" prop="expenseRecognition">
        <template #default="scope">
          {{ scope.row.expenseRecognition === 1 ? "需要" : "不需要" }}
        </template>
      </el-table-column>
      <el-table-column label="时段预约人数" align="center" prop="timeslotBookNum" />
      <el-table-column label="时段预留人数" align="center" prop="timeslotReservedNum" />
      <!-- 排队规则(check_type.seq_rule):库里是 0/1/2,按字典 ecg_seq_rule 显示中文;
           未配置(null) 时后端按「时段号」处理,这里显式提示,避免出现空白单元格 -->
      <el-table-column label="排队规则" align="center" prop="seqRule">
        <template #default="scope">
          <span v-if="scope.row.seqRule === null || scope.row.seqRule === undefined">时段号(默认)</span>
          <dict-tag v-else :type="DICT_TYPE.ECG_SEQ_RULE" :value="scope.row.seqRule" />
        </template>
      </el-table-column>
      <el-table-column label="序号前缀" align="center" prop="seqPrefix" />
      <el-table-column label="候诊人数" align="center" prop="readyNum" />
      <el-table-column label="大屏显示列" align="center" prop="callingColumn" />
      <!-- <el-table-column label="患者条码" align="center" prop="displayBarcode" /> -->
      <el-table-column label="注意事项" align="center" prop="notes" />
      <el-table-column label="操作" align="center" min-width="200px" fixed="right">
        <template #default="scope">
          <el-button link type="primary" @click="openForm('update', scope.row.id)"
            v-hasPermi="['ecg:check-type:update']">
            编辑
          </el-button>
          <el-button link type="primary" @click="openQueueSequenceForm(scope.row)"
            v-hasPermi="['ecg:check-type:update']">
            预约时段
          </el-button>
          <el-button link type="danger" @click="handleDelete(scope.row.id)" v-hasPermi="['ecg:check-type:delete']">
            删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <Pagination :total="total" v-model:page="queryParams.pageNo" v-model:limit="queryParams.pageSize"
      @pagination="getList" />
  </ContentWrap>
 
  <!-- 表单弹窗:添加/修改 -->
  <CheckTypeForm ref="formRef" @success="getList" />
 
  <!-- 预约时段维护弹窗:维护该检查项目各时段的取号规则(增/删/改) -->
  <QueueSequenceForm ref="queueSequenceFormRef" />
</template>
 
<script setup lang="ts">
import { dateFormatter, dateFormatter2 } from '@/utils/formatTime'
import download from '@/utils/download'
import { CheckTypeApi, CheckTypeVO } from '@/api/ecg/checktype'
import { DICT_TYPE } from '@/utils/dict'
import CheckTypeForm from './CheckTypeForm.vue'
import QueueSequenceForm from './QueueSequenceForm.vue'
import { useCheckTypeStore } from "@/store/modules/checkType";
import { getCheckTypeName } from "../../../utils/checkTypeFormatter";
 
/** 检查项目 列表 */
defineOptions({ name: 'CheckType' })
 
const message = useMessage() // 消息弹窗
const { t } = useI18n() // 国际化
const checkTypeStore = useCheckTypeStore();
const loading = ref(true) // 列表的加载中
const list = ref<CheckTypeVO[]>([]) // 列表的数据
const total = ref(0) // 列表的总页数
const queryParams = reactive({
  pageNo: 1,
  pageSize: 10,
  name: undefined,
  value: undefined,
  readyNum: undefined,
  createTime: [],
  needDevReady: undefined,
  callingColumn: undefined,
  displayBarcode: undefined,
  expenseRecognition: undefined,
  timeslotBookNum: undefined,
  timeslotReservedNum: undefined,
  affinityCheckTypes: undefined
})
const queryFormRef = ref() // 搜索的表单
const exportLoading = ref(false) // 导出的加载中
 
/** 预约时段维护弹窗 */
const queueSequenceFormRef = ref()
/** 打开「预约时段」维护弹窗(传入整行,便于显示检查项目名称) */
const openQueueSequenceForm = (row: CheckTypeVO) => {
  queueSequenceFormRef.value.open(row)
}
 
/**
 * 需求9:列表内直接修改「排序序号」后保存。
 *
 * 仅提交 id 与 sort 两个字段 —— 后端 update 为「按非空字段更新」,
 * 其余字段传 null 不会被覆盖,避免把整行数据回写造成意外。
 */
const handleSortChange = async (row: CheckTypeVO) => {
  try {
    await CheckTypeApi.updateCheckType({ id: row.id, sort: row.sort } as CheckTypeVO)
    message.success('排序已更新')
    await getList()   // 重新拉取,使列表顺序按新的 sort 排好
  } catch {
    await getList()   // 失败时回滚显示
  }
}
 
/** 查询列表 */
const getList = async () => {
  loading.value = true
  try {
    const data = await CheckTypeApi.getCheckTypePage(queryParams)
    list.value = data.list
    total.value = data.total
  } finally {
    loading.value = false
  }
}
 
/** 搜索按钮操作 */
const handleQuery = () => {
  queryParams.pageNo = 1
  getList()
}
 
/** 重置按钮操作 */
const resetQuery = () => {
  queryFormRef.value.resetFields()
  handleQuery()
}
 
/** 添加/修改操作 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
  formRef.value.open(type, id)
}
 
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
  try {
    // 删除的二次确认
    await message.delConfirm()
    // 发起删除
    await CheckTypeApi.deleteCheckType(id)
    message.success(t('common.delSuccess'))
    // 刷新列表
    await getList()
  } catch { }
}
 
/** 导出按钮操作 */
const handleExport = async () => {
  try {
    // 导出的二次确认
    await message.exportConfirm()
    // 发起导出
    exportLoading.value = true
    const data = await CheckTypeApi.exportCheckType(queryParams)
    download.excel(data, '检查项目.xls')
  } catch {
  } finally {
    exportLoading.value = false
  }
}
 
/** 初始化 **/
onMounted(() => {
  getList()
})
</script>