liveShopControl.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <div class="m-container">
  3. <h2>
  4. <el-page-header
  5. @back="onCancel"
  6. :content="detail.roomTitle || ''"
  7. ></el-page-header>
  8. </h2>
  9. <div class="m-core">
  10. <el-alert title="直播课信息" :closable="false" type="info"> </el-alert>
  11. <descriptions :column="4">
  12. <descriptions-item label="直播课标题:">{{
  13. detail.roomTitle || ""
  14. }}</descriptions-item>
  15. <descriptions-item label="主讲人:">{{
  16. detail.speakerName || ""
  17. }}</descriptions-item>
  18. <descriptions-item label="直播开始时间:">{{
  19. detail.liveStartTime | dateForMinFormat
  20. }}</descriptions-item>
  21. <descriptions-item label="状态:">{{
  22. detail.liveState | liveState
  23. }}</descriptions-item>
  24. </descriptions>
  25. <el-alert
  26. title="直播商品"
  27. :closable="false"
  28. type="info"
  29. style="margin: 20px 0"
  30. >
  31. </el-alert>
  32. <save-form
  33. :inline="true"
  34. :model="searchForm"
  35. @submit="search"
  36. @reset="onReSet"
  37. ref="searchForm"
  38. >
  39. <el-form-item>
  40. <el-input
  41. v-model.trim="searchForm.search"
  42. clearable
  43. @keyup.enter.native="
  44. e => {
  45. e.target.blur();
  46. $refs.searchForm.save();
  47. search();
  48. }
  49. "
  50. placeholder="商品编号/名称"
  51. ></el-input>
  52. </el-form-item>
  53. <el-form-item prop="status">
  54. <el-select
  55. v-model.trim="searchForm.status"
  56. clearable
  57. filterable
  58. placeholder="状态"
  59. >
  60. <el-option label="上架" :value="1"></el-option>
  61. <el-option label="下架" :value="0"></el-option>
  62. </el-select>
  63. </el-form-item>
  64. <el-form-item>
  65. <el-button native-type="submit" type="primary">搜索</el-button>
  66. <el-button native-type="reset" type="danger">重置</el-button>
  67. </el-form-item>
  68. </save-form>
  69. <auth auths="liveGoodsMapper/add">
  70. <el-button
  71. @click="addShop"
  72. type="primary"
  73. style="margin-bottom: 20px"
  74. :disabled="detail.liveState == 2"
  75. >添加</el-button
  76. >
  77. </auth>
  78. <div class="tableWrap">
  79. <el-table
  80. style="width: 100%"
  81. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  82. :data="tableList"
  83. >
  84. <el-table-column
  85. align="center"
  86. prop="id"
  87. label="商品编号"
  88. ></el-table-column>
  89. <el-table-column
  90. align="center"
  91. prop="name"
  92. label="商品名称"
  93. ></el-table-column>
  94. <el-table-column align="center" prop="originalPrice" label="原价">
  95. <template slot-scope="scope">
  96. <div>
  97. {{ scope.row.originalPrice | moneyFormat(true) }}
  98. </div>
  99. </template>
  100. </el-table-column>
  101. <el-table-column align="center" prop="currentPrice" label="直播价">
  102. <template slot-scope="scope">
  103. <div>
  104. {{ scope.row.currentPrice | moneyFormat(true) }}
  105. </div>
  106. </template>
  107. </el-table-column>
  108. <el-table-column
  109. align="center"
  110. prop="stockCount"
  111. label="库存"
  112. ></el-table-column>
  113. <el-table-column align="center" prop="status" label="状态">
  114. <template slot-scope="scope">
  115. <div>
  116. {{ scope.row.status ? "上架" : "下架" }}
  117. </div>
  118. </template>
  119. </el-table-column>
  120. <el-table-column align="center" prop="studentId" label="操作">
  121. <template slot-scope="scope">
  122. <div>
  123. <auth auths="liveGoodsMapper/updateStatus">
  124. <el-button type="text" @click="resetShop(scope.row)">
  125. {{ !scope.row.status ? "上架" : "下架" }}</el-button
  126. >
  127. </auth>
  128. <!-- <auth auths="liveGoods/delete">
  129. <el-button type="text" @click="deteleShop(scope.row)"
  130. >删除</el-button
  131. >
  132. </auth> -->
  133. </div>
  134. </template>
  135. </el-table-column>
  136. </el-table>
  137. <pagination
  138. sync
  139. :total.sync="rules.total"
  140. :page.sync="rules.page"
  141. :limit.sync="rules.limit"
  142. :page-sizes="rules.page_size"
  143. @pagination="getList"
  144. />
  145. </div>
  146. </div>
  147. <addLiveShop ref="addLiveShop" @getList="getList" />
  148. </div>
  149. </template>
  150. <script>
  151. import { getToken, getTenantId } from "@/utils/auth";
  152. import {
  153. getRoomInfo,
  154. getLiveGoodsMapper,
  155. updateLiveGoodsMapperStatus
  156. } from "./api";
  157. import pagination from "@/components/Pagination/index";
  158. import addLiveShop from "./modals/addLiveShop";
  159. export default {
  160. components: { pagination, addLiveShop },
  161. data() {
  162. return {
  163. detail: {
  164. roomTitle: "",
  165. speakerName: "",
  166. liveStartTime: "",
  167. liveState: ""
  168. },
  169. searchForm: {
  170. search: "",
  171. status: ""
  172. },
  173. tableList: [],
  174. organList: [],
  175. rules: {
  176. // 分页规则
  177. limit: 10, // 限制显示条数
  178. page: 1, // 当前页
  179. total: 0, // 总条数
  180. page_size: [10, 20, 40, 50] // 选择限制显示条数
  181. }
  182. };
  183. },
  184. mounted() {
  185. this.getDetail();
  186. this.getList();
  187. },
  188. methods: {
  189. async getList() {
  190. let params = {
  191. ...this.searchForm,
  192. page: this.rules.page,
  193. rows: this.rules.limit,
  194. liveId: this.$route.query.roomUid
  195. };
  196. try {
  197. const res = await getLiveGoodsMapper({ ...params });
  198. this.tableList = res.data.rows;
  199. this.rules.total = res.data.total;
  200. } catch (e) {
  201. console.log(e);
  202. }
  203. },
  204. search() {
  205. this.rules.page = 1;
  206. this.getList();
  207. },
  208. onReSet() {
  209. this.searchForm.search = "";
  210. this.searchForm.status = "";
  211. this.search();
  212. },
  213. onCancel() {
  214. this.$store.dispatch("delVisitedViews", this.$route);
  215. this.$router.push("/liveClassManager");
  216. },
  217. async getDetail() {
  218. try {
  219. let obj = {
  220. roomUid: this.$route.query.roomUid
  221. };
  222. const res = await getRoomInfo(obj);
  223. this.detail = { ...res.data };
  224. } catch (e) {
  225. console.log(e);
  226. }
  227. },
  228. addShop() {
  229. this.$refs.addLiveShop.openDioag({ roomUid: this.$route.query.roomUid });
  230. },
  231. resetShop(row) {
  232. let str = "";
  233. if (row.status) {
  234. str = "下架";
  235. } else {
  236. str = "上架";
  237. }
  238. this.$confirm(`您是否${str}商品"${row.name}"`, "提示", {
  239. confirmButtonText: "确定",
  240. cancelButtonText: "取消",
  241. type: "warning"
  242. })
  243. .then(async () => {
  244. await updateLiveGoodsMapperStatus({
  245. liveGoodsId: row.id,
  246. liveId: this.$route.query.roomUid,
  247. status: row.status ? 0 : 1
  248. }).then(res => {
  249. this.$message.success(`${str}成功`);
  250. this.getList();
  251. });
  252. })
  253. .catch(() => {});
  254. }
  255. }
  256. };
  257. </script>
  258. <style lang="scss" scoped>
  259. ::v-deep .description-tr {
  260. border-bottom: none !important;
  261. }
  262. </style>