test-form.vue 54 KB

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