test-form.vue 57 KB

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