index.vue 17 KB

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