table-form.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914
  1. <template>
  2. <div class="hc-table-form-content">
  3. <div class="hc-content-box">
  4. <div class="hc-table-forem-box">
  5. <HcTableForm
  6. ref="tableFormRef"
  7. :form="tableFormData"
  8. :html="excelHtmlData"
  9. :loading="loading"
  10. :pkey="excelIdVal"
  11. @render="tableFormRender"
  12. />
  13. </div>
  14. <div v-if="formLogDataList.length > 1" class="hc-fixed-page">
  15. <el-scrollbar>
  16. <div class="hc-fixed-page-list-box">
  17. <template v-for="(item, index) in formLogDataList" :key="index">
  18. <div :class="index === formLogIndex ? 'primary' : ''" class="fixed-page-item" @click="getBussDataInfo(index)">
  19. <div class="name-box">
  20. <HcIcon name="sticky-note" />
  21. <span class="page">第{{ index + 1 }}页</span>
  22. </div>
  23. <div class="close-box" @click.stop="closeBussDataInfo(item, index)">
  24. <HcIcon name="close" />
  25. </div>
  26. </div>
  27. </template>
  28. </div>
  29. </el-scrollbar>
  30. </div>
  31. <div class="hc-right-pian-box hc-flex-column">
  32. <DateCalendar :date-data="dateData" :record-date="recordDates" @choice-date="dateCalendarChoice" />
  33. <el-alert show-icon title="蓝色代表当天已填写过日志" type="warning" />
  34. <div v-if="menuItem?.nodeType === 7 || menuItem?.nodeType === 11" class="my-4">
  35. <el-button hc-btn type="primary" @click="showProcessModal">
  36. <HcIcon name="add-circle" />
  37. <span>关联工序</span>
  38. </el-button>
  39. </div>
  40. <div v-if="menuItem?.nodeType === 7 || menuItem?.nodeType === 11" class="hc-process-box">
  41. <el-scrollbar>
  42. <div v-for="(item, index) in processDataList" class="process-item-box">
  43. <div class="process-item">
  44. {{ item.path }}
  45. </div>
  46. <HcIcon class="process-icon" fill name="close-circle" @click="deleProcess(index)" />
  47. </div>
  48. </el-scrollbar>
  49. </div>
  50. </div>
  51. </div>
  52. <div class="hc-footer-box">
  53. <HcTooltip keys="ledger_query_save_form">
  54. <el-button
  55. :disabled="!isTableForm || taskStatus === 3 || taskStatus === 4"
  56. :loading="tableFormSaveLoading" hc-btn color="#12C060" style="color: white;"
  57. @click="tableFormSaveClick"
  58. >
  59. <HcIcon name="save" />
  60. <span>保存</span>
  61. </el-button>
  62. </HcTooltip>
  63. <HcTooltip keys="ledger_query_report_form">
  64. <el-button
  65. :disabled="!isTableForm || taskStatus === 1 || taskStatus === 3 || taskStatus === 4" hc-btn
  66. color="#FF976A" style="color: white;" @click="reportModalClick"
  67. >
  68. <HcIcon name="send-plane-2" />
  69. <span>上报</span>
  70. </el-button>
  71. </HcTooltip>
  72. <HcTooltip keys="ledger_query_preview_form">
  73. <el-button
  74. :disabled="!isTableForm || taskStatus === 1 " :loading="previewLoading" hc-btn
  75. color="#A16222" @click="previewBussPdf"
  76. >
  77. <HcIcon name="eye" />
  78. <span>预览</span>
  79. </el-button>
  80. </HcTooltip>
  81. <HcTooltip keys="ledger_query_copy_form">
  82. <el-button
  83. :disabled="!isTableForm || taskStatus === 3 || taskStatus === 4" hc-btn
  84. color="#567722" @click="copyTableFormClick"
  85. >
  86. <HcIcon name="file-copy-2" />
  87. <span>复制当前表格及内容</span>
  88. </el-button>
  89. </HcTooltip>
  90. <HcTooltip keys="ledger_query_time_form">
  91. <el-button
  92. :disabled="!isTableForm || taskStatus === 3 || taskStatus === 4" hc-btn
  93. color="#567722" @click="copyTimeLogModal"
  94. >
  95. <HcIcon name="file-copy-2" />
  96. <span>复制任意时间</span>
  97. </el-button>
  98. </HcTooltip>
  99. <HcTooltip keys="ledger_query_add_form">
  100. <el-button
  101. :disabled="!isTableForm || taskStatus === 3 || taskStatus === 4" hc-btn
  102. color="#37c0fe" style="color: white;" @click="addTableFormClick"
  103. >
  104. <HcIcon name="add-circle" />
  105. <span>新增表格</span>
  106. </el-button>
  107. </HcTooltip>
  108. <HcTooltip keys="ledger_query_abolish_form">
  109. <el-button
  110. :disabled="!isTableForm || taskStatus === 1 || taskStatus === 2" hc-btn
  111. color="#FF976A" style="color: white;" @click="abolishTableFormClick"
  112. >
  113. <HcIcon name="delete-bin-3" />
  114. <span>废除</span>
  115. </el-button>
  116. </HcTooltip>
  117. </div>
  118. <!-- 关联工序 -->
  119. <hc-new-dialog v-model="processNodeModal" title="选择关联工序" widths="62rem" is-table @save="processNodeClick">
  120. <div class="node-many-tree">
  121. <!-- <el-tree
  122. ref="processElTree" :default-checked-keys="defaultChecked"
  123. :default-expanded-keys="defaultExpanded" :load="ElTreeLoadNode" :props="processTreeProps"
  124. check-strictly
  125. class="my-tree" lazy node-key="primaryKeyId"
  126. show-checkbox
  127. /> -->
  128. <HcLazyTree
  129. ref="processElTree"
  130. :h-props="processTreeProps"
  131. :auto-expand-keys="defaultExpanded"
  132. check-strictly show-checkbox
  133. :default-checked-keys="defaultChecked"
  134. @load="ElTreeLoadNode"
  135. />
  136. </div>
  137. </hc-new-dialog>
  138. <!-- 复制任意时间 -->
  139. <hc-new-dialog v-model="copyTimeModal" :loading="copyTimeLoading" :padding="false" is-table save-text="复制" title="复制任意时间" widths="62rem" @save="copyTimeSaveClick">
  140. <div class="hc-user-time-box">
  141. <div class="tree-box">
  142. <el-scrollbar>
  143. <el-tree
  144. :data="copyTimeTreeData" :default-expanded-keys="copyTimeTreeKeys"
  145. :props="copyTimeTreeProps"
  146. accordion class="hc-tree-node" highlight-current
  147. node-key="hierarchy" @node-click="copyTimeTreeNodeClick"
  148. />
  149. </el-scrollbar>
  150. </div>
  151. <div class="user-box">
  152. <HcTable
  153. ref="copyTimeTableRef" :column="copyTimeTableColumn" :datas="copyTimeTableData" :loading="copyTimeTableLoading"
  154. is-new :index-style="{ width: 60 }" is-check :check-style="{ width: 29 }"
  155. @selection-change="copyTimeTableSelection"
  156. />
  157. </div>
  158. </div>
  159. </hc-new-dialog>
  160. <!-- 批量上报审批 -->
  161. <HcReportModal
  162. :ids="logId"
  163. :addition="reportAddition" :contract-id="contractId" :project-id="projectId"
  164. :show="showReportModal" :task-name="reportTaskName" :type-data="menuItem.primaryKeyId"
  165. title="日志填报上报"
  166. type="log" url="contractLog/startTaskTheLog" @finish="showReportFinish"
  167. @hide="showReportModal = false"
  168. />
  169. </div>
  170. </template>
  171. <script setup>
  172. import { onActivated, onDeactivated, onMounted, onUnmounted, ref, watch } from 'vue'
  173. import { arrToId, getArrValue, getObjVal, getObjValue, isArrIndex, isNullES, isString } from 'js-fast-way'
  174. import DateCalendar from './dateCalendar/index.vue'
  175. //import HcTableForm from "~com/table-form/index.vue";
  176. import HTableForm from '~src/plugins/HTableForm'
  177. import wbsQueryApi from '~api/data-fill/query'
  178. import queryApi from '~api/ledger/query'
  179. import { useAppStore } from '~src/store'
  180. import { toPdfPage } from '~uti/btn-auth'
  181. //参数
  182. const props = defineProps({
  183. projectId: {
  184. type: [String, Number],
  185. default: '',
  186. },
  187. contractId: {
  188. type: [String, Number],
  189. default: '',
  190. },
  191. items: {
  192. type: Object,
  193. default: () => ({}),
  194. },
  195. userName: {
  196. type: [String, Number],
  197. default: '',
  198. },
  199. })
  200. const useAppState = useAppStore()
  201. //变量
  202. const projectId = ref(props.projectId)
  203. const contractId = ref(props.contractId)
  204. const menuItem = ref(props.items)
  205. const userName = ref(props.userName)
  206. const excelIdVal = ref('')
  207. const tableFormRef = ref(null)
  208. const contractInfo = ref(useAppState.getContractInfo)
  209. const { contractType } = contractInfo.value
  210. const classifyType = ref(contractType === 2 ? '2' : '1')
  211. //监听
  212. watch(() => [
  213. props.projectId,
  214. props.contractId,
  215. props.items,
  216. props.userName,
  217. ], ([pid, cid, item, name]) => {
  218. projectId.value = pid
  219. contractId.value = cid
  220. menuItem.value = item
  221. userName.value = name
  222. getQueryData()
  223. })
  224. //渲染完成
  225. onMounted(() => {
  226. setQueryDataDate()
  227. setMountOnEventKey()
  228. })
  229. //获取相关数据
  230. const getQueryData = () => {
  231. setQueryDataDate()
  232. const date = recordDate.value ?? {}, time = recordTime.value ?? ''
  233. getExcelBusinessData(date, time)
  234. }
  235. const setQueryDataDate = () => {
  236. const { excelId } = menuItem.value
  237. excelIdVal.value = excelId > 0 ? excelId + '' : ''
  238. }
  239. //日期日历回调
  240. const recordTime = ref('')
  241. const recordDate = ref({})
  242. const recordDates = ref({})
  243. const dateCalendarChoice = ({ date, choices, dates }) => {
  244. recordTime.value = choices
  245. recordDate.value = date
  246. recordDates.value = dates
  247. getExcelBusinessData(date, choices)
  248. }
  249. //获取数据
  250. const loading = ref(false)
  251. const choicesVal = ref(null)
  252. const getExcelBusinessData = async (date, choices) => {
  253. const { primaryKeyId } = menuItem.value
  254. loading.value = true
  255. choicesVal.value = choices
  256. await getTheLogBusinessData(excelIdVal.value, choices)
  257. await getExcelHtml(excelIdVal.value)
  258. loading.value = false
  259. await getSubmitLogDateList(date, primaryKeyId)
  260. await checkTheLogTaskStatus(choices, primaryKeyId)
  261. }
  262. //获取模板标签数据
  263. const isTableForm = ref(false)
  264. const excelHtmlData = ref('')
  265. const getExcelHtml = async (excelId) => {
  266. if (excelId) {
  267. //获取数据
  268. const { error, code, data } = await queryApi.getExcelHtml({
  269. contractId: contractId.value || '',
  270. pkeyId: excelId,
  271. }, false)
  272. //处理数据
  273. const resData = isString(data) ? data || '' : ''
  274. if (!error && code === 200 && resData) {
  275. excelHtmlData.value = resData
  276. } else {
  277. excelHtmlData.value = ''
  278. isTableForm.value = false
  279. window?.$message?.warning('暂无表单')
  280. }
  281. } else {
  282. isTableForm.value = false
  283. window?.$message?.error('项目未关联日志表单')
  284. }
  285. }
  286. //渲染表单完成
  287. const tableFormRender = (form) => {
  288. isTableForm.value = form.isRenderForm
  289. }
  290. //表单数据
  291. const formLogDataList = ref([])
  292. const getTheLogBusinessData = async (excelId, recordDate) => {
  293. const { primaryKeyId } = menuItem.value
  294. const { data } = await queryApi.getTheLogBusinessData({
  295. contractId: contractId.value || '',
  296. pkeyId: excelId,
  297. nodePrimaryKeyId: primaryKeyId,
  298. recordTime: recordDate,
  299. theLogId: '',
  300. }, false)
  301. //设置默认数据
  302. let formArrData = getArrValue(data)
  303. if (formArrData.length > 0) {
  304. logId.value = formArrData[0].logId
  305. for (let i = 0; i < formArrData.length; i++) {
  306. formArrData[i] = setFormDefaultData(formArrData[i])
  307. }
  308. } else {
  309. formArrData = [setFormDefaultData()]
  310. }
  311. formLogDataList.value = formArrData
  312. getBussDataInfo()
  313. }
  314. const getAddLogBusinessData = async (excelId, recordDate) => {
  315. const { primaryKeyId } = menuItem.value
  316. const { data } = await queryApi.getAddTheLogBusinessData({
  317. contractId: contractId.value || '',
  318. pkeyId: excelId,
  319. nodePrimaryKeyId: primaryKeyId,
  320. recordTime: recordDate,
  321. theLogId: '',
  322. }, false)
  323. //设置默认数据
  324. let formArrData = getArrValue(data)
  325. if (formArrData.length > 0) {
  326. logId.value = formArrData[0].logId
  327. for (let i = 0; i < formArrData.length; i++) {
  328. formArrData[i] = setFormDefaultData(formArrData[i])
  329. }
  330. } else {
  331. formArrData = [setFormDefaultData()]
  332. }
  333. formLogDataList.value = formArrData
  334. // getBussDataInfo()
  335. }
  336. //获取表单初始数据
  337. const formLogIndex = ref(0)
  338. const tableFormData = ref({})
  339. const getBussDataInfo = (index = 0) => {
  340. const formLog = formLogDataList.value
  341. const info = getObjValue(formLog[index])
  342. formLogIndex.value = index
  343. if (getObjVal(info)) {
  344. tableFormData.value = info
  345. } else {
  346. tableFormData.value = {}
  347. }
  348. tableFormRef.value?.setExcelHtml()
  349. queryCurrentLogSelectProcessList(info?.id ?? '')
  350. }
  351. //获取日期记录
  352. const dateData = ref([])
  353. const getSubmitLogDateList = async ({ year }, pid) => {
  354. if (pid > 0 && year) {
  355. const { data } = await queryApi.getSubmitLogDateList({
  356. projectId: projectId.value,
  357. contractId: contractId.value,
  358. primaryKeyId: pid,
  359. year: year,
  360. }, false)
  361. //处理数据
  362. dateData.value = getArrValue(data)
  363. } else {
  364. dateData.value = []
  365. }
  366. }
  367. //获取当前资料的任务状态
  368. const taskStatus = ref(1)
  369. const checkTheLogTaskStatus = async (choices, primaryKeyId) => {
  370. if (primaryKeyId > 0) {
  371. const { error, code, data } = await queryApi.checkTheLogTaskStatus({
  372. projectId: projectId.value,
  373. contractId: contractId.value,
  374. nodePrimaryKeyId: primaryKeyId,
  375. recordTime: choices,
  376. }, false)
  377. //处理数据
  378. const res = isNullES(data) ? '' : data || ''
  379. if (!error && code === 200 && res) {
  380. //1和2的时候所有按钮皆可操作,废除 除外
  381. //3和4时, 除了预览和废除 都不行
  382. taskStatus.value = data
  383. } else {
  384. taskStatus.value = 1
  385. }
  386. } else {
  387. taskStatus.value = 1
  388. }
  389. }
  390. //关联工序
  391. const processNodeModal = ref(false)
  392. const showProcessModal = () => {
  393. processNodeModal.value = true
  394. defaultChecked.value = []
  395. processDataList.value.forEach((ele)=>{
  396. defaultChecked.value.push(ele?.primaryKeyId)
  397. })
  398. }
  399. //树的配置
  400. const processElTree = ref(null)
  401. const processTreeProps = { label: 'title', children: 'children', isLeaf: 'notExsitChild' }
  402. const defaultExpanded = ref([]) //默认展开
  403. const defaultChecked = ref([]) //默认选中
  404. //树形结构异步加载数据
  405. const ElTreeLoadNode = async ({ node, item, level }, resolve) => {
  406. if (node.level === 0) {
  407. const { error, code, data } = await wbsQueryApi.queryWbsTreeData({
  408. contractId: contractId.value || '',
  409. contractIdRelation: '',
  410. primaryKeyId: '',
  411. parentId: '',
  412. classifyType: classifyType.value,
  413. tableOwner:'1',
  414. })
  415. //处理数据
  416. if (!error && code === 200) {
  417. const resData = getArrValue(data)
  418. resolve(resData)
  419. defaultExpanded.value = [resData[0]?.primaryKeyId]
  420. } else {
  421. resolve([])
  422. }
  423. } else {
  424. const { id, contractIdRelation, primaryKeyId } = node.data
  425. const { error, code, data } = await wbsQueryApi.queryWbsTreeData({
  426. contractId: contractId.value || '',
  427. contractIdRelation: contractIdRelation || '',
  428. primaryKeyId: id,
  429. parentId: contractIdRelation ? primaryKeyId : id,
  430. classifyType: classifyType.value,
  431. tableOwner:'1',
  432. })
  433. //处理数据
  434. if (!error && code === 200) {
  435. // resolve(getArrValue(data))
  436. let resdata = getArrValue(data)
  437. resdata.forEach((ele)=>{
  438. ele.colorStatus = 1
  439. })
  440. resolve(resdata)
  441. } else {
  442. resolve([])
  443. }
  444. }
  445. }
  446. //数组对象去重
  447. const getNorepeatArr = (tempArr)=> {
  448. let newArr = []
  449. for (let i = 0; i < tempArr.length; i++) {
  450. if (newArr.indexOf(tempArr[i].primaryKeyId) == -1) {
  451. newArr.push(tempArr[i].primaryKeyId)
  452. } else {
  453. tempArr.splice(i, 1)
  454. i--
  455. }
  456. }
  457. return tempArr
  458. }
  459. //确认关联工序
  460. const processDataList = ref([])
  461. const processNodeClick = () => {
  462. const keys = processElTree.value.treeRef.getCheckedKeys()
  463. const formIndex = formLogIndex.value
  464. const formData = formLogDataList.value[formIndex]
  465. let linkTabIds = getArrValue(formData?.linkTabIds)
  466. if (keys.length === 0) {
  467. linkTabIds = []
  468. }
  469. //去出掉取消勾选的
  470. for (let index = 0; index < keys.length; index++) {
  471. linkTabIds = linkTabIds.filter((ele)=>{
  472. if (ele.primaryKeyId === keys[index]) {
  473. return ele
  474. }
  475. })
  476. }
  477. for (let index = 0; index < keys.length; index++) {
  478. let pathArr = []
  479. let node = processElTree.value.treeRef.getNode(keys[index])
  480. getPathName(node, pathArr)
  481. linkTabIds.push({
  482. path: pathArr.join('/'),
  483. primaryKeyId: keys[index],
  484. })
  485. }
  486. //去除掉重复的
  487. getNorepeatArr(linkTabIds)
  488. formLogDataList.value[formIndex]['linkTabIds'] = linkTabIds
  489. processDataList.value = linkTabIds
  490. processNodeModal.value = false
  491. }
  492. //获取节点的路径名字
  493. const getPathName = (node, pathArr) => {
  494. if (node.parent?.parent) {
  495. pathArr.unshift(node.data?.title.replace(/(^\s*)|(\s*$)/g, '')) //去掉头尾空格
  496. getPathName(node.parent, pathArr)
  497. } else {
  498. return //根节点结束
  499. }
  500. }
  501. //移除工序
  502. const deleProcess = (index) => {
  503. const formIndex = formLogIndex.value
  504. const formData = formLogDataList.value[formIndex]
  505. const linkTabIds = getArrValue(formData?.linkTabIds)
  506. linkTabIds.splice(index, 1)
  507. formLogDataList.value[formIndex]['linkTabIds'] = linkTabIds
  508. processDataList.value = linkTabIds
  509. }
  510. //保存数据
  511. const tableFormSaveLoading = ref(false)
  512. const tableFormSaveClick = async () => {
  513. const { primaryKeyId } = menuItem.value
  514. const res = await saveExcelBussData()
  515. if (res) {
  516. await checkTheLogTaskStatus(recordTime.value, primaryKeyId)
  517. // await getBussPdfInfo()
  518. tableFormSaveLoading.value = false
  519. }
  520. }
  521. //保存
  522. const logId = ref('')
  523. const saveExcelBussData = async () => {
  524. let isLinkTabIds = getLinkTabIds() //处理工序ID
  525. const { primaryKeyId } = menuItem.value
  526. if (isLinkTabIds) {
  527. tableFormSaveLoading.value = true
  528. const { error, code, msg, data } = await queryApi.saveExcelBussData({
  529. dataInfo: { orderList: formLogDataList.value },
  530. nodePrimaryKeyId: primaryKeyId,
  531. }, false)
  532. if (!error && code === 200) {
  533. logId.value = data
  534. window?.$message?.success(msg)
  535. return true
  536. } else {
  537. tableFormSaveLoading.value = false
  538. window?.$message?.warning(msg)
  539. return false
  540. }
  541. }
  542. }
  543. //处理工序数据
  544. const getLinkTabIds = () => {
  545. let { nodeType } = menuItem.value
  546. let isLink = false
  547. if (nodeType === 7 || nodeType === 11) {
  548. isLink = formLogDataList.value.some((item) => {
  549. const linkIds = getArrValue(item?.linkTabIds)
  550. return linkIds.length > 0
  551. })
  552. if (isLink) {
  553. return true
  554. } else {
  555. window?.$message?.warning('请先关联工序')
  556. return false
  557. }
  558. } else {
  559. return true
  560. }
  561. }
  562. //预览
  563. const previewLoading = ref(false)
  564. const previewBussPdf = () => {
  565. getBussPdfInfo()
  566. }
  567. //预览PDF
  568. const getBussPdfInfo = async () => {
  569. previewLoading.value = true
  570. const { primaryKeyId } = menuItem.value
  571. const { error, code, data } = await queryApi.getBussPdfInfo({
  572. contractId: contractId.value || '',
  573. pkeyId: excelIdVal.value,
  574. nodePrimaryKeyId: primaryKeyId,
  575. recordTime: recordTime.value,
  576. theLogId: '',
  577. }, false)
  578. //处理数据
  579. previewLoading.value = false
  580. const resData = isString(data) ? data || '' : ''
  581. if (!error && code === 200 && resData) {
  582. toPdfPage(resData)
  583. //window.open(resData, '_blank')
  584. } else {
  585. window?.$message?.warning('暂无PDF,无法预览')
  586. }
  587. }
  588. //获取当前日志资料关联的工序节点信息
  589. const queryCurrentLogSelectProcessList = async (bid) => {
  590. if (bid) {
  591. const { error, code, data, msg } = await queryApi.queryCurrentLogSelectProcessList({
  592. contractId: contractId.value || '',
  593. businessId: bid ?? '',
  594. }, false)
  595. //处理数据
  596. const formIndex = formLogIndex.value
  597. if (!error && code === 200) {
  598. let linkTabIds = getArrValue(data)
  599. formLogDataList.value[formIndex]['linkTabIds'] = linkTabIds
  600. processDataList.value = linkTabIds
  601. } else {
  602. processDataList.value = []
  603. defaultChecked.value = []
  604. if (msg) window?.$message?.warning(msg)
  605. }
  606. } else {
  607. const formIndex = formLogIndex.value
  608. const formData = formLogDataList.value[formIndex]
  609. processDataList.value = getArrValue(formData?.linkTabIds)
  610. }
  611. }
  612. //新增表格
  613. const addTableFormClick = () => {
  614. const defaultData = setFormDefaultData({})
  615. formLogDataList.value.push(defaultData)
  616. const index = formLogDataList.value.length - 1
  617. // getBussDataInfo(index)
  618. getAddLogBusinessData(excelIdVal.value, choicesVal.value)
  619. getBussDataInfo(index)
  620. }
  621. //复制表格内容
  622. const copyTableFormClick = () => {
  623. const formLog = formLogDataList.value
  624. const logIndex = formLogIndex.value
  625. const defaultData = setFormDefaultData(formLog[logIndex])
  626. formLogDataList.value.push({
  627. ...defaultData,
  628. id: '',
  629. })
  630. const index = formLogDataList.value.length - 1
  631. getBussDataInfo(index)
  632. }
  633. //复制任意时间
  634. const copyTimeModal = ref(false)
  635. const copyTimeLogModal = () => {
  636. copyTimeModal.value = true
  637. copyTimeLoading.value = false
  638. queryReportLogTimeTree()
  639. }
  640. //日期数
  641. const copyTimeTreeProps = {
  642. children: 'treeList', label: 'name',
  643. }
  644. const copyTimeTreeData = ref([])
  645. const copyTimeTreeKeys = ref([])
  646. //获取当前合同段下本日志节点的填报资料日期树
  647. const queryReportLogTimeTree = async () => {
  648. const { primaryKeyId } = menuItem.value
  649. const { data } = await queryApi.queryReportLogTimeTree({
  650. contractId: contractId.value || '',
  651. nodePrimaryKeyId: primaryKeyId,
  652. })
  653. const res = getArrValue(data)
  654. copyTimeTreeData.value = res
  655. if (res.length > 0) {
  656. copyTimeTreeKeys.value = [res[0]?.hierarchy]
  657. }
  658. }
  659. //日期树被点击
  660. const copyTimeTreeNodeClick = (data) => {
  661. queryLogTimeTreeList(data?.hierarchy)
  662. }
  663. //复制任意时间的记录人
  664. const copyTimeTableRef = ref(null)
  665. const copyTimeTableColumn = ref([
  666. { key: 'createUserName', name: '记录人' },
  667. { key: 'recordTime', name: '时间' },
  668. ])
  669. const copyTimeTableData = ref([])
  670. //获取填报记录
  671. const copyTimeTableLoading = ref(false)
  672. const queryLogTimeTreeList = async (time) => {
  673. copyTimeTableLoading.value = true
  674. const { primaryKeyId } = menuItem.value
  675. const { data } = await queryApi.queryLogTimeTreeList({
  676. contractId: contractId.value || '',
  677. nodePrimaryKeyId: primaryKeyId,
  678. time: time,
  679. })
  680. copyTimeTableLoading.value = false
  681. copyTimeTableData.value = getArrValue(data)
  682. }
  683. //多选
  684. const copyTimeTableKeys = ref([])
  685. const copyTimeTableSelection = (rows) => {
  686. copyTimeTableKeys.value = rows.filter((item) => {
  687. return (item ?? '') !== ''
  688. })
  689. }
  690. //确认复制
  691. const copyTimeLoading = ref(false)
  692. const copyTimeSaveClick = () => {
  693. const rows = copyTimeTableKeys.value
  694. if (rows.length > 0) {
  695. const ids = arrToId(rows)
  696. copyTheLogBusinessData(ids)
  697. } else {
  698. window.$message?.warning('请先勾选记录人')
  699. }
  700. }
  701. //复制任意时间
  702. const copyTheLogBusinessData = async (ids) => {
  703. copyTimeLoading.value = true
  704. const { primaryKeyId } = menuItem.value
  705. const { error, code, msg } = await queryApi.copyTheLogBusinessData({
  706. contractId: contractId.value || '',
  707. nodePrimaryKeyId: primaryKeyId,
  708. currentTime: recordTime.value,
  709. theLogId: ids,
  710. })
  711. //处理数据
  712. copyTimeLoading.value = false
  713. if (!error && code === 200) {
  714. copyTimeModal.value = false
  715. window?.$message?.success('复制成功')
  716. setTimeout(() => {
  717. // window?.location?.reload() //刷新页面
  718. setQueryDataDate()
  719. setMountOnEventKey()
  720. getQueryData()
  721. }, 1000)
  722. } else {
  723. window.$message.error(msg)
  724. }
  725. }
  726. //设置表单默认数据
  727. const setFormDefaultData = (formInfo = {}) => {
  728. return {
  729. linkTabIds: [],
  730. ...formInfo,
  731. projectId: projectId.value,
  732. contractId: contractId.value,
  733. recordTime: recordTime.value,
  734. pkeyId: excelIdVal.value,
  735. isTheLog: '1',
  736. theLogId: '',
  737. classify: 1,
  738. }
  739. }
  740. //删除记录
  741. const closeBussDataInfo = async (item, index) => {
  742. console.log(item, '删除')
  743. if (item?.id) {
  744. const { error, code, data } = await queryApi.removeLogTab({
  745. id:item?.id,
  746. })
  747. //处理数据
  748. if (!error && code === 200) {
  749. window.$message.success('删除成功')
  750. } else {
  751. window.$message.error('操作失败')
  752. }
  753. }
  754. formLogDataList.value.splice(index, 1)
  755. const logIndex = index <= 0 ? 0 : index - 1
  756. formLogIndex.value = logIndex
  757. getBussDataInfo(logIndex)
  758. }
  759. //批量上报
  760. const reportTaskName = ref('')
  761. const reportAddition = ref({})
  762. const showReportModal = ref(false)
  763. const reportModalClick = async () => {
  764. await tableFormSaveClick()
  765. const { primaryKeyId, title } = menuItem.value
  766. reportTaskName.value = `${recordTime.value} ${title} ${userName.value}`
  767. reportAddition.value = {
  768. nodePrimaryKeyId: primaryKeyId,
  769. recordTime: recordTime.value,
  770. }
  771. tableFormSaveLoading.value = false
  772. showReportModal.value = true
  773. }
  774. //上报完成
  775. const showReportFinish = () => {
  776. showReportModal.value = false
  777. window?.location?.reload() //刷新页面
  778. }
  779. //废除
  780. const abolishTableFormClick = () => {
  781. window?.$messageBox?.alert('是否废除已上报的文件?', '废除文件', {
  782. showCancelButton: true,
  783. confirmButtonText: '确定废除',
  784. cancelButtonText: '取消',
  785. callback: (action) => {
  786. if (action === 'confirm') {
  787. theLogOneAbolish()
  788. }
  789. },
  790. })
  791. }
  792. //确认废除
  793. const theLogOneAbolish = async () => {
  794. const { primaryKeyId } = menuItem.value
  795. const { error, code } = await queryApi.theLogOneAbolish({
  796. projectId: projectId.value,
  797. contractId: contractId.value,
  798. nodePrimaryKeyId: primaryKeyId,
  799. recordTime: recordTime.value,
  800. })
  801. //处理数据
  802. if (!error && code === 200) {
  803. window.$message?.success('废除成功')
  804. window?.location?.reload() //刷新页面
  805. }
  806. }
  807. //缓存被激活时
  808. onActivated(() => {
  809. setMountOnEventKey()
  810. })
  811. //缓存时被移除
  812. onDeactivated(() => {
  813. HTableForm.unmountEventKey()
  814. })
  815. const setMountOnEventKey = () => {
  816. HTableForm.setOnEventKey({
  817. //按下ctrl键 或 control 键
  818. onCtrlDown: () => {
  819. //window.$HcLog('全局按键', '按下ctrl键 或 control 键')
  820. tableFormRef.value?.setIsCtrlKey(true)
  821. },
  822. //按下复制快捷键
  823. onCtrlDownC: (event) => {
  824. //window.$HcLog('全局按键', '按下复制快捷键')
  825. tableFormRef.value?.setCopyKeyList(event)
  826. },
  827. //按下粘贴快捷键
  828. onCtrlDownV: async (event) => {
  829. //window.$HcLog('全局按键', '按下粘贴快捷键')
  830. await tableFormRef.value?.setPasteKeyList(event)
  831. },
  832. //放开ctrl键 或 control 键
  833. onCtrlUp: () => {
  834. //window.$HcLog('全局按键', '放开ctrl键 或 control 键')
  835. tableFormRef.value?.setIsCtrlKey(false)
  836. },
  837. })
  838. }
  839. //页面被卸载
  840. onUnmounted(() => {
  841. HTableForm.unmountEventKey()
  842. })
  843. </script>
  844. <style lang="scss" scoped>
  845. @import "./table-form.scss";
  846. </style>