123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316 |
- <template>
- <div class="app-container">
- <el-card class="filter-container" shadow="never">
- <div>
- <i class="el-icon-search"></i>
- <span>筛选搜索</span>
- <el-button
- style="float: right"
- @click="searchBrandList()"
- type="primary"
- size="small">
- 查询结果
- </el-button>
- </div>
- <div style="margin-top: 15px">
- <el-form :inline="true" :model="listQuery" size="small" label-width="140px">
- <el-form-item label="输入搜索:">
- <el-input style="width: 203px" v-model="listQuery.keyword" placeholder="品牌名称/关键字"></el-input>
- </el-form-item>
- </el-form>
- </div>
- </el-card>
- <el-card class="operate-container" shadow="never">
- <i class="el-icon-tickets"></i>
- <span>数据列表</span>
- <el-button
- v-if="createbrand"
- class="btn-add"
- @click="addBrand()"
- size="mini">
- 添加
- </el-button>
- </el-card>
- <div class="table-container">
- <el-table ref="brandTable"
- :data="list"
- style="width: 100%"
- @selection-change="handleSelectionChange"
- v-loading="listLoading"
- border>
- <el-table-column type="selection" width="60" align="center"></el-table-column>
- <el-table-column label="编号" width="100" align="center">
- <template slot-scope="scope">{{scope.row.id}}</template>
- </el-table-column>
- <el-table-column label="品牌名称" align="center">
- <template slot-scope="scope">{{scope.row.name}}</template>
- </el-table-column>
- <el-table-column label="品牌首字母" width="100" align="center">
- <template slot-scope="scope">{{scope.row.firstLetter}}</template>
- </el-table-column>
- <el-table-column label="排序" width="100" align="center">
- <template slot-scope="scope">{{scope.row.sort}}</template>
- </el-table-column>
- <el-table-column label="品牌制造商" width="100" align="center">
- <template slot-scope="scope">
- <el-switch
- @change="handleFactoryStatusChange(scope.$index, scope.row)"
- :active-value="1"
- :inactive-value="0"
- v-model="scope.row.factoryStatus">
- </el-switch>
- </template>
- </el-table-column>
- <el-table-column label="是否显示" width="100" align="center">
- <template slot-scope="scope">
- <el-switch
- @change="handleShowStatusChange(scope.$index, scope.row)"
- :active-value="1"
- :inactive-value="0"
- v-model="scope.row.showStatus">
- </el-switch>
- </template>
- </el-table-column>
- <el-table-column label="相关" width="220" align="center">
- <template slot-scope="scope">
- <span>商品:</span>
- <el-button
- size="mini"
- type="text"
- @click="getProductList(scope.$index, scope.row)">100
- </el-button>
- <span>评价:</span>
- <el-button
- size="mini"
- type="text"
- @click="getProductCommentList(scope.$index, scope.row)">1000
- </el-button>
- </template>
- </el-table-column>
- <el-table-column label="操作" width="200" align="center">
- <template slot-scope="scope">
- <el-button
- v-if="updatebrand"
- size="mini"
- @click="handleUpdate(scope.$index, scope.row)">编辑
- </el-button>
- <el-button
- v-if="deletebrand"
- size="mini"
- type="danger"
- @click="handleDelete(scope.$index, scope.row)">删除
- </el-button>
- </template>
- </el-table-column>
- </el-table>
- </div>
- <div class="batch-operate-container">
- <el-select
- size="small"
- v-model="operateType" placeholder="批量操作">
- <el-option
- v-for="item in operates"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- <el-button
- style="margin-left: 20px"
- class="search-button"
- @click="handleBatchOperate()"
- type="primary"
- size="small">
- 确定
- </el-button>
- </div>
- <div class="pagination-container">
- <el-pagination
- background
- @size-change="handleSizeChange"
- @current-change="handleCurrentChange"
- layout="total, sizes,prev, pager, next,jumper"
- :page-size="listQuery.pageSize"
- :page-sizes="[5,10,15]"
- :current-page.sync="listQuery.pageNum"
- :total="total">
- </el-pagination>
- </div>
- </div>
- </template>
- <script>
- import {fetchList, updateShowStatus, updateFactoryStatus, deleteBrand} from '@/api/brand'
- import {createbrand,updatebrand,deletebrand} from '@/api/permissions'
- export default {
- name: 'brandList',
- data() {
- return {
- createbrand,
- updatebrand,
- deletebrand,
- operates: [
- {
- label: "显示品牌",
- value: "showBrand"
- },
- {
- label: "隐藏品牌",
- value: "hideBrand"
- }
- ],
- operateType: null,
- listQuery: {
- keyword: null,
- pageNum: 1,
- pageSize: 10
- },
- list: null,
- total: null,
- listLoading: true,
- multipleSelection: []
- }
- },
- created() {
- this.getList();
- },
- methods: {
- getList() {
- this.listLoading = true;
- fetchList(this.listQuery).then(response => {
- this.listLoading = false;
- this.list = response.data.list;
- this.total = response.data.total;
- this.totalPage = response.data.totalPage;
- this.pageSize = response.data.pageSize;
- });
- },
- handleSelectionChange(val) {
- this.multipleSelection = val;
- },
- handleUpdate(index, row) {
- this.$router.push({path: '/pms/updateBrand', query: {id: row.id}})
- },
- handleDelete(index, row) {
- this.$confirm('是否要删除该品牌', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- deleteBrand(row.id).then(response => {
- this.$message({
- message: '删除成功',
- type: 'success',
- duration: 1000
- });
- this.getList();
- });
- });
- },
- getProductList(index, row) {
- console.log(index, row);
- },
- getProductCommentList(index, row) {
- console.log(index, row);
- },
- handleFactoryStatusChange(index, row) {
- var data = new URLSearchParams();
- data.append("ids", row.id);
- data.append("factoryStatus", row.factoryStatus);
- updateFactoryStatus(data).then(response => {
- this.$message({
- message: '修改成功',
- type: 'success',
- duration: 1000
- });
- }).catch(error => {
- if (row.factoryStatus === 0) {
- row.factoryStatus = 1;
- } else {
- row.factoryStatus = 0;
- }
- });
- },
- handleShowStatusChange(index, row) {
- let data = new URLSearchParams();
- ;
- data.append("ids", row.id);
- data.append("showStatus", row.showStatus);
- updateShowStatus(data).then(response => {
- this.$message({
- message: '修改成功',
- type: 'success',
- duration: 1000
- });
- }).catch(error => {
- if (row.showStatus === 0) {
- row.showStatus = 1;
- } else {
- row.showStatus = 0;
- }
- });
- },
- handleSizeChange(val) {
- this.listQuery.pageNum = 1;
- this.listQuery.pageSize = val;
- this.getList();
- },
- handleCurrentChange(val) {
- this.listQuery.pageNum = val;
- this.getList();
- },
- searchBrandList() {
- this.listQuery.pageNum = 1;
- this.getList();
- },
- handleBatchOperate() {
- console.log(this.multipleSelection);
- if (this.multipleSelection < 1) {
- this.$message({
- message: '请选择一条记录',
- type: 'warning',
- duration: 1000
- });
- return;
- }
- let showStatus = 0;
- if (this.operateType === 'showBrand') {
- showStatus = 1;
- } else if (this.operateType === 'hideBrand') {
- showStatus = 0;
- } else {
- this.$message({
- message: '请选择批量操作类型',
- type: 'warning',
- duration: 1000
- });
- return;
- }
- let ids = [];
- for (let i = 0; i < this.multipleSelection.length; i++) {
- ids.push(this.multipleSelection[i].id);
- }
- let data = new URLSearchParams();
- data.append("ids", ids);
- data.append("showStatus", showStatus);
- updateShowStatus(data).then(response => {
- this.getList();
- this.$message({
- message: '修改成功',
- type: 'success',
- duration: 1000
- });
- });
- },
- addBrand() {
- this.$router.push({path: '/pms/addBrand'})
- }
- }
- }
- </script>
- <style rel="stylesheet/scss" lang="scss" scoped>
- </style>
|