index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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="150" show-overflow-tooltip>
  66. <template #default="scope">
  67. <el-tag :type="getResultLevelType(scope.row.riskLevel)">
  68. {{ (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. dailyLifeDelete,
  132. dailyLifePage
  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. tenantIds: userStore.orgTenantId
  160. })
  161. const queryFormRef = ref()
  162. // 处理批量导出
  163. const handleBatchExport = async (batch: number, count: number) => {
  164. exportLoading.value = true
  165. console.log(batch, count)
  166. }
  167. /** 查询列表 */
  168. const getList = async () => {
  169. loading.value = true
  170. try {
  171. const data = await dailyLifePage(queryParams)
  172. list.value = data.list
  173. total.value = data.total
  174. } finally {
  175. loading.value = false
  176. }
  177. }
  178. /** 搜索按钮操作 */
  179. const handleQuery = async () => {
  180. if (!queryFormRef.value) return
  181. const valid = await queryFormRef.value.validate()
  182. if (!valid) return
  183. queryParams.pageNo = 1
  184. await getList()
  185. }
  186. /** 重置按钮操作 */
  187. const resetQuery = () => {
  188. queryParams.elderName = ''
  189. queryParams.assessor = ''
  190. queryParams.tenantIds = userStore.orgTenantId
  191. queryParams.assessDate = getCurrentMonthRange()
  192. queryFormRef.value.resetFields()
  193. handleQuery()
  194. }
  195. /** 添加/修改操作 */
  196. const formRef = ref()
  197. const openForm = (id?: number) => {
  198. if (queryParams.tenantIds.length == 0 || queryParams.tenantIds.length > 1) {
  199. message.error('新增只能选择一个机构')
  200. return
  201. }
  202. formRef.value.open(queryParams.tenantIds[0], id, false)
  203. }
  204. const openFormEdit = (row: any = {}, id?: number) => {
  205. formRef.value.open(row.tenantId, id, false)
  206. }
  207. const openFormDetail = (row: any = {}, id?: number) => {
  208. formRef.value.open(row.tenantId, id, true)
  209. }
  210. const openClose = async (item: any) => {
  211. try {
  212. const res = await message.confirm('确定要删除吗?', '提示')
  213. if (res == 'confirm') {
  214. try {
  215. const res = await dailyLifeDelete(item.id)
  216. if (res) {
  217. message.success(t('common.updateSuccess'))
  218. await getList()
  219. }
  220. } catch (err) { }
  221. }
  222. } catch { }
  223. }
  224. /** 取消按钮操作 */
  225. const cancelDelete = async (id: number) => {
  226. try {
  227. await message.cancelConfirm()
  228. message.success(t('common.delSuccess'))
  229. await getList()
  230. } catch { }
  231. }
  232. const route = useRoute()
  233. /** 初始化 **/
  234. onMounted(() => {
  235. if (route.query && route.query.elderName) {
  236. queryParams.elderName = route.query.elderName as string
  237. }
  238. getList()
  239. })
  240. // 表头格式
  241. const tableHeaderColor = ({ rowIndex }: any) => {
  242. if (rowIndex === 0) {
  243. return {
  244. backgroundColor: '#f8f8f9',
  245. color: '#666666',
  246. fontWeight: 'bold'
  247. }
  248. }
  249. }
  250. // 获取结果等级类型
  251. const getResultLevelType = (resultLevel: string) => {
  252. switch (resultLevel) {
  253. case 'complete_dependence': return 'danger'
  254. case 'large_help': return 'warning'
  255. case 'need_help': return 'info'
  256. case 'basic_independent': return 'success'
  257. default: return ''
  258. }
  259. }
  260. // 获取结果等级文本
  261. const getResultLevelText = (resultLevel: string) => {
  262. switch (resultLevel) {
  263. case 'complete_dependence': return '生活完全依赖'
  264. case 'large_help': return '生活需要很大帮助'
  265. case 'need_help': return '生活需要帮忙'
  266. case 'basic_independent': return '生活基本自理'
  267. default: return '-'
  268. }
  269. }
  270. </script>
  271. <style scoped lang="scss"></style>