You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
443 lines
14 KiB
443 lines
14 KiB
<template>
|
|
<div class="app-container">
|
|
<div v-show="viewState == 1">
|
|
<button-bar ref="btnbar" view-title="商品列表" :btndisabled="btndisabled" @btnhandle="btnHandle" />
|
|
<div class="main-content">
|
|
<div class="searchcon">
|
|
<el-button size="small" class="searchbtn" @click="clicksearchShow">
|
|
{{ searchxianshitit }}
|
|
</el-button>
|
|
<div v-show="isSearchShow" class="search">
|
|
<el-form :inline="true" class="tab-header">
|
|
<el-form-item label="商品名称">
|
|
<el-input v-model="queryParams.params.name" placeholder="" clearable />
|
|
</el-form-item>
|
|
|
|
</el-form>
|
|
<div class="btn" style="text-align: center;">
|
|
<el-button type="primary" size="small" icon="el-icon-search" @click="dosearch">查询</el-button>
|
|
<el-button type="primary" size="small" icon="el-icon-refresh" @click="resetQuery">重置</el-button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- Start 项目列表头部 -->
|
|
<div class="listtop">
|
|
<div class="tit" :hidden="false">商品列表</div>
|
|
</div>
|
|
<!-- End 项目列表头部 -->
|
|
<!-- Start 项目列表 -->
|
|
<div class="">
|
|
<el-table v-loading="tableLoading" :data="dataList" border style="width: 100%"
|
|
@selection-change="selectionLineChangeHandle">
|
|
<el-table-column width="50" type="selection" align="center" />
|
|
<el-table-column width="60" label="序号" type="index" :index="indexMethod" align="center" />
|
|
<el-table-column label="操作" align="center" width="80">
|
|
<template slot-scope="scope">
|
|
<el-button type="primary" size="mini" @click="toRelevancy(scope.row)">详情</el-button>
|
|
<!-- <el-button type="primary" size="mini" @click="toRelevancyInfo(scope.row)">删除</el-button> -->
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="是否可用" align="center" width="140">
|
|
<template slot-scope="scope">
|
|
<el-switch v-model="scope.row.isEnable" active-text="是" inactive-text="否" active-value="1"
|
|
inactive-value="2" @change="enableChange(scope.row.sid,scope.row.isEnable)" />
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column prop="goodsName" label="商品名称" align="center" />
|
|
<el-table-column prop="goodsCode" label="商品编码" align="center" />
|
|
<el-table-column prop="barCode" label="商品条码" align="center" />
|
|
<el-table-column prop="brandName" label="商品品牌" align="center" />
|
|
<el-table-column prop="typeName" label="商品类别" align="center" />
|
|
<el-table-column prop="goodsUnitName" label="商品单位" align="center" />
|
|
<el-table-column prop="manufacturerName" label="商品厂家" align="center" />
|
|
<el-table-column prop="nationalStandardCode" label="国标码" align="center" />
|
|
<el-table-column prop="taxRate" label="税率" align="center" />
|
|
</el-table>
|
|
</div>
|
|
<!-- End 项目列表 -->
|
|
<div class="pages">
|
|
<div class="tit" />
|
|
<!-- 翻页 -->
|
|
<pagination v-show="dataList.length > 0" :total="queryParams.total" :page.sync="queryParams.current"
|
|
:limit.sync="queryParams.size" class="pagination" @pagination="loadList" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- End 查询和其列表部分 -->
|
|
<!-- 新增修改部分组件 -->
|
|
<divAdd v-show="viewState == 2 || viewState == 3" ref="divadd" @doback="resetState" @reloadlist="loadList" />
|
|
<!-- 详情部分组件 -->
|
|
<divInfo v-show="viewState == 4" ref="divinfo" @doback="resetState" @reloadlist="loadList" />
|
|
|
|
<!-- 导入 -->
|
|
<el-dialog :visible.sync="dialogVisible" width="60%" :show-close="false">
|
|
<div style="margin-top: -40px;">
|
|
<el-button size="medium" type="text" style="font-weight: bold" @click="downLoad">下载商品导入明细模板</el-button>
|
|
|
|
</div>
|
|
<div style="margin-top: 10px;font-weight: bold">导入的EXCEL中的抬头的顺序和名字请保持一致!否则导入数据不正确。</div>
|
|
<div style="margin-top: 5px;font-weight: bold">导入之前,请仔细检查数据中不能存在"\这些特殊字符。</div>
|
|
<div style="margin-top: 5px;font-weight: bold">只能导入xls或者xlsx文件,如果导入内容较多,请耐心等待响应。</div>
|
|
<el-card class="box-card" style="margin-top: 10px;">
|
|
<div>
|
|
<el-upload ref="upload" class="upload-demo" accept=".xls,.xlsx" name="file" :action="updateAction"
|
|
:on-success="handleSuccess" :file-list="fileList" :auto-upload="false" :multiple="false" :limit="1"
|
|
:data="uploadData" :headers="headers">
|
|
<el-button slot="trigger" size="small" type="primary">选取文件</el-button>
|
|
<el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload">上传</el-button>
|
|
</el-upload>
|
|
</div>
|
|
<div>
|
|
<h3>文件上传结果</h3>
|
|
<el-card class="box-card">
|
|
<div>{{ uploadResultMesssage }}</div>
|
|
</el-card>
|
|
</div>
|
|
</el-card>
|
|
<div slot="footer" class="dialog-footer" style="text-align: center">
|
|
<el-button type="primary" size="small" @click="handleConfirm">确定</el-button>
|
|
<el-button size="small" @click="dialogVisible = false">取消</el-button>
|
|
</div>
|
|
</el-dialog>
|
|
|
|
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import req from '@/api/goods/goods.js'
|
|
import ButtonBar from '@/components/ButtonBar'
|
|
import Pagination from '@/components/pagination'
|
|
import pageye from '@/components/pagination/pageye'
|
|
import divAdd from './goodsAdd.vue'
|
|
import divInfo from './goodsInfo.vue'
|
|
export default {
|
|
components: {
|
|
ButtonBar,
|
|
Pagination,
|
|
pageye,
|
|
divAdd,
|
|
divInfo,
|
|
|
|
},
|
|
data() {
|
|
return {
|
|
dialogVisible: false,
|
|
btndisabled: false,
|
|
updateAction: process.env.VUE_APP_BASE_API + '/wms/apiadmin/base/basegoodsspu/importExcel',
|
|
fileList: [],
|
|
uploadSuccess: false,
|
|
uploadResultMesssage: '',
|
|
uploadData: {
|
|
sid: ''
|
|
},
|
|
headers: {
|
|
token: window.sessionStorage.getItem('token')
|
|
},
|
|
viewState: 1, // 1、列表 2、添加 3、修改 4、查看
|
|
isSearchShow: false,
|
|
searchxianshitit: '显示查询条件',
|
|
tableLoading: false,
|
|
dataList: [],
|
|
btnList: [{
|
|
type: 'success',
|
|
size: 'small',
|
|
icon: '',
|
|
btnKey: 'doImport',
|
|
btnLabel: '导入商品'
|
|
}, {
|
|
type: 'primary',
|
|
size: 'small',
|
|
icon: 'plus',
|
|
btnKey: 'toAdd',
|
|
btnLabel: '新增'
|
|
},
|
|
{
|
|
type: 'primary',
|
|
size: 'small',
|
|
icon: 'edit',
|
|
btnKey: 'toEdit',
|
|
btnLabel: '编辑'
|
|
},
|
|
{
|
|
type: 'danger',
|
|
size: 'small',
|
|
icon: 'plus',
|
|
btnKey: 'doDel',
|
|
btnLabel: '删除'
|
|
},
|
|
{
|
|
type: 'info',
|
|
size: 'small',
|
|
icon: 'cross',
|
|
btnKey: 'doClose',
|
|
btnLabel: '关闭'
|
|
}
|
|
],
|
|
queryParams: {
|
|
current: 1,
|
|
size: 10,
|
|
total: 0,
|
|
params: {
|
|
name: ''
|
|
}
|
|
},
|
|
sids: [],
|
|
selectionList: []
|
|
}
|
|
},
|
|
mounted() {
|
|
this.$refs['btnbar'].setButtonList(this.btnList)
|
|
},
|
|
created() {
|
|
this.loadList()
|
|
},
|
|
methods: {
|
|
downLoad() {
|
|
const loading = this.$loading({
|
|
lock: true,
|
|
text: 'Loading',
|
|
spinner: 'el-icon-loading',
|
|
background: 'rgba(0, 0, 0, 0.7)'
|
|
})
|
|
req.downloadExcel().then((resp) => {
|
|
loading.close()
|
|
const blob = new Blob([resp], {
|
|
type: 'application/vnd.ms-excel'
|
|
})
|
|
const fileName = '商品导入明细模版' + '.xls'
|
|
const elink = document.createElement('a')
|
|
elink.download = fileName
|
|
elink.style.display = 'nonde'
|
|
elink.href = URL.createObjectURL(blob)
|
|
document.body.appendChild(elink)
|
|
elink.click()
|
|
URL.revokeObjectURL(elink.href)
|
|
document.body.removeChild(elink)
|
|
}).catch(() => {
|
|
loading.close()
|
|
})
|
|
},
|
|
submitUpload() {
|
|
this.$refs.upload.submit()
|
|
},
|
|
handleSuccess(resp, file, fileList) {
|
|
const _this = this
|
|
_this.uploadResultMesssage = resp.msg
|
|
_this.uploadSuccess = resp.success
|
|
|
|
},
|
|
handleConfirm() {
|
|
if (!this.uploadSuccess) {
|
|
this.$message({
|
|
showClose: true,
|
|
type: 'error',
|
|
message: '请先上传商品导入明细'
|
|
})
|
|
return
|
|
}
|
|
this.dialogVisible = false
|
|
this.loadList()
|
|
},
|
|
// 搜索条件效果
|
|
clicksearchShow() {
|
|
this.isSearchShow = !this.isSearchShow
|
|
if (this.isSearchShow) {
|
|
this.searchxianshitit = '隐藏查询条件'
|
|
} else {
|
|
this.searchxianshitit = '显示查询条件'
|
|
}
|
|
},
|
|
btnHandle(btnKey) {
|
|
switch (btnKey) {
|
|
case "doImport":
|
|
this.doImport()
|
|
break
|
|
case 'toAdd':
|
|
this.toAdd()
|
|
break
|
|
case 'toEdit':
|
|
this.toEdit()
|
|
break
|
|
case 'doDel':
|
|
this.doDel()
|
|
break
|
|
case 'doClose':
|
|
this.doClose()
|
|
break
|
|
default:
|
|
break
|
|
}
|
|
},
|
|
selectionLineChangeHandle(val) {
|
|
console.log("val", val);
|
|
|
|
this.selectionList = val
|
|
const aa = []
|
|
val.forEach(element => {
|
|
aa.push(element.sid)
|
|
})
|
|
this.sids = aa
|
|
},
|
|
loadList() {
|
|
this.tableLoading = true
|
|
req.listPage(this.queryParams).then((resp) => {
|
|
this.tableLoading = false
|
|
if (resp.success) {
|
|
const data = resp.data
|
|
this.queryParams.total = data.total
|
|
this.dataList = data.records
|
|
} else {
|
|
// 根据resp.code进行异常情况处理
|
|
this.dataList = []
|
|
this.queryParams.total = 0
|
|
}
|
|
}).catch(() => {
|
|
this.tableLoading = false
|
|
})
|
|
},
|
|
|
|
// 序号
|
|
indexMethod(index) {
|
|
var pagestart = (this.queryParams.current - 1) * this.queryParams.size
|
|
var pageindex = index + 1 + pagestart
|
|
return pageindex
|
|
},
|
|
dosearch() {
|
|
this.queryParams.current = 1
|
|
this.loadList()
|
|
},
|
|
resetQuery() {
|
|
this.queryParams = {
|
|
current: 1,
|
|
size: 10,
|
|
total: 0,
|
|
params: {
|
|
name: ''
|
|
}
|
|
}
|
|
this.loadList()
|
|
},
|
|
doImport() {
|
|
this.dialogVisible = true
|
|
},
|
|
toAdd() {
|
|
this.viewState = 2
|
|
this.$refs['divadd'].showAdd()
|
|
},
|
|
toEdit() {
|
|
|
|
if (this.selectionList.length != 1) {
|
|
this.$message({
|
|
type: 'warning',
|
|
message: "请选择一条数据。",
|
|
showClose: true
|
|
})
|
|
return
|
|
}
|
|
|
|
this.viewState = 3
|
|
this.$refs['divadd'].showEdit(this.selectionList[0])
|
|
},
|
|
|
|
doDel() {
|
|
|
|
if (this.sids.length > 0) {
|
|
const tip = '请确认是否删除所选 ' + this.sids.length + ' 条记录?'
|
|
this.$confirm(tip, '提示', {
|
|
confirmButtonText: '确定',
|
|
cancelButtonText: '取消',
|
|
type: 'warning'
|
|
}).then(() => {
|
|
const loading = this.$loading({
|
|
lock: true,
|
|
text: 'Loading',
|
|
spinner: 'el-icon-loading',
|
|
background: 'rgba(0, 0, 0, 0.7)'
|
|
})
|
|
req.deleteBySids(this.sids).then((resp) => {
|
|
loading.close()
|
|
if (resp.success) {
|
|
this.$message({
|
|
type: 'success',
|
|
message: resp.msg,
|
|
showClose: true
|
|
})
|
|
this.loadList()
|
|
} else {
|
|
// 根据resp.code进行异常情况处理
|
|
}
|
|
}).catch(e => {
|
|
loading.close()
|
|
})
|
|
}).catch(() => {})
|
|
} else {
|
|
this.$message({
|
|
showClose: true,
|
|
message: '请至少选择一条记录进行删除操作'
|
|
})
|
|
}
|
|
},
|
|
|
|
doClose() {
|
|
this.$store.dispatch('tagsView/delView', this.$route)
|
|
this.$router.go(-1)
|
|
},
|
|
toRelevancy(row) {
|
|
this.viewState = 4
|
|
this.$refs['divinfo'].showEdit(row)
|
|
},
|
|
toRelevancyInfo(row) {
|
|
const tip = '请确认是否删除所选品牌?'
|
|
this.$confirm(tip, '提示', {
|
|
confirmButtonText: '确定',
|
|
cancelButtonText: '取消',
|
|
type: 'warning'
|
|
}).then(() => {
|
|
const loading = this.$loading({
|
|
lock: true,
|
|
text: 'Loading',
|
|
spinner: 'el-icon-loading',
|
|
background: 'rgba(0, 0, 0, 0.7)'
|
|
})
|
|
req.deleteGoods(row.sid).then((resp) => {
|
|
loading.close()
|
|
if (resp.success) {
|
|
this.$message({
|
|
type: 'success',
|
|
message: resp.msg,
|
|
showClose: true
|
|
})
|
|
this.loadList()
|
|
} else {
|
|
// 根据resp.code进行异常情况处理
|
|
}
|
|
}).catch(e => {
|
|
loading.close()
|
|
})
|
|
}).catch(() => {})
|
|
},
|
|
resetState() {
|
|
this.viewState = 1
|
|
},
|
|
enableChange(sid, state) {
|
|
console.log('sid', sid)
|
|
console.log('state', state)
|
|
req.updateIsEnable(sid, state).then((resp) => {
|
|
if (resp.success) {
|
|
this.$message({
|
|
type: 'success',
|
|
message: '状态已更新',
|
|
showClose: true
|
|
})
|
|
} else { // 根据resp.code进行异常情况处理
|
|
}
|
|
}).catch(e => {
|
|
console.log(e)
|
|
})
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
<style scoped>
|
|
</style>
|
|
|