test-form.vue 29 KB

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