flow.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <hc-card-item class="hc-test-sample-card-item">
  3. <template #header>
  4. <div class="w-200px">
  5. <el-select v-model="searchForm.contractId" placeholder="选择合同段" filterable block>
  6. <el-option v-for="item in contractData" :key="item.id" :label="item.contractName" :value="item.id" />
  7. </el-select>
  8. </div>
  9. <div class="ml-2 w-250px">
  10. <hc-date-picker :dates="betweenTime" clearable @change="betweenTimeUpdate" />
  11. </div>
  12. <div class="ml-2 w-250px">
  13. <hc-search-input v-model="searchForm.materialName" @search="searchClick" />
  14. </div>
  15. </template>
  16. <hc-table :column="tableColumn" :datas="tableData" :loading="tableLoading" :index-style="{ width: 60 }">
  17. <template #key9="{ row }">
  18. <el-button v-if="row.key9 === 1" type="success" size="small">已同意</el-button>
  19. <el-button v-if="row.key9 === 2" type="info" size="small">待审批</el-button>
  20. <el-button v-if="row.key9 === 3" type="danger" size="small">已废除</el-button>
  21. </template>
  22. </hc-table>
  23. <template #action>
  24. <hc-pages :pages="searchForm" @change="pageChange" />
  25. </template>
  26. </hc-card-item>
  27. </template>
  28. <script setup>
  29. import { onMounted, ref, watch } from 'vue'
  30. import { useAppStore } from '~src/store'
  31. import { getErtractInfo } from '~api/other'
  32. import { getArrValue, getObjValue, isNullES } from 'js-fast-way'
  33. import mainApi from '~api/tentative/material/testSample'
  34. //参数
  35. const props = defineProps({
  36. tree: {
  37. type: Object,
  38. default: () => ({}),
  39. },
  40. })
  41. //变量
  42. const store = useAppStore()
  43. const projectId = ref(store.getProjectId)
  44. const contractId = ref(store.getContractId)
  45. //渲染完成
  46. onMounted(() => {
  47. getContractData()
  48. })
  49. //监听数据
  50. const treeInfo = ref(props.tree)
  51. watch(() => props.tree, (obj) => {
  52. treeInfo.value = getObjValue(obj)
  53. searchClick()
  54. })
  55. //搜索表单
  56. const searchForm = ref({
  57. status: 1, startTime: null, endTime: null, materialName: null,
  58. current: 1, size: 20, total: 0,
  59. })
  60. //获取合同段信息
  61. const contractData = ref([])
  62. const getContractData = async () => {
  63. const { data } = await getErtractInfo({
  64. projectId: projectId.value,
  65. contractId: contractId.value,
  66. })
  67. const res = getArrValue(data)
  68. contractData.value = res
  69. if (res.length > 0) {
  70. searchForm.value.contractId = res[0].id
  71. searchClick()
  72. }
  73. }
  74. //日期时间被选择
  75. const betweenTime = ref(null)
  76. const betweenTimeUpdate = ({ arr }) => {
  77. betweenTime.value = arr
  78. if (arr.length > 0) {
  79. searchForm.value.startTime = arr[0]
  80. searchForm.value.endTime = arr[1]
  81. } else {
  82. searchForm.value.startTime = null
  83. searchForm.value.endTime = null
  84. }
  85. }
  86. //搜索
  87. const searchClick = () => {
  88. searchForm.value.current = 1
  89. getTableData()
  90. }
  91. //分页被点击
  92. const pageChange = ({ current, size }) => {
  93. searchForm.value.current = current
  94. searchForm.value.size = size
  95. getTableData()
  96. }
  97. //表格数据
  98. const tableColumn = ref([
  99. { key: 'materialName', name: '样品名称' },
  100. { key: 'specificationModel', name: '规格型号', align: 'center' },
  101. { key: 'materialCount', name: '试样数量', align: 'center' },
  102. { key: 'calculationUnit', name: '计算单位', align: 'center' },
  103. { key: 'proposedPosition', name: '拟用部位' },
  104. { key: 'representativeCount', name: '代表数量', align: 'center' },
  105. { key: 'userName', name: '取样人', align: 'center' },
  106. { key: 'entrustTime', name: '委托单上报时间', align: 'center' },
  107. ])
  108. const tableData = ref([])
  109. //获取表格数据
  110. const tableLoading = ref(false)
  111. const getTableData = async () => {
  112. const { primaryKeyId } = treeInfo.value
  113. if (isNullES(primaryKeyId)) return
  114. tableLoading.value = true
  115. const { error, code, data } = await mainApi.queryPage({
  116. ...searchForm.value,
  117. projectId: projectId.value,
  118. contractId: contractId.value,
  119. nodeId: primaryKeyId || '',
  120. })
  121. //处理数据
  122. tableLoading.value = false
  123. if (!error && code === 200) {
  124. tableData.value = getArrValue(data?.records)
  125. searchForm.value.total = data.total || 0
  126. } else {
  127. tableData.value = []
  128. searchForm.value.total = 0
  129. }
  130. }
  131. </script>