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

View File

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

View File

@ -2,9 +2,11 @@
<div>
<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">
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">
Browse
<span v-if="fileName">重新选择</span>
<span v-else>点击上传</span>
</el-button>
</div>
</div>
@ -24,10 +26,15 @@ export default {
excelData: {
header: null,
results: null
}
},
fileName: ''
}
},
methods: {
resetData() {
this.$refs['excel-upload-input'].value = null;
this.fileName = '';
},
generateData({ header, results }) {
this.excelData.header = header
this.excelData.results = results
@ -64,7 +71,8 @@ export default {
const files = e.target.files
const rawFile = files[0] // only use files[0]
if (!rawFile) return
this.upload(rawFile)
this.upload(rawFile);
this.fileName = rawFile.name;
},
upload(rawFile) {
this.$refs['excel-upload-input'].value = null // fix can't select the same excel
@ -125,8 +133,7 @@ export default {
}
.drop{
border: 2px dashed #bbb;
width: 600px;
height: 160px;
width: 800px;
line-height: 160px;
margin: 0 auto;
font-size: 24px;

View File

@ -435,7 +435,7 @@
cost: 0,
otPrice: 0,
stock: 0,
barCode: '',
// barCode: '',
// weight: 0,
// volume: 0
}],
@ -448,7 +448,7 @@
id: 0,
couponIds: [],
coupons: [],
activity: ['默认','秒杀']
activity: ['默认']//,''
}
const objTitle = {
price: {
@ -463,9 +463,9 @@
stock: {
title: '库存'
},
barCode: {
title: '商品编号'
},
// barCode: {
// title: ''
// },
// weight: {
// title: 'KG'
// },
@ -479,7 +479,7 @@
data() {
return {
isDisabled: this.$route.params.isDisabled==='1'?true:false,
activity: { '默认': 'red', '秒杀': 'blue' },
activity: { '默认': 'red'}, // , '': 'blue'
props2: {
children: 'child',
label: 'name',
@ -720,7 +720,7 @@
cost: 0,
otPrice: 0,
stock: 0,
barCode: '',
// barCode: '',
// weight: 0,
// volume: 0,
brokerage: 0,
@ -751,7 +751,7 @@
cost: 0,
otPrice: 0,
stock: 0,
barCode: '',
// barCode: '',
// weight: 0,
// volume: 0,
brokerage: 0,
@ -884,7 +884,7 @@
this.$set(val, 'cost', this.oneFormBatch[0].cost)
this.$set(val, 'otPrice', this.oneFormBatch[0].otPrice)
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, 'volume', this.oneFormBatch[0].volume)
this.$set(val, 'brokerage', this.oneFormBatch[0].brokerage)
@ -1000,7 +1000,7 @@
ficti: info.ficti,
coupons: info.coupons,
couponIds: info.couponIds,
activity: info.activityStr ? info.activityStr.split(',') : ['默认','秒杀']
activity: info.activityStr ? info.activityStr.split(',') : ['默认']// ,''
}
marketingSendApi({type:3}).then(res=>{
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>
</router-link>
<!-- <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>
<el-table
v-loading="listLoading"
@ -159,17 +160,56 @@
:before-close="handleClose">
<tao-bao v-if="dialogVisible" @handleCloseMod="handleCloseMod"></tao-bao>
</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>
</template>
<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 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 {
name: 'ProductList',
components: { taoBao },
computed: {
tableHeader() {
return tableHeader
}
},
components: {edit, CreatTemplates, taoBao, UploadExcelComponent },
data() {
return {
props: {
@ -192,10 +232,15 @@ export default {
keywords: '',
type: '1'
},
excelTableData: [],
excelTableHeader: [],
excelUploadState: true,
excelUploadFile: '',
categoryList: [],
merCateList: [],
objectUrl: process.env.VUE_APP_BASE_API,
dialogVisible: false,
importVisible: false,
}
},
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() {
this.tableFrom.page = 1
this.getList()
@ -223,6 +304,11 @@ export default {
handleClose() {
this.dialogVisible = false
},
uploadExcelClose() {
this.importVisible = false
this.excelUploadState = true;
this.$refs['excel-upload-input'].resetData();
},
handleCloseMod(item){
this.dialogVisible = item
this.goodHeade();
@ -232,12 +318,42 @@ export default {
onCopy(){
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 () {
productExcelApi({cateId:this.tableFrom.cateId,keywords: this.tableFrom.keywords, type:this.tableFrom.type}).then((res) => {
window.location.href = res.fileName;
})
},
importExcel() {
this.importVisible = true
},
//
goodHeade () {
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-column align="center" label="可配送区域" min-width="260">
<template slot-scope="scope">
<span v-if="scope.$index === 0">默认全国</span>
<!-- <span v-if="scope.$index === 0">默认全国</span>-->
<el-cascader
v-else
v-model="scope.row.city_ids"
style="width: 98%"
:options="cityList"
@ -67,11 +66,11 @@
<el-table-column align="center" label="操作" min-width="80">
<template slot-scope="scope">
<el-button
v-if="scope.$index > 0"
type="text"
size="small"
@click="confirmEdit(ruleForm.region,scope.$index)"
>
<!-- v-if="scope.$index > 0"-->
删除
</el-button>
</template>
@ -96,7 +95,7 @@
<el-cascader
v-model="row.city_ids"
style="width: 95%"
:options="cityList"
:options="a_cityList"
:props="props"
collapse-tags
clearable
@ -179,7 +178,7 @@ const defaultRole = {
firstPrice: 0,
renewal: 0,
renewalPrice: 0,
city_ids: []
city_ids: [],
}],
undelivery: 0,
free: [],
@ -264,6 +263,7 @@ export default {
ruleForm: Object.assign({}, defaultRole),
listLoading: false,
cityList: [],
a_cityList: [],
columns: {
title: '首件',
title2: '续件',
@ -271,13 +271,17 @@ export default {
},
isShowPrice: true,
tempId: 0,
type: 0 // 0 1
type: 0, // 0 1
defaultCity : {"id":0,"cityId":0,"name":"默认全国","city_ids":[[0]],"child":null}
}
},
mounted() {
setTimeout(()=>{
let cityList = JSON.parse(sessionStorage.getItem('cityList'));
let a_cityList = JSON.parse(sessionStorage.getItem('cityList'));
cityList.unshift(this.defaultCity);
this.cityList = cityList;
this.a_cityList = a_cityList;
},1000);
},
methods: {
@ -314,7 +318,6 @@ export default {
}
},
changeRegion(value) {
console.log(value)
},
changeRadio(num) {
this.columns = Object.assign({}, statusMap[num - 1])
@ -403,7 +406,10 @@ export default {
logistics.cityListTree().then(res => {
sessionStorage.setItem('cityList',JSON.stringify(res));
let cityList = JSON.parse(sessionStorage.getItem('cityList'));
let a_cityList = JSON.parse(sessionStorage.getItem('cityList'));
cityList.unshift(this.defaultCity);
this.cityList = cityList;
this.a_cityList = a_cityList;
}).catch(res => {
this.$message.error(res.message)
})
@ -441,31 +447,38 @@ export default {
// //
// shippingTemplatesFreeRequestList: []
}
let isAllNum = 0;
this.ruleForm.region.forEach((el, index) => {
el.title = el.city_ids.length > 0 ? JSON.stringify(el.city_ids) : JSON.stringify([[0, 0]])
for (var i = 0; i < el.city_ids.length; i++) {
el.city_ids[i].shift()
let cityId = 'all';
let title = JSON.stringify([[0]]);
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.forEach((el, index) => {
// delete el.city_ids
// delete el.city_id
})
if (this.ruleForm.appoint) {
this.ruleForm.free.forEach((el, index) => {
el.title = el.city_ids.length > 0 ? JSON.stringify(el.city_ids) : JSON.stringify([[0, 0]])
for (var i = 0; i < el.city_ids.length; i++) {
el.city_ids[i].shift()
let cityId = 'all';
let title = JSON.stringify([[0]]);
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.forEach((el, index) => {
// delete el.city_ids
// delete el.city_id
})
}
if (this.type === 0) {
logistics.shippingSave(param).then(res => {
@ -519,4 +532,7 @@ export default {
width: 100px !important;
}
}
.el-table__row .el-form-item--mini.el-form-item {
margin-bottom: 0;
}
</style>

View File

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

View File

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

View File

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