index.vue 5.2 KB

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