Blame view

ant-design-vue-jeecg/src/views/system/modules/DataLogCompareModal.vue 3.83 KB
肖超群 authored
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<template>
  <a-modal
    :width="modalWidth"
    :visible="visible"
    :footer="null"
    @cancel="handleCancel"
    cancelText="关闭">
    <!--table区 -->
    <div class="marginCss">
      <a-table
        ref="table"
        size="small"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :rowClassName="setdataCss"
        :loading="loading"
        :scroll="{ y: 700 }"
        :pagination="false">
肖超群 authored
21
22
        <span slot="dataVersionTitle1"><a-icon type="smile-o"/> 版本:{{ dataVersion1Num }}</span>
        <span slot="dataVersionTitle2"><a-icon type="smile-o"/> 版本:{{ dataVersion2Num }}</span>
肖超群 authored
23
24
25
26
27
28
29
30
31
32
33
34
        <template slot="avatarslot" slot-scope="text, record">
          <div class="anty-img-wrap">
            <img :src="getAvatarView(record)"/>
          </div>

        </template>
      </a-table>
    </div>
  </a-modal>
</template>

<script>
肖超群 authored
35
import {getAction} from '@/api/manage'
肖超群 authored
36
肖超群 authored
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
export default {
  name: 'DataLogCompareModal',
  data() {
    return {
      modalWidth: 1000,
      modaltoggleFlag: true,
      confirmDirty: false,
      title: '操作',
      visible: false,
      model: {},
      confirmLoading: false,
      headers: {},
      //版本号
      dataVersion1Num: '',
      dataVersion2Num: '',
      //表头
      columns: [
        {
          title: '字段名',
          align: 'left',
          dataIndex: 'code',
          width: '30%',
        }, {
          align: 'left',
          dataIndex: 'dataVersion1',
          width: '30%',
          slots: {title: 'dataVersionTitle1'},
        }, {
          title: '',
          dataIndex: 'imgshow',
          align: 'center',
          scopedSlots: {customRender: "avatarslot"},
          width: '10%',
        }, {
          align: 'left',
          dataIndex: 'dataVersion2',
          width: '30%',
          slots: {title: 'dataVersionTitle2'},
        }
      ],
      //数据集
      dataSource: [],
      loading: false,
      url: {
        queryCompareUrl: "/sys/dataLog/queryCompareList",
      },
    }
  },
  created() {
肖超群 authored
86
肖超群 authored
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
  },
  methods: {
    loadData(dataId1, dataId2) {
      this.dataSource = [];
      let that = this;
      getAction(that.url.queryCompareUrl, {dataId1: dataId1, dataId2: dataId2}).then((res) => {
        if (res.success) {
          that.dataVersion1Num = res.result[0].dataVersion;
          that.dataVersion2Num = res.result[1].dataVersion;
          let json1 = JSON.parse(res.result[0].dataContent);
          let json2 = JSON.parse(res.result[1].dataContent);
          for (var item1 in json1) {
            for (var item2 in json2) {
              if (item1 == item2) {
                this.dataSource.push({
                  code: item1,
                  imgshow: '',
                  dataVersion1: json1[item1],
                  dataVersion2: json2[item2],
                })
肖超群 authored
107
108
109
110
              }
            }
          }
        } else {
肖超群 authored
111
          console.log(res.message);
肖超群 authored
112
        }
肖超群 authored
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
      })
    },
    compareModal(dataId1, dataId2) {
      this.visible = true
      this.loadData(dataId1, dataId2);
    },
    handleCancel() {
      this.close()
    },
    modalFormOk() {
    },
    close() {
      this.$emit('close');
      this.visible = false;
      this.disableSubmit = false;
    },
    setdataCss(record) {
      let className = 'trcolor';
      const dataVersion1 = record.dataVersion1;
      const dataVersion2 = record.dataVersion2;
      if (dataVersion1 != dataVersion2) {
        return className;
      }
    },
    getAvatarView: function (avatar) {
      if (avatar.dataVersion1 != avatar.dataVersion2) {
        return "/goright.png";
      } else {
        return "";
      }
    },
肖超群 authored
144
  }
肖超群 authored
145
}
肖超群 authored
146
147
148
</script>

<style scoped>
肖超群 authored
149
150
151
152
.anty-img-wrap {
  height: 25px;
  position: relative;
}
肖超群 authored
153
肖超群 authored
154
155
156
.anty-img-wrap > img {
  max-height: 100%;
}
肖超群 authored
157
肖超群 authored
158
159
160
.marginCss {
  margin-top: 20px;
}
肖超群 authored
161
肖超群 authored
162
@import '../../../assets/less/index.less';
肖超群 authored
163
</style>