table-form.vue 28 KB

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