first-itemcopy.vue 32 KB

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