test-form.vue 53 KB

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