index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. <template>
  2. <div class="hc-page-box">
  3. <hc-page-split>
  4. <template #left>
  5. <hc-card scrollbar>
  6. <!-- Element Plus 菜单组件 -->
  7. <ElMenu
  8. v-if="folderData.length > 0"
  9. v-loading="folderLoading"
  10. default-active="1-1"
  11. class="custom-menu"
  12. unique-opened
  13. @select="handleSelect"
  14. >
  15. <!-- 渲染动态菜单 -->
  16. <template v-for="item in folderData" :key="item.id">
  17. <MenuItem :menu-item-data="item" :selected-key-path="selectedKeyPath" />
  18. </template>
  19. </ElMenu>
  20. <div v-else class="mt-40">
  21. <hc-empty />
  22. </div>
  23. </hc-card>
  24. </template>
  25. <hc-new-card>
  26. <template #extra>
  27. <el-button hc-btn type="danger" :loading="scanLoading" @click="scanClick">开始扫描</el-button>
  28. </template>
  29. <template #header>
  30. <el-button hc-btn color="#12B9A7" class="text-white" @click="movesClick">移动</el-button>
  31. <el-button hc-btn color="#149BF4" class="text-white">自动识别</el-button>
  32. <el-button hc-btn class="text-white" color="#149BF4" :disabled="!tableCheckedKeys.length" @click="editClick">编辑</el-button>
  33. <el-button v-del-com:[delClick] hc-btn type="danger" :disabled="!tableCheckedKeys.length">删除</el-button>
  34. </template>
  35. <HcTable
  36. ref="tableRef" :check-style="{ width: 29 }" :column="tableColumn" :datas="tableData"
  37. :index-style="{ width: 60 }" :loading="tableLoading" is-check is-new
  38. :cell-style="tableCellStyle"
  39. @selection-change="tableSelection"
  40. >
  41. <template #fileName="{ row }">
  42. <span class="text-link" @click="viewPdf(row.ossUrl)">{{ row?.fileName }}</span>
  43. </template>
  44. </HcTable>
  45. <template #action>
  46. <HcPages :pages="searchForm" :sizes="[20, 50, 100, 200, 300, 500]" @change="pageChange" />
  47. </template>
  48. </hc-new-card>
  49. </hc-page-split>
  50. <!-- 移动 -->
  51. <hc-new-dialog v-model="movesModal" :loading="movesModalLoading" is-table title="跨目录移动" widths="80vw" @close="movesModalClose" @save="movesModalSave">
  52. <div class="hc-moves-transfer-box">
  53. <div class="hc-moves-transfer-panel">
  54. <div class="panel-header">
  55. <div class="panel-header-label">
  56. <el-checkbox v-model="movesCheckAll" :indeterminate="isIndeterminate" class="space size-xl" @change="handleCheckAllChange">
  57. 选择需要迁移的文件
  58. </el-checkbox>
  59. </div>
  60. <div class="panel-header-extra">{{ checkedMoves.length }}/{{ tableCheckedKeys.length }}</div>
  61. </div>
  62. <div class="panel-body">
  63. <el-scrollbar>
  64. <el-checkbox-group v-model="checkedMoves" @change="handleCheckedMovesChange">
  65. <div v-for="item in tableCheckedKeys" :key="item.id" class="hc-file-checkbox">
  66. <el-checkbox :value="item.id" class="space size-xl">{{ item.name }}</el-checkbox>
  67. </div>
  68. </el-checkbox-group>
  69. </el-scrollbar>
  70. </div>
  71. </div>
  72. <div class="hc-moves-transfer-buttons">
  73. <!-- <el-button hc-btn _icon size="small"
  74. :type="tableCheckedKeys.length <= 0 || checkedMoves.length <= 0 ? '' : 'primary'"
  75. :disabled="tableCheckedKeys.length <= 0 || checkedMoves.length <= 0">
  76. <HcIcon name="arrow-right"/>
  77. </el-button> -->
  78. <HcIcon name="arrow-right-double" style="font-size: 22px;" type="primary" />
  79. </div>
  80. <div class="hc-moves-transfer-panel">
  81. <div class="panel-header">选择移动目录</div>
  82. <div class="panel-body">
  83. <el-scrollbar>
  84. <HcTree :contract-id="contractId" :is-show-menu="false" :project-id="projectId" id-prefix="hc-tree-moves-" is-radio @noderadio="nodeRadio" />
  85. </el-scrollbar>
  86. </div>
  87. </div>
  88. </div>
  89. </hc-new-dialog>
  90. <!-- 编辑 -->
  91. <hc-new-dialog v-model="editModal" :loading="editLoading" is-table title="编辑" widths="60vw" @close="editModalClose" @save="editModalSave">
  92. <HcTable
  93. ui="hc-form-table" is-new :is-index="false"
  94. :column="tableEditColumn" :datas="tableEditData"
  95. >
  96. <template #fileNum="{ row }">
  97. <el-input v-model="row.fileNum" />
  98. </template>
  99. <template #fileName="{ row }">
  100. <el-input v-model="row.fileName" type="textarea" />
  101. </template>
  102. <template #responsible="{ row }">
  103. <el-input v-model="row.responsible" type="textarea" />
  104. </template>
  105. <template #fileDate="{ row }">
  106. <el-date-picker v-model="row.fileDate" value-format="YYYY-MM-DD HH:mm:ss" type="datetime" />
  107. </template>
  108. </HcTable>
  109. </hc-new-dialog>
  110. </div>
  111. </template>
  112. <script setup>
  113. import { onMounted, ref } from 'vue'
  114. import scanApi from '~api/archiveFile/scanning'
  115. import { useAppStore } from '~src/store'
  116. import HcTree from '~src/components/tree/hc-tree.vue'
  117. import { deepClone, getArrValue } from 'js-fast-way'
  118. import MenuItem from './MenuItem.vue' // 导入递归组件
  119. import { toPdfPage } from '~uti/btn-auth'
  120. const useAppState = useAppStore()
  121. const contractId = ref(useAppState.getContractId)
  122. const projectId = ref(useAppState.getProjectId)
  123. const folderLoading = ref(false)
  124. onMounted(()=>{
  125. getMenuFolderData()
  126. })
  127. //菜单数据
  128. const folderData = ref([])
  129. const isCollapse = ref(false)
  130. // 记录当前选中的完整路径
  131. const selectedKeyPath = ref([])
  132. const folderId = ref('') // 当前选中的文件夹ID
  133. // 处理菜单选择事件 - 记录完整路径
  134. const handleSelect = (key, keyPath) => {
  135. selectedKeyPath.value = keyPath
  136. folderId.value = key
  137. getTableData()
  138. }
  139. const getMenuFolderData = async ()=>{
  140. folderLoading.value = true
  141. const { error, code, data } = await scanApi.getScanFolder({
  142. ...searchForm.value,
  143. projectId: 111,
  144. contractId: 123,
  145. })
  146. folderLoading.value = false
  147. if (!error && code === 200) {
  148. folderData.value = getArrValue(data)
  149. } else {
  150. folderData.value = []
  151. }
  152. }
  153. //分页被点击
  154. const pageChange = ({ current, size }) => {
  155. searchForm.value.current = current
  156. searchForm.value.size = size
  157. }
  158. //搜索表单
  159. const searchForm = ref({
  160. contractId: null, type: null, approval: null, betweenTime: null,
  161. current: 1, size: 20, total: 0,
  162. })
  163. //表格数据
  164. const tableRef = ref(null)
  165. const tableColumn = ref([
  166. { key: 'digitalNum', name: '数字编号' },
  167. { key: 'fileNum', name: '文件编号' },
  168. { key: 'fileName', name: '文件题名' },
  169. { key: 'fileSize', name: '文件页数' },
  170. { key: 'fileDate', name: '文件日期' },
  171. { key: 'responsible', name: '责任者' },
  172. ])
  173. const tableData = ref([ ])
  174. const viewPdf = (ossUrl)=>{
  175. toPdfPage(ossUrl)
  176. }
  177. //设置单元格的样式
  178. const tableCellStyle = ({ row, column, rowIndex, columnIndex }) => {
  179. if (row.id === 1 && column.property === 'name') {
  180. return {
  181. backgroundColor: '#FF7D43',
  182. color: 'black',
  183. }
  184. }
  185. }
  186. //获取数据
  187. const tableLoading = ref(false)
  188. const getTableData = async () => {
  189. tableLoading.value = true
  190. const { error, code, data } = await scanApi.getScanFile({
  191. ...searchForm.value,
  192. projectId: 111,
  193. contractId: 123,
  194. folderId: folderId.value,
  195. })
  196. tableLoading.value = false
  197. if (!error && code === 200) {
  198. tableData.value = getArrValue(data['records'])
  199. searchForm.value.total = data['total'] || 0
  200. } else {
  201. tableData.value = []
  202. searchForm.value.total = 0
  203. }
  204. }
  205. //多选
  206. const tableCheckedKeys = ref([])
  207. const tableSelection = (rows) => {
  208. tableCheckedKeys.value = rows
  209. }
  210. //移动
  211. //跨目录移动
  212. const movesModal = ref(false)
  213. const movesClick = () => {
  214. movesModal.value = true
  215. }
  216. //选择需要迁移的文件
  217. const movesCheckAll = ref(false)
  218. const isIndeterminate = ref(true)
  219. const checkedMoves = ref([])
  220. //全选
  221. const handleCheckAllChange = (val) => {
  222. const checked = tableCheckedKeys.value
  223. const keys = rowsToIdNumArr(checked)
  224. checkedMoves.value = val ? keys : []
  225. isIndeterminate.value = false
  226. }
  227. //勾选
  228. const handleCheckedMovesChange = (value) => {
  229. const keys = tableCheckedKeys.value
  230. const checkedCount = value.length
  231. movesCheckAll.value = checkedCount === keys.length
  232. isIndeterminate.value = checkedCount > 0 && checkedCount < keys.length
  233. }
  234. //保存
  235. const movesModalLoading = ref(false)
  236. const chnodeId = ref('')
  237. const movesModalSave = async () => {
  238. movesModalLoading.value = true
  239. console.log(checkedMoves.value, 'checkedMoves.value')
  240. let ids = checkedMoves.value.join(',')
  241. const { error, code, data, msg } = await tuningApi.moveArchive({
  242. ids: ids,
  243. nodeId: chnodeId.value,
  244. })
  245. movesModalLoading.value = false
  246. if (!error && code === 200) {
  247. console.log(msg, 'msg')
  248. window.$message?.success(msg)
  249. getTableData()
  250. } else {
  251. window.$message?.warning(msg)
  252. }
  253. movesModal.value = false
  254. }
  255. //关闭
  256. const movesModalClose = () => {
  257. movesModal.value = false
  258. }
  259. //开始扫描
  260. const scanLoading = ref(false)
  261. const scanClick = async () => {
  262. scanLoading.value = true
  263. const { error, code, data, msg } = await scanApi.startOrEndScan({
  264. type: 1,
  265. contractId: contractId.value,
  266. })
  267. scanLoading.value = false
  268. if (!error && code === 200) {
  269. window.$message?.success(msg)
  270. getTableData()
  271. } else {
  272. window.$message?.warning(msg)
  273. }
  274. movesModal.value = false
  275. }
  276. //编辑
  277. const editModal = ref(false)
  278. const editClick = () => {
  279. editModal.value = true
  280. tableEditData.value = deepClone(tableCheckedKeys.value)
  281. }
  282. const editLoading = ref(false)
  283. const editModalSave = async () => {
  284. editLoading.value = true
  285. const { error, code } = await scanApi.updateScanFile(
  286. tableEditData.value)
  287. //判断状态
  288. editLoading.value = false
  289. if (!error && code === 200) {
  290. window.$message?.success('保存成功')
  291. editModalClose()
  292. getTableData()
  293. } else {
  294. window.$message?.error('保存失败')
  295. }
  296. }
  297. const editModalClose = () => {
  298. editModal.value = false
  299. tableRef.value?.clearSelection()
  300. }
  301. const tableEditColumn = ref([
  302. { key: 'fileNum', name: '文件编号' },
  303. { key: 'fileName', name: '文件题名' },
  304. { key: 'fileDate', name: '文件日期' },
  305. { key: 'responsible', name: '责任者' },
  306. ])
  307. const tableEditData = ref([])
  308. const delClick = async (_, resolve) => {
  309. let ids = []
  310. tableCheckedKeys.value.forEach((element)=>{
  311. ids.push(element.id)
  312. })
  313. const { error, code } = await scanApi.deleteScanFile({
  314. ids: ids.join(','),
  315. })
  316. //处理数据
  317. if (!error && code === 200) {
  318. window.$message?.success('操作成功')
  319. getTableData()
  320. }
  321. resolve()
  322. }
  323. </script>
  324. <style scoped lang="scss">
  325. .custom-menu {
  326. width: 100%;
  327. min-height: 400px;
  328. border-right: none !important;
  329. }
  330. .hc-card {
  331. position: relative;
  332. }
  333. .hc-moves-transfer-box {
  334. position: relative;
  335. display: flex;
  336. height: 100%;
  337. align-items: center;
  338. .hc-moves-transfer-panel {
  339. width: 47%;
  340. position: relative;
  341. height: 100%;
  342. background: #ffffff;
  343. display: inline-block;
  344. text-align: left;
  345. border: 1px solid #ebeef5;
  346. border-radius: 4px;
  347. .panel-header {
  348. position: relative;
  349. background: #f5f7fa;
  350. display: flex;
  351. align-items: center;
  352. height: 48px;
  353. padding: 0 16px;
  354. border-bottom: 1px solid #ebeef5;
  355. border-radius: 4px 4px 0 0;
  356. .panel-header-label {
  357. position: relative;
  358. flex: 1;
  359. }
  360. .panel-header-extra {
  361. color: #aaaaaa;
  362. }
  363. }
  364. .panel-body {
  365. position: relative;
  366. padding: 16px;
  367. height: calc(100% - 48px);
  368. .hc-file-checkbox {
  369. position: relative;
  370. }
  371. .hc-file-checkbox + .hc-file-checkbox {
  372. margin-top: 16px;
  373. }
  374. }
  375. }
  376. .hc-moves-transfer-buttons {
  377. display: inline-block;
  378. vertical-align: middle;
  379. padding: 0 16px;
  380. }
  381. }
  382. </style>