企微助手 ,仓库名 短剧

platformManage.vue 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <div v-loading="loading" class="platformManage-wrap">
  3. <div class="screenBox flex">
  4. <div></div><!-- 占位 -->
  5. <div class="right">
  6. <el-button type="primary" size="mini" @click="onClickAddPlatform">添加平台</el-button>
  7. </div>
  8. </div>
  9. <el-table :height="height" :data="platformList" tooltip-effect="dark" style="width: 100%;margin-top:10px">
  10. <el-table-column label="平台" prop="name" min-width="160" align="center" />
  11. <el-table-column label="描述" prop="name" min-width="160" align="center" />
  12. <el-table-column label="账号" min-width="300" align="center">
  13. <template slot-scope="{ row }">
  14. <div class="account-wrap">
  15. <span>123123123</span>
  16. <i class="el-icon-delete" />
  17. </div>
  18. <div class="account-add-btn">
  19. <i class="el-icon-plus" />
  20. <span>添加账号</span>
  21. </div>
  22. </template>
  23. </el-table-column>
  24. <el-table-column label="状态" min-width="160" align="center">
  25. <template slot-scope="{ row }">
  26. <span v-if="row.enable == 1" class="c-448AFF">启用</span>
  27. <span v-else class="c-F03F5C">禁用</span>
  28. </template>
  29. </el-table-column>
  30. <el-table-column label="操作" min-width="160" align="center">
  31. <template slot-scope="{ row }">
  32. <el-button type="primary" size="mini" @click="onClickEditPlatform(row)">编辑</el-button>
  33. <el-button v-if="row.enable == 1" type="danger" size="mini" @click="onClickEnable(row, 0)">禁用</el-button>
  34. <el-button v-else type="primary" size="mini" @click="onClickEnable(row, 1)">启用</el-button>
  35. </template>
  36. </el-table-column>
  37. </el-table>
  38. <div class="pagination" v-show="pagination.total > 0">
  39. <el-pagination background :current-page="pagination.page" @current-change="handleCurrentChange" layout="prev, pager, next" :page-count="Number(pagination.pages)">
  40. </el-pagination>
  41. </div>
  42. <!-- S 添加平台 & 编辑平台 -->
  43. <addPlatformDialog
  44. :dialogVisible="addPlatformDialogVisible"
  45. :platformInfo="currentPlatformInfo"
  46. @confirm="handleAddPlatformConfirm"
  47. @cancel="handleAddPlatformCancel"
  48. />
  49. <!-- E 添加平台 & 编辑平台 -->
  50. </div>
  51. </template>
  52. <script>
  53. import addPlatformDialog from './dialog/addPlatformDialog.vue'
  54. export default {
  55. name: 'platformManage',
  56. components: {
  57. addPlatformDialog,
  58. },
  59. data () {
  60. return {
  61. height: '',
  62. loading: false,
  63. pagination: {
  64. page: 1,
  65. page_size: 20,
  66. pages: 0,
  67. total: 0,
  68. },
  69. platformList: [],
  70. addPlatformDialogVisible: false, // 控制"添加平台"弹框显示
  71. currentPlatformInfo: {}, // 当前编辑的平台信息
  72. }
  73. },
  74. created () {
  75. this.height = document.documentElement.clientHeight - 200 > 400 ? document.documentElement.clientHeight - 200 : 400
  76. this.handleGetPlatform()
  77. },
  78. methods: {
  79. // 获取列表数据
  80. async handleGetPlatform() {
  81. try {
  82. this.loading = true
  83. const url = `${this.URL.BASEURL}${this.URL.pitcher_dramaList}`
  84. const params = {
  85. is_select: 0,
  86. page: this.pagination.page,
  87. page_size: this.pagination.page_size,
  88. }
  89. const { data: res = {} } = await this.$axios.get(url, { params })
  90. if (res && res.errno == 0 && Array.isArray(res.rst.data)) {
  91. this.platformList = res.rst.data;
  92. this.pagination.total = res.rst.pageInfo.total;
  93. this.pagination.pages = res.rst.pageInfo.pages;
  94. } else if (res.errno != 4002) {
  95. this.$message.warning(res.err)
  96. this.platformList = [];
  97. this.pagination.total = 0;
  98. this.pagination.pages = 0;
  99. }
  100. } catch (error) {
  101. console.log(error)
  102. this.platformList = [];
  103. this.pagination.total = 0;
  104. this.pagination.pages = 0;
  105. } finally {
  106. this.loading = false
  107. }
  108. },
  109. // 监听当前页数变化
  110. handleCurrentChange(currentPage) {
  111. this.pagination.page = currentPage
  112. this.handleGetPlatform()
  113. },
  114. // S 添加 & 编辑平台
  115. // 监听点击"添加平台"
  116. onClickAddPlatform() {
  117. this.currentPlatformInfo = {}
  118. this.addPlatformDialogVisible = true
  119. },
  120. // 监听点击"编辑平台"
  121. onClickEditPlatform(platformInfo) {
  122. this.currentPlatformInfo = platformInfo
  123. this.addPlatformDialogVisible = true
  124. },
  125. // 添加平台 & 编辑平台 => 确定
  126. handleAddPlatformConfirm() {
  127. this.addPlatformDialogVisible = false
  128. this.pagination.page = 1
  129. this.handleGetPlatform()
  130. },
  131. // 添加平台 & 编辑平台 => 取消
  132. handleAddPlatformCancel() {
  133. this.addPlatformDialogVisible = false
  134. },
  135. // E 添加 & 编辑平台
  136. // S 禁用、启用平台
  137. // 监听点击"禁用"、"启用"按钮
  138. async onClickEnable(currentPlatform, eventCode) {
  139. try {
  140. const h = this.$createElement
  141. await this.$confirm('', {
  142. message:h('div', null, [
  143. h('span', null, `确定${eventCode === 0 ? '禁用' : '启用'}`),
  144. h('span', { style:'color: #32B38A;' }, `${currentPlatform.name}`),
  145. h('span', null, '吗?'),
  146. ]),
  147. confirmButtonText: '确定',
  148. cancelButtonText: '取消',
  149. type: 'warning',
  150. })
  151. this.handleEnable(currentPlatform, eventCode)
  152. } catch (error) {
  153. console.log(error)
  154. }
  155. },
  156. // 执行"禁用"、"启用"
  157. async handleEnable(currentPlatform, eventCode) {
  158. try {
  159. let url = `${this.URL.BASEURL}${this.URL.xxx}`
  160. const params = {
  161. id: currentPlatform.id,
  162. enable: eventCode,
  163. }
  164. console.log('url => ', url)
  165. console.log('params => ', params)
  166. return // mock
  167. this.loading = true
  168. const { data: res = {} } = await this.$axios.post(url, params)
  169. if (res && res.errno == 0) {
  170. this.$message.success('操作成功')
  171. this.handleGetPlatform()
  172. } else if (res.errno != 4002) {
  173. this.$message.warning(res.err || '操作失败')
  174. }
  175. } catch (error) {
  176. console.log('error => ', error)
  177. } finally {
  178. this.loading = false
  179. }
  180. },
  181. // E 禁用、启用平台
  182. }
  183. }
  184. </script>
  185. <style lang="scss" scoped>
  186. .screenBox {
  187. background: #fff;
  188. padding: 5px 20px;
  189. }
  190. .platformManage-wrap {
  191. .account-wrap {
  192. display: flex;
  193. align-items: center;
  194. justify-content: center;
  195. i {
  196. color: #F46C6C;
  197. cursor: pointer;
  198. margin-left: 4px;
  199. }
  200. }
  201. .account-add-btn {
  202. display: flex;
  203. align-items: center;
  204. justify-content: center;
  205. color: #32B38A;
  206. cursor: pointer;
  207. i {
  208. margin-right: 4px;
  209. }
  210. }
  211. }
  212. </style>