list-select.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <div class="app-container">
  3. <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal">
  4. <el-menu-item index="1">选择商品</el-menu-item>
  5. </el-menu>
  6. <div class="filter-container" style="margin-top:20px;">
  7. <el-input v-model="listQuery.form.id" placeholder="商品ID" style="width: 120px;" class="filter-item" @keyup.enter.native="handleFilter" />
  8. <el-input v-model="listQuery.form.productName" placeholder="商品名称" style="width: 120px;" class="filter-item" @keyup.enter.native="handleFilter" />
  9. <el-input v-model="listQuery.form.shopName" placeholder="供应商名称" style="width: 120px;" class="filter-item" @keyup.enter.native="handleFilter" />
  10. <el-button class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">
  11. 搜索
  12. </el-button>
  13. <el-button class="filter-item" type="primary" icon="el-icon-check">确定选择</el-button>
  14. <el-button class="filter-item" type="primary" icon="el-icon-close" @click="toggleSelection()">取消选择</el-button>
  15. </div>
  16. <el-table
  17. ref="multipleTable"
  18. v-loading="listLoading"
  19. :data="list"
  20. element-loading-text="Loading"
  21. border
  22. fit
  23. highlight-current-row
  24. style="width:100%;margin-top:20px;"
  25. @selection-change="handleSelectionChange"
  26. >
  27. <el-table-column align="center" type="selection" width="55" />
  28. <el-table-column label="商品ID" align="center" prop="id" />
  29. <el-table-column label="商品图片" align="center" prop="classifyImage">
  30. <template slot-scope="{row}">
  31. <img :src="row.mainImage" alt="">
  32. </template>
  33. </el-table-column>
  34. <el-table-column label="商品名称" align="center" prop="productName" />
  35. <el-table-column label="供应商名称" align="center" prop="shopName" />
  36. <el-table-column label="市场价" align="center" prop="normalPrice">
  37. <template slot-scope="{row}">
  38. <el-input v-model="row.normalPrice" style="width:60px;" size="small" />
  39. </template>
  40. </el-table-column>
  41. <el-table-column label="成本价" align="center" prop="costPrice">
  42. <template slot-scope="{row}">
  43. <el-input v-model="row.normalPrice" style="width:60px;" size="small" />
  44. </template>
  45. </el-table-column>
  46. <el-table-column label="售价" align="center" prop="retailPrice">
  47. <template slot-scope="{row}">
  48. <el-input v-model="row.normalPrice" style="width:60px;" size="small" />
  49. </template>
  50. </el-table-column>
  51. <el-table-column label="起订量" align="center" prop="minBuyNumber">
  52. <template slot-scope="{row}">
  53. <el-input v-model="row.normalPrice" style="width:60px;" size="small" />
  54. </template>
  55. </el-table-column>
  56. <el-table-column label="商品分类" align="center" prop="classifyID">
  57. <template slot-scope="{row}">
  58. <el-select v-model="row.classifyID" placeholder="商品分类" clearable style="width: 110px" class="filter-item" value="">
  59. <!-- <el-option v-for="item in productsClassifyList" :key="item.id" :label="item.classifyName" :value="item.id" /> -->
  60. </el-select>
  61. </template>
  62. </el-table-column>
  63. </el-table>
  64. <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="fetchData" />
  65. </div>
  66. </template>
  67. <script>
  68. import { getList } from '@/api/goods'
  69. import Pagination from '@/components/Pagination'
  70. export default {
  71. components: { Pagination },
  72. filters: {
  73. statusFilter(status) {
  74. const statusMap = {
  75. 1: 'success',
  76. 0: 'gray'
  77. }
  78. return statusMap[status]
  79. }
  80. },
  81. data() {
  82. return {
  83. list: null,
  84. listLoading: true,
  85. total: 0,
  86. activeIndex: '1',
  87. listQuery: {
  88. page: 1,
  89. limit: 10,
  90. form: {
  91. id: '',
  92. classifyImage: '',
  93. productName: '',
  94. shopName: '',
  95. normalPrice: '', // 市场价',
  96. costPrice: '', // 成本价',
  97. retailPrice: '', // '售价',
  98. minBuyNumber: '', // '最小起订量',
  99. preferredProduct: '', // 是否是优选商品:0不是优选,1优选商品',
  100. commonlyProduct: '', // 是否是常用商品:0不是常用,1常用商品',
  101. preferentialProduct: '', // 是否是星范精品:0不是精品,1星范精品商品',
  102. validFlag: '', // '商品状态,1已上架,2已下架',
  103. productClassifyName: '', // '对应cm_mall_products_classify商品分类表id',
  104. addTime: '', // '添加时间',
  105. organizeID: this.organizeID // '组织ID,具体对应cm_mall_organize表ID',
  106. }
  107. },
  108. multipleSelection: []
  109. }
  110. },
  111. computed: {
  112. organizeID() {
  113. return this.$store.state.settings.organizeID
  114. }
  115. },
  116. created() {
  117. this.fetchData()
  118. },
  119. methods: {
  120. fetchData() {
  121. this.listLoading = true
  122. getList().then(response => {
  123. this.list = response.data.items
  124. this.listLoading = false
  125. }).catch(() => {
  126. // 封装静态数据
  127. this.list = [
  128. {
  129. id: 0,
  130. classifyImage: '',
  131. productName: 'hahaah',
  132. shopName: '',
  133. normalPrice: '',
  134. costPrice: '',
  135. retailPrice: '',
  136. minBuyNumber: '',
  137. preferredProduct: '',
  138. commonlyProduct: '',
  139. preferentialProduct: '',
  140. validFlag: '',
  141. productClassifyName: 0,
  142. addTime: '',
  143. organizeID: this.organizeID
  144. },
  145. {
  146. id: 0,
  147. classifyImage: '',
  148. productName: 'hahaah',
  149. shopName: '',
  150. normalPrice: '',
  151. costPrice: '',
  152. retailPrice: '',
  153. minBuyNumber: '',
  154. preferredProduct: '',
  155. commonlyProduct: '',
  156. preferentialProduct: '',
  157. validFlag: '',
  158. productClassifyName: 0,
  159. addTime: '',
  160. organizeID: this.organizeID
  161. }
  162. ]
  163. })
  164. this.listLoading = false
  165. this.total = 2
  166. },
  167. handleFilter() {
  168. alert('搜索')
  169. },
  170. handleCreate() {
  171. alert('添加')
  172. },
  173. toggleSelection(rows) {
  174. if (rows) {
  175. rows.forEach(row => {
  176. this.$refs.multipleTable.toggleRowSelection(row)
  177. })
  178. } else {
  179. this.$refs.multipleTable.clearSelection()
  180. }
  181. },
  182. handleSelectionChange(val) {
  183. this.multipleSelection = val
  184. }
  185. }
  186. }
  187. </script>
  188. <style scoped>
  189. </style>