first-item.vue 31 KB

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