index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  1. <template>
  2. <div class="manage-root personnel-manage">
  3. <Header />
  4. <div class="manage-root-contain">
  5. <nav-menu class="manage-root-contain-left" :activeMenuIndex="activeMenuIndex"></nav-menu>
  6. <div class="manage-root-contain-right personnel-manage-right">
  7. <breadcrumb :breadcrumbList="breadcrumbList" class="breadcrumb-box"></breadcrumb>
  8. <div class="personal-inner">
  9. <div class="common-title-box">
  10. <h3>兑换码列表</h3>
  11. <div class="btn-box">
  12. <el-button type="primary" size="small" @click="createCdkey">创建兑换码</el-button>
  13. </div>
  14. </div>
  15. <div class="search-box">
  16. <div class="search-item">
  17. <label>搜索</label>
  18. <el-input
  19. placeholder="输入搜索内容"
  20. v-model="searchInput" maxlength="200">
  21. <i slot="suffix" class="el-input__icon el-icon-search" @click="getList(1)" style="cursor: pointer;"></i>
  22. </el-input>
  23. </div>
  24. <div class="search-item">
  25. <label>状态</label>
  26. <el-select v-model="searchStatus" @change="getList(1)" placeholder="请选择">
  27. <el-option
  28. v-for="item in statusList"
  29. :key="item.value"
  30. :label="item.label"
  31. :value="item.value">
  32. </el-option>
  33. </el-select>
  34. </div>
  35. <div class="search-item">
  36. <label>类型</label>
  37. <el-select v-model="searchType" @change="getList(1)" placeholder="请选择">
  38. <el-option
  39. v-for="item in typeList"
  40. :key="item.value"
  41. :label="item.label"
  42. :value="item.value">
  43. </el-option>
  44. </el-select>
  45. </div>
  46. </div>
  47. <el-table
  48. class="search-table"
  49. :data="tableData"
  50. style="width: 100%"
  51. @sort-change="handleSort"
  52. :default-sort = dataSort
  53. :max-height="tableHeight"
  54. v-loading="tableLoading">
  55. <el-table-column
  56. type="index"
  57. label="#"
  58. sortable
  59. width="54"
  60. :index="(pageNumber-1)*pageSize+1">
  61. </el-table-column>
  62. <el-table-column
  63. prop="name"
  64. label="兑换码名称"
  65. sortable="custom"
  66. width="163">
  67. </el-table-column>
  68. <el-table-column
  69. prop="code"
  70. label="兑换码"
  71. sortable="custom"
  72. width="170">
  73. </el-table-column>
  74. <el-table-column
  75. prop="type"
  76. label="类型"
  77. sortable="custom"
  78. width="92" >
  79. <template slot-scope="scope">
  80. {{scope.row.type===0?'普通兑换码':'批量兑换码'}}
  81. </template>
  82. </el-table-column>
  83. <el-table-column
  84. prop="goods_count"
  85. label="内容数"
  86. min-width="80">
  87. </el-table-column>
  88. <el-table-column
  89. prop="phone"
  90. label="使用情况"
  91. width="96">
  92. <template slot-scope="scope">
  93. {{scope.row.person_count_use+'/'+scope.row.person_count_max}}
  94. </template>
  95. </el-table-column>
  96. <el-table-column
  97. prop="creator_name"
  98. label="创建人"
  99. width="88">
  100. </el-table-column>
  101. <el-table-column
  102. prop="create_time"
  103. label="创建时间"
  104. sortable="custom"
  105. width="164">
  106. </el-table-column>
  107. <el-table-column
  108. prop="end_date"
  109. label="到期日期"
  110. sortable="custom"
  111. width="126" >
  112. </el-table-column>
  113. <el-table-column
  114. prop="valid_status"
  115. label="状态"
  116. width="88" >
  117. <template slot-scope="scope">
  118. <div class="status-box">
  119. <span :style="{background:statusListCss[scope.row.valid_status].bg}"></span>
  120. <b :style="{color:statusListCss[scope.row.valid_status].color}">{{statusListCss[scope.row.valid_status].text}}</b>
  121. </div>
  122. </template>
  123. </el-table-column>
  124. <el-table-column
  125. prop="momo"
  126. label="备注"
  127. width="120">
  128. </el-table-column>
  129. <el-table-column
  130. fixed="right"
  131. label="操作"
  132. width="180">
  133. <template slot-scope="scope">
  134. <el-button
  135. @click.native.prevent="handleEdit(scope.row)"
  136. type="text"
  137. size="small"
  138. class="primary-btn">
  139. 查看
  140. </el-button>
  141. <el-button
  142. @click.native.prevent="handleUp(scope.row, scope.$index)"
  143. type="text"
  144. size="small"
  145. class="primary-btn"
  146. v-if="scope.row.valid_status===0">
  147. 启用
  148. </el-button>
  149. <el-button
  150. @click.native.prevent="handleUp(scope.row, scope.$index)"
  151. type="text"
  152. size="small"
  153. class="red-btn"
  154. v-else-if="scope.row.valid_status===1">
  155. 停用
  156. </el-button>
  157. <el-button
  158. @click.native.prevent="handleRevoca(scope.row)"
  159. type="text"
  160. size="small"
  161. class="primary-btn">
  162. 撤回
  163. </el-button>
  164. <el-button
  165. @click.native.prevent="handleDelete(scope.row, scope.$index)"
  166. type="text"
  167. size="small"
  168. class="red-btn">
  169. 删除
  170. </el-button>
  171. </template>
  172. </el-table-column>
  173. </el-table>
  174. <el-pagination
  175. background
  176. @size-change="handleSizeChange"
  177. @current-change="handleCurrentChange"
  178. :current-page="pageNumber"
  179. :page-sizes="[10, 20, 30, 40]"
  180. :page-size="pageSize"
  181. layout="total, prev, pager, next, sizes, jumper"
  182. :total="total_count">
  183. </el-pagination>
  184. </div>
  185. </div>
  186. </div>
  187. </div>
  188. </template>
  189. <script>
  190. //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  191. //例如:import 《组件名称》from ‘《组件路径》';
  192. import Header from "../../components/Header.vue";
  193. import NavMenu from "../../components/NavMenu.vue"
  194. import Breadcrumb from '../../components/Breadcrumb.vue';
  195. import { getLogin } from "@/api/ajax";
  196. export default {
  197. //import引入的组件需要注入到对象中才能使用
  198. components: { Header, NavMenu, Breadcrumb },
  199. props: {},
  200. data() {
  201. //这里存放数据
  202. return {
  203. activeMenuIndex: "cdkey_manage",
  204. breadcrumbList:[
  205. {
  206. icon:'barcode-line',
  207. url:'',
  208. text:''
  209. },
  210. {
  211. icon:'',
  212. url:'',
  213. text:'兑换码管理'
  214. }
  215. ],
  216. searchInput: '',
  217. searchType: -1,
  218. searchStatus: -1,
  219. typeList:[
  220. {
  221. value:-1,
  222. label:'全部'
  223. },
  224. {
  225. value:0,
  226. label:'普通兑换码'
  227. },
  228. {
  229. value:1,
  230. label:'批量兑换码'
  231. }
  232. ],
  233. statusList:[
  234. {
  235. label: '全部',
  236. value: -1
  237. },
  238. {
  239. label: '使用中',
  240. value: 1
  241. },
  242. {
  243. label: '已停用',
  244. value: 0
  245. },
  246. {
  247. label: '已到期',
  248. value: 2
  249. }
  250. ],
  251. statusListCss:{
  252. 1:{
  253. text:'使用中',
  254. bg:'#165DFF',
  255. color:''
  256. },
  257. 0:{
  258. text:'已停用',
  259. bg:'#F53F3F',
  260. color:''
  261. },
  262. 2:{
  263. text:'已过期',
  264. bg:'#FF7D00',
  265. color:''
  266. }
  267. },
  268. tableData:[
  269. // {
  270. // id:'1',
  271. // userName:'admin',
  272. // realName:'超级管理员',
  273. // sex:'0',
  274. // type:'0', // 0 管理员 1 平台管理员 2 内容管理员 3 财务管理员 4 兑换码管理员
  275. // email:'d.dkemi@kqtdgbo.tj',
  276. // phone:'13082684216',
  277. // status:'1',
  278. // data:'2018-02-03',
  279. // img:''
  280. // }
  281. ],
  282. pageSize: window.localStorage.getItem('pageSize')?Number(window.localStorage.getItem('pageSize')):10,
  283. pageNumber: window.localStorage.getItem('pageNumber')?Number(window.localStorage.getItem('pageNumber')):1,
  284. tableHeight: "", // 表格高度
  285. total_count: 0,
  286. dataSort: {},
  287. tableLoading: false,
  288. }
  289. },
  290. //计算属性 类似于data概念
  291. computed: {
  292. },
  293. //监控data中数据变化
  294. watch: {},
  295. //方法集合
  296. methods: {
  297. createCdkey(){
  298. window.localStorage.removeItem('cdKeyId')
  299. this.$router.push({path: '/createCdkey'})
  300. },
  301. handleSort(value){
  302. let dataSort = {
  303. prop: value.prop,
  304. order: value.order
  305. }
  306. this.dataSort = dataSort
  307. this.getList()
  308. },
  309. // 撤回
  310. handleRevoca(row){
  311. this.$confirm('确定撤回吗?', '提示', {
  312. confirmButtonText: '确定',
  313. cancelButtonText: '取消',
  314. type: 'warning'
  315. }).then(() => {
  316. }).catch(() => {
  317. });
  318. },
  319. // 删除
  320. handleDelete(row){
  321. this.$confirm('确定删除吗?', '提示', {
  322. confirmButtonText: '确定',
  323. cancelButtonText: '取消',
  324. type: 'warning'
  325. }).then(() => {
  326. let Mname = "/CourseServer/Manager/ZBCourseManager/DeleteZBCourse";
  327. let data = {
  328. id: row.id
  329. };
  330. getLogin(Mname, data).then(res => {
  331. this.$message({
  332. type: 'success',
  333. message: '删除成功!'
  334. });
  335. this.getList()
  336. });
  337. }).catch(() => {
  338. });
  339. },
  340. // 查询列表
  341. getList(page){
  342. this.tableLoading = true
  343. if(page){
  344. this.pageNumber = page
  345. }
  346. let MethodName = "/ShopServer/Manager/DiscountCodeManager/PageQueryDiscountCodeList";
  347. let order_column_list = []
  348. if(this.dataSort != {}){
  349. if(this.dataSort.order=='descending'){
  350. order_column_list = [this.dataSort.prop + ':desc']
  351. }else if(this.dataSort.order=='ascending'){
  352. // 升序不传值
  353. order_column_list = [this.dataSort.prop]
  354. }else{
  355. order_column_list = ['create_time:desc']
  356. }
  357. }else{
  358. order_column_list = ['create_time:desc']
  359. }
  360. let data = {
  361. content:this.searchInput.trim(),
  362. type:this.searchType,
  363. valid_status:this.searchStatus,
  364. page_capacity:this.pageSize,
  365. cur_page:this.pageNumber,
  366. order_column_list: order_column_list
  367. }
  368. getLogin(MethodName, data)
  369. .then((res) => {
  370. this.tableLoading = false
  371. if(res.status===1){
  372. this.tableData = res.discount_code_list
  373. this.total_count = res.total_count
  374. }
  375. })
  376. .catch(() => {
  377. this.tableLoading = false
  378. });
  379. },
  380. // 编辑账号
  381. handleEdit(row){
  382. // 根据登录用户判断当前用户是不是超管 在table里加上disabled
  383. // 点击时记录页码和每页条数
  384. window.localStorage.setItem('pageSize',this.pageSize)
  385. window.localStorage.setItem('pageNumber',this.pageNumber)
  386. if(row&&row.id){
  387. this.$router.push({
  388. path: "/checkGoods",
  389. query: {
  390. id: row?row.id:''
  391. },
  392. });
  393. }
  394. },
  395. // 停用 启用
  396. handleUp(row, index) {
  397. let Mname = "/OrgServer/Manager/SysUserManager/EnableSysUser";
  398. let updataData = JSON.parse(JSON.stringify(row));
  399. let data = {
  400. id: row.id
  401. };
  402. if (row.status === 0) {
  403. // 下架状态
  404. data.is_enable = "true";
  405. updataData.status = 1;
  406. } else if (row.status === 1) {
  407. data.is_enable = "false";
  408. updataData.status = 0;
  409. }
  410. getLogin(Mname, data).then(res => {
  411. this.$message.success("操作成功");
  412. this.$set(this.tableData, index, updataData);
  413. this.getList()
  414. });
  415. },
  416. handleSizeChange(val) {
  417. this.pageSize = val
  418. this.pageNumber = 1
  419. this.getList()
  420. },
  421. handleCurrentChange(val) {
  422. this.pageNumber = val
  423. this.getList()
  424. },
  425. //计算table高度(动态设置table高度)
  426. getTableHeight() {
  427. let tableH = 370; //距离页面下方的高度
  428. let tableHeightDetil = window.innerHeight - tableH;
  429. if (tableHeightDetil <= 300) {
  430. this.tableHeight = 300;
  431. } else {
  432. this.tableHeight = window.innerHeight - tableH;
  433. }
  434. },
  435. },
  436. //生命周期 - 创建完成(可以访问当前this实例)
  437. created() {
  438. this.getTableHeight();
  439. this.getList()
  440. },
  441. //生命周期 - 挂载完成(可以访问DOM元素)
  442. mounted() {
  443. let _this = this
  444. let input = document.querySelector('input');
  445. input.addEventListener('keyup', function(event) {
  446. // 判断是否按下回车键
  447. if (event.keyCode === 13) {
  448. // 回车键被按下,执行你想要的操作
  449. _this.getList(1)
  450. }
  451. });
  452. },
  453. //生命周期-创建之前
  454. beforeCreated() { },
  455. //生命周期-挂载之前
  456. beforeMount() { },
  457. //生命周期-更新之前
  458. beforUpdate() { },
  459. //生命周期-更新之后
  460. updated() { },
  461. //生命周期-销毁之前
  462. beforeDestory() { },
  463. //生命周期-销毁完成
  464. destoryed() { },
  465. //如果页面有keep-alive缓存功能,这个函数会触发
  466. activated() { }
  467. }
  468. </script>
  469. <style lang="scss" scoped>
  470. /* @import url(); 引入css类 */
  471. </style>
  472. <style lang="scss">
  473. .personal-inner{
  474. .user-info{
  475. .cell{
  476. display: flex;
  477. align-items: center;
  478. .touxiang{
  479. width: 24px;
  480. height: 24px;
  481. border-radius: 50%;
  482. margin-right: 8px;
  483. }
  484. }
  485. }
  486. .type-info{
  487. background: #F2F3F5;
  488. border-radius: 2px;
  489. color: #1D2129;
  490. padding: 2px 8px 3px 8px;
  491. font-weight: 500;
  492. font-size: 14px;
  493. line-height: 22px;
  494. height: auto;
  495. border: none;
  496. }
  497. }
  498. </style>