fileDialog.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <template>
  2. <el-dialog
  3. width="80%"
  4. title="文件信息"
  5. :visible="innerVisible"
  6. append-to-body
  7. :close-on-click-modal="false"
  8. @close="closeDiag"
  9. >
  10. <!-- close-on-click-modal="false"//禁止点击遮罩层关闭弹窗。 -->
  11. <!-- $emit('update-inner-visible', false) -->
  12. <el-row class="row">
  13. <el-col :span="12">
  14. <el-row>
  15. <el-col :span="5" class="nameClass">文件名称:</el-col>
  16. <el-col :span="19" class="contentClass">{{ digData?digData.FILE_NAME_:'/' }}</el-col>
  17. </el-row>
  18. </el-col>
  19. <el-col :span="12">
  20. <el-row>
  21. <el-col :span="5" class="nameClass">版本号:</el-col>
  22. <el-col :span="19" class="contentClass">{{ digData?(digData.ban_ben_?digData.ban_ben_:(digData.xiu_ding_ban_ben_?digData.xiu_ding_ban_ben_:'/')):'/' }}</el-col>
  23. </el-row>
  24. </el-col>
  25. </el-row>
  26. <el-row class="row">
  27. <el-col :span="12">
  28. <el-row>
  29. <el-col v-if="digData.cao_zuo_lei_xing_=='新增'" :span="5" class="nameClass">创建人:</el-col>
  30. <el-col v-else :span="5" class="nameClass">修订人:</el-col>
  31. <el-col :span="19" class="contentClass">{{ digData?(digData.fileInfos.CREATOR_NAME_?digData.fileInfos.CREATOR_NAME_:'/'):'/' }}</el-col>
  32. </el-row>
  33. </el-col>
  34. <el-col :span="12">
  35. <el-row>
  36. <el-col v-if="digData.cao_zuo_lei_xing_=='新增'" :span="5" class="nameClass">创建日期:</el-col>
  37. <el-col v-else :span="5" class="nameClass">修订日期:</el-col>
  38. <el-col :span="19" class="contentClass">{{ digData?(digData.fileInfos.CREATE_TIME_?formattedTimestamp(digData.fileInfos.CREATE_TIME_):'/'):'/' }}</el-col>
  39. </el-row>
  40. </el-col>
  41. </el-row>
  42. <el-row v-if="digData.cao_zuo_lei_xing_=='修订'" class="row">
  43. <el-col :span="3" class="nameClass">修订内容:</el-col>
  44. <el-col :span="21" class="contentClass">{{ digData.xiu_ding_nei_rong?digData.xiu_ding_nei_rong:'/' }}</el-col>
  45. </el-row>
  46. <el-row v-if="digData.cao_zuo_lei_xing_=='修订'" class="row">
  47. <el-col :span="3" class="nameClass">修订原因:</el-col>
  48. <el-col :span="21" class="contentClass">{{ digData.yuan_yin_?digData.yuan_yin_:'/' }}</el-col>
  49. </el-row>
  50. <el-table
  51. :data="listData"
  52. stripe
  53. border
  54. max-height="380px"
  55. highlight-current-row
  56. style="width: 100%;padding:10px;"
  57. >
  58. <el-table-column
  59. label="用户"
  60. width="300"
  61. >
  62. <template slot-scope="scope">
  63. <span style="margin-left: 10px">{{ changUserName(scope.row.create_by_) }}</span>
  64. </template>
  65. </el-table-column>
  66. <el-table-column
  67. label="最近阅读时间"
  68. width="300"
  69. >
  70. <template slot-scope="scope">
  71. <span style="margin-left: 10px">{{ formattedTimestamp(scope.row.create_time_) }}</span>
  72. </template>
  73. </el-table-column>
  74. <el-table-column
  75. label="累计阅读时长"
  76. >
  77. <template slot-scope="scope">
  78. <span style="margin-left: 10px">{{ formatDuration(scope.row.shi_chang_) }}</span>
  79. </template>
  80. </el-table-column>
  81. </el-table>
  82. <el-pagination
  83. style="margin-top: 5px; padding-bottom: 10px"
  84. :current-page="currentPage"
  85. :page-sizes="[10, 20,30, 50,100]"
  86. :page-size="pageSize"
  87. layout="prev,pager,next,jumper,sizes,->,total"
  88. :total="showList.length"
  89. @size-change="handleSizeChange"
  90. @current-change="handleCurrentChange"
  91. />
  92. </el-dialog>
  93. </template>
  94. <script>
  95. export default {
  96. props: {
  97. showList: {
  98. type: Array,
  99. default: () => []
  100. },
  101. digData: {
  102. type: Object,
  103. default: () => {}
  104. },
  105. innerVisible: {
  106. type: Boolean,
  107. default: false
  108. },
  109. fileIndex: {
  110. type: Number }
  111. },
  112. data () {
  113. const { userList } = this.$store.getters
  114. return {
  115. userList: userList,
  116. listData: [],
  117. currentPage: 1,
  118. pageSize: 10,
  119. timer: null,
  120. controlShow: false
  121. }
  122. },
  123. watch: {
  124. innerVisible: {
  125. immediate: true,
  126. handler (val) {
  127. if (val) {
  128. this.updateShowList()
  129. }
  130. }
  131. }
  132. },
  133. mounted () {
  134. this.setInterfaceTime()
  135. },
  136. methods: {
  137. updateShowList () {
  138. const start = (this.currentPage - 1) * this.pageSize
  139. const end = start + this.pageSize
  140. this.listData = this.showList.slice(start, end)
  141. },
  142. handleSizeChange (val) {
  143. this.pageSize = val
  144. this.updateShowList()
  145. },
  146. handleCurrentChange (val) {
  147. this.currentPage = val
  148. this.updateShowList()
  149. },
  150. // 定时器
  151. setInterfaceTime () {
  152. this.timer = setTimeout(() => {
  153. this.$emit('pause')
  154. }, 30000)
  155. },
  156. formattedTimestamp (timestamp) {
  157. const date = new Date(timestamp)
  158. // 获取年月日时分秒
  159. const year = date.getFullYear()
  160. const month = String(date.getMonth() + 1).padStart(2, '0')
  161. const day = String(date.getDate()).padStart(2, '0')
  162. const hours = String(date.getHours()).padStart(2, '0')
  163. const minutes = String(date.getMinutes()).padStart(2, '0')
  164. const seconds = String(date.getSeconds()).padStart(2, '0')
  165. // 格式化日期
  166. return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
  167. },
  168. // id转name
  169. changUserName (id) {
  170. const user = this.userList.find(item => item.userId === id)
  171. if (user) {
  172. return user.userName
  173. }
  174. },
  175. // 查阅时长的转化
  176. formatDuration (data) {
  177. // 定义变量
  178. let hours = 0
  179. let minutes = 0
  180. let seconds = data
  181. // 处理大于 60 分钟的情况
  182. if (data >= 3600) { // 3600 秒 = 1 小时
  183. hours = Math.floor(data / 3600)
  184. data %= 3600
  185. }
  186. // 处理大于 60 秒的情况
  187. if (data >= 60) {
  188. minutes = Math.floor(data / 60)
  189. seconds = data % 60
  190. }
  191. // 格式化输出
  192. const formattedHours = hours > 0 ? `${hours}小时` : ''
  193. const formattedMinutes = minutes > 0 ? `${minutes}分钟` : ''
  194. const formattedSeconds = seconds > 0 ? `${seconds}秒` : ''
  195. // 返回格式化的字符串
  196. return `${formattedHours}${formattedMinutes}${formattedSeconds}`
  197. },
  198. closeDiag () {
  199. this.$emit('update-inner-visible', false)
  200. this.$emit('start')
  201. clearTimeout(this.timer)
  202. }
  203. }
  204. }
  205. </script>
  206. <style scoped lang="scss">
  207. .row{
  208. padding: 1% 2%;
  209. .nameClass{
  210. font-size: 16px;
  211. color: #555;
  212. font-weight: 600;
  213. }
  214. .contentClass{
  215. font-size: 16px;
  216. color: #777;
  217. }
  218. }
  219. </style>