com-dialog-activity.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?php
  2. /**
  3. * @link:http://www.gdqijianshi.com/
  4. * @copyright: Copyright (c) 2020 广东七件事集团
  5. * Created by PhpStorm
  6. * Author: ganxiaohao
  7. * Date: 2020-04-24
  8. * Time: 19:33
  9. */
  10. ?>
  11. <style>
  12. .com-dialog-dialog {
  13. min-width: 700px;
  14. }
  15. </style>
  16. <template id="com-dialog-activity">
  17. <div class="com-dialog-activity">
  18. <el-dialog append-to-body :title="title" :visible.sync="visible" :close-on-click-modal="false"
  19. custom-class="com-dialog-dialog" :before-close="close" @close="close">
  20. <div>
  21. <el-input v-model="search.keyword" placeholder="根据活动名称或活动ID搜索" @keyup.enter.native="getDetail(1)">
  22. <el-button slot="append" @click="getDetail(1)">搜索</el-button>
  23. </el-input>
  24. <el-table border v-loading="listLoading" :data="list" style="margin-top: 24px;"
  25. @selection-change="handleSelectionChange">
  26. <el-table-column type="selection" width="60px" label="ID" props="id" v-if="multiple">
  27. </el-table-column>
  28. <el-table-column width="100px" label="ID" props="id" v-else>
  29. <template slot-scope="props">
  30. <el-radio-group v-model="radioSelection" @change="handleSelectionChange(props.row)">
  31. <el-radio :label="props.row.id"></el-radio>
  32. </el-radio-group>
  33. </template>
  34. </el-table-column>
  35. <el-table-column prop="id" label="ID" width="80" align="center"></el-table-column>
  36. <el-table-column label="名称">
  37. <template slot-scope="props">
  38. <div style="display: flex;">
  39. <div>
  40. <com-ellipsis :line="2">{{props.row[listKey]}}</com-ellipsis>
  41. <div style="font-size: 12px;color: red;">{{props.row.title}}</div>
  42. </div>
  43. </div>
  44. </template>
  45. </el-table-column>
  46. </el-table>
  47. </div>
  48. <div style="margin-top: 24px;">
  49. <el-row>
  50. <el-pagination
  51. v-if="pagination"
  52. style="display: inline-block;"
  53. background
  54. :page-size="pagination.pageSize"
  55. @current-change="getDetail"
  56. layout="prev, pager, next"
  57. :total="pagination.total_count">
  58. </el-pagination>
  59. <el-button type="primary" size="small" style="float: right" @click="confirm">选择</el-button>
  60. </el-row>
  61. </div>
  62. </el-dialog>
  63. <div @click="click" style="display: inline-block">
  64. <slot></slot>
  65. </div>
  66. </div>
  67. </template>
  68. <script>
  69. Vue.component('com-dialog-activity', {
  70. template: '#com-dialog-activity',
  71. props: {
  72. /* visible : {
  73. type: String,
  74. }, */
  75. url: {
  76. type: String,
  77. default: 'lucky-group/group/list'
  78. },
  79. multiple: Boolean,
  80. title: {
  81. type: String,
  82. default: '活动选择'
  83. },
  84. listKey: {
  85. type: String,
  86. default: 'name'
  87. },
  88. params: Object,
  89. display: Boolean,
  90. extraSearch: Object,
  91. },
  92. data() {
  93. return {
  94. visible: false,
  95. listLoading: false,
  96. list: [],
  97. pagination: null,
  98. radioSelection: 0,
  99. search: {
  100. keyword: ''
  101. },
  102. multipleSelection: []
  103. }
  104. },
  105. methods: {
  106. close(){
  107. this.visible=false;
  108. this.$emit('close');
  109. },
  110. click() {
  111. this.getDetail(1);
  112. this.visible = !this.visible;
  113. },
  114. getDetail(page) {
  115. this.list = [];
  116. this.listLoading = true;
  117. let params = Object.assign({
  118. r: this.url,
  119. search: Object.assign(this.search, this.extraSearch),
  120. page: page
  121. }, this.params);
  122. console.log(params);
  123. request({
  124. params: params
  125. }).then(e => {
  126. this.listLoading = false;
  127. //console.log("商品的数据=="+JSON.stringify(e))
  128. if (e.data.code === 0) {
  129. console.log(e,22222);
  130. this.list = e.data.data.list;
  131. this.pagination = e.data.data.pagination;
  132. } else {
  133. this.$message.error(e.data.msg);
  134. }
  135. }).catch(e => {
  136. this.listLoading = false;
  137. });
  138. },
  139. handleSelectionChange(val) {
  140. this.multipleSelection = val;
  141. },
  142. confirm() {
  143. this.visible = false;
  144. this.$emit('selected', this.multipleSelection);
  145. this.$emit('input', this.multipleSelection);
  146. }
  147. }
  148. });
  149. </script>