fileDialog.vue 7.4 KB

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