discountCodeList.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. <template>
  2. <div class="discountCodeList" v-if="isData">
  3. <Header />
  4. <Nav :title="$t('Key560')" />
  5. <div class="contentInner">
  6. <div class="search-form">
  7. <el-form :inline="true" ref="form" style="margin-left: 10px">
  8. <el-form-item>
  9. <!-- 优惠码 -->
  10. <el-form-item class="label-input" :label="$t('Key793')" style="margin-right: 30px">
  11. <!-- 输入生成激活码数量" -->
  12. <el-input
  13. :placeholder="$t('Key794')"
  14. v-model="discountNumber"
  15. type="number"
  16. :oninput="numberInput"
  17. ></el-input>
  18. </el-form-item>
  19. <el-button @click="onSubmit" size="medium" type="primary" :loading="loading">
  20. <!-- 生成 -->{{ $t('Key562') }}
  21. </el-button>
  22. </el-form-item>
  23. </el-form>
  24. <el-form :inline="true">
  25. <el-form-item class="label-input" :label="$t('Key563') + ':'" style="margin-right: 30px">
  26. <el-radio v-model="exportRadio" :label="-1"> <!-- 全部 -->{{ $t('Key110') }} </el-radio>
  27. <el-radio v-model="exportRadio" :label="1"> <!-- 已使用 -->{{ this.$t('Key564') }} </el-radio>
  28. <el-radio v-model="exportRadio" :label="0"> <!-- 未使用 -->{{ this.$t('Key565') }} </el-radio>
  29. </el-form-item>
  30. <el-button @click="onExport" size="medium" type="primary" :loading="exportLoading"
  31. >{{ this.$t('Key566') }} excel</el-button
  32. >
  33. </el-form>
  34. </div>
  35. <div class="table-box">
  36. <el-table :data="tableData" style="width: 100%" v-loading="tableloading">
  37. <!-- 优惠码 -->
  38. <el-table-column
  39. class="table-firstC"
  40. :label="$t('Key793')"
  41. prop="discount_code"
  42. width="150"
  43. ></el-table-column>
  44. <!-- 状态 -->
  45. <el-table-column :label="$t('Key164')" prop="is_used" width="150" :formatter="handleStatus"></el-table-column>
  46. <!-- 使用者 -->
  47. <el-table-column :label="$t('Key569')" prop="consumer_name" width="150"></el-table-column>
  48. <!-- 使用时间 -->
  49. <el-table-column :label="$t('Key568')" prop="use_time" width="200"></el-table-column>
  50. <!-- 使用者所属机构 -->
  51. <el-table-column :label="$t('Key567')" prop="consumer_org_name" width="250"></el-table-column>
  52. <!-- 创建时间 -->
  53. <el-table-column :label="$t('Key163')" prop="create_time" width="200"></el-table-column>
  54. <!-- 操作 -->
  55. <el-table-column fixed="right" :label="$t('Key166')" prop width="100">
  56. <template slot-scope="scope">
  57. <!-- 删除 -->
  58. <el-button @click="handleDel(scope.row)" type="text">{{ $t('Key172') }}</el-button>
  59. </template>
  60. </el-table-column>
  61. </el-table>
  62. </div>
  63. <el-pagination
  64. :current-page="currentPage"
  65. :page-size="10"
  66. :page-sizes="[1, 10, 20, 30, 40, 50]"
  67. :total="courseTotal"
  68. @current-change="handleCurrentChange"
  69. @size-change="handleSizeChange"
  70. layout="total, sizes, prev, pager, next, jumper"
  71. ></el-pagination>
  72. </div>
  73. </div>
  74. </template>
  75. <script>
  76. import Header from '@/components/Header';
  77. import Nav from '@/components/teacher-devEntering/Nav';
  78. import { BookgetContent, LearnWebSI } from '@/api/api';
  79. import { getToken } from '@/utils/auth';
  80. import { encodeURL } from 'js-base64';
  81. import { updateWordPack } from '@/utils/i18n';
  82. export default {
  83. name: 'courselist',
  84. components: {
  85. Header,
  86. Nav,
  87. },
  88. data() {
  89. return {
  90. bookId: '',
  91. discountNumber: null, // 生成数量
  92. loading: false,
  93. tableData: [], // 数据内容
  94. currentPage: 1, // 当前页码
  95. page_capacity: 10, // 每页条数
  96. courseTotal: 0, // 数据总条数
  97. tableloading: true,
  98. usedStatus: null,
  99. exportRadio: -1,
  100. exportLoading: false,
  101. goods_type: null,
  102. isData: false,
  103. };
  104. },
  105. async created() {
  106. await updateWordPack({
  107. word_key_list: [
  108. 'Key5',
  109. 'Key8',
  110. 'Key9',
  111. 'Key39',
  112. 'Key83',
  113. 'Key94',
  114. 'Key110',
  115. 'Key164',
  116. 'Key163',
  117. 'Key166',
  118. 'Key172',
  119. 'Key232',
  120. 'Key361',
  121. 'Key532',
  122. 'Key560',
  123. 'Key561',
  124. 'Key562',
  125. 'Key563',
  126. 'Key564',
  127. 'Key565',
  128. 'Key566',
  129. 'Key567',
  130. 'Key568',
  131. 'Key569',
  132. 'Key687',
  133. 'Key689',
  134. 'Key793',
  135. 'Key794',
  136. ],
  137. });
  138. const _this = this;
  139. _this.usedStatus = {
  140. true: this.$t('Key564'), //"已使用",
  141. false: this.$t('Key565'), //"未使用",
  142. };
  143. _this.isData = true;
  144. _this.bookId = this.$route.query.bookId;
  145. _this.goods_type = this.$route.query.goods_type;
  146. this.getList();
  147. },
  148. methods: {
  149. numberInput() {
  150. this.discountNumber = this.discountNumber.replace(/[^0-9]/g, '');
  151. },
  152. // 切换每页条数
  153. handleSizeChange(val) {
  154. this.currentPage = 1;
  155. this.page_capacity = val;
  156. this.getList();
  157. },
  158. // 切换页码
  159. handleCurrentChange(val) {
  160. this.currentPage = val;
  161. this.getList();
  162. },
  163. // 生成数量
  164. onSubmit() {
  165. if (this.discountNumber) {
  166. this.loading = true;
  167. let MethodName = 'order-discount_manager-BatchCreateDiscountCodeFoGoods';
  168. let data = {
  169. goods_id: this.bookId,
  170. goods_type: this.goods_type * 1,
  171. count: Number(this.discountNumber),
  172. };
  173. LearnWebSI(MethodName, data)
  174. .then((res) => {
  175. this.$message.success(this.$t('Key687')); //操作成功
  176. this.discountNumber = null;
  177. this.loading = false;
  178. this.pageIndex = 1;
  179. this.getList();
  180. })
  181. .catch(() => {
  182. this.loading = false;
  183. });
  184. } else {
  185. this.$message(
  186. {
  187. type: 'warning',
  188. message: this.$t('Key561'), //"请输入生成激活码数量!",
  189. },
  190. 2000,
  191. );
  192. return false;
  193. }
  194. },
  195. // 查询数据列表
  196. getList() {
  197. let MethodName = 'page_query-PageQueryGoodsDiscountCodeList';
  198. let data = {
  199. goods_id: this.bookId,
  200. page_capacity: this.page_capacity,
  201. cur_page: this.currentPage,
  202. use_status: -1,
  203. goods_type: this.goods_type * 1,
  204. };
  205. LearnWebSI(MethodName, data).then((res) => {
  206. let _this = this;
  207. _this.tableData = res.discount_code_list;
  208. _this.courseTotal = res.total_count;
  209. _this.tableloading = false;
  210. });
  211. },
  212. // 处理发布状态
  213. handleStatus(row) {
  214. if (row) {
  215. return this.usedStatus[row.is_used];
  216. }
  217. },
  218. // 删除书籍
  219. handleDel(row) {
  220. // 确定删除此优惠码吗?
  221. this.$confirm(this.$t('Key689'), this.$t('Key361'), {
  222. confirmButtonText: this.$t('Key94'), //"确定",
  223. cancelButtonText: this.$t('Key83'), //"取消",
  224. type: 'warning',
  225. })
  226. .then(() => {
  227. let MethodName = 'order-discount_manager-DeleteGoodsDiscountCode';
  228. let data = {
  229. discount_code_id: row.id,
  230. goods_id: this.bookId,
  231. goods_type: this.goods_type * 1,
  232. };
  233. LearnWebSI(MethodName, data)
  234. .then((res) => {
  235. this.currentPage = 1;
  236. this.getList();
  237. this.$message({
  238. type: 'success',
  239. message: this.$t('Key532'), //"删除成功!",
  240. });
  241. })
  242. .catch(() => {});
  243. })
  244. .catch(() => {});
  245. },
  246. // 导出
  247. onExport() {
  248. this.exportLoading = true;
  249. let userInfor = getToken() || sessionStorage.getItem('GCLS_Token_Tc');
  250. let UserCode = '',
  251. UserType = '',
  252. SessionID = '';
  253. if (userInfor) {
  254. let user = getToken() ? JSON.parse(getToken()) : JSON.parse(sessionStorage.getItem('GCLS_Token_Tc'));
  255. UserCode = user.user_code;
  256. UserType = user.user_type;
  257. SessionID = user.session_id;
  258. }
  259. let MethodName = 'data_export-ExportGoodsDiscountCodeList';
  260. let data = {
  261. use_status: this.exportRadio,
  262. goods_id: this.bookId,
  263. goods_type: this.goods_type * 1,
  264. };
  265. window.open(
  266. process.env.VUE_APP_BASE_API +
  267. `/GCLSLearnWebSI/ServiceInterface?MethodName=${MethodName}&UserCode=${UserCode}&UserType=${UserType}&SessionID=${SessionID}&Parameter=${encodeURIComponent(
  268. JSON.stringify(data),
  269. )}`,
  270. );
  271. this.exportLoading = false;
  272. },
  273. },
  274. };
  275. </script>
  276. <style lang="scss" scoped>
  277. .discountCodeList {
  278. width: 100%;
  279. background: #f5f5f5;
  280. .contentInner {
  281. width: 100%;
  282. max-width: 1200px;
  283. margin: 0 auto;
  284. height: auto;
  285. padding: 30px 0;
  286. }
  287. .search-form {
  288. display: flex;
  289. align-items: center;
  290. justify-content: space-between;
  291. }
  292. }
  293. </style>