SyncResourceInfo.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{$t('cloudenv.text_463')}}</div>
  4. <div slot="body">
  5. <dialog-table :data="dataList" :columns="columns" />
  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: 'cloudproviderregionsSyncResourceInfoDialog',
  18. mixins: [DialogMixin, WindowsMixin],
  19. data () {
  20. const data = this.params.data[0]
  21. const dataList = this.getDataList(data)
  22. return {
  23. dataList,
  24. columns: [
  25. {
  26. title: this.$t('cloudenv.text_321'),
  27. field: 'resource',
  28. slots: {
  29. default: ({ row }) => {
  30. if (this.$te(`dictionary.${row.resource}`)) {
  31. return this.$t(`dictionary.${row.resource}`)
  32. }
  33. if (this.$te(`dictionary.${row.resource.substr(0, row.resource.length - 1)}`)) {
  34. return this.$t(`dictionary.${row.resource.substr(0, row.resource.length - 1)}`)
  35. }
  36. return row.resource
  37. },
  38. },
  39. },
  40. {
  41. title: this.$t('cloudenv.resource_add_cnt'),
  42. field: 'add_cnt',
  43. slots: {
  44. default: ({ row }) => {
  45. return row.add_cnt || '-'
  46. },
  47. },
  48. },
  49. {
  50. title: this.$t('cloudenv.resource_del_cnt'),
  51. field: 'del_cnt',
  52. slots: {
  53. default: ({ row }) => {
  54. return row.del_cnt || '-'
  55. },
  56. },
  57. },
  58. ],
  59. }
  60. },
  61. methods: {
  62. getDataList (data) {
  63. const { sync_results = {} } = data
  64. const ret = []
  65. for (const key in sync_results) {
  66. if (R.is(Object, sync_results[key])) {
  67. const { add_cnt = 0, del_cnt = 0 } = sync_results[key]
  68. if (add_cnt || del_cnt) {
  69. ret.push({ resource: key, add_cnt, del_cnt })
  70. }
  71. }
  72. }
  73. return ret
  74. },
  75. },
  76. }
  77. </script>