records.vue 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350
  1. <template>
  2. <div class="hc-page-layout-box">
  3. <div class="hc-layout-left-box" :style="'width:' + leftWidth + 'px;'">
  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" v-loading="treeLoading" element-loading-text="加载中...">
  14. <el-scrollbar>
  15. <HcTree :projectId="projectId" :contractId="contractId" @nodeTap="projectTreeClick" @nodeLoading="treeNodeLoading"/>
  16. </el-scrollbar>
  17. </div>
  18. <!--左右拖动-->
  19. <div class="horizontal-drag-line" @mousedown="onmousedown"/>
  20. </div>
  21. <div class="hc-page-content-box">
  22. <HcCard>
  23. <template #header>
  24. <div class="w-64 ml-2">
  25. <el-input v-model="searchForm.queryValue" size="large" placeholder="请输入案卷题名、档号进行搜索" clearable @keyup="keyUpEvent"/>
  26. </div>
  27. <div class="ml-2 mr-5">
  28. <el-button type="primary" hc-btn @click="searchClick">
  29. <HcIcon name="search-2"/>
  30. <span>搜索</span>
  31. </el-button>
  32. </div>
  33. <HcTooltip keys="file_records_btn_download">
  34. <el-button hc-btn :disabled="tableCheckedKeys.length <= 0" :loading="downloadLoading" @click="batchDownload">
  35. <HcIcon name="download"/>
  36. <span>下载</span>
  37. </el-button>
  38. </HcTooltip>
  39. <HcTooltip keys="file_records_btn_edit">
  40. <el-button hc-btn :disabled="tableCheckedKeys.length <= 0" @click="batchEditClick">
  41. <HcIcon name="edit"/>
  42. <span>编辑</span>
  43. </el-button>
  44. </HcTooltip>
  45. <HcTooltip keys="file_records_btn_del">
  46. <el-button hc-btn :disabled="tableCheckedKeys.length <= 0" @click="delModalClick">
  47. <HcIcon name="delete-bin"/>
  48. <span>删除</span>
  49. </el-button>
  50. </HcTooltip>
  51. </template>
  52. <template #extra>
  53. <HcTooltip keys="file_records_btn_upload_scanned_files">
  54. <el-button type="primary" hc-btn @click="uploadModalClick">
  55. <HcIcon name="qr-scan"/>
  56. <span>扫描上传案卷</span>
  57. </el-button>
  58. </HcTooltip>
  59. <HcTooltip keys="file_records_btn_moves">
  60. <el-button type="primary" hc-btn @click="movesClick">
  61. <HcIcon name="arrow-left-right"/>
  62. <span>跨目录移动</span>
  63. </el-button>
  64. </HcTooltip>
  65. </template>
  66. <HcTable ref="tableRef" :column="tableColumn" :datas="tableData" :loading="tableLoading" isCheck @selection-change="tableSelection">
  67. <template #table-column-header-num>
  68. <HcTooltip keys="file_records_btn_sort">
  69. <span class="text-link text-lg" @click="tableSortClick">
  70. <HcIcon name="arrow-up-down"/>
  71. </span>
  72. </HcTooltip>
  73. </template>
  74. <template #name="{row}">
  75. <span class="text-link" @click="tableRowName(row)">{{row?.name}}</span>
  76. </template>
  77. <template #secretLevel="{row}">
  78. {{row.secretLevelValue}}
  79. </template>
  80. <template #storageTime="{row}">
  81. {{row.storageTimeValue}}
  82. </template>
  83. <template #dates="{row}">
  84. {{row.dates[0].substring(0,10)}}~{{row.dates[1].substring(0,10)}}
  85. </template>
  86. </HcTable>
  87. <template #action>
  88. <HcPages :pages="searchForm" @change="pageChange" :sizes="[5,10,20,30,40,50]"/>
  89. </template>
  90. </HcCard>
  91. </div>
  92. <!--跨目录移动-->
  93. <HcDialog :show="movesModal" title="跨目录移动" widths="990px" isTable @close="movesModalClose" @save="movesModalSave" :loading="movesModalLoading">
  94. <div class="hc-moves-transfer-box">
  95. <div class="hc-moves-transfer-panel">
  96. <div class="panel-header">
  97. <div class="panel-header-label">
  98. <el-checkbox class="size-xl space" v-model="movesCheckAll" :indeterminate="isIndeterminate" @change="handleCheckAllChange">选择需要迁移的文件</el-checkbox>
  99. </div>
  100. <div class="panel-header-extra">{{checkedMoves.length}}/{{fileDatasList.length}}</div>
  101. </div>
  102. <div class="panel-body">
  103. <el-scrollbar>
  104. <el-checkbox-group v-model="checkedMoves" @change="handleCheckedMovesChange">
  105. <div class="hc-file-checkbox" v-for="item in fileDatasList" :key="item.id">
  106. <el-checkbox class="size-xl space" :label="item.id">{{item.name}}</el-checkbox>
  107. </div>
  108. </el-checkbox-group>
  109. </el-scrollbar>
  110. </div>
  111. </div>
  112. <div class="hc-moves-transfer-buttons">
  113. <el-button hc-btn _icon size="small"
  114. :type="fileDatasList.length <= 0 || checkedMoves.length <= 0 ? '' : 'primary'"
  115. :disabled="fileDatasList.length <= 0 || checkedMoves.length <= 0">
  116. <HcIcon name="arrow-right"/>
  117. </el-button>
  118. </div>
  119. <div class="hc-moves-transfer-panel">
  120. <div class="panel-header">选择移动目录</div>
  121. <div class="panel-body" v-loading="treePanelLoading">
  122. <el-scrollbar>
  123. <HcTree idPrefix="hc-tree-moves-" ref="movesTreeRef" :projectId="projectId" :contractId="contractId" isRadio
  124. @radioChange="radioChange" :showRadioFun="showRadioFun" @nodeLoading="panelTreeLoading"/>
  125. </el-scrollbar>
  126. </div>
  127. </div>
  128. </div>
  129. </HcDialog>
  130. <!--调整排序-->
  131. <HcDialog :show="sortModal" title="调整排序" widths="980px" isTable isRowFooter @close="sortModalClose">
  132. <el-alert title="可拖动排序,也可在后面点击图标,切换排序" type="error" :closable="false"/>
  133. <div class="hc-table-h">
  134. <HcTable ui="hc-table-row-drop" :column="sortTableColumn" :datas="sortTableData" :loading="sortTableLoading" isRowDrop @row-drop="sortTableRowDrop">
  135. <template #key2="{row}">
  136. <span class="text-link">{{row?.key2}}</span>
  137. </template>
  138. <template #action="{index}">
  139. <span class="text-link text-xl" @click="upSortClick(index)">
  140. <HcIcon name="arrow-up" fill/>
  141. </span>
  142. <span class="text-link text-xl ml-2" @click="downSortClick(index)">
  143. <HcIcon name="arrow-down" fill/>
  144. </span>
  145. </template>
  146. </HcTable>
  147. </div>
  148. <template #leftRowFooter>
  149. <el-button hc-btn @click="sortModalClose">
  150. <HcIcon name="close"/>
  151. <span>取消</span>
  152. </el-button>
  153. <el-button type="primary" hc-btn :loading="sortModalLoading" @click="sortModalSave">
  154. <HcIcon name="check"/>
  155. <span>确认</span>
  156. </el-button>
  157. </template>
  158. <template #rightRowFooter>
  159. <HcPages :pages="sortSearchForm" :sizes="[10, 20, 50, 100, 200, 300, 400, 500, 600]" @change="sortPageChange"/>
  160. </template>
  161. </HcDialog>
  162. <!--新增编辑文件-->
  163. <el-dialog v-model="showUploadModal" :title="tableUploadType === 'add'?'上传文件':'修改案卷基础信息'" width="80vw" class="hc-modal-border hc-modal-table">
  164. <div class="batch-set" v-if="tableUploadType === 'add'">
  165. <span>批量设置</span>
  166. <span class="ml-10">档号:</span>
  167. <span>前缀:</span>
  168. <span><el-input v-model="batchSet.prefix" placeholder="输入档号前缀"/></span>
  169. <span class="ml-5">流水号:</span>
  170. <span><el-input v-model="batchSet.numberStart" placeholder="起号" class="batch-set-input"/></span>
  171. <span>~</span>
  172. <span><el-input v-model="batchSet.numberEnd" placeholder="止号" class="batch-set-input"/></span>
  173. <span class="ml-5">密级:</span>
  174. <span>
  175. <el-select v-model="batchSet.securityLevel">
  176. <el-option v-for="item in securityLevel" :key="item['dictKey']" :label="item['dictValue']" :value="item['dictKey']"/>
  177. </el-select>
  178. </span>
  179. <span class="ml-5">保管期限:</span>
  180. <span>
  181. <el-select v-model="batchSet.storagePeriod">
  182. <el-option v-for="item in storagePeriod" :key="item['dictKey']" :label="item['dictValue']" :value="item['dictKey']"/>
  183. </el-select>
  184. </span>
  185. <span class="ml-5">立卷单位:</span>
  186. <span><el-input v-model="batchSet.filingUnit" placeholder="输入立卷单位"/></span>
  187. <span class="ml-5">
  188. <el-button type="primary" @click="batchSetHandle">设置</el-button>
  189. </span>
  190. </div>
  191. <HcTable ui="hc-form-table" :column="tableUploadColumn" :datas="tableUploadData" :loading="uploadSaveLoading" :isIndex="false" :class="{'set-table': tableUploadType === 'add'}">
  192. <template #no="{index}">
  193. {{index+1}}
  194. <template v-if="tableUploadType === 'add'">
  195. <span class="text-link text-lg">
  196. <HcIcon name="arrow-up" @click="upUpSortClick(index)"/>
  197. </span>
  198. <span class="text-link text-lg">
  199. <HcIcon name="arrow-down" @click="downUpSortClick(index)"/>
  200. </span>
  201. </template>
  202. </template>
  203. <template #fileNumber="{row}">
  204. <el-input v-model="row.fileNumber" type="textarea"/>
  205. </template>
  206. <template #name="{row}">
  207. <el-input v-model="row.name" type="textarea"/>
  208. </template>
  209. <template #secretLevel="{row}">
  210. <el-select v-model="row.secretLevel">
  211. <el-option v-for="item in securityLevel" :key="item['dictKey']" :label="item['dictValue']" :value="item['dictKey']"/>
  212. </el-select>
  213. </template>
  214. <template #storageTime="{row}">
  215. <el-select v-model="row.storageTime">
  216. <el-option v-for="item in storagePeriod" :key="item['dictKey']" :label="item['dictValue']" :value="item['dictKey']"/>
  217. </el-select>
  218. </template>
  219. <template #filingUnit="{row}">
  220. <el-input v-model="row.filingUnit" type="textarea"/>
  221. </template>
  222. <template #dates="{row}">
  223. <el-date-picker v-model="row.dates" value-format="YYYY-MM-DD HH:mm:ss" type="daterange"/>
  224. </template>
  225. <template #action="{row,index}" v-if="tableUploadType === 'add'">
  226. <el-button type="danger" plain size="small" :loading="row['delBtnLoading']" @click="delUploadData(row,index)">删除</el-button>
  227. </template>
  228. </HcTable>
  229. <template #footer>
  230. <div class="lr-dialog-footer">
  231. <div class="left flex items-center">
  232. <el-button type="primary" hc-btn @click="uploadFileClick">
  233. <HcIcon name="add-circle"/>
  234. <span>新增上传</span>
  235. </el-button>
  236. <el-alert title="提示:每次不超过10份,文件量越多,响应容易超时" type="error" :closable="false"/>
  237. </div>
  238. <div class="right">
  239. <el-button size="large" @click="batchUploadCancel" :disabled="uploadsLoading">
  240. <HcIcon name="close"/>
  241. <span>取消</span>
  242. </el-button>
  243. <el-button type="primary" hc-btn :disabled="uploadsLoading" :loading="uploadSaveLoading" @click="batchUploadSave">
  244. <HcIcon name="save"/>
  245. <span>提交保存</span>
  246. </el-button>
  247. </div>
  248. </div>
  249. </template>
  250. </el-dialog>
  251. <HcUploadFile ref="HcUploadFileRef"
  252. @fileProgress="HcUploadFileProgress"
  253. @fileSuccess="HcUploadFileSuccess"
  254. @filesChange="HcUploadFileChange"/>
  255. </div>
  256. </template>
  257. <script setup>
  258. import {ref, watch, onMounted,nextTick } from "vue";
  259. import {useAppStore} from "~src/store";
  260. import HcTree from "~src/components/tree/hc-tree.vue"
  261. import notableform from '~src/assets/view/notableform.svg';
  262. import {delMessage, rowsToId, rowsToIdNumArr} from "~uti/tools";
  263. import {getArrValue, deepClone, downloadBlob, getObjVal} from "js-fast-way"
  264. import tasksApi from '~api/tasks/data';
  265. import ossApi from "~api/oss";
  266. import archiveFileApi from "~api/archiveFile/archiveFileAuto.js";
  267. //变量
  268. const useAppState = useAppStore()
  269. const projectId = ref(useAppState.getProjectId);
  270. const contractId = ref(useAppState.getContractId);
  271. const projectInfo = ref(useAppState.getProjectInfo);
  272. const isCollapse = ref(useAppState.getCollapse)
  273. const userInfo = ref(useAppState.getUserInfo)
  274. //上传变量
  275. const HcUploadFileRef = ref(null)
  276. const uploadsLoading = ref(false)
  277. //监听
  278. watch(() => [
  279. useAppState.getCollapse
  280. ], ([Collapse]) => {
  281. isCollapse.value = Collapse
  282. })
  283. //渲染完成
  284. onMounted(() => {
  285. treeLoading.value = true
  286. setTableColumns()
  287. getStoragePeriod()
  288. getSecurityLevel()
  289. })
  290. //打开文件选择框
  291. const uploadFileClick = () => {
  292. HcUploadFileRef?.value.btnUpload()
  293. }
  294. // 文件上传进度
  295. const HcUploadFileProgress = (res) => {
  296. uploadsLoading.value = res
  297. }
  298. // 文件上传成功的回调
  299. const HcUploadFileSuccess = (res) => {
  300. console.log('文件上传成功', res)
  301. uploadsChange(res)
  302. }
  303. // 文件全部上传成功
  304. const HcUploadFileChange = () => {
  305. console.log('文件全部上传成功')
  306. HcUploadFileRef?.value.close()
  307. }
  308. //树加载
  309. const treeLoading = ref(false)
  310. const treeNodeLoading = () => {
  311. treeLoading.value = false
  312. }
  313. const treePanelLoading = ref(false)
  314. const panelTreeLoading = () => {
  315. treePanelLoading.value = false
  316. }
  317. //审批状态
  318. const approvalStatus = ref([
  319. {label: '未上报', value: '1'},
  320. {label: '待审批', value: '2'},
  321. {label: '已审批', value: '3'}
  322. ])
  323. //认证状态
  324. const certifiedStatus = ref([
  325. {label: '已认证', value: '1'},
  326. {label: '未认证', value: '2'}
  327. ])
  328. //搜索表单
  329. const searchForm = ref({
  330. nodeIds:'',
  331. approval: null, certified: null, queryValue: null,
  332. current: 1, size: 5, total: 0
  333. })
  334. //树相关的变量
  335. const primaryKeyId = ref('')
  336. const isBuiltDrawing = ref(0)
  337. const isStorageNode = ref(0)
  338. const nodeIds = ref('')
  339. const projectTreeClick = ({node, data, keys, key}) => {
  340. nodeIds.value = data.id || '';
  341. isStorageNode.value = data['isStorageNode'] || 0;
  342. //设置搜索数据
  343. searchForm.value.current = 1;
  344. searchForm.value.nodeIds = data.id || '';
  345. sortSearchForm.value.nodeIds = data.id || '';
  346. getTableData()
  347. }
  348. //回车搜索
  349. const keyUpEvent = (e) => {
  350. if (e.key === "Enter") {
  351. searchForm.value.current = 1;
  352. getTableData()
  353. }
  354. }
  355. //搜索
  356. const searchClick = () => {
  357. searchForm.value.current = 1;
  358. getTableData()
  359. }
  360. //分页被点击
  361. const pageChange = ({current, size}) => {
  362. searchForm.value.current = current
  363. searchForm.value.size = size
  364. getTableData()
  365. }
  366. //表格数据
  367. const tableRef = ref(null)
  368. const tableColumn = ref([])
  369. //设置表头
  370. const setTableColumns = () => {
  371. tableColumn.value = [
  372. {key:'fileNumber', name: '档号', width: 160},
  373. {key:'name', name: '案卷题名'},
  374. {key:'secretLevel', name: '密级', width: 100},
  375. {key:'storageTime', name: '保管期限', width: 100},
  376. {key:'pageN', name: '页数', width: 100},
  377. {key:'filingUnit', name: '立卷单位'},
  378. {key:'dates', name: '起止日期', width: 190}
  379. ]
  380. }
  381. const tableData = ref([])
  382. //获取数据
  383. const tableLoading = ref(false)
  384. const getTableData = async () => {
  385. tableLoading.value = true
  386. const { error, code, data } = await archiveFileApi.getarchiveFilePage({
  387. ...searchForm.value,
  388. projectId: projectId.value,
  389. contractId: contractId.value,
  390. isAutoFile:1
  391. })
  392. tableLoading.value = false
  393. if (!error && code === 200) {
  394. tableData.value = getArrValue(data['records'])
  395. tableData.value.forEach((element)=>{
  396. element.dates = [element.startDate,element.endDate]
  397. })
  398. searchForm.value.total = data['total'] || 0
  399. } else {
  400. tableData.value = []
  401. searchForm.value.total = 0
  402. }
  403. }
  404. //多选
  405. const tableCheckedKeys = ref([]);
  406. const tableSelection = (rows) => {
  407. tableCheckedKeys.value = rows
  408. }
  409. //分盒整理
  410. const sortingModal = ref(false)
  411. const sortingClick = async() => {
  412. if (nodeIds.value && isStorageNode.value === 1) {
  413. const { error, code, data } = await archiveFileApi.getBoxNameAndBoxNumber({
  414. nodeId:nodeIds.value
  415. })
  416. if (!error && code === 200) {
  417. if(data.length > 0){
  418. sortingActiveKey.value = [];
  419. sortingModal.value = true
  420. sortingItemData.value = getArrValue(data)
  421. sortingOldData.value = deepClone(sortingItemData.value)
  422. }else{
  423. sortingNoneModal.value = true
  424. }
  425. }
  426. } else {
  427. window?.$message?.warning('请先选择一个子节点')
  428. }
  429. }
  430. const sortingNoneModal = ref(false)//无数据显示的弹窗
  431. const toSortingModal = ()=>{
  432. sortingNoneModal.value = false;
  433. sortingActiveKey.value = [];
  434. sortingModal.value = true
  435. }
  436. const sortingItemData = ref([])
  437. const sortingOldData = ref([])//旧数据,用来对比是否修改名字
  438. //获取数据
  439. const sortingItemLoading = ref(false)
  440. const getSortingItemData = () => {
  441. }
  442. //校验
  443. const tableIsInput = (val, row, key) => {
  444. //console.log(!val);
  445. //检测是否改过案卷名字
  446. if(key == 'isName'){
  447. row.isChange = true;
  448. }
  449. row[key] = !val;
  450. }
  451. //选择文件
  452. // const sortingActiveKey = ref('')
  453. // const sortingSelectFile = (row, index) => {
  454. // //取当前展开组的key
  455. // const key = sortingActiveKey.value;
  456. // const keys = key ? key.split('-') : [];
  457. // const active = keys.length > 0 ? keys[1]: -1;
  458. // if (Number(active) === index) {
  459. // sortingActiveKey.value = null;
  460. // } else {
  461. // sortingActiveKey.value = `item-${index}`;
  462. // }
  463. // }
  464. const sortingActiveKey = ref([])
  465. const sortingSelectFile = (row, index) => {
  466. const key = `item-${index}`;
  467. const indexNum = sortingActiveKey.value.indexOf(key);
  468. if(indexNum > -1){
  469. sortingActiveKey.value.splice(indexNum,1);
  470. }else{
  471. sortingActiveKey.value.push(key);
  472. if(!(row.list && row.list.length > 0)){
  473. getSortingTableData(row, index)
  474. }
  475. }
  476. }
  477. //表格
  478. const sortingTableColumn = [
  479. {key:'name', name: '文件名称'},
  480. ];
  481. const sortingTableData = ref([])
  482. //获取数据
  483. const sortingTableLoading = ref(false)
  484. const getSortingTableData = async(row, index) => {
  485. sortingTableLoading.value = true
  486. const { error, code, data } = await archiveFileApi.pageByBoxName({
  487. size: 99999,
  488. current: 1,
  489. projectId: projectId.value,
  490. contractId: contractId.value,
  491. nodeIds:nodeIds.value,
  492. boxName:row.boxName?row.boxName:''
  493. })
  494. sortingTableLoading.value = false
  495. if (!error && code === 200) {
  496. row.list = getArrValue(data['records'])
  497. setTableCheck(row, index)
  498. } else {
  499. row.list = []
  500. }
  501. }
  502. //表格ref
  503. const sorTableRef = ref([]);
  504. //回显勾选
  505. const setTableCheck = async(row, index) => {
  506. //console.log(row)
  507. if(row.ids){
  508. const keys = row.ids.split(',');
  509. row.list.forEach(async (item)=>{
  510. if(keys.indexOf(item.id) > -1){
  511. item.checked = true;
  512. await nextTick();
  513. sorTableRef.value[index].toggleRowSelection(item,true);
  514. }
  515. })
  516. }
  517. }
  518. //多选
  519. const sortingTableKeys = ref([]);
  520. const sortingTableSelection = (rows,list,event) => {
  521. //console.log(event)
  522. list.forEach(element => {
  523. element.checked = false;
  524. });
  525. rows.forEach((element)=>{
  526. element.checked = true;
  527. })
  528. }
  529. //删除
  530. const sortingDelData = (row,index) => {
  531. sortingItemData.value.splice(index,1);
  532. }
  533. //添加分盒
  534. const addSortingModalClick = () => {
  535. sortingItemData.value.push({
  536. boxName: ''
  537. })
  538. }
  539. //确认保存
  540. const sortingModalLoading = ref(false)
  541. const sortingModalSave = async() => {
  542. sortingModalLoading.value = true
  543. //检测案卷名是否重复
  544. let nameRes = await checkNames();
  545. //console.log(nameRes)
  546. //return;
  547. for (let i = 0; i < nameRes.length; i++) {
  548. if(typeof nameRes[i].data == 'string'){
  549. window.$message?.error(nameRes[i].data+',案卷名重复')
  550. sortingModalLoading.value = false
  551. return;
  552. }
  553. }
  554. //组装数据
  555. let rows = [];
  556. sortingItemData.value.forEach((item,index)=>{
  557. let obj = {
  558. ids:'',
  559. boxName:item.boxName,
  560. boxNumber:index+1,
  561. };
  562. let list = [];
  563. if(item.list){
  564. item.list.forEach((item2)=>{
  565. if(item2.checked){
  566. list.push(item2.id)
  567. }
  568. })
  569. obj.ids = list.join(',');
  570. }else{
  571. obj.ids = item.ids;
  572. }
  573. rows.push(obj)
  574. })
  575. const { error, code, data } = await archiveFileApi.allocation({
  576. list: rows
  577. })
  578. if (!error && code === 200) {
  579. window.$message?.success('保存成功')
  580. sortingModal.value = false
  581. } else {
  582. window.$message?.error('保存失败')
  583. }
  584. sortingModalLoading.value = false
  585. }
  586. const checkNames =() =>{
  587. const arr = [];
  588. sortingItemData.value.forEach((item)=>{
  589. if(item.boxNumber){
  590. if(item.isChange){
  591. //是否修改过
  592. //对比旧的数据,是否相同
  593. for (let i = 0; i < sortingOldData.value.length; i++) {
  594. if(sortingOldData.value[i].boxNumber == item.boxNumber){
  595. if(sortingOldData.value[i].boxName != item.boxName){
  596. arr.push(
  597. archiveFileApi.getIsBoxName({
  598. boxName:item.boxName
  599. })
  600. )
  601. }
  602. return;
  603. }
  604. }
  605. }
  606. }else{
  607. arr.push(
  608. archiveFileApi.getIsBoxName({
  609. boxName:item.boxName
  610. })
  611. )
  612. }
  613. })
  614. return Promise.all(arr);
  615. }
  616. //关闭
  617. const sortingModalClose = () => {
  618. sortingModal.value = false
  619. }
  620. //删除
  621. const delModalClick = () => {
  622. delMessage(async () => {
  623. let ids = [];
  624. tableCheckedKeys.value.forEach((element)=>{
  625. ids.push(element.id)
  626. })
  627. const { error, code, data } = await archiveFileApi.remove({
  628. ids:ids.join(',')
  629. })
  630. //处理数据
  631. if (!error && code === 200) {
  632. window.$message?.success('操作成功')
  633. getTableData()
  634. }
  635. })
  636. }
  637. //跨目录移动
  638. const movesModal = ref(false)
  639. const movesClick = async() => {
  640. movesModal.value = true
  641. treePanelLoading.value = true
  642. const { error, code, data } = await archiveFileApi.getarchiveFilePage({
  643. ...searchForm.value,
  644. size:9999,
  645. projectId: projectId.value,
  646. contractId: contractId.value
  647. })
  648. if (!error && code === 200) {
  649. fileDatasList.value = getArrValue(data['records'])
  650. } else {
  651. fileDatasList.value = []
  652. }
  653. }
  654. //选择需要迁移的文件
  655. const movesCheckAll = ref(false)
  656. const isIndeterminate = ref(true)
  657. const checkedMoves = ref([])
  658. //左侧待迁移文件
  659. const fileDatasList = ref([])
  660. //全选
  661. const handleCheckAllChange = (val) => {
  662. const checked = fileDatasList.value
  663. const keys = rowsToIdNumArr(checked);
  664. checkedMoves.value = val ? keys : []
  665. isIndeterminate.value = false
  666. }
  667. //勾选
  668. const handleCheckedMovesChange = (value) => {
  669. const keys = fileDatasList.value
  670. const checkedCount = value.length
  671. movesCheckAll.value = checkedCount === keys.length
  672. isIndeterminate.value = checkedCount > 0 && checkedCount < keys.length
  673. }
  674. //右侧radio
  675. const movesTreeRef = ref(null)
  676. let radioNode = ref(null)
  677. const radioChange = (id)=>{
  678. //console.log(id)
  679. //radioNodeId = id;
  680. radioNode.value = movesTreeRef.value.ElTreeRef.getNode(id);
  681. }
  682. //只显示储存节点的单选
  683. const showRadioFun = (data)=>{
  684. if(data.isStorageNode == 1){
  685. return true;
  686. }else{
  687. return false;
  688. }
  689. }
  690. //保存
  691. const movesModalLoading = ref(false)
  692. const movesModalSave = async() => {
  693. let ids = checkedMoves.value.join(',')
  694. if(checkedMoves.value.length < 1){
  695. window.$message?.warning('请勾选需要迁移的文件')
  696. return;
  697. }
  698. if(!radioNode.value){
  699. window.$message?.warning('请选择要移动到的节点')
  700. return;
  701. }
  702. movesModalLoading.value = true;
  703. const { error, code, data } = await archiveFileApi.migrateFile({
  704. ids:ids,
  705. nodeId:radioNode.value.data.id,
  706. nodeSort:radioNode.value.data.treeSort,
  707. })
  708. movesModalLoading.value = false
  709. if (!error && code === 200) {
  710. window.$message?.success('保存成功')
  711. movesModal.value = false
  712. getTableData()
  713. } else {
  714. window.$message?.error('保存失败')
  715. }
  716. }
  717. //关闭
  718. const movesModalClose = () => {
  719. movesModal.value = false
  720. }
  721. //表格排序
  722. const sortModal = ref(false)
  723. //显示
  724. const tableSortClick = () => {
  725. sortModal.value = true
  726. getSortTableData()
  727. }
  728. //搜索表单
  729. const sortSearchForm = ref({
  730. nodeIds:'',
  731. current: 1, size: 20, total: 0
  732. })
  733. //分页被点击
  734. const sortPageChange = ({current, size}) => {
  735. sortSearchForm.value.current = current
  736. sortSearchForm.value.size = size
  737. getSortTableData()
  738. }
  739. //表格数据
  740. const sortTableColumn = ref([
  741. {key:'fileNumber', name: '档号', width: 160},
  742. {key:'name', name: '案卷题名'},
  743. {key:'action', name: '排序', width: 90},
  744. ])
  745. const sortTableData = ref([])
  746. const sortTableLoading = ref(false)
  747. const getSortTableData = async () => {
  748. sortTableLoading.value = true
  749. const { error, code, data } = await archiveFileApi.getarchiveFilePage({
  750. ...sortSearchForm.value,
  751. projectId: projectId.value,
  752. contractId: contractId.value
  753. })
  754. sortTableLoading.value = false
  755. if (!error && code === 200) {
  756. sortTableData.value = getArrValue(data['records'])
  757. sortSearchForm.value.total = data['total'] || 0
  758. } else {
  759. sortTableData.value = []
  760. sortSearchForm.value.total = 0
  761. }
  762. }
  763. //拖动完成
  764. const sortTableRowDrop = (rows) => {
  765. sortTableData.value = rows
  766. }
  767. //向下
  768. const downSortClick = (index) => {
  769. const indexs = index + 1
  770. const data = sortTableData.value
  771. if(indexs !== data.length) {
  772. const tmp = data.splice(indexs,1);
  773. sortTableData.value.splice(index,0,tmp[0]);
  774. } else {
  775. window?.$message?.warning('已经处于置底,无法下移')
  776. }
  777. }
  778. //向上
  779. const upSortClick = (index) => {
  780. const data = sortTableData.value || []
  781. if(index !== 0) {
  782. const tmp = data.splice(index - 1,1);
  783. sortTableData.value.splice(index,0,tmp[0]);
  784. } else {
  785. window?.$message?.warning('已经处于置顶,无法上移')
  786. }
  787. }
  788. //保存
  789. const sortModalLoading = ref(false)
  790. const sortModalSave = async() => {
  791. let rows = sortTableData.value;
  792. rows.forEach((element,index)=>{
  793. element.autoFileSort = index+1
  794. })
  795. await batchEditSaveApi(rows)
  796. sortModal.value = false
  797. }
  798. //关闭
  799. const sortModalClose = () => {
  800. sortModal.value = false
  801. }
  802. //获取认证状态
  803. const certificationType = ref([])
  804. const certificationStatus = async () => {
  805. const { error, code, data } = await tasksApi.queryTaskTypeStatus({
  806. typeOrStatus: 'certification_status'
  807. })
  808. //处理数据
  809. if (!error && code === 200) {
  810. certificationType.value = getArrValue(data)
  811. } else {
  812. certificationType.value = []
  813. }
  814. }
  815. //获取图幅类型
  816. const sheetType = ref([])
  817. const sheetTypeStatus = async () => {
  818. const { error, code, data } = await tasksApi.queryTaskTypeStatus({
  819. typeOrStatus: 'sheet_type'
  820. })
  821. //处理数据
  822. if (!error && code === 200) {
  823. sheetType.value = getArrValue(data)
  824. } else {
  825. sheetType.value = []
  826. }
  827. }
  828. //获取图表来源
  829. const sheetSourceType = ref([])
  830. const sheetSourceStatus = async () => {
  831. const { error, code, data } = await tasksApi.queryTaskTypeStatus({
  832. typeOrStatus: 'sheet_source'
  833. })
  834. //处理数据
  835. if (!error && code === 200) {
  836. sheetSourceType.value = getArrValue(data)
  837. } else {
  838. sheetSourceType.value = []
  839. }
  840. }
  841. //获取密级
  842. const securityLevel = ref([])
  843. const getSecurityLevel = async () => {
  844. const { error, code, data } = await tasksApi.queryTaskTypeStatus({
  845. typeOrStatus: 'security_level'
  846. })
  847. //处理数据
  848. if (!error && code === 200) {
  849. securityLevel.value = getArrValue(data)
  850. } else {
  851. securityLevel.value = []
  852. }
  853. }
  854. //获取保管期限
  855. const storagePeriod = ref([])
  856. const getStoragePeriod = async () => {
  857. const { error, code, data } = await tasksApi.queryTaskTypeStatus({
  858. typeOrStatus: 'storage_period'
  859. })
  860. //处理数据
  861. if (!error && code === 200) {
  862. storagePeriod.value = getArrValue(data)
  863. } else {
  864. storagePeriod.value = []
  865. }
  866. }
  867. //新增文件
  868. const tableUploadType = ref('add')
  869. const showUploadModal = ref(false)
  870. const uploadModalClick = () => {
  871. if (nodeIds.value && isStorageNode.value === 1) {
  872. tableUploadType.value = 'add'
  873. setTableUploadColumn()
  874. uploadSaveLoading.value = false
  875. tableUploadData.value = []
  876. showUploadModal.value = true
  877. } else {
  878. window?.$message?.warning('请先选择一个子节点')
  879. }
  880. }
  881. //设置文件表头
  882. const tableUploadColumn = ref([
  883. {key:'no', name: '序号', width: 100},
  884. {key:'fileNumber', name: '档号', width: 160},
  885. {key:'name', name: '案卷题名'},
  886. {key:'secretLevel', name: '密级', width: 100},
  887. {key:'storageTime', name: '保管期限', width: 100},
  888. {key:'filingUnit', name: '立卷单位'},
  889. {key:'dates', name: '起止日期', width: 380},
  890. {key:'action', name: '操作', width: 100}
  891. ])
  892. const setTableUploadColumn = () => {
  893. }
  894. const tableUploadData = ref([])
  895. //上传的文件结果
  896. const uploadsChange = (item) => {
  897. if (getObjVal(item)) {
  898. let newArr = tableUploadData.value
  899. let name = item['originalName'] || ''
  900. let fileName = name.substring(0, name.lastIndexOf("."))
  901. newArr.push({
  902. projectId: projectId.value,
  903. contractId: contractId.value,
  904. nodeId: nodeIds.value,
  905. name:fileName,
  906. approvalFileList:[{
  907. projectId: projectId.value,
  908. contractId: contractId.value,
  909. nodeId: nodeIds.value,
  910. fileName: fileName,
  911. fileNumber:'',
  912. ossFileName: item?.name || '',
  913. fileUrl: item?.link || '',
  914. pdfFileUrl: item?.pdfUrl || '',
  915. filePage: item?.page || '',
  916. isApproval:0,
  917. isNeedCertification:0,
  918. dutyUser: userInfo.value.real_name
  919. }]
  920. })
  921. tableUploadData.value = newArr
  922. } else {
  923. console.log(item)
  924. }
  925. }
  926. //表单下拉数据
  927. const whetherData = ref([
  928. {label: "不需要", value: 0},
  929. {label: "需要", value: 1}
  930. ])
  931. //删除
  932. const delUploadData = async (row,index) => {
  933. if (row['ossFileName']) {
  934. row['delBtnLoading'] = true
  935. await ossApi.removeFile({fileName: row['ossFileName']})
  936. row['delBtnLoading'] = false
  937. tableUploadData.value.splice(index,1);
  938. } else {
  939. tableUploadData.value.splice(index,1);
  940. }
  941. }
  942. //批量上传保存
  943. const uploadSaveLoading = ref(false)
  944. const batchUploadSave = async () => {
  945. const rows = tableUploadData.value
  946. if (rows.length > 0) {
  947. //验证表单数据
  948. uploadSaveLoading.value = true
  949. let isTableRows = false;
  950. //判断数据
  951. if (isTableRows) {
  952. uploadSaveLoading.value = false
  953. window.$message?.warning('请先完善表单信息')
  954. } else {
  955. //数据处理
  956. rows.forEach((element,index)=>{
  957. element.startDate = element.dates[0]
  958. element.endDate = element.dates[1]
  959. element.autoFileSort = index+1
  960. })
  961. if (tableUploadType.value === 'add') {
  962. await batchUploadSaveApi(rows)
  963. } else {
  964. await batchEditSaveApi(rows)
  965. }
  966. }
  967. } else {
  968. window.$message?.warning('请先上传文件')
  969. }
  970. }
  971. //确认上传保存
  972. const batchUploadSaveApi = async (rows) => {
  973. uploadSaveLoading.value = true
  974. const {error, code} = await archiveFileApi.batchUploadSave({
  975. list: rows
  976. },false)
  977. //判断状态
  978. uploadSaveLoading.value = false
  979. if (!error && code === 200) {
  980. window.$message?.success('保存成功')
  981. batchUploadCancel()
  982. getTableData()
  983. } else {
  984. window.$message?.error('保存失败')
  985. }
  986. }
  987. //取消上传
  988. const batchUploadCancel = () => {
  989. tableUploadData.value = []
  990. uploadSaveLoading.value = false
  991. uploadsLoading.value = false
  992. showUploadModal.value = false
  993. }
  994. //批量编辑
  995. const batchEditClick = () => {
  996. const rows = deepClone(tableCheckedKeys.value)
  997. //判断是否满足条件
  998. tableUploadType.value = 'edit'
  999. setTableUploadColumn()
  1000. uploadSaveLoading.value = false
  1001. tableUploadData.value = rows
  1002. showUploadModal.value = true
  1003. }
  1004. //确认编辑上传保存
  1005. const batchEditSaveApi = async (rows) => {
  1006. uploadSaveLoading.value = true
  1007. const {error, code} = await archiveFileApi.batchUploadSave({
  1008. list: rows
  1009. },false)
  1010. //判断状态
  1011. uploadSaveLoading.value = false
  1012. if (!error && code === 200) {
  1013. window.$message?.success('保存成功')
  1014. batchUploadCancel()
  1015. getTableData()
  1016. } else {
  1017. window.$message?.error('保存失败')
  1018. }
  1019. }
  1020. //上传文件向下
  1021. const downUpSortClick = (index) => {
  1022. const indexs = index + 1
  1023. const data = tableUploadData.value
  1024. if(indexs !== data.length) {
  1025. const tmp = data.splice(indexs,1);
  1026. tableUploadData.value.splice(index,0,tmp[0]);
  1027. } else {
  1028. window?.$message?.warning('已经处于置底,无法下移')
  1029. }
  1030. }
  1031. //上传文件向上
  1032. const upUpSortClick = (index) => {
  1033. const data = tableUploadData.value || []
  1034. if(index !== 0) {
  1035. const tmp = data.splice(index - 1,1);
  1036. tableUploadData.value.splice(index,0,tmp[0]);
  1037. } else {
  1038. window?.$message?.warning('已经处于置顶,无法上移')
  1039. }
  1040. }
  1041. //批量设置
  1042. const batchSet = ref({
  1043. prefix:'',
  1044. numberStart:'',
  1045. numberEnd:'',
  1046. securityLevel:'',
  1047. storagePeriod:'',
  1048. filingUnit:'',
  1049. })
  1050. //批量设置
  1051. const batchSetHandle = () => {
  1052. setSecurityLevel()
  1053. setStoragePeriod()
  1054. setFileNumber()
  1055. setFilingUnit()
  1056. }
  1057. //批量设置密级
  1058. const setSecurityLevel = () => {
  1059. if(batchSet.value.securityLevel){
  1060. let isSet = true;
  1061. for (let i = 0; i < tableUploadData.value.length; i++) {
  1062. if(tableUploadData.value[i].secretLevel!=='0' && tableUploadData.value[i].secretLevel){
  1063. isSet = false;
  1064. return;
  1065. }
  1066. }
  1067. //如果有一条数据选了,其他的都不进行设置
  1068. if(isSet){
  1069. tableUploadData.value.forEach((element)=>{
  1070. element.secretLevel = batchSet.value.securityLevel
  1071. })
  1072. }
  1073. }
  1074. }
  1075. //批量设置保管期限
  1076. const setStoragePeriod = () => {
  1077. if(batchSet.value.storagePeriod){
  1078. let isSet = true;
  1079. for (let i = 0; i < tableUploadData.value.length; i++) {
  1080. if(tableUploadData.value[i].storageTime!=='0' && tableUploadData.value[i].storageTime){
  1081. isSet = false;
  1082. return;
  1083. }
  1084. }
  1085. //如果有一条数据选了,其他的都不进行设置
  1086. if(isSet){
  1087. tableUploadData.value.forEach((element)=>{
  1088. element.storageTime = batchSet.value.storagePeriod
  1089. })
  1090. }
  1091. }
  1092. }
  1093. const setFileNumber = () => {
  1094. let isSet = true;
  1095. for (let i = 0; i < tableUploadData.value.length; i++) {
  1096. if(tableUploadData.value[i].fileNumber){
  1097. isSet = false;
  1098. return;
  1099. }
  1100. }
  1101. if(!isSet){
  1102. return;
  1103. }
  1104. if(batchSet.value.prefix && batchSet.value.numberStart && batchSet.value.numberEnd){
  1105. const regPos = /^[0-9]+.?[0-9]*/; //判断是否是数字。
  1106. if(!regPos.test(batchSet.value.numberStart)){
  1107. window.$message?.warning('流水号 起号 存在非数字,请修改')
  1108. return;
  1109. }
  1110. if(!regPos.test(batchSet.value.numberEnd)){
  1111. window.$message?.warning('流水号 止号 存在非数字,请修改')
  1112. return;
  1113. }
  1114. const startNum = Number(batchSet.value.numberStart);
  1115. const endNum = Number(batchSet.value.numberEnd);
  1116. if(startNum > endNum){
  1117. window.$message?.warning('起号需要小于止号')
  1118. return;
  1119. }
  1120. //获取最长的字符串长度
  1121. let numL = 0;
  1122. if(batchSet.value.numberStart.length > batchSet.value.numberEnd.length){
  1123. numL = batchSet.value.numberStart.length
  1124. }else{
  1125. numL = batchSet.value.numberEnd.length
  1126. }
  1127. //检测前缀最后是否有-
  1128. let prefix = batchSet.value.prefix;
  1129. if(prefix.charAt(prefix.length - 1) !== '-'){
  1130. //没有就加上
  1131. prefix = prefix + '-';
  1132. }
  1133. //遍历赋值
  1134. let index = 0;
  1135. for (let i = startNum; i <= endNum; i++) {
  1136. //超出就终止
  1137. if(tableUploadData.value[index] === undefined){
  1138. return;
  1139. }
  1140. //前面补零
  1141. const numStr = i.toString().padStart(numL,'0');
  1142. tableUploadData.value[index].fileNumber = prefix + numStr;
  1143. index++;
  1144. }
  1145. }else{
  1146. window.$message?.warning('档号由前缀和流水号组成,请填写完整再进行批量设置档号')
  1147. }
  1148. }
  1149. //立卷单位
  1150. const setFilingUnit = ()=>{
  1151. if(batchSet.value.filingUnit){
  1152. let isSet = true;
  1153. for (let i = 0; i < tableUploadData.value.length; i++) {
  1154. if(tableUploadData.value[i].filingUnit){
  1155. isSet = false;
  1156. return;
  1157. }
  1158. }
  1159. //如果有一条数据选了,其他的都不进行设置
  1160. if(isSet){
  1161. tableUploadData.value.forEach((element)=>{
  1162. element.filingUnit = batchSet.value.filingUnit
  1163. })
  1164. }
  1165. }
  1166. }
  1167. //批量下载
  1168. const downloadLoading = ref(false)
  1169. const batchDownload = async () => {
  1170. let ids = [];
  1171. tableCheckedKeys.value.forEach((element)=>{
  1172. ids.push(element.id)
  1173. })
  1174. downloadLoading.value = true
  1175. const { error,response, res} = await archiveFileApi.batchDownloadFileToZip({
  1176. ids:ids.join(',')
  1177. })
  1178. downloadLoading.value = false
  1179. if (!error) {
  1180. downloadBlob(res, response.headers['content-disposition'])
  1181. }
  1182. }
  1183. //名称被点击
  1184. const tableRowName = async (row) => {
  1185. const { error, code, data } = await archiveFileApi.mergePdf({
  1186. ids: row.id
  1187. })
  1188. //处理数据
  1189. if (!error && code === 200) {
  1190. window.open(data, '_blank')
  1191. }
  1192. }
  1193. //左右拖动,改变树形结构宽度
  1194. const leftWidth = ref(382);
  1195. const onmousedown = () => {
  1196. const leftNum = isCollapse.value ? 142 : 272
  1197. document.onmousemove = (ve) => {
  1198. let diffVal = ve.clientX - leftNum;
  1199. if(diffVal >= 310 && diffVal <= 900) {
  1200. leftWidth.value = diffVal;
  1201. }
  1202. }
  1203. document.onmouseup = () => {
  1204. document.onmousemove = null;
  1205. document.onmouseup = null;
  1206. }
  1207. }
  1208. </script>
  1209. <style lang="scss" scoped>
  1210. @import '~style/file/scoped/collection.scss';
  1211. .batch-set{
  1212. display: flex;
  1213. align-items: center;
  1214. margin-bottom: 10px;
  1215. .batch-set-input{
  1216. width: 80px;
  1217. }
  1218. }
  1219. .set-table{
  1220. height: calc(100% - 42px);
  1221. }
  1222. </style>
  1223. <style lang="scss">
  1224. @import '~style/file/collection.scss';
  1225. </style>