test-form-bak.vue 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465
  1. <template>
  2. <div class="hc-page-box">
  3. <HcNewCard action-ui="text-center">
  4. <template #header>
  5. <el-button :type="authBtnTabKey === '1' ? 'primary' : ''" hc-btn :disabled="router.currentRoute.value.query?.id && router.currentRoute.value.query?.id.length > 0 || nodeIdvalue.length > 0 || newId.length > 0" @click="authBtnTabClick('1')">
  6. <HcIcon name="folder-user" />
  7. <span>施工自检</span>
  8. </el-button>
  9. <el-button :type="authBtnTabKey === '2' ? 'primary' : ''" hc-btn :disabled="router.currentRoute.value.query?.id && router.currentRoute.value.query?.id.length > 0 || nodeIdvalue.length > 0 || newId.length > 0" @click="authBtnTabClick('2')">
  10. <HcIcon name="folder-shield" />
  11. <span>监理质检</span>
  12. </el-button>
  13. </template>
  14. <template #extra>
  15. <el-button :disabled="listItemData.length <= 0" hc-btn type="primary" @click="linksRelateModalClick">
  16. 关联工程用途及部位
  17. </el-button>
  18. <el-button
  19. :disabled="!isMixRatioTestIds" :type="isMixRatioTestIds ? 'primary' : ''" hc-btn
  20. @click="linksRawModalClick"
  21. >
  22. 关联原材检测报告
  23. </el-button>
  24. <el-button hc-btn type="primary" @click="linksSampleModalClick">关联取样</el-button>
  25. </template>
  26. <template #search>
  27. <div class="flex-1">
  28. <HcNewSwitch :datas="tabTypeTab" :keys="tabTypeKey" :round="false" size="default" @change="tabTypeChange" />
  29. </div>
  30. <div class="hc-search-top-form">
  31. <div class="w-40">
  32. <el-input v-model="listItemBaseData.trialUserName" clearable placeholder="请输入试验人员" />
  33. </div>
  34. <div v-if="tabTypeKey === '2'" class="w-36 ml-2">
  35. <el-date-picker
  36. v-model="listItemBaseData.reportDate" :clearable="false" class="block"
  37. placeholder="请选择报告日期" type="date" value-format="YYYY-MM-DD"
  38. />
  39. </div>
  40. <div v-if="tabTypeKey === '2'" class="w-28 ml-2">
  41. <el-select v-model="listItemBaseData.detectionResult" block placeholder="是否合格">
  42. <el-option label="合格" value="1" />
  43. <el-option label="不合格" value="0" />
  44. </el-select>
  45. </div>
  46. <div class="w-36 ml-2">
  47. <el-select v-model="listItemBaseData.detectionCategory" block placeholder="选择检测类型">
  48. <el-option v-for="item in categoryData" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
  49. </el-select>
  50. </div>
  51. </div>
  52. </template>
  53. <!-- 清表列表 -->
  54. <el-scrollbar v-if="listItemData.length > 0" ref="ListItemScrollRef" v-loading="isLoadList">
  55. <CollapseForm
  56. ref="ListItemRef"
  57. :node-status="NodeStatus"
  58. :alllist-data="alllistData"
  59. :auth-btn-tab-key="authBtnTabKey"
  60. :base-data="listItemBaseData"
  61. :datas="listItemData"
  62. :device-use-ids="listDeviceUseIds"
  63. :node-idvalue="nodeIdvalue"
  64. :status="1"
  65. :tab-type-key="tabTypeKey"
  66. @chageorin-data="chageorinData"
  67. @change-iscanclick="changeIscanclick"
  68. @changesdate="changeorinsdate"
  69. @changesing-save-id="changesingSaveId"
  70. @offset-top="ListItemOffsetTop"
  71. @renew="getTableDataAll"
  72. @upcheck-table-id="upcheckTableId"
  73. @updevice-use-ids="updeviceUseIds"
  74. />
  75. </el-scrollbar>
  76. <HcStatus v-else v-loading="isLoadList" text="暂无表单" />
  77. <template #action>
  78. <div class="hc-table-form-action-tip">
  79. <el-alert
  80. :closable="false"
  81. class="hc-alert"
  82. show-icon
  83. style=""
  84. title="完善资料填写后记得一定要保存哦"
  85. type="warning"
  86. />
  87. </div>
  88. <el-button
  89. :disabled="NodeStatus === '3' || listItemData.length <= 0" :loading="tableFormSaveLoading"
  90. hc-btn
  91. type="primary" @click="tableFormSaveClick"
  92. >
  93. <HcIcon name="save" />
  94. <span>保存</span>
  95. </el-button>
  96. <el-button
  97. :disabled="NodeStatus === '3' || NodeStatus === '1'" :loading="reportLoading" hc-btn
  98. @click="reportModalClick"
  99. >
  100. <HcIcon name="send-plane-2" />
  101. <span>上报</span>
  102. </el-button>
  103. <!-- <el-button hc-btn :loading="reportLoading" @click="reportModalClick" >
  104. <HcIcon name="send-plane-2"/>
  105. <span>上报</span>
  106. </el-button> -->
  107. <el-button
  108. :disabled="NodeStatus === '1'" :loading="bussPdfsLoading" hc-btn
  109. @click="bussPdfsClick(router.currentRoute.value.query.id || nodeIdvalue)"
  110. >
  111. <HcIcon name="eye" />
  112. <span>预览</span>
  113. </el-button>
  114. <el-button v-if="NodeStatus === '3'" hc-btn @click="abolishOneClick">
  115. <HcIcon name="arrow-go-back" />
  116. <span>撤回上报流程</span>
  117. </el-button>
  118. <el-button hc-btn @click="toBackClick">
  119. <HcIcon name="delete-back" />
  120. <span>返回</span>
  121. </el-button>
  122. </template>
  123. </HcNewCard>
  124. <!-- 关联工程用途及部位 -->
  125. <hc-new-dialog v-model="linksRelateModal" is-table save-text="确认关联" title="关联工程用途及部位" widths="50rem" @close="linksRelateModalClose" @save="linksRelateModalSave">
  126. <div class="hc-links-relate-tree-box">
  127. <div class="hc-search-tree-val">
  128. <el-input
  129. v-model="linksRelateSearchTreeVal" block clearable placeholder="请输入名称关键词检索"
  130. size="large" @keyup="searchTreeKeyUp"
  131. >
  132. <template #suffix>
  133. <HcIcon name="search-2" ui="text-xl" @click="searchTreeClick" />
  134. </template>
  135. </el-input>
  136. </div>
  137. <div v-loading="linksRelateTreeLoading" class="hc-tree-scrollbar" element-loading-text="获取数据中...">
  138. <el-scrollbar>
  139. <!-- <DivisionTree :datas="unmatchedTreeData" @nodeTap="divisionTreeClick" @nodeCheck="divisionTreeCheck" :defaultCheckarr="defaultCheckarrIds"/> -->
  140. <!-- <DivisionTree1
  141. v-show="isSearchTree"
  142. :ElTreeProps="seaElTreeProps"
  143. :datas="searchTreeData"
  144. :defaultCheckarr="defaultCheckarrIds"
  145. :defaultExpandAll="true"
  146. :divisionLoading="searchlinksRelateTreeLoading"
  147. @nodeCheck="divisionTreeCheck"
  148. @nodeTap="divisionTreeClick"/>
  149. <DivisionTree
  150. v-show="!isSearchTree"
  151. ref="divisionTree"
  152. :datas="unmatchedTreeData"
  153. :defaultCheckarr="defaultCheckarrIds"
  154. :divisionLoading="isdivisionLoading"
  155. :linksRelateSearchTreeVal="linksRelateSearchTreeVal"
  156. @nodeCheck="divisionTreeCheck"
  157. @nodeTap="divisionTreeClick"
  158. /> -->
  159. <HcLazyTree
  160. ref="ElTreeRef"
  161. :h-props="treeProps"
  162. show-checkbox
  163. :check-strictly="true"
  164. :default-checked-keys="defaultCheckarrIds"
  165. @load="treeLoadNode"
  166. @node-tap="divisionTreeClick"
  167. @check="divisionTreeCheck"
  168. />
  169. </el-scrollbar>
  170. </div>
  171. </div>
  172. </hc-new-dialog>
  173. <!-- 关联原材检测报告 -->
  174. <hc-new-dialog v-model="linksRawModal" is-table save-text="确认关联" title="关联原材检测报告" widths="75rem" @close="linksRawModalClose" @save="linksRawModalSave">
  175. <div class="hc-links-sample-modal-box">
  176. <div class="hc-links-sample-tree-box">
  177. <el-scrollbar>
  178. <TestTreeMaterial
  179. :mix-ratio-test-tree-data="MixRatioTestTreeData" :from-type="true"
  180. :node-id="nodeId" :project-id="projectId" :tenant-id="userInfo?.tenant_id"
  181. :wbs-temp-id="projectInfo?.referenceWbsTemplateIdTrial" :wbs-type="2"
  182. @node-tap="linksRawTreeClick"
  183. />
  184. </el-scrollbar>
  185. </div>
  186. <div class="hc-links-sample-table-box">
  187. <HcTable
  188. ref="tableRawRef" :column="linksRawTableColumn" :datas="linksRawTableData"
  189. :is-index="false" :loading="linksRawTableLoading" is-new is-check :check-style="{ width: 29 }"
  190. @selection-change="linksRawTableSelection"
  191. />
  192. </div>
  193. </div>
  194. </hc-new-dialog>
  195. <!-- 关联取样 -->
  196. <hc-new-dialog v-model="linksSampleModal" is-table save-text="确认" title="关联取样信息" widths="75rem" @close="linksSampleModalClose" @save="linksSampleModalSave">
  197. <div class="hc-links-sample-modal-box">
  198. <div class="hc-links-sample-tree-box">
  199. <el-scrollbar>
  200. <TestTree
  201. :project-id="projectId" :tenant-id="userInfo?.tenant_id"
  202. :wbs-temp-id="projectInfo?.referenceWbsTemplateIdTrial" :wbs-type="2"
  203. @node-tap="linksSampleTreeClick"
  204. />
  205. </el-scrollbar>
  206. </div>
  207. <div class="hc-links-sample-table-box">
  208. <HcTable
  209. ref="tableSampleRef" :column="linksSampleTableColumn" :datas="linksSampleTableData"
  210. :is-index="false" :loading="linksSampleTableLoading" is-new is-check :check-style="{ width: 29 }"
  211. @selection-change="linksSampleTableSelection"
  212. />
  213. </div>
  214. </div>
  215. </hc-new-dialog>
  216. <!-- 批量上报审批 -->
  217. <HcReportModal
  218. :classify-type="authBtnTabKey"
  219. :addition="reportAddition" :contract-id="contractId" :ids="reportIds"
  220. :project-id="projectId" :show="showReportModal" :task-name="reportTaskName"
  221. :trial-self-inspection-record-id="dataId.length > 0 ? dataId : nodeIdvalue"
  222. :type-data="reportTypeData" title="批量上报审批" type="wbs"
  223. url="informationWriteQuery/taskOne" @finish="showReportFinish"
  224. @hide="showReportModal = false"
  225. />
  226. </div>
  227. </template>
  228. <script setup>
  229. import { nextTick, onDeactivated, onMounted, ref, watch } from 'vue'
  230. import { useAppStore } from '~src/store'
  231. import { useRoute, useRouter } from 'vue-router'
  232. import CollapseForm from './collapse-form/src/index.vue'
  233. import ListItem from './components/ListItem.vue'
  234. import DivisionTree from './components/DivisionTree.vue'
  235. import DivisionTree1 from './components/DivisionTree1.vue'
  236. import dataApi from '~api/tentative/detect/test'
  237. import samplingApi from '~api/tentative/material/sampling'
  238. import divisionApi from '~api/data-fill/division'
  239. import queryApi from '~api/data-fill/query'
  240. import { getStoreValue, setStoreValue } from '~src/utils/storage'
  241. import TestTree from '../material/components/TestTree.vue'
  242. import TestTreeMaterial from '../material/components/TestTreeMaterial.vue'
  243. import { arrToId, getArrValue, getObjValue, isString } from 'js-fast-way'
  244. import { getDictionary } from '~api/other'
  245. import dayjs from 'dayjs'
  246. import { Loading } from 'element-plus/es/components/loading/src/service'
  247. import { eVisaTaskCheckApi } from '~api/other'
  248. import wbsApi from '~api/data-fill/wbs'
  249. import { toPdfPage } from '~uti/btn-auth'
  250. //变量
  251. const router = useRouter()
  252. const useRoutes = useRoute()
  253. const useAppState = useAppStore()
  254. const userInfo = ref(useAppState.getUserInfo)
  255. const projectId = ref(useAppState.getProjectId)
  256. const contractId = ref(useAppState.getContractId)
  257. const projectInfo = ref(useAppState.getProjectInfo)
  258. const contractInfo = ref(useAppState.getContractInfo)
  259. const divisionTree = ref(null)
  260. //获取模板标签数据
  261. const isTableForm = ref(false)
  262. //路由参数
  263. const routerQuery = useRoutes?.query
  264. //存储目录格式 1按部位存储,2按日期存储
  265. const dataId = routerQuery?.id || ''
  266. const nodeId = routerQuery?.nodeId || ''
  267. const dataType = routerQuery?.dataType || '1'
  268. let isaddType = routerQuery?.isaddType || false
  269. const afterAdd = ref(false)
  270. const dayDate = dayjs().format('YYYY-MM-DD')
  271. const testTreeItem = ref(getStoreValue('testTreeItem'))
  272. const isMixRatioTestIds = ref(false)
  273. const tabTypeKey = ref('')
  274. const isopersampleIds = ref(false)
  275. //渲染完成
  276. onMounted(() => {
  277. tabTypeKey.value = routerQuery?.tabTypeKey || '1'
  278. const { title, mixRatioTestIds } = getObjValue(testTreeItem.value)
  279. const info = getStoreValue('test-form') || {}
  280. isMixRatioTestIds.value = !(!mixRatioTestIds || mixRatioTestIds <= 0)
  281. listItemBaseData.value.contractId = contractId.value
  282. listItemBaseData.value.trialProjectName = title
  283. listItemBaseData.value.reportDate = dayDate
  284. // listItemBaseData.value.detectionCategory = Number(dataType)
  285. listItemBaseData.value.detectionCategory = info.detectionCategory || 1
  286. listItemBaseData.value.trialUserName = info.trialUserName || (userInfo.value['nick_name'])
  287. listItemBaseData.value.projectPosition = info.projectPosition || ''
  288. listItemBaseData.value.rawMaterialIds = info.rawMaterialIds || ''
  289. listItemBaseData.value.sampleIds = info.sampleIds || ''
  290. if (info && info.detectionResult) {
  291. listItemBaseData.value.detectionResult = info.detectionResult.toString()
  292. }
  293. if (info && info.projectPosition) {
  294. defaultCheckarrIds.value = info.projectPosition.split(',')
  295. defaultprojectPositionName.value = info?.projectPositionName
  296. }
  297. getSearchNodeTables()
  298. getSearchNodeTablesall(1)
  299. getSearchNodeTablesall(2)
  300. getCategoryData()
  301. })
  302. onDeactivated(() => {
  303. // 更新内容
  304. setTimeout(() => {
  305. window?.location?.reload() //刷新页面
  306. }, 1000)
  307. })
  308. //身份按钮切换数据
  309. const authBtnTabKey = ref(dataType)
  310. const authBtnTabClick = (val) => {
  311. if (val !== authBtnTabKey.value) {
  312. authBtnTabKey.value = val
  313. listItemBaseData.value.type = val
  314. listItemBaseData.value.detectionCategory = Number(val)
  315. getSearchNodeTables()
  316. }
  317. }
  318. //类型tab数据和相关处理
  319. const leftFormData = ref([])
  320. const rightFormData = ref([])
  321. const allFormData = ref([])
  322. const tabTypeTab = ref([
  323. { key: '1', name: '记录表' },
  324. { key: '2', name: '报告单' },
  325. ])
  326. const tabTypeChange = ({ key }) => {
  327. // console.log(ListItemRef.value?.getFormData(),'ListItemRef.value?.getFormData()');
  328. tabTypeKey.value = key
  329. let curform = ListItemRef.value?.getFormData()
  330. setAllListData(curform)
  331. if (listItemBaseData.value.detectionResult === '' && tabTypeKey.value == 2) {
  332. window.$message?.warning('请选择报告单是否合格')
  333. }
  334. // if(tabTypeKey.value==='2'){
  335. // leftFormData.value=ListItemRef.value?.getFormData()
  336. // }else{
  337. // rightFormData.value=ListItemRef.value?.getFormData()
  338. // }
  339. getSearchNodeTables()
  340. }
  341. //获取检测类别类型
  342. const categoryData = ref([])
  343. const getCategoryData = async () => {
  344. const { data } = await getDictionary({
  345. code: 'trial_detection_category',
  346. })
  347. const arrData = getArrValue(data)
  348. arrData.forEach(item => {
  349. item.dictKey = Number(item.dictKey)
  350. })
  351. categoryData.value = arrData
  352. }
  353. //顶部表单
  354. const ListItemRef = ref(null)
  355. const listItemBaseData = ref({
  356. sampleIds: '', contractId: null, nodeId: nodeId, trialProjectName: null, type: dataType, tableType: '1',
  357. detectionCategory: '', detectionResult: '', reportDate: '', trialUserName: '', id: dataId,
  358. })
  359. const listItemData = ref([])
  360. const isLoadList = ref(false)
  361. const listDeviceUseIds = ref('')
  362. const reportData = ref([])
  363. const testData = ref([])
  364. const alllistData = ref([])
  365. const orgAlllistData = ref([])
  366. const getSearchNodeTables = async (newaddId) => {
  367. isLoadList.value = true
  368. const isid = dataId.length > 0 ? dataId : nodeIdvalue.value || newaddId || ''
  369. if (isaddType) {
  370. const { error, code, data } = await dataApi.searchNodeTables({
  371. id: dataId.length > 0 ? dataId : nodeIdvalue.value || newaddId,
  372. projectId: projectId.value,
  373. contractId: contractId.value,
  374. primaryKeyId: nodeId,
  375. type: authBtnTabKey.value,
  376. tableType: tabTypeKey.value,
  377. // isAdd: 1
  378. isAdd: isid.length > 0 ? '' : 1,
  379. })
  380. //处理数据
  381. if (!error && code === 200) {
  382. listItemData.value = getArrValue(data)
  383. listItemData.value.forEach((item) => {
  384. if (item.pKeyId === singSaveId.value) {
  385. item.isCancopy = true
  386. }
  387. },
  388. )
  389. // console.log( listItemData.value,' listItemData.value');
  390. // defaultCheckarrIds.value= listItemData.value.projectPosition.join(',')
  391. } else {
  392. listItemData.value = []
  393. }
  394. isLoadList.value = false
  395. } else {
  396. queryNodeStatus()//查询按钮状态
  397. const { error, code, data } = await dataApi.searchNodeTables({
  398. id: dataId.length > 0 ? dataId : nodeIdvalue.value,
  399. projectId: projectId.value,
  400. contractId: contractId.value,
  401. primaryKeyId: nodeId,
  402. type: authBtnTabKey.value,
  403. tableType: tabTypeKey.value,
  404. })
  405. //处理数据
  406. if (!error && code === 200) {
  407. listItemData.value = getArrValue(data)
  408. listItemData.value.forEach((item) => {
  409. if (item.pKeyId === singSaveId.value) {
  410. item.isCancopy = true
  411. }
  412. },
  413. )
  414. } else {
  415. listItemData.value = []
  416. }
  417. isLoadList.value = false
  418. }
  419. }
  420. const getSearchNodeTablesall = async (type, newaddId) => {
  421. orgAlllistData.value = []
  422. const isid = dataId.length > 0 ? dataId : nodeIdvalue.value || newaddId || ''
  423. const { error, code, data } = await dataApi.searchNodeTables({
  424. id: dataId.length > 0 ? dataId : nodeIdvalue.value || newaddId,
  425. projectId: projectId.value,
  426. contractId: contractId.value,
  427. primaryKeyId: nodeId,
  428. type: authBtnTabKey.value,
  429. tableType: type,
  430. // isAdd: 1
  431. // isAdd: isaddType ? 1 : ''
  432. isAdd: isid.length > 0 ? '' : 1,
  433. })
  434. //处理数据
  435. if (!error && code === 200) {
  436. // listItemData.value = getArrValue(data)
  437. if (type === 1) {
  438. testData.value = getArrValue(data)
  439. testData.value.forEach((item) => {
  440. let bussDataInfoTrialData = item.bussDataInfoTrial
  441. if (bussDataInfoTrialData && Object.keys(bussDataInfoTrialData).length !== 0) {
  442. for (var key in bussDataInfoTrialData) {
  443. item[key] = bussDataInfoTrialData[key]
  444. }
  445. }
  446. orgAlllistData.value.push(item)
  447. })
  448. } else {
  449. reportData.value = getArrValue(data)
  450. reportData.value.forEach((item) => {
  451. let bussDataInfoTrialData = item.bussDataInfoTrial
  452. if (bussDataInfoTrialData && Object.keys(bussDataInfoTrialData).length !== 0) {
  453. for (let key in bussDataInfoTrialData) {
  454. item[key] = bussDataInfoTrialData[key]
  455. }
  456. }
  457. orgAlllistData.value.push(item)
  458. })
  459. }
  460. } else {
  461. // listItemData.value = []
  462. // eslint-disable-next-line eqeqeq
  463. if (type == 1) {
  464. testData.value = []
  465. alllistData.value = []
  466. } else {
  467. reportData.value = []
  468. alllistData.value = []
  469. }
  470. }
  471. }
  472. //改变原始数据复制隐藏本表的状态
  473. const newId = ref('')
  474. //获取数据
  475. const getTableDataAll = (newaddId) => {
  476. newId.value = newaddId
  477. getSearchNodeTables(newaddId)
  478. queryNodeStatus(newaddId)
  479. getSearchNodeTablesall(1, newaddId)
  480. getSearchNodeTablesall(2, newaddId)
  481. }
  482. //隐藏显示本表改变原始数据
  483. const changeorinsdate = (pKeyId, isBussShow) => {
  484. orgAlllistData.value.forEach((item) => {
  485. if (item.pKeyId === pKeyId) {
  486. const isBussShows = isBussShow === 2 ? 1 : 2 //状态(1显示 2隐藏)
  487. item.isBussShow = isBussShows
  488. }
  489. })
  490. console.log(orgAlllistData.value, ' orgAlllistData.value')
  491. }
  492. //复制本表改变原始数据
  493. const chageorinData = () => {
  494. getSearchNodeTablesall(1)
  495. getSearchNodeTablesall(2)
  496. }
  497. //设置滚动条位置
  498. const ListItemScrollRef = ref(null)
  499. const ListItemOffsetTop = (offsetTop) => {
  500. if (offsetTop > 0) {
  501. setTimeout(() => {
  502. ListItemScrollRef.value?.setScrollTop(offsetTop)
  503. }, 350)
  504. } else {
  505. ListItemScrollRef.value?.setScrollTop(offsetTop)
  506. }
  507. }
  508. const checkTabId = ref('')
  509. const upcheckTableId = (val) => {
  510. checkTabId.value = val
  511. }
  512. const singSaveId = ref('')
  513. const iscanclick = ref(true)
  514. const changeIscanclick = () => {
  515. iscanclick.value = false
  516. }
  517. const changesingSaveId = (id) => {
  518. singSaveId.value = id
  519. }
  520. //关联工程用途及部位 树
  521. const linksRelateModal = ref(false)
  522. const linksRelateModalClick = () => {
  523. linksRelateModal.value = true
  524. linksRelateSearchTreeVal.value = ''
  525. getContractInfoTreeApi()
  526. }
  527. //获取导入树
  528. const unmatchedTreeData = ref([])
  529. const defaultCheckarrIds = ref([])
  530. const defaultprojectPositionName = ref('')
  531. const isdivisionLoading = ref(false)
  532. const getContractInfoTreeApi = async () => {
  533. isdivisionLoading.value = true
  534. const { error, code, data } = await divisionApi.getengineerInfoTree1({
  535. projectId: projectId.value,
  536. contractId: contractId.value,
  537. wbsId: projectInfo?.value.referenceWbsTemplateId,
  538. selfId: dataId,
  539. })
  540. //判断状态
  541. if (!error && code === 200) {
  542. unmatchedTreeData.value = getArrValue(data['treeContractAll'])
  543. searchTreeData.value = getArrValue(data['treeContractAll'])
  544. setStoreValue('unmatchedTreeData', unmatchedTreeData.value)
  545. // defaultCheckarrIds.value=getArrValue(data['isSelectedStatus'])
  546. checkrelationId.value = getArrValue(data['isSelectedStatus'])
  547. } else {
  548. unmatchedTreeData.value = []
  549. }
  550. isdivisionLoading.value = false
  551. }
  552. //关联树
  553. const divisionTreeItemInfo = ref({})
  554. const divisionTreeClick = ({ data }) => {
  555. divisionTreeItemInfo.value = data
  556. }
  557. const checkrelationId = ref([])
  558. const checkrelationString = ref([])
  559. const ElTreeRef = ref(null)
  560. const divisionTreeCheck = (data1, data2) => {
  561. checkrelationId.value = data2?.checkedNodes
  562. }
  563. const seaElTreeProps = ref({
  564. label: 'fullName',
  565. children: 'children',
  566. })
  567. const linksRelateSearchTreeVal = ref('')
  568. // watch(tabTypeKey, (val) => {
  569. // if(val){
  570. // console.log(val);
  571. // if (val==='1') {
  572. // leftFormData.value=ListItemRef.value?.getFormData()
  573. // }else{
  574. // rightFormData.value= ListItemRef.value?.getFormData()
  575. // }
  576. // }
  577. // },
  578. // )
  579. watch(linksRelateSearchTreeVal, (val) => {
  580. if (!val.length) {
  581. isSearchTree.value = !isSearchTree.value
  582. }
  583. },
  584. )
  585. const linksRelateTreeLoading = ref(false)
  586. const searchTreeData = ref([])
  587. const searchlinksRelateTreeLoading = ref(false)
  588. const searchTreeKeyUp = (e) => {
  589. if (e.key === 'Enter') {
  590. searchTreeClick()
  591. }
  592. }
  593. //树搜索
  594. const isSearchTree = ref(false)
  595. const searchTreeClick = async () => {
  596. if (linksRelateSearchTreeVal.value) {
  597. nextTick(() => {
  598. isSearchTree.value = false
  599. })
  600. // const {error, code, data} = await queryApi.searchContractTree({
  601. // contractId: contractId.value,
  602. // queryValue: linksRelateSearchTreeVal.value
  603. // })
  604. // //判断状态
  605. // if (!error && code === 200) {
  606. // searchlinksRelateTreeLoading.value = false
  607. // } else {
  608. // searchlinksRelateTreeLoading.value = false
  609. // searchTreeData.value = []
  610. // }
  611. }
  612. }
  613. const positiondata = ref([])
  614. //确认关联
  615. const linksRelateModalSave = async () => {
  616. let idarr = []
  617. checkrelationId.value.forEach((item) => {
  618. idarr.push(item.primaryKeyId)
  619. })
  620. checkrelationString.value = idarr.toString()
  621. console.log(checkrelationString.value, 'checkrelationString.value')
  622. listItemBaseData.value.projectPosition = checkrelationString.value
  623. let infodata = await getpositiondata()
  624. positiondata.value = infodata
  625. ListItemRef.value.changePositionInput(infodata)
  626. if (infodata.length > 0) {
  627. window.$message?.success('操作成功')
  628. linksRelateModal.value = false
  629. }
  630. linksRelateModal.value = false
  631. }
  632. const linksRelateModalClose = () => {
  633. linksRelateModal.value = false
  634. }
  635. //关联原材检测报告
  636. const linksRawModal = ref(false)
  637. const MixRatioTestTreeData = ref([])
  638. const linksRawModalClick = () => {
  639. linksRawModal.value = true
  640. getTreeData()
  641. }
  642. const getTreeData = async (node, reslove) => {
  643. const { error, code, data } = await samplingApi.getMixRatioTestTree({
  644. pKeyId: nodeId,
  645. })
  646. MixRatioTestTreeData.value = getArrValue(data)
  647. }
  648. const linkNodeid = ref('')
  649. //树被点击
  650. const linksRawTreeClick = ({ data }) => {
  651. linkNodeid.value = data.pKeyId
  652. getrawMaterialList()
  653. }
  654. //原材检测报告数据
  655. const tableRawRef = ref(null)
  656. const linksRawTableColumn = ref([
  657. { key: 'reportNo', name: '报告编号' },
  658. { key: 'trialProjectName', name: '试验项目名称' },
  659. { key: 'projectPositionName', name: '工程部位及用途' },
  660. { key: 'reportDate', name: '报告日期' },
  661. ])
  662. const linksRawTableData = ref([])
  663. const linksRawTableLoading = ref(false)
  664. //多选
  665. const tableRawCheckedKeys = ref([])
  666. const tableRawCheckedKeysid = ref('')
  667. const linksRawTableSelection = (rows) => {
  668. tableRawCheckedKeys.value = rows
  669. let arr = []
  670. tableRawCheckedKeys.value.forEach((item) => {
  671. arr.push(item.id)
  672. })
  673. tableRawCheckedKeysid.value = arr.join()
  674. }
  675. const linksRawModalSave = async () => {
  676. linksRawModal.value = false
  677. listItemBaseData.value.rawMaterialIds = tableRawCheckedKeysid.value
  678. window.$message?.success('操作成功')
  679. // const { error, code, data } = await dataApi.rawMaterialSubmit({
  680. // id: dataId,
  681. // ids:tableRawCheckedKeysid.value,
  682. // projectId: projectId.value,
  683. // contractId: contractId.value,
  684. // primaryKeyId: nodeId,
  685. // type: authBtnTabKey.value,
  686. // })
  687. // if (!error && code === 200) {
  688. // window.$message?.success('操作成功')
  689. // tableRawCheckedKeys.value=[]
  690. // linksRawModal.value = false
  691. // tableRawRef.value?.clearSelection();
  692. // }
  693. // else {
  694. // window.$message?.warning(error)
  695. // }
  696. }
  697. //关闭原材检测报告
  698. const linksRawModalClose = () => {
  699. linksRawModal.value = false
  700. linksRawTableData.value = []
  701. tableRawRef.value?.clearSelection()
  702. }
  703. const formpositon = ref('')
  704. //关联取样
  705. const linksSampleModal = ref(false)
  706. const linksSampleModalClick = () => {
  707. linksSampleTableData.value = []
  708. linksSampleModal.value = true
  709. let FormData = ListItemRef.value?.getFormData()
  710. formpositon.value = FormData
  711. getKetarr()
  712. }
  713. const positonkey = ref([])
  714. const positionName = ref('')
  715. //取出工程部位名称的key值
  716. const getKetarr = ()=>{
  717. let rekey = []
  718. if (positiondata.value.length > 0) {
  719. positiondata.value.forEach((ele)=>{
  720. let arr = Object.keys(ele)
  721. arr.forEach((item)=>{
  722. if (item.indexOf('key') !== -1) {
  723. rekey.push(item)
  724. positionName.value = ele[item]
  725. }
  726. })
  727. })
  728. }
  729. positonkey.value = rekey
  730. }
  731. const formname = ref('')
  732. //取样工程部位值清空与替换
  733. const clearinf = ()=>{
  734. //1.点了工程部位进行清空
  735. if (positonkey.value.length > 0) {
  736. positonkey.value.forEach((item)=>{
  737. sampledata.value.forEach((ele)=>{
  738. let arr = Object.keys(ele)
  739. arr.forEach((ele1)=>{
  740. if (ele1.indexOf(item) !== -1) {
  741. ele[ele1] = positionName.value
  742. }
  743. })
  744. })
  745. })
  746. ListItemRef.value.changeSimpleInput( sampledata.value, checkTabId.value)
  747. } else if (defaultCheckarrIds.value.length > 0) {
  748. //2.表单工程部位有值,替换为工程部位的值
  749. sampledata.value.forEach((ele)=>{
  750. let arr = Object.keys(ele)
  751. arr.forEach((ele1)=>{
  752. if (ele1.indexOf('取样对应工程部位Key') !== -1) {
  753. ele[ele[ele1]] = defaultprojectPositionName.value
  754. }
  755. })
  756. })
  757. ListItemRef.value.changeSimpleInput( sampledata.value, checkTabId.value)
  758. } else {
  759. let rekey = []
  760. sampledata.value.forEach((ele)=>{
  761. let arr = Object.keys(ele)
  762. arr.forEach((item)=>{
  763. if (item.indexOf('取样对应') !== -1) {
  764. rekey.push(ele['取样对应工程部位Key'])
  765. }
  766. })
  767. })
  768. formpositon.value.forEach((ele1)=>{
  769. rekey.forEach((ele2)=>{
  770. if (ele1[ele2]) {
  771. formname.value = ele1[ele2]
  772. }
  773. })
  774. })
  775. rekey.forEach((item)=>{
  776. sampledata.value.forEach((ele)=>{
  777. let arr = Object.keys(ele)
  778. arr.forEach((ele1)=>{
  779. if (ele1.indexOf(item) !== -1) {
  780. // ele[item]= formname.value
  781. if (formname.value.length > 0) {
  782. ele[item] = formname.value
  783. } else {
  784. console.log(454545)
  785. }
  786. }
  787. })
  788. })
  789. })
  790. ListItemRef.value.changeSimpleInput( sampledata.value, checkTabId.value)
  791. }
  792. }
  793. //搜索表单
  794. const linksSampleSearchForm = ref({
  795. nodeId: null, current: 1, size: 20, total: 0,
  796. })
  797. //树被点击
  798. const linksSampleTreeClick = ({ data }) => {
  799. linksSampleSearchForm.value.nodeId = data.primaryKeyId
  800. linksSampleSearchForm.value.current = 1
  801. getLinksSampleData()
  802. }
  803. //关联取样数据
  804. const tableSampleRef = ref(null)
  805. const linksSampleTableColumn = ref([
  806. { key: 'materialName', name: '样品名称' },
  807. { key: 'samplingDate', name: '取样日期' },
  808. { key: 'specificationModel', name: '规格型号' },
  809. { key: 'proposedPosition', name: '拟用部位' },
  810. { key: 'userName', name: '取样人' },
  811. ])
  812. const linksSampleTableData = ref([])
  813. //获取关联数据
  814. const linksSampleTableLoading = ref(false)
  815. const getLinksSampleData = async () => {
  816. linksSampleTableLoading.value = true
  817. const { error, code, data } = await dataApi.sampleListInfo({
  818. ...linksSampleSearchForm.value,
  819. projectId: projectId.value,
  820. contractId: contractId.value,
  821. id: dataId,
  822. })
  823. //处理数据
  824. linksSampleTableLoading.value = false
  825. if (!error && code === 200) {
  826. linksSampleTableData.value = getArrValue(data)
  827. linksSampleTableData.value.forEach((iten) => {
  828. if (iten.isRelation === 1) {
  829. nextTick(() => {
  830. tableSampleRef.value?.toggleRowSelection(iten, true)
  831. })
  832. }
  833. })
  834. //searchForm.value.total = data.total || 0
  835. } else {
  836. linksSampleTableData.value = []
  837. //searchForm.value.total = 0
  838. }
  839. }
  840. //获取关联原材料检测报告
  841. const getrawMaterialList = async () => {
  842. linksRawTableLoading.value = true
  843. const { error, code, data } = await dataApi.rawMaterialList({
  844. nodeId: linkNodeid.value,
  845. contractId: contractId.value,
  846. id: dataId,
  847. })
  848. //处理数据
  849. linksRawTableLoading.value = false
  850. if (!error && code === 200) {
  851. linksRawTableData.value = getArrValue(data)
  852. linksRawTableData.value.forEach((iten) => {
  853. if (iten.isRawMaterialRelation === 1) {
  854. nextTick(() => {
  855. tableRawRef.value?.toggleRowSelection(iten, true)
  856. })
  857. }
  858. })
  859. //searchForm.value.total = data.total || 0
  860. } else {
  861. linksRawTableData.value = []
  862. //searchForm.value.total = 0
  863. }
  864. }
  865. //多选
  866. const tableSampleCheckedKeys = ref([])
  867. const linksSampleTableSelection = (rows) => {
  868. tableSampleCheckedKeys.value = rows
  869. }
  870. const sampledata = ref([])
  871. //保存关联
  872. const linksSampleModalSave = async () => {
  873. const rows = tableSampleCheckedKeys.value
  874. listItemBaseData.value.sampleIds = arrToId(rows) || ''
  875. window.$message?.success('操作成功')
  876. isopersampleIds.value = true
  877. let infodata = await getrecordsamplegetData()
  878. sampledata.value = infodata
  879. clearinf()
  880. tableSampleCheckedKeys.value = []
  881. linksSampleModal.value = false
  882. }
  883. //获取关联取样信息key值
  884. const getrecordsamplegetData = async () => {
  885. const { data } = await dataApi.recordsamplegetData({
  886. sampleIds: listItemBaseData.value.sampleIds,
  887. nodePKeyId: routerQuery?.nodeId,
  888. contractId: contractId.value,
  889. })
  890. return data
  891. }
  892. //获取关联工程部位key值
  893. const getpositiondata = async () => {
  894. const { error, code, data } = await dataApi.recordprojectPositiongetData({
  895. projectPositionIds:checkrelationString.value,
  896. nodePKeyId: routerQuery?.nodeId,
  897. contractId: contractId.value,
  898. })
  899. if (!error && code === 200) {
  900. return data
  901. }
  902. }
  903. //关闭关联取样
  904. const linksSampleModalClose = () => {
  905. linksSampleModal.value = false
  906. }
  907. //保存
  908. const tableFormSaveLoading = ref(false)
  909. const tableFormSaveClick = async () => {
  910. //false是编辑
  911. if (tabTypeKey.value === '2' && listItemBaseData.value.detectionResult === '') {
  912. window.$message?.warning('请选择报告单是否合格')
  913. } else {
  914. let FormData
  915. let curform = await ListItemRef.value?.setFormChart()
  916. //let curform = ListItemRef.value?.getFormData()
  917. setAllListData(curform)
  918. let operTrue = alllistData.value.filter(e => e.oper) //操作的数据
  919. let types = []
  920. operTrue.forEach(e => {
  921. types.push(e.type)
  922. })
  923. let setTypes = Array.from(new Set(types))
  924. let type = setTypes.length > 0 ? setTypes[0] : ''
  925. if (newId.value?.length > 0) {
  926. isaddType = false
  927. listItemBaseData.value.id = newId.value
  928. }
  929. if (isaddType) { //新增
  930. if (setTypes.length > 1) {
  931. FormData = alllistData.value
  932. listItemBaseData.value.tableType = '1,2'
  933. } else {
  934. // FormData = alllistData.value.filter(e => e.type == type);
  935. if (!afterAdd.value) {
  936. FormData = alllistData.value.filter(e => e.type == type)
  937. } else {
  938. let filterType = type ? type : tabTypeKey.value
  939. // FormData =alllistData.value.filter(e => e.type == type);
  940. FormData = alllistData.value.filter(e => e.type == filterType)
  941. orgAlllistData.value.forEach((item1) => {
  942. if (item1.tableType.toString() !== tabTypeKey.value) {
  943. let data1 = {
  944. projectId: item1.projectId,
  945. contractId: contractId.value,
  946. pkeyId: item1.pKeyId,
  947. nodeId: routerQuery?.nodeId,
  948. isCollapseLoad: false,
  949. isBussShow: item1.isBussShow,
  950. }
  951. // 过滤存在的key_的键值
  952. let ishasKey = Object.keys(item1).filter(e => e.indexOf('key_') >= 0)
  953. if (ishasKey.length > 0) {
  954. ishasKey.forEach(key => {
  955. data1[key] = item1[key]
  956. })
  957. }
  958. FormData.push(data1)
  959. }
  960. })
  961. }
  962. listItemBaseData.value.tableType = type
  963. }
  964. } else { //编辑
  965. console.log(alllistData.value, 'alllistData.value')
  966. FormData = alllistData.value
  967. const info = getStoreValue('test-form')
  968. let recordNo = info?.recordNo || tabTypeKey.value == 1 ? listItemBaseData.value.id : ''
  969. let reportNo = info?.reportNo || tabTypeKey.value == 2 ? listItemBaseData.value.id : ''
  970. //组装type
  971. if (recordNo === '' && reportNo !== '') {
  972. listItemBaseData.value.tableType = '2'
  973. } else if (recordNo !== '' && reportNo === '') {
  974. listItemBaseData.value.tableType = '1'
  975. } else {
  976. listItemBaseData.value.tableType = '1,2'
  977. }
  978. let notChangeData = []
  979. if (setTypes.length == 0) { //没操作过页面数据
  980. FormData = []
  981. notChangeData = orgAlllistData.value //默认就是原始左右全部数据
  982. if (listItemBaseData.value.tableType.length === 1) { //从原始数据过滤当前页面数据
  983. notChangeData = orgAlllistData.value.filter(e => e.tableType === listItemBaseData.value.tableType)
  984. }
  985. } else if (setTypes.length == 1) {// 操作过一边的数据
  986. orgAlllistData.value.forEach((item1) => {
  987. if (item1.tableType.toString() !== tabTypeKey.value) {
  988. let data1 = {
  989. projectId: item1.projectId,
  990. contractId: contractId.value,
  991. pkeyId: item1.pKeyId,
  992. nodeId: routerQuery?.nodeId,
  993. isCollapseLoad: false,
  994. isBussShow: item1.isBussShow,
  995. }
  996. // 过滤存在的key_的键值
  997. let ishasKey = Object.keys(item1).filter(e => e.indexOf('key_') >= 0)
  998. if (ishasKey.length > 0) {
  999. ishasKey.forEach(key => {
  1000. data1[key] = item1[key]
  1001. })
  1002. }
  1003. FormData.push(data1)
  1004. }
  1005. })
  1006. console.log(FormData, 'FormData22222222')
  1007. let tableTypeArr = listItemBaseData.value.tableType.split(',')
  1008. if (tableTypeArr[0] != type) { //两边都有数据/当前操作的数据不是进来时的选项,筛选另一边的数据
  1009. listItemBaseData.value.tableType = '1,2'
  1010. }
  1011. } else { //两边都操作
  1012. listItemBaseData.value.tableType = '1,2'
  1013. }
  1014. notChangeData.forEach(item => {
  1015. let data = {
  1016. projectId: item.projectId,
  1017. contractId: contractId.value,
  1018. pkeyId: item.pKeyId,
  1019. nodeId: routerQuery?.nodeId,
  1020. isCollapseLoad: false,
  1021. isBussShow: item.isBussShow,
  1022. }
  1023. // 过滤存在的key_的键值
  1024. let ishasKey = Object.keys(item).filter(e => e.indexOf('key_') >= 0)
  1025. if (ishasKey.length > 0) {
  1026. ishasKey.forEach(key => {
  1027. data[key] = item[key]
  1028. })
  1029. }
  1030. FormData.push(data)
  1031. })
  1032. }
  1033. let FormRegExpJson = ListItemRef.value?.getFormRegExpJson()
  1034. if (newId.value?.length > 0) {
  1035. isaddType = false
  1036. }
  1037. if (isaddType && FormData.length == 0 || !isaddType && FormData.length == 0) {
  1038. console.log('什么都不操作新增或者编辑')
  1039. if (tabTypeKey.value == 1) {
  1040. FormData = alllistData.value.filter((itenel) => {
  1041. return itenel.type == 1
  1042. })
  1043. } else if (tabTypeKey.value == 2) {
  1044. FormData = alllistData.value.filter((itenel) => {
  1045. return itenel.type == 2
  1046. })
  1047. } else {
  1048. FormData = alllistData.value
  1049. }
  1050. listItemBaseData.value.tableType = tabTypeKey.value
  1051. }
  1052. //效验数据
  1053. if (FormData.length > 0) {
  1054. if (listItemBaseData.value.detectionResult === '' && listItemBaseData.value.tableType == '1,2') {
  1055. window.$message?.warning('请选择报告单是否合格')
  1056. } else {
  1057. tableFormSaveLoading.value = true
  1058. console.log(listItemData.value, 'listItemData.value')
  1059. if (listItemData.value.id && listItemData.value.id.length < 0) {
  1060. listItemData.value.id = dataId
  1061. }
  1062. console.log(FormData, 'lastFormData')
  1063. //过滤掉已经隐藏表的数据
  1064. FormData = FormData.filter((item) => {
  1065. if (item.isBussShow !== 2) {
  1066. return item
  1067. }
  1068. })
  1069. console.log( listItemBaseData.value.tableType, ' listItemBaseData.value.tableType')
  1070. console.log(FormData, 'lastFormData1')
  1071. if (listItemBaseData.value.tableType && listItemBaseData.value?.tableType.length === 1 && newId.value?.length === 0) {
  1072. console.log('只要一边的数据')
  1073. // eslint-disable-next-line array-callback-return
  1074. FormData = FormData.filter((ele) => {
  1075. // eslint-disable-next-line eqeqeq
  1076. if (ele.type == listItemBaseData.value.tableType) {
  1077. return ele
  1078. }
  1079. })
  1080. console.log(FormData, 'FormDat4444444a')
  1081. }
  1082. const { error, code, data } = await dataApi.saveExcelBussData({
  1083. ...listItemBaseData.value,
  1084. isBatchSave: 1,
  1085. dataInfo: { orderList: FormData },
  1086. // deviceUseIds:listDeviceUseIds.value
  1087. })
  1088. nodeIdvalue.value = data
  1089. tableFormSaveLoading.value = false
  1090. if (!error && code === 200) {
  1091. window?.$message?.success('保存成功')
  1092. listItemBaseData.value.deviceUseIds = ''
  1093. checkTabId.value = ''
  1094. // alllistData.value.forEach(e => e.oper = false)
  1095. alllistData.value = []
  1096. if (!isaddType) {
  1097. bussPdfsClick(router.currentRoute.value.query.id || listItemBaseData.value.id)
  1098. // toBackClick()
  1099. getSearchNodeTables()
  1100. getSearchNodeTablesall(1)
  1101. getSearchNodeTablesall(2)
  1102. } else {
  1103. listItemBaseData.value.id = data
  1104. bussPdfsClick(nodeIdvalue.value)
  1105. getSearchNodeTables()
  1106. getSearchNodeTablesall(1)
  1107. getSearchNodeTablesall(2)
  1108. afterAdd.value = true
  1109. isaddType = false
  1110. }
  1111. getTableDataAll()
  1112. }
  1113. }
  1114. }
  1115. }
  1116. }
  1117. const setAllListData = (curform) => {
  1118. if (curform) {
  1119. curform.forEach((item) => {
  1120. let pkeyId = item.pkeyId
  1121. item.oper = false
  1122. let ishasKey = Object.keys(item).filter(e => e.indexOf('key_') >= 0)
  1123. if (ishasKey.length > 0) { //筛出当前编辑过的数据
  1124. item.oper = true
  1125. }
  1126. let orgData = orgAlllistData.value.filter(e => e.pKeyId === pkeyId)
  1127. item.type = orgData[0]?.tableType
  1128. alllistData.value = alllistData.value.filter(e => e.pkeyId != pkeyId) //去掉老数据
  1129. console.log(orgData, 'orgData')
  1130. if (orgData.length > 0) {
  1131. ishasKey = Object.keys(orgData[0]).filter(e => e.indexOf('key_') >= 0)
  1132. }
  1133. if (!item.isCollapseLoad && ishasKey.length > 0) { //没操作过,并且存在KEY
  1134. ishasKey.forEach(key => {
  1135. item[key] = orgData[0][key]
  1136. })
  1137. }
  1138. alllistData.value.push(item) //加入新数据
  1139. })
  1140. }
  1141. }
  1142. //效验数据
  1143. const setFormRegExpJson = (FormRegExpJson) => {
  1144. let nodeName = '', itemId = ''
  1145. Object.keys(FormRegExpJson).forEach(key => {
  1146. const name = FormRegExpJson[key]?.nodeName ?? ''
  1147. if (name) {
  1148. if (nodeName) {
  1149. nodeName += ',' + name
  1150. } else {
  1151. nodeName = name
  1152. itemId = FormRegExpJson[key]?.itemId
  1153. }
  1154. }
  1155. })
  1156. //const activeKey = ListItemRef.value?.getActiveKey()
  1157. //弹出提示
  1158. const val = '<div style="font-size: 16px;">请先完善 <span style="color:#1ECC95;">' + nodeName + '</span> 的数据内容</div>'
  1159. window?.$messageBox?.alert(val, '表单完善提醒', {
  1160. confirmButtonText: '确定',
  1161. dangerouslyUseHTMLString: true,
  1162. callback: (action) => {
  1163. if (action === 'confirm') {
  1164. ListItemRef.value?.setActiveKey(itemId)
  1165. ListItemOffsetTop(0)
  1166. setTimeout(() => {
  1167. const offsetTop = document.getElementById(itemId)?.offsetTop
  1168. ListItemOffsetTop(offsetTop)
  1169. }, 350)
  1170. }
  1171. },
  1172. })
  1173. }
  1174. //获取数据列表
  1175. const nodeItemInfo = ref({})
  1176. const nodeDataInfo = ref({})
  1177. //查询状态
  1178. const NodeStatus = ref('1')
  1179. const queryNodeStatus = async (newaddId) => {
  1180. const info = getStoreValue('prenodeDataInfo') || {}
  1181. const { error, code, data } = await wbsApi.queryNodeStatusTrial({
  1182. // primaryKeyId: info['contractIdRelation'] ? info['id'] : info['primaryKeyId'],
  1183. id: dataId.length > 0 ? dataId : nodeIdvalue.value || newaddId,
  1184. classify: authBtnTabKey.value,
  1185. })
  1186. //1 未填报,2待上报,3已上报
  1187. if (!error && code === 200) {
  1188. NodeStatus.value = data ?? '1'
  1189. } else {
  1190. NodeStatus.value = '1'
  1191. }
  1192. }
  1193. //批量上报
  1194. const reportIds = ref('')
  1195. const reportTaskName = ref('')
  1196. const reportAddition = ref({})
  1197. const showReportModal = ref(false)
  1198. const reportLoading = ref(false)
  1199. const reportTypeData = ref([])
  1200. // const reportModalClick = async () => {
  1201. // showReportModal.value = true
  1202. // }
  1203. //上报完成
  1204. const showReportFinish = () => {
  1205. showReportModal.value = false
  1206. getTableDataAll()
  1207. }
  1208. const reportModalClick = async () => {
  1209. const info = getStoreValue('prenodeDataInfo') || {}
  1210. console.log(info, 'info')
  1211. const rows = listItemData.value
  1212. if (rows.length > 0) {
  1213. reportLoading.value = true
  1214. const taskCheck = await eVisaTaskCheckApi({
  1215. projectId: projectId.value,
  1216. contractId: contractId.value,
  1217. })
  1218. //处理数据
  1219. let newArr = []
  1220. // console.log(rows,'rows');
  1221. for (let i = 0; i < rows.length; i++) {
  1222. newArr.push(rows[i]['pKeyId'])
  1223. }
  1224. reportTypeData.value = newArr
  1225. reportLoading.value = false
  1226. if (taskCheck) {
  1227. //初始弹出弹窗,防呆
  1228. // reportIds.value = info['primaryKeyId'] dataId
  1229. reportIds.value = dataId.length > 0 ? dataId : nodeIdvalue.value
  1230. reportAddition.value = {
  1231. classify: authBtnTabKey.value,
  1232. contractIdRelation: info['contractIdRelation'],
  1233. }
  1234. showReportModal.value = true
  1235. //请求文件题名
  1236. const { data } = await wbsApi.queryDocumentTitle({
  1237. // primaryKeyId: info['primaryKeyId'],
  1238. primaryKeyId: dataId.length > 0 ? dataId : nodeIdvalue.value,
  1239. classify: authBtnTabKey.value,
  1240. })
  1241. reportTaskName.value = isString(data) ? data : ''
  1242. }
  1243. } else {
  1244. window.$message?.warning('暂无相关数据')
  1245. }
  1246. }
  1247. //多表预览
  1248. const bussPdfsLoading = ref(false)
  1249. const nodeIdvalue = ref('')
  1250. const bussPdfsClick = async (nodeId, newaddId) => {
  1251. bussPdfsLoading.value = true
  1252. const { error, code, data } = await dataApi.getBussPdfs({
  1253. projectId: projectId.value,
  1254. contractId: contractId.value,
  1255. classify: authBtnTabKey.value,
  1256. tableType: tabTypeKey.value,
  1257. // nodeId: router.currentRoute.value.query.id,
  1258. nodeId: nodeId || newId.value,
  1259. })
  1260. bussPdfsLoading.value = false
  1261. if (!error && code === 200) {
  1262. toPdfPage(data)
  1263. //window.open(data, '_blank')
  1264. } else {
  1265. window.$message?.warning('获取PDF失败')
  1266. }
  1267. }
  1268. //撤回上报流程
  1269. // const abolishOneClick = () => {
  1270. // window.$message?.warning('暂无接口')
  1271. // }
  1272. //撤回上报流程
  1273. const abolishOneClick = () => {
  1274. window?.$messageBox?.alert('请谨慎考虑后,是否确定撤回?', '撤回上报', {
  1275. showCancelButton: true,
  1276. confirmButtonText: '确定撤回',
  1277. cancelButtonText: '取消',
  1278. callback: (action) => {
  1279. if (action === 'confirm') {
  1280. abolishOneSave()
  1281. }
  1282. },
  1283. })
  1284. }
  1285. //撤回请求
  1286. const abolishOneSave = async () => {
  1287. const info = getStoreValue('prenodeDataInfo') || {}
  1288. const { error, code } = await wbsApi.abolishOne({
  1289. // primaryKeyId: info?.primaryKeyId || '',
  1290. primaryKeyId: dataId.length > 0 ? dataId : nodeIdvalue.value,
  1291. classify: authBtnTabKey.value,
  1292. projectId:projectId.value,
  1293. contractId:contractId.value,
  1294. })
  1295. if (!error && code === 200) {
  1296. window.$message?.success('撤回成功')
  1297. getTableDataAll()
  1298. }
  1299. }
  1300. //返回
  1301. const toBackClick = () => {
  1302. router.push({
  1303. path: '/tentative/detect/test',
  1304. query: {},
  1305. })
  1306. // setTimeout(() => {
  1307. // window?.location?.reload() //刷新页面
  1308. // }, 1000);
  1309. }
  1310. const updeviceUseIds = (val) => {
  1311. listItemBaseData.value.deviceUseIds = val
  1312. }
  1313. const treeProps = {
  1314. label: 'fullName',
  1315. children: 'hasChildren',
  1316. isLeaf: 'notExsitChild',
  1317. }
  1318. //获取工程部位方法
  1319. const treeLoadNode = async ({ node, item, level }, resolve) => {
  1320. let id = ''
  1321. if (level !== 0) {
  1322. const nodeData = getObjValue(item)
  1323. id = nodeData?.id || ''
  1324. }
  1325. //获取数据
  1326. const { error, code, data } = await divisionApi.getengineerInfoTree1({
  1327. projectId: projectId.value,
  1328. contractId: contractId.value,
  1329. wbsId: projectInfo?.value.referenceWbsTemplateId,
  1330. selfId: dataId,
  1331. id:id,
  1332. })
  1333. checkrelationId.value = getArrValue(data['isSelectedStatus'])
  1334. resolve(getArrValue(data))
  1335. }
  1336. </script>
  1337. <style lang="scss" scoped>
  1338. @import "../../../styles/tentative/detect/test-form.scss";
  1339. .hc-table-form-action-tip {
  1340. position: absolute;
  1341. bottom: 77px;
  1342. width: 100%;
  1343. }
  1344. .hc-table-form-action-tip .hc-alert {
  1345. background-color: #f1f5f8;
  1346. display: inline;
  1347. vertical-align: middle;
  1348. box-shadow: -2px 0 10px 0 rgba(32, 37, 50, 0.03), 0 10px 21px 20px rgba(32, 37, 50, 0.03);
  1349. }
  1350. </style>