index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <!-- 搜索 -->
  3. <ContentWrap>
  4. <!-- 搜索工作栏 -->
  5. <el-form
  6. class="-mb-15px"
  7. :model="queryParams"
  8. ref="queryFormRef"
  9. :inline="true"
  10. label-width="80px"
  11. >
  12. <TenantSelect v-model="queryParams.tenantIds" placeholder="请选择机构名称" prop="tenantIds" />
  13. <el-form-item label="长者姓名" prop="elderName">
  14. <el-input
  15. @keyup.enter="handleQuery"
  16. v-model="queryParams.elderName"
  17. placeholder="请输入长者姓名"
  18. class="!w-240px"
  19. />
  20. </el-form-item>
  21. <el-form-item label="合同状态" prop="type">
  22. <el-select v-model="queryParams.type" placeholder="请选择" class="!w-240px">
  23. <el-option
  24. v-for="(dict, index) in getIntDictOptions(DICT_TYPE.CONTRACT_TYPE)"
  25. :key="index"
  26. :label="dict.label"
  27. :value="dict.value"
  28. />
  29. </el-select>
  30. </el-form-item>
  31. <el-form-item label="是否已上传合同" prop="hasExtra" label-width="120px">
  32. <el-select v-model="queryParams.hasExtra" placeholder="请选择" class="!w-240px">
  33. <el-option
  34. v-for="(dict, index) in getIntDictOptions(DICT_TYPE.COMMON_STATUS6)"
  35. :key="index"
  36. :label="dict.label"
  37. :value="dict.value"
  38. />
  39. </el-select>
  40. </el-form-item>
  41. <el-form-item label="入住类型" prop="inStatusType">
  42. <el-select v-model="queryParams.inStatusType" placeholder="请选择" class="!w-240px">
  43. <el-option
  44. v-for="(dict, index) in getStrDictOptions(DICT_TYPE.IN_STATUS_TYPE)"
  45. :key="index"
  46. :label="dict.label"
  47. :value="dict.value"
  48. />
  49. </el-select>
  50. </el-form-item>
  51. <el-form-item>
  52. <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
  53. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
  54. </el-form-item>
  55. </el-form>
  56. </ContentWrap>
  57. <!-- 列表 -->
  58. <ContentWrap>
  59. <TabBarBtn />
  60. <Table2
  61. v-loading="loading"
  62. :data="list"
  63. :columns="ContractColumns"
  64. :queryParams="queryParams"
  65. :opWidth="240"
  66. @edit="(arg) => handleRenewal(arg, 1)"
  67. @upload="openForm"
  68. @detail="openDetail"
  69. >
  70. <!-- @check="(arg) => handleRenewal(arg, 2)" -->
  71. <template #pre="{ scope }">
  72. <el-button
  73. link
  74. type="primary"
  75. @click="handleRenewal(scope, 2)"
  76. v-hasPermi="['contract:check']"
  77. v-show="scope.status == 1"
  78. >
  79. 办理
  80. </el-button>
  81. </template>
  82. </Table2>
  83. <!-- 分页 -->
  84. <Pagination
  85. :total="total"
  86. v-model:page="queryParams.pageNo"
  87. v-model:limit="queryParams.pageSize"
  88. @pagination="getList"
  89. />
  90. </ContentWrap>
  91. <Form ref="formRef" @success="getList" />
  92. <ContractManageForm ref="contractManageFormRef" />
  93. <Renewal ref="renewalRef" @success="getList" />
  94. <Detail ref="detailRef" />
  95. </template>
  96. <script lang="ts" setup>
  97. import { DICT_TYPE, getIntDictOptions, getStrDictOptions } from '@/utils/dict'
  98. import { getElderlyContract, getElderlyContract2 } from '@/api/elderly/elder/contract'
  99. import { ContractColumns } from '../column'
  100. import Form from './Form.vue'
  101. import Renewal from './Renewal.vue'
  102. import Detail from './Detail.vue'
  103. import ContractManageForm from '@/views/elderly/contracts/ContractManageForm.vue'
  104. import { useUserStore } from '@/store/modules/user'
  105. import { formatTimestampYMD } from '@/utils/dateUtil'
  106. defineOptions({ name: 'Contract' })
  107. const userStore = useUserStore()
  108. const message = useMessage() // 消息弹窗
  109. const loading = ref(true) // 列表的加载中
  110. const total = ref(0) // 列表的总页数
  111. const list = ref([]) // 列表的数据
  112. const queryParams = reactive({
  113. pageNo: 1,
  114. pageSize: 10,
  115. elderName: undefined,
  116. type: undefined,
  117. hasExtra: undefined,
  118. inStatusType: undefined,
  119. tenantIds: userStore.orgTenantId
  120. })
  121. const queryFormRef = ref() // 搜索的表单
  122. const contractManageFormRef = ref() // 合同管理的表单
  123. /** 查询列表 */
  124. const getList = async () => {
  125. loading.value = true
  126. try {
  127. const data = await getElderlyContract(queryParams)
  128. list.value = data.list
  129. total.value = data.total
  130. } finally {
  131. loading.value = false
  132. }
  133. }
  134. /** 搜索按钮操作 */
  135. const handleQuery = async () => {
  136. if (!queryFormRef.value) return
  137. const valid = await queryFormRef.value.validate()
  138. if (!valid) return
  139. queryParams.pageNo = 1
  140. getList()
  141. }
  142. /** 重置按钮操作 */
  143. const resetQuery = () => {
  144. queryFormRef.value.resetFields()
  145. handleQuery()
  146. }
  147. /** 添加/修改操作 */
  148. const formRef = ref()
  149. const openForm = (row: any = {}, type: number = 1) => {
  150. contractManageFormRef.value.open(row, type)
  151. // formRef.value.open(row, type)
  152. }
  153. // 变更/续签
  154. const renewalRef = ref()
  155. const handleRenewal = (row: any = {}, type: number = 1) => {
  156. renewalRef.value.open(row, type)
  157. }
  158. // 详情
  159. const detailRef = ref()
  160. const openDetail = (row: any = {}) => {
  161. detailRef.value.open(row.id)
  162. }
  163. const queryParamsContract = reactive({
  164. pageNo: 1,
  165. pageSize: 100,
  166. elderName: undefined,
  167. type: 0,
  168. inStatusType: undefined,
  169. tenantIds: userStore.orgTenantId
  170. })
  171. //合同过期
  172. const getContractList = async () => {
  173. loading.value = true
  174. try {
  175. const data = await getElderlyContract2(queryParamsContract)
  176. if (data && data.length > 0) {
  177. if ((window as any).$showContractNotification) {
  178. ;(window as any).$showContractNotification({
  179. title: '合同过期提醒',
  180. message: `检测到 ${data.length} 位长者的合同已过期,请及时处理!`,
  181. contracts: data.map((item: any) => ({
  182. elderName: item.elderName || item.name,
  183. expireDate: formatTimestampYMD(item.expireTime)
  184. }))
  185. })
  186. }
  187. }
  188. } finally {
  189. loading.value = false
  190. }
  191. }
  192. const route = useRoute()
  193. /** 初始化 **/
  194. onMounted(() => {
  195. // 通知跳转过来的直接打开办理弹窗
  196. if (route.query && route.query.id) {
  197. openForm({ elderId: route.query.id, tenantId: route.query.tenantId }, 2)
  198. }
  199. getList()
  200. getContractList()
  201. })
  202. </script>