test-form.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965
  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. listItemBaseData.value.tableType=key
  232. if(tabTypeKey.value==='2'){
  233. leftFormData.value=ListItemRef.value?.getFormData()
  234. }else{
  235. rightFormData.value=ListItemRef.value?.getFormData()
  236. }
  237. getSearchNodeTables()
  238. }
  239. //获取检测类别类型
  240. const categoryData = ref([])
  241. const getCategoryData = async () => {
  242. const { data } = await getDictionary({
  243. code: 'trial_detection_category'
  244. })
  245. const arrData = getArrValue(data)
  246. arrData.forEach(item => {
  247. item.dictKey = Number(item.dictKey)
  248. })
  249. categoryData.value = arrData
  250. }
  251. //顶部表单
  252. const ListItemRef = ref(null);
  253. const listItemBaseData = ref({
  254. sampleIds: '', contractId: null, nodeId: nodeId, trialProjectName: null, type: dataType, tableType: '1',
  255. detectionCategory: '', detectionResult: '', reportDate: '', trialUserName: '', id: dataId,
  256. })
  257. //获取数据
  258. const isLoading = ref(false)
  259. const listItemData = ref([])
  260. const listDeviceUseIds=ref('')
  261. const reportData=ref([])
  262. const testData=ref([])
  263. const getSearchNodeTables = async () => {
  264. isLoading.value = true
  265. if(isaddType){
  266. const { error, code, data } = await dataApi.searchNodeTables({
  267. id: dataId,
  268. projectId: projectId.value,
  269. contractId: contractId.value,
  270. primaryKeyId: nodeId,
  271. type: authBtnTabKey.value,
  272. tableType: tabTypeKey.value,
  273. isAdd: 1
  274. })
  275. //处理数据
  276. isLoading.value = false
  277. if (!error && code === 200) {
  278. listItemData.value = getArrValue(data)
  279. } else {
  280. listItemData.value = []
  281. }
  282. }else{
  283. queryNodeStatus()//查询按钮状态
  284. const { error, code, data } = await dataApi.searchNodeTables({
  285. id: dataId,
  286. projectId: projectId.value,
  287. contractId: contractId.value,
  288. primaryKeyId: nodeId,
  289. type: authBtnTabKey.value,
  290. tableType: tabTypeKey.value,
  291. })
  292. //处理数据
  293. isLoading.value = false
  294. if (!error && code === 200) {
  295. listItemData.value = getArrValue(data)
  296. } else {
  297. listItemData.value = []
  298. }
  299. }
  300. }
  301. const getSearchNodeTablesall = async (type) => {
  302. const { error, code, data } = await dataApi.searchNodeTables({
  303. id: dataId,
  304. projectId: projectId.value,
  305. contractId: contractId.value,
  306. primaryKeyId: nodeId,
  307. type: authBtnTabKey.value,
  308. tableType: type,
  309. isAdd: 1
  310. })
  311. //处理数据
  312. isLoading.value = false
  313. if (!error && code === 200) {
  314. // listItemData.value = getArrValue(data)
  315. if(type==1){
  316. testData.value= getArrValue(data)
  317. }else{
  318. reportData.value= getArrValue(data)
  319. }
  320. } else {
  321. // listItemData.value = []
  322. if(type==1){
  323. testData.value= []
  324. }else{
  325. reportData.value= []
  326. }
  327. }
  328. }
  329. //获取数据
  330. const getTableDataAll = () => {
  331. getSearchNodeTables()
  332. queryNodeStatus()
  333. }
  334. //设置滚动条位置
  335. const ListItemScrollRef = ref(null)
  336. const ListItemOffsetTop = (offsetTop) => {
  337. if (offsetTop > 0) {
  338. setTimeout(() => {
  339. ListItemScrollRef.value?.setScrollTop(offsetTop)
  340. }, 350)
  341. } else {
  342. ListItemScrollRef.value?.setScrollTop(offsetTop)
  343. }
  344. }
  345. const checkTabId=ref('')
  346. const upcheckTableId = (val) => {
  347. checkTabId.value=val
  348. }
  349. //关联工程用途及部位 树
  350. const linksRelateModal = ref(false)
  351. const linksRelateModalClick = () => {
  352. linksRelateModal.value = true
  353. linksRelateSearchTreeVal.value=''
  354. getContractInfoTreeApi()
  355. }
  356. //获取导入树
  357. const unmatchedTreeData = ref([])
  358. const defaultCheckarrIds=ref([])
  359. const isdivisionLoading=ref(false)
  360. const getContractInfoTreeApi = async () => {
  361. isdivisionLoading.value=true
  362. const {error, code, data} = await divisionApi.getengineerInfoTree1({
  363. projectId: projectId.value,
  364. contractId: contractId.value,
  365. wbsId: projectInfo?.value.referenceWbsTemplateId,
  366. selfId:dataId
  367. })
  368. //判断状态
  369. if (!error && code === 200) {
  370. unmatchedTreeData.value = getArrValue(data['treeContractAll'])
  371. searchTreeData.value = getArrValue(data['treeContractAll'])
  372. setStoreData('unmatchedTreeData', unmatchedTreeData.value)
  373. defaultCheckarrIds.value=getArrValue(data['isSelectedStatus'])
  374. checkrelationId.value=getArrValue(data['isSelectedStatus'])
  375. } else {
  376. unmatchedTreeData.value = []
  377. }
  378. isdivisionLoading.value=false
  379. }
  380. //关联树
  381. const divisionTreeItemInfo = ref({})
  382. const divisionTreeClick = ({data}) => {
  383. divisionTreeItemInfo.value = data
  384. }
  385. const checkrelationId=ref([])
  386. const checkrelationString=ref([])
  387. const divisionTreeCheck = (data) => {
  388. checkrelationId.value=data
  389. }
  390. const seaElTreeProps = ref({
  391. label: 'title',
  392. children: 'children'
  393. })
  394. const linksRelateSearchTreeVal = ref('')
  395. // watch(tabTypeKey, (val) => {
  396. // if(val){
  397. // console.log(val);
  398. // if (val==='1') {
  399. // leftFormData.value=ListItemRef.value?.getFormData()
  400. // }else{
  401. // rightFormData.value= ListItemRef.value?.getFormData()
  402. // }
  403. // }
  404. // },
  405. // )
  406. watch(linksRelateSearchTreeVal, (val) => {
  407. if(!val.length){
  408. clearSearch()
  409. }
  410. },
  411. )
  412. const linksRelateTreeLoading = ref(false)
  413. const searchTreeData = ref([])
  414. const searchlinksRelateTreeLoading = ref(false)
  415. const searchTreeKeyUp = (e) => {
  416. if (e.key === "Enter") {
  417. searchTreeClick()
  418. }
  419. }
  420. const clearSearch = (e) => {
  421. isSearchTree.value=true
  422. searchlinksRelateTreeLoading.value = true
  423. setTimeout(()=>{
  424. searchlinksRelateTreeLoading.value = false
  425. },3000)
  426. }
  427. //树搜索
  428. const isSearchTree = ref(false)
  429. const searchTreeClick = async () => {
  430. if (linksRelateSearchTreeVal.value) {
  431. nextTick(()=> {
  432. isSearchTree.value=false
  433. })
  434. // const {error, code, data} = await queryApi.searchContractTree({
  435. // contractId: contractId.value,
  436. // queryValue: linksRelateSearchTreeVal.value
  437. // })
  438. // //判断状态
  439. // if (!error && code === 200) {
  440. // searchlinksRelateTreeLoading.value = false
  441. // } else {
  442. // searchlinksRelateTreeLoading.value = false
  443. // searchTreeData.value = []
  444. // }
  445. }
  446. }
  447. //确认关联
  448. const linksRelateModalSave =async () => {
  449. let idarr=[]
  450. checkrelationId.value.forEach((item)=>{
  451. idarr.push(item.primaryKeyId)
  452. })
  453. checkrelationString.value=idarr.toString()
  454. const { error, code, data } = await dataApi.projectpositionSubmit({
  455. id: dataId,
  456. projectPosition:checkrelationString.value,
  457. })
  458. if (!error && code === 200) {
  459. window.$message?.success('操作成功')
  460. linksRelateModal.value = false
  461. }else {
  462. window.$message?.warning(error)
  463. linksRelateModal.value = false
  464. }
  465. }
  466. const linksRelateModalClose = () => {
  467. linksRelateModal.value = false
  468. }
  469. //关联原材检测报告
  470. const linksRawModal = ref(false)
  471. const linksRawModalClick = () => {
  472. linksRawModal.value = true
  473. }
  474. const linkNodeid=ref('')
  475. //树被点击
  476. const linksRawTreeClick = ({data}) => {
  477. linkNodeid.value=data.primaryKeyId
  478. getrawMaterialList()
  479. }
  480. //原材检测报告数据
  481. const tableRawRef = ref(null)
  482. const linksRawTableColumn = ref([
  483. {key:'reportNo', name: '报告编号'},
  484. {key:'trialProjectName', name: '试验项目名称'},
  485. {key:'projectPositionName', name: '工程部位及用途'},
  486. {key:'reportDate', name: '报告日期'}
  487. ])
  488. const linksRawTableData = ref([])
  489. const linksRawTableLoading = ref(false)
  490. //多选
  491. const tableRawCheckedKeys = ref([]);
  492. const tableRawCheckedKeysid = ref('');
  493. const linksRawTableSelection = (rows) => {
  494. tableRawCheckedKeys.value = rows
  495. let arr=[]
  496. tableRawCheckedKeys.value.forEach((item)=>{
  497. arr.push(item.id)
  498. })
  499. tableRawCheckedKeysid.value=arr.join()
  500. }
  501. const linksRawModalSave =async () => {
  502. const { error, code, data } = await dataApi.rawMaterialSubmit({
  503. id: dataId,
  504. ids:tableRawCheckedKeysid.value,
  505. projectId: projectId.value,
  506. contractId: contractId.value,
  507. primaryKeyId: nodeId,
  508. type: authBtnTabKey.value,
  509. })
  510. if (!error && code === 200) {
  511. window.$message?.success('操作成功')
  512. tableRawCheckedKeys.value=[]
  513. linksRawModal.value = false
  514. tableRawRef.value?.clearSelection();
  515. }
  516. else {
  517. window.$message?.warning(error)
  518. }
  519. }
  520. //关闭原材检测报告
  521. const linksRawModalClose = () => {
  522. linksRawModal.value = false
  523. linksRawTableData.value=[]
  524. tableRawRef.value?.clearSelection();
  525. }
  526. //关联取样
  527. const linksSampleModal = ref(false)
  528. const linksSampleModalClick = () => {
  529. linksSampleTableData.value = [];
  530. linksSampleModal.value = true
  531. }
  532. //搜索表单
  533. const linksSampleSearchForm = ref({
  534. nodeId: null, current: 1, size: 20, total: 0
  535. })
  536. //树被点击
  537. const linksSampleTreeClick = ({data}) => {
  538. linksSampleSearchForm.value.nodeId = data.primaryKeyId;
  539. linksSampleSearchForm.value.current = 1;
  540. getLinksSampleData()
  541. }
  542. //关联取样数据
  543. const tableSampleRef = ref(null)
  544. const linksSampleTableColumn = ref([
  545. {key:'materialName', name: '样品名称'},
  546. {key:'samplingDate', name: '取样日期'},
  547. {key:'specificationModel', name: '规格型号'},
  548. {key:'proposedPosition', name: '拟用部位'},
  549. {key:'userName', name: '取样人'},
  550. ])
  551. const linksSampleTableData = ref([])
  552. //获取关联数据
  553. const linksSampleTableLoading = ref(false)
  554. const getLinksSampleData = async () => {
  555. linksSampleTableLoading.value = true
  556. const { error, code, data } = await dataApi.sampleListInfo({
  557. ...linksSampleSearchForm.value,
  558. projectId: projectId.value,
  559. contractId: contractId.value,
  560. id:dataId
  561. })
  562. //处理数据
  563. linksSampleTableLoading.value = false
  564. if (!error && code === 200) {
  565. linksSampleTableData.value = getArrValue(data)
  566. linksSampleTableData.value.forEach((iten)=>{
  567. if(iten.isRelation===1){
  568. nextTick(()=>{
  569. tableSampleRef.value?.toggleRowSelection(iten,true);
  570. })
  571. }
  572. })
  573. //searchForm.value.total = data.total || 0
  574. } else {
  575. linksSampleTableData.value = []
  576. //searchForm.value.total = 0
  577. }
  578. }
  579. //获取关联原材料检测报告
  580. const getrawMaterialList = async () => {
  581. linksRawTableLoading.value = true
  582. const { error, code, data } = await dataApi.rawMaterialList({
  583. nodeId: linkNodeid.value,
  584. contractId: contractId.value,
  585. id:dataId
  586. })
  587. //处理数据
  588. linksRawTableLoading.value = false
  589. if (!error && code === 200) {
  590. linksRawTableData.value = getArrValue(data)
  591. linksRawTableData.value.forEach((iten)=>{
  592. if(iten.isRawMaterialRelation===1){
  593. nextTick(()=>{
  594. tableRawRef.value?.toggleRowSelection(iten,true);
  595. })
  596. }
  597. })
  598. //searchForm.value.total = data.total || 0
  599. } else {
  600. linksRawTableData.value = []
  601. //searchForm.value.total = 0
  602. }
  603. }
  604. //多选
  605. const tableSampleCheckedKeys = ref([]);
  606. const linksSampleTableSelection = (rows) => {
  607. tableSampleCheckedKeys.value = rows
  608. }
  609. //保存关联
  610. const linksSampleModalSave =async () => {
  611. const rows = tableSampleCheckedKeys.value
  612. listItemBaseData.value.sampleIds = rowsToId(rows) || '';
  613. console.log( rowsToId(rows),' rowsToId(rows)');
  614. const { error, code, data } = await dataApi.recordsampleSubmit({
  615. id: dataId,
  616. sampleIds:rowsToId(rows) || '',
  617. })
  618. if (!error && code === 200) {
  619. window.$message?.success('操作成功')
  620. tableSampleRef.value?.clearSelection();
  621. }
  622. else {
  623. // window.$message?.warning(error)
  624. }
  625. tableSampleCheckedKeys.value = [];
  626. linksSampleModal.value = false
  627. }
  628. //关闭关联取样
  629. const linksSampleModalClose = () => {
  630. linksSampleModal.value = false
  631. }
  632. //保存
  633. const tableFormSaveLoading = ref(false)
  634. const tableFormSaveClick = async () => {
  635. console.log(listItemBaseData.value,'.listItemBaseData.value');
  636. console.log(isaddType,'isaddType');
  637. //false是编辑
  638. //编辑要传记录和报告单
  639. if(checkrelationString.value.length>0){
  640. listItemBaseData.value.projectPosition=checkrelationString.value
  641. }
  642. if(tabTypeKey.value==='2'&&listItemBaseData.value.detectionResult===''){
  643. window.$message?.warning('请选择是否合格')
  644. }else{
  645. // let FormData = ListItemRef.value?.getFormData()
  646. let FormData
  647. if(leftFormData.value===undefined||rightFormData.value===undefined){
  648. FormData =ListItemRef.value?.getFormData()
  649. listItemBaseData.value.tableType=tabTypeKey.value
  650. }
  651. else if(leftFormData.value?.length===0&&rightFormData.value?.length===0){
  652. FormData =ListItemRef.value?.getFormData()
  653. listItemBaseData.value.tableType=tabTypeKey.value
  654. }
  655. else if(leftFormData.value?.length>0&&tabTypeKey.value==='2'&&ListItemRef.value?.getFormData().length>0){
  656. FormData = leftFormData.value?.concat(ListItemRef.value?.getFormData())
  657. listItemBaseData.value.tableType='1,2'
  658. }else if(rightFormData.value?.length>0&&tabTypeKey.value==='1'&&ListItemRef.value?.getFormData().length>0){
  659. FormData = rightFormData.value?.concat(ListItemRef.value?.getFormData())
  660. listItemBaseData.value.tableType='1,2'
  661. }
  662. else{
  663. FormData = leftFormData.value?.concat(rightFormData.value)
  664. listItemBaseData.value.tableType='1,2'
  665. }
  666. let FormRegExpJson = ListItemRef.value?.getFormRegExpJson()
  667. console.log(getObjNullValue(FormRegExpJson),'getObjNullValue(FormRegExpJson)');
  668. //效验数据
  669. if (FormData.length > 0) {
  670. tableFormSaveLoading.value = true
  671. const {error, code,data} = await dataApi.saveExcelBussData({
  672. ...listItemBaseData.value,
  673. isBatchSave:1,
  674. dataInfo: {orderList: FormData},
  675. // deviceUseIds:listDeviceUseIds.value
  676. })
  677. nodeIdvalue.value=data
  678. tableFormSaveLoading.value = false
  679. if (!error && code === 200) {
  680. window?.$message?.success('保存成功')
  681. listItemBaseData.value.deviceUseIds=''
  682. checkTabId.value=''
  683. if(!isaddType){
  684. bussPdfsClick(router.currentRoute.value.query.id)
  685. }else{
  686. bussPdfsClick(nodeIdvalue.value)
  687. // toBackClick()
  688. }
  689. getTableDataAll()
  690. }
  691. } else {
  692. if(!isaddType){
  693. window.$message?.warning('请先选择你需要编辑的表格')
  694. bussPdfsClick(router.currentRoute.value.query.id)
  695. }else{
  696. window.$message?.warning('请先选择你需要新增的表格')
  697. }
  698. }
  699. }
  700. }
  701. //效验数据
  702. const setFormRegExpJson = (FormRegExpJson) => {
  703. let nodeName = '', itemId = '';
  704. Object.keys(FormRegExpJson).forEach(key => {
  705. const name = FormRegExpJson[key]?.nodeName ?? ''
  706. if (name) {
  707. if (nodeName) {
  708. nodeName += ',' + name
  709. } else {
  710. nodeName = name
  711. itemId = FormRegExpJson[key]?.itemId
  712. }
  713. }
  714. })
  715. //const activeKey = ListItemRef.value?.getActiveKey()
  716. //弹出提示
  717. const val = '<div style="font-size: 16px;">请先完善 <span style="color:#1ECC95;">' + nodeName + '</span> 的数据内容</div>'
  718. window?.$messageBox?.alert(val, '表单完善提醒', {
  719. confirmButtonText: '确定',
  720. dangerouslyUseHTMLString: true,
  721. callback: (action) => {
  722. if (action === 'confirm') {
  723. ListItemRef.value?.setActiveKey(itemId)
  724. ListItemOffsetTop(0)
  725. setTimeout(() => {
  726. const offsetTop = document.getElementById(itemId)?.offsetTop
  727. ListItemOffsetTop(offsetTop)
  728. }, 350)
  729. }
  730. }
  731. })
  732. }
  733. //获取数据列表
  734. const nodeItemInfo = ref({})
  735. const nodeDataInfo = ref({})
  736. //查询状态
  737. const NodeStatus = ref('1')
  738. const queryNodeStatus = async () => {
  739. const info = getStoreData('prenodeDataInfo') || {}
  740. const {error, code, data} = await wbsApi.queryNodeStatusTrial({
  741. // primaryKeyId: info['contractIdRelation'] ? info['id'] : info['primaryKeyId'],
  742. id: dataId,
  743. classify: authBtnTabKey.value
  744. })
  745. //1 未填报,2待上报,3已上报
  746. if (!error && code === 200) {
  747. NodeStatus.value = data ?? '1'
  748. } else {
  749. NodeStatus.value = '1'
  750. }
  751. }
  752. //批量上报
  753. const reportIds = ref('')
  754. const reportTaskName = ref('')
  755. const reportAddition = ref({})
  756. const showReportModal = ref(false)
  757. const reportLoading = ref(false)
  758. const reportTypeData = ref([])
  759. // const reportModalClick = async () => {
  760. // showReportModal.value = true
  761. // }
  762. //上报完成
  763. const showReportFinish = () => {
  764. showReportModal.value = false
  765. getTableDataAll()
  766. }
  767. const reportModalClick = async () => {
  768. const info = getStoreData('prenodeDataInfo') || {}
  769. console.log(info,'info');
  770. const rows = listItemData.value;
  771. if (rows.length > 0) {
  772. reportLoading.value = true
  773. const taskCheck = await eVisaTaskCheckApi({
  774. projectId: projectId.value,
  775. contractId: contractId.value
  776. })
  777. //处理数据
  778. let newArr = [];
  779. // console.log(rows,'rows');
  780. for (let i = 0; i < rows.length; i++) {
  781. newArr.push(rows[i]['pKeyId'])
  782. }
  783. reportTypeData.value = newArr
  784. reportLoading.value = false
  785. if (taskCheck) {
  786. //初始弹出弹窗,防呆
  787. // reportIds.value = info['primaryKeyId'] dataId
  788. reportIds.value = dataId
  789. reportAddition.value = {
  790. classify: authBtnTabKey.value,
  791. contractIdRelation: info['contractIdRelation'],
  792. }
  793. showReportModal.value = true
  794. //请求文件题名
  795. const {data} = await wbsApi.queryDocumentTitle({
  796. // primaryKeyId: info['primaryKeyId'],
  797. primaryKeyId:dataId,
  798. classify: authBtnTabKey.value
  799. })
  800. reportTaskName.value = isString(data)? data : ''
  801. }
  802. } else {
  803. window.$message?.warning('暂无相关数据')
  804. }
  805. }
  806. //多表预览
  807. const bussPdfsLoading = ref(false)
  808. const nodeIdvalue=ref('')
  809. const bussPdfsClick = async (nodeId) => {
  810. bussPdfsLoading.value = true
  811. const {error, code, data} = await dataApi.getBussPdfs({
  812. projectId: projectId.value,
  813. contractId: contractId.value,
  814. classify: authBtnTabKey.value,
  815. tableType: tabTypeKey.value,
  816. // nodeId: router.currentRoute.value.query.id,
  817. nodeId: nodeId,
  818. })
  819. bussPdfsLoading.value = false
  820. if (!error && code === 200) {
  821. window.open(data,'_blank')
  822. } else {
  823. window.$message?.warning('获取PDF失败')
  824. }
  825. }
  826. //撤回上报流程
  827. // const abolishOneClick = () => {
  828. // window.$message?.warning('暂无接口')
  829. // }
  830. //撤回上报流程
  831. const abolishOneClick = () => {
  832. window?.$messageBox?.alert('请谨慎考虑后,是否确定撤回?', '撤回上报', {
  833. showCancelButton: true,
  834. confirmButtonText: '确定撤回',
  835. cancelButtonText: '取消',
  836. callback: (action) => {
  837. if (action === 'confirm') {
  838. abolishOneSave()
  839. }
  840. }
  841. })
  842. }
  843. //撤回请求
  844. const abolishOneSave = async () => {
  845. const info = getStoreData('prenodeDataInfo') || {}
  846. const {error, code} = await wbsApi.abolishOne({
  847. // primaryKeyId: info?.primaryKeyId || '',
  848. primaryKeyId: dataId,
  849. classify: authBtnTabKey.value
  850. })
  851. if (!error && code === 200) {
  852. window.$message?.success('撤回成功')
  853. getTableDataAll()
  854. }
  855. }
  856. //返回
  857. const toBackClick = () => {
  858. router.push({
  859. path: '/tentative/detect/test',
  860. query: {}
  861. })
  862. }
  863. const updeviceUseIds = (val) => {
  864. listItemBaseData.value.deviceUseIds=val
  865. }
  866. </script>
  867. <style lang="scss" scoped>
  868. @import "../../../styles/tentative/detect/test-form.scss";
  869. </style>