link-select.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <?php
  2. /**
  3. * @link:http://www.goodmall.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="link-select">
  17. <div class="com-dialog-select">
  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" center>
  20. <div style="display: flex;justify-content: center;">
  21. <el-input placeholder="请输入标题" v-model="keyword" size="small" style="width: 350px;margin: 0 auto;" @keyup.enter.native="getDetail(1)">
  22. <el-button slot="append" @click="getDetail(1)">搜索</el-button>
  23. </el-input>
  24. </div>
  25. <el-table
  26. :data="list"
  27. v-loading="listLoading"
  28. border
  29. style="width: 100%;margin-top: 10px;">
  30. <el-table-column width="100px" label="ID" align="center">
  31. <template slot-scope="props">
  32. <el-radio-group v-model="selectId" @change="handleSelectionChange(props.row)">
  33. <el-radio :label="props.row.id"></el-radio>
  34. </el-radio-group>
  35. </template>
  36. </el-table-column>
  37. <el-table-column
  38. prop="title"
  39. label="标题"
  40. >
  41. </el-table-column>
  42. <el-table-column prop="created_at" label="时间">
  43. <template slot-scope="scope">
  44. <div>{{ scope.row.created_at|dateTimeFormat('Y-m-d H:i:s') }}</div>
  45. </template>
  46. </el-table-column>
  47. </el-table>
  48. <div style="text-align: right;margin: 20px 0;">
  49. <el-pagination
  50. background
  51. @current-change="getDetail"
  52. layout="prev, pager, next"
  53. :page-count="pageCount">
  54. </el-pagination>
  55. </div>
  56. <div style="display: flex;justify-content: center;">
  57. <el-button type="primary" @click="confirm">确定</el-button>
  58. </div>
  59. </el-dialog>
  60. <div @click="click" style="display: inline-block">
  61. <slot></slot>
  62. </div>
  63. </div>
  64. </template>
  65. <script>
  66. Vue.component('link-select', {
  67. template: '#link-select',
  68. props: {
  69. visible : {
  70. type: String,
  71. },
  72. url: {
  73. type: String,
  74. default: 'eight-out-two/setting/get-diy-list'//'mall/goods/index'
  75. },
  76. multiple: Boolean,
  77. title: {
  78. type: String,
  79. default: '页面选择'
  80. },
  81. listKey: {
  82. type: String,
  83. default: 'name'
  84. },
  85. params: Object,
  86. display: Boolean,
  87. extraSearch: Object,
  88. },
  89. data() {
  90. return {
  91. visible: false,
  92. listLoading: false,
  93. list: [],
  94. pagination: null,
  95. radioSelection: 0,
  96. search: {
  97. keyword: ''
  98. },
  99. multipleSelection: [],
  100. selectId:0,
  101. tableData:[],
  102. pageCount:0,
  103. keyword:''
  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. request({
  119. params: {
  120. r: this.url,
  121. page: page,
  122. limit:10,
  123. keyword:this.keyword
  124. },
  125. method: 'get',
  126. }).then(e => {
  127. console.log('列表结果='+JSON.stringify(e))
  128. this.listLoading = false;
  129. if (e.data.code === 0) {
  130. this.list = e.data.data.list;
  131. this.pageCount = e.data.data.page_count;
  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. currentChange(){
  148. }
  149. }
  150. });
  151. </script>