2022-08-02 10:16:07 +08:00
|
|
|
<template>
|
2022-09-01 18:49:41 +08:00
|
|
|
<div class="conent">
|
|
|
|
|
<!-- 新增按钮 -->
|
2023-04-17 18:56:59 +08:00
|
|
|
<el-button type="success" @click="handAdd">新增</el-button>
|
|
|
|
|
<el-button type="primary" @click="syncShopStock('all')">同步所有店铺库存</el-button>
|
2022-09-01 18:49:41 +08:00
|
|
|
|
2022-09-08 01:02:07 +08:00
|
|
|
<div class="table" style="margin-top: 10px">
|
2022-09-19 11:10:05 +08:00
|
|
|
<el-table v-loading="loading" :data="tableData" style="width: 100%">
|
2022-10-24 00:23:09 +08:00
|
|
|
<el-table-column prop="name" label="店铺名称">
|
2022-09-01 18:49:41 +08:00
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column prop="plat_id" label="所属平台"></el-table-column>
|
2023-07-15 18:18:22 +08:00
|
|
|
<el-table-column prop="owner_id" label="商家店铺id"></el-table-column>
|
|
|
|
|
<el-table-column prop="refresh_token_expires_at" label="授权过期时间点"></el-table-column>
|
2022-10-24 21:30:23 +08:00
|
|
|
<el-table-column label="成本变动">
|
2022-10-24 00:23:09 +08:00
|
|
|
<template slot-scope="scope">
|
2022-10-24 21:30:23 +08:00
|
|
|
<el-input v-model="scope.row.ratio" placeholder="成本变动" @change="handleCellChange(scope.row)">
|
2022-10-24 00:23:09 +08:00
|
|
|
</el-input>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
2022-09-01 18:49:41 +08:00
|
|
|
<el-table-column label="操作">
|
|
|
|
|
<template slot-scope="scope">
|
2023-04-17 18:56:59 +08:00
|
|
|
<el-button type="danger" v-if="scope.row.status === '未授权'" size="small"><a :href="scope.row.authUrl"
|
|
|
|
|
target="_blank" rel="noopener noreferrer">授权</a>
|
2022-09-01 18:49:41 +08:00
|
|
|
</el-button>
|
2023-04-17 18:56:59 +08:00
|
|
|
|
2022-09-01 18:49:41 +08:00
|
|
|
<div v-if="scope.row.status === '已授权'">
|
2023-04-17 18:56:59 +08:00
|
|
|
<el-button type="success" :disabled="true" size="small">{{ scope.row.status }}</el-button>
|
|
|
|
|
<el-button @click="download(scope.row)" size="small">下载商品</el-button>
|
|
|
|
|
<el-button type="primary" v-if="scope.row.status === '已授权'" size="small"
|
|
|
|
|
@click="syncShopStock(scope.row.id)">同步库存</el-button>
|
2022-09-01 18:49:41 +08:00
|
|
|
</div>
|
|
|
|
|
<div v-if="scope.row.status === '重新授权'">
|
2023-04-17 18:56:59 +08:00
|
|
|
<el-button type="danger" target="_blank" size="small">
|
|
|
|
|
<a :href="scope.row.authUrl" rel="noopener noreferrer">重新授权</a>
|
2022-09-01 18:49:41 +08:00
|
|
|
</el-button>
|
2023-04-17 18:56:59 +08:00
|
|
|
<el-button @click="download(scope.row)" size="small">下载商品</el-button>
|
2022-09-01 18:49:41 +08:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div v-if="scope.row.status === '无需授权'">
|
2023-04-17 18:56:59 +08:00
|
|
|
<el-button type="success" :disabled="true" size="small">{{ scope.row.status }}</el-button>
|
2022-09-01 18:49:41 +08:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- 分页功能 -->
|
|
|
|
|
<div class="block">
|
|
|
|
|
<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
|
|
|
|
|
:current-page="current_page" :page-sizes="[15, 50, 100]" :page-size="per_page"
|
|
|
|
|
layout="total, sizes, prev, pager, next, jumper" :total="Paginationdata.total">
|
|
|
|
|
</el-pagination>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- 新增店铺 -->
|
2022-10-24 00:23:09 +08:00
|
|
|
<el-dialog title="新增店铺" :visible.sync="dialogFormVisible" :close-on-click-modal="false" width="20%">
|
|
|
|
|
<el-form ref="form" :rules="rules" :model="form" lable-width="80px">
|
2022-09-01 18:49:41 +08:00
|
|
|
<el-form-item label="店铺名称">
|
2022-10-24 00:23:09 +08:00
|
|
|
<el-input v-model="form.name" placeholder="输入店铺名称" style="width: 400px;"></el-input>
|
2022-09-01 18:49:41 +08:00
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="店铺平台">
|
2022-10-24 00:23:09 +08:00
|
|
|
<el-select v-model="form.plat_id" placeholder="输入店铺平台" style="width: 400px;">
|
2022-09-01 18:49:41 +08:00
|
|
|
<el-option v-for="(item, index) in storeId" :key="index" :label="item" :value="index">
|
|
|
|
|
</el-option>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
2022-10-24 21:30:23 +08:00
|
|
|
<el-form-item label="成本变动">
|
|
|
|
|
<el-input v-model="form.ratio" placeholder="成本变动" style="width: 400px;"></el-input>
|
2022-10-24 00:23:09 +08:00
|
|
|
</el-form-item>
|
2022-09-01 18:49:41 +08:00
|
|
|
</el-form>
|
|
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
|
|
<el-button @click="dialogFormVisible = false">取 消</el-button>
|
|
|
|
|
<el-button type="primary" @click="addSubmit">确 定</el-button>
|
2022-08-17 15:40:04 +08:00
|
|
|
</div>
|
2022-09-01 18:49:41 +08:00
|
|
|
</el-dialog>
|
2022-08-06 20:03:35 +08:00
|
|
|
</div>
|
2022-08-02 10:16:07 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2023-04-17 18:56:59 +08:00
|
|
|
import { shopListId, shopAdd, storeList, downloadGoods, updateStore, syncStoreStock } from "../../api/shop";
|
2022-09-01 18:49:41 +08:00
|
|
|
export default {
|
2022-08-25 11:21:14 +08:00
|
|
|
data() {
|
2022-09-01 18:49:41 +08:00
|
|
|
return {
|
|
|
|
|
dialogFormVisible: false,
|
|
|
|
|
form: {
|
|
|
|
|
name: "",
|
|
|
|
|
plat_id: "",
|
2022-10-24 21:30:23 +08:00
|
|
|
ratio: "*1",
|
2022-10-24 00:23:09 +08:00
|
|
|
},
|
|
|
|
|
rules: {
|
|
|
|
|
name: [
|
|
|
|
|
{ required: true, message: '请输入店铺名称', trigger: 'blur' },
|
|
|
|
|
],
|
|
|
|
|
plat_id: [
|
|
|
|
|
{ required: true, message: '请选择店铺平台', trigger: 'blur' },
|
|
|
|
|
],
|
|
|
|
|
ratio: [
|
2022-10-24 21:30:23 +08:00
|
|
|
{ required: true, message: '请输入成本变动', trigger: 'blur', },
|
2022-10-24 00:23:09 +08:00
|
|
|
],
|
2022-09-01 18:49:41 +08:00
|
|
|
},
|
|
|
|
|
storeId: [], // 店铺id
|
2022-09-19 11:10:05 +08:00
|
|
|
loading: true,
|
2022-09-01 18:49:41 +08:00
|
|
|
tableData: [],
|
|
|
|
|
Paginationdata: {}, //分页相关数据
|
|
|
|
|
current_page: 1, //当前页
|
|
|
|
|
per_page: 15, //每页显示数量
|
|
|
|
|
};
|
2022-08-06 20:03:35 +08:00
|
|
|
},
|
2022-08-25 11:21:14 +08:00
|
|
|
mounted() {
|
2022-09-01 18:49:41 +08:00
|
|
|
// 展示店铺列表
|
|
|
|
|
this.getStoreList();
|
2022-08-04 18:59:32 +08:00
|
|
|
},
|
2022-08-25 11:21:14 +08:00
|
|
|
methods: {
|
2022-09-01 18:49:41 +08:00
|
|
|
// 点击新增
|
|
|
|
|
handAdd() {
|
|
|
|
|
this.form.name = "";
|
|
|
|
|
this.form.plat_id = "";
|
|
|
|
|
this.dialogFormVisible = true;
|
|
|
|
|
this.getshop();
|
|
|
|
|
},
|
2022-08-12 18:26:27 +08:00
|
|
|
|
2022-09-01 18:49:41 +08:00
|
|
|
// 新增商品
|
|
|
|
|
addSubmit() {
|
|
|
|
|
const datas = this.form;
|
|
|
|
|
shopAdd(datas).then((res) => {
|
|
|
|
|
if (res.status == 200) {
|
|
|
|
|
this.$message({
|
|
|
|
|
type: "success",
|
|
|
|
|
message: "添加成功",
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
this.getStoreList();
|
2022-08-25 11:21:14 +08:00
|
|
|
});
|
2022-09-01 18:49:41 +08:00
|
|
|
this.dialogFormVisible = false;
|
|
|
|
|
},
|
2022-08-25 11:21:14 +08:00
|
|
|
|
2022-09-01 18:49:41 +08:00
|
|
|
// 店铺列表
|
|
|
|
|
getStoreList() {
|
|
|
|
|
let page = {
|
|
|
|
|
page: this.current_page,
|
|
|
|
|
per_page: this.per_page,
|
|
|
|
|
};
|
|
|
|
|
storeList(page).then((res) => {
|
|
|
|
|
this.tableData = res.data.data;
|
|
|
|
|
this.Paginationdata = res.data.meta;
|
|
|
|
|
});
|
2022-09-19 11:10:05 +08:00
|
|
|
this.loading = false
|
2022-09-01 18:49:41 +08:00
|
|
|
},
|
2022-08-17 15:40:04 +08:00
|
|
|
|
2022-09-01 18:49:41 +08:00
|
|
|
//分页功能
|
|
|
|
|
handleSizeChange(val) {
|
|
|
|
|
//当前条数
|
|
|
|
|
this.per_page = val;
|
|
|
|
|
this.getStoreList();
|
|
|
|
|
},
|
|
|
|
|
handleCurrentChange(val) {
|
|
|
|
|
//当前页
|
|
|
|
|
this.current_page = val;
|
|
|
|
|
this.getStoreList();
|
|
|
|
|
},
|
2022-08-25 11:21:14 +08:00
|
|
|
|
2022-09-01 18:49:41 +08:00
|
|
|
// 店铺平台
|
|
|
|
|
getshop() {
|
|
|
|
|
shopListId().then((res) => {
|
|
|
|
|
this.storeId = res.data.data;
|
|
|
|
|
});
|
|
|
|
|
},
|
2022-08-25 11:21:14 +08:00
|
|
|
|
2022-09-01 18:49:41 +08:00
|
|
|
// 下载商品
|
|
|
|
|
download(row) {
|
2022-09-19 13:21:36 +08:00
|
|
|
const loading = this.$loading({
|
|
|
|
|
lock: true,
|
|
|
|
|
text: row.name + ' 店铺商品下载中...',
|
|
|
|
|
spinner: 'el-icon-loading',
|
|
|
|
|
background: 'rgba(0, 0, 0, 0.7)'
|
|
|
|
|
});
|
2022-09-01 18:49:41 +08:00
|
|
|
downloadGoods(row.id).then((res) => {
|
2022-09-19 13:21:36 +08:00
|
|
|
loading.close();
|
|
|
|
|
this.$message({
|
|
|
|
|
type: "success",
|
|
|
|
|
message: res.data.message,
|
|
|
|
|
});
|
2022-09-01 18:49:41 +08:00
|
|
|
});
|
|
|
|
|
},
|
2022-10-24 00:23:09 +08:00
|
|
|
handleCellChange(row) {
|
2022-10-24 21:30:23 +08:00
|
|
|
this.$confirm('确认修改成本变动吗?', '提示', {
|
2022-10-24 00:23:09 +08:00
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
|
type: 'warning'
|
|
|
|
|
}).then(() => {
|
|
|
|
|
updateStore(row.id, { ratio: row.ratio }).then((res) => {
|
|
|
|
|
this.$message({
|
|
|
|
|
type: 'info',
|
|
|
|
|
message: res.data.message
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
},
|
2023-04-17 18:56:59 +08:00
|
|
|
// 同步
|
|
|
|
|
syncShopStock(id) {
|
|
|
|
|
let loading = this.$loading({
|
|
|
|
|
lock: true,
|
|
|
|
|
text: '店铺商品库存同步中...',
|
|
|
|
|
spinner: 'el-icon-loading',
|
|
|
|
|
background: 'rgba(0, 0, 0, 0.7)'
|
|
|
|
|
});
|
|
|
|
|
syncStoreStock({ shop_id: id }).then((res) => {
|
|
|
|
|
loading.close();
|
|
|
|
|
this.$message({
|
|
|
|
|
type: 'info',
|
|
|
|
|
message: res.data.message
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
}
|
2022-08-17 15:40:04 +08:00
|
|
|
},
|
2022-09-01 18:49:41 +08:00
|
|
|
};
|
2022-08-02 10:16:07 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2022-09-01 18:49:41 +08:00
|
|
|
a {
|
2022-08-25 11:21:14 +08:00
|
|
|
text-decoration: none;
|
|
|
|
|
color: white;
|
2022-09-01 18:49:41 +08:00
|
|
|
}
|
2022-09-19 13:21:36 +08:00
|
|
|
|
2022-09-01 18:49:41 +08:00
|
|
|
.block {
|
2022-09-01 18:56:36 +08:00
|
|
|
margin-top: 20px;
|
2022-09-01 18:49:41 +08:00
|
|
|
}
|
|
|
|
|
</style>
|