index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template> 
  2. <div class="app-container">
  3. <div class="filter-container">
  4. <span>输入搜索:</span>
  5. <el-input
  6. size="small"
  7. style="width: 200px"
  8. v-model="listQuery.keyword"
  9. placeholder="品牌名称/关键字"
  10. ></el-input>
  11. <el-button
  12. class="search-button"
  13. @click="searchBrandList()"
  14. type="primary"
  15. size="small">
  16. 查询结果
  17. </el-button>
  18. </div>
  19. <el-table ref="brandTable"
  20. :data="list"
  21. style="width: 100%"
  22. @selection-change="handleSelectionChange"
  23. v-loading="listLoading"
  24. border>
  25. <el-table-column type="selection" width="60" align="center"></el-table-column>
  26. <el-table-column label="编号" width="80" align="center">
  27. <template slot-scope="scope">{{scope.row.id}}</template>
  28. </el-table-column>
  29. <el-table-column label="品牌名称" align="center">
  30. <template slot-scope="scope">{{scope.row.name}}</template>
  31. </el-table-column>
  32. <el-table-column label="品牌首字母" width="100" align="center">
  33. <template slot-scope="scope">{{scope.row.firstLetter}}</template>
  34. </el-table-column>
  35. <el-table-column label="排序" width="80" align="center">
  36. <template slot-scope="scope">{{scope.row.sort}}</template>
  37. </el-table-column>
  38. <el-table-column label="品牌制造商" width="100" align="center">
  39. <template slot-scope="scope">
  40. <el-switch
  41. @change="handleFactoryStatusChange(scope.$index, scope.row)"
  42. :active-value="1"
  43. :inactive-value="0"
  44. v-model="scope.row.factoryStatus">
  45. </el-switch>
  46. </template>
  47. </el-table-column>
  48. <el-table-column label="是否显示" width="100" align="center">
  49. <template slot-scope="scope">
  50. <el-switch
  51. @change="handleShowStatusChange(scope.$index, scope.row)"
  52. :active-value="1"
  53. :inactive-value="0"
  54. v-model="scope.row.showStatus">
  55. </el-switch>
  56. </template>
  57. </el-table-column>
  58. <el-table-column label="相关" width="220" align="center">
  59. <template slot-scope="scope">
  60. <span>商品:</span>
  61. <el-button
  62. size="mini"
  63. type="text"
  64. @click="handleProductList(scope.$index, scope.row)">100
  65. </el-button>
  66. <span>评价:</span>
  67. <el-button
  68. size="mini"
  69. type="text"
  70. @click="handleProductCommentList(scope.$index, scope.row)">1000
  71. </el-button>
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="操作" width="220" align="center">
  75. <template slot-scope="scope">
  76. <el-button
  77. size="mini"
  78. @click="handleEdit(scope.$index, scope.row)">编辑
  79. </el-button>
  80. <el-button
  81. size="mini"
  82. type="danger"
  83. @click="handleDelete(scope.$index, scope.row)">删除
  84. </el-button>
  85. </template>
  86. </el-table-column>
  87. </el-table>
  88. <div class="batch-operate-container">
  89. <el-select
  90. size="small"
  91. v-model="operateValue" placeholder="批量操作">
  92. <el-option
  93. v-for="item in operates"
  94. :key="item.value"
  95. :label="item.label"
  96. :value="item.value">
  97. </el-option>
  98. </el-select>
  99. <el-button
  100. style="margin-left: 20px"
  101. class="search-button"
  102. @click="handleBatchOperate()"
  103. type="primary"
  104. size="small">
  105. 确定
  106. </el-button>
  107. </div>
  108. <div class="pagination-container">
  109. <el-pagination
  110. background
  111. @current-change="handleCurrentChange"
  112. layout="total, prev, pager, next,jumper"
  113. :page-size="listQuery.pageSize"
  114. :current-page.sync="listQuery.pageNum"
  115. :total="total">
  116. </el-pagination>
  117. </div>
  118. </div>
  119. </template>
  120. <script>
  121. import {fetchList} from '@/api/brand'
  122. export default {
  123. name: 'brandList',
  124. data() {
  125. return {
  126. operates:[
  127. {
  128. label:"显示品牌",
  129. value:"showBrand"
  130. },
  131. {
  132. label:"隐藏品牌",
  133. value:"hideBrand"
  134. }
  135. ],
  136. operateValue:null,
  137. listQuery: {
  138. keyword: null,
  139. pageNum: 1,
  140. pageSize: 10
  141. },
  142. list: null,
  143. total: null,
  144. listLoading: true,
  145. multipleSelection: []
  146. }
  147. },
  148. created() {
  149. this.getList();
  150. },
  151. methods: {
  152. getList() {
  153. this.listLoading = true;
  154. fetchList(this.listQuery).then(response => {
  155. this.listLoading = false;
  156. this.list = response.data.list;
  157. this.total = response.data.total;
  158. this.totalPage = response.data.totalPage;
  159. this.pageSize = response.data.pageSize;
  160. });
  161. },
  162. handleSelectionChange(val) {
  163. this.multipleSelection = val;
  164. },
  165. handleEdit(index, row) {
  166. console.log(index, row);
  167. },
  168. handleDelete(index, row) {
  169. console.log(index, row);
  170. },
  171. handleProductList(index, row) {
  172. console.log(index, row);
  173. },
  174. handleProductCommentList(index, row) {
  175. console.log(index, row);
  176. },
  177. handleFactoryStatusChange(index, row) {
  178. console.log(index, row);
  179. },
  180. handleShowStatusChange(index, row) {
  181. console.log(index, row);
  182. },
  183. handleCurrentChange(val) {
  184. this.listQuery.pageNum = val;
  185. this.getList();
  186. },
  187. searchBrandList() {
  188. this.listQuery.pageNum = 1;
  189. this.getList();
  190. },
  191. handleBatchOperate() {
  192. console.log(this.operateValue);
  193. }
  194. }
  195. }
  196. </script>
  197. <style rel="stylesheet/scss" lang="scss" scoped>
  198. .pagination-container {
  199. display: inline-block;
  200. float: right;
  201. margin-top: 20px;
  202. }
  203. .filter-container {
  204. margin-bottom: 20px;
  205. }
  206. .search-button {
  207. float: right;
  208. }
  209. .batch-operate-container{
  210. display: inline-block;
  211. margin-top: 20px;
  212. }
  213. </style>