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

683 行
30 KiB
HTML
可执行文件

<!--[1.7.90]-->
<style>
th {
background-color: #f5f7fa !important;
}
th > .cell {
white-space: nowrap !important;
text-align: center;
}
th, td {
text-align: center;
line-height: 30px;
padding: 0;
}
th > .cell, td > .cell {
text-align: center;
}
.el-pagination {
padding: 8px;
}
.el-input {
width: 200px;
}
.el-table__row > td:last-child > .cell {
white-space: nowrap;
}
.center-content {
margin: 20px 0;
display: flex;
justify-content: space-between;
align-items: center;
}
.center-content .el-input__inner {
padding: 0 15px;
text-align: left;
}
.small-dialog-content {
margin-left: calc(7% + 40px);
}
.goods_title {
padding: 10px 0;
}
.el-input {
margin-bottom: 10px;
}
</style>
<div class="purchaseBox" id="rule" v-cloak>
<div class="goods_title">
<el-collapse accordion>
<el-collapse-item>
<template slot="title">
<el-button type="text" size="mini">拆分组合需知>>></el-button>
</template>
<div>1. 请先制定大件商品与小件商品的规则(例如大件商品选择矿泉水整箱,小件商品选择矿泉水,规则数量填写关联数量24:一箱矿泉水由24瓶矿泉水组成)</div>
<div>2. 拆分操作是将大件商品拆成小件商品,拆分数量指的是要拆的大件商品的数量,操作成功后大件商品库存减少,小件商品的库存根据规则增加相应的关联数量</div>
<div>3. 组合操作是将小件商品组合成大件商品,组合数量是指小件商品的数量,操作成功后小件商品库存减少,大件商品的库存根据规则增加相应的数量(小件商品的组合数量/关联数量 = 大件商品增加的数量)
</div>
</el-collapse-item>
</el-collapse>
</div>
<div class="center-content">
<div>
<el-input placeholder="名称/货号/条码"
type="text"
clearable
size="small"
v-model="name"></el-input>
<el-button type="primary" plain @click="search" size="small">搜索</el-button>
</div>
</div>
<div style=" margin: 10px 0;">
<el-table border :data="list" style="width: 100%; margin-top: 20px;border: none;"
size="mini"
max-height="500"
v-loading="loading"
element-loading-text="数据获取中"
element-loading-spinner="el-icon-loading">
<el-table-column prop="index" label="序号"></el-table-column>
<el-table-column prop="large_name" label="大件商品"></el-table-column>
<el-table-column prop="large_company" label="大件单位"></el-table-column>
<el-table-column prop="small_name" label="小件商品"></el-table-column>
<el-table-column prop="small_company" label="小件单位"></el-table-column>
<el-table-column prop="num" label="关联数量"></el-table-column>
<el-table-column prop="add_time" label="添加时间"></el-table-column>
<el-table-column fixed="right" label="操作" width="200px" style="border-right: none;">
<template slot-scope="scope">
<if condition="$authArr['dosubmitsplit'] eq true">
<el-button @click="split(scope.row.id,scope.row.small_goods_id,scope.row.small_sku_id)"
type="text" size="small">拆分
</el-button>
<el-button @click="combine(scope.row.id,scope.row.large_goods_id,scope.row.large_sku_id)" type="text" size="small">组合</el-button>
</if>
<if condition="$authArr['record'] eq true">
<el-button @click="record(scope.row.id)" type="text" size="small">记录</el-button>
</if>
<if condition="$authArr['Delete'] eq true">
<el-button @click="Delete(scope.row.id)" type="text" size="small">删除</el-button>
</if>
</template>
</el-table-column>
</el-table>
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
:page-sizes="[10, 15, 20, 25, 30, 35, 40, 45, 50]"
:page-size="100"
layout="total, sizes, prev, pager, next, jumper"
:total="currentLen">
</el-pagination>
</div>
<!--拆分-->
<div class="dialog-details">
<template>
<el-dialog title="数量" :modal-append-to-body="false" :visible.sync="SplitStatus" style="text-align: center;">
<el-input v-model="OperationNum" placeholder="数量" size="small" style="width: 300px"></el-input>
<el-select v-model="purchase_order_id" placeholder="请选择绑定采购单" v-if="supplier_type == 2" size="small">
<el-option
v-for="item in purchase_list"
:key="item.purchase_order_id"
:label="item.order_number"
:value="item.purchase_order_id">
</el-option>
</el-select>
<el-button size="small" @click="splitOperation">提交</el-button>
</if>
</el-dialog>
</template>
</div>
<div>
<span style="color: red;font-size: 18px">制定规则:</span>
<el-button size="small" @click="largeGoods" style="width: 200px">{{LargeName}}</el-button>
<span> = </span>
<el-button size="small" @click="smallGoods" style="width: 200px">{{SmallName}}</el-button>
<span> * </span>
<el-input v-model="num" placeholder="数量" size="small" style="width: 100px"></el-input>
<if condition="$authArr['splitgoodsset'] eq true">
<el-button size="small" @click="addRule">保存</el-button>
</if>
</div>
<!--/弹出框/-->
<div class="dialog-details">
<template>
<el-dialog title="选择商品" :modal-append-to-body="false" :visible.sync="outerVisible">
<div class="dialog-details-first">
<template>
<div style="display: flex;">
<el-input
size="small"
style="margin-right: 20px;width: 200px"
class="el-input-remote"
v-model="searchText"
placeholder="名称/货号/条码">
</el-input>
<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>
<el-button type="primary" plain @click="searchGoods" size="small" style="height: 33px">搜索
</el-button>
</div>
</template>
</div>
<template>
<el-table
v-loading="loadingTwo"
:data="goodsArr"
border
style="width: 100%; margin-top: 20px">
<el-table-column prop="goods_number" label="货号"></el-table-column>
<el-table-column prop="sku_goods_number" label="货号"></el-table-column>
<el-table-column prop="goods_name" label="商品名称"></el-table-column>
<el-table-column prop="sku_name" label="规格"></el-table-column>
<el-table-column prop="company" label="单位"></el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<el-button type="text" size="mini" @click="Choice(scope.$index)">选择</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
@size-change="handleSizeChangeTwo"
@current-change="handleCurrentChangeTow"
:current-page="currentPageTwo"
:page-sizes="[10, 15, 20, 25, 30, 35, 40, 45, 50]"
:page-size="100"
layout="total, sizes, prev, pager, next, jumper"
:total="currentLenTwo">
</el-pagination>
</template>
</el-dialog>
</template>
</div>
<!--记录-->
<div class="dialog-details">
<template>
<el-dialog title="记录" :modal-append-to-body="false" :visible.sync="RecordStatus">
<el-table
v-loading="loadingThree"
:data="recordList"
element-loading-text="数据获取中"
border
style="width: 100%; margin-top: 20px">
<el-table-column prop="index" label="序号"></el-table-column>
<el-table-column prop="large_name" label="大件商品" show-overflow-tooltip></el-table-column>
<el-table-column prop="large_company" label="大件单位" show-overflow-tooltip></el-table-column>
<el-table-column prop="small_name" label="小件商品" show-overflow-tooltip></el-table-column>
<el-table-column prop="small_company" label="小件单位" show-overflow-tooltip></el-table-column>
<el-table-column prop="num" label="关联数量" show-overflow-tooltip></el-table-column>
<el-table-column prop="large_num" label="大件数量" show-overflow-tooltip></el-table-column>
<el-table-column prop="small_num" label="小件数量" show-overflow-tooltip></el-table-column>
<el-table-column prop="type_name" label="操作类型" show-overflow-tooltip></el-table-column>
<el-table-column prop="add_time" label="操作时间" show-overflow-tooltip></el-table-column>
</el-table>
<el-pagination
@size-change="handleSizeChangeThree"
@current-change="handleCurrentChangeThree"
:current-page="currentPageThree"
:page-sizes="[10, 15, 20, 25, 30, 35, 40, 45, 50]"
:page-size="100"
layout="total, sizes, prev, pager, next, jumper"
:total="currentLenThree">
</el-pagination>
</el-dialog>
</template>
</div>
</div>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/Retail/common/js/select-goods-category.js"></script>
<script type="text/javascript">
var rule = new Vue({
el: "#rule",
data: function () {
return {
store_id: localStorage.store_id,
supplier_type: "{$supplier_type}", //2寄售供货商
purchase_list: [],
purchase_order_id:"", //采购单id
name: "",
list: [],
currentPage: 1,
currentLimit: 10,
currentLen: 0,
loading: true,
outerVisible: false,
currentPageTwo: 1,
currentLimitTwo: 10,
currentLenTwo: 0,
searchText: "",
goodsClassId1: "",
goodsClassId2: "",
goodsClassId3: "",
goodsArr: [], //商品档案信息
notInIds: "", //选中的大件商品或小件商品
loadingTwo: true,
LargeGoods: {}, //大件商品
SmallGoods: {}, //小件商品
LargeName: "大件商品",
SmallName: "小件件商品",
type: 1, //1大件商品 2小件商品
num: "", //数量
SplitStatus: false, //拆分
OperationType: 1, //1拆分 2组合
OperationNum: "", //操作数量
OperationId: "", //操作id
RecordStatus: false, //记录
recordList: [],
loadingThree: true,
currentPageThree: 1,
currentLimitThree: 10,
currentLenThree: 0,
}
},
methods: {
handleSizeChange: function (val) {
this.currentLimit = val;//切换每页数量
this.currentPage = 1;
this.getData();
},
handleCurrentChange: function (val) {
this.currentPage = val;
this.getData();//切换页数
},
//搜索
search: function () {
this.currentPage = 1;
this.getData();
},
//查询
getData: function () {
var that = this;
that.loading = true;
var page = that.currentPage;
var limit = that.currentLimit;
var name = that.name;
$.ajax({
url: "{:U('splitgoodslist')}",
type: "post",
data: {
page: page,
limit: limit,
name: name
},
success: function (res) {
that.loading = false;
that.list = [];
that.list = res.data;
that.$nextTick(function () {
that.currentLen = parseInt(res.count);
})
}
})
},
handleSizeChangeTwo: function (val) {
this.currentLimitTwo = val;//切换每页数量
this.currentPageTwo = 1;
this.goodsList();
},
handleCurrentChangeTow: function (val) {
this.currentPageTwo = val;
this.goodsList();//切换页数
},
searchGoods: function () {
var that = this;
this.currentPageTwo = 1;
that.goodsList();
},
goodsList: function () {
var that = this;
var notInIds = that.notInIds;
var searchText = that.searchText;
$.ajax({
url: "{:U(SSaleList)}",
type: 'POST',
data: {
page: this.currentPageTwo,
limit: this.currentLimitTwo,
notInIds: notInIds,
searchText: this.searchText,
person1: that.goodsClassId1,
person2: that.goodsClassId2,
person3: that.goodsClassId3,
},
success: function (res) {
if (res.status == 1) {
that.loadingTwo = false;
that.goodsArr = [];
that.goodsArr = res.data;
that.$nextTick(function () {
that.currentLenTwo = parseInt(res.count);
})
} else {
that.$confirm(res.msg, '提示', {
confirmButtonText: '确定',
type: 'warning'
}).then(() => {
}).catch(() => {
});
}
}
});
},
largeGoods: function () {
//大件商品
var that = this;
that.type = 1;
that.outerVisible = true;
that.searchText = "";
var SmallGoods = that.SmallGoods;
if (!$.isEmptyObject(SmallGoods)) {
that.notInIds = SmallGoods.id;
} else {
that.notInIds = "";
}
that.goodsList();
},
smallGoods: function () {
//小件商品
var that = this;
that.type = 2;
that.outerVisible = true;
that.searchText = "";
var LargeGoods = that.LargeGoods;
if (!$.isEmptyObject(LargeGoods)) {
that.notInIds = LargeGoods.id;
} else {
that.notInIds = "";
}
that.goodsList();
},
Choice: function (index) {
//大件商品
var that = this;
var type = that.type;
var goodsArr = that.goodsArr;
if (type == 1) {
var LargeGoods = that.LargeGoods;
LargeGoods.id = goodsArr[index].id;
LargeGoods.large_goods_id = goodsArr[index].goods_id;
LargeGoods.large_sku_id = goodsArr[index].sku_id;
LargeGoods.large_attribute_state = goodsArr[index].attribute_state;
LargeGoods.large_pricing_method = goodsArr[index].pricing_method;
LargeGoods.large_name = goodsArr[index].goods_name;
LargeGoods.large_sku_name = goodsArr[index].sku_name;
LargeGoods.large_number = goodsArr[index].goods_number;
LargeGoods.large_sku_number = goodsArr[index].sku_goods_number;
LargeGoods.large_code = goodsArr[index].goods_code;
LargeGoods.large_sku_code = goodsArr[index].sku_code;
LargeGoods.large_company = goodsArr[index].company;
that.LargeName = goodsArr[index].goods_name + goodsArr[index].sku_name;
} else if (type == 2) {
var SmallGoods = that.SmallGoods;
SmallGoods.id = goodsArr[index].id;
SmallGoods.small_goods_id = goodsArr[index].goods_id;
SmallGoods.small_sku_id = goodsArr[index].sku_id;
SmallGoods.small_attribute_state = goodsArr[index].attribute_state;
SmallGoods.small_pricing_method = goodsArr[index].pricing_method;
SmallGoods.small_name = goodsArr[index].goods_name;
SmallGoods.small_sku_name = goodsArr[index].sku_name;
SmallGoods.small_number = goodsArr[index].goods_number;
SmallGoods.small_sku_number = goodsArr[index].sku_goods_number;
SmallGoods.small_code = goodsArr[index].goods_code;
SmallGoods.small_sku_code = goodsArr[index].sku_code;
SmallGoods.small_company = goodsArr[index].company;
that.SmallName = goodsArr[index].goods_name + goodsArr[index].sku_name;
}
that.outerVisible = false;
},
addRule: function () {
var that = this;
var reg = /^\+?[1-9][0-9]*$/;
var LargeGoods = that.LargeGoods;
var SmallGoods = that.SmallGoods;
var num = that.num;
if ($.isEmptyObject(LargeGoods)) {
that.$message({type: "warning", message: "请选择大件商品", duration: 1000});
return false;
}
if ($.isEmptyObject(SmallGoods)) {
that.$message({type: "warning", message: "请选择小件商品", duration: 1000});
return false;
}
if (!num || !reg.test(num)) {
that.$message({type: "warning", message: "请输入正确数量", duration: 1000});
return false;
}
$.ajax({
url: "{:U('splitgoodsset')}",
type: "post",
data: {
LargeGoods: LargeGoods,
SmallGoods: SmallGoods,
num: num,
},
success: function (res) {
if (res.status == 1) {
that.$message({
type: "success",
message: res.msg,
duration: 1000,
onClose:function(){
that.LargeName = "大件商品";
that.SmallName = "小件商品";
that.LargeGoods = {};
that.SmallGoods = {};
that.getData();
}
});
} else {
that.$message({type: "warning", message: res.msg, duration: 1000});
}
}
})
},
Delete: function (id) {
var that = this;
that.$confirm('确认删除该规则, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
$.ajax({
url: "{:U('deleteRule')}",
type: "post",
data: {id: id},
success: function (res) {
if (res.status == 1) {
that.getData();
that.$message({
type: "success",
message: res.msg,
duration: 1000,
});
} else {
that.$message({type: "warning", message: res.msg, duration: 1000});
}
}
})
}).catch(() => {
that.$message({
type: 'info',
message: '已取消删除'
});
});
},
split: function (id, goods_id, sku_id) {
//拆分
var that = this;
var supplier_type = that.supplier_type; //2寄售供货商
that.SplitStatus = true;
that.OperationType = 1;
that.OperationId = id;
if (supplier_type == 2) {
$.ajax({
url: "{:U('getPurchaseList')}",
type: "post",
data: {goods_id: goods_id, sku_id: sku_id},
success: function (res) {
if (res.status == 1) {
that.purchase_list = [];
that.purchase_list = res.data.purchase_list;
}else{
that.purchase_list = [];
}
}
})
}
},
combine: function (id,goods_id,sku_id) {
//组合
var that = this;
that.SplitStatus = true;
that.OperationType = 2;
that.OperationId = id;
var supplier_type = that.supplier_type; //2寄售供货商
if (supplier_type == 2) {
$.ajax({
url: "{:U('getPurchaseList')}",
type: "post",
data: {goods_id: goods_id, sku_id: sku_id},
success: function (res) {
if (res.status == 1) {
that.purchase_list = [];
that.purchase_list = res.data.purchase_list;
}else{
that.purchase_list = [];
}
}
})
}
},
splitOperation: function () {
var that = this;
var supplier_type = that.supplier_type;
var reg = /^\+?[1-9][0-9]*$/;
var OperationId = that.OperationId;
var OperationType = that.OperationType;
var OperationNum = that.OperationNum;
var purchase_order_id = that.purchase_order_id;
if (!OperationId || !OperationType || !OperationNum) {
that.$message({
type: "error",
message: "参数缺失",
duration: 1000
})
return false;
}
if (!reg.test(OperationNum)) {
that.$message({
type: "error",
message: "数量有误",
duration: 1000
})
return false;
}
if(supplier_type == 2 && that.purchase_list.length > 0 && purchase_order_id == ''){
that.$message({
type:"error",
message:"请绑定采购单",
duration:1500
});
return false;
}
this.$confirm('确认操作, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
$.ajax({
url: "{:U('dosubmitsplit')}",
data: {
id: OperationId,
operation_type: OperationType,
operation_num: OperationNum,
purchase_order_id:purchase_order_id
},
type: "post",
success: function (res) {
if (res.status == 1) {
that.$message({
type: "success",
message: res.msg,
duration: 1000,
onClose: function () {
that.OperationNum = "";
that.SplitStatus = false;
that.purchase_order_id = '';
that.purchase_list=[];
}
})
} else {
that.$message({
type: "error",
message: res.msg,
duration: 2000
})
}
}
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
});
},
handleSizeChangeThree: function (val) {
this.currentLimitThree = val;//切换每页数量
this.currentPageThree = 1;
this.recordInfo();
},
handleCurrentChangeThree: function (val) {
this.currentPageThree = val;
this.recordInfo();//切换页数
},
record: function (id) {
//记录
var that = this;
that.RecordStatus = true;
that.OperationId = id;
that.recordInfo();
},
recordInfo: function () {
var that = this;
var OperationId = that.OperationId;
$.ajax({
url: "{:U('recordList')}",
type: "post",
data: {
rule_id: OperationId,
page: that.currentPageThree,
limit: that.currentLimitThree
},
success: function (res) {
that.loadingThree = false;
that.recordList = [];
that.recordList = res.data;
that.$nextTick(function () {
that.currentLenThree = parseInt(res.count);
})
}
})
}
},
created: function () {
this.getData();
}
})
</script>