ExternalProjectLogDialog.vue 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <base-dialog @cancel="cancelDialog" :width="1000">
  3. <div slot="header">{{$t('bill.record_detail')}}</div>
  4. <div slot="body">
  5. <dialog-table :data="recordList" :columns="columns" :showOverflow="true" />
  6. </div>
  7. <div slot="footer">
  8. <a-button type="primary" @click="cancelDialog">{{ $t('dialog.ok') }}</a-button>
  9. </div>
  10. </base-dialog>
  11. </template>
  12. <script>
  13. import * as R from 'ramda'
  14. import DialogMixin from '@/mixins/dialog'
  15. import WindowsMixin from '@/mixins/windows'
  16. export default {
  17. name: 'ExternalProjectLogDialog',
  18. mixins: [DialogMixin, WindowsMixin],
  19. data () {
  20. return {
  21. loading: false,
  22. recordList: [],
  23. columns: [
  24. {
  25. field: 'ops_time',
  26. title: this.$t('bill.action_time'),
  27. formatter: ({ row }) => {
  28. return this.$moment(row.ops_time).format()
  29. },
  30. },
  31. {
  32. field: 'action',
  33. title: this.$t('bill.action'),
  34. formatter: ({ row }) => {
  35. const { action } = row._i18n || {}
  36. return action
  37. },
  38. },
  39. {
  40. field: 'change_text',
  41. title: this.$t('bill.change_text'),
  42. width: 200,
  43. slots: {
  44. default: ({ row }) => {
  45. let { notes = {} } = row
  46. if (R.is(String, notes)) {
  47. notes = JSON.parse(notes)
  48. }
  49. const ret = []
  50. if (notes.old_domain && notes.old_project) {
  51. ret.push(<div>{this.$t('cloudenv.old_sth', [this.$t('dictionary.domain')])}: {notes.old_domain}</div>)
  52. ret.push(<div>{this.$t('cloudenv.old_sth', [this.$t('dictionary.project')])}: {notes.old_project}</div>)
  53. }
  54. if (notes.new_domain && notes.new_project) {
  55. ret.push(<div>{this.$t('cloudenv.new_sth', [this.$t('dictionary.domain')])}: {notes.new_domain}</div>)
  56. ret.push(<div>{this.$t('cloudenv.new_sth', [this.$t('dictionary.project')])}: {notes.new_project}</div>)
  57. }
  58. return ret
  59. },
  60. },
  61. },
  62. {
  63. field: 'user',
  64. title: this.$t('table.title.sponsor'),
  65. },
  66. ],
  67. }
  68. },
  69. created () {
  70. this.$l = new this.$Manager('actions', 'v1')
  71. this.fetchRecords()
  72. },
  73. methods: {
  74. async fetchRecords () {
  75. const { id } = this.params.data[0]
  76. try {
  77. const { data = {} } = await this.$l.list({
  78. params: {
  79. filter: [`obj_id.in('${id}')`],
  80. limit: 10,
  81. scope: this.$store.getters.scope,
  82. },
  83. })
  84. this.recordList = data.data.filter(item => {
  85. return item.notes
  86. })
  87. } catch (err) {
  88. }
  89. },
  90. },
  91. }
  92. </script>