文件
mashangyoujiu/Application/Retail/View/Goods/sync_goods.html

367 行
16 KiB
HTML
可执行文件

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<!doctype html>
<!--[1.8.50]-->
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>同步商品</title>
<link rel="stylesheet" href="__PUBLIC__/vue/element-ui.css">
<style>
[v-cloak] {
display: none;
}
.seek {
margin-right: 10px;
margin-top: 10px;
white-space: nowrap;
}
.dialog {
width: 70%;
}
</style>
</head>
<body>
<div id="app" v-cloak style="width: 100%;padding-left: 10px;">
<el-collapse accordion>
<el-collapse-item>
<template slot="title">
同步商品须知>>></i>
</template>
<div>1.同步商户商品时,商品库存和商品进价是不会同步到门店的</div>
<div>2.一个商品在一个门店只能同步一次</div>
</el-collapse-item>
</el-collapse>
<!-- 搜索数据 -->
<div style="display: flex;padding-bottom: 15px;flex-wrap: wrap;">
<div class="seek">
<el-input v-model="seek_data.goods_name" placeholder="商品名称" clearable size="small"
style="width: 220px;"></el-input>
</div>
<div class="seek">
<el-input v-model="seek_data.keyword" placeholder="货号/条码" clearable size="small"
style="width: 220px;"></el-input>
</div>
<div class="seek">
<select-goods-category :user-type="2"
:store-id="store_id"
:category-id1.sync="goodsClassId1"
:category-id2.sync="goodsClassId2"
:category-id3.sync="goodsClassId3"></select-goods-category>
</div>
<div class="seek" style="display: flex;text-align: center;">
<el-button type="primary" @click="pageChange(1)" size="small">查询</el-button>
<el-button type="primary" @click="reset" size="small">重置</el-button>
</div>
</div>
<!-- 列表展示 -->
<template>
<div style="padding-bottom: 10px;">
<el-button type="primary" size="small" @click="batchSync">批量同步</el-button>
<el-button v-if="error_journal.length > 0" type="primary" size="small" @click="show_error = true">错误原因
</el-button>
</div>
<el-table :data="sync_goods" border size="small" @selection-change="ChooseSelectionChange">
<el-table-column type="selection" width="55" align="center"></el-table-column>
<el-table-column type="index" label="序号" width="55" align="center"></el-table-column>
<el-table-column prop="goods_name" label="商品名称" width="150" :show-overflow-tooltip="true"></el-table-column>
<el-table-column prop="subheading" label="副标题" width="150" :show-overflow-tooltip="true"></el-table-column>
<el-table-column prop="class_name" label="商品分类" :show-overflow-tooltip="true"></el-table-column>
<el-table-column prop="good_number" label="商品货号" width="160"
:show-overflow-tooltip="true"></el-table-column>
<el-table-column prop="code_name" label="商品条码" width="160"></el-table-column>
<el-table-column prop="third_goods_code" label="Q3编码" width="160"></el-table-column>
<el-table-column prop="company" label="单位" width="160"></el-table-column>
<el-table-column label="售价" align="center">
<el-table-column prop="retail_price" label="店内" width="100"></el-table-column>
<el-table-column prop="online_price" label="商城" width="100"></el-table-column>
</el-table-column>
<el-table-column label="会员价" align="center">
<el-table-column prop="store_vip_price" label="店内" width="100"></el-table-column>
<el-table-column prop="shop_vip_price" label="商城" width="100"></el-table-column>
<el-table-column prop="plus_price_state" label="Plus价" width="100"></el-table-column>
</el-table-column>
<el-table-column prop="weigh_type" label="称重类型" width="120"></el-table-column>
<el-table-column label="商品类型" width="120">
<template slot-scope="scope">
<span v-if="scope.row.attribute == 1">普通商品</span>
<el-button v-else type="text" size="small"
@click="seeSku(scope.row.id,scope.row.can_exchange_weigh,scope.row.sku)">规格信息
</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
@size-change="sizeChange"
@current-change="pageChange"
layout="total, sizes, prev, pager, next, jumper"
:pager-count="5"
:page-sizes="[10,20,30,40,50,60,70,80,90]"
:page-size="10"
:total="total">
</el-pagination>
</template>
<!-- 规格信息 -->
<el-dialog :modal-append-to-body="false" :visible.sync="show_sku" custom-class="dialog" :before-close="clearSku">
<template>
<el-table border :data="sku" size="small" max-height="500">
<el-table-column type="index" label="序号" width="50" align="center"></el-table-column>
<el-table-column prop="sku_name" label="规格名称" :show-overflow-tooltip="true"></el-table-column>
<el-table-column prop="sku_goods_number" label="规格货号" :show-overflow-tooltip="true"></el-table-column>
<el-table-column prop="code_name" label="规格条码" width="160"></el-table-column>
<el-table-column prop="third_goods_code" label="Q3编码" width="160"></el-table-column>
<el-table-column prop="weight_value" label="重量/kg" width="160"></el-table-column>
<el-table-column label="售价" align="center">
<el-table-column prop="retail_price" label="店内" width="100"></el-table-column>
<el-table-column prop="online_price" label="商城" width="100"></el-table-column>
</el-table-column>
<el-table-column label="会员价" align="center">
<el-table-column prop="store_vip_price" label="店内" width="100"></el-table-column>
<el-table-column prop="shop_vip_price" label="商城" width="100"></el-table-column>
<el-table-column prop="plus_price_state" label="Plus价" width="100"></el-table-column>
</el-table-column>
</el-table>
<!-- <div style="padding-top: 15px;text-align: center;">-->
<!-- <el-button type="primary" size="small" @click="saveSet">保存设置</el-button>-->
<!-- </div>-->
</template>
</el-dialog>
<!-- 同步失败原因 -->
<el-dialog :modal-append-to-body="false" :visible.sync="show_error">
<template>
<el-table border :data="error_journal" size="small" max-height="500">
<el-table-column type="index" width="80" align="center"></el-table-column>
<el-table-column prop="goods_name" label="商品名称" width="220"
:show-overflow-tooltip="true"></el-table-column>
<el-table-column prop="error" label="失败原因"></el-table-column>
</el-table>
</template>
</el-dialog>
</div>
</body>
<script src="__PUBLIC__/jquery/js/jquery-3.2.1.min.js"></script>
<script src="__PUBLIC__/vue/js/vue2.5.16.js"></script>
<script src="__PUBLIC__/vue/element-ui.js"></script>
<script src="__PUBLIC__/js/common.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/Retail/common/js/select-goods-category.js"></script>
<script>
var app = new Vue({
el: '#app',
data() {
return {
platform_type: 1,
store_id: localStorage.store_id,
industry_id: localStorage.industry_id,
seek_data: { // 搜索数据
goods_name: '', // 商品名称
keyword: '', // 商品货号、条码
},
goodsClassId1: "",
goodsClassId2: "",
goodsClassId3: "",
sync_goods: [], // 同步商品列表
chose_goods: [], // 勾选了的商品
page: 1, // 分页
limit: 10, // 每页显示条数
total: 0, // 总数 [int]
show_sku: false, // 规格信息(显示,隐藏)
mgoods_id: 0, // 同步商品id(遍历修改)
sku: [], // 规格
weight: 1, // 1.普通商品 2.称重商品
show_error: false, // 显示错误日志
error_journal: [], // 错误日志
};
},
methods: {
//商户平台类型 1默认系统 2微礼平台
getPlatformType(){
$.ajax({
url:'/index.php/Retail/Goods/getPlatformType',
type:"post",
data:{},
success:(res)=>{
this.platform_type = res.platform_type
}
})
},
// 获取同步列表
getSyncGoods() {
this.$loading({
lock: true,
text: '数据获取中,请等待...',
spinner: 'el-icon-loading',
background: 'rgba(255, 255, 255, 0.7)'
});
$.ajax({
url: "{:U('getSyncGoods')}",
type: "post",
data: {
seek_data: this.seek_data,
page: this.page,
industry_id: this.industry_id,
limit: this.limit,
person1: this.goodsClassId1,
person2: this.goodsClassId2,
person3: this.goodsClassId3
},
success: (res) => {
this.$loading().close();
if (res.status == 1) {
this.sync_goods = res.sync_goods;
this.total = res.total;
} else {
this.sync_goods = [];
this.total = 0;
}
}
})
},
// 重置表单
reset() {
this.seek_data = {
goods_name: '',
keyword: '',
};
this.pageChange(1);
},
// 分页
pageChange(val) {
this.page = val;
this.getSyncGoods();
},
// 验证商品全部数量
syncNumChange(sync_num, goods_num) {
this.$message.closeAll();
if (parseFloat(sync_num) > goods_num) {
this.$message.warning('提示:同步数量设置有误');
}
},
// 显示数量
sizeChange(val) {
this.limit = val;
this.page = 1;
this.getSyncGoods();
},
// 规格信息
seeSku(mgoods_id, weight, sku) {
this.show_sku = true;
this.mgoods_id = mgoods_id;
this.weight = weight;
this.sku = JSON.parse(JSON.stringify(sku));
},
// 保存设置
saveSet() {
if (!this.mgoods_id || this.mgoods_id == 1 || this.sku.length <= 0) {
return this.$message.warning('提示:保存失败,请刷新重试');
}
var sync_num = 0;
for (var i = 0; i < this.sku.length; i++) {
// 同步数量
if (!this.sku[i].sync_num || this.sku[i].sync_num == '') {
this.sku[i].sync_num = 0;
} else {
this.sku[i].sync_num = parseInt(this.sku[i].sync_num * 1000) / 1000;
}
if (this.sku[i].sync_num > this.sku[i].goods_num) {
return this.$message.warning('提示:规格【' + this.sku[i].sku_name + '】同步数量超出总部库存');
} else {
sync_num += parseInt(this.sku[i].sync_num * 1000) / 1000;
}
}
// 同步列表
var sync_goods = this.sync_goods;
sync_goods.find((val) => {
if (val.id === this.mgoods_id) {
val.sku = this.sku;
if (sync_num > 0) {
val.sync_num = sync_num;
}
}
});
this.sync_goods = sync_goods;
// 已勾选的商品
if (this.chose_goods.length > 0) {
var chose_goods = this.chose_goods;
chose_goods.find((val) => {
if (val.id === this.mgoods_id) {
val.sku = this.sku;
if (sync_num > 0) {
val.sync_num = sync_num;
}
}
});
this.chose_goods = chose_goods;
}
this.clearSku();
},
// 选择商品
ChooseSelectionChange(data) {
this.chose_goods = data;
},
// 批量同步
batchSync() {
if (this.chose_goods.length <= 0) {
return this.$message.warning('提示:请选择同步商品');
}
this.$loading({
lock: true,
text: '同步中...',
spinner: 'el-icon-loading',
background: 'rgba(255, 255, 255, 0.7)'
});
$.ajax({
url: "{:U('batchSync')}",
type: "post",
data: {chose_goods: JSON.stringify(this.chose_goods)},
success: (res) => {
this.$loading().close();
if (res.status == 1) {
this.$message.success(res.msg);
this.pageChange(1);
} else if (res.status == 2) {
this.$confirm('部分商品同步失败,点击确定打开失败原因列表', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.show_error = true;
this.error_journal = res.error_journal;
}).catch(() => {
this.error_journal = res.error_journal;
})
this.pageChange(1);
} else {
this.$message.error(res.msg)
}
}
})
},
// 清除规格信息
clearSku() {
this.show_sku = false;
this.mgoods_id = 0;
this.sku = [];
this.weight = 1;
},
},
created() {
this.pageChange(1);
},
})
</script>
</html>