index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. width: this.$col.m
  36. },
  37. {
  38. key: 'platform',
  39. name: '平台',
  40. width: this.$col.m
  41. },
  42. {
  43. key: 'versionCode',
  44. name: '版本编码',
  45. minWidth: this.$col.b
  46. },
  47. {
  48. key: 'versionNumber',
  49. name: '版本号',
  50. minWidth: this.$col.b
  51. },
  52. {
  53. key: 'downloadUrl',
  54. name: '下载地址',
  55. minWidth: this.$col.b
  56. },
  57. {
  58. key: 'upgradeDesc',
  59. name: '升级描述',
  60. minWidth: this.$col.b
  61. },
  62. {
  63. key: 'isForceUpgrade',
  64. name: '强制更新',
  65. width: this.$col.b,
  66. type: 'switch',
  67. switchName: ['开启', '关闭'],
  68. api: async row => {
  69. const { success } = await forceUpgradeItem(row);
  70. if (success) {
  71. this.$success('修改成功!');
  72. }
  73. this.$g_emit('update_app_reload');
  74. }
  75. },
  76. {
  77. key: 'createAt',
  78. name: '创建时间',
  79. width: this.$col.b
  80. },
  81. {
  82. key: 'isShow',
  83. name: '显示/隐藏',
  84. width: this.$col.b,
  85. type: 'switch',
  86. switchName: ['显示', '隐藏'],
  87. api: async row => {
  88. const { success } = await changeShowItem(row);
  89. if (success) {
  90. this.$success('修改成功!');
  91. }
  92. this.$g_emit('update_app_reload');
  93. }
  94. }
  95. // {
  96. // key: 'action',
  97. // name: '操作',
  98. // width: '120',
  99. // render: (h, { row }) => {
  100. // const action = [];
  101. // action.push(
  102. // h(
  103. // 'el-button',
  104. // {
  105. // props: {
  106. // type: 'text'
  107. // },
  108. // on: {
  109. // click: () =>
  110. // this.$TrendItemModal({
  111. // id: row.id,
  112. // info: {
  113. // name: row.name,
  114. // sort: row.sort,
  115. // isShow: row.isShow
  116. // }
  117. // })
  118. // }
  119. // },
  120. // '编辑'
  121. // )
  122. // );
  123. // action.push(
  124. // h(
  125. // 'BaseBtn',
  126. // {
  127. // props: {
  128. // popip: true,
  129. // txt: '删除',
  130. // type: 'text'
  131. // },
  132. // class: 'ml-10',
  133. // on: {
  134. // ok: () => this.handleDelItem(row)
  135. // }
  136. // },
  137. // '删除'
  138. // )
  139. // );
  140. // return h('div', action);
  141. // }
  142. // }
  143. ]
  144. };
  145. },
  146. created() {
  147. this.$g_on('update_app_reload', this.reload);
  148. },
  149. beforeDestroy() {
  150. this.$g_off('update_app_reload', this.reload);
  151. },
  152. methods: {
  153. handleAdd() {
  154. this.$updateAppItemModal();
  155. },
  156. async handleDelItem(item) {
  157. const { success, msg } = await delItem({
  158. id: item.id
  159. });
  160. if (success) {
  161. this.$success('删除成功!');
  162. this.$g_emit('trend_reload');
  163. }
  164. }
  165. }
  166. };
  167. </script>
  168. <style type="scss" scoped></style>