discountCodeList.vue 8.7 KB

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