| ¶Ô±ÈÐÂÎļþ |
| | |
| | | |
| | | <template> |
| | | <TableLayout :permissions="['business:basegoods:query']"> |
| | | <!-- æç´¢è¡¨å --> |
| | | <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" inline> |
| | | <el-form-item label="åååç§°" prop="name"> |
| | | <el-input v-model="searchForm.name" placeholder="请è¾å
¥åååç§°" @keypress.enter.native="search"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="ååID" prop="id"> |
| | | <el-input v-model="searchForm.id" placeholder="请è¾å
¥ååID" @keypress.enter.native="search"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="ç±»å«" prop="categoryId"> |
| | | <el-select v-model="searchForm.categoryId" clearable placeholder="è¯·éæ©"> |
| | | <el-option v-for="item in categoryList" :key="item.id" :label="item.name" :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | <!-- <el-input v-model="searchForm.categoryId" placeholder="请è¾å
¥æå±åç±»ç¼ç " @keypress.enter.native="search"></el-input> --> |
| | | </el-form-item> |
| | | <el-form-item label="åç" prop="brandId"> |
| | | <el-select v-model="searchForm.brandId" clearable placeholder="è¯·éæ©"> |
| | | <el-option v-for="item in brandList" :key="item.id" :label="item.name" :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | <!-- <el-input v-model="searchForm.brandId" placeholder="请è¾å
¥æå±åçç¼ç " @keypress.enter.native="search"></el-input> --> |
| | | </el-form-item> |
| | | <el-form-item label="ç¶æ" prop="status"> |
| | | <el-select v-model="searchForm.status" clearable placeholder="è¯·éæ©"> |
| | | <el-option v-for="item in statusList" :key="item.id" :label="item.name" :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | <!-- <el-input v-model="searchForm.status" placeholder="请è¾å
¥ç¶æ 0å¯ç¨ 1ç¦ç¨" @keypress.enter.native="search"></el-input> --> |
| | | </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" v-permissions="['business:basegoods:create', 'business:basegoods:delete']"> |
| | | <li v-permissions="['business:basegoods:create']"> |
| | | <el-button type="primary" @click="$refs.operaGoodsWindow.open('æ°å»ºåå')" icon="el-icon-plus">æ°å»º</el-button> |
| | | </li> |
| | | <!-- <el-button type="primary" :loading="isWorking.export" |
| | | @click="$refs.selectProduct.open('鿩平å°åå')">鿩平å°åå</el-button> --> |
| | | <li v-permissions="['business:basegoods:exportExcel', 'business:goods:delete']"> |
| | | <ImportButton text="导å
¥" template-name="goods_import_modle.xlsx" |
| | | template-path="/template/goods_import_modle.xlsx" action="/business/baseGoods/importExcel" |
| | | @success="search" /> |
| | | </li> |
| | | <li> |
| | | <el-button type="primary" :loading="isWorking.export" @click="bulkOperation(0)">æ¹é䏿¶</el-button> |
| | | </li> |
| | | <li> |
| | | <el-button type="primary" :loading="isWorking.export" @click="bulkOperation(1)">æ¹é䏿¶</el-button> |
| | | </li> |
| | | <li v-permissions="['business:goods:delete']"> |
| | | <el-button type="danger" @click="deleteByIdInBatch">æ¹éå é¤</el-button> |
| | | </li> |
| | | </ul> |
| | | <el-table v-loading="isWorking.search" :data="tableData.list" stripe border :header-cell-style="rowStyle" |
| | | :cell-style="rowStyle" @selection-change="handleSelectionChange"> |
| | | <el-table-column type="selection" width="55"></el-table-column> |
| | | <el-table-column prop="id" label="ååID" min-width="100px"></el-table-column> |
| | | <el-table-column prop="name" label="åååç§°/åå·" min-width="200px"> |
| | | <template slot-scope="{row}"> |
| | | <div style="display: flex; align-items: center;"> |
| | | <div style="width: 70px; height: 70px; flex-shrink: 0;"> |
| | | <el-image v-if="row.imgurl" style="width: 70px; height: 70px" :src="row.fullImgUrl" |
| | | :preview-src-list="[row.fullImgUrl]" fit="cover"></el-image> |
| | | </div> |
| | | <span style="margin-left: 15px">{{ row.name }}</span> |
| | | </div> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="brandName" label="åç" min-width="100px"></el-table-column> |
| | | <el-table-column prop="categoryName" label="ç±»å«" min-width="100px"></el-table-column> |
| | | <el-table-column prop="zdPrice" label="æå¯¼ä»·ï¼å
ï¼" min-width="100px"></el-table-column> |
| | | <el-table-column prop="jdPrice" label="éè´ä»·(å
)" min-width="100px"></el-table-column> |
| | | <el-table-column prop="price" label="éå®ä»·(å
)" min-width="100px"></el-table-column> |
| | | <el-table-column prop="createDate" label="å建æ¶é´" min-width="100px"></el-table-column> |
| | | <el-table-column prop="status" v-if="containPermissions(['business:basegoods:update'])" label="ç¶æ" min-width="100px"> |
| | | <template slot-scope="{row}"> |
| | | <el-switch v-model="row.status" @change="changeStatus(row)" active-color="#13ce66" inactive-color="#ff4949" |
| | | :active-value="0" :inactive-value="1"> |
| | | </el-switch> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column v-if="containPermissions(['business:basegoods:update', 'business:basegoods:delete'])" label="æä½" |
| | | min-width="120" fixed="right"> |
| | | <template slot-scope="{row}"> |
| | | <el-button type="text" @click="edit(row.id)" icon="el-icon-edit" |
| | | v-permissions="['business:basegoods:update']">ç¼è¾</el-button> |
| | | <el-button type="text" @click="deleteById(row)" icon="el-icon-delete" |
| | | v-permissions="['business:basegoods:delete']">å é¤</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <pagination @size-change="handleSizeChange" @current-change="handlePageChange" :pagination="tableData.pagination"> |
| | | </pagination> |
| | | </template> |
| | | <!-- æ°å»º/ä¿®æ¹ --> |
| | | <OperaGoodsWindow ref="operaGoodsWindow" @success="handlePageChange" /> |
| | | <!-- 鿩平å°åå --> |
| | | <selectProduct ref="selectProduct" @success="handlePageChange" @result="search" /> |
| | | </TableLayout> |
| | | </template> |
| | | |
| | | <script> |
| | | import BaseTable from '@/components/base/BaseTable' |
| | | import TableLayout from '@/layouts/TableLayout' |
| | | import Pagination from '@/components/common/Pagination' |
| | | import OperaGoodsWindow from '@/components/business/OperaGoodsWindow' |
| | | import selectProduct from '@/components/business/selectProduct' |
| | | import ImportButton from '@/components/common/ImportButton' |
| | | import { brand, baseCategory } from '@/api/system/common.js' |
| | | import { updateStatus, queryById, exportDoc } from '@/api/business/goods.js' |
| | | export default { |
| | | name: 'Goods', |
| | | extends: BaseTable, |
| | | components: { TableLayout, Pagination, OperaGoodsWindow, selectProduct, ImportButton }, |
| | | data() { |
| | | return { |
| | | // æç´¢ |
| | | searchForm: { |
| | | id: '', |
| | | name: '', |
| | | status: '', |
| | | categoryId: '', |
| | | brandId: '' |
| | | }, |
| | | ids: '', |
| | | idList: [], |
| | | categoryList: [], |
| | | brandList: [], |
| | | statusList: [ |
| | | { name: 'å¯ç¨', id: 0 }, |
| | | { name: 'ç¦ç¨', id: 1 } |
| | | ] |
| | | } |
| | | }, |
| | | provide() { |
| | | return { |
| | | brandList: () => this.brandList, |
| | | categoryList: () => this.categoryList |
| | | } |
| | | }, |
| | | created() { |
| | | this.config({ |
| | | module: 'åå', |
| | | api: '/business/goods', |
| | | 'field.id': 'id', |
| | | 'field.main': 'name' |
| | | }) |
| | | this.search() |
| | | this.getbrand() |
| | | this.getcategory() |
| | | }, |
| | | methods: { |
| | | // handleSelectionChange(e) { |
| | | // let arr = e.map(item => item.id) |
| | | // this.ids = arr.join(',') |
| | | // this.idList = arr; |
| | | // }, |
| | | // æ¹éä¸ä¸æ¶ |
| | | bulkOperation(type) { |
| | | if (this.tableData.selectedRows.length === 0) { |
| | | this.$tip.warning('请è³å°éæ©ä¸æ¡æ°æ®') |
| | | return |
| | | } |
| | | let idList = this.tableData.selectedRows.map(item => item.id) |
| | | updateStatus({ |
| | | idList, |
| | | status: type |
| | | }).then(res => { |
| | | this.$tip.apiSuccess('æä½æå'); |
| | | // this.$message.success({ message:res.message }) |
| | | this.handlePageChange() |
| | | }) |
| | | }, |
| | | downloadFile() { |
| | | exportDoc({}) |
| | | .then(response => { |
| | | this.download(response) |
| | | }) |
| | | .catch(e => { |
| | | this.$tip.apiFailed(e) |
| | | }) |
| | | }, |
| | | rowStyle() { |
| | | return "text-align:center"; |
| | | }, |
| | | edit(id) { |
| | | queryById(id) |
| | | .then(res => { |
| | | this.$refs.operaGoodsWindow.open('ç¼è¾åå', res) |
| | | }) |
| | | }, |
| | | changeStatus(item) { |
| | | updateStatus({ |
| | | idList: [item.id], |
| | | status: item.status |
| | | }).then(res => { |
| | | this.$tip.apiSuccess('æ´æ°æå') |
| | | }) |
| | | .catch (err => { |
| | | this.$message.error(err) |
| | | } ) |
| | | .finally(() => { |
| | | this.handlePageChange() |
| | | }) |
| | | }, |
| | | getbrand() { |
| | | brand({ type: 1 }) |
| | | .then(res => { |
| | | this.brandList = res |
| | | }) |
| | | }, |
| | | getcategory() { |
| | | baseCategory({}) |
| | | .then(res => { |
| | | this.categoryList = res |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |