index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <div class="">
  3. <toolbar @on-filter="filterData" @on-reset="filterData" />
  4. <div class="m-10 bg-w p-20 br-10">
  5. <el-button type="primary" icon="el-icon-plus" @click="handleAdd"
  6. >新增</el-button
  7. >
  8. <base-table
  9. :columns="columns"
  10. :items="items"
  11. :pagination="pagination"
  12. :page-change="pageChange"
  13. />
  14. </div>
  15. </div>
  16. </template>
  17. <script>
  18. import toolbar from './toolbar';
  19. import mxFilterList from '@/mixins/filterList';
  20. import { getPage, changeShowItem, forceUpgradeItem } from '@/api/app';
  21. export default {
  22. name: 'UpdateList',
  23. components: { toolbar },
  24. mixins: [
  25. mxFilterList({
  26. fetchList: getPage // 在下方data再声明一个 fetchList: iGetList 同等效果
  27. })
  28. ],
  29. data() {
  30. return {
  31. columns: [
  32. {
  33. key: 'productName',
  34. name: '版本名',
  35. minWidth: this.$col.m
  36. },
  37. {
  38. key: 'versionNumber',
  39. name: '版本号',
  40. minWidth: this.$col.b
  41. },
  42. {
  43. key: 'platform',
  44. name: '客户端',
  45. width: this.$col.m
  46. },
  47. {
  48. key: 'downloadUrl',
  49. name: '下载地址',
  50. minWidth: this.$col.m
  51. },
  52. {
  53. key: 'upgradeDesc',
  54. name: '升级描述',
  55. minWidth: this.$col.b
  56. },
  57. {
  58. key: 'isForceUpgrade',
  59. name: '强制更新',
  60. width: this.$col.b,
  61. type: 'switch',
  62. switchName: ['开启', '关闭'],
  63. api: async row => {
  64. const { success } = await forceUpgradeItem(row);
  65. if (success) {
  66. this.$success('修改成功!');
  67. }
  68. this.$g_emit('update_app_reload');
  69. }
  70. },
  71. {
  72. key: 'isShow',
  73. name: '状态',
  74. width: this.$col.b,
  75. type: 'switch',
  76. switchName: ['运行', '停止'],
  77. api: async row => {
  78. const { success } = await changeShowItem(row);
  79. if (success) {
  80. this.$success('修改成功!');
  81. }
  82. this.$g_emit('update_app_reload');
  83. }
  84. }
  85. // {
  86. // key: 'action',
  87. // name: '操作',
  88. // width: '120',
  89. // render: (h, { row }) => {
  90. // const action = [];
  91. // action.push(
  92. // h(
  93. // 'el-button',
  94. // {
  95. // props: {
  96. // type: 'text'
  97. // },
  98. // on: {
  99. // click: () =>
  100. // this.$TrendItemModal({
  101. // id: row.id,
  102. // info: {
  103. // name: row.name,
  104. // sort: row.sort,
  105. // isShow: row.isShow
  106. // }
  107. // })
  108. // }
  109. // },
  110. // '编辑'
  111. // )
  112. // );
  113. // action.push(
  114. // h(
  115. // 'BaseBtn',
  116. // {
  117. // props: {
  118. // popip: true,
  119. // txt: '删除',
  120. // type: 'text'
  121. // },
  122. // class: 'ml-10',
  123. // on: {
  124. // ok: () => this.handleDelItem(row)
  125. // }
  126. // },
  127. // '删除'
  128. // )
  129. // );
  130. // return h('div', action);
  131. // }
  132. // }
  133. ]
  134. };
  135. },
  136. created() {
  137. this.$g_on('update_app_reload', this.reload);
  138. },
  139. beforeDestroy() {
  140. this.$g_off('update_app_reload', this.reload);
  141. },
  142. methods: {
  143. handleAdd() {
  144. this.$updateAppItemModal();
  145. },
  146. async handleDelItem(item) {
  147. const { success, msg } = await delItem({
  148. id: item.id
  149. });
  150. if (success) {
  151. this.$success('删除成功!');
  152. this.$g_emit('trend_reload');
  153. }
  154. }
  155. }
  156. };
  157. </script>
  158. <style type="scss" scoped></style>