<template>
|
<div>
|
<list-condition-template ref="table" v-loading="isLoading" :form="listQuery" :formLabel="formLabel"
|
:tableData="tableData" :total="total"
|
@page-info-change="handlePageInfoChange">
|
<template slot="otherElement">
|
<el-col :span="6" :offset="0">
|
<el-form-item>
|
<el-button size="mini" type="primary" @click="queryData">查询</el-button>
|
<el-button size="mini" @click="resetQuery">重置</el-button>
|
</el-form-item>
|
</el-col>
|
</template>
|
<template slot="operationSection">
|
<el-button size="mini" type="success" @click="addItem">新增</el-button>
|
<el-button size="mini" type="warning" @click="importMemberInfo">导入</el-button>
|
<el-button size="mini" @click="downTemplate">下载模板</el-button>
|
<el-button size="mini" icon="el-icon-download" type="primary" @click="exportData">导出
|
</el-button>
|
</template>
|
<template slot="columns">
|
<el-table-column label="商品主编码" prop="spuNum" show-overflow-tooltip width="250px">
|
</el-table-column>
|
<el-table-column label="存货辅助核算编码" prop="auxiliaryCode" show-overflow-tooltip width="250px">
|
</el-table-column>
|
<el-table-column label="商品名称" prop="spuName" show-overflow-tooltip>
|
</el-table-column>
|
<el-table-column label="规格型号" prop="model" width="150px" show-overflow-tooltip>
|
</el-table-column>
|
<el-table-column label="单位" prop="unit" width="150px">
|
</el-table-column>
|
<el-table-column label="操作" :width="`${2 * $store.getters.colSize}px`">
|
<template slot-scope="scope">
|
<wly-btn type="primary" @click="editInfo(scope.row)">编辑</wly-btn>
|
<wly-btn type="danger" @click="deleteItem(scope.row)">删除</wly-btn>
|
</template>
|
</el-table-column>
|
</template>
|
</list-condition-template>
|
<prod-account-info :show.sync="show" :row="row" :title="title"></prod-account-info>
|
<el-dialog :visible.sync="importDialogVisible" title="导入" :close-on-click-modal="false"
|
:modal-append-to-body="false" width="450px">
|
<el-form ref="form" size="mini">
|
<el-upload class="upload-demo" action="api" ref="upload" :limit="1" :accept="'.xlsx, .xls'"
|
:http-request="handleRequrst" :auto-upload="false" :on-change="handleChange"
|
:file-list="fileList" drag>
|
<i class="el-icon-upload"></i>
|
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
<div class="el-upload__tip" slot="tip">只能上传一个文件,且文件格式只支持.xlsx, .xls文件</div>
|
</el-upload>
|
</el-form>
|
<div slot="footer" class="dialog-footer">
|
<el-button type="primary" size="mini" :loading="loading" @click="submitImport">确定
|
</el-button>
|
<el-button size="mini" @click="importDialogVisible=false">取消</el-button>
|
</div>
|
</el-dialog>
|
<el-dialog :visible.sync="tipDialogVisible" title="导入提示" :close-on-click-modal="false"
|
:modal-append-to-body="false">
|
<h4 style="margin-bottom:20px;">导入{{successNum+tipTableData.length}}条核算编码,成功 {{successNum}}
|
条,失败{{tipTableData.length}}条</h4>
|
<tablePagination :tableData="tipTableData" :showOperatBtn="false">
|
<el-table-column label="商品主编码" prop="spuNum" show-overflow-tooltip>
|
</el-table-column>
|
<el-table-column label="存货辅助核算编码" prop="auxiliaryCode" show-overflow-tooltip>
|
</el-table-column>
|
<el-table-column label="商品名称" prop="spuName" show-overflow-tooltip>
|
</el-table-column>
|
<el-table-column label="规格型号" prop="model">
|
</el-table-column>
|
<el-table-column label="单位" prop="unit">
|
</el-table-column>
|
<el-table-column label="失败原因" prop="failReason">
|
</el-table-column>
|
</tablePagination>
|
<div slot="footer" class="buttonPosition dialog-footer">
|
<el-button size="mini" @click="closeTip()">关闭</el-button>
|
</div>
|
</el-dialog>
|
</div>
|
</template>
|
<script>
|
import invoiceProdInfoApi from '@/api/invoiceProdInfo'
|
import prodAccountInfo from '@/views/invoiceProdInfo/info.vue'
|
import { objectCopy } from '@/utils/objectCopyHelper'
|
import { downloadFile } from '@/utils/downloadFile'
|
import tablePagination from '@/views/blindBoxActivity/components/tablePagination.vue'
|
|
export default {
|
components: { prodAccountInfo, tablePagination },
|
data() {
|
return {
|
formLabel: [
|
{
|
model: 'spuNum',
|
label: '商品主编码',
|
type: 'input',
|
labelWidth: '100px',
|
rule: /[^\w]/g // 可输入数字字母
|
},
|
{
|
model: 'auxiliaryCode',
|
label: '核算编码',
|
type: 'input',
|
rule: /[^\w]/g // 可输入数字字母
|
},
|
{
|
model: 'spuName',
|
label: '商品名称',
|
type: 'input'
|
}
|
],
|
listQuery: {
|
spuNum: null,
|
auxiliaryCode: null,
|
spuName: null
|
},
|
tableData: [],
|
show: false,
|
title: null,
|
row: {},
|
dialogVisible: false,
|
form: {},
|
total: 0,
|
importDialogVisible: false,
|
fileList: [],
|
loading: false,
|
percentage: 0, // 进度条数值
|
isLoading: false, // 是否展示进度条遮罩
|
tipDialogVisible: false,
|
tipTableData: [],
|
successNum: 0, // 导入成功数量
|
exportQuery: null // 导出参数
|
}
|
},
|
/**
|
* 数据变化后刷新列表
|
*/
|
activated() {
|
this.queryList(this.$refs.table.getPageInfo())
|
},
|
methods: {
|
// 导出
|
async exportData() {
|
this.isLoading = true
|
const config = {
|
url: 'awl-order-service/invoiceProdInfo/download/exportData',
|
data: this.exportQuery,
|
fileName: '商品核算信息',
|
type: '.xlsx'
|
}
|
await downloadFile(config)
|
this.isLoading = false
|
},
|
// 下载模板
|
async downTemplate() {
|
const config = {
|
onUploadProgress: ProgressEvent => {
|
const progressPercent = Math.round(ProgressEvent.loaded / ProgressEvent.total * 100 | 0)
|
this.percentage = progressPercent === 100 ? 99 : progressPercent
|
this.isLoading = true
|
},
|
onDownloadProgress: ProgressEvent => {
|
},
|
url: 'awl-order-service/invoiceProdInfo/download/demoExcel',
|
data: null,
|
fileName: '商品核算信息模板',
|
Method: 'get',
|
type: '.xlsx'
|
}
|
const res = await downloadFile(config)
|
if (res) {
|
this.percentage = 100
|
this.isLoading = false
|
} else {
|
this.percentage = 100
|
this.isLoading = false
|
}
|
},
|
// 导入
|
importMemberInfo() {
|
this.importDialogVisible = true
|
},
|
// 导入三方系统会员信息
|
submitImport() {
|
this.$refs.upload.submit()
|
},
|
closeTip() {
|
this.tipDialogVisible = false
|
this.importDialogVisible = false
|
if (this.successNum) {
|
this.$refs.table.reloadCurrent()
|
}
|
},
|
// 当文件改变时获取选中的文件
|
handleChange(file, fileList) {
|
const acceptFile = '.xlsx, .xls'
|
var nameType = file.name.substring(file.name.lastIndexOf('.') + 1)
|
var fileType = acceptFile.indexOf(nameType) !== -1
|
if (!fileType) {
|
this.$message.error(`上传失败!仅支持${acceptFile}格式,请重新上传`)
|
this.fileList = []
|
return false
|
}
|
return true
|
},
|
// 手动上传文件
|
async handleRequrst(param) {
|
this.loading = true
|
const formData = new FormData()
|
formData.append('file', param.file)
|
try {
|
const res = await invoiceProdInfoApi.importData(formData)
|
if (res.code === '0') {
|
this.loading = false
|
this.fileList = []
|
if (res.data.failNum) {
|
this.tipTableData = res.data.omsInvoiceProdInfoExcelVoList
|
this.tipDialogVisible = true
|
} else {
|
this.$message.success('导入成功!')
|
this.importDialogVisible = false
|
this.$refs.table.reloadCurrent()
|
}
|
this.successNum = res.data.successNum
|
} else {
|
this.loading = false
|
this.fileList = []
|
}
|
} catch (error) {
|
this.fileList = []
|
this.$message.error('上传文件失败!请重新上传')
|
this.loading = false
|
}
|
},
|
/**
|
* 删除
|
*/
|
deleteItem(row) {
|
this.$confirm('确认删除该数据?', '删除', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
invoiceProdInfoApi.deleteItem({ id: row.id }).then(res => {
|
if (res.code === '0') {
|
this.$message({
|
message: '操作成功',
|
type: 'success'
|
})
|
this.queryData()
|
}
|
})
|
}).catch(() => { })
|
},
|
/**
|
* '分页信息改变时查询列表
|
*/
|
handlePageInfoChange(pageInfo) {
|
this.queryList(pageInfo)
|
},
|
/**
|
* 重置
|
*/
|
resetQuery() {
|
this.$refs.table.reloadCurrent()
|
},
|
/**
|
* 点击查询按钮
|
*/
|
queryData() {
|
this.$refs.table.changeCondition()
|
},
|
/**
|
* 查看详情
|
*/
|
lookInfo(row) {
|
this.dialogVisible = true
|
this.form = row
|
},
|
/**
|
* 编辑
|
*/
|
editInfo(row) {
|
this.show = true
|
this.title = '编辑商品核算信息'
|
this.row = objectCopy(row)
|
},
|
/**
|
* 查询列表
|
*/
|
queryList(pageInfo = { pageNum: 1, pageSize: 10 }) {
|
invoiceProdInfoApi.getList({ ...this.listQuery, ...pageInfo }).then(res => {
|
if (res.data) {
|
this.tableData = res.data.list
|
this.total = res.data.total
|
this.exportQuery = JSON.parse(JSON.stringify(this.listQuery))
|
}
|
})
|
},
|
/**
|
* 跳转到新增页面
|
*/
|
addItem() {
|
this.show = true
|
this.title = '添加商品核算信息'
|
}
|
}
|
}
|
</script>
|