first-item.vue 31 KB

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