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