细节 加批量导入

main
fanfan 11 months ago
parent a2387a961a
commit 86b9bdf2e0
  1. 1
      src/App.vue
  2. 6
      src/config/router.config.js
  3. 79
      src/views/dataCenter/goods/Index.vue
  4. 185
      src/views/dataCenter/goods/modify.vue

@ -23,7 +23,6 @@ export default {
<style>
.container {
/* overflow-x: scroll; */
min-width: 1500px !important;
}
.ant-table-body {
overflow-x: scroll;

@ -79,6 +79,12 @@ export const asyncRouterMap = [
meta: { title: '编辑商品', keepAlive: false },
hidden: true
},
{
path: '/goods/modify',
component: () => import(/* webpackChunkName: "goods" */ '@/views/dataCenter/goods/modify'),
meta: { title: '批量修改', keepAlive: false },
hidden: true
},
{
path: '/goods/copy',
component: () => import(/* webpackChunkName: "goods" */ '@/views/dataCenter/goods/Copy'),

@ -137,20 +137,30 @@
<a-button class="fl-l" icon="arrow-up" @click="handleImport()">批量导入</a-button>
<div class="button-group">
<a-button-group class="ml-10">
<a-button v-if="selectedRowKeys.length"
<a-button
v-if="selectedRowKeys.length"
icon="arrow-up"
style="background-color: red; color: #fff"
@click="handleUpdateStatus(selectedRowKeys, 1)"
>上架</a-button
>
<a-button v-if="selectedRowKeys.length"
<a-button
v-if="selectedRowKeys.length"
icon="arrow-down"
style="background-color: gray; color: #fff"
@click="handleUpdateStatus(selectedRowKeys, 2)"
>移除</a-button
>
<a-button v-if="selectedRowKeys.length" style="background-color: green; color: #fff; border: none" @click="visible = true">归类</a-button>
<a-button v-if="selectedRowKeys.length" style="background-color: blue; color: #fff; border: none" @click="saleVisible = true"
<a-button
v-if="selectedRowKeys.length"
style="background-color: green; color: #fff; border: none"
@click="visible = true"
>归类</a-button
>
<a-button
v-if="selectedRowKeys.length"
style="background-color: blue; color: #fff; border: none"
@click="saleVisible = true"
>停售</a-button
>
<a-button style="background-color: #6370e4; color: #fff; border: none" @click="priceVisible = true"
@ -161,9 +171,12 @@
@click="handleExport(selectedRowKeys)"
>导出</a-button
>
<a-button v-if="selectedRowKeys.length" icon="delete" @click="handleDelete(selectedRowKeys)">删除</a-button>
<a-button v-if="selectedRowKeys.length" icon="delete" @click="handleDelete(selectedRowKeys)">删除</a-button>
</a-button-group>
</div>
<a-button class="fl-l" style="background-color: #f0baae; border: none" type="primary" @click="handleModify()"
>批量修改</a-button
>
</div>
</div>
<s-table
@ -187,7 +200,7 @@
<p v-else>{{ text }}</p>
</span>
<span slot="profit_rate" slot-scope="text, item">
<p>{{ text>0?Number(text)+'%':0 }}</p>
<p>{{ text > 0 ? Number(text) + '%' : 0 }}</p>
</span>
<!-- 商品池 -->
<span slot="is_pool" slot-scope="text">
@ -405,7 +418,7 @@ export default {
},
},
methods: {
handleTableChange(e){
handleTableChange(e) {
console.log(e)
},
validateAmount() {
@ -418,10 +431,10 @@ export default {
} else if (row.startsWith('0')) {
this.money = ''
//2
}else if(!/^\d+(\.\d{1,2})?$/.test(row)){
} else if (!/^\d+(\.\d{1,2})?$/.test(row)) {
this.$message.error('请输入数字!')
this.money = ''
}else if (row.split('.')[1] && row.split('.')[1].length > 2) {
} else if (row.split('.')[1] && row.split('.')[1].length > 2) {
this.$message.error('金额小数部分不能超过2位,请修改')
this.rate = ''
}
@ -564,7 +577,7 @@ export default {
return
}
this.isLoading = true
GoodsApi.addPrice({categoryIds, rate })
GoodsApi.addPrice({ categoryIds, rate })
.then((result) => {
this.priceVisible = false
this.$message.success(result.message, 1.5)
@ -592,19 +605,34 @@ export default {
handleExport() {
const formData = this.searchForm.getFieldsValue()
this.isLoading = true
var index = window.serverConfig.BASE_API.indexOf("?")
var resolve = window.serverConfig.BASE_API.substring(0, index);
let params='&goodsName='+(formData.goodsName||'')+
'&goodsNo='+(formData.goodsNo||'')+'&goods_price_max='+(formData.goods_price_max || '')+'&goods_price_min='+(formData.goods_price_min || '')+
'&profit_rate_max='+(formData.profit_rate_max || '')+
'&profit_rate_min='+(formData.profit_rate_min || '')+
'&categoryId='+this.queryParam.categoryId+
'&channel='+this.queryParam.channel+
'&data_type='+this.queryParam.data_type+
'&is_pool='+this.queryParam.is_pool+
'&is_sale='+this.queryParam.is_sale+
'&is_self='+this.queryParam.is_self
window.open(resolve+'?s=/admin/goods/export'+params)
var index = window.serverConfig.BASE_API.indexOf('?')
var resolve = window.serverConfig.BASE_API.substring(0, index)
let params =
'&goodsName=' +
(formData.goodsName || '') +
'&goodsNo=' +
(formData.goodsNo || '') +
'&goods_price_max=' +
(formData.goods_price_max || '') +
'&goods_price_min=' +
(formData.goods_price_min || '') +
'&profit_rate_max=' +
(formData.profit_rate_max || '') +
'&profit_rate_min=' +
(formData.profit_rate_min || '') +
'&categoryId=' +
this.queryParam.categoryId +
'&channel=' +
this.queryParam.channel +
'&data_type=' +
this.queryParam.data_type +
'&is_pool=' +
this.queryParam.is_pool +
'&is_sale=' +
this.queryParam.is_sale +
'&is_self=' +
this.queryParam.is_self
window.open(resolve + '?s=/admin/goods/export' + params)
},
//
handleDelete(goodsIds) {
@ -632,7 +660,10 @@ export default {
handleImport() {
this.$router.push('/goods/import/batch')
},
//
handleModify() {
this.$router.push('/goods/modify')
},
/**
* 刷新列表
* @param Boolean bool 强制刷新到第一页

@ -0,0 +1,185 @@
<template>
<a-card :bordered="false">
<div class="card-title">
<span>{{ $route.meta.pageTitle }}</span>
</div>
<a-spin :spinning="isLoading">
<div class="container">
<div class="upload-dragger">
<a-upload-dragger
accept=".xls, .xlsx"
:multiple="false"
:fileList="fileList"
:showUploadList="false"
:beforeUpload="beforeUpload"
:remove="handleRemove"
>
<p class="ant-upload-drag-icon">
<a-icon type="cloud-upload" />
</p>
<div v-if="!fileList.length">
<p class="ant-upload-text">点击选择文件或者将文件拖拽至此区域</p>
<p class="ant-upload-hint">仅支持 .xls, .xlsx 格式的excel文件限2M以内</p>
</div>
<div v-else>
<p class="ant-upload-text">
<span>{{ fileList[0].name }}</span>
<a
class="ml-10"
href="javascript:void(0);"
@click.stop="handleRemove(fileList[0])"
>删除</a>
</p>
<a-button class="mt-20" type="primary" @click.stop="onFormSubmit">立即导入</a-button>
</div>
</a-upload-dragger>
</div>
<div class="import-explain">
<h2 class="title">导入说明</h2>
<a-timeline class="timeline">
<a-timeline-item class="timeline-item">
<p class="name">使用模板</p>
<ul class="content">
<li class="content-li">
<span>模板中最多不能超过500个商品如超过500个商品请分批导入</span>
</li>
<li class="content-li">
<span>模板中的字段含义以及填写规则可查看模板文件中标题栏的标注</span>
</li>
</ul>
</a-timeline-item>
</a-timeline>
</div>
<!-- 文件选择器 -->
<FilesModal
ref="FilesModal"
:multiple="true"
:maxNum="10"
:actions="['delete', 'move', 'copyIds']"
/>
</div>
</a-spin>
</a-card>
</template>
<script>
import * as GoodsApi from '@/api/goods'
import { FilesModal } from '@/components/Modal'
export default {
components: {
FilesModal
},
data () {
return {
//
isLoading: false,
//
fileList: [],
// 2m
uploadSizeLimit: '2'
}
},
//
created () {
},
methods: {
//
handleSelectImage () {
this.$refs.FilesModal.show()
},
//
beforeUpload (file) {
//
const fileSizeMb = file.size / 1024 / 1024
if (fileSizeMb > this.uploadSizeLimit) {
this.$message.error(`上传的文件大小不能超出${this.uploadSizeLimit}MB`)
return false
}
this.fileList = [file]
return false
},
//
handleRemove (file) {
const { fileList } = this
const index = fileList.indexOf(file)
if (index > -1) {
fileList.splice(index, 1)
}
},
// api
onFormSubmit () {
const { fileList } = this
const formData = new FormData()
formData.append('file', fileList[0])
this.isLoading = true
GoodsApi.exportData(formData)
.then(result => {
this.fileList = []
this.$message.success(result.message, 1.8)
setTimeout(() => this.$router.push('/goods/index'), 1500)
})
.finally(() => this.isLoading = false)
}
}
}
</script>
<style lang="less" scoped>
/deep/.ant-upload.ant-upload-drag .ant-upload {
padding: 82px 0;
}
/deep/span.ant-radio + * {
color: #7a7a7a;
}
.card-title {
display: flex;
justify-content: space-between;
}
.container {
width: 1000px;
margin: 0 auto;
}
.timeline {
color: #111;
}
.import-explain {
margin-top: 40px;
.title {
margin-bottom: 25px;
font-weight: bold;
font-size: 15px;
}
.name {
font-size: 14px;
margin-bottom: 8px;
}
.timeline-item {
padding-bottom: 20px;
}
.content {
color: #7a7a7a;
padding-left: 20px;
.content-li {
list-style-type: disc;
margin-bottom: 5px;
}
}
}
</style>
Loading…
Cancel
Save