Blame view

src/components/admin/viewUnItemLog.vue 3.27 KB
b25b036d   wuxw   v1.9 优化日期
1
  <template>
1705091d   wuxw   开发完成 admin 台账功能
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
    <el-dialog
      :title="$t('viewUnItemLog.title')"
      :visible.sync="visible"
      width="70%"
    >
      <el-form label-width="120px">
        <el-form-item :label="$t('viewUnItemLog.serviceName')">
          <el-input v-model="viewUnItemLogInfo.serviceName" disabled />
        </el-form-item>
        <el-row>
          <el-col :span="12">
            <el-form-item :label="$t('viewUnItemLog.action')">
              <el-input v-model="viewUnItemLogInfo.action" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('viewUnItemLog.actionObj')">
              <el-input v-model="viewUnItemLogInfo.actionObj" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item :label="$t('viewUnItemLog.preValue')">
          <el-input
            v-model="viewUnItemLogInfo.preValue"
            type="textarea"
            :rows="5"
            disabled
          />
        </el-form-item>
        <el-form-item :label="$t('viewUnItemLog.afterValue')">
          <el-input
            v-model="viewUnItemLogInfo.afterValue"
            type="textarea"
            :rows="5"
            disabled
          />
        </el-form-item>
        <el-form-item :label="$t('viewUnItemLog.logText')">
          <el-input
            v-model="viewUnItemLogInfo.logText"
            type="textarea"
            :rows="5"
            disabled
          />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="warning" @click="visible = false">
          {{ $t('common.cancel') }}
        </el-button>
      </div>
    </el-dialog>
  </template>
  
  <script>
  import { listUnitemLog } from '@/api/admin/orderManageApi'
  
  export default {
    name: 'ViewUnItemLog',
    data() {
      return {
        visible: false,
        viewUnItemLogInfo: {
          bId: '',
          serviceName: '',
          logText: '',
          preValue: '',
          afterValue: '',
          action: '',
          actionObj: ''
        }
      }
    },
    methods: {
      open(order) {
        this.clearLog()
        this.viewUnItemLogInfo.bId = order.bId
        
        if (order.action === 'ADD') {
          this.viewUnItemLogInfo.action = this.$t('viewUnItemLog.add')
        } else if (order.action === 'MOD') {
          this.viewUnItemLogInfo.action = this.$t('viewUnItemLog.modify')
        } else if (order.action === 'DEL') {
          this.viewUnItemLogInfo.action = this.$t('viewUnItemLog.delete')
        } else {
          this.viewUnItemLogInfo.action = '-'
        }
        
        this.viewUnItemLogInfo.actionObj = order.actionObj
        this.visible = true
        this._loadOrderUnitemLog()
      },
      async _loadOrderUnitemLog() {
        try {
          const res = await listUnitemLog({ bId: this.viewUnItemLogInfo.bId })
          Object.assign(this.viewUnItemLogInfo, res.data)
  
          const logText = JSON.parse(res.data.logText)
          this.viewUnItemLogInfo.preValue = JSON.stringify(logText.preValue, null, 2)
          this.viewUnItemLogInfo.afterValue = JSON.stringify(logText.afterValue, null, 2)
        } catch (error) {
          this.$message.error(this.$t('viewUnItemLog.fetchError'))
        }
      },
      clearLog() {
        this.viewUnItemLogInfo = {
          bId: '',
          serviceName: '',
          logText: '',
          preValue: '',
          afterValue: '',
          action: '',
          actionObj: ''
        }
      }
    }
  }
  </script>