com-dialog-store.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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-store">
  17. <div class="com-dialog-store">
  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="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 v-if="multiple" 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. <el-image fit="cover" style="width: 40px;height: 40px;display: block;margin-right: 5px;" :src="props.row.logo_img"></el-image>
  40. <div>
  41. <com-ellipsis :line="2">{{props.row.store_name}}</com-ellipsis>
  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-store', {
  70. template: '#com-dialog-store',
  71. props: {
  72. /* visible : {
  73. type: String,
  74. }, */
  75. url: {
  76. type: String,
  77. //default: 'subscribe/default/select-store'
  78. default: 'store/store/select-store'
  79. },
  80. multiple: Boolean,//是否开启选
  81. title: {
  82. type: String,
  83. default: '门店选择'
  84. },
  85. listKey: { //键值
  86. type: String,
  87. default: 'goods_name'
  88. },
  89. params: Object,
  90. display: Boolean,
  91. extraSearch: Object,
  92. },
  93. data() {
  94. return {
  95. visible: false,
  96. listLoading: false,
  97. list: [],
  98. total_count:1,
  99. pageSize:20,
  100. pagination: null,
  101. radioSelection: 0,
  102. keyword: null,
  103. multipleSelection: []
  104. }
  105. },
  106. methods: {
  107. close(){
  108. this.visible=false;
  109. this.$emit('close');
  110. },
  111. click() {
  112. this.getDetail(1);
  113. this.visible = !this.visible;
  114. },
  115. getDetail(page) {
  116. this.list = [];
  117. this.listLoading = true;
  118. let params = Object.assign({
  119. r: this.url,
  120. keyword: this.keyword,
  121. page: page
  122. }, this.params);
  123. console.log(params);
  124. request({
  125. params: params
  126. }).then(e => {
  127. this.listLoading = false;
  128. //console.log("门店的数据=="+JSON.stringify(e))
  129. if (e.data.code === 0) {
  130. this.list = e.data.data.list;
  131. this.pagination = e.data.data.pagination;
  132. this.pagination.pageSize = e.data.data.page_size;
  133. this.pagination.total_count = this.pagination.totalCount;
  134. } else {
  135. this.$message.error(e.data.msg);
  136. }
  137. }).catch(e => {
  138. this.listLoading = false;
  139. });
  140. },
  141. handleSelectionChange(val) {
  142. this.multipleSelection = val;
  143. },
  144. confirm() {
  145. this.visible = false;
  146. this.$emit('selected', this.multipleSelection);
  147. this.$emit('input', this.multipleSelection);
  148. }
  149. }
  150. });
  151. </script>