This commit is contained in:
tangzh 2025-03-30 22:54:20 +08:00
parent ef1bdea2f0
commit a47b0047ee
9 changed files with 205 additions and 59 deletions

View File

@ -280,6 +280,19 @@ export function productExcelApi(params) {
}) })
} }
/**
* 商品导入
* @param params
* @returns {*}
*/
export function importExcelApi(data) {
return request({
url: `/admin/import/excel/product`,
method: 'post',
data
})
}
/** /**
* 商品列表 获取复制商品配置 * 商品列表 获取复制商品配置
* @param pram * @param pram

View File

@ -40,11 +40,11 @@ export function detailApi(id) {
* ebsystemhelpproblem删除 * ebsystemhelpproblem删除
* @param pram * @param pram
*/ */
export function deleteApi(data) { export function deleteApi(params) {
return request({ return request({
url: `admin/system/helpProblem/delete`, url: `admin/system/helpProblem/delete`,
method: 'POST', method: 'POST',
data params
}) })
} }

View File

@ -2,9 +2,11 @@
<div> <div>
<input ref="excel-upload-input" class="excel-upload-input" type="file" accept=".xlsx, .xls" @change="handleClick"> <input ref="excel-upload-input" class="excel-upload-input" type="file" accept=".xlsx, .xls" @change="handleClick">
<div class="drop" @drop="handleDrop" @dragover="handleDragover" @dragenter="handleDragover"> <div class="drop" @drop="handleDrop" @dragover="handleDragover" @dragenter="handleDragover">
Drop excel file here or <span v-if="fileName">已选择{{ fileName }}</span>
<span v-else>将文件拖到此处或</span>
<el-button :loading="loading" style="margin-left:16px;" size="mini" type="primary" @click="handleUpload"> <el-button :loading="loading" style="margin-left:16px;" size="mini" type="primary" @click="handleUpload">
Browse <span v-if="fileName">重新选择</span>
<span v-else>点击上传</span>
</el-button> </el-button>
</div> </div>
</div> </div>
@ -24,10 +26,15 @@ export default {
excelData: { excelData: {
header: null, header: null,
results: null results: null
} },
fileName: ''
} }
}, },
methods: { methods: {
resetData() {
this.$refs['excel-upload-input'].value = null;
this.fileName = '';
},
generateData({ header, results }) { generateData({ header, results }) {
this.excelData.header = header this.excelData.header = header
this.excelData.results = results this.excelData.results = results
@ -64,7 +71,8 @@ export default {
const files = e.target.files const files = e.target.files
const rawFile = files[0] // only use files[0] const rawFile = files[0] // only use files[0]
if (!rawFile) return if (!rawFile) return
this.upload(rawFile) this.upload(rawFile);
this.fileName = rawFile.name;
}, },
upload(rawFile) { upload(rawFile) {
this.$refs['excel-upload-input'].value = null // fix can't select the same excel this.$refs['excel-upload-input'].value = null // fix can't select the same excel
@ -125,8 +133,7 @@ export default {
} }
.drop{ .drop{
border: 2px dashed #bbb; border: 2px dashed #bbb;
width: 600px; width: 800px;
height: 160px;
line-height: 160px; line-height: 160px;
margin: 0 auto; margin: 0 auto;
font-size: 24px; font-size: 24px;

View File

@ -435,7 +435,7 @@
cost: 0, cost: 0,
otPrice: 0, otPrice: 0,
stock: 0, stock: 0,
barCode: '', // barCode: '',
// weight: 0, // weight: 0,
// volume: 0 // volume: 0
}], }],
@ -448,7 +448,7 @@
id: 0, id: 0,
couponIds: [], couponIds: [],
coupons: [], coupons: [],
activity: ['默认','秒杀'] activity: ['默认']//,''
} }
const objTitle = { const objTitle = {
price: { price: {
@ -463,9 +463,9 @@
stock: { stock: {
title: '库存' title: '库存'
}, },
barCode: { // barCode: {
title: '商品编号' // title: ''
}, // },
// weight: { // weight: {
// title: 'KG' // title: 'KG'
// }, // },
@ -479,7 +479,7 @@
data() { data() {
return { return {
isDisabled: this.$route.params.isDisabled==='1'?true:false, isDisabled: this.$route.params.isDisabled==='1'?true:false,
activity: { '默认': 'red', '秒杀': 'blue' }, activity: { '默认': 'red'}, // , '': 'blue'
props2: { props2: {
children: 'child', children: 'child',
label: 'name', label: 'name',
@ -720,7 +720,7 @@
cost: 0, cost: 0,
otPrice: 0, otPrice: 0,
stock: 0, stock: 0,
barCode: '', // barCode: '',
// weight: 0, // weight: 0,
// volume: 0, // volume: 0,
brokerage: 0, brokerage: 0,
@ -751,7 +751,7 @@
cost: 0, cost: 0,
otPrice: 0, otPrice: 0,
stock: 0, stock: 0,
barCode: '', // barCode: '',
// weight: 0, // weight: 0,
// volume: 0, // volume: 0,
brokerage: 0, brokerage: 0,
@ -884,7 +884,7 @@
this.$set(val, 'cost', this.oneFormBatch[0].cost) this.$set(val, 'cost', this.oneFormBatch[0].cost)
this.$set(val, 'otPrice', this.oneFormBatch[0].otPrice) this.$set(val, 'otPrice', this.oneFormBatch[0].otPrice)
this.$set(val, 'stock', this.oneFormBatch[0].stock) this.$set(val, 'stock', this.oneFormBatch[0].stock)
this.$set(val, 'barCode', this.oneFormBatch[0].barCode) // this.$set(val, 'barCode', this.oneFormBatch[0].barCode)
// this.$set(val, 'weight', this.oneFormBatch[0].weight) // this.$set(val, 'weight', this.oneFormBatch[0].weight)
// this.$set(val, 'volume', this.oneFormBatch[0].volume) // this.$set(val, 'volume', this.oneFormBatch[0].volume)
this.$set(val, 'brokerage', this.oneFormBatch[0].brokerage) this.$set(val, 'brokerage', this.oneFormBatch[0].brokerage)
@ -1000,7 +1000,7 @@
ficti: info.ficti, ficti: info.ficti,
coupons: info.coupons, coupons: info.coupons,
couponIds: info.couponIds, couponIds: info.couponIds,
activity: info.activityStr ? info.activityStr.split(',') : ['默认','秒杀'] activity: info.activityStr ? info.activityStr.split(',') : ['默认']// ,''
} }
marketingSendApi({type:3}).then(res=>{ marketingSendApi({type:3}).then(res=>{
if(this.formValidate.couponIds !== null){ if(this.formValidate.couponIds !== null){

View File

@ -21,7 +21,8 @@
<el-button size="small" type="primary" class="mr10" v-hasPermi="['admin:product:save']">添加商品</el-button> <el-button size="small" type="primary" class="mr10" v-hasPermi="['admin:product:save']">添加商品</el-button>
</router-link> </router-link>
<!-- <el-button size="small" type="success" class="mr10" @click="onCopy" v-hasPermi="['admin:product:save']">商品采集</el-button>--> <!-- <el-button size="small" type="success" class="mr10" @click="onCopy" v-hasPermi="['admin:product:save']">商品采集</el-button>-->
<!-- <el-button size="small" icon="el-icon-upload2" @click="exports" v-hasPermi="['admin:export:excel:product']">导出</el-button>--> <el-button size="small" type="success" class="mr10" @click="importExcel">商品导入</el-button>
<el-button size="small" icon="el-icon-upload2" @click="exports" v-hasPermi="['admin:export:excel:product']">导出</el-button>
</div> </div>
<el-table <el-table
v-loading="listLoading" v-loading="listLoading"
@ -159,17 +160,56 @@
:before-close="handleClose"> :before-close="handleClose">
<tao-bao v-if="dialogVisible" @handleCloseMod="handleCloseMod"></tao-bao> <tao-bao v-if="dialogVisible" @handleCloseMod="handleCloseMod"></tao-bao>
</el-dialog> </el-dialog>
<el-dialog
:visible.sync="importVisible"
title="导入文件"
:close-on-click-modal="false"
width="1200px"
@close="uploadExcelClose">
<el-row type="flex" justify="center" align="centre">
<el-col :span="18">
<upload-excel-component :on-success="handleSuccess" :before-upload="beforeUpload" ref="excel-upload-input"/>
</el-col>
<el-col :span="2" style="line-height: 160px">
<el-button plain type="primary" @click="excelUpload" :disabled="excelUploadState">上传到服务器</el-button>
</el-col>
</el-row>
</el-dialog>
</div> </div>
</template> </template>
<script> <script>
import { productLstApi, productDeleteApi, categoryApi, putOnShellApi, offShellApi, productHeadersApi, productExportApi, restoreApi, productExcelApi } from '@/api/store' import {
productLstApi,
productDeleteApi,
categoryApi,
putOnShellApi,
offShellApi,
productHeadersApi,
productExportApi,
restoreApi,
productExcelApi,
importExcelApi,
replyListApi, productDetailApi
} from '@/api/store'
import { getToken } from '@/utils/auth' import { getToken } from '@/utils/auth'
import taoBao from './taoBao' import taoBao from './taoBao'
import { checkPermi } from "@/utils/permission"; // import UploadExcelComponent from '@/components/UploadExcel/index.vue'
import { checkPermi } from "@/utils/permission";
import CreatTemplates from "@/views/systemSetting/logistics/shippingTemplates/creatTemplates.vue";
import edit from "@/components/Category/edit.vue";
import tableHeader from "element-ui/packages/table/src/table-header";
import {fileImageApi} from "@/api/systemSetting"; //
export default { export default {
name: 'ProductList', name: 'ProductList',
components: { taoBao }, computed: {
tableHeader() {
return tableHeader
}
},
components: {edit, CreatTemplates, taoBao, UploadExcelComponent },
data() { data() {
return { return {
props: { props: {
@ -192,10 +232,15 @@ export default {
keywords: '', keywords: '',
type: '1' type: '1'
}, },
excelTableData: [],
excelTableHeader: [],
excelUploadState: true,
excelUploadFile: '',
categoryList: [], categoryList: [],
merCateList: [], merCateList: [],
objectUrl: process.env.VUE_APP_BASE_API, objectUrl: process.env.VUE_APP_BASE_API,
dialogVisible: false, dialogVisible: false,
importVisible: false,
} }
}, },
mounted() { mounted() {
@ -216,6 +261,42 @@ export default {
}) })
}); });
}, },
beforeUpload(file) {
this.excelUploadState = false;
this.excelUploadFile = file;
const isLt1M = file.size / 1024 / 1024 < 1;
if (isLt1M) { return true; }
this.$message.warning("上传文件不能大于1M");
this.excelUploadState = true;
return false;
},
handleSuccess({ results, header }) {
this.excelTableData = results;
this.excelTableHeader = header;
},
async excelUpload() {
if (this.excelTableData.length === 0 || this.excelTableHeader.length === 0) {
this.$message.error("数据为空,不能上传");
}
let loading = this.$loading({
lock: true,
text: "上传中,请稍候...",
spinner: "el-icon-loading",
background: "rgba(0, 0, 0, 0.7)",
});
const formData = new FormData();
formData.append("multipart", this.excelUploadFile);
importExcelApi(formData).then(res => {
loading.close();
this.$message.success("上传成功");
this.tableData.page = 1;
this.goodHeade()
this.getList()
this.importVisible = false;
}).catch(() => {
loading.close();
})
},
seachList() { seachList() {
this.tableFrom.page = 1 this.tableFrom.page = 1
this.getList() this.getList()
@ -223,6 +304,11 @@ export default {
handleClose() { handleClose() {
this.dialogVisible = false this.dialogVisible = false
}, },
uploadExcelClose() {
this.importVisible = false
this.excelUploadState = true;
this.$refs['excel-upload-input'].resetData();
},
handleCloseMod(item){ handleCloseMod(item){
this.dialogVisible = item this.dialogVisible = item
this.goodHeade(); this.goodHeade();
@ -232,12 +318,42 @@ export default {
onCopy(){ onCopy(){
this.dialogVisible = true this.dialogVisible = true
}, },
//
modalPicTap (tit, num, i,status) {
const _this = this;
if(_this.isDisabled) return;
this.$modalUpload(function(img) {
if(tit==='1'&& !num){
_this.formValidate.image = img[0].sattDir
_this.OneattrValue[0].image = img[0].sattDir
}
if(tit==='2'&& !num){
if(img.length>10) return this.$message.warning("最多选择10张图片");
if(img.length + _this.formValidate.sliderImages.length > 10) return this.$message.warning("最多选择10张图片");
img.map((item) => {
_this.formValidate.sliderImages.push(item.sattDir)
});
}
if(tit==='1'&& num === 'dan' ){
_this.OneattrValue[0].image = img[0].sattDir
}
if(tit==='1'&& num === 'duo' ){
_this.ManyAttrValue[i].image = img[0].sattDir
}
if(tit==='1'&& num === 'pi' ){
_this.oneFormBatch[0].image = img[0].sattDir
}
},tit, 'content')
},
// //
exports () { exports () {
productExcelApi({cateId:this.tableFrom.cateId,keywords: this.tableFrom.keywords, type:this.tableFrom.type}).then((res) => { productExcelApi({cateId:this.tableFrom.cateId,keywords: this.tableFrom.keywords, type:this.tableFrom.type}).then((res) => {
window.location.href = res.fileName; window.location.href = res.fileName;
}) })
}, },
importExcel() {
this.importVisible = true
},
// //
goodHeade () { goodHeade () {
productHeadersApi().then(res => { productHeadersApi().then(res => {

View File

@ -22,9 +22,8 @@
<el-table v-loading="listLoading" :data="ruleForm.region" border fit highlight-current-row style="width: 100%" size="mini" class="tempBox"> <el-table v-loading="listLoading" :data="ruleForm.region" border fit highlight-current-row style="width: 100%" size="mini" class="tempBox">
<el-table-column align="center" label="可配送区域" min-width="260"> <el-table-column align="center" label="可配送区域" min-width="260">
<template slot-scope="scope"> <template slot-scope="scope">
<span v-if="scope.$index === 0">默认全国</span> <!-- <span v-if="scope.$index === 0">默认全国</span>-->
<el-cascader <el-cascader
v-else
v-model="scope.row.city_ids" v-model="scope.row.city_ids"
style="width: 98%" style="width: 98%"
:options="cityList" :options="cityList"
@ -67,11 +66,11 @@
<el-table-column align="center" label="操作" min-width="80"> <el-table-column align="center" label="操作" min-width="80">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
v-if="scope.$index > 0"
type="text" type="text"
size="small" size="small"
@click="confirmEdit(ruleForm.region,scope.$index)" @click="confirmEdit(ruleForm.region,scope.$index)"
> >
<!-- v-if="scope.$index > 0"-->
删除 删除
</el-button> </el-button>
</template> </template>
@ -96,7 +95,7 @@
<el-cascader <el-cascader
v-model="row.city_ids" v-model="row.city_ids"
style="width: 95%" style="width: 95%"
:options="cityList" :options="a_cityList"
:props="props" :props="props"
collapse-tags collapse-tags
clearable clearable
@ -179,7 +178,7 @@ const defaultRole = {
firstPrice: 0, firstPrice: 0,
renewal: 0, renewal: 0,
renewalPrice: 0, renewalPrice: 0,
city_ids: [] city_ids: [],
}], }],
undelivery: 0, undelivery: 0,
free: [], free: [],
@ -264,6 +263,7 @@ export default {
ruleForm: Object.assign({}, defaultRole), ruleForm: Object.assign({}, defaultRole),
listLoading: false, listLoading: false,
cityList: [], cityList: [],
a_cityList: [],
columns: { columns: {
title: '首件', title: '首件',
title2: '续件', title2: '续件',
@ -271,13 +271,17 @@ export default {
}, },
isShowPrice: true, isShowPrice: true,
tempId: 0, tempId: 0,
type: 0 // 0 1 type: 0, // 0 1
defaultCity : {"id":0,"cityId":0,"name":"默认全国","city_ids":[[0]],"child":null}
} }
}, },
mounted() { mounted() {
setTimeout(()=>{ setTimeout(()=>{
let cityList = JSON.parse(sessionStorage.getItem('cityList')); let cityList = JSON.parse(sessionStorage.getItem('cityList'));
let a_cityList = JSON.parse(sessionStorage.getItem('cityList'));
cityList.unshift(this.defaultCity);
this.cityList = cityList; this.cityList = cityList;
this.a_cityList = a_cityList;
},1000); },1000);
}, },
methods: { methods: {
@ -314,7 +318,6 @@ export default {
} }
}, },
changeRegion(value) { changeRegion(value) {
console.log(value)
}, },
changeRadio(num) { changeRadio(num) {
this.columns = Object.assign({}, statusMap[num - 1]) this.columns = Object.assign({}, statusMap[num - 1])
@ -403,7 +406,10 @@ export default {
logistics.cityListTree().then(res => { logistics.cityListTree().then(res => {
sessionStorage.setItem('cityList',JSON.stringify(res)); sessionStorage.setItem('cityList',JSON.stringify(res));
let cityList = JSON.parse(sessionStorage.getItem('cityList')); let cityList = JSON.parse(sessionStorage.getItem('cityList'));
let a_cityList = JSON.parse(sessionStorage.getItem('cityList'));
cityList.unshift(this.defaultCity);
this.cityList = cityList; this.cityList = cityList;
this.a_cityList = a_cityList;
}).catch(res => { }).catch(res => {
this.$message.error(res.message) this.$message.error(res.message)
}) })
@ -441,31 +447,38 @@ export default {
// // // //
// shippingTemplatesFreeRequestList: [] // shippingTemplatesFreeRequestList: []
} }
let isAllNum = 0;
this.ruleForm.region.forEach((el, index) => { this.ruleForm.region.forEach((el, index) => {
el.title = el.city_ids.length > 0 ? JSON.stringify(el.city_ids) : JSON.stringify([[0, 0]]) let cityId = 'all';
for (var i = 0; i < el.city_ids.length; i++) { let title = JSON.stringify([[0]]);
el.city_ids[i].shift() if (el.city_ids.length > 0 && el.city_ids[0] != '0') {
cityId = el.city_ids.join(',');
title = JSON.stringify(el.city_ids);
} else {
isAllNum = isAllNum + 1;
} }
el.cityId = el.city_ids.length > 0 ? el.city_ids.join(',') : 'all' el.title = title;
el.cityId = cityId
}) })
if (isAllNum > 1 || (isAllNum == 1 && this.ruleForm.region.length > 1)) {
this.$message.error('配送区域已有全国选项,请移除其他区域')
this.loading = false;
return ;
}
param.shippingTemplatesRegionRequestList = this.ruleForm.region param.shippingTemplatesRegionRequestList = this.ruleForm.region
param.shippingTemplatesRegionRequestList.forEach((el, index) => {
// delete el.city_ids
// delete el.city_id
})
if (this.ruleForm.appoint) { if (this.ruleForm.appoint) {
this.ruleForm.free.forEach((el, index) => { this.ruleForm.free.forEach((el, index) => {
el.title = el.city_ids.length > 0 ? JSON.stringify(el.city_ids) : JSON.stringify([[0, 0]]) let cityId = 'all';
for (var i = 0; i < el.city_ids.length; i++) { let title = JSON.stringify([[0]]);
el.city_ids[i].shift() if (el.city_ids.length > 0 && el.city_ids[0] != '0') {
cityId = el.city_ids.join(',');
title = JSON.stringify(el.city_ids);
} }
el.cityId = el.city_ids.length > 0 ? el.city_ids.join(',') : 'all' el.title = title;
el.cityId = cityId
}) })
param.shippingTemplatesFreeRequestList = this.ruleForm.free param.shippingTemplatesFreeRequestList = this.ruleForm.free
param.shippingTemplatesFreeRequestList.forEach((el, index) => {
// delete el.city_ids
// delete el.city_id
})
} }
if (this.type === 0) { if (this.type === 0) {
logistics.shippingSave(param).then(res => { logistics.shippingSave(param).then(res => {
@ -519,4 +532,7 @@ export default {
width: 100px !important; width: 100px !important;
} }
} }
.el-table__row .el-form-item--mini.el-form-item {
margin-bottom: 0;
}
</style> </style>

View File

@ -7,9 +7,7 @@
<!-- 新增和创建表单表单 --> <!-- 新增和创建表单表单 -->
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataSubmit()" label-width="80px"> <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataSubmit()" label-width="80px">
<el-form-item label="分类" prop="cid"> <el-form-item label="分类" prop="cid">
<el-select v-model="dataForm.cid" placeholder="请选择" class="selWidthd">
<el-select v-model="dataForm.cid" placeholder="分类" clearable class="selWidth">
<el-option label="--请选择--" value=""></el-option>
<el-option <el-option
v-for="item in categoryList" v-for="item in categoryList"
:key="item.id" :key="item.id"
@ -17,7 +15,6 @@
:value="item.id" :value="item.id"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="标题" prop="title"> <el-form-item label="标题" prop="title">
<el-input v-model="dataForm.title" placeholder="标题"></el-input> <el-input v-model="dataForm.title" placeholder="标题"></el-input>
@ -30,8 +27,8 @@
</el-form-item> </el-form-item>
<el-form-item label="是否无效" prop="status"> <el-form-item label="是否无效" prop="status">
<el-select v-model="dataForm.status"> <el-select v-model="dataForm.status">
<el-option label="有效" :value="1"></el-option> <el-option label="有效" :value="true"></el-option>
<el-option label="无效" :value="0"></el-option> <el-option label="无效" :value="false"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -53,7 +50,7 @@ export default {
categoryList: [], categoryList: [],
dataForm: { dataForm: {
id: 0, id: 0,
cid: '', cid: 0,
title: '', title: '',
content: '', content: '',
jumpUrl: '', jumpUrl: '',
@ -73,9 +70,6 @@ export default {
content: [ content: [
{required: true, message: '内容 为必填项', trigger: 'blur'} {required: true, message: '内容 为必填项', trigger: 'blur'}
], ],
jumpUrl: [
{required: true, message: '跳转地址 为必填项', trigger: 'blur'}
],
status: [ status: [
{required: true, message: '状态 为必填项', trigger: 'blur'} {required: true, message: '状态 为必填项', trigger: 'blur'}
], ],

View File

@ -189,8 +189,9 @@ export default {
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
api.deleteApi(id).then(res => { api.deleteApi({ids : ids.join(',')}).then(res => {
// TODO this.$message.success('操作成功')
this.getDataList()
}) })
}) })
} }

View File

@ -10,8 +10,7 @@
:name="tab.id.toString()"> :name="tab.id.toString()">
<template> <template>
<el-tabs v-model="activeNamel2" <el-tabs v-model="activeNamel2" type="border-card" @tab-click="handleItemTabClick">
type="border-card" @tab-click="handleItemTabClick">
<el-tab-pane <el-tab-pane
v-for="(tabItem,itemIndex) in tab.child" v-for="(tabItem,itemIndex) in tab.child"
:key="itemIndex" :key="itemIndex"