|
@@ -7,13 +7,14 @@
|
|
|
<el-button class="btn-primary" @click="onShopOperation('create')" v-permission="'/shopOperation'">添加</el-button>
|
|
|
<el-upload
|
|
|
style="display: inline-block;"
|
|
|
- action="import/goods"
|
|
|
+ action="/api-web/import/goods"
|
|
|
:show-file-list="false"
|
|
|
:before-upload="beforeUpload"
|
|
|
accept=".xlsx,.xls"
|
|
|
- :limit="1"
|
|
|
+ :headers="headers"
|
|
|
+ :on-error="handleError"
|
|
|
:on-success="handleSuccess">
|
|
|
- <el-button class="btn-primary">批量导入</el-button>
|
|
|
+ <el-button class="btn-primary">商品导入</el-button>
|
|
|
</el-upload>
|
|
|
<el-button class="btn-primary" @click="onDownload">下载模板</el-button>
|
|
|
<!-- 搜索类型 -->
|
|
@@ -148,15 +149,21 @@ import { goodsQuery, goodsUpdate, goodsDelete } from '@/api/businessManager'
|
|
|
import store from '@/store'
|
|
|
import Tooltip from '@/components/Tooltip/index'
|
|
|
import { Export } from '@/utils/downLoadFile'
|
|
|
+import { getToken } from "@/utils/auth";
|
|
|
+import load from '@/utils/loading'
|
|
|
export default {
|
|
|
components: { pagination, Tooltip },
|
|
|
name: 'shopList',
|
|
|
data () {
|
|
|
return {
|
|
|
+ goodsLoading: false,
|
|
|
organId: null,
|
|
|
searchForm: {
|
|
|
status: ''
|
|
|
},
|
|
|
+ headers: {
|
|
|
+ Authorization: getToken()
|
|
|
+ },
|
|
|
searchLsit: [],
|
|
|
tableList: [],
|
|
|
pageInfo: {
|
|
@@ -242,19 +249,31 @@ export default {
|
|
|
query: { paramInfo, pageInfo }
|
|
|
})
|
|
|
},
|
|
|
- beforeUpload() {
|
|
|
- console.log(file.type)
|
|
|
- const isJPG = file.type === '.xlsx' || file.type === '.xls';
|
|
|
- // const isLt2M = file.size / 1024 / 1024 < 2;
|
|
|
-
|
|
|
- if (!isJPG) {
|
|
|
- this.$message.error('上传头像图片只能是 JPG 格式!');
|
|
|
- }
|
|
|
- return isJPG;
|
|
|
+ beforeUpload(file) {
|
|
|
+ // console.log(file.type)
|
|
|
+ // const isJPG = file.type === '.xlsx' || file.type === '.xls';
|
|
|
+ // // const isLt2M = file.size / 1024 / 1024 < 2;
|
|
|
+ // if (!isJPG) {
|
|
|
+ // this.$message.error('上传头像图片只能是 JPG 格式!');
|
|
|
+ // }
|
|
|
+ // return isJPG;
|
|
|
+ // this.goodsLoading = true
|
|
|
+ load.startLoading()
|
|
|
},
|
|
|
- handleSuccess() { // 导入商品
|
|
|
+ handleSuccess(response, file, fileList) { // 导入商品
|
|
|
// 报表导出
|
|
|
-
|
|
|
+ load.endLoading()
|
|
|
+ console.log(response, file, fileList)
|
|
|
+ if(response.code == 200) {
|
|
|
+ this.$message.success('导入成功')
|
|
|
+ this.getList()
|
|
|
+ } else {
|
|
|
+ this.$message.error(response.msg)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleError(err, file, fileList) {
|
|
|
+ load.endLoading()
|
|
|
+ console.log(err, file, fileList)
|
|
|
},
|
|
|
onDownload() { // 下载模板
|
|
|
// // 报表导出
|