first-itemcopy.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901
  1. <template>
  2. <div class="hc-layout-box" id="first-item-node-layout-target">
  3. <div class="hc-layout-left-box" :style="'width:' + leftWidth + 'px;'" v-show="!isFirstReportDrawer">
  4. <div class="hc-project-box">
  5. <div class="hc-project-icon-box">
  6. <HcIcon name="stack"/>
  7. </div>
  8. <div class="ml-2 project-name-box">
  9. <span class="text-xl text-cut project-alias">{{projectInfo['projectAlias']}}</span>
  10. <div class="text-xs text-cut project-name">{{projectInfo['name']}}</div>
  11. </div>
  12. </div>
  13. <div class="hc-tree-box">
  14. <el-scrollbar>
  15. <WbsTree :autoExpandKeys="TreeAutoExpandKeys" :projectId="projectId" :contractId="contractId" @nodeTap="nodeWbsElTreeClick"/>
  16. </el-scrollbar>
  17. </div>
  18. <!--左右拖动-->
  19. <div class="horizontal-drag-line" @mousedown="onmousedown"/>
  20. </div>
  21. <div class="hc-layout-content-box first-item" v-show="!isFirstReportDrawer">
  22. <HcCard :scrollbar="false" actionSize="lg">
  23. <template #header>
  24. <HcTooltip keys="other-first-item-report" v-if="tabTypeKey === 'mark'">
  25. <el-button type="primary" hc-btn :disabled="tableSelectionKeys.length <= 0" @click="firstReportClick">
  26. <HcIcon name="send-plane-2"/>
  27. <span>上报首件</span>
  28. </el-button>
  29. </HcTooltip>
  30. <HcTooltip keys="other-first-item-report-approval" v-if="tabTypeKey === 'query'">
  31. <el-button type="primary" hc-btn :disabled="tableSelectionKeys.length <= 0" @click="reportModalClick(1)">
  32. <HcIcon name="send-plane-2"/>
  33. <span>上报审批</span>
  34. </el-button>
  35. </HcTooltip>
  36. <HcTooltip keys="other-first-item-repeal" v-if="tabTypeKey === 'query'">
  37. <el-button hc-btn :disabled="tableSelectionKeys.length <= 0" @click="batchAbolishClick">
  38. <HcIcon name="delete-bin-3"/>
  39. <span>批量废除</span>
  40. </el-button>
  41. </HcTooltip>
  42. <HcTooltip keys="other-first-item-down-print">
  43. <el-button hc-btn :disabled="tableSelectionKeys.length <= 0" :loading="printLoading" @click="batchPrint">
  44. <HcIcon name="printer"/>
  45. <span>预览/打印</span>
  46. </el-button>
  47. </HcTooltip>
  48. </template>
  49. <template #extra>
  50. <HcNewSwitch :datas="tabTypeTab" :keys="tabTypeKey" @change="tabTypeChange"/>
  51. </template>
  52. <template #search>
  53. <div class="w-32">
  54. <el-select v-model="searchForm.status" placeholder="流程状态" clearable>
  55. <el-option v-for="item in processStatus" :label="item['dictValue']" :value="item['dictKey']"/>
  56. </el-select>
  57. </div>
  58. <div class="w-32 ml-3">
  59. <el-select v-model="searchForm.reportNumber" placeholder="上报批次" clearable>
  60. <el-option v-for="item in reportBatch" :label="item" :value="item"/>
  61. </el-select>
  62. </div>
  63. <div class="w-64 ml-3">
  64. <HcDatePicker :dates="betweenTime" clearable @change="betweenTimeUpdate"/>
  65. </div>
  66. <div class="w-64 ml-3">
  67. <el-input v-model="searchForm.queryValue" placeholder="请输入名称关键词检索" clearable @keyup="keyUpEvent"/>
  68. </div>
  69. <div class="ml-2">
  70. <el-button type="primary" @click="searchClick">
  71. <HcIcon name="search-2"/>
  72. <span>搜索</span>
  73. </el-button>
  74. </div>
  75. </template>
  76. <HcTable ref="tableListRef" :column="tableListColumn" :datas="tableListData" :loading="tableLoading" isCheck @selection-change="tableSelectionChange">
  77. <template #name="{row}">
  78. <span class="text-link" @click="tableRowName(row)">{{row?.name}}</span>
  79. </template>
  80. <template #waitingUserList="{row}">
  81. <template v-for="item in row['waitingUserList']">
  82. <el-tag :type="`${item.status === 2 ? 'success' : item.status === 3 ? 'warning' : item.status === 999 ? 'danger' : 'info'}`"
  83. class="mx-1" effect="dark" v-if="item['waitingUserName']">{{item['waitingUserName']}}</el-tag>
  84. </template>
  85. </template>
  86. <template #taskStatusStr="{row}">
  87. <el-tag :type="`${row.status === 2 ? 'success' : row.status === 0 ? 'warning' : row.status === 1 ? 'danger' : 'info'}`"
  88. class="mx-1" effect="dark" v-if="row['taskStatusStr']">{{row['taskStatusStr']}}</el-tag>
  89. </template>
  90. </HcTable>
  91. <template #action>
  92. <div class="lr-dialog-footer">
  93. <div class="left">
  94. <span class="text-success">任务人中:</span>
  95. <el-tag type="success" class="mx-1" effect="dark">已签字</el-tag>
  96. <el-tag type="warning" class="mx-1" effect="dark">已废除</el-tag>
  97. <el-tag type="danger" class="mx-1" effect="dark">签字异常</el-tag>
  98. </div>
  99. <div class="right">
  100. <HcPages :pages="searchForm" @change="pageChange"/>
  101. </div>
  102. </div>
  103. </template>
  104. </HcCard>
  105. </div>
  106. <!--上报首件-->
  107. <HcDrawer :show="isFirstReportDrawer" :isCard="false" uis="hc-first-item-node-layout" to-id="first-item-node-layout-target" @close="FirstReportDrawerClose">
  108. <div class="node-content">
  109. <div class="node-form">
  110. <el-scrollbar v-if="contractId && isTableForm" ref="ListItemScrollRef" >
  111. <!-- <div class="hc-excel-table-form-view" :id="`table-form-${contractId}`"></div> -->
  112. <ListItem ref="ListItemsRef"
  113. :datas="ListItemDatas"
  114. :status="NodeStatus"
  115. :classify="authBtnTabKey"
  116. @offsetTop="ListItemOffsetTop"
  117. :projectInfo="projectInfo"
  118. :treeItem="treeItem"
  119. :contractId="contractId"
  120. @renew="renewtable"
  121. :drawType="isDrawType"
  122. :tableFileData="tableFileData"
  123. :finishFile="finishFile"
  124. />
  125. </el-scrollbar>
  126. <HcStatus :desc="statusDesc" v-else/>
  127. </div>
  128. <div class="node-file">
  129. <div class="title">上传总结报告1111</div>
  130. <div class="node-upload-box" v-if="contractId && isTableForm">
  131. <HcUpload :fileList="fileListData" :pkeyId="pkeyIds" @finish='uploadChange'/>
  132. </div>
  133. <div class="node-upload-box" v-else>
  134. <el-alert title="表单异常,暂时无法使用上传" type="warning" show-icon :closable="false"/>
  135. </div>
  136. <el-divider border-style="dashed" />
  137. <div class="title">文件附件</div>
  138. <div class="hc-table-node-file-box">
  139. <HcTable :column="tableFileColumn" :datas="tableFileData" :isIndex="false">
  140. <template #action="{row,index}">
  141. <el-button type="danger" plain size="small" @click="tableDelButton(index)">删除</el-button>
  142. </template>
  143. </HcTable>
  144. </div>
  145. </div>
  146. </div>
  147. <div class="node-action">
  148. <el-button type="primary" hc-btn :disabled="!contractId || !isTableForm||NodeStatus === '3'" :loading="tableFormSaveLoading" @click="saveBussData">
  149. <HcIcon name="save"/>
  150. <span>保存</span>
  151. </el-button>
  152. <el-button hc-btn :disabled="!contractId || !isTableForm || !tableFormId||NodeStatus === '1'" @click="bussPdfInfo">
  153. <HcIcon name="eye"/>
  154. <span>预览</span>
  155. </el-button>
  156. <el-button hc-btn :disabled="!contractId || !isTableForm || !tableFormId||NodeStatus === '3' || NodeStatus === '1'" :loading="reportLoading" @click="reportModalClick(2)">
  157. <HcIcon name="send-plane-2"/>
  158. <span>上报</span>
  159. </el-button>
  160. <el-button hc-btn @click="FirstReportDrawerClose">
  161. <HcIcon name="close"/>
  162. <span>返回</span>
  163. </el-button>
  164. </div>
  165. </HcDrawer>
  166. <!--上报审批-->
  167. <HcReportModal
  168. title="上报审批"
  169. url="informationWriteQuery/batchTask"
  170. :show="showReportModal"
  171. :projectId="projectId"
  172. :contractId="contractId"
  173. type="first"
  174. :typeData="reportTypeData"
  175. :taskName="reportTaskName"
  176. :ids="reportIds"
  177. :isDatas="isReportModalDatas"
  178. :datas="reportDatas"
  179. @hide="showReportModal = false"
  180. @finish="showReportFinish"
  181. @tagClose="reportTaskTagClose"
  182. />
  183. </div>
  184. </template>
  185. <script setup>
  186. import {useAppStore} from "~src/store";
  187. import {nextTick, onMounted, ref, watch} from 'vue'
  188. import {useRouter, useRoute} from 'vue-router'
  189. import WbsTree from "./components/WbsTree.vue"
  190. import HcUpload from "./components/HcUpload.vue"
  191. import HTableForm from "~src/plugins/HTableForm"
  192. import {getReportNumber,eVisaTaskCheckApi} from "~api/other";
  193. import firstApi from '~api/other/first-item';
  194. import tasksApi from '~api/tasks/data';
  195. import {getStoreData, setStoreData} from '~src/utils/storage'
  196. import {getArrValue, isString, getObjValue, getObjNullValue,deepClone} from "vue-utils-plus"
  197. import queryApi from "~api/data-fill/query";
  198. import wbsApi from "~api/data-fill/wbs";
  199. import ListItem from "./components/ListItem.vue"
  200. //变量
  201. const router = useRouter()
  202. const useRoutes = useRoute()
  203. const useAppState = useAppStore()
  204. const projectId = ref(useAppState.getProjectId);
  205. const contractId = ref(useAppState.getContractId);
  206. const projectInfo = ref(useAppState.getProjectInfo);
  207. const contractInfo = ref(useAppState.getContractInfo);
  208. const isCollapse = ref(useAppState.getCollapse)
  209. //路由参数
  210. const routerQuery = useRoutes?.query;
  211. const typeName = routerQuery?.type || 'mark'
  212. //监听
  213. watch(() => [
  214. useAppState.getCollapse
  215. ], ([Collapse]) => {
  216. isCollapse.value = Collapse
  217. })
  218. //自动展开缓存
  219. const TreeAutoExpandKeys = ref(getStoreData('firstItemTreeKeys') || [])
  220. //类型tab数据和相关处理
  221. const tabTypeKey = ref(typeName)
  222. const tabTypeTab = ref([
  223. {key:'mark', name: '已标记为首件'},
  224. {key:'query', name: '首件查询'}
  225. ]);
  226. const tabTypeChange = (item) => {
  227. tableFormId.value = ''
  228. tabTypeKey.value = item?.key
  229. if (searchForm.value.wbsId) {
  230. searchForm.value.current = 1;
  231. getTableData()
  232. }
  233. //路由跳转
  234. router.push({
  235. path: useRoutes.path,
  236. query: {type: item?.key}
  237. })
  238. }
  239. //渲染完成
  240. onMounted(() => {
  241. firstTaskStatus()
  242. })
  243. const renewtable=()=>{
  244. getTableData()
  245. queryNodeStatus()
  246. }
  247. //项目树被点击
  248. const treeItem = ref({})
  249. const nodeWbsElTreeClick = ({data, keys}) => {
  250. treeItem.value = data
  251. searchForm.value.contractIdRelation = data['contractIdRelation']
  252. searchForm.value.wbsId = data['primaryKeyId']
  253. //缓存自动展开
  254. TreeAutoExpandKeys.value = keys
  255. setStoreData('firstItemTreeKeys', keys)
  256. //获取相关数据
  257. getReportNumberByContractId(data['contractIdRelation'])
  258. searchClick()
  259. }
  260. //获取流程状态
  261. const processStatus = ref([])
  262. const firstTaskStatus = async () => {
  263. const { data } = await tasksApi.queryTaskTypeStatus({
  264. typeOrStatus: 'first_task_status'
  265. })
  266. //处理数据
  267. processStatus.value = getArrValue(data)
  268. }
  269. //查询状态
  270. const NodeStatus = ref('1')
  271. const { contractType } = contractInfo.value;
  272. const authBtnTabKey = ref(contractType===2?'2':'1')
  273. const queryNodeStatus = async () => {
  274. const info = treeItem.value;
  275. console.log(info,'info')
  276. const {error, code, data} = await wbsApi.queryNodeStatus({
  277. // primaryKeyId: info['contractIdRelation'] ? info['id'] : info['primaryKeyId'],
  278. // classify: 1
  279. primaryKeyId: authBtnTabKey.value==1 ? info['id'] : info['primaryKeyId'],
  280. classify: authBtnTabKey.value
  281. })
  282. //1 未填报,2待上报,3已上报
  283. if (!error && code === 200) {
  284. NodeStatus.value = data ?? '1'
  285. } else {
  286. NodeStatus.value = '1'
  287. }
  288. }
  289. //获取上报批次
  290. const reportBatch = ref([])
  291. const getReportNumberByContractId = async (cid) => {
  292. const { data } = await getReportNumber({
  293. contractId: contractId.value,
  294. projectId:projectId.value,
  295. contractIdRelation: cid ?? '',
  296. firstTitle: tabTypeKey.value === 'query' ? 1: null
  297. })
  298. //处理数据
  299. reportBatch.value = getArrValue(data)
  300. }
  301. //搜索表单
  302. const searchForm = ref({
  303. wbsId: '', status: null, reportNumber: null, queryValue: '', betweenTime: '',
  304. contractIdRelation: '', current: 1, size: 20, total: 0
  305. })
  306. //日期时间被选择
  307. const betweenTime = ref(null)
  308. const betweenTimeUpdate = ({query,arr}) => {
  309. betweenTime.value = arr
  310. searchForm.value.betweenTime = query
  311. }
  312. //回车搜索
  313. const keyUpEvent = (e) => {
  314. if (e.key === "Enter") {
  315. searchClick()
  316. }
  317. }
  318. //搜索
  319. const searchClick = () => {
  320. if (searchForm.value.wbsId) {
  321. searchForm.value.current = 1;
  322. getTableData()
  323. } else {
  324. window?.$message?.warning('请先在左边选择一个树节点')
  325. }
  326. }
  327. //分页被点击
  328. const pageChange = ({current, size}) => {
  329. searchForm.value.current = current
  330. searchForm.value.size = size
  331. getTableData()
  332. }
  333. //表格表头
  334. const tableListColumn = ref([
  335. {key:'name', name: '文件名称'},
  336. {key:'waitingUserList', name: '任务人'},
  337. {key:'startTime', name: '开始时间', width: 180},
  338. {key:'taskStatusStr', name: '流程状态', width: 140},
  339. {key:'reportNumber', name: '上报批次', width: 120},
  340. ])
  341. //获取表格数据
  342. const tableLoading = ref(false)
  343. const tableListData = ref([])
  344. //获取数据列表
  345. const ListItemsRef = ref(null)
  346. //是否是抽屉
  347. const isDrawType = ref(false)
  348. //设置滚动条位置
  349. const ListItemScrollRef = ref(null)
  350. const ListItemOffsetTop = (offsetTop) => {
  351. if (offsetTop > 0) {
  352. setTimeout(() => {
  353. ListItemScrollRef.value?.setScrollTop(offsetTop)
  354. }, 350)
  355. } else {
  356. ListItemScrollRef.value?.setScrollTop(offsetTop)
  357. }
  358. }
  359. const getTableData = async () => {
  360. const searchInfo = searchForm.value
  361. const tabKey = tabTypeKey.value
  362. if (!!searchInfo.wbsId) {
  363. //初始处理
  364. tableLoading.value = true
  365. tableListRef.value?.clearSelection()
  366. tableSelectionKeys.value = []
  367. tableListData.value = []
  368. //获取相关数据
  369. let addFormData = {
  370. projectId: projectId.value,
  371. contractId: contractId.value,
  372. isFirst: 1,
  373. }
  374. const treeInfo = treeItem.value
  375. //已标记的首件
  376. if (tabKey === 'mark' && addFormData['firstTitle']) {
  377. delete addFormData.firstTitle
  378. }
  379. //查询数据
  380. if (tabKey === 'query') {
  381. addFormData['firstTitle'] = 1
  382. }
  383. addFormData['wbsId'] = treeInfo['contractIdRelation'] ? treeInfo['id'] : treeInfo['primaryKeyId']
  384. //处理数据
  385. const { error, code, data } = await firstApi.getQueryPageData({
  386. ...addFormData,
  387. ...searchInfo,
  388. })
  389. tableLoading.value = false
  390. if (!error && code === 200) {
  391. tableListData.value = getArrValue(data['records'])
  392. searchForm.value.total = data.total || 0
  393. } else {
  394. tableListData.value = []
  395. searchForm.value.total = 0
  396. }
  397. } else {
  398. window?.$message?.warning('请先选择一个树节点')
  399. }
  400. }
  401. //多选
  402. const tableListRef = ref(null)
  403. const tableSelectionKeys = ref([]);
  404. const tableSelectionChange = (rows) => {
  405. tableSelectionKeys.value = rows.filter((item) => {
  406. return (item??'') !== '';
  407. })
  408. }
  409. //文件名称被点击
  410. const tableRowName = (row) => {
  411. //如果 evisaPdfUrl 不为空,使用evisaPdfUrl,反之使用pdfUrl
  412. if (tabTypeKey.value === 'query') {
  413. //首件查询时,直接调用接口
  414. getBussPdfInfo(row.id + '')
  415. } else if (row['evisaPdfUrl']) {
  416. window.open(row['evisaPdfUrl'],'_blank')
  417. } else if (row['pdfUrl']) {
  418. window.open(row['pdfUrl'],'_blank')
  419. } else {
  420. window.$message?.warning('文件不存在')
  421. }
  422. }
  423. const ListItemDatas = ref([]);
  424. //上报首件
  425. const isFirstReportDrawer = ref(false)
  426. const isCanreport=ref(false)
  427. const firstReportClick = () => {
  428. const rows = deepClone(tableSelectionKeys.value)
  429. console.log(rows,'rows')
  430. nextTick(()=>{
  431. ListItemDatas.value=rows
  432. })
  433. console.log( ListItemDatas.value,' ListItemDatas.value')
  434. //判断是否满足条件
  435. const result = rows.every(({status})=> {
  436. return status === 2
  437. // return status === 0 || status === 3
  438. })
  439. isCanreport.value=result
  440. //判断状态
  441. // if (result) {
  442. // isFirstReportDrawer.value = true
  443. // queryNodeStatus()
  444. // tableFileData.value = rows
  445. // getFirstExcelHtml()
  446. // } else {
  447. // tableFileData.value = []
  448. // window.$message?.warning('已上报的文件不能进行再次上报,若要重新上报,要先撤回之前的上报,再重新上报')
  449. // }
  450. isFirstReportDrawer.value = true
  451. // getTableData()
  452. queryNodeStatus()
  453. tableFileData.value = rows
  454. getFirstExcelHtml()
  455. }
  456. const FirstReportDrawerClose = () => {
  457. isFirstReportDrawer.value = false
  458. }
  459. //获取表单
  460. const statusDesc = ref('')
  461. const isTableForm = ref(false)
  462. const pkeyIds = ref('')
  463. const getFirstExcelHtml = async () => {
  464. const cid = contractId.value;
  465. const { error, code, data } = await firstApi.getFirstExcelHtml({
  466. contractId: contractId.value || ''
  467. }, false)
  468. //处理数据
  469. const temp = isString(data?.data) ? data?.data || '' : ''
  470. if (!error && code === 200 && temp) {
  471. let pkeyId = data?.id || ''
  472. pkeyIds.value = pkeyId
  473. await getFirstBussDataInfo(pkeyId)
  474. setHTableForm(temp, cid)
  475. } else {
  476. isTableForm.value = false
  477. statusDesc.value = '暂无表单'
  478. window?.$message?.warning('暂无表单')
  479. }
  480. }
  481. //渲染表单
  482. const tableFormApp = ref(null)
  483. const setHTableForm = (resData, cid) => {
  484. //先卸载
  485. if (tableFormApp.value) {
  486. tableFormApp.value?.unmount()
  487. }
  488. if (resData) {
  489. isTableForm.value = true
  490. nextTick(() => {
  491. tableFormApp.value = HTableForm.createForm({
  492. template: resData,
  493. tableForm: tableFormData.value,
  494. appId: `#table-form-${cid}`
  495. })
  496. })
  497. } else {
  498. isTableForm.value = false
  499. statusDesc.value = '暂无表单'
  500. window?.$message?.warning('暂无表单')
  501. }
  502. }
  503. //获取回显数据
  504. const tableFormData = ref({})
  505. const getFirstBussDataInfo = async (pkeyId) => {
  506. if (pkeyId) {
  507. const { data } = await firstApi.getFirstBussDataInfo({
  508. contractId: contractId.value || '',
  509. firstId: pkeyId + ''
  510. }, false)
  511. const info = getObjValue(data)
  512. if (getObjNullValue(info)) {
  513. HTableForm.setPickerKey(info)
  514. tableFormData.value = info
  515. } else {
  516. tableFormData.value = {}
  517. }
  518. } else {
  519. tableFormData.value = {}
  520. }
  521. }
  522. //上传变量
  523. const fileListData = ref([]);
  524. const finishFile = ref({
  525. sourceUrl: '', pdfUrl: '', firstFileName: ''
  526. })
  527. //上传文件
  528. const uploadChange = async ({type, res}) => {
  529. if (type === 'success') {
  530. const {code, data, msg} = res
  531. if (code === 200) {
  532. finishFile.value = {
  533. sourceUrl: data?.sourceUrl,
  534. pdfUrl: data?.pdfUrl,
  535. firstFileName: data?.fileName,
  536. }
  537. window.$message?.success(msg);
  538. } else {
  539. window.$message?.error(msg || '上传失败');
  540. }
  541. }
  542. }
  543. //文件附件列表
  544. const tableFileColumn = ref([
  545. {key:'name', name: '文件名称'},
  546. {key:'action', name: '操作', width: 80, align: 'center'}
  547. ]);
  548. const tableFileData = ref([]);
  549. const tableDelButton = (index) => {
  550. const arr = tableFileData.value
  551. if (arr.length > 1) {
  552. window?.$messageBox?.alert('确定删除该文件吗?', '删除提醒', {
  553. type: 'warning',
  554. showCancelButton: true,
  555. confirmButtonText: '确定删除',
  556. cancelButtonText: '取消',
  557. callback: (action) => {
  558. if (action === 'confirm') {
  559. tableFileData.value.splice(index, 1)
  560. }
  561. }
  562. })
  563. } else {
  564. window?.$message?.warning('至少保留一个文件')
  565. }
  566. }
  567. //填报数据保存
  568. const pdfId=ref('')
  569. const saveBussData = async () => {
  570. console.log('保存');
  571. const { id } = treeItem.value
  572. const res = await saveExcelBussData(id + '')
  573. //刷新页面
  574. // window?.location?.reload() //刷新页面
  575. if (res) {
  576. pdfId.value=res
  577. queryNodeStatus()
  578. await getBussPdfInfo(res)
  579. }
  580. }
  581. //保存请求
  582. const tableFormSaveLoading = ref(false)
  583. const tableFormId = ref('')
  584. const saveExcelBussData = async (pkeyId) => {
  585. tableFormId.value = ''
  586. const { primaryKeyId } = treeItem.value
  587. tableFormSaveLoading.value = true
  588. const linkIds = rowsToArr(tableFileData.value);
  589. const { error, code, data } = await firstApi.saveBussData({
  590. ...tableFormData.value,
  591. projectId: projectId.value,
  592. contractId: contractId.value,
  593. firstNodeId: primaryKeyId,
  594. pkeyId: pkeyId,
  595. classify: '1',
  596. isFirst: 1,
  597. linkProcessList: linkIds,
  598. ...finishFile.value
  599. }, false)
  600. //判断状态
  601. tableFormSaveLoading.value = false
  602. if (!error && code === 200 && isString(data)) {
  603. window.$message?.success('保存成功')
  604. tableFormId.value = data
  605. return data
  606. } else {
  607. window.$message?.error('保存失败')
  608. tableFormId.value = ''
  609. return ''
  610. }
  611. }
  612. //pdf预览
  613. const bussPdfInfo = () => {
  614. const { id } = treeItem.value
  615. // getBussPdfInfo(id + '')
  616. getBussPdfInfo(pdfId.value)
  617. }
  618. //预览PDF请求
  619. const getBussPdfInfo = async (pkeyId) => {
  620. const { error, code, data } = await firstApi.getFirstBussPdfInfo({
  621. firstId: pkeyId
  622. })
  623. //判断状态
  624. const res = isString(data)? data ?? '': ''
  625. if (!error && code === 200 && res) {
  626. window.open(res,'_blank')
  627. }
  628. }
  629. //上报审批
  630. const reportIds = ref('')
  631. const showReportModal = ref(false)
  632. const reportTaskName = ref('')
  633. const reportAddition = ref({})
  634. const reportLoading = ref(false)
  635. const reportTypeData = ref('')
  636. const reportDatas = ref([])
  637. const isReportModalDatas = ref(false)
  638. const iscanReport=ref(false)
  639. //上报方法封装
  640. const toreportModalClick = async (type) => {
  641. if(type){
  642. const { primaryKeyId, contractIdRelation } = treeItem.value
  643. let rows = [];
  644. //处理获取流程的条件
  645. if (tabTypeKey.value === 'mark') {
  646. reportTypeData.value = tableFormId.value
  647. isReportModalDatas.value = false
  648. rows = tableFileData.value
  649. } else {
  650. isReportModalDatas.value = true
  651. rows = tableSelectionKeys.value
  652. }
  653. if (rows.length > 0) {
  654. reportLoading.value = true
  655. const taskCheck = await eVisaTaskCheckApi({
  656. projectId: projectId.value,
  657. contractId: contractId.value
  658. })
  659. if (taskCheck) {
  660. if (tabTypeKey.value === 'mark') {
  661. reportIds.value = tableFormId.value
  662. const { data } = await firstApi.queryFirstDocumentTitle({
  663. projectId: projectId.value,
  664. contractId: contractId.value,
  665. queryId: tableFormId.value
  666. })
  667. reportTaskName.value = isString(data) ? data ?? '' : ''
  668. } else {
  669. reportIds.value = rowsToId(rows)
  670. //设置任务数据
  671. let reportDataArr = []
  672. rows.forEach(item => {
  673. reportDataArr.push({
  674. id: item?.id,
  675. name: item?.name
  676. })
  677. })
  678. reportDatas.value = reportDataArr
  679. //其他数据
  680. reportTypeData.value = rows[0]['id']
  681. reportTaskName.value = rows.length > 1?`${rows[0].name}等${rows.length}个文件`:rows[0].name
  682. }
  683. reportLoading.value = false
  684. //附加数据
  685. reportAddition.value = {
  686. classify: 1,
  687. isFirst: 1,
  688. primaryKeyId: primaryKeyId,
  689. contractIdRelation: contractIdRelation ?? contractId.value,
  690. }
  691. showReportModal.value = true
  692. } else {
  693. reportLoading.value = false
  694. }
  695. } else {
  696. window.$message?.warning('暂无相关数据')
  697. }
  698. }else{
  699. window.$message?.warning('当前工序资料还未审批,待审批完成才能进行首件模板上报')
  700. }
  701. }
  702. const reportModalClick = async (type) => {
  703. if(type===2){
  704. console.log('上报')
  705. iscanReport.value=isCanreport.value;
  706. toreportModalClick(iscanReport.value)
  707. }
  708. else{
  709. const rows = deepClone(tableSelectionKeys.value)
  710. let result=false
  711. console.log('上报审批',rows)
  712. //判断自身是否满足条件
  713. const result1 = rows.every(({taskStatusStr})=> {
  714. return taskStatusStr === '未上报'||taskStatusStr === '已废除'
  715. })
  716. if(result1){
  717. //判断工序节点是否满足条件
  718. result = rows.every(({isApprove})=> {
  719. return isApprove === true
  720. })
  721. iscanReport.value=result
  722. toreportModalClick(iscanReport.value)
  723. }else{
  724. window.$message?.warning('已上报的数据不能重复上报')
  725. iscanReport.value=false
  726. }
  727. }
  728. }
  729. //上报的审批内容移除
  730. const reportTaskTagClose = (index) => {
  731. const row = tableSelectionKeys.value[index];
  732. tableListRef.value?.toggleRowSelection(row,false)
  733. }
  734. const getTableDataAll = () => {
  735. getTableData()
  736. firstTaskStatus()
  737. }
  738. //上报完成
  739. const showReportFinish = () => {
  740. showReportModal.value = false
  741. getTableDataAll()
  742. }
  743. //打印
  744. const printLoading = ref(false)
  745. const batchPrint = async () => {
  746. const rows = tableSelectionKeys.value;
  747. const ids = rowsToId(rows)
  748. //批量下载
  749. printLoading.value = true
  750. const { error, code, data } = await firstApi.batchPrint({
  751. ids: ids
  752. })
  753. //处理数据
  754. printLoading.value = false
  755. //判断状态
  756. const res = isString(data)? data ?? '': ''
  757. if (!error && code === 200 && res) {
  758. window.open(res,'_blank')
  759. }
  760. }
  761. //废除
  762. const batchAbolishClick = () => {
  763. const rows = tableSelectionKeys.value;
  764. //判断是否满足条件
  765. const result = rows.every(({status})=> {
  766. return status !== 0 && status !== 3
  767. })
  768. //判断状态
  769. if (result) {
  770. //拼接ID
  771. const ids = rowsToId(rows)
  772. window?.$messageBox?.alert('是否废除勾选的已上报文件?', '废除文件', {
  773. showCancelButton: true,
  774. confirmButtonText: '确定废除',
  775. cancelButtonText: '取消',
  776. callback: (action) => {
  777. if (action === 'confirm') {
  778. batchAbolishSave(ids)
  779. }
  780. }
  781. })
  782. } else {
  783. window.$message?.warning('未上报的文件不能废除')
  784. }
  785. }
  786. //废除勾选的已上报文件
  787. const batchAbolishSave = async (ids) => {
  788. const { error, code } = await queryApi.batchAbolish({ids: ids})
  789. //处理数据
  790. if (!error && code === 200) {
  791. window.$message?.success('批量废除成功')
  792. tableSelectionKeys.value = []
  793. getTableData()
  794. }
  795. }
  796. //拼接ID
  797. const rowsToId = (rows) => {
  798. return rows.map((obj) => {
  799. return obj.id;
  800. }).join(",")
  801. }
  802. //处理数据
  803. const rowsToArr = (rows) => {
  804. let newArr = [];
  805. for (let i = 0; i < rows.length; i++) {
  806. newArr.push({
  807. id: rows[i]?.id,
  808. name: rows[i]?.name
  809. })
  810. }
  811. return newArr
  812. }
  813. //左右拖动,改变树形结构宽度
  814. const leftWidth = ref(382)
  815. const onmousedown = () => {
  816. const leftNum = isCollapse.value ? 142 : 272
  817. document.onmousemove = (ve) => {
  818. const diffVal = ve.clientX - leftNum;
  819. if(diffVal >= 310 && diffVal <= 900) {
  820. leftWidth.value = diffVal;
  821. }
  822. }
  823. document.onmouseup = () => {
  824. document.onmousemove = null;
  825. document.onmouseup = null;
  826. }
  827. }
  828. </script>
  829. <style lang="scss" scoped>
  830. @import "../../styles/other/first-item.scss";
  831. </style>
  832. <style lang="scss">
  833. .hc-first-item-node-layout.el-overlay {
  834. position: absolute;
  835. background-color: transparent;
  836. margin: -24px;
  837. height: revert;
  838. .hc-drawer-box.el-drawer {
  839. --el-drawer-bg-color: transparent;
  840. .el-drawer__body {
  841. padding: 24px;
  842. display: flex;
  843. flex-direction: column;
  844. overflow: hidden;
  845. }
  846. }
  847. }
  848. </style>