| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <GlobalWindow |
| | | :title="title" |
| | | width="100%" |
| | | :visible.sync="visible" |
| | | > |
| | | <TableLayout > |
| | | <!-- æç´¢è¡¨å --> |
| | | <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="10px" style="display: block;" > |
| | | <el-form-item label="" prop="name" style="display: inline-block;margin-right: 30px;width: 180px"> |
| | | <el-input v-model="searchForm.name" placeholder="åååç§°" @keypress.enter.native="search"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="" prop="id" style="display: inline-block;margin-right: 30px;;width: 180px"> |
| | | <el-input v-model="searchForm.id" placeholder="ååID" @keypress.enter.native="search"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="" prop="categoryId" style="display: inline-block;margin-right: 30px;"> |
| | | <!-- 0æ£å¸¸ 1ç¦ç¨ --> |
| | | <el-select |
| | | v-model="searchForm.categoryId" |
| | | style="width: 120px" |
| | | placeholder="æå±åç±»" |
| | | clearable |
| | | @change="search" |
| | | > |
| | | <el-option |
| | | v-for="item in labels" |
| | | :key="item.id" |
| | | :value="item.id" |
| | | :label="item.name" |
| | | ></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="" prop="brandId" style="display: inline-block;margin-right: 30px;"> |
| | | <!-- 0æ£å¸¸ 1ç¦ç¨ --> |
| | | <el-select |
| | | v-model="searchForm.brandId" |
| | | style="width: 120px" |
| | | placeholder="æå±åç" |
| | | clearable |
| | | @change="search" |
| | | > |
| | | <el-option |
| | | v-for="item in brands" |
| | | :key="item.id" |
| | | :value="item.id" |
| | | :label="item.name" |
| | | ></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="" prop="status" style="display: inline-block;margin-right: 30px;"> |
| | | <!-- 0æ£å¸¸ 1ç¦ç¨ --> |
| | | <el-select |
| | | v-model="searchForm.status" |
| | | style="width: 120px" |
| | | @change="search" |
| | | clearable |
| | | placeholder="ä¸ä¸æ¶ç¶æ" |
| | | > |
| | | <el-option :key="0" :value="0" label="䏿¶"></el-option> |
| | | <el-option :key="1" :value="1" label="䏿¶"></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <section> |
| | | <el-button type="primary" @click="search">æç´¢</el-button> |
| | | <el-button @click="reset">éç½®</el-button> |
| | | </section> |
| | | </el-form> |
| | | <!-- è¡¨æ ¼åå页 --> |
| | | <template v-slot:table-wrap> |
| | | <!-- <ul class="toolbar" > |
| | | <li><el-button type="primary" icon="el-icon-plus" @click="setPriceBatch" >æ¹éå®ä»·</el-button></li> |
| | | </ul>--> |
| | | <div :style="'display: flex;height:'+tabelHeight+'px;'"> |
| | | <el-table |
| | | :height="tabelHeight" |
| | | v-loading="isWorking.search" |
| | | :data="tableData.list" |
| | | stripe |
| | | border |
| | | @selection-change="handleSelectionChange" |
| | | > |
| | | <!-- |
| | | <el-table-column type="selection" width="55"></el-table-column> |
| | | --> |
| | | <el-table-column prop="imgurl" label="ååä¿¡æ¯" min-width="80px"> |
| | | <template slot-scope="{row}"> |
| | | <el-image style="width: 50px;height: 50px;" v-if="row.imgurl && row.imgurl!=''" :src="row.resourcePath+row.imgurl" :preview-src-list="[row.resourcePath+row.imgurl]"></el-image> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="id" label="ååID" min-width="120px" ></el-table-column> |
| | | <el-table-column prop="name" label="åååç§°" min-width="180px" show-overflow-tooltip></el-table-column> |
| | | <el-table-column prop="categoryName" label="æå±åç±»" min-width="120px"></el-table-column> |
| | | <el-table-column prop="brandName" label="æå±åç" min-width="120px"></el-table-column> |
| | | <el-table-column prop="stockNum" label="å©ä½åºåé" min-width="100px"></el-table-column> |
| | | <el-table-column prop="status" label="ä¸ä¸æ¶ç¶æ" min-width="100px" align="center"> |
| | | <template slot-scope="{row}"> |
| | | <span v-if="row.status ==1" class="red">已䏿¶</span> |
| | | <span v-else class="green">已䏿¶</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="price" label="å±ç¤ºä»·æ ¼" min-width="100px" align="center"></el-table-column> |
| | | <el-table-column prop="skuPrice" label="éå®ä»·(å
)" fixed="right" min-width="100px" align="center"> |
| | | <template slot-scope="{row}"> |
| | | <span class="orange">{{ row.skuPrice }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="shopPrice" label="ä¾è´§ä»·(å
)" align="center" min-width="100px" fixed="right"> |
| | | <template slot-scope="scope"> |
| | | <el-input v-if="scope.row.isPriceSelected" v-model="scope.row.shopPrice" |
| | | @focus="focusEvent(scope.row,scope.$index,scope.column)" |
| | | @blur="blurEvent(scope.row,scope.$index,scope.column)" v-focus></el-input> |
| | | <p :style="'cursor: pointer;'+((scope.row.skuPrice||0) <= (scope.row.shopPrice||0)?'color: red':'')+';'" class="blue" title="ç¹å»ç¼è¾" @click="cellClick(scope.row, scope.column)" v-else> |
| | | {{scope.row.shopPrice || 'æªè®¾ç½®' }} |
| | | <i v-if="(scope.row.skuPrice||0) <= (scope.row.shopPrice||0)" class="el-icon-warning" style="color: red"></i> |
| | | </p> |
| | | </template> |
| | | </el-table-column> |
| | | <!-- <el-table-column |
| | | label="æä½" |
| | | min-width="160" |
| | | fixed="right" |
| | | > |
| | | <template slot-scope="{row}"> |
| | | <el-button type="text" v-permissions="['business:goods:update']" @click="setPrice(row)">è®¾ç½®ä»·æ ¼</el-button> |
| | | </template> |
| | | </el-table-column>--> |
| | | </el-table> |
| | | <pagination |
| | | @size-change="handleSizeChange" |
| | | @current-change="handlePageChange" |
| | | :pagination="tableData.pagination" |
| | | > |
| | | </pagination> |
| | | </div> |
| | | </template> |
| | | </TableLayout> |
| | | <template v-slot:footer> |
| | | <el-button @click="visible=false">è¿å</el-button> |
| | | </template> |
| | | </GlobalWindow> |
| | | </template> |
| | | |
| | | <script> |
| | | import GlobalWindow from '@/components/common/GlobalWindow' |
| | | import BaseTable from '@/components/base/BaseTable' |
| | | import TableLayout from '@/layouts/TableLayout' |
| | | import Pagination from '@/components/common/Pagination' |
| | | import { findAll as labelList } from '@/api/business/labels' |
| | | import { setGoodsPrice } from '@/api/business/shop' |
| | | export default { |
| | | name: 'OperaShopGoodsWindow', |
| | | extends: BaseTable, |
| | | components: { GlobalWindow, TableLayout, Pagination }, |
| | | data () { |
| | | return { |
| | | title: '', |
| | | price: null, |
| | | visible: false, |
| | | tabelHeight: null, |
| | | // æç´¢ |
| | | searchForm: { |
| | | id: '', |
| | | name: '', |
| | | shopId: null, |
| | | categoryId: '', |
| | | brandId: '', |
| | | // ç±»å 0å¹³å°åå 1åè±åå 2åå¡è®¡ååå |
| | | type: '0', // å¹³å°åå |
| | | status: 0, |
| | | labels: '' |
| | | }, |
| | | labels: [], |
| | | brands: [] |
| | | } |
| | | }, |
| | | mounted () { |
| | | window.addEventListener('resize', this.handleResize) |
| | | }, |
| | | beforeDestroy () { |
| | | window.removeEventListener('resize', this.handleResize) |
| | | }, |
| | | created: function () { |
| | | this.config({ |
| | | module: 'ååä¿¡æ¯è¡¨', |
| | | api: '/business/goods', |
| | | 'field.id': 'id', |
| | | 'field.main': 'id' |
| | | }) |
| | | this.handleResize() |
| | | labelList({ |
| | | type: 0 // åååç±» |
| | | }).then(res => { |
| | | this.labels = res |
| | | }) |
| | | labelList({ |
| | | type: 1 // åååç |
| | | }) |
| | | .then(res => { |
| | | this.brands = res |
| | | }) |
| | | }, |
| | | directives: { |
| | | focus: { |
| | | inserted: function (el) { |
| | | el.querySelector('input').focus() |
| | | } |
| | | } |
| | | }, |
| | | methods: { |
| | | setPrice (row) { |
| | | if (row.skuPrice == null) { |
| | | this.$tip.warning('请å
设置ååéå®ä»·ï¼') |
| | | return |
| | | } |
| | | console.log(row) |
| | | }, |
| | | setPriceBatch () { |
| | | }, |
| | | handleResize () { |
| | | this.tabelHeight = window.innerHeight - 400 |
| | | }, |
| | | open (title, info) { |
| | | this.title = title |
| | | this.visible = true |
| | | this.searchForm.shopId = info.id |
| | | this.search() |
| | | this.handleResize() |
| | | }, |
| | | handlePageChange: function (pageIndex) { |
| | | this.__checkApi() |
| | | this.tableData.pagination.pageIndex = pageIndex || this.tableData.pagination.pageIndex |
| | | this.isWorking.search = true |
| | | this.api.fetchList({ |
| | | page: this.tableData.pagination.pageIndex, |
| | | capacity: this.tableData.pagination.pageSize, |
| | | model: this.searchForm, |
| | | sorts: this.tableData.sorts |
| | | }) |
| | | .then(data => { |
| | | (data.records || []).forEach((item) => { |
| | | item.isPriceSelected = false |
| | | }) |
| | | this.tableData.list = data.records || [] |
| | | this.tableData.pagination.total = data.total |
| | | console.log(this.tableData.list) |
| | | }) |
| | | .catch(e => { |
| | | this.$tip.apiFailed(e) |
| | | }) |
| | | .finally(() => { |
| | | this.isWorking.search = false |
| | | }) |
| | | }, |
| | | cellClick (row, column) { |
| | | row.isPriceSelected = !row.isPriceSelected |
| | | }, |
| | | focusEvent (row, index, column) { |
| | | row.oldShopsPrice = row.shopPrice |
| | | }, |
| | | blurEvent (row, curIndex, column) { |
| | | if ( !row.skuPrice) { |
| | | this.$tip.error('ååéå®ä»·æªè®¾ç½®ï¼') |
| | | row.isPriceSelected = !row.isPriceSelected |
| | | row.shopPrice = row.oldShopsPrice// ä»·æ ¼è¿å |
| | | return |
| | | } |
| | | if ( row.skuPrice <= row.shopPrice) { |
| | | this.$tip.error('ä¾è´§ä»·ä¸è½å¤§äºéå®ä»·') |
| | | row.isPriceSelected = !row.isPriceSelected |
| | | row.shopPrice = row.oldShopsPrice// ä»·æ ¼è¿å |
| | | return |
| | | } |
| | | if (row.shopPrice == row.oldShopsPrice) { |
| | | row.isPriceSelected = !row.isPriceSelected |
| | | return |
| | | } |
| | | setGoodsPrice({ |
| | | id: this.searchForm.shopId, |
| | | goodsId: row.id, |
| | | goodsPrice: row.shopPrice |
| | | }).then(res => { |
| | | row.oldShopsPrice = row.shopPrice |
| | | this.$tip.success('ä¿®æ¹æå') |
| | | this.$emit('success') |
| | | }).catch(e => { |
| | | row.shopPrice = row.oldShopsPrice// ä»·æ ¼è¿å |
| | | }).finally(() => { |
| | | row.isPriceSelected = !row.isPriceSelected |
| | | }) |
| | | }, |
| | | handleClick (val) { |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | <style scoped> |
| | | .table-pagination{ |
| | | position: fixed !important; |
| | | bottom: 50px; |
| | | } |
| | | </style> |