sj-list-layer.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <el-dialog
  3. title="选择商家"
  4. :visible.sync="selDialog"
  5. :close-on-click-modal="false"
  6. :append-to-body="true"
  7. width="800px"
  8. @close="$emit('update:show', false)"
  9. >
  10. <div class="recharge-modal-content">
  11. <el-radio-group
  12. v-model="radio"
  13. class="radio-wrap"
  14. >
  15. <x-crud
  16. class="liu-crud-wrap"
  17. @load="onLoad"
  18. >
  19. <template #table-column-radio="{scope}">
  20. <div>
  21. <el-radio :label="scope.row.index">选择</el-radio>
  22. </div>
  23. </template>
  24. <template #table-column-imgUrl="{scope}">
  25. <div>
  26. <cl-avatar
  27. shape="square"
  28. :size="40"
  29. :src="scope.row.imgUrl | default_avatar"
  30. :style="{ margin: 'auto' }"
  31. ></cl-avatar>
  32. </div>
  33. </template>
  34. </x-crud>
  35. </el-radio-group>
  36. </div>
  37. <div
  38. slot="footer"
  39. class="dialog-footer"
  40. >
  41. <el-button
  42. size="small"
  43. @click="resetForm"
  44. >取 消</el-button>
  45. <el-button
  46. type="primary"
  47. size="small"
  48. @click="confirmFn"
  49. >确定</el-button>
  50. </div>
  51. </el-dialog>
  52. </template>
  53. <script>
  54. export default {
  55. name: 'sj-list-layer',
  56. props: {
  57. show: {
  58. type: Boolean,
  59. default: false
  60. },
  61. multi: {
  62. type: Boolean,
  63. default: false
  64. }
  65. },
  66. data () {
  67. return {
  68. selDialog: false,
  69. ruleForm: {},
  70. radio: '',
  71. list: [],
  72. selData: {}
  73. };
  74. },
  75. computed: {
  76. },
  77. watch: {
  78. show (val) {
  79. this.selDialog = val;
  80. }
  81. },
  82. created () { },
  83. methods: {
  84. confirmFn () {
  85. this.$emit('confirm', this.list[this.radio]);
  86. },
  87. resetForm () {
  88. this.$emit('cancel');
  89. },
  90. onLoad ({ ctx, app }) {
  91. this.app = app;
  92. let applyHost = () => {
  93. return this.$service.saasShop.merchantList({ style: '3' });
  94. };
  95. ctx.service({
  96. page: applyHost
  97. })
  98. .set('table', {
  99. columns: [
  100. {
  101. prop: 'radio',
  102. label: '选择',
  103. align: 'center',
  104. 'min-width': 60
  105. },
  106. {
  107. prop: 'name',
  108. label: '商家名称',
  109. align: 'center'
  110. },
  111. {
  112. prop: 'currentStyle',
  113. label: '类型',
  114. align: 'center'
  115. }
  116. ],
  117. // 操作列
  118. op: {
  119. visible: false // 是否显示
  120. }
  121. })
  122. .set('dict', {
  123. search: {
  124. keyWord: 'name'
  125. }
  126. })
  127. .set('search', {
  128. key: {
  129. placeholder: '商家名称,支持拼音首字母'
  130. }
  131. })
  132. .set('pagination', {
  133. size: 6
  134. })
  135. .set('layout', [
  136. ['slot-tabs'],
  137. ['search-key', 'flex1', 'refresh-btn'],
  138. ['data-table'],
  139. ['flex1', 'pagination']
  140. ])
  141. .on('refresh', async (params, { next, render }) => {
  142. // 继续执行刷新
  143. let { list } = await next(params);
  144. list.map((e, index) => {
  145. e.index = index;
  146. });
  147. this.list = list;
  148. render(list);
  149. })
  150. .done();
  151. app.refresh({ type: this.tabIndex });
  152. }
  153. }
  154. };
  155. </script>
  156. <style lang="scss">
  157. // 列表
  158. .radio-wrap {
  159. display: block;
  160. }
  161. </style>