test-file.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. <template>
  2. <div class="radio-box">
  3. <el-radio-group v-model="fileModalradio" @change="radioChange">
  4. <el-radio :label="1">试验检测</el-radio>
  5. <el-radio :label="2">第三方检测</el-radio>
  6. <el-radio :label="3">外委检测</el-radio>
  7. </el-radio-group>
  8. </div>
  9. <div class="adding-form-dialog-box">
  10. <div class="dialog-tree-box">
  11. <el-scrollbar>
  12. <!-- 试验检测树 -->
  13. <TestTree
  14. v-if="fileModalradio == 1"
  15. :contract-id="contractId"
  16. :project-id="projectId"
  17. :tenant-id="tenant_id"
  18. :wbs-id="wbsTempId"
  19. :wbs-type="wbs_type"
  20. @nodeTap="fileModalElTreeClick"
  21. />
  22. <!-- 第三方树 -->
  23. <ElTree
  24. v-else ref="ElTreeRef2" :data="thirdtreeDatas" :indent="0" :props="thirdElTreeProps"
  25. accordion class="hc-tree-node" highlight-current
  26. node-key="id" @node-click="thirdtreeDatasElTreeClick"
  27. />
  28. </el-scrollbar>
  29. </div>
  30. <div class="dialog-table-box">
  31. <div class="dialog-search">
  32. <div class="w-64 ml-2">
  33. <HcDatePicker :dates="filebetweenTime" clearable @change="filebetweenTimeUpdate" />
  34. </div>
  35. <div class="ml-2">
  36. <el-button type="primary" @click="filesearchClick">
  37. <HcIcon name="search-2" />
  38. <span>搜索</span>
  39. </el-button>
  40. </div>
  41. </div>
  42. <div class="dialog-table">
  43. <HcTable
  44. v-if="fileModalradio == 1" ref="dialogTableRef1" :column="filedialogTableColumn"
  45. :datas="filedialogTableData" :loading="filedialogTableLoading"
  46. is-new :index-style="{ width: 60 }" is-check :check-style="{ width: 29 }"
  47. @selection-change="filedialogTableSelection1"
  48. >
  49. <template #reportNo="{ row }">
  50. <span :class="[row?.isSelectedStatus == 1 ? 'text-green' : '']">{{ row?.reportNo }}</span>
  51. </template>
  52. </HcTable>
  53. <HcTable
  54. v-if="fileModalradio == 2" ref="dialogTableRef2" :column="filedialogTableColumn1"
  55. :datas="filedialogTableData" :loading="filedialogTableLoading"
  56. is-new :index-style="{ width: 60 }" is-check :check-style="{ width: 29 }"
  57. @selection-change="filedialogTableSelection"
  58. >
  59. <template #reportNo="{ row }">
  60. <span :class="[row?.isSelectedStatus === 1 ? 'text-green' : '']">{{ row?.reportNo }}</span>
  61. </template>
  62. <template #status="{ row }">
  63. <span>{{ row?.status == 1 ? '合格' : '不合格' }}</span>
  64. </template>
  65. </HcTable>
  66. <HcTable
  67. v-if="fileModalradio == 3" ref="dialogTableRef" :column="filedialogTableColumn1"
  68. :datas="filedialogTableData" :loading="filedialogTableLoading"
  69. is-new :index-style="{ width: 60 }" is-check :check-style="{ width: 29 }"
  70. @selection-change="filedialogTableSelection"
  71. >
  72. <template #reportNo="{ row }">
  73. <span :class="[row?.isSelectedStatus === 1 ? 'text-green' : '']">{{ row?.reportNo }}</span>
  74. </template>
  75. <template #status="{ row }">
  76. <span>{{ row?.status == 1 ? '合格' : '不合格' }}</span>
  77. </template>
  78. </HcTable>
  79. </div>
  80. <div class="dialog-pages">
  81. <HcPages :pages="filesearchFormPage" @change="filesearchFormPageChange" />
  82. </div>
  83. </div>
  84. </div>
  85. </template>
  86. <script setup>
  87. import { nextTick, onMounted, ref, watch } from 'vue'
  88. import { getArrValue } from 'js-fast-way'
  89. import { getTreeAll } from '~api/tentative/detect'
  90. import thirdApi from '~api/tentative/detect/third'
  91. import samplingApi from '~api/tentative/material/sampling'
  92. import TestTree from './testTree.vue'
  93. const props = defineProps({
  94. projectId: [String, Number],
  95. contractId: [String, Number],
  96. wbsId: [String, Number],
  97. tenantId: [String, Number],
  98. wbsType: [String, Number],
  99. treeId: [String, Number],
  100. })
  101. const projectId = ref(props.projectId)
  102. const contractId = ref(props.contractId)
  103. const wbsTempId = ref(props.wbsId)
  104. const tenant_id = ref(props.tenantId)
  105. const wbs_type = ref(props.wbsType)
  106. const isPrimaryKeyId = ref(props.treeId)
  107. //监听
  108. watch(() => [
  109. props.projectId,
  110. props.contractId,
  111. props.wbsId,
  112. props.tenantId,
  113. props.wbsType,
  114. props.treeId,
  115. ], ([pid, cid, wbs_id, tid, type, treeId]) => {
  116. projectId.value = pid
  117. contractId.value = cid
  118. wbsTempId.value = wbs_id
  119. tenant_id.value = tid
  120. wbs_type.value = type
  121. isPrimaryKeyId.value = treeId
  122. })
  123. const CTDTreeAutoExpandKeys = ref([])
  124. const defaultExpandedCids = ref([])
  125. const ElTreeProps = ref({
  126. label: 'title',
  127. children: 'children',
  128. isLeaf: 'hasChildren',
  129. })
  130. //关联试验文件
  131. const filedialogTableData = ref([])
  132. const fileModalradio = ref(1)
  133. const radioChange = (val) => {
  134. if (val !== 1) {
  135. getthirdTreeDatas(val)
  136. }
  137. }
  138. //获取试验文件树树数据
  139. const fileModaltreeDatas = ref([])
  140. //节点被点击
  141. //节点被点击
  142. const filenodeItemInfo = ref({})
  143. const filenodeDataInfo = ref({})
  144. const fileTableData1 = ref([])
  145. const fileTableColumn = ref([
  146. { key: 'recordNo', name: '报告编号' },
  147. { key: 'reportDate', name: '报告日期' },
  148. { key: 'projectPositionName', name: '工程用途及部位' },
  149. { key: 'detectionResultName', name: '检测结果' },
  150. ])
  151. const fileModalElTreeClick = async ({ data, node }) => {
  152. filenodeItemInfo.value = node
  153. filenodeDataInfo.value = data
  154. getfileNodeData()
  155. }
  156. //获取第三方树试验文件
  157. //获取树数据
  158. const thirdtreeDatas = ref([])
  159. const thirdElTreeProps = ref({
  160. label: 'nodeName',
  161. children: 'children',
  162. isLeaf: function (data) {
  163. return !data.hasChildren
  164. },
  165. })
  166. const getthirdTreeDatas = async (type) => {
  167. const { error, code, data } = await getTreeAll({
  168. projectId: projectId.value,
  169. contractId: contractId.value,
  170. })
  171. if (!error && code === 200) {
  172. if (type == 2) {
  173. thirdtreeDatas.value = getArrValue(data['rightTree'])
  174. } else {
  175. thirdtreeDatas.value = getArrValue(data['leftTree'])
  176. }
  177. } else {
  178. thirdtreeDatas.value = []
  179. }
  180. }
  181. const thirdfilenodeItemInfo = ref({})
  182. const thirdfilenodeDataInfo = ref({})
  183. //获取第三方树节点下的数据
  184. const getthirdTreetavleDatas = async () => {
  185. filedialogTableLoading.value = true
  186. const { error, code, data } = await thirdApi.queryPage({
  187. projectId: projectId.value,
  188. contractId: contractId.value,
  189. nodeId: thirdfilenodeDataInfo.value.id,
  190. current: filesearchFormPage.value.current,
  191. size: filesearchFormPage.value.size,
  192. startTime: filesearchFormPage.value.startTime,
  193. endTime: filesearchFormPage.value.lastTime,
  194. qualityTestPKeyId: isPrimaryKeyId.value,
  195. })
  196. //处理数据
  197. if (!error && code === 200) {
  198. filedialogTableData.value = getArrValue(data['records'])
  199. filesearchFormPage.value.total = data.total || 0
  200. filedialogTableLoading.value = false
  201. if (filedialogTableData.value.length > 0) {
  202. let defaultarr = []
  203. filedialogTableData.value.forEach((item) => {
  204. if (item.isSelectedStatus === 1) {
  205. defaultarr.push(item)
  206. }
  207. if (fileModalradio.value === 2) {
  208. outtabtoggleSelection(defaultarr)
  209. } else {
  210. thirdtabtoggleSelection(defaultarr)
  211. }
  212. })
  213. }
  214. } else {
  215. filedialogTableData.value = []
  216. filesearchFormPage.value.total = 0
  217. filesearchFormPage.value = false
  218. }
  219. filedialogTableLoading.value = false
  220. }
  221. const thirdtreeDatasElTreeClick = (data, node) => {
  222. thirdfilenodeItemInfo.value = node
  223. thirdfilenodeDataInfo.value = data
  224. getthirdTreetavleDatas()
  225. }
  226. const filebetweenTime = ref([])
  227. const filesearchFormPage = ref({
  228. startTime: null, lastTime: null, wbsId: null, current: 1, size: 20, total: 0,
  229. })
  230. const filesearchFormPageChange = ({ current, size }) => {
  231. filesearchFormPage.value.current = current
  232. filesearchFormPage.value.size = size
  233. // getDialogTableData()
  234. }
  235. const filebetweenTimeUpdate = ({ arr }) => {
  236. filebetweenTime.value = arr
  237. filesearchFormPage.value.startTime = arr[0]
  238. filesearchFormPage.value.lastTime = arr[1]
  239. }
  240. const filesearchClick = () => {
  241. filesearchFormPage.value.current = 1
  242. getfileNodeData()
  243. }
  244. const filedialogTableLoading = ref(false)
  245. const filedialogTableColumn = ref([
  246. // reportNo
  247. { key: 'reportNo', name: '报告编号' },
  248. { key: 'reportDate', name: '报告日期' },
  249. { key: 'projectPositionName', name: '工程用途及部位' },
  250. { key: 'detectionResultName', name: '检测结果' },
  251. ])
  252. const filedialogTableColumn1 = ref([
  253. // reportNo
  254. { key: 'reportNo', name: '报告编号' },
  255. { key: 'reportDate', name: '报告日期' },
  256. { key: 'projectPosition', name: '工程用途及部位' },
  257. { key: 'status', name: '检测结果' },
  258. ])
  259. //多选
  260. const filetableCheckedKeys = ref([])
  261. const filedialogTableSelection1 = (rows) => {
  262. filetableCheckedKeys.value = rows.filter((item) => {
  263. return (item ?? '') !== ''
  264. })
  265. }
  266. const filedialogTableSelection = (rows) => {
  267. filetableCheckedKeys.value = rows.filter((item) => {
  268. return (item ?? '') !== ''
  269. })
  270. }
  271. //试验文件节点下的数据
  272. const getfileNodeData = async () => {
  273. //获取数据
  274. filedialogTableLoading.value = true
  275. const { error, code, data } = await samplingApi.gettrialPage({
  276. contractId: contractId.value,
  277. nodeId: filenodeDataInfo.value.primaryKeyId,
  278. current: filesearchFormPage.value.current,
  279. size: filesearchFormPage.value.size,
  280. startTime: filesearchFormPage.value.startTime,
  281. endTime: filesearchFormPage.value.lastTime,
  282. qualityTestPKeyId: isPrimaryKeyId.value,
  283. })
  284. //处理数据
  285. if (!error && code === 200) {
  286. filedialogTableData.value = getArrValue(data['records'])
  287. filesearchFormPage.value.total = data.total || 0
  288. filedialogTableLoading.value = false
  289. let defaultarr = []
  290. filedialogTableData.value.forEach((item) => {
  291. if (item.isSelectedStatus === 1) {
  292. defaultarr.push(item)
  293. }
  294. tabtoggleSelection(defaultarr)
  295. })
  296. } else {
  297. filedialogTableData.value = []
  298. filesearchFormPage.value.total = 0
  299. filesearchFormPage.value = false
  300. }
  301. }
  302. const dialogTableRef = ref(null)
  303. const dialogTableRef1 = ref(null)
  304. const dialogTableRef2 = ref(null)
  305. const tabtoggleSelection = (rows) => {
  306. if (rows) {
  307. rows.forEach(row => {
  308. nextTick(() => {
  309. dialogTableRef1.value?.toggleRowSelection(row, true)
  310. })
  311. })
  312. } else {
  313. dialogTableRef1.value?.clearSelection()
  314. }
  315. }
  316. //确认关联试验文件
  317. const savefileSubmit = async () => {
  318. const idarr = []
  319. filetableCheckedKeys.value.forEach((item) => {
  320. idarr.push(item.id)
  321. })
  322. const idval = idarr.join(',')
  323. await savesubmitRelationFile(idval)
  324. }
  325. //关联试验文件
  326. const savesubmitRelationFile = async (ids) => {
  327. const { error, code, data } = await samplingApi.submitRelationFile({
  328. projectId: projectId.value,
  329. contractId: contractId.value,
  330. nodeId: isPrimaryKeyId.value,
  331. type: fileModalradio.value,
  332. ids,
  333. })
  334. if (!error && code === 200) {
  335. window?.$message?.success('操作成功')
  336. }
  337. }
  338. // 暴露出去
  339. defineExpose({
  340. savefileSubmit,
  341. })
  342. </script>
  343. <style lang="scss">
  344. </style>