manage.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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="row.isRectifyUser === 0 ? 'cursor-not-allowed' : 'text-link'" @click="tableRowEdit(row)">{{ row?.inspectName }}</span>
  8. </template>
  9. <template #isRectify="{ row }">
  10. <el-tag
  11. v-if="row?.isRectify"
  12. :type="`${row.isRectify === 3 ? 'success' : row.isRectify === 1 ? 'warning' : 'info'}`" class="mx-1" effect="dark"
  13. >
  14. {{ row.isRectify === 3 ? '已整改' : row.isRectify === 2 ? '不需要' : '需要' }}
  15. </el-tag>
  16. </template>
  17. <template #action="{ row }">
  18. <el-link v-if="row.submitRectify == 1" type="primary" :disabled="row.isRectifyUser === 0" @click="changeRow(row)">整改</el-link>
  19. <el-link v-else type="primary" :disabled="row.isRectifyUser === 0" @click="cancleSubmit(row)">撤回提交</el-link>
  20. </template>
  21. </HcTable>
  22. <template #action>
  23. <HcPages :pages="searchForm" @change="pageChange" />
  24. </template>
  25. </HcNewCard>
  26. </div>
  27. </template>
  28. <script setup>
  29. import { onActivated, onMounted, ref, watch } from 'vue'
  30. import { useRouter } from 'vue-router'
  31. import patrolApi from '~api/patrol/patrol'
  32. import { useAppStore } from '~src/store'
  33. import { getArrValue } from 'js-fast-way'
  34. const useAppState = useAppStore()
  35. const projectId = ref(useAppState.getProjectId)
  36. const contractId = ref(useAppState.contractId)
  37. //初始变量
  38. const router = useRouter()
  39. const tableColumn = [
  40. { key: 'projectName', name: '项目' },
  41. { key: 'inspectTypeName', name: '检查类别' },
  42. { key: 'inspectName', name: '检查名称' },
  43. { key: 'reviewInspectStatusName', name: '复核检查状态' },
  44. { key: 'isRectify', name: '是否需要整改' },
  45. { key: 'rectifyDate', name: '需求整改完成日期' },
  46. { key: 'actualRectifyDate', name: '实际整改完成日期' },
  47. { key: 'action', name: '操作' },
  48. ]
  49. const tableData = ref([
  50. { key1: 'xx至xx高速公路-演示项(本地测试)', key2: '安全巡检', key3: '原地面检查', key4:'检查状态', key5:'需要整改', key6:'2023-09-27', key7:'2023-09-27', isType:true },
  51. { key1: 'xx至xx高速公路-演示项(本地测试)', key2: '安全巡检', key3: '原地面检查', key4:'检查状态', key5:'需要整改', key6:'2023-09-27', key7:'2023-09-27', isType:false },
  52. { key1: 'xx至xx高速公路-演示项(本地测试)', key2: '安全巡检', key3: '原地面检查', key4:'检查状态', key5:'需要整改', key6:'2023-09-27', key7:'2023-09-27', isType:true },
  53. ])
  54. //搜索表单
  55. const searchForm = ref({
  56. current: 1, size: 20, total: 0,
  57. })
  58. //分页被点击
  59. const pageChange = ({ current, size }) => {
  60. searchForm.value.current = current
  61. searchForm.value.size = size
  62. getTableData()
  63. }
  64. const tableLoading = ref(false)
  65. const getTableData = async () => {
  66. tableLoading.value = true
  67. const { error, code, data } = await patrolApi.page2({
  68. ...searchForm.value,
  69. projectId: projectId.value,
  70. contractId:contractId.value,
  71. })
  72. //判断状态
  73. tableLoading.value = false
  74. if (!error && code === 200) {
  75. tableData.value = getArrValue(data['records'])
  76. searchForm.value.total = data['total'] || 0
  77. } else {
  78. tableData.value = []
  79. searchForm.value.total = 0
  80. }
  81. }
  82. onActivated(()=>{
  83. getTableData()
  84. })
  85. const tableRowEdit = (row)=>{
  86. const { isRectifyUser } = row
  87. if (isRectifyUser !== 0) {
  88. changeRow(row)
  89. }
  90. }
  91. //提交整改
  92. const changeRow = (row)=>{
  93. router.push({
  94. path: '/patrol/add',
  95. query: {
  96. type: 'changeRow',
  97. id:row.id,
  98. },
  99. })
  100. }
  101. //撤回提交
  102. const cancleSubmit = async (row)=>{
  103. tableLoading.value = true
  104. const { error, code, msg } = await patrolApi.revokeSubmit({
  105. id:row.id,
  106. })
  107. //判断状态
  108. if (!error && code === 200) {
  109. window.$message.success(msg)
  110. getTableData()
  111. }
  112. }
  113. </script>
  114. <style lang='scss' scoped>
  115. </style>