index.vue 5.6 KB

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