test-form.vue 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049
  1. <template>
  2. <div class="hc-page-box">
  3. <HcCard actionUi="text-center">
  4. <template #header>
  5. <el-button :type="authBtnTabKey === '1'?'primary':''" hc-btn @click="authBtnTabClick('1')">
  6. <HcIcon name="folder-user"/>
  7. <span>施工自检</span>
  8. </el-button>
  9. <el-button :type="authBtnTabKey === '2'?'primary':''" hc-btn @click="authBtnTabClick('2')">
  10. <HcIcon name="folder-shield"/>
  11. <span>监理质检</span>
  12. </el-button>
  13. </template>
  14. <template #extra>
  15. <el-button type="primary" hc-btn @click="linksRelateModalClick" :disabled="listItemData.length <= 0">关联工程用途及部位</el-button>
  16. <el-button :type="isMixRatioTestIds ? 'primary' : ''" hc-btn :disabled="!isMixRatioTestIds" @click="linksRawModalClick">关联原材检测报告</el-button>
  17. <el-button type="primary" hc-btn @click="linksSampleModalClick">关联取样</el-button>
  18. </template>
  19. <template #search>
  20. <div class="flex-1">
  21. <HcNewSwitch :datas="tabTypeTab" :keys="tabTypeKey" @change="tabTypeChange" size="default" :round="false"/>
  22. </div>
  23. <div class="hc-search-top-form">
  24. <div class="w-40">
  25. <el-input v-model="listItemBaseData.trialUserName" placeholder="请输入试验人员" clearable/>
  26. </div>
  27. <div class="w-36 ml-2" v-if="tabTypeKey === '2'">
  28. <el-date-picker type="date" v-model="listItemBaseData.reportDate" class="block" value-format="YYYY-MM-DD" :clearable="false" placeholder="请选择报告日期"/>
  29. </div>
  30. <div class="w-28 ml-2" v-if="tabTypeKey === '2'">
  31. <el-select v-model="listItemBaseData.detectionResult" placeholder="是否合格" block>
  32. <el-option label="合格" value="1" />
  33. <el-option label="不合格" value="0" />
  34. </el-select>
  35. </div>
  36. <div class="w-36 ml-2">
  37. <el-select v-model="listItemBaseData.detectionCategory" placeholder="选择检测类型" block>
  38. <el-option v-for="item in categoryData" :label="item['dictValue']" :value="item['dictKey']"/>
  39. </el-select>
  40. </div>
  41. </div>
  42. </template>
  43. <!--清表列表-->
  44. <el-scrollbar ref="ListItemScrollRef" v-loading="isLoading" v-if="listItemData.length > 0">
  45. <ListItem ref="ListItemRef" :datas="listItemData" :status="1" :baseData="listItemBaseData" @offsetTop="ListItemOffsetTop" @renew="getTableDataAll"
  46. :deviceUseIds="listDeviceUseIds"
  47. :authBtnTabKey="authBtnTabKey"
  48. :tabTypeKey="tabTypeKey"
  49. @updeviceUseIds="updeviceUseIds"
  50. @upcheckTableId="upcheckTableId"
  51. />
  52. </el-scrollbar>
  53. <template #action>
  54. <el-button type="primary" hc-btn :disabled="NodeStatus === '3' || listItemData.length <= 0" :loading="tableFormSaveLoading" @click="tableFormSaveClick">
  55. <HcIcon name="save"/>
  56. <span>保存</span>
  57. </el-button>
  58. <el-button hc-btn :loading="reportLoading" @click="reportModalClick" :disabled="NodeStatus === '3' || NodeStatus === '1'" >
  59. <HcIcon name="send-plane-2"/>
  60. <span>上报</span>
  61. </el-button>
  62. <!-- <el-button hc-btn :loading="reportLoading" @click="reportModalClick" >
  63. <HcIcon name="send-plane-2"/>
  64. <span>上报</span>
  65. </el-button> -->
  66. <el-button hc-btn :disabled="NodeStatus === '1'" :loading="bussPdfsLoading" @click="bussPdfsClick(router.currentRoute.value.query.id)">
  67. <HcIcon name="eye"/>
  68. <span>预览</span>
  69. </el-button>
  70. <el-button hc-btn @click="abolishOneClick" v-if="NodeStatus === '3'">
  71. <HcIcon name="arrow-go-back"/>
  72. <span>撤回上报流程</span>
  73. </el-button>
  74. <el-button hc-btn @click="toBackClick">
  75. <HcIcon name="delete-back"/>
  76. <span>返回</span>
  77. </el-button>
  78. </template>
  79. </HcCard>
  80. <!--关联工程用途及部位-->
  81. <HcDialog :show="linksRelateModal" title="关联工程用途及部位" widths="50rem" isTable saveText="确认关联" @close="linksRelateModalClose" @save="linksRelateModalSave">
  82. <div class="hc-links-relate-tree-box">
  83. <div class="hc-search-tree-val">
  84. <el-input v-model="linksRelateSearchTreeVal" block size="large" placeholder="请输入名称关键词检索" clearable @keyup="searchTreeKeyUp" @clear="clearSearch">
  85. <template #suffix>
  86. <HcIcon name="search-2" ui="text-xl" @click="searchTreeClick"/>
  87. </template>
  88. </el-input>
  89. </div>
  90. <div class="hc-tree-scrollbar" v-loading="linksRelateTreeLoading" element-loading-text="获取数据中...">
  91. <el-scrollbar>
  92. <!-- <DivisionTree :datas="unmatchedTreeData" @nodeTap="divisionTreeClick" @nodeCheck="divisionTreeCheck" :defaultCheckarr="defaultCheckarrIds"/> -->
  93. <template v-if="isSearchTree">
  94. <DivisionTree1
  95. :datas="searchTreeData"
  96. @nodeTap="divisionTreeClick"
  97. @nodeCheck="divisionTreeCheck"
  98. :defaultCheckarr="defaultCheckarrIds"
  99. :ElTreeProps="seaElTreeProps"
  100. :defaultExpandAll="true"
  101. :check-strictly="true"
  102. :divisionLoading="searchlinksRelateTreeLoading"/>
  103. </template>
  104. <DivisionTree
  105. v-show="!isSearchTree"
  106. :datas="unmatchedTreeData"
  107. @nodeTap="divisionTreeClick"
  108. @nodeCheck="divisionTreeCheck"
  109. :defaultCheckarr="defaultCheckarrIds"
  110. :check-strictly="true"
  111. :divisionLoading="isdivisionLoading"
  112. :linksRelateSearchTreeVal="linksRelateSearchTreeVal"
  113. />
  114. </el-scrollbar>
  115. </div>
  116. </div>
  117. </HcDialog>
  118. <!--关联原材检测报告-->
  119. <HcDialog :show="linksRawModal" title="关联原材检测报告" widths="75rem" isTable saveText="确认关联" @close="linksRawModalClose" @save="linksRawModalSave">
  120. <div class="hc-links-sample-modal-box">
  121. <div class="hc-links-sample-tree-box">
  122. <el-scrollbar>
  123. <TestTree :projectId="projectId" :wbsTempId="projectInfo?.referenceWbsTemplateIdTrial" :wbsType="2" :tenantId="userInfo?.tenant_id" @nodeTap="linksRawTreeClick"/>
  124. </el-scrollbar>
  125. </div>
  126. <div class="hc-links-sample-table-box">
  127. <HcTable ref="tableRawRef" :column="linksRawTableColumn" :datas="linksRawTableData" :loading="linksRawTableLoading" :isIndex="false" isCheck @selection-change="linksRawTableSelection"/>
  128. </div>
  129. </div>
  130. </HcDialog>
  131. <!--关联取样-->
  132. <HcDialog :show="linksSampleModal" title="关联取样信息" widths="75rem" isTable saveText="确认" @close="linksSampleModalClose" @save="linksSampleModalSave">
  133. <div class="hc-links-sample-modal-box">
  134. <div class="hc-links-sample-tree-box">
  135. <el-scrollbar>
  136. <TestTree :projectId="projectId" :wbsTempId="projectInfo?.referenceWbsTemplateIdTrial" :wbsType="2" :tenantId="userInfo?.tenant_id" @nodeTap="linksSampleTreeClick"/>
  137. </el-scrollbar>
  138. </div>
  139. <div class="hc-links-sample-table-box">
  140. <HcTable ref="tableSampleRef" :column="linksSampleTableColumn" :datas="linksSampleTableData" :loading="linksSampleTableLoading" :isIndex="false" isCheck @selection-change="linksSampleTableSelection"/>
  141. </div>
  142. </div>
  143. </HcDialog>
  144. <!--批量上报审批-->
  145. <HcReportModal title="批量上报审批" url="informationWriteQuery/taskOne" :show="showReportModal" :projectId="projectId" :contractId="contractId" type="wbs" :typeData="reportTypeData"
  146. :taskName="reportTaskName" :ids="reportIds" :addition="reportAddition" :trialSelfInspectionRecordId="dataId" @hide="showReportModal = false" @finish="showReportFinish"/>
  147. </div>
  148. </template>
  149. <script setup>
  150. import {ref, watch, onMounted,nextTick} from "vue";
  151. import {useAppStore} from "~src/store";
  152. import {useRouter, useRoute} from 'vue-router'
  153. import ListItem from "./components/ListItem.vue"
  154. import DivisionTree from "./components/DivisionTree.vue"
  155. import DivisionTree1 from "./components/DivisionTree1.vue"
  156. import dataApi from "~api/tentative/detect/test";
  157. import divisionApi from "~api/data-fill/division";
  158. import queryApi from '~api/data-fill/query';
  159. import {getStoreData,setStoreData} from '~src/utils/storage'
  160. import TestTree from "../material/components/TestTree.vue"
  161. import {getArrValue, getObjValue, getObjNullValue,isString} from "vue-utils-plus";
  162. import {getDictionary} from "~api/other";
  163. import {rowsToId} from "~uti/tools";
  164. import dayjs from "dayjs"
  165. import { Loading } from "element-plus/es/components/loading/src/service";
  166. import { eVisaTaskCheckApi} from "~api/other"
  167. import wbsApi from "~api/data-fill/wbs"
  168. //变量
  169. const router = useRouter()
  170. const useRoutes = useRoute()
  171. const useAppState = useAppStore()
  172. const userInfo = ref(useAppState.getUserInfo);
  173. const projectId = ref(useAppState.getProjectId);
  174. const contractId = ref(useAppState.getContractId);
  175. const projectInfo = ref(useAppState.getProjectInfo);
  176. const contractInfo = ref(useAppState.getContractInfo);
  177. //获取模板标签数据
  178. const isTableForm = ref(false)
  179. //路由参数
  180. const routerQuery = useRoutes?.query;
  181. //存储目录格式 1按部位存储,2按日期存储
  182. const dataId = routerQuery?.id || '';
  183. const nodeId = routerQuery?.nodeId || '';
  184. const dataType = routerQuery?.dataType || '1';
  185. const isaddType = routerQuery?.isaddType || false;
  186. const dayDate = dayjs().format('YYYY-MM-DD')
  187. const testTreeItem = ref(getStoreData('testTreeItem'));
  188. const isMixRatioTestIds = ref(false);
  189. const tabTypeKey = ref('')
  190. //渲染完成
  191. onMounted(() => {
  192. tabTypeKey.value= routerQuery?.tabTypeKey || '1'
  193. const { title, mixRatioTestIds} = getObjValue(testTreeItem.value);
  194. const info = getStoreData('test-form') || {}
  195. isMixRatioTestIds.value = !(!mixRatioTestIds || mixRatioTestIds <= 0);
  196. listItemBaseData.value.contractId = contractId.value
  197. listItemBaseData.value.trialProjectName = title
  198. listItemBaseData.value.reportDate = dayDate
  199. listItemBaseData.value.detectionCategory = Number(dataType)
  200. listItemBaseData.value.trialUserName =info.trialUserName||(userInfo.value['nick_name'])
  201. if(info&&info.detectionResult){
  202. listItemBaseData.value.detectionResult=info.detectionResult.toString()
  203. }
  204. getSearchNodeTables()
  205. getSearchNodeTablesall(1)
  206. getSearchNodeTablesall(2)
  207. getCategoryData()
  208. })
  209. //身份按钮切换数据
  210. const authBtnTabKey = ref(dataType)
  211. const authBtnTabClick = (val) => {
  212. if (val !== authBtnTabKey.value) {
  213. authBtnTabKey.value = val
  214. listItemBaseData.value.type = val
  215. listItemBaseData.value.detectionCategory = Number(val)
  216. getSearchNodeTables()
  217. }
  218. }
  219. //类型tab数据和相关处理
  220. const leftFormData=ref([])
  221. const rightFormData=ref([])
  222. const allFormData=ref([])
  223. const tabTypeTab = ref([
  224. {key:'1', name: '记录表'},
  225. {key:'2', name: '报告单'},
  226. ]);
  227. const tabTypeChange = ({key}) => {
  228. console.log(key,'切换key');
  229. // console.log(ListItemRef.value?.getFormData(),'ListItemRef.value?.getFormData()');
  230. tabTypeKey.value = key
  231. let curform=ListItemRef.value?.getFormData()
  232. setAllListData(curform)
  233. // if(tabTypeKey.value==='2'){
  234. // leftFormData.value=ListItemRef.value?.getFormData()
  235. // }else{
  236. // rightFormData.value=ListItemRef.value?.getFormData()
  237. // }
  238. getSearchNodeTables()
  239. }
  240. //获取检测类别类型
  241. const categoryData = ref([])
  242. const getCategoryData = async () => {
  243. const { data } = await getDictionary({
  244. code: 'trial_detection_category'
  245. })
  246. const arrData = getArrValue(data)
  247. arrData.forEach(item => {
  248. item.dictKey = Number(item.dictKey)
  249. })
  250. categoryData.value = arrData
  251. }
  252. //顶部表单
  253. const ListItemRef = ref(null);
  254. const listItemBaseData = ref({
  255. sampleIds: '', contractId: null, nodeId: nodeId, trialProjectName: null, type: dataType, tableType: '1',
  256. detectionCategory: '', detectionResult: '', reportDate: '', trialUserName: '', id: dataId,
  257. })
  258. //获取数据
  259. const isLoading = ref(false)
  260. const listItemData = ref([])
  261. const listDeviceUseIds=ref('')
  262. const reportData=ref([])
  263. const testData=ref([])
  264. const alllistData=ref([])
  265. const orgAlllistData=ref([])
  266. const getSearchNodeTables = async () => {
  267. isLoading.value = true
  268. if(isaddType){
  269. const { error, code, data } = await dataApi.searchNodeTables({
  270. id: dataId,
  271. projectId: projectId.value,
  272. contractId: contractId.value,
  273. primaryKeyId: nodeId,
  274. type: authBtnTabKey.value,
  275. tableType: tabTypeKey.value,
  276. isAdd: 1
  277. })
  278. //处理数据
  279. isLoading.value = false
  280. if (!error && code === 200) {
  281. listItemData.value = getArrValue(data)
  282. } else {
  283. listItemData.value = []
  284. }
  285. }else{
  286. queryNodeStatus()//查询按钮状态
  287. const { error, code, data } = await dataApi.searchNodeTables({
  288. id: dataId,
  289. projectId: projectId.value,
  290. contractId: contractId.value,
  291. primaryKeyId: nodeId,
  292. type: authBtnTabKey.value,
  293. tableType: tabTypeKey.value,
  294. })
  295. //处理数据
  296. isLoading.value = false
  297. if (!error && code === 200) {
  298. listItemData.value = getArrValue(data)
  299. } else {
  300. listItemData.value = []
  301. }
  302. }
  303. }
  304. const getSearchNodeTablesall = async (type) => {
  305. const { error, code, data } = await dataApi.searchNodeTables({
  306. id: dataId,
  307. projectId: projectId.value,
  308. contractId: contractId.value,
  309. primaryKeyId: nodeId,
  310. type: authBtnTabKey.value,
  311. tableType: type,
  312. // isAdd: 1
  313. isAdd:isaddType?1:''
  314. })
  315. //处理数据
  316. isLoading.value = false
  317. if (!error && code === 200) {
  318. // listItemData.value = getArrValue(data)
  319. if(type===1){
  320. testData.value= getArrValue(data)
  321. testData.value.forEach((item)=>{
  322. let bussDataInfoTrialData=item.bussDataInfoTrial
  323. if(bussDataInfoTrialData&&Object.keys(bussDataInfoTrialData).length!==0){
  324. for(var key in bussDataInfoTrialData){
  325. console.log(key,bussDataInfoTrialData[key])
  326. item[key]=bussDataInfoTrialData[key]
  327. }
  328. }
  329. orgAlllistData.value.push(item)
  330. })
  331. }else{
  332. reportData.value= getArrValue(data)
  333. reportData.value.forEach((item)=>{
  334. let bussDataInfoTrialData=item.bussDataInfoTrial
  335. if(bussDataInfoTrialData&&Object.keys(bussDataInfoTrialData).length!==0){
  336. for(var key in bussDataInfoTrialData){
  337. console.log(key,bussDataInfoTrialData[key])
  338. item[key]=bussDataInfoTrialData[key]
  339. }
  340. }
  341. orgAlllistData.value.push(item)
  342. })
  343. }
  344. } else {
  345. // listItemData.value = []
  346. if(type==1){
  347. testData.value= []
  348. alllistData.value=[]
  349. }else{
  350. reportData.value= []
  351. alllistData.value=[]
  352. }
  353. }
  354. }
  355. //获取数据
  356. const getTableDataAll = () => {
  357. getSearchNodeTables()
  358. queryNodeStatus()
  359. }
  360. //设置滚动条位置
  361. const ListItemScrollRef = ref(null)
  362. const ListItemOffsetTop = (offsetTop) => {
  363. if (offsetTop > 0) {
  364. setTimeout(() => {
  365. ListItemScrollRef.value?.setScrollTop(offsetTop)
  366. }, 350)
  367. } else {
  368. ListItemScrollRef.value?.setScrollTop(offsetTop)
  369. }
  370. }
  371. const checkTabId=ref('')
  372. const upcheckTableId = (val) => {
  373. checkTabId.value=val
  374. }
  375. //关联工程用途及部位 树
  376. const linksRelateModal = ref(false)
  377. const linksRelateModalClick = () => {
  378. linksRelateModal.value = true
  379. linksRelateSearchTreeVal.value=''
  380. getContractInfoTreeApi()
  381. }
  382. //获取导入树
  383. const unmatchedTreeData = ref([])
  384. const defaultCheckarrIds=ref([])
  385. const isdivisionLoading=ref(false)
  386. const getContractInfoTreeApi = async () => {
  387. isdivisionLoading.value=true
  388. const {error, code, data} = await divisionApi.getengineerInfoTree1({
  389. projectId: projectId.value,
  390. contractId: contractId.value,
  391. wbsId: projectInfo?.value.referenceWbsTemplateId,
  392. selfId:dataId
  393. })
  394. //判断状态
  395. if (!error && code === 200) {
  396. unmatchedTreeData.value = getArrValue(data['treeContractAll'])
  397. searchTreeData.value = getArrValue(data['treeContractAll'])
  398. setStoreData('unmatchedTreeData', unmatchedTreeData.value)
  399. defaultCheckarrIds.value=getArrValue(data['isSelectedStatus'])
  400. checkrelationId.value=getArrValue(data['isSelectedStatus'])
  401. } else {
  402. unmatchedTreeData.value = []
  403. }
  404. isdivisionLoading.value=false
  405. }
  406. //关联树
  407. const divisionTreeItemInfo = ref({})
  408. const divisionTreeClick = ({data}) => {
  409. divisionTreeItemInfo.value = data
  410. }
  411. const checkrelationId=ref([])
  412. const checkrelationString=ref([])
  413. const divisionTreeCheck = (data) => {
  414. checkrelationId.value=data
  415. }
  416. const seaElTreeProps = ref({
  417. label: 'title',
  418. children: 'children'
  419. })
  420. const linksRelateSearchTreeVal = ref('')
  421. // watch(tabTypeKey, (val) => {
  422. // if(val){
  423. // console.log(val);
  424. // if (val==='1') {
  425. // leftFormData.value=ListItemRef.value?.getFormData()
  426. // }else{
  427. // rightFormData.value= ListItemRef.value?.getFormData()
  428. // }
  429. // }
  430. // },
  431. // )
  432. watch(linksRelateSearchTreeVal, (val) => {
  433. if(!val.length){
  434. clearSearch()
  435. }
  436. },
  437. )
  438. const linksRelateTreeLoading = ref(false)
  439. const searchTreeData = ref([])
  440. const searchlinksRelateTreeLoading = ref(false)
  441. const searchTreeKeyUp = (e) => {
  442. if (e.key === "Enter") {
  443. searchTreeClick()
  444. }
  445. }
  446. const clearSearch = (e) => {
  447. isSearchTree.value=true
  448. searchlinksRelateTreeLoading.value = true
  449. setTimeout(()=>{
  450. searchlinksRelateTreeLoading.value = false
  451. },3000)
  452. }
  453. //树搜索
  454. const isSearchTree = ref(false)
  455. const searchTreeClick = async () => {
  456. if (linksRelateSearchTreeVal.value) {
  457. nextTick(()=> {
  458. isSearchTree.value=false
  459. })
  460. // const {error, code, data} = await queryApi.searchContractTree({
  461. // contractId: contractId.value,
  462. // queryValue: linksRelateSearchTreeVal.value
  463. // })
  464. // //判断状态
  465. // if (!error && code === 200) {
  466. // searchlinksRelateTreeLoading.value = false
  467. // } else {
  468. // searchlinksRelateTreeLoading.value = false
  469. // searchTreeData.value = []
  470. // }
  471. }
  472. }
  473. //确认关联
  474. const linksRelateModalSave =async () => {
  475. let idarr=[]
  476. checkrelationId.value.forEach((item)=>{
  477. idarr.push(item.primaryKeyId)
  478. })
  479. checkrelationString.value=idarr.toString()
  480. // listItemBaseData.value.projectPosition=checkrelationString.value
  481. linksRelateModal.value = false
  482. // const { error, code, data } = await dataApi.projectpositionSubmit({
  483. // id: dataId,
  484. // projectPosition:checkrelationString.value,
  485. // })
  486. // if (!error && code === 200) {
  487. // window.$message?.success('操作成功')
  488. // linksRelateModal.value = false
  489. // }else {
  490. // window.$message?.warning(error)
  491. // linksRelateModal.value = false
  492. // }
  493. }
  494. const linksRelateModalClose = () => {
  495. linksRelateModal.value = false
  496. }
  497. //关联原材检测报告
  498. const linksRawModal = ref(false)
  499. const linksRawModalClick = () => {
  500. linksRawModal.value = true
  501. }
  502. const linkNodeid=ref('')
  503. //树被点击
  504. const linksRawTreeClick = ({data}) => {
  505. linkNodeid.value=data.primaryKeyId
  506. getrawMaterialList()
  507. }
  508. //原材检测报告数据
  509. const tableRawRef = ref(null)
  510. const linksRawTableColumn = ref([
  511. {key:'reportNo', name: '报告编号'},
  512. {key:'trialProjectName', name: '试验项目名称'},
  513. {key:'projectPositionName', name: '工程部位及用途'},
  514. {key:'reportDate', name: '报告日期'}
  515. ])
  516. const linksRawTableData = ref([])
  517. const linksRawTableLoading = ref(false)
  518. //多选
  519. const tableRawCheckedKeys = ref([]);
  520. const tableRawCheckedKeysid = ref('');
  521. const linksRawTableSelection = (rows) => {
  522. tableRawCheckedKeys.value = rows
  523. let arr=[]
  524. tableRawCheckedKeys.value.forEach((item)=>{
  525. arr.push(item.id)
  526. })
  527. tableRawCheckedKeysid.value=arr.join()
  528. }
  529. const linksRawModalSave =async () => {
  530. console.log(tableRawCheckedKeysid.value,'tableRawCheckedKeysid.value');
  531. // const { error, code, data } = await dataApi.rawMaterialSubmit({
  532. // id: dataId,
  533. // ids:tableRawCheckedKeysid.value,
  534. // projectId: projectId.value,
  535. // contractId: contractId.value,
  536. // primaryKeyId: nodeId,
  537. // type: authBtnTabKey.value,
  538. // })
  539. // if (!error && code === 200) {
  540. // window.$message?.success('操作成功')
  541. // tableRawCheckedKeys.value=[]
  542. // linksRawModal.value = false
  543. // tableRawRef.value?.clearSelection();
  544. // }
  545. // else {
  546. // window.$message?.warning(error)
  547. // }
  548. }
  549. //关闭原材检测报告
  550. const linksRawModalClose = () => {
  551. linksRawModal.value = false
  552. linksRawTableData.value=[]
  553. tableRawRef.value?.clearSelection();
  554. }
  555. //关联取样
  556. const linksSampleModal = ref(false)
  557. const linksSampleModalClick = () => {
  558. linksSampleTableData.value = [];
  559. linksSampleModal.value = true
  560. }
  561. //搜索表单
  562. const linksSampleSearchForm = ref({
  563. nodeId: null, current: 1, size: 20, total: 0
  564. })
  565. //树被点击
  566. const linksSampleTreeClick = ({data}) => {
  567. linksSampleSearchForm.value.nodeId = data.primaryKeyId;
  568. linksSampleSearchForm.value.current = 1;
  569. getLinksSampleData()
  570. }
  571. //关联取样数据
  572. const tableSampleRef = ref(null)
  573. const linksSampleTableColumn = ref([
  574. {key:'materialName', name: '样品名称'},
  575. {key:'samplingDate', name: '取样日期'},
  576. {key:'specificationModel', name: '规格型号'},
  577. {key:'proposedPosition', name: '拟用部位'},
  578. {key:'userName', name: '取样人'},
  579. ])
  580. const linksSampleTableData = ref([])
  581. //获取关联数据
  582. const linksSampleTableLoading = ref(false)
  583. const getLinksSampleData = async () => {
  584. linksSampleTableLoading.value = true
  585. const { error, code, data } = await dataApi.sampleListInfo({
  586. ...linksSampleSearchForm.value,
  587. projectId: projectId.value,
  588. contractId: contractId.value,
  589. id:dataId
  590. })
  591. //处理数据
  592. linksSampleTableLoading.value = false
  593. if (!error && code === 200) {
  594. linksSampleTableData.value = getArrValue(data)
  595. linksSampleTableData.value.forEach((iten)=>{
  596. if(iten.isRelation===1){
  597. nextTick(()=>{
  598. tableSampleRef.value?.toggleRowSelection(iten,true);
  599. })
  600. }
  601. })
  602. //searchForm.value.total = data.total || 0
  603. } else {
  604. linksSampleTableData.value = []
  605. //searchForm.value.total = 0
  606. }
  607. }
  608. //获取关联原材料检测报告
  609. const getrawMaterialList = async () => {
  610. linksRawTableLoading.value = true
  611. const { error, code, data } = await dataApi.rawMaterialList({
  612. nodeId: linkNodeid.value,
  613. contractId: contractId.value,
  614. id:dataId
  615. })
  616. //处理数据
  617. linksRawTableLoading.value = false
  618. if (!error && code === 200) {
  619. linksRawTableData.value = getArrValue(data)
  620. linksRawTableData.value.forEach((iten)=>{
  621. if(iten.isRawMaterialRelation===1){
  622. nextTick(()=>{
  623. tableRawRef.value?.toggleRowSelection(iten,true);
  624. })
  625. }
  626. })
  627. //searchForm.value.total = data.total || 0
  628. } else {
  629. linksRawTableData.value = []
  630. //searchForm.value.total = 0
  631. }
  632. }
  633. //多选
  634. const tableSampleCheckedKeys = ref([]);
  635. const linksSampleTableSelection = (rows) => {
  636. tableSampleCheckedKeys.value = rows
  637. }
  638. //保存关联
  639. const linksSampleModalSave =async () => {
  640. const rows = tableSampleCheckedKeys.value
  641. listItemBaseData.value.sampleIds = rowsToId(rows) || '';
  642. console.log( rowsToId(rows),' rowsToId(rows)');
  643. const { error, code, data } = await dataApi.recordsampleSubmit({
  644. id: dataId,
  645. sampleIds:rowsToId(rows) || '',
  646. })
  647. if (!error && code === 200) {
  648. window.$message?.success('操作成功')
  649. tableSampleRef.value?.clearSelection();
  650. }
  651. else {
  652. // window.$message?.warning(error)
  653. }
  654. tableSampleCheckedKeys.value = [];
  655. linksSampleModal.value = false
  656. }
  657. //关闭关联取样
  658. const linksSampleModalClose = () => {
  659. linksSampleModal.value = false
  660. }
  661. //保存
  662. const tableFormSaveLoading = ref(false)
  663. const tableFormSaveClick = async () => {
  664. // console.log(listItemBaseData.value,'.listItemBaseData.value');
  665. //false是编辑
  666. //编辑要传记录和报告单
  667. if(checkrelationString.value.length>0){
  668. listItemBaseData.value.projectPosition=checkrelationString.value
  669. }
  670. if(tabTypeKey.value==='2'&&listItemBaseData.value.detectionResult===''){
  671. window.$message?.warning('请选择报告单是否合格')
  672. }else{
  673. // let FormData = ListItemRef.value?.getFormData()
  674. let FormData
  675. let curform=ListItemRef.value?.getFormData()
  676. setAllListData(curform)
  677. // alllistData.value.forEach((item)=>{
  678. // if(item.pKeyId===item1.pkeyId){
  679. console.log(orgAlllistData.value, "orgAlllistData");
  680. let operTrue = alllistData.value.filter(e => e.oper); //操作的数据
  681. let types = []
  682. operTrue.forEach(e => {
  683. types.push(e.type);
  684. })
  685. let setTypes = Array.from(new Set(types))
  686. let type = setTypes[0];
  687. if (setTypes.length > 1 || !isaddType) {
  688. FormData = alllistData.value;
  689. listItemBaseData.value.tableType = "1,2"
  690. if (!isaddType && setTypes.length <= 1) { //没有切换的时候,需要添加没切换的数据
  691. //编辑的时候,什么都不操作,原有type为undefined,需取当前页面type
  692. type = setTypes.length == 0 ? alllistData.value[0].type : type;
  693. let notChangeData = orgAlllistData.value.filter(e => e.tableType !== type);
  694. notChangeData.forEach(item => {
  695. let data = {
  696. projectId: item.projectId,
  697. contractId: contractId.value,
  698. pkeyId: item.pKeyId,
  699. nodeId: routerQuery?.nodeId,
  700. isCollapseLoad: false
  701. }
  702. // 过滤存在的key_的键值
  703. let ishasKey= Object.keys(item).filter(e => e.indexOf("key_") >= 0)
  704. if (ishasKey.length > 0) {
  705. ishasKey.forEach(key => {
  706. data[key] = item[key]
  707. })
  708. }
  709. console.log(data, "notChangeData");
  710. FormData.push(data)
  711. })
  712. }
  713. } else {
  714. FormData = alllistData.value.filter(e => e.type == type);
  715. listItemBaseData.value.tableType = type
  716. }
  717. let FormRegExpJson = ListItemRef.value?.getFormRegExpJson()
  718. console.log(isaddType,'isaddType');
  719. //效验数据
  720. if (FormData.length > 0) {
  721. if( listItemBaseData.value.detectionResult===''&& listItemBaseData.value.tableType == "1,2"){
  722. window.$message?.warning('请选择报告单是否合格')
  723. }else{
  724. tableFormSaveLoading.value = true
  725. const {error, code,data} = await dataApi.saveExcelBussData({
  726. ...listItemBaseData.value,
  727. isBatchSave:1,
  728. dataInfo: {orderList: FormData},
  729. // deviceUseIds:listDeviceUseIds.value
  730. })
  731. nodeIdvalue.value=data
  732. tableFormSaveLoading.value = false
  733. if (!error && code === 200) {
  734. window?.$message?.success('保存成功')
  735. listItemBaseData.value.deviceUseIds=''
  736. checkTabId.value=''
  737. // alllistData.value.forEach(e => e.oper = false)
  738. alllistData.value=[]
  739. if(!isaddType){
  740. bussPdfsClick(router.currentRoute.value.query.id)
  741. }else{
  742. bussPdfsClick(nodeIdvalue.value)
  743. // toBackClick()
  744. }
  745. getTableDataAll()
  746. }
  747. }
  748. } else {
  749. if(!isaddType){
  750. window.$message?.warning('请先选择你需要编辑的表格')
  751. bussPdfsClick(router.currentRoute.value.query.id)
  752. }else{
  753. window.$message?.warning('请先选择你需要新增的表格')
  754. }
  755. }
  756. }
  757. }
  758. const setAllListData = (curform) => {
  759. console.log(curform,'setAllListData curform');
  760. curform.forEach((item)=>{
  761. let pkeyId = item.pkeyId;
  762. item.oper = false
  763. let ishasKey= Object.keys(item).filter(e => e.indexOf("key_") >= 0)
  764. if (ishasKey.length>0) { //筛出当前编辑过的数据
  765. item.oper = true
  766. }
  767. let types = orgAlllistData.value.filter(e => e.pKeyId === pkeyId);
  768. item.type = types[0].tableType;
  769. alllistData.value = alllistData.value.filter(e => e.pkeyId != pkeyId); //去掉老数据
  770. alllistData.value.push(item) //加入新数据
  771. })
  772. console.log(alllistData.value,'setAllListData alllistData');
  773. }
  774. //效验数据
  775. const setFormRegExpJson = (FormRegExpJson) => {
  776. let nodeName = '', itemId = '';
  777. Object.keys(FormRegExpJson).forEach(key => {
  778. const name = FormRegExpJson[key]?.nodeName ?? ''
  779. if (name) {
  780. if (nodeName) {
  781. nodeName += ',' + name
  782. } else {
  783. nodeName = name
  784. itemId = FormRegExpJson[key]?.itemId
  785. }
  786. }
  787. })
  788. //const activeKey = ListItemRef.value?.getActiveKey()
  789. //弹出提示
  790. const val = '<div style="font-size: 16px;">请先完善 <span style="color:#1ECC95;">' + nodeName + '</span> 的数据内容</div>'
  791. window?.$messageBox?.alert(val, '表单完善提醒', {
  792. confirmButtonText: '确定',
  793. dangerouslyUseHTMLString: true,
  794. callback: (action) => {
  795. if (action === 'confirm') {
  796. ListItemRef.value?.setActiveKey(itemId)
  797. ListItemOffsetTop(0)
  798. setTimeout(() => {
  799. const offsetTop = document.getElementById(itemId)?.offsetTop
  800. ListItemOffsetTop(offsetTop)
  801. }, 350)
  802. }
  803. }
  804. })
  805. }
  806. //获取数据列表
  807. const nodeItemInfo = ref({})
  808. const nodeDataInfo = ref({})
  809. //查询状态
  810. const NodeStatus = ref('1')
  811. const queryNodeStatus = async () => {
  812. const info = getStoreData('prenodeDataInfo') || {}
  813. const {error, code, data} = await wbsApi.queryNodeStatusTrial({
  814. // primaryKeyId: info['contractIdRelation'] ? info['id'] : info['primaryKeyId'],
  815. id: dataId,
  816. classify: authBtnTabKey.value
  817. })
  818. //1 未填报,2待上报,3已上报
  819. if (!error && code === 200) {
  820. NodeStatus.value = data ?? '1'
  821. } else {
  822. NodeStatus.value = '1'
  823. }
  824. }
  825. //批量上报
  826. const reportIds = ref('')
  827. const reportTaskName = ref('')
  828. const reportAddition = ref({})
  829. const showReportModal = ref(false)
  830. const reportLoading = ref(false)
  831. const reportTypeData = ref([])
  832. // const reportModalClick = async () => {
  833. // showReportModal.value = true
  834. // }
  835. //上报完成
  836. const showReportFinish = () => {
  837. showReportModal.value = false
  838. getTableDataAll()
  839. }
  840. const reportModalClick = async () => {
  841. const info = getStoreData('prenodeDataInfo') || {}
  842. console.log(info,'info');
  843. const rows = listItemData.value;
  844. if (rows.length > 0) {
  845. reportLoading.value = true
  846. const taskCheck = await eVisaTaskCheckApi({
  847. projectId: projectId.value,
  848. contractId: contractId.value
  849. })
  850. //处理数据
  851. let newArr = [];
  852. // console.log(rows,'rows');
  853. for (let i = 0; i < rows.length; i++) {
  854. newArr.push(rows[i]['pKeyId'])
  855. }
  856. reportTypeData.value = newArr
  857. reportLoading.value = false
  858. if (taskCheck) {
  859. //初始弹出弹窗,防呆
  860. // reportIds.value = info['primaryKeyId'] dataId
  861. reportIds.value = dataId
  862. reportAddition.value = {
  863. classify: authBtnTabKey.value,
  864. contractIdRelation: info['contractIdRelation'],
  865. }
  866. showReportModal.value = true
  867. //请求文件题名
  868. const {data} = await wbsApi.queryDocumentTitle({
  869. // primaryKeyId: info['primaryKeyId'],
  870. primaryKeyId:dataId,
  871. classify: authBtnTabKey.value
  872. })
  873. reportTaskName.value = isString(data)? data : ''
  874. }
  875. } else {
  876. window.$message?.warning('暂无相关数据')
  877. }
  878. }
  879. //多表预览
  880. const bussPdfsLoading = ref(false)
  881. const nodeIdvalue=ref('')
  882. const bussPdfsClick = async (nodeId) => {
  883. bussPdfsLoading.value = true
  884. const {error, code, data} = await dataApi.getBussPdfs({
  885. projectId: projectId.value,
  886. contractId: contractId.value,
  887. classify: authBtnTabKey.value,
  888. tableType: tabTypeKey.value,
  889. // nodeId: router.currentRoute.value.query.id,
  890. nodeId: nodeId,
  891. })
  892. bussPdfsLoading.value = false
  893. if (!error && code === 200) {
  894. window.open(data,'_blank')
  895. } else {
  896. window.$message?.warning('获取PDF失败')
  897. }
  898. }
  899. //撤回上报流程
  900. // const abolishOneClick = () => {
  901. // window.$message?.warning('暂无接口')
  902. // }
  903. //撤回上报流程
  904. const abolishOneClick = () => {
  905. window?.$messageBox?.alert('请谨慎考虑后,是否确定撤回?', '撤回上报', {
  906. showCancelButton: true,
  907. confirmButtonText: '确定撤回',
  908. cancelButtonText: '取消',
  909. callback: (action) => {
  910. if (action === 'confirm') {
  911. abolishOneSave()
  912. }
  913. }
  914. })
  915. }
  916. //撤回请求
  917. const abolishOneSave = async () => {
  918. const info = getStoreData('prenodeDataInfo') || {}
  919. const {error, code} = await wbsApi.abolishOne({
  920. // primaryKeyId: info?.primaryKeyId || '',
  921. primaryKeyId: dataId,
  922. classify: authBtnTabKey.value
  923. })
  924. if (!error && code === 200) {
  925. window.$message?.success('撤回成功')
  926. getTableDataAll()
  927. }
  928. }
  929. //返回
  930. const toBackClick = () => {
  931. router.push({
  932. path: '/tentative/detect/test',
  933. query: {}
  934. })
  935. }
  936. const updeviceUseIds = (val) => {
  937. listItemBaseData.value.deviceUseIds=val
  938. }
  939. </script>
  940. <style lang="scss" scoped>
  941. @import "../../../styles/tentative/detect/test-form.scss";
  942. </style>