safe.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <!-- -->
  2. <template>
  3. <div class="hc-page-box">
  4. <HcNewCard>
  5. <HcTable is-new :column="tableColumn" :datas="tableData">
  6. <template #inspectName="{ row }">
  7. <span class="text-link" @click="tableRowEdit(row)">{{ row?.inspectName }}</span>
  8. </template>
  9. <template #isRectify="{ row }">
  10. <span v-if="row.isRectify == 1">需要</span>
  11. <span v-else>不需要</span>
  12. </template>
  13. <template #action="{ row }">
  14. <el-link v-if="row.submitRectify == 2 && row.isRectify == 1" type="primary" @click="reviewRow(row)">复核</el-link>
  15. <el-link type="primary" @click="updateRow(row)">修改</el-link>
  16. <el-link type="primary" @click="delRow(row)">删除</el-link>
  17. </template>
  18. </HcTable>
  19. <template #action>
  20. <HcPages :pages="searchForm" @change="pageChange" />
  21. </template>
  22. </HcNewCard>
  23. </div>
  24. </template>
  25. <script setup>
  26. import { onActivated, onMounted, ref } from 'vue'
  27. import { useRouter } from 'vue-router'
  28. import patrolApi from '~api/patrol/patrol'
  29. import { useAppStore } from '~src/store'
  30. import { getArrValue } from 'js-fast-way'
  31. import { delMessageV2 } from '~com/message/index.js'
  32. const useAppState = useAppStore()
  33. const projectId = ref(useAppState.getProjectId)
  34. //初始变量
  35. const router = useRouter()
  36. const tableColumn = [
  37. { key: 'projectName', name: '项目' },
  38. { key: 'inspectTypeName', name: '检查类别' },
  39. { key: 'inspectName', name: '检查名称' },
  40. { key: 'reviewInspectStatusName', name: '复核检查状态' },
  41. { key: 'isRectify', name: '是否需要整改' },
  42. { key: 'rectifyDate', name: '需求整改完成日期' },
  43. { key: 'actualRectifyDate', name: '实际整改完成日期' },
  44. { key: 'action', name: '操作' },
  45. ]
  46. const tableData = ref([])
  47. //搜索表单
  48. const searchForm = ref({
  49. current: 1, size: 20, total: 0,
  50. })
  51. //分页被点击
  52. const pageChange = ({ current, size }) => {
  53. searchForm.value.current = current
  54. searchForm.value.size = size
  55. getTableData()
  56. }
  57. const tableLoading = ref(false)
  58. const getTableData = async () => {
  59. tableLoading.value = true
  60. const { error, code, data } = await patrolApi.queryPage({
  61. ...searchForm.value,
  62. projectId: projectId.value,
  63. })
  64. //判断状态
  65. tableLoading.value = false
  66. if (!error && code === 200) {
  67. tableData.value = getArrValue(data['records'])
  68. searchForm.value.total = data['total'] || 0
  69. } else {
  70. tableData.value = []
  71. searchForm.value.total = 0
  72. }
  73. }
  74. onActivated(()=>{
  75. getTableData()
  76. })
  77. const tableRowEdit = (row)=>{
  78. router.push({
  79. path: '/patrol/add',
  80. query: {
  81. type: 'view',
  82. id:row.id,
  83. },
  84. })
  85. }
  86. const updateRow = (row)=>{
  87. router.push({
  88. path: '/patrol/add',
  89. query: {
  90. type: 'confirmChange',
  91. id:row.id,
  92. },
  93. })
  94. }
  95. const reviewRow = (row)=>{
  96. router.push({
  97. path: '/patrol/add',
  98. query: {
  99. type: 'review',
  100. id:row.id,
  101. },
  102. })
  103. }
  104. //删除
  105. const delRow = (row)=>{
  106. delMessageV2(async (action, instance, done) => {
  107. if (action === 'confirm') {
  108. instance.confirmButtonLoading = true
  109. delInfo(row)
  110. instance.confirmButtonLoading = false
  111. done()
  112. } else {
  113. done()
  114. }
  115. })
  116. }
  117. const delInfo = async (row)=>{
  118. const { error, code, msg } = await patrolApi.delete({
  119. id:row.id,
  120. })
  121. //判断状态
  122. if (!error && code === 200) {
  123. window.$message.success(msg)
  124. getTableData()
  125. }
  126. }
  127. </script>
  128. <style lang='scss' scoped>
  129. </style>