123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217 |
- <template>
- <div class="product-select">
- <el-form :inline="true" :model="formData" class="demo-form-inline">
- <el-form-item label="">
- <el-input v-model="formData.keyword" maxlength="20" placeholder="店铺名称/商品ID/商品分组"></el-input>
- </el-form-item>
- <el-form-item label="官方分类">
- <el-cascader
- ref="cascader"
- v-model="formData.categoryId"
- :options="categoryList"
- :props="{ checkStrictly: true,label: 'categoryName',value: 'id',children: 'childs' }"
- clearable></el-cascader>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" @click="onSubmit">查询</el-button>
- </el-form-item>
- </el-form>
- <el-table
- ref="multipleTable"
- :data="tableData"
- max-height="500"
- border
- row-key="productId"
- @selection-change="handleSelectionChange"
- style="width: 100%">
- <el-table-column
- v-if="isMultiple"
- width="40"
- type="selection"
- :reserve-selection="true"
- fixed="left"
- >
- </el-table-column>
- <el-table-column label="" width="40" align="center" v-else>
- <template slot-scope="scope">
- <el-radio v-model="tableRadio" :label="scope.row"><i></i></el-radio>
- </template>
- </el-table-column>
- <el-table-column label="产品主图" width="180" align="center">
- <template slot-scope="scope">
- <el-image
- style="width: 80px; height: 80px"
- :src="scope.row.image"
- fit="contain"></el-image>
- </template>
- </el-table-column>
- <el-table-column
- prop="productName"
- label="产品名称"
- width="180">
- </el-table-column>
- <el-table-column
- prop="productId"
- label="产品ID">
- </el-table-column>
- <el-table-column
- prop="price"
- label="售价">
- </el-table-column>
- <el-table-column
- prop="originalPrice"
- label="原价">
- </el-table-column>
- <el-table-column
- prop="stockNumber"
- label="库存">
- </el-table-column>
- <el-table-column
- prop="number"
- label="销量">
- </el-table-column>
- </el-table>
- <el-pagination
- @size-change="handleSizeChange"
- @current-change="handleCurrentChange"
- :current-page="currentPage"
- :hide-on-single-page="true"
- :page-sizes="[10, 20, 50, 100]"
- :page-size="pageSize"
- layout="total, sizes, prev, pager, next, jumper"
- :total="total">
- </el-pagination>
- </div>
- </template>
- <script>
- import api from '@@/components/canvasShow/config/api'
- import {sendReqMixin} from '@@/components/canvasShow/config/mixin'
- import {checkEmptyChild} from '@@/config/common'
- import Cookies from 'js-cookie'
- import { mapGetters } from 'vuex'
- export default {
- name: 'product-select',
- mixins: [sendReqMixin],
- data () {
- return {
- tableRadio: '',
- formData: {
- keyword: '',
- status: '',
- categoryId: ''
- },
- currentPage: 1,
- total: 0,
- pageSize: 10,
- categoryList: [],
- tableData: [],
- multipleSelection: []
- }
- },
- props: {
- selectedRows: {
- type: Array,
- default: () => []
- },
- isMultiple: {
- type: Boolean,
- default: false
- }
- },
- mounted () {
- this.getCategory()
- this.getTableData()
- },
- computed: {
- ...mapGetters([
- 'typeId'
- ])
- },
- methods: {
-
- getCategory () {
- var _this = this
- let params = {
- url: api.getClassify,
- method: 'GET'
- }
- this.sendReq(params, (res) => {
- _this.categoryList = res.data
- checkEmptyChild(_this.categoryList)
- })
- },
-
- getTableData () {
- var _this = this
- var paramsUrl = `${api.getProducts}?page=${this.currentPage}&pageSize=${this.pageSize}&shelveState=1`
- if (this.formData.keyword) {
- paramsUrl += `&search=${this.formData.keyword}`
- }
- let shopId = parseInt(Cookies.get('shopID'))
- if (shopId && this.typeId===3) {
- paramsUrl += `&shopId=${shopId}`
- }
- let nodesObj = this.$refs['cascader'].getCheckedNodes()
- if (nodesObj && nodesObj.length !== 0) {
- var categoryId = nodesObj[0].value
- paramsUrl += `&classifyId=${categoryId}`
- }
- let params = {
- url: paramsUrl,
- method: 'GET'
- }
- this.sendReq(params, (res) => {
- _this.tableData = res.data.list
- _this.total = res.data.total
-
-
-
-
-
-
- })
- },
-
- onSubmit () {
- this.getTableData()
- },
-
- handleSizeChange (val) {
- this.pageSize = val
- this.getTableData()
- },
-
- handleCurrentChange (val) {
- this.currentPage = val
- this.getTableData()
- },
-
- handleSelectionChange(val) {
- this.multipleSelection = val
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .product-select{
- .el-pagination{
- padding: 0px;
- margin-top: 30px;
- }
- .el-table{
- .img{
- width: 80px;
- height: 80px;
- }
- }
- }
- </style>
|