index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <div class="m-container">
  3. <h2>
  4. <div class="squrt"></div>
  5. 团练宝流量包
  6. </h2>
  7. <save-form
  8. :inline="true"
  9. class="searchForm"
  10. ref="searchForm"
  11. @submit="search"
  12. @reset="reset"
  13. :saveKey="'platformProductManager'"
  14. :model.sync="searchForm"
  15. >
  16. <el-form-item>
  17. <el-select
  18. v-model.trim="searchForm.minuteUp"
  19. clearable
  20. filterable
  21. placeholder="请选择分钟数"
  22. >
  23. <el-option v-for="min in minuteList" :label="min" :value="min" :key="min"></el-option>
  24. </el-select>
  25. </el-form-item>
  26. <el-form-item>
  27. <el-button native-type="submit" type="danger">搜索</el-button>
  28. <el-button native-type="reset" type="primary">重置</el-button>
  29. </el-form-item>
  30. </save-form>
  31. <el-button style="margin-bottom: 20px;" type="primary" v-permission="'cloudRoomFlowConfig/add'" @click="openCloudPackage('create')" icon="el-icon-plus">新增流量包</el-button>
  32. <!-- 列表 -->
  33. <div class="tableWrap">
  34. <el-table
  35. :data="tableList"
  36. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  37. >
  38. <el-table-column align="center" prop="id" label="流量包编号">
  39. </el-table-column>
  40. <el-table-column align="center" label="分钟数" prop="minuteUpLimit">
  41. </el-table-column>
  42. <el-table-column align="center" label="原价(元)" prop="price">
  43. </el-table-column>
  44. <el-table-column align="center" label="描述" prop="remark">
  45. <template slot-scope="scope">
  46. <tooltip :content="scope.row.remark" />
  47. </template>
  48. </el-table-column>
  49. <el-table-column align="center" label="操作">
  50. <template slot-scope="scope">
  51. <el-button
  52. @click="resetCloudPackage(scope.row)"
  53. v-permission="'cloudRoomFlowConfig/update'"
  54. type="text"
  55. >修改</el-button
  56. >
  57. <el-button
  58. @click="delCloudPackage(scope.row)"
  59. v-permission="'cloudRoomFlowConfig/delete'"
  60. type="text"
  61. >删除</el-button
  62. >
  63. </template>
  64. </el-table-column>
  65. </el-table>
  66. <pagination
  67. :saveKey="'platformProductManager'"
  68. sync
  69. :total.sync="pageInfo.total"
  70. :page.sync="pageInfo.page"
  71. :limit.sync="pageInfo.limit"
  72. :page-sizes="pageInfo.page_size"
  73. @pagination="getList"
  74. />
  75. </div>
  76. <el-dialog
  77. :title="isAdd ? '新增流量包' : '修改流量包'"
  78. class="courseMask"
  79. width="500px"
  80. :visible.sync="courseVisible"
  81. >
  82. <cloudModel
  83. ref="cloudModel"
  84. :activeRow="activeRow"
  85. :pageType="pageType"
  86. v-if="courseVisible"
  87. @close="close"
  88. />
  89. <div slot="footer" class="dialog-footer">
  90. <el-button @click="courseVisible = false">取 消</el-button>
  91. <el-button type="primary" @click="submitInfo">确 定</el-button>
  92. </div>
  93. </el-dialog>
  94. </div>
  95. </template>
  96. <script>
  97. import pagination from "@/components/Pagination/index";
  98. import { queryPage, getMinuteUp, cloudDelete } from "./api";
  99. import cloudModel from './cloudModel'
  100. const initSearch = {
  101. minuteUp: null
  102. };
  103. export default {
  104. components: { pagination, cloudModel },
  105. data() {
  106. return {
  107. tableList: [],
  108. pageInfo: {
  109. // 分页规则
  110. limit: 10, // 限制显示条数
  111. page: 1, // 当前页
  112. total: 0, // 总条数
  113. page_size: [10, 20, 40, 50], // 选择限制显示条数
  114. },
  115. searchForm: { ...initSearch },
  116. isAdd: true,
  117. courseVisible: false,
  118. activeRow: null,
  119. minuteList: [],
  120. };
  121. },
  122. mounted() {
  123. this.__init()
  124. this.getList();
  125. },
  126. methods: {
  127. async __init() {
  128. try {
  129. const res = await getMinuteUp()
  130. this.minuteList = res.data || []
  131. } catch(e) {}
  132. },
  133. async getList() {
  134. try {
  135. const res = await queryPage({
  136. ...this.searchForm,
  137. page: this.pageInfo.page,
  138. rows: this.pageInfo.limit,
  139. });
  140. this.pageInfo.total = res.data.total;
  141. this.tableList = res.data.rows;
  142. } catch (e) {}
  143. },
  144. search() {
  145. this.pageInfo.page = 1;
  146. this.$refs.searchForm.save(this.searchForm);
  147. this.$refs.searchForm.save(this.pageInfo, "page");
  148. this.getList();
  149. },
  150. reset() {
  151. this.searchForm = { ...initSearch };
  152. this.search();
  153. },
  154. resetCloudPackage(row) {
  155. this.isAdd = false;
  156. this.activeRow = row;
  157. this.pageType = 'update'
  158. this.courseVisible = true;
  159. },
  160. submitInfo() {
  161. const str = this.isAdd ? "create" : "update";
  162. this.$refs.cloudModel.submitInfo(str);
  163. },
  164. close() {
  165. this.courseVisible = false;
  166. this.getList();
  167. },
  168. openCloudPackage() {
  169. this.isAdd = true;
  170. this.activeRow = null;
  171. this.pageType = 'create'
  172. this.courseVisible = true;
  173. },
  174. async delCloudPackage(row) {
  175. this.$confirm("是否删除?", "提示", {
  176. confirmButtonText: "确定",
  177. cancelButtonText: "取消",
  178. type: "warning",
  179. }).then( async() => {
  180. try{
  181. const res = await cloudDelete({ id:row.id})
  182. this.$message.success('删除成功')
  183. this.getList()
  184. }catch{}
  185. });
  186. },
  187. },
  188. };
  189. </script>
  190. <style lang="scss" scoped>
  191. .courseMask .el-dialog__body {
  192. padding-bottom: 0;
  193. }
  194. </style>