index.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <template>
  2. <ContentWrap>
  3. <!-- 防坠床评估表 -->
  4. <el-form
  5. class="-mb-15px"
  6. :model="queryParams"
  7. ref="queryFormRef"
  8. :inline="true"
  9. label-width="110px"
  10. >
  11. <el-form-item label="长者姓名">
  12. <el-input
  13. v-model="queryParams.elderName"
  14. placeholder="长者姓名"
  15. class="!w-240px"
  16. clearable
  17. />
  18. </el-form-item>
  19. <el-form-item label="评估人">
  20. <el-input
  21. v-model="queryParams.assessor"
  22. placeholder="评估人"
  23. class="!w-240px"
  24. clearable
  25. />
  26. </el-form-item>
  27. <el-form-item label="记录日期">
  28. <el-date-picker
  29. size="default"
  30. ref="selectRef"
  31. class="!w-240px"
  32. v-model="queryParams.assessDate"
  33. type="daterange"
  34. :clearable="true"
  35. :editable="false"
  36. placeholder="选择记录日期"
  37. value-format="YYYY-MM-DD"
  38. format="YYYY-MM-DD"
  39. date-format="YYYY-MM-DD"
  40. />
  41. </el-form-item>
  42. <el-form-item>
  43. <el-button @click="handleQuery" style="margin-left: 2vw"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
  44. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
  45. </el-form-item>
  46. </el-form>
  47. </ContentWrap>
  48. <!-- 列表 -->
  49. <ContentWrap>
  50. <div class="mb-10px">
  51. <ButtonAdd @click="openForm(undefined)" />
  52. </div>
  53. <el-table v-loading="loading" :data="list" :header-cell-style="tableHeaderColor">
  54. <el-table-column header-align="center" align="center" label="序号" width="60">
  55. <template #default="scope">
  56. {{
  57. scope.$index + (queryParams.pageNo * queryParams.pageSize - queryParams.pageSize) + 1
  58. }}
  59. </template>
  60. </el-table-column>
  61. <el-table-column prop="elderName" header-align="center" align="center" label="长者姓名" min-width="150" show-overflow-tooltip/>
  62. <el-table-column prop="assessor" header-align="center" align="center" label="评估人" min-width="150" show-overflow-tooltip/>
  63. <el-table-column prop="assessDate" header-align="center" align="center" label="记录日期" min-width="150" show-overflow-tooltip/>
  64. <el-table-column prop="assessScore" header-align="center" align="center" label="评估总得分" min-width="120" show-overflow-tooltip/>
  65. <el-table-column prop="riskLevel" header-align="center" align="center" label="风险等级" min-width="120" show-overflow-tooltip>
  66. <template #default="scope">
  67. <el-tag :type="getRiskLevelType(scope.row.riskLevel)">
  68. {{ getRiskLevelText(scope.row.riskLevel) }}
  69. </el-tag>
  70. </template>
  71. </el-table-column>
  72. <el-table-column prop="creator" header-align="center" align="center" label="记录人" min-width="150" show-overflow-tooltip/>
  73. <el-table-column label="操作" align="center" width="200">
  74. <template #default="scope">
  75. <el-button
  76. link
  77. type="primary"
  78. @click="openFormEdit(scope.row, scope.row.id)"
  79. >
  80. 编辑
  81. </el-button>
  82. <el-button
  83. link
  84. type="warning"
  85. @click="openFormDetail(scope.row,scope.row.id)"
  86. >
  87. 详情
  88. </el-button>
  89. <el-button
  90. link
  91. type="danger"
  92. @click="openClose(scope.row)"
  93. >
  94. 删除
  95. </el-button>
  96. </template>
  97. </el-table-column>
  98. </el-table>
  99. <!-- 分页 -->
  100. <Pagination
  101. :total="total"
  102. v-model:page="queryParams.pageNo"
  103. v-model:limit="queryParams.pageSize"
  104. @pagination="getList"
  105. />
  106. </ContentWrap>
  107. <AddForm ref="formRef" @success="getList" />
  108. <!-- 通用批量导出弹窗 -->
  109. <BatchExportDialog
  110. :show="showBatchExport"
  111. :title="exportConfig.title"
  112. :loading="exportLoading"
  113. :batch-min="exportConfig.batchMin"
  114. :batch-max="exportConfig.batchMax"
  115. :count-min="exportConfig.countMin"
  116. :count-max="exportConfig.countMax"
  117. :default-batch="exportConfig.defaultBatch"
  118. :default-count="exportConfig.defaultCount"
  119. :description="exportConfig.description"
  120. @update:show="showBatchExport = $event"
  121. @confirm="handleBatchExport"
  122. @cancel="showBatchExport = false"
  123. />
  124. </template>
  125. <script setup lang="ts">
  126. import AddForm from "./AddForm.vue";
  127. import ButtonAdd from "@/components/ButtonAdd/src/ButtonAdd.vue";
  128. import { useUserStore } from '@/store/modules/user'
  129. import { getCurrentMonthRange } from "@/utils/dateUtil";
  130. import {
  131. fallPreventionDelete,
  132. fallPreventionPage
  133. } from "@/api/social-work";
  134. const message = useMessage()
  135. const { t } = useI18n()
  136. const userStore = useUserStore()
  137. const loading = ref(true)
  138. const total = ref(0)
  139. const list = ref([])
  140. // 状态管理
  141. const showBatchExport = ref(false)
  142. const exportConfig = ref({
  143. title: '',
  144. batchMin: 1,
  145. batchMax: 999,
  146. countMin: 1,
  147. countMax: 200,
  148. defaultBatch: 1,
  149. defaultCount: 200,
  150. description: [] as string[]
  151. })
  152. const exportLoading = ref(false)
  153. let queryParams = reactive({
  154. pageNo: 1,
  155. pageSize: 10,
  156. elderName: '',
  157. assessor: '',
  158. // assessDate: getCurrentMonthRange(),
  159. assessDate: [],
  160. tenantIds: userStore.orgTenantId
  161. })
  162. const queryFormRef = ref()
  163. // 处理批量导出
  164. const handleBatchExport = async (batch: number, count: number) => {
  165. exportLoading.value = true
  166. console.log(batch, count)
  167. }
  168. /** 查询列表 */
  169. const getList = async () => {
  170. loading.value = true
  171. try {
  172. const data = await fallPreventionPage(queryParams)
  173. list.value = data.list
  174. total.value = data.total
  175. } finally {
  176. loading.value = false
  177. }
  178. }
  179. /** 搜索按钮操作 */
  180. const handleQuery = async () => {
  181. if (!queryFormRef.value) return
  182. const valid = await queryFormRef.value.validate()
  183. if (!valid) return
  184. queryParams.pageNo = 1
  185. await getList()
  186. }
  187. /** 重置按钮操作 */
  188. const resetQuery = () => {
  189. queryParams.elderName = ''
  190. queryParams.assessor = ''
  191. queryParams.tenantIds = userStore.orgTenantId
  192. // queryParams.assessDate = getCurrentMonthRange()
  193. queryParams.assessDate = []
  194. queryFormRef.value.resetFields()
  195. handleQuery()
  196. }
  197. /** 添加/修改操作 */
  198. const formRef = ref()
  199. const openForm = (id?: number) => {
  200. if (queryParams.tenantIds.length == 0 || queryParams.tenantIds.length > 1) {
  201. message.error('新增只能选择一个机构')
  202. return
  203. }
  204. formRef.value.open(queryParams.tenantIds[0], id, false)
  205. }
  206. const openFormEdit = (row: any = {}, id?: number) => {
  207. formRef.value.open(row.tenantId, id, false)
  208. }
  209. const openFormDetail = (row: any = {}, id?: number) => {
  210. formRef.value.open(row.tenantId, id, true)
  211. }
  212. const openClose = async (item: any) => {
  213. try {
  214. const res = await message.confirm('确定要删除吗?', '提示')
  215. if (res == 'confirm') {
  216. try {
  217. const res = await fallPreventionDelete(item.id)
  218. if (res) {
  219. message.success(t('common.updateSuccess'))
  220. await getList()
  221. }
  222. } catch (err) { }
  223. }
  224. } catch { }
  225. }
  226. /** 取消按钮操作 */
  227. const cancelDelete = async (id: number) => {
  228. try {
  229. await message.cancelConfirm()
  230. message.success(t('common.delSuccess'))
  231. await getList()
  232. } catch { }
  233. }
  234. const route = useRoute()
  235. /** 初始化 **/
  236. onMounted(() => {
  237. if (route.query && route.query.elderName) {
  238. queryParams.elderName = route.query.elderName as string
  239. }
  240. getList()
  241. })
  242. // 表头格式
  243. const tableHeaderColor = ({ rowIndex }: any) => {
  244. if (rowIndex === 0) {
  245. return {
  246. backgroundColor: '#f8f8f9',
  247. color: '#666666',
  248. fontWeight: 'bold'
  249. }
  250. }
  251. }
  252. // 获取风险等级类型
  253. const getRiskLevelType = (riskLevel: string) => {
  254. switch (riskLevel) {
  255. case 'none': return 'success'
  256. case 'low': return 'info'
  257. case 'medium': return 'warning'
  258. case 'high': return 'danger'
  259. default: return ''
  260. }
  261. }
  262. // 获取风险等级文本
  263. const getRiskLevelText = (riskLevel: string) => {
  264. switch (riskLevel) {
  265. case 'none': return '无风险'
  266. case 'low': return '低风险'
  267. case 'medium': return '中风险'
  268. case 'high': return '高风险'
  269. default: return '-'
  270. }
  271. }
  272. </script>
  273. <style scoped lang="scss"></style>