test-form.vue 54 KB

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