index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <!-- -->
  2. <template>
  3. <div class="m-container">
  4. <h2>
  5. <div class="squrt"></div>
  6. 直播商品管理
  7. </h2>
  8. <div class="m-core">
  9. <auth auths="liveGoods/add">
  10. <el-button
  11. type="primary"
  12. style="margin-bottom: 30px; margian-right: 10px"
  13. @click="addLiveShop"
  14. >新建商品</el-button
  15. >
  16. </auth>
  17. <save-form
  18. :inline="true"
  19. :model="searchForm"
  20. @submit="search"
  21. @reset="onReSet"
  22. >
  23. <el-form-item>
  24. <el-input
  25. v-model.trim="searchForm.search"
  26. clearable
  27. @keyup.enter.native="search"
  28. placeholder="商品编号/名称"
  29. ></el-input>
  30. </el-form-item>
  31. <el-form-item>
  32. <el-button native-type="submit" type="primary">搜索</el-button>
  33. <el-button native-type="reset" type="danger">重置</el-button>
  34. </el-form-item>
  35. </save-form>
  36. <div class="tableWrap">
  37. <el-table
  38. style="width: 100%"
  39. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  40. :data="tableList"
  41. >
  42. <el-table-column
  43. align="center"
  44. prop="id"
  45. label="商品编号"
  46. ></el-table-column>
  47. <el-table-column
  48. align="center"
  49. prop="name"
  50. label="商品名称"
  51. ></el-table-column>
  52. <el-table-column align="center" prop="originalPrice" label="原价">
  53. <template slot-scope="scope">
  54. <div>
  55. {{ scope.row.originalPrice | moneyFormat(true) }}
  56. </div>
  57. </template>
  58. </el-table-column>
  59. <el-table-column align="center" prop="currentPrice" label="直播价">
  60. <template slot-scope="scope">
  61. <div>
  62. {{ scope.row.currentPrice | moneyFormat(true) }}
  63. </div>
  64. </template>
  65. </el-table-column>
  66. <el-table-column
  67. align="center"
  68. prop="stockCount"
  69. label="库存"
  70. ></el-table-column>
  71. <el-table-column align="center" prop="studentId" label="操作">
  72. <template slot-scope="scope">
  73. <div>
  74. <auth
  75. auths="liveGoods/update"
  76. >
  77. <el-button type="text" @click="resetShop(scope.row)"
  78. >修改</el-button
  79. >
  80. </auth>
  81. <auth
  82. auths="liveGoods/delete"
  83. >
  84. <el-button type="text" @click="deteleShop(scope.row)"
  85. >删除</el-button
  86. >
  87. </auth>
  88. </div>
  89. </template>
  90. </el-table-column>
  91. </el-table>
  92. <pagination
  93. sync
  94. :total.sync="rules.total"
  95. :page.sync="rules.page"
  96. :limit.sync="rules.limit"
  97. :page-sizes="rules.page_size"
  98. @pagination="getList"
  99. />
  100. </div>
  101. </div>
  102. <eidtLiveShop ref="eidtLiveShop" @getList="getList" />
  103. </div>
  104. </template>
  105. <script>
  106. import axios from "axios";
  107. import { getToken } from "@/utils/auth";
  108. import pagination from "@/components/Pagination/index";
  109. import load from "@/utils/loading";
  110. import { getTimes } from "@/utils";
  111. import { getLiveGoodsMapperList,delLiveGoods } from "./api";
  112. import eidtLiveShop from "./models/eidtLiveShop";
  113. export default {
  114. components: { pagination, eidtLiveShop },
  115. data() {
  116. return {
  117. searchForm: {
  118. search: null,
  119. },
  120. tableList: [],
  121. organList: [],
  122. rules: {
  123. // 分页规则
  124. limit: 10, // 限制显示条数
  125. page: 1, // 当前页
  126. total: 0, // 总条数
  127. page_size: [10, 20, 40, 50], // 选择限制显示条数
  128. },
  129. };
  130. },
  131. //生命周期 - 创建完成(可以访问当前this实例)
  132. created() {},
  133. //生命周期 - 挂载完成(可以访问DOM元素)
  134. mounted() {
  135. // 获取分部
  136. this.init();
  137. },
  138. methods: {
  139. init() {
  140. this.getList();
  141. },
  142. async getList() {
  143. let params = {
  144. ...this.searchForm,
  145. page: this.rules.page,
  146. rows: this.rules.limit,
  147. };
  148. try {
  149. const res = await getLiveGoodsMapperList({ ...params });
  150. this.tableList = res.data.rows;
  151. this.rules.total = res.data.total;
  152. } catch (e) {
  153. console.log(e);
  154. }
  155. },
  156. search() {
  157. this.rules.page = 1;
  158. this.getList();
  159. },
  160. onReSet() {
  161. this.searchForm.search = "";
  162. this.search();
  163. },
  164. resetShop(row) {
  165. this.$refs.eidtLiveShop.openDioag(row);
  166. },
  167. addLiveShop() {
  168. this.$refs.eidtLiveShop.openDioag();
  169. },
  170. deteleShop(row) {
  171. this.$confirm(`确定删除"${row.name}"?`, "提示", {
  172. confirmButtonText: "确定",
  173. cancelButtonText: "取消",
  174. type: "warning",
  175. })
  176. .then(() => {
  177. delLiveGoods({ goodsId: row.id }).then((res) => {
  178. if (res.code === 200) {
  179. this.$message.success("删除成功");
  180. this.getList();
  181. // this.routeOrderStatus = false;
  182. }
  183. });
  184. })
  185. .catch();
  186. },
  187. },
  188. };
  189. </script>
  190. <style lang='scss' scoped>
  191. </style>