dev2 #1
@ -38,11 +38,11 @@ export async function deleteGoods(data) {
|
||||
})
|
||||
}
|
||||
|
||||
export async function downloadTempGoods(data) {
|
||||
data = stringify(data)
|
||||
export async function downloadTempGoods() {
|
||||
return request({
|
||||
url: `/admin/shop/shop-sync-productMapper/template?${data}`,
|
||||
url: '/admin/shop/shop-sync-productMapper/template',
|
||||
method: 'get',
|
||||
responseType: 'blob',
|
||||
})
|
||||
}
|
||||
|
||||
@ -58,15 +58,18 @@ export async function batchCreateGoods(data) {
|
||||
}
|
||||
|
||||
export async function batchExportGoods(data) {
|
||||
const formData = new URLSearchParams();
|
||||
data.forEach(id => formData.append('ids', id));
|
||||
return request({
|
||||
url: '/admin/shop/shop-sync-productMapper/exportSelected',
|
||||
method: 'post',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
data,
|
||||
})
|
||||
}
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
data: formData.toString(),
|
||||
responseType: 'blob'
|
||||
});
|
||||
}
|
||||
|
||||
export async function getProductMapping(data) {
|
||||
return request({
|
||||
@ -91,20 +94,26 @@ export async function downloadErrorReport(data) {
|
||||
})
|
||||
}
|
||||
|
||||
export async function syncProductMaping() {
|
||||
export async function syncProductMaping(storeId) {
|
||||
return request({
|
||||
url: `/admin/shop/shop-sync-productMapper/syncProductMaping`,
|
||||
method: 'put',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
params:{
|
||||
storeId
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export async function importGoodsData(data) {
|
||||
return request({
|
||||
url: `/admin/shop/shop-sync-productMapper/importData`,
|
||||
url: '/admin/shop/shop-sync-productMapper/importData',
|
||||
method: 'post',
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ export function convertRouter(asyncRoutes) {
|
||||
|
||||
if (route.meta.title == '店铺' && route.name == 'Vab330') {
|
||||
const obj = {
|
||||
path: '/goodsTool',
|
||||
path: '/storeConf',
|
||||
component: '@/views/store/storeConf/index',
|
||||
name: 'Vab88001',
|
||||
redirect: null,
|
||||
|
||||
119
src/views/product/goodsTool/BatchProductOperation.vue
Normal file
119
src/views/product/goodsTool/BatchProductOperation.vue
Normal file
@ -0,0 +1,119 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
title="批量商品上架"
|
||||
:visible="visible"
|
||||
width="600px"
|
||||
@close="$emit('update:visible', false)"
|
||||
>
|
||||
<div class="operation-container">
|
||||
<el-button plain type="info" @click="handleSyncProductMaping">
|
||||
自动匹配规格
|
||||
</el-button>
|
||||
<el-button @click="handleSyncShopImages">图库匹配并上架商品</el-button>
|
||||
<el-select
|
||||
v-model="filter.storeId"
|
||||
clearable
|
||||
filterable
|
||||
placeholder="选择店铺"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in shopList"
|
||||
:key="item.store_id"
|
||||
:label="item.store_name"
|
||||
:value="item.store_id"
|
||||
/>
|
||||
</el-select>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import GoodsToolApi from '@/api/goodsTool'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
filter: {
|
||||
productName: '',
|
||||
storeId: '',
|
||||
},
|
||||
tableData: [],
|
||||
pagination: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
total: 0,
|
||||
},
|
||||
selectedRowKeys: [],
|
||||
shopList: [],
|
||||
tableData: [],
|
||||
}
|
||||
},
|
||||
props: {
|
||||
visible: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.getShopList()
|
||||
this.getGoodsList()
|
||||
},
|
||||
methods: {
|
||||
handleClose() {
|
||||
this.$emit('update:visible', false)
|
||||
},
|
||||
open() {
|
||||
console.log('123456456456')
|
||||
this.$emit('update:visible', true)
|
||||
},
|
||||
async handleSyncProductMaping() {
|
||||
const res = await GoodsToolApi.syncProductMaping(this.filter.storeId)
|
||||
if (res.status == 200) {
|
||||
this.$message.success('操作成功')
|
||||
}
|
||||
},
|
||||
handleSyncShopImages() {
|
||||
if (!this.filter.storeId) {
|
||||
this.$message.error('请选择店铺')
|
||||
return
|
||||
}
|
||||
this.$confirm('确定要匹配当前选择店铺的商品图库?', '友情提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'danger',
|
||||
}).then(async () => {
|
||||
const res = await GoodsToolApi.syncShopImages({
|
||||
storeId: this.filter.storeId,
|
||||
})
|
||||
if (res.status == 200) {
|
||||
this.$message.success('操作成功')
|
||||
this.getProductMapperList()
|
||||
}
|
||||
})
|
||||
},
|
||||
handleSelectionChange(selection) {
|
||||
this.selectedRowKeys = selection.map((item) => item.id)
|
||||
},
|
||||
async getGoodsList() {
|
||||
let res = await GoodsToolApi.getProductMapperList({
|
||||
...this.filter,
|
||||
pageNum: this.pagination.pageNum,
|
||||
pageSize: this.pagination.pageSize,
|
||||
})
|
||||
this.tableData = res.data.items
|
||||
this.pagination.total = res.data.records
|
||||
},
|
||||
async getShopList() {
|
||||
let res = await GoodsToolApi.getShopList()
|
||||
this.shopList = res.data.items
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.operation-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
</style>
|
||||
@ -319,25 +319,33 @@
|
||||
return
|
||||
}
|
||||
|
||||
let res = null
|
||||
if (this.mode == 'add') {
|
||||
res = await GoodsToolApi.batchCreateGoods(submitData)
|
||||
} else {
|
||||
res = await GoodsToolApi.updateGoods({
|
||||
...submitData?.[0],
|
||||
id: this.batchForm.items?.[0].id,
|
||||
})
|
||||
}
|
||||
|
||||
if (res.status == 200) {
|
||||
this.$message.success('操作成功')
|
||||
} else {
|
||||
this.loading = false
|
||||
}
|
||||
try {
|
||||
let res = null;
|
||||
if (this.mode === 'add') {
|
||||
res = await GoodsToolApi.batchCreateGoods(submitData);
|
||||
} else {
|
||||
this.$message.error('请完善表单信息')
|
||||
return false
|
||||
res = await GoodsToolApi.updateGoods({
|
||||
...submitData[0],
|
||||
id: this.batchForm.items[0].id,
|
||||
});
|
||||
}
|
||||
|
||||
if (res.status === 200) {
|
||||
this.$message.success('操作成功');
|
||||
this.drawerVisible = false; // 关闭抽屉
|
||||
} else {
|
||||
this.$message.error('操作失败: ' + res.msg);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('提交错误:', error);
|
||||
this.$message.error('提交时发生错误');
|
||||
} finally {
|
||||
this.loading = false; // 确保无论成功或失败都重置 loading
|
||||
}
|
||||
} else {
|
||||
this.$message.error('请完善表单信息');
|
||||
return false;
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -12,7 +12,7 @@
|
||||
:model="innerFormData"
|
||||
:rules="rules"
|
||||
>
|
||||
<el-form-item label="店铺ID" prop="storeId">
|
||||
<el-form-item label="店铺名字" prop="storeId" v-if="!isEdit">
|
||||
<el-select v-model="innerFormData.storeId" placeholder="请选择店铺">
|
||||
<el-option
|
||||
v-for="item in storeIdOptions"
|
||||
@ -22,7 +22,9 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="店铺名字" prop="storeName" v-if="isEdit">
|
||||
<el-input v-model="innerFormData.storeName" :disabled="isEdit"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="数据库IP地址" prop="dbIp">
|
||||
<el-input v-model="innerFormData.dbIp" />
|
||||
</el-form-item>
|
||||
@ -61,9 +63,9 @@
|
||||
<el-form-item label="刷新时间" prop="refreshTime">
|
||||
<el-date-picker
|
||||
v-model="innerFormData.refreshTime"
|
||||
:disabled="isEdit"
|
||||
placeholder="请选择刷新时间"
|
||||
type="datetime"
|
||||
value-format="yyyy-MM-dd HH:mm:ss"
|
||||
>
|
||||
>
|
||||
</el-date-picker>
|
||||
@ -91,7 +93,7 @@
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="是否双向同步" prop="isTowSync">
|
||||
<el-radio-group v-model="innerFormData.isTowSync" :disabled="isEdit">
|
||||
<el-radio-group v-model="innerFormData.isTowSync">
|
||||
<el-radio :label="'1'">是</el-radio>
|
||||
<el-radio :label="'0'">否</el-radio>
|
||||
</el-radio-group>
|
||||
@ -134,7 +136,8 @@
|
||||
// 创建表单数据的副本,避免直接修改props
|
||||
innerFormData: this.initFormData(),
|
||||
rules: {
|
||||
storeId: [{ required: true, message: '请选择店铺', trigger: 'blur' }],
|
||||
storeId: [{ required: true, message: '请选择店铺', trigger: 'change' }],
|
||||
// storeName: [{ required: true, message: '请输入店铺名字', trigger: 'blur' }],
|
||||
dbIp: [
|
||||
{ required: true, message: '请输入数据库IP地址', trigger: 'blur' },
|
||||
{
|
||||
@ -175,9 +178,9 @@
|
||||
remark: [
|
||||
{ required: true, message: '请输入备注信息', trigger: 'change' },
|
||||
],
|
||||
refreshTime: [
|
||||
{ required: true, message: '请选择刷新时间', trigger: 'change' },
|
||||
],
|
||||
// refreshTime: [
|
||||
// { required: true, message: '请选择刷新时间', trigger: 'change' },
|
||||
// ],
|
||||
isTowSync: [
|
||||
{
|
||||
required: true,
|
||||
@ -219,6 +222,7 @@
|
||||
initFormData() {
|
||||
return {
|
||||
storeId: '',
|
||||
storeName:'',
|
||||
dbIp: '',
|
||||
dbType: '',
|
||||
dbName: '',
|
||||
@ -252,6 +256,7 @@
|
||||
this.$refs.formRef.validate((valid) => {
|
||||
if (valid) {
|
||||
this.$emit('save', this.cloneData(this.innerFormData))
|
||||
this.myVisible=false
|
||||
} else {
|
||||
this.$message.error('请完善表单信息')
|
||||
return false
|
||||
|
||||
@ -43,6 +43,7 @@
|
||||
|
||||
<el-table border :data="dbConfigList" stripe>
|
||||
<el-table-column label="店铺ID" prop="storeId" />
|
||||
<el-table-column label="店铺名字" prop="storeName" />
|
||||
<el-table-column label="数据库IP地址" prop="dbIp" />
|
||||
<el-table-column label="数据库类型" prop="dbType" />
|
||||
<el-table-column label="数据库名称" prop="dbName" />
|
||||
@ -252,7 +253,8 @@
|
||||
let res = null
|
||||
if (this.isEditMode) {
|
||||
res = await StoreConfApi.updateConfList({
|
||||
...omit(data, ['refreshTime', 'isTowSync']),
|
||||
// ...omit(data, ['refreshTime', 'isTowSync']),
|
||||
...omit(data, ['storeName']),
|
||||
})
|
||||
} else {
|
||||
res = await StoreConfApi.createConfList(data)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user