test.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <div class="hc-page-layout-box">
  3. <div :style="`width:${leftWidth}px;`" class="hc-layout-left-box">
  4. <div class="hc-project-box">
  5. <div class="hc-project-icon-box">
  6. <HcIcon name="stack" />
  7. </div>
  8. <div class="ml-2 project-name-box">
  9. <span class="text-xl text-cut project-alias">{{ projectInfo.projectAlias }}</span>
  10. <div class="text-xs text-cut project-name">{{ projectInfo.name }}</div>
  11. </div>
  12. </div>
  13. <div class="hc-tree-box">
  14. <el-scrollbar>
  15. <HcLazyTree :auto-expand-keys="treeAutoExpandKeys" is-type @load="treeLoadNode" @nodeTap="wbsElTreeClick" />
  16. </el-scrollbar>
  17. </div>
  18. <!-- 左右拖动 -->
  19. <div class="horizontal-drag-line" @mousedown="onmousedown" />
  20. </div>
  21. <div class="hc-page-content-box">
  22. <HcCard :scrollbar="false" action-size="lg">
  23. <template #header>
  24. <HcTooltip keys="tentative_collect_test_del">
  25. <el-button hc-btn color="#e03997" @click="delModalClick">
  26. <HcIcon name="delete-bin-2" />
  27. <span>删除</span>
  28. </el-button>
  29. </HcTooltip>
  30. <HcTooltip keys="tentative_collect_test_print">
  31. <el-button hc-btn color="#567722">
  32. <HcIcon name="printer" />
  33. <span>打印</span>
  34. </el-button>
  35. </HcTooltip>
  36. <HcTooltip keys="tentative_collect_test_download">
  37. <el-button hc-btn color="#A16222">
  38. <HcIcon name="download" />
  39. <span>下载</span>
  40. </el-button>
  41. </HcTooltip>
  42. </template>
  43. <template #search>
  44. <div class="w-auto">
  45. <el-select v-model="searchForm.contractId" block clearable placeholder="请选择合同段">
  46. <el-option
  47. v-for="item in projectInfo?.contractInfoList" :key="item.id"
  48. :label="item.name" :value="item.id"
  49. />
  50. </el-select>
  51. </div>
  52. <div class="w-32 ml-2">
  53. <el-select v-model="searchForm.type" block clearable placeholder="检测类别">
  54. <el-option
  55. v-for="item in typeData" :key="item.value" :label="item.label"
  56. :value="item.value"
  57. />
  58. </el-select>
  59. </div>
  60. <div class="w-32 ml-2">
  61. <el-select v-model="searchForm.approval" block clearable placeholder="审批状态">
  62. <el-option
  63. v-for="item in approvalData" :key="item.value" :label="item.label"
  64. :value="item.value"
  65. />
  66. </el-select>
  67. </div>
  68. <div class="w-64 ml-2">
  69. <HcDatePicker :dates="betweenTime" clearable @change="betweenTimeUpdate" />
  70. </div>
  71. <div class="ml-2">
  72. <el-button type="primary" @click="searchClick">
  73. <HcIcon name="search-2" />
  74. <span>搜索</span>
  75. </el-button>
  76. </div>
  77. </template>
  78. <HcTable
  79. ref="tableRef" :column="tableColumn" :datas="tableData" :loading="tableLoading" is-check
  80. border @selection-change="tableSelection"
  81. />
  82. <template #action>
  83. <HcPages :pages="searchForm" @change="pageChange" />
  84. </template>
  85. </HcCard>
  86. </div>
  87. </div>
  88. </template>
  89. <script setup>
  90. import { onMounted, ref, watch } from 'vue'
  91. import { useAppStore } from '~src/store'
  92. import queryApi from '~api/data-fill/query'
  93. import { getArrValue, getObjValue } from 'js-fast-way'
  94. import { getStoreValue, setStoreValue } from '~src/utils/storage'
  95. import { delMessageV2 } from '~com/message/index.js'
  96. //变量
  97. const useAppState = useAppStore()
  98. const projectId = ref(useAppState.getProjectId)
  99. const contractId = ref(useAppState.getContractId)
  100. const projectInfo = ref(useAppState.getProjectInfo)
  101. const isCollapse = ref(useAppState.getCollapse)
  102. const contractInfo = ref(useAppState.getContractInfo)
  103. const { contractType } = contractInfo.value
  104. const classifyType = ref(contractType === 2 ? '2' : '1')
  105. //监听
  106. watch(() => [
  107. useAppState.getCollapse,
  108. ], ([Collapse]) => {
  109. isCollapse.value = Collapse
  110. })
  111. //自动展开缓存
  112. const treeAutoExpandKeys = ref(getStoreValue('wbsTreeExpandKeys') || [])
  113. //渲染完成
  114. onMounted(() => {
  115. })
  116. //搜索表单
  117. const searchForm = ref({
  118. contractId: null, type: null, approval: null, betweenTime: null,
  119. current: 1, size: 20, total: 0,
  120. })
  121. //树相关的变量
  122. const primaryKeyId = ref('')
  123. const nodeItemInfo = ref({})
  124. const nodeDataInfo = ref({})
  125. //懒加载的数据
  126. const treeLoadNode = async ({ node, item, level }, resolve) => {
  127. let contractIdRelation = '', parentId = '', primaryKeyId = ''
  128. if (level !== 0) {
  129. const nodeData = getObjValue(item)
  130. contractIdRelation = nodeData?.contractIdRelation || ''
  131. parentId = contractIdRelation ? nodeData?.primaryKeyId : nodeData?.id
  132. primaryKeyId = nodeData?.id || ''
  133. }
  134. //获取数据
  135. const { data } = await queryApi.queryWbsTreeData({
  136. contractId: contractId.value || '',
  137. contractIdRelation,
  138. primaryKeyId,
  139. parentId,
  140. classifyType: classifyType.value,
  141. })
  142. resolve(getArrValue(data))
  143. }
  144. //树被点击
  145. const wbsElTreeClick = ({ node, data, keys }) => {
  146. nodeItemInfo.value = node
  147. nodeDataInfo.value = data
  148. primaryKeyId.value = data['primaryKeyId'] || ''
  149. //缓存自动展开
  150. treeAutoExpandKeys.value = keys
  151. setStoreValue('wbsTreeExpandKeys', keys)
  152. //改变搜索表单数据
  153. //searchForm.value.wbsId = data['contractIdRelation'] ? data['id'] : data['primaryKeyId']
  154. //searchForm.value.contractIdRelation = data['contractIdRelation']
  155. searchForm.value.current = 1
  156. getTableData()
  157. }
  158. //检测类别
  159. const typeData = ref([
  160. { label: '自检', value: '1' },
  161. { label: '抽检', value: '2' },
  162. { label: '平行试验', value: '3' },
  163. { label: '验证试验', value: '4' },
  164. { label: '中心试验', value: '5' },
  165. ])
  166. //审批状态
  167. const approvalData = ref([
  168. { label: '未上报', value: '1' },
  169. { label: '待审批', value: '2' },
  170. { label: '已审批', value: '3' },
  171. ])
  172. //日期时间被选择
  173. const betweenTime = ref(null)
  174. const betweenTimeUpdate = ({ arr, query }) => {
  175. betweenTime.value = arr
  176. searchForm.value.betweenTime = query
  177. }
  178. //搜索
  179. const searchClick = () => {
  180. searchForm.value.current = 1
  181. getTableData()
  182. }
  183. //分页被点击
  184. const pageChange = ({ current, size }) => {
  185. searchForm.value.current = current
  186. searchForm.value.size = size
  187. getTableData()
  188. }
  189. //表格数据
  190. const tableRef = ref(null)
  191. const tableColumn = ref([
  192. { key: 'key1', name: '报告编号' },
  193. { key: 'key2', name: '工程部位' },
  194. { key: 'key3', name: '试验日期' },
  195. { key: 'key4', name: '样品编号' },
  196. { key: 'key5', name: '生产厂家' },
  197. { key: 'key6', name: '规格型号' },
  198. { key: 'key7', name: '代表数量' },
  199. { key: 'key8', name: '密度(开kg/m3)' },
  200. { key: 'key9', name: '比表面积(m2/kg)' },
  201. { key: 'key10', name: '细度(%)' },
  202. { key: 'key11', name: '标准稠度用水量(%)' },
  203. { key: 'key12', name: '初凝结时间(min)' },
  204. { key: 'key13', name: '终凝结时间(min)' },
  205. { key: 'key14', name: '安定性霍氏夹法' },
  206. { key: 'key15', name: '抗折3D胶砂强度(Mpa)' },
  207. { key: 'key16', name: '抗折28D胶砂强度(Mpa)' },
  208. { key: 'key17', name: '抗压3D胶砂强度(Mpa)' },
  209. { key: 'key18', name: '抗压28D胶砂强度(Mpa)' },
  210. { key: 'key19', name: '试验结果' },
  211. { key: 'key20', name: '检测类型' },
  212. { key: 'key21', name: '检测人' },
  213. ])
  214. //获取数据
  215. const tableLoading = ref(false)
  216. const tableData = ref([])
  217. const getTableData = async () => {
  218. }
  219. //多选
  220. const tableCheckedKeys = ref([])
  221. const tableSelection = (rows) => {
  222. tableCheckedKeys.value = rows.filter((item) => {
  223. return (item ?? '') !== ''
  224. })
  225. }
  226. //删除
  227. const delModalClick = () => {
  228. delMessageV2(async (action, instance, done) => {
  229. if (action === 'confirm') {
  230. instance.confirmButtonLoading = true
  231. //removeContractTreeNode()
  232. instance.confirmButtonLoading = false
  233. done()
  234. } else {
  235. done()
  236. }
  237. })
  238. }
  239. //左右拖动,改变树形结构宽度
  240. const leftWidth = ref(382)
  241. const onmousedown = () => {
  242. const leftNum = isCollapse.value ? 142 : 272
  243. document.onmousemove = (ve) => {
  244. let diffVal = ve.clientX - leftNum
  245. if (diffVal >= 310 && diffVal <= 900) {
  246. leftWidth.value = diffVal
  247. }
  248. }
  249. document.onmouseup = () => {
  250. document.onmousemove = null
  251. document.onmouseup = null
  252. }
  253. }
  254. </script>
  255. <style lang="scss" scoped>
  256. </style>