| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <GlobalWindow |
| | | :title="title" |
| | | width="80%" |
| | | :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;"> |
| | | <el-input v-model="searchForm.name" placeholder="请è¾å
¥åç§°" @keypress.enter.native="search"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="" prop="code" style="display: inline-block;margin-right: 30px;"> |
| | | <el-input v-model="searchForm.code" placeholder="请è¾å
¥é¨åºID" @keypress.enter.native="search"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="" prop="saleType" style="display: inline-block;margin-right: 30px;"> |
| | | <!-- 0æ£å¸¸ 1ç¦ç¨ --> |
| | | <el-select v-model="searchForm.saleType" placeholder="é宿¨¡å¼" @change="search" > |
| | | <el-option :key="0" :value="0" label="å¹³å°éºè´§" ></el-option> |
| | | <el-option :key="1" :value="1" label="èªä¸»éè´" ></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" placeholder="è¯·éæ©ç¶æ" @change="search" > |
| | | <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> |
| | | <div :style="'display: flex;height:'+tabelHeight+'px;'"> |
| | | <el-table |
| | | 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="name" label="åç§°" fixed align="center" min-width="100px"> </el-table-column> |
| | | <el-table-column prop="code" label="é¨åºID" align="center" min-width="100px"></el-table-column> |
| | | <el-table-column prop="bigAreaName" label="æå±åºå" align="center" min-width="100px"></el-table-column> |
| | | <el-table-column prop="areaFullName" label="çå¸åº" align="center" min-width="150px" show-overflow-tooltip> |
| | | <template slot-scope="{row}"> |
| | | <span v-if="row.areas!=null">{{(row.areas.provinceName||'') + (row.areas.cityName||'') + (row.areas.name||'')}}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="saleType" label="é宿¨¡å¼" align="center" min-width="150px"> |
| | | <template slot-scope="{row}"> |
| | | {{ row.saleType == 1?'èªä¸»éè´':'å¹³å°éºè´§'}} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="status" label="ç¶æ" align="center" min-width="100px" fixed="right"> |
| | | <template slot-scope="{row}"> |
| | | {{ row.status == 1?'ç¦ç¨':'æ£å¸¸'}} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="price" label="éå®ä»·" align="center" min-width="100px" fixed="right"> |
| | | {{ price}} |
| | | </el-table-column> |
| | | <el-table-column prop="goodsPrice" label="ä¾è´§ä»·" align="center" min-width="100px" fixed="right"> |
| | | <template slot-scope="scope"> |
| | | <el-input v-if="scope.row.isPriceSelected" v-model="scope.row.goodsPrice" |
| | | @focus="focusEvent(scope.row,scope.$index,scope.column)" |
| | | @blur="blurEvent(scope.row,scope.$index,scope.column)" v-focus></el-input> |
| | | <p style="cursor: pointer" class="blue" title="ç¹å»ç¼è¾" @click="cellClick(scope.row, scope.column)" v-else>{{scope.row.goodsPrice || 'æªè®¾ç½®' }}</p> |
| | | </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' |
| | | export default { |
| | | name: 'OperaShopGoodsWindow', |
| | | extends: BaseTable, |
| | | components: { GlobalWindow, TableLayout, Pagination }, |
| | | data () { |
| | | return { |
| | | activeName: 'first', |
| | | title: '', |
| | | price : null, |
| | | visible: false, |
| | | tabelHeight: null, |
| | | // æç´¢ |
| | | searchForm: { |
| | | name: '', |
| | | goodsId: null, |
| | | username: '', |
| | | status: '', |
| | | saleType: '', |
| | | isrec: '' |
| | | } |
| | | } |
| | | }, |
| | | mounted () { |
| | | window.addEventListener('resize', this.handleResize) |
| | | }, |
| | | beforeDestroy () { |
| | | window.removeEventListener('resize', this.handleResize) |
| | | }, |
| | | created () { |
| | | this.config({ |
| | | module: 'ååä¿¡æ¯è¡¨', |
| | | api: '/business/shop', |
| | | 'field.id': 'id', |
| | | 'field.main': 'id' |
| | | }) |
| | | this.handleResize() |
| | | }, |
| | | directives: { |
| | | focus: { |
| | | inserted: function (el) { |
| | | el.querySelector('input').focus() |
| | | } |
| | | } |
| | | }, |
| | | methods: { |
| | | handleResize () { |
| | | this.tabelHeight = window.innerHeight - 300 |
| | | }, |
| | | open (title, goods) { |
| | | this.title = title |
| | | this.visible = true |
| | | this.price = goods.skuPrice |
| | | this.searchForm.goodsId = goods.id |
| | | this.search() |
| | | }, |
| | | 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.oldGoodsPrice = row.goodsPrice |
| | | }, |
| | | blurEvent (row, curIndex, column) { |
| | | if(this.price <= row.goodsPrice) { |
| | | this.$tip.error('ä¾è´§ä»·ä¸è½å¤§äºéå®ä»·') |
| | | row.isPriceSelected = !row.isPriceSelected |
| | | row.goodsPrice = row.oldGoodsPrice// ä»·æ ¼è¿å |
| | | return |
| | | } |
| | | if( row.goodsPrice == row.oldGoodsPrice){ |
| | | row.isPriceSelected = !row.isPriceSelected |
| | | return; |
| | | } |
| | | this.api.setGoodsPrice({ |
| | | id: row.id, |
| | | goodsId: this.searchForm.goodsId, |
| | | goodsPrice: row.goodsPrice |
| | | }).then(res => { |
| | | row.oldGoodsPrice = row.goodsPrice |
| | | this.$tip.success('ä¿®æ¹æå') |
| | | this.$emit('success') |
| | | }).catch(e => { |
| | | row.goodsPrice = row.oldGoodsPrice// ä»·æ ¼è¿å |
| | | }).finally(() => { |
| | | row.isPriceSelected = !row.isPriceSelected |
| | | }) |
| | | }, |
| | | handleClick (val) { |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | <style scoped> |
| | | .table-pagination{ |
| | | position: fixed !important; |
| | | bottom: 50px; |
| | | } |
| | | </style> |