certificate.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <div class="relative h-full">
  3. <hc-new-card title="中期支付证书列表">
  4. <template #extra>
  5. <el-button hc-btn type="primary" @click="addModalClick">
  6. <hc-icon name="add" />
  7. <span>新增</span>
  8. </el-button>
  9. </template>
  10. <hc-table :column="tableColumn" :datas="tableData" :loading="tableLoading" is-new :index-style="{ width: 60 }">
  11. <template #action="{ row }">
  12. <el-link type="primary" @click="isReportDrawer = true">查看报表</el-link>
  13. <el-link type="success" @click="rowEditClick(row)">修改</el-link>
  14. <el-link type="danger" @click="rowDelClick(row)">删除</el-link>
  15. <el-link>重新计算</el-link>
  16. <el-link type="warning" @click="rowLockingClick(row)">{{ row.isLock === 1 ? '取消锁定' : '锁定' }}</el-link>
  17. </template>
  18. </hc-table>
  19. <template #action>
  20. <hc-pages :pages="searchForm" @change="pageChange" />
  21. </template>
  22. </hc-new-card>
  23. <!-- 中间计量新增 -->
  24. <HcAddModal v-model="addModalShow" @finish="addModalFinish" />
  25. <!-- 中间计量编辑 -->
  26. <HcEditModal v-model="editModalShow" :ids="editModalIds" @finish="editModalFinish" />
  27. <!-- 查看报表 -->
  28. <hc-view-report v-model="isReportDrawer" />
  29. </div>
  30. </template>
  31. <script setup>
  32. import { getArrValue } from 'js-fast-way'
  33. import { onMounted, ref } from 'vue'
  34. import { useAppStore } from '~src/store'
  35. import { delMessage } from '~uti/tools'
  36. import HcAddModal from './components/certificate/addModal.vue'
  37. import HcEditModal from './components/certificate/editModal.vue'
  38. import mainApi from '~api/debit-pay/admin/certificate'
  39. const useAppState = useAppStore()
  40. const projectId = ref(useAppState.getProjectId || '')
  41. const contractId = ref(useAppState.getContractId || '')
  42. defineOptions({
  43. name: 'DebitPayAdminCertificate',
  44. })
  45. //渲染完成
  46. onMounted(() => {
  47. getTableData()
  48. })
  49. const isReportDrawer = ref(false)
  50. //搜索表单
  51. const searchForm = ref({ current: 1, size: 10, total: 0 })
  52. //分页
  53. const pageChange = ({ current, size }) => {
  54. searchForm.value.current = current
  55. searchForm.value.size = size
  56. getTableData()
  57. }
  58. //表格数据
  59. const tableLoading = ref(false)
  60. const tableColumn = ref([
  61. { key: 'periodNumber', name: '期号' },
  62. { key: 'certificateNumber', name: '证书编号' },
  63. { key: 'startDate', name: '开始日期' },
  64. { key: 'endDate', name: '结束日期' },
  65. { key: 'printDate', name: '打印日期' },
  66. { key: 'calculateDate', name: '重新计算时间' },
  67. { key: 'payMoney', name: '支付金额' },
  68. { key: 'action', name: '操作', width: 280 },
  69. ])
  70. const tableData = ref([])
  71. const getTableData = async () => {
  72. tableData.value = []
  73. tableLoading.value = true
  74. const { data } = await mainApi.getPage({
  75. ...searchForm.value,
  76. projectId: projectId.value,
  77. contractId: contractId.value,
  78. })
  79. tableData.value = getArrValue(data['records'])
  80. searchForm.value.total = data.total || 0
  81. tableLoading.value = false
  82. }
  83. //新增
  84. const addModalShow = ref(false)
  85. const addModalClick = () => {
  86. addModalShow.value = true
  87. }
  88. const addModalFinish = () => {
  89. getTableData()
  90. }
  91. //修改
  92. const editModalShow = ref(false)
  93. const editModalIds = ref('')
  94. const rowEditClick = (row) => {
  95. editModalIds.value = row.id
  96. editModalShow.value = true
  97. }
  98. const editModalFinish = () => {
  99. getTableData()
  100. }
  101. //删除
  102. const rowDelClick = (row) => {
  103. delMessage(async () => {
  104. const { code, msg } = await mainApi.remove({ ids: row.id })
  105. if (code === 200) {
  106. window.$message.success('删除成功')
  107. getTableData().then()
  108. } else {
  109. window.$message.error(msg ?? '删除失败')
  110. }
  111. })
  112. }
  113. //锁定还是解锁
  114. const rowLockingClick = async (row) => {
  115. //isLock,是否锁定:0未锁定,1锁定
  116. const { code, msg } = await mainApi.setLocking({
  117. id: row.id,
  118. isLock: row.isLock,
  119. })
  120. if (code === 200) {
  121. window.$message.success('操作成功')
  122. getTableData().then()
  123. } else {
  124. window.$message.error(msg ?? '操作失败')
  125. }
  126. }
  127. </script>
  128. <style scoped lang="scss">
  129. </style>