test-form.vue 53 KB

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