supplier-list.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <div class="supplier-list">
  3. <div class="filter-container">
  4. <div class="filter-control">
  5. <span>供应商名称:</span>
  6. <el-input
  7. v-model="listQuery.shopName"
  8. size="mini"
  9. placeholder="供应商名称"
  10. @keyup.enter.native="filterSupplierList"
  11. />
  12. </div>
  13. <div class="filter-control">
  14. <span>供应商类型:</span>
  15. <el-select
  16. v-model="listQuery.shopType"
  17. placeholder="供应商类型"
  18. size="mini"
  19. clearable
  20. @change="filterSupplierList"
  21. >
  22. <el-option label="所有类型" value="" />
  23. <el-option label="代理商" :value="2" />
  24. <el-option label="品牌方" :value="1" />
  25. </el-select>
  26. </div>
  27. <div class="filter-control">
  28. <span>手机号:</span>
  29. <el-input
  30. v-model="listQuery.mobile"
  31. size="mini"
  32. placeholder="手机号"
  33. @keyup.enter.native="filterSupplierList"
  34. />
  35. </div>
  36. <div class="filter-control">
  37. <el-button type="primary" size="mini" @click="filterSupplierList">查询</el-button>
  38. </div>
  39. </div>
  40. <el-table
  41. v-infinite-scroll="onLoad"
  42. :data="supplierList"
  43. border
  44. class="infinite-list hide-table-check-all"
  45. style="overflow: auto"
  46. :infinite-scroll-delay="300"
  47. :infinite-scroll-immediate="false"
  48. header-row-class-name="tableHeader"
  49. highlight-current-row
  50. @row-click="handleSelectSupplier"
  51. >
  52. >
  53. <el-table-column label="选择" width="55" align="center">
  54. <template slot-scope="{ row }">
  55. <el-radio v-model="selectedAuthUserId" :label="row.authUserId"><span v-show="false">1</span></el-radio>
  56. </template>
  57. </el-table-column>
  58. <el-table-column label="序号" type="index" width="80" align="center" />
  59. <el-table-column property="name" label="供应商名称" />
  60. <el-table-column label="供应商类型" align="center" width="120">
  61. <template slot-scope="{ row }">
  62. <span v-if="row.shopType === 1">品牌方</span>
  63. <span v-else>代理商</span>
  64. </template>
  65. </el-table-column>
  66. <!-- <el-table-column label="登录账号" align="center">
  67. <template slot-scope="{ row }">
  68. <span v-if="row.loginAccount">{{ row.loginAccount }}</span>
  69. <span v-else>未绑定</span>
  70. </template>
  71. </el-table-column> -->
  72. <el-table-column prop="mobile" label="手机号" align="center" width="160" />
  73. <el-table-column prop="linkMan" label="联系人" align="center" />
  74. </el-table>
  75. <div class="control">
  76. <el-button @click="onCancel">取 消</el-button>
  77. <el-button type="primary" @click="onConfirm">确定</el-button>
  78. </div>
  79. </div>
  80. </template>
  81. <script>
  82. import { fetchSupplierList } from '@/api/supplier'
  83. import { deepClone } from '@/utils'
  84. export default {
  85. name: 'SupplierList',
  86. data() {
  87. return {
  88. listQuery: {
  89. shopName: '',
  90. shopType: '',
  91. mobile: '',
  92. pageNum: 1,
  93. pageSize: 10
  94. },
  95. supplierList: [],
  96. selectedAuthUserId: '',
  97. selectedSupplierInfo: null
  98. }
  99. },
  100. created() {
  101. this.filterSupplierList()
  102. },
  103. methods: {
  104. // 取消
  105. onCancel() {
  106. this.selectedAuthUserId = ''
  107. this.selectedSupplierInfo = null
  108. this.$emit('cancel', this.selectedSupplierInfo)
  109. },
  110. // 确认
  111. onConfirm() {
  112. this.$emit('confirm', deepClone(this.selectedSupplierInfo))
  113. this.selectedAuthUserId = ''
  114. this.selectedSupplierInfo = null
  115. },
  116. // 确认选中的供应商
  117. handleSubmitSupplier() {
  118. this.dialogTableVisible = false
  119. this.currentSupplierList = [this.selectedSupplierInfo]
  120. },
  121. // 选择供应商
  122. handleSelectSupplier(e) {
  123. this.selectedAuthUserId = e.authUserId
  124. this.selectedSupplierInfo = e
  125. },
  126. // 选择供应商对话框关闭事件
  127. handleDialogClosed() {
  128. this.listQuery.pageNum = 1
  129. this.listQuery.shopName = ''
  130. this.listQuery.shopType = ''
  131. this.listQuery.mobile = ''
  132. this.listQuery.linkMan = ''
  133. },
  134. // 筛选供应商
  135. filterSupplierList() {
  136. this.listQuery.pageNum = 1
  137. this.supplierList = []
  138. this.fetchSupplierList()
  139. },
  140. // 获取供应商列表
  141. fetchSupplierList() {
  142. fetchSupplierList(this.listQuery).then((res) => {
  143. console.log(res)
  144. this.supplierList = [...this.supplierList, ...res.data.list]
  145. this.hasNextPage = res.data.hasNextPage
  146. this.total = res.data.total
  147. })
  148. },
  149. onLoad() {
  150. if (!this.hasNextPage) return
  151. this.listQuery.pageNum++
  152. this.fetchSupplierList()
  153. }
  154. }
  155. }
  156. </script>
  157. <style lang="scss" scoped>
  158. .supplier-list {
  159. .control {
  160. text-align: right;
  161. margin-top: 12px;
  162. }
  163. .infinite-list {
  164. height: 400px;
  165. }
  166. }
  167. </style>