index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <div class="m-container">
  3. <h2>
  4. <div class="squrt"></div>
  5. 服务管理
  6. </h2>
  7. <div class="m-core">
  8. <save-form
  9. :inline="true"
  10. class="searchForm"
  11. ref="searchForm"
  12. @submit="search"
  13. @reset="reset"
  14. :saveKey="'serviceManager'"
  15. :model.sync="searchForm"
  16. >
  17. <el-form-item :rules="[]">
  18. <el-input v-model="searchForm.search" placeholder="服务名称"></el-input>
  19. </el-form-item>
  20. <el-form-item>
  21. <el-button native-type="submit" type="danger">搜索</el-button>
  22. <el-button native-type="reset" type="primary">重置</el-button>
  23. </el-form-item>
  24. </save-form>
  25. <el-button style="margin-bottom: 20px;" type="primary" v-permission="'platformServe/add'" @click="openService('create')" icon="el-icon-plus">新增服务</el-button>
  26. <!-- 列表 -->
  27. <div class="tableWrap">
  28. <el-table
  29. :data="tableList"
  30. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  31. >
  32. <el-table-column align="center" prop="id" label="服务编号">
  33. </el-table-column>
  34. <el-table-column align="center" label="服务名称" prop="serveName">
  35. </el-table-column>
  36. <el-table-column align="center" label="产品服务" prop="productName">
  37. </el-table-column>
  38. <el-table-column align="center" label="操作">
  39. <template slot-scope="scope">
  40. <el-button
  41. @click="openService('update', scope.row)"
  42. v-permission="'platformServe/update'"
  43. type="text"
  44. >修改</el-button
  45. >
  46. <el-button
  47. @click="delService(scope.row)"
  48. v-permission="'platformServe/delete'"
  49. type="text"
  50. >删除</el-button
  51. >
  52. </template>
  53. </el-table-column>
  54. </el-table>
  55. <pagination
  56. :saveKey="'serviceManager'"
  57. sync
  58. :total.sync="pageInfo.total"
  59. :page.sync="pageInfo.page"
  60. :limit.sync="pageInfo.limit"
  61. :page-sizes="pageInfo.page_size"
  62. @pagination="getList"
  63. />
  64. </div>
  65. </div>
  66. </div>
  67. </template>
  68. <script>
  69. import pagination from "@/components/Pagination/index";
  70. import { platformServeQueryPage,platformServeDelete } from "./api";
  71. const initSearch = {
  72. search: null
  73. };
  74. export default {
  75. components: { pagination },
  76. data() {
  77. return {
  78. tableList: [],
  79. pageInfo: {
  80. // 分页规则
  81. limit: 10, // 限制显示条数
  82. page: 1, // 当前页
  83. total: 0, // 总条数
  84. page_size: [10, 20, 40, 50], // 选择限制显示条数
  85. },
  86. searchForm: { ...initSearch },
  87. };
  88. },
  89. mounted() {
  90. this.getList();
  91. },
  92. methods: {
  93. async getList() {
  94. try {
  95. const res = await platformServeQueryPage({
  96. ...this.searchForm,
  97. page: this.pageInfo.page,
  98. rows: this.pageInfo.limit,
  99. });
  100. this.pageInfo.total = res.data.total;
  101. this.tableList = res.data.rows;
  102. } catch (e) {}
  103. },
  104. search() {
  105. this.pageInfo.page = 1;
  106. this.$refs.searchForm.save(this.searchForm);
  107. this.$refs.searchForm.save(this.pageInfo, "page");
  108. this.getList();
  109. },
  110. reset() {
  111. this.searchForm = { ...initSearch };
  112. this.search();
  113. },
  114. openService(type, row) {
  115. const tagTitle = type == 'update' ? '修改' : '创建'
  116. this.$router.push({
  117. path: '/platformManager/serviceOperation',
  118. query: {
  119. type: type,
  120. id: row?.id || null
  121. }
  122. }, (route) => {
  123. route.meta.title = tagTitle + '服务'
  124. })
  125. },
  126. async delService(row) {
  127. this.$confirm("是否删除?", "提示", {
  128. confirmButtonText: "确定",
  129. cancelButtonText: "取消",
  130. type: "warning",
  131. }).then( async() => {
  132. try{
  133. await platformServeDelete({ id:row.id})
  134. this.$message.success('删除成功')
  135. this.getList()
  136. }catch{}
  137. });
  138. },
  139. },
  140. };
  141. </script>
  142. <style lang="scss" scoped>
  143. .courseMask .el-dialog__body {
  144. padding-bottom: 0;
  145. }
  146. </style>