certificate.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <template>
  2. <div class="relative h-full">
  3. <hc-new-card title="中期支付证书列表">
  4. <template #extra>
  5. <hc-tooltip keys="debit_pay_admin_certificate_recalculate_btn">
  6. <el-button :disabled="tableCheckedKeys.length <= 0" hc-btn type="warning" :loading="recalculateLoading" @click="recalculateClick">重新计算</el-button>
  7. </hc-tooltip>
  8. <el-button hc-btn type="primary" @click="addModalClick">
  9. <hc-icon name="add" />
  10. <span>新增</span>
  11. </el-button>
  12. </template>
  13. <hc-table
  14. :column="tableColumn" :datas="tableData" :loading="tableLoading" :index-style="{ width: 60 }"
  15. is-check :check-style="{ width: 29 }" @selection-change="tableSelectionChange"
  16. >
  17. <template #action="{ row }">
  18. <el-link type="primary" :disabled="!row.rawUrl" @click="rowViewRawPdf(row)">查看电签报表</el-link>
  19. <el-link type="primary" @click="rowViewPdf(row)">查看报表</el-link>
  20. <el-link type="primary" :disabled="row.approveStatus === 0" @click="eVisaRowClick(row)">查看电签流程</el-link>
  21. <el-link type="success" :disabled="row.isLock === 1" @click="rowEditClick(row)">修改</el-link>
  22. <el-link type="danger" :disabled="row.isLock === 1" @click="rowDelClick(row)">删除</el-link>
  23. <el-link v-loading="row?.recalculateLoading" :disabled="row.isLock === 1 || row.approveStatus !== 0" @click="rowRecalculateClick(row)">重新计算</el-link>
  24. <el-link type="warning" @click="rowLockingClick(row)">{{ row.isLock === 1 ? '取消锁定' : '锁定' }}</el-link>
  25. </template>
  26. </hc-table>
  27. <template #action>
  28. <hc-pages :pages="searchForm" @change="pageChange" />
  29. </template>
  30. </hc-new-card>
  31. <!-- 中间计量新增 -->
  32. <HcAddModal v-model="addModalShow" @finish="addModalFinish" />
  33. <!-- 中间计量编辑 -->
  34. <HcEditModal v-model="editModalShow" :ids="editModalIds" @finish="editModalFinish" />
  35. <!-- 查看报表 -->
  36. <hc-view-report v-model="isReportDrawer" :datas="pdfList" />
  37. <!-- 任务流程 -->
  38. <HcTaskModal v-model="isTaskModal" :ids="taskDataId" @close="taskDataId = ''" />
  39. </div>
  40. </template>
  41. <script setup>
  42. import { onActivated, ref, watch } from 'vue'
  43. import { useAppStore } from '~src/store'
  44. import { delMessage } from '~uti/tools'
  45. import { getArrValue, isNullES } from 'js-fast-way'
  46. import HcAddModal from './components/certificate/addModal.vue'
  47. import HcEditModal from './components/certificate/editModal.vue'
  48. import HcTaskModal from '~src/components/task-modal/task-modal.vue'
  49. import mainApi from '~api/debit-pay/admin/certificate'
  50. import { toPdfPage } from '~uti/btn-auth'
  51. import { useRoute } from 'vue-router'
  52. const useAppState = useAppStore()
  53. const useRoutes = useRoute()
  54. const projectId = ref(useAppState.getProjectId || '')
  55. const contractId = ref(useAppState.getContractId || '')
  56. defineOptions({
  57. name: 'DebitPayAdminCertificate',
  58. })
  59. //渲染完成
  60. onActivated(() => {
  61. getTableData()
  62. })
  63. const isReportDrawer = ref(false)
  64. watch(() => useRoutes, (val) => {
  65. if (val) {
  66. isReportDrawer.value = false
  67. }
  68. }, { immediate: true, deep: true })
  69. //搜索表单
  70. const searchForm = ref({ current: 1, size: 20, total: 0 })
  71. //分页
  72. const pageChange = ({ current, size }) => {
  73. searchForm.value.current = current
  74. searchForm.value.size = size
  75. getTableData()
  76. }
  77. //表格数据
  78. const tableLoading = ref(false)
  79. const tableColumn = ref([
  80. { key: 'periodNumber', name: '期号' },
  81. { key: 'certificateNumber', name: '证书编号' },
  82. { key: 'startDate', name: '开始日期' },
  83. { key: 'endDate', name: '结束日期' },
  84. { key: 'printDate', name: '打印日期' },
  85. { key: 'calculateDate', name: '重新计算时间' },
  86. { key: 'payMoney', name: '支付金额' },
  87. { key: 'action', name: '操作', width: 440, align: 'center' },
  88. ])
  89. const tableData = ref([])
  90. const getTableData = async () => {
  91. tableData.value = []
  92. tableLoading.value = true
  93. const { data } = await mainApi.getPage({
  94. ...searchForm.value,
  95. projectId: projectId.value,
  96. contractId: contractId.value,
  97. })
  98. tableData.value = getArrValue(data['records'])
  99. searchForm.value.total = data.total || 0
  100. tableLoading.value = false
  101. }
  102. //新增
  103. const addModalShow = ref(false)
  104. const addModalClick = () => {
  105. addModalShow.value = true
  106. }
  107. const addModalFinish = () => {
  108. getTableData()
  109. }
  110. //多选
  111. const tableCheckedKeys = ref([])
  112. const tableSelectionChange = (rows) => {
  113. tableCheckedKeys.value = rows
  114. }
  115. //修改
  116. const editModalShow = ref(false)
  117. const editModalIds = ref('')
  118. const rowEditClick = (row) => {
  119. editModalIds.value = row.id
  120. editModalShow.value = true
  121. }
  122. const editModalFinish = () => {
  123. getTableData()
  124. editModalIds.value = false
  125. }
  126. //删除
  127. const rowDelClick = (row) => {
  128. delMessage(async () => {
  129. const { error, code, msg } = await mainApi.remove({ ids: row.id })
  130. if (!error && code === 200) {
  131. window.$message.success('删除成功')
  132. getTableData().then()
  133. } else {
  134. window.$message.error(msg ?? '删除失败')
  135. }
  136. })
  137. }
  138. //锁定还是解锁
  139. const rowLockingClick = async (row) => {
  140. //isLock,是否锁定:0未锁定,1锁定
  141. const { error, code, msg } = await mainApi.setLocking({
  142. id: row.id,
  143. isLock: row.isLock,
  144. })
  145. if (!error && code === 200) {
  146. window.$message.success('操作成功')
  147. getTableData().then()
  148. } else {
  149. window.$message.error(msg ?? '操作失败')
  150. }
  151. }
  152. //重新计算
  153. const recalculateLoading = ref(false)
  154. const recalculateClick = async () => {
  155. const rows = tableCheckedKeys.value
  156. if (rows.length <= 0) {
  157. window.$message.warning('请先勾选一条数据')
  158. return
  159. }
  160. if (rows.length > 1) {
  161. window.$message.warning('目前仅支持选择一条数据')
  162. return
  163. }
  164. recalculateLoading.value = true
  165. const isRes = await postRecalculateApi(rows[0])
  166. recalculateLoading.value = false
  167. if (isRes) {
  168. editModalIds.value = false
  169. getTableData().then()
  170. }
  171. }
  172. //重新计算报表
  173. const rowRecalculateClick = async (row) => {
  174. row.recalculateLoading = true
  175. const isRes = await postRecalculateApi(row)
  176. row.recalculateLoading = false
  177. if (isRes) {
  178. editModalIds.value = false
  179. getTableData().then()
  180. }
  181. }
  182. //发起重新计算请求
  183. const postRecalculateApi = async ({ id }) => {
  184. const { error, code, msg } = await mainApi.recalculate({
  185. reportId: id,
  186. type: 0,
  187. taskType: 1,
  188. })
  189. if (!error && code === 200) {
  190. window.$message.success('操作成功')
  191. return true
  192. } else {
  193. window.$message.error(msg ?? '操作失败')
  194. return false
  195. }
  196. }
  197. //查看报表
  198. const pdfList = ref([])
  199. const rowViewPdf = (row)=>{
  200. pdfList.value = []
  201. if (getArrValue(row?.urlListData).length > 0) {
  202. pdfList.value = getArrValue(row?.urlListData)
  203. console.log(pdfList.value, 'pdfList.value')
  204. isReportDrawer.value = true
  205. } else {
  206. window.$message.warning('暂无报表数据')
  207. }
  208. }
  209. const rowViewRawPdf = (row)=>{
  210. toPdfPage(row?.rawUrl)
  211. }
  212. //查看电签流程
  213. const isTaskModal = ref(false)
  214. const taskDataId = ref('')
  215. const eVisaRowClick = ({ taskId }) => {
  216. if (isNullES(taskId)) {
  217. window.$message.warning('暂无电签数据')
  218. return
  219. }
  220. taskDataId.value = taskId
  221. setTimeout(()=> {
  222. isTaskModal.value = true
  223. }, 200)
  224. }
  225. </script>
  226. <style scoped lang="scss">
  227. </style>