test-form.vue 33 KB

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