阅行客电子档案
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

367 lines
13 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <el-dialog class="detail-dialog" :title="detailTitle" :close-on-click-modal="false" :modal-append-to-body="false" append-to-body :visible.sync="archivesInfoVisible" :before-close="handleClose">
  3. <div class="setting-dialog">
  4. <div class="detail-tab tab-content">
  5. <!-- tab -->
  6. <ul class="tab-nav">
  7. <li :class="{'active-tab-nav': archivesTabIndex == 0}" @click="changeActiveTab(0)">基本信息</li>
  8. <li :class="{'active-tab-nav': archivesTabIndex == 1}" @click="changeActiveTab(1)">原文列表</li>
  9. <!-- <li v-if="isHasFile" :class="{'active-tab-nav': archivesTabIndex == 2}" @click="changeActiveTab(2)">附件</li> -->
  10. <li :class="{'active-tab-nav': archivesTabIndex == 2}" @click="changeActiveTab(2)">元数据</li>
  11. </ul>
  12. <!-- 基本信息 -->
  13. <div v-if="archivesTabIndex==0" class="base-info item-content">
  14. <el-row>
  15. <el-col v-for="(item,index) in archivesDetailsData" v-show="index<archivesDetailsData.length-5" :key="index" :span="item.isLine ? 24 : 12" class="base-info-item">
  16. <span>{{ item.fieldCnName }}</span>
  17. <p :style="{ width: ( item.editLength ? item.editLength+'px' : '' ), flex: ( !item.editLength ? 1 : '' )}">{{ item.context }}</p>
  18. </el-col>
  19. </el-row>
  20. <el-row v-if="isDetailsInfo">
  21. <el-col v-for="(item,index) in archivesDetailsData.slice(archivesDetailsData.length-5,archivesDetailsData.length)" :key="'last'+index" :span=" 12" class="base-info-item">
  22. <span>{{ item.fieldCnName }}</span>
  23. <div v-if="item.fieldName === 'folder_location' && item.context" :style="{ width: item.editLength+'px', marginTop:'-6px'}">
  24. <div v-if="item.context.indexOf(',')">
  25. <el-tag
  26. v-for="(val,key) in item.context.split(',')"
  27. :key="key"
  28. :type="val"
  29. effect="dark"
  30. >
  31. {{ val }}
  32. </el-tag>
  33. </div>
  34. <div v-else-if="!item.context.indexOf(',')">
  35. <el-tag effect="dark">{{ item.context }}</el-tag>
  36. </div>
  37. </div>
  38. <div v-else :style="{ width: item.editLength+'px'}" :class="[ (item.fieldName === 'borrow_type') ? 'row-state row-lending' : '' ]">
  39. {{ item.context }}
  40. </div>
  41. </el-col>
  42. </el-row>
  43. </div>
  44. <!-- 附件 -->
  45. <!-- <UploadFile v-if="archivesTabIndex==1" ref="uploadFile" class="item-content" :is-upload-detail="false" :category-id="categoryId" :arc-id="arcId" /> -->
  46. <!-- <ArchivesList v-if="archivesTabIndex==1" ref="dialogList" class="item-content" :is-upload-detail="false" :category-id="categoryId" :arc-id="arcId" /> -->
  47. <div v-if="archivesTabIndex==1">
  48. <el-table
  49. ref="table"
  50. :data="tableData"
  51. style="min-width: 100%"
  52. height="500"
  53. @row-click="clickRowHandler"
  54. @selection-change="selectionChangeHandler"
  55. >
  56. <el-table-column type="index" label="序号" width="55" align="center" />
  57. <el-table-column prop="file_name" label="文件名称" show-overflow-tooltip min-width="140" align="center" />
  58. <el-table-column prop="file_type" label="格式" min-width="60" align="center" />
  59. <el-table-column prop="file_size" label="大小" min-width="85" align="center">
  60. <template slot-scope="scope">
  61. {{ getFileSize(scope.row.file_size) }}
  62. </template>
  63. </el-table-column>
  64. <!-- <el-table-column prop="file_dpi" label="分辨率" min-width="85" align="center">
  65. <template slot-scope="scope">
  66. <div v-if="!scope.row.file_dpi || scope.row.file_dpi === 'null'"> - </div>
  67. <div v-else> {{ scope.row.file_dpi }} </div>
  68. </template>
  69. </el-table-column> -->
  70. <el-table-column prop="file_thumbnail" label="缩略图" min-width="60" align="center">
  71. <template slot-scope="scope">
  72. <div v-if="scope.row.file_type === 'jpg' || scope.row.file_type === 'jpeg' || scope.row.file_type === 'png' || scope.row.file_type === 'bmp'|| scope.row.file_type === 'gif'">
  73. <img width="60px" height="32px" class="screenshot" :src="baseApi+ '/downloadFile' +scope.row.file_path" :onerror="defaultImg" @click="showCoverPreview(scope.row)">
  74. </div>
  75. <div v-else>
  76. <svg-icon icon-class="fujian" class-name="svg-style" />
  77. </div>
  78. </template>
  79. </el-table-column>
  80. </el-table>
  81. <!-- @size-change="sizeChangeHandler($event)" @current-change="pageChangeHandler" -->
  82. <el-pagination :page-size.sync="page.size" :total="page.total" :current-page.sync="page.page" style="margin-top: 8px;" layout="total, prev, pager, next, sizes" />
  83. </div>
  84. <!-- 元数据 -->
  85. <div v-if="archivesTabIndex==2" class="metadata-cont item-content">
  86. <pre v-highlightjs="xml_show">
  87. <code class="highlight_s">
  88. {[xml_show]}
  89. </code>
  90. </pre>
  91. </div>
  92. </div>
  93. <div slot="footer" class="dialog-footer">
  94. <el-button type="primary" @click="archivesInfoVisible=false">确定</el-button>
  95. </div>
  96. </div>
  97. </el-dialog>
  98. </template>
  99. <script>
  100. import { form } from '@crud/crud'
  101. import { FetchArchivesDetails, FetchArchivesMetadata } from '@/api/archivesManage/archivesList'
  102. // import UploadFile from './uploadFile/index'
  103. // import ArchivesList from './list/index'
  104. export default {
  105. name: 'ArchivesInfo',
  106. components: { },
  107. mixins: [
  108. form({})
  109. ],
  110. props: {
  111. categoryId: {
  112. type: String,
  113. default: function() {
  114. return ''
  115. }
  116. },
  117. arcId: {
  118. type: String,
  119. default: function() {
  120. return ''
  121. }
  122. }
  123. },
  124. data() {
  125. return {
  126. detailTitle: '',
  127. isHasFile: false, // 卷内/文件才有附件
  128. isDetailsInfo: false, // 项目不显示最下面5行基本信息
  129. isTidOrBorrow: true, // 卷内不显示tid/借阅状态
  130. archivesInfoVisible: false,
  131. archivesTabIndex: 0,
  132. archivesDetailsData: [],
  133. archivesDetailsMetadata: [],
  134. xml_show: null,
  135. page: {
  136. total: 0,
  137. size: 10,
  138. page: 1
  139. },
  140. tableData: [
  141. {
  142. isType: '卷案表',
  143. group: ' 全宗A',
  144. category: '文书档案(案卷)',
  145. number: 'DAS-Y-2020-001',
  146. title: '人事劳资文件级文书档案人事'
  147. }, {
  148. isType: '卷案表',
  149. group: ' 全宗A',
  150. category: '文书档案(案卷)',
  151. number: 'DAS-Y-2020-001',
  152. title: '人事劳资文件级文书档案人事'
  153. }, {
  154. isType: '卷案表',
  155. group: ' 全宗A',
  156. category: '文书档案(案卷)',
  157. number: 'DAS-Y-2020-001',
  158. title: '人事劳资文件级文书档案人事'
  159. }, {
  160. isType: '卷案表',
  161. group: ' 全宗A',
  162. category: '文书档案(案卷)',
  163. number: 'DAS-Y-2020-001',
  164. title: '人事劳资文件级文书档案人事'
  165. }
  166. ], // list
  167. selections: [] // table - 选中的
  168. }
  169. },
  170. mounted() {
  171. },
  172. methods: {
  173. getFileSize(fileSize) {
  174. const fileSizeInKB = (fileSize / 1024).toFixed(2) + 'kB'
  175. const fileSizeInB = fileSize + 'B'
  176. return (fileSize / 1024) <= 0.01 ? fileSizeInB : fileSizeInKB
  177. },
  178. getDetial(rowId) {
  179. const params = {
  180. // categoryId: this.categoryId,
  181. categoryId: 'B073E8430B85B4821E7360',
  182. // archivesId: rowId
  183. archivesId: '2946C34412182B73FBC287'
  184. }
  185. FetchArchivesDetails(params).then(data => {
  186. this.archivesDetailsData = data
  187. // 案卷 / 文件的借阅状态
  188. this.archivesDetailsData.forEach(item => {
  189. if (item.fieldName === 'borrow_type') {
  190. if (item.context === 1) {
  191. item.context = '待登记'
  192. } else if (item.context === 2) {
  193. item.context = '待借阅'
  194. } else if (item.context === 3) {
  195. item.context = '待归还'
  196. } else if (item.context === 4 || item.context === '' || item.context === null) {
  197. item.context = '-'
  198. } else if (item.context === -1) {
  199. item.context = '在库'
  200. }
  201. }
  202. })
  203. // 如果是卷内 - 不显示‘tid’/'借阅状态'
  204. if (!this.isTidOrBorrow) {
  205. const indexBorrow = this.archivesDetailsData.findIndex(item => item.fieldName === 'borrow_type')
  206. const indexTid = this.archivesDetailsData.findIndex(item => item.fieldName === 'tid')
  207. this.archivesDetailsData.splice(indexBorrow, 1)
  208. this.archivesDetailsData.splice(indexTid, 1)
  209. }
  210. })
  211. FetchArchivesMetadata(params).then(data => {
  212. this.archivesDetailsMetadata = data
  213. })
  214. },
  215. setXml() {
  216. const xmlstr = this.archivesDetailsMetadata
  217. // console.log('xmlstr:', xmlstr)
  218. // console.log('xml转json:', this.$x2js.xml2js(xmlstr))
  219. // console.log('json转xml:', this.$x2js.js2xml(this.$x2js.xml2js(xmlstr)))
  220. // this.xml_show = vkbeautify.xml(xmlstr)
  221. this.xml_show = this.showXml(xmlstr)
  222. },
  223. changeActiveTab(index) {
  224. this.archivesTabIndex = index
  225. if (this.archivesTabIndex === 2) {
  226. this.setXml()
  227. }
  228. this.$nextTick(() => {
  229. if (this.$refs.uploadFile) {
  230. this.$refs.uploadFile.tableData = []
  231. this.$refs.uploadFile.getFileList()
  232. }
  233. })
  234. },
  235. // 删除 - 关闭
  236. handleClose(done) {
  237. this.archivesInfoVisible = false
  238. done()
  239. },
  240. // xml格式化
  241. showXml(str) {
  242. var that = this
  243. var text = str
  244. // 去掉多余的空格
  245. text =
  246. '\n' +
  247. text
  248. .replace(/(<\w+)(\s.*?>)/g, function($0, name, props) {
  249. return name + ' ' + props.replace(/\s+(\w+=)/g, ' $1')
  250. })
  251. .replace(/>\s*?</g, '>\n<')
  252. // 把注释编码
  253. text = text
  254. .replace(/\n/g, '\r')
  255. .replace(/<!--(.+?)-->/g, function($0, text) {
  256. var ret = '<!--' + escape(text) + '-->'
  257. return ret
  258. })
  259. .replace(/\r/g, '\n')
  260. // 调整格式
  261. var rgx = /\n(<(([^\?]).+?)(?:\s|\s*?>|\s*?(\/)>)(?:.*?(?:(?:(\/)>)|(?:<(\/)\2>)))?)/gm
  262. var nodeStack = []
  263. var output = text.replace(rgx, function(
  264. $0,
  265. all,
  266. name,
  267. isBegin,
  268. isCloseFull1,
  269. isCloseFull2,
  270. isFull1,
  271. isFull2
  272. ) {
  273. var isClosed =
  274. isCloseFull1 === '/' ||
  275. isCloseFull2 === '/' ||
  276. isFull1 === '/' ||
  277. isFull2 === '/'
  278. var prefix = ''
  279. if (isBegin === '!') {
  280. prefix = that.getPrefix(nodeStack.length)
  281. } else {
  282. if (isBegin !== '/') {
  283. prefix = that.getPrefix(nodeStack.length)
  284. if (!isClosed) {
  285. nodeStack.push(name)
  286. }
  287. } else {
  288. nodeStack.pop()
  289. prefix = that.getPrefix(nodeStack.length)
  290. }
  291. }
  292. var ret = '\n' + prefix + all
  293. return ret
  294. })
  295. var outputText = output.substring(1)
  296. // 把注释还原并解码,调格式
  297. outputText = outputText
  298. .replace(/\n/g, '\r')
  299. .replace(/(\s*)<!--(.+?)-->/g, function($0, prefix, text) {
  300. if (prefix.charAt(0) === '\r') prefix = prefix.substring(1)
  301. text = unescape(text).replace(/\r/g, '\n')
  302. var ret =
  303. '\n' + prefix + '<!--' + text.replace(/^\s*/gm, prefix) + '-->'
  304. return ret
  305. })
  306. outputText = outputText.replace(/\s+$/g, '').replace(/\r/g, '\r\n')
  307. return outputText
  308. },
  309. getPrefix(prefixIndex) {
  310. var span = ' '
  311. var output = []
  312. for (var i = 0; i < prefixIndex; ++i) {
  313. output.push(span)
  314. }
  315. return output.join('')
  316. },
  317. // table
  318. clickRowHandler(row) {
  319. this.$refs.table.toggleRowSelection(row)
  320. },
  321. // table
  322. selectionChangeHandler(val) {
  323. this.selections = val
  324. }
  325. }
  326. }
  327. </script>
  328. <style lang="scss" scoped>
  329. .base-info,
  330. .metadata-cont{
  331. background-color: #F6F8FC;
  332. }
  333. // 档案详情
  334. .base-info{
  335. padding: 20px 0;
  336. .base-info-item{
  337. display: flex;
  338. flex-direction: row;
  339. margin-bottom: 20px;
  340. color: #545B65;
  341. span{
  342. display: block;
  343. width: 120px;
  344. margin-right: 5px;
  345. text-align: right;
  346. color: #0C0E1E;
  347. }
  348. }
  349. }
  350. code.hljs {
  351. color: #0C0E1E !important;
  352. height: 530px !important;
  353. }
  354. ::v-deep .hljs-name{
  355. color: #0C0E1E !important;
  356. }
  357. .svg-style{
  358. width: 60px;
  359. height: 32px;
  360. }
  361. </style>