DataLogList.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <div class="data-log-scroll" :style="{'height': height+'px'}">
  3. <div class="data-log-content">
  4. <div class="logbox">
  5. <div class="log-item" v-for="(item, index) in dataList">
  6. <span class="log-item-icon">
  7. <plus-outlined v-if="lastIndex == index" style="margin-top:3px"/>
  8. <edit-outlined v-else/>
  9. </span>
  10. <span class="log-item-content">
  11. <a @click="handleClickPerson">@{{item.createBy}}</a>
  12. {{ item.dataContent }}
  13. </span>
  14. <div class="log-item-date">
  15. <Tooltip :title="item.createTime">
  16. <span>{{ getDateDiff(item) }}</span>
  17. </Tooltip>
  18. </div>
  19. </div>
  20. </div>
  21. </div>
  22. </div>
  23. </template>
  24. <script>
  25. import { PlusOutlined, EditOutlined } from '@ant-design/icons-vue';
  26. import { getModalHeight, getLogList } from './useComment'
  27. import {ref, watchEffect} from 'vue'
  28. import { propTypes } from '/@/utils/propTypes';
  29. import { Tooltip } from 'ant-design-vue';
  30. import dayjs from 'dayjs';
  31. import 'dayjs/locale/zh.js';
  32. import relativeTime from 'dayjs/plugin/relativeTime';
  33. import customParseFormat from 'dayjs/plugin/customParseFormat';
  34. dayjs.locale('zh');
  35. dayjs.extend(relativeTime);
  36. dayjs.extend(customParseFormat);
  37. export default {
  38. name: "DataLogList",
  39. components:{
  40. PlusOutlined,
  41. EditOutlined,
  42. Tooltip
  43. },
  44. props: {
  45. tableName: propTypes.string.def(''),
  46. dataId: propTypes.string.def(''),
  47. datetime: propTypes.number.def(1),
  48. },
  49. setup(props){
  50. const winHeight = getModalHeight();
  51. const height = ref(300);
  52. height.value = winHeight - 46 - 57 -53 - 30;
  53. const dataList = ref([]);
  54. const lastIndex = ref(0);
  55. /**
  56. * 加载数据
  57. * @returns {Promise<void>}
  58. */
  59. async function loadData() {
  60. const params = {
  61. dataTable: props.tableName,
  62. dataId: props.dataId,
  63. type: 'comment'
  64. };
  65. const res = await getLogList(params);
  66. if (!res || !res.result || res.result.length == 0) {
  67. dataList.value = [];
  68. lastIndex.value = -1;
  69. } else {
  70. let arr = res.result;
  71. lastIndex.value = arr.length-1;
  72. console.log('log-list', arr);
  73. dataList.value = arr;
  74. }
  75. }
  76. watchEffect(() => {
  77. if(props.datetime){
  78. if (props.tableName && props.dataId) {
  79. console.log(props.tableName, props.dataId)
  80. loadData();
  81. }
  82. }
  83. });
  84. function getDateDiff(item) {
  85. if (item.createTime) {
  86. const temp = dayjs(item.createTime, 'YYYY-MM-DD hh:mm:ss');
  87. return temp.fromNow();
  88. }
  89. return '';
  90. }
  91. function handleClickPerson() {
  92. console.log('此功能未开放')
  93. }
  94. return {
  95. height,
  96. lastIndex,
  97. dataList,
  98. getDateDiff,
  99. handleClickPerson
  100. }
  101. }
  102. }
  103. </script>
  104. <style lang="less" scoped>
  105. .data-log-scroll{
  106. box-sizing: border-box;
  107. height: 100%;
  108. padding-bottom: 16px;
  109. width: 100%;
  110. overflow: hidden;
  111. position: relative;
  112. overflow-y: auto;
  113. .data-log-content{
  114. /* right: -10px;
  115. bottom: 0;
  116. left: 0;
  117. overflow: scroll;
  118. overflow-x: hidden;
  119. position: absolute;
  120. top: 0;*/
  121. -webkit-box-sizing: border-box;
  122. box-sizing: border-box;
  123. .logbox{
  124. box-sizing: border-box;
  125. padding-left: 16px;
  126. .log-item{
  127. box-sizing: border-box;
  128. color: #9e9e9e;
  129. margin-bottom: 20px;
  130. padding-left: 20px;
  131. padding-right: 25px;
  132. position: relative;
  133. .log-item-icon{
  134. left: 0;
  135. line-height: 16px;
  136. position: absolute;
  137. top: 3px;
  138. vertical-align: middle;
  139. }
  140. .log-item-content{
  141. word-wrap: break-word;
  142. display: inline-block;
  143. font-size: 13px;
  144. vertical-align: middle;
  145. width: 100%;
  146. word-break: break-word;
  147. box-sizing: border-box;
  148. }
  149. .log-item-date{
  150. word-wrap: break-word;
  151. display: inline-block;
  152. font-size: 13px;
  153. vertical-align: middle;
  154. width: 100%;
  155. word-break: break-word;
  156. box-sizing: border-box;
  157. margin-top: 5px;
  158. }
  159. }
  160. }
  161. }
  162. }
  163. </style>