初始上传

This commit is contained in:
2026-04-04 17:27:12 +08:00
parent 4d80d28eb4
commit b7e11774ee
11191 changed files with 1588469 additions and 0 deletions

View File

@@ -0,0 +1,271 @@
.form-content {
display: flex;
flex-wrap: wrap;
margin-top: 0.2rem;
.store-info {
.form-inline {
padding-left: 0.05rem;
}
}
.form-item {
margin-bottom: 0.1rem;
display: flex;
.form-label {
width: 1.3rem;
text-align: right;
padding-right: 0.1rem;
box-sizing: border-box;
height: 0.32rem;
line-height: 0.32rem;
.required {
color: red;
margin-right: 0.03rem;
}
}
.form-inline {
width: 2.4rem;
line-height: 0.32rem;
margin-right: 0.1rem;
box-sizing: border-box;
&.input {
input {
padding: 0 0.1rem;
}
}
.form-input {
border-width: 0.01rem;
border-style: solid;
background-color: #fff;
color: rgba(0, 0, 0, 0.85);
border-radius: 0.02rem;
padding-left: 0.1rem;
height: 0.32rem;
line-height: 0.32rem;
font-size: 0.14rem;
border-color: #e6e6e6;
}
}
}
}
.stock-body{
position: relative;
height: 100%;
.content-wrap {
padding: 0.15rem;
background-color: #fff;
@extend %body-overhide;
box-sizing: border-box;
.title {
font-size: 0.18rem;
margin-bottom: 0.2rem;
text-align: center;
}
.table-wrap {
position: relative;
margin-top: 40rpx;
border: 1rpx solid #dcdfe6;
.table-head {
background-color: #f7f7f7;
}
.table-body {
@extend %body-overhide;
max-height: 6rem;
.table-tr {
&:nth-child(1) {
position: absolute;
left: 0;
right: 0;
background: #fff;
z-index: 3;
}
&:nth-child(2) {
margin-top: 0.49rem;
}
&:last-of-type .table-td {
border-bottom: 0;
}
}
}
.table-tr {
display: flex;
}
.table-th,
.table-td {
display: flex;
align-items: center;
justify-content: center;
padding: 0.07rem 0.3rem;
border-bottom: 0.01rem solid #dcdfe6;
border-right: 0.01rem solid #dcdfe6;
text-align: center;
&:last-of-type {
border-right: 0;
justify-content: flex-end;
}
&.goods-name {
justify-content: flex-start;
image {
width: 0.45rem;
height: 0.45rem;
flex-shrink: 0;
}
.name {
margin-left: 0.1rem;
}
}
}
.delete {
margin: 0;
font-size: $uni-font-size-base;
background-color: $primary-color;
color: #fff;
line-height: 0.32rem;
height: 0.32rem;
&::after{
border-width: 0;
}
}
.table-empty {
justify-content: center;
padding: 0.3rem;
color: #999;
}
}
.select-goods-input,
.goods-name {
position: relative;
input {
flex: 1;
padding: 0 0.2rem;
}
.icontuodong {
font-size: 0.16rem;
position: absolute;
top: 0.17rem;
right: 0.34rem;
z-index: 2;
cursor: pointer;
}
}
input {
font-size: $uni-font-size-base !important;
border: 0.01rem solid #e6e6e6 !important;
height: 0.32rem;
}
}
.action-wrap {
position: absolute;
bottom: 0;
left: 0;
right: 0;
display: flex;
justify-content: space-between;
padding: 0.24rem 0.2rem;
align-items: center;
background-color: #fff;
z-index: 10;
.btn-wrap {
display: flex;
align-items: center;
justify-content: center;
button {
margin: 0;
min-width: 2.75rem;
height: 0.4rem;
line-height: 0.4rem;
font-size: $uni-font-size-base;
&.stockout-btn {
margin-right: 0.15rem;
background-color: $primary-color;
color: #fff;
&::after{
border-width: 0;
}
}
&.remark {
margin-right: 0.15rem;
min-width: 1.2rem;
}
}
}
}
}
.remark-wrap {
width: 6rem;
background-color: #fff;
border-radius: 0.04rem;
box-shadow: 0 0.01rem 0.12rem 0 rgba(0, 0, 0, 0.1);
.header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 0.15rem;
height: 0.45rem;
line-height: 0.45rem;
border-bottom: 0.01rem solid #e8eaec;
.iconfont {
font-size: $uni-font-size-lg;
}
}
.body {
padding: 0.15rem 0.15rem 0.1rem;
textarea {
border: 0.01rem solid #e6e6e6;
width: 100%;
padding: 0.1rem;
box-sizing: border-box;
font-size: 0.14rem;
}
.placeholder-class {
font-size: 0.14rem;
}
}
.footer {
height: 0.5rem;
padding-bottom: 0.05rem;
display: flex;
align-items: center;
justify-content: center;
button.default {
width: 95%;
}
}
}

View File

@@ -0,0 +1,356 @@
.goodslist {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
.goodslist-box {
width: 100%;
height: 100%;
background: #fff;
display: flex;
.goodslist-left {
width: 5rem;
height: 100%;
border-right: 0.01rem solid #e6e6e6;
box-sizing: border-box;
overflow: hidden;
position: relative;
.notYet {
color: #e6e6e6;
font-size: 0.4rem;
padding-top: 3rem;
text-align: center;
}
.goods-title {
text-align: center;
line-height: 0.6rem;
font-size: 0.18rem;
font-weight: 500;
height: 0.6rem;
border-bottom: 0.01rem solid #e6e6e6;
box-sizing: border-box;
position: relative;
.icongengduo1 {
position: absolute;
top: 50%;
right: 0.2rem;
transform: translateY(-50%);
font-size: 0.3rem;
color: $primary-color;
}
}
.goods-search {
width: 100%;
height: 0.6rem;
border-bottom: 0.01rem solid #e6e6e6;
display: flex;
align-items: center;
justify-content: center;
padding: 0 0.2rem;
box-sizing: border-box;
.search {
width: 5.6rem;
height: 0.4rem;
border-radius: 0.04rem;
background: #f5f5f5;
display: flex;
align-items: center;
padding: 0 0.2rem;
box-sizing: border-box;
.iconfont {
font-size: 0.16rem;
color: #909399;
margin-right: 0.11rem;
}
input {
width: 80%;
height: 60%;
border: none;
font-size: 0.14rem;
}
}
}
.goods-list-scroll {
width: 100%;
height: calc(100% - 2.08rem);
.itemhover {
background: var(--primary-color-light-9);
}
.item {
padding: 0.2rem;
.title {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 0.2rem;
view {
font-size: 0.16rem;
}
view:nth-child(2) {
color: $primary-color;
}
}
}
}
.add-wastage {
padding: 0.24rem 0.2rem;
button{
width: 100%;
line-height: 0.4rem;
height: 0.4rem;
}
}
}
.goodslist-right {
flex: 1;
width: 0;
height: 100%;
box-sizing: border-box;
position: relative;
padding-bottom: 0.88rem;
overflow: hidden;
.goods-title {
text-align: center;
line-height: 0.6rem;
font-size: 0.18rem;
font-weight: 500;
height: 0.6rem;
border-bottom: 0.01rem solid #e6e6e6;
box-sizing: border-box;
position: relative;
}
.cart-empty {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 2.1rem;
}
.order-information {
width: 100%;
height: calc(100% - 0.6rem);
padding: 0.2rem;
box-sizing: border-box;
overflow-y: auto;
// position: relative;
.order-status {
font-size: 0.24rem;
font-weight: bold;
margin-bottom: 0.24rem;
}
.order-types {
width: 100%;
min-height: 1rem;
padding: 0.2rem 0.3rem;
display: flex;
flex-direction: column;
justify-content: space-between;
margin-bottom: 0.2rem;
box-sizing: border-box;
.type {
padding-left: 0.1rem;
view {
font-size: 0.14rem;
.look {
color: $primary-color;
margin-left: 0.24rem;
}
}
view:nth-child(1) {
width: 0.9rem;
text-align: right;
margin-right: 0.1rem;
}
.message{
max-width: 10.7rem;
overflow: hidden;
-o-text-overflow: ellipsis;
text-overflow: ellipsis;
white-space: nowrap;
}
}
.type1 {
display: flex;
align-items: center;
height: 0.34rem;
}
}
.goods-info {
min-height: 2.7rem;
background: #ffffff;
padding: 0.2rem 0;
box-sizing: border-box;
.title {
font-size: 0.18rem;
font-weight: 550;
margin-bottom: 0.2rem;
}
.table {
width: 100%;
box-sizing: border-box;
margin-bottom: 0.2rem;
.table-all {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 0.38rem;
box-sizing: border-box;
.table-td {
font-size: 0.14rem;
text-align: left;
display: flex;
align-items: center;
justify-content: center;
image {
margin-right: 0.1rem;
}
}
.table-goods-name {
image {
width: 0.6rem;
height: 0.6rem;
margin-right: 0.1rem;
flex-shrink: 0;
}
}
}
.table-th {
height: 0.56rem;
background: #f7f8fa;
}
.table-tr {
height: 0.7rem;
border-bottom: 0.01rem solid #e6e6e6;
.table-td {
image {
width: 0.5rem;
height: 0.5rem;
}
.content-text {
width: 80%;
height: 0.4rem;
text-overflow: -o-ellipsis-lastline;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
line-clamp: 2;
-webkit-box-orient: vertical;
}
}
}
}
}
}
.total-money-num {
display: flex;
flex-direction: column;
.box {
justify-content: flex-end;
padding: 0.1rem 0 0 0;
color: #333;
}
.money {
text-align: right;
width: 1.2rem;
color: #333;
font-size: 0.14rem;
}
.total {
border-top: 0.01rem solid #e6e6e6;
margin-top: 0.1rem;
.money {
color: #fe2278;
font-size: 0.18rem;
}
}
}
}
}
}
.other-info {
display: flex;
justify-content: space-between;
align-items: center;
}
.total-money-num {
.member-info {
display: flex;
align-items: center;
float: left;
-ms-flex-negative: 0;
-webkit-flex-shrink: 0;
flex-shrink: 0;
}
.box {
display: flex;
align-items: center;
float: right;
view {
font-size: 0.14rem;
}
view:nth-child(1) {
// transform: translateY(-.01rem);
}
view:nth-child(2) {
color: #fe2278;
font-size: 0.18rem;
}
}
}
.total-money-num:after {
overflow: hidden;
content: '';
height: 0;
display: block;
clear: both;
}
/deep/ .uni-scroll-view::-webkit-scrollbar {
width: 0.05rem;
height: 0.3rem;
}
/deep/ .uni-scroll-view::-webkit-scrollbar-thumb {
border-radius: 0.1rem;
box-shadow: inset 0 0 0.05rem rgba(0, 0, 0, 0.2);
background: rgba(193, 193, 193, 1);
}
.order-information::-webkit-scrollbar {
width: 0.05rem;
height: 0.3rem;
}
.order-information::-webkit-scrollbar-thumb {
border-radius: 0.1rem;
box-shadow: inset 0 0 0.05rem rgba(0, 0, 0, 0.2);
background: rgba(193, 193, 193, 1);
}
.action-box {
width: 100%;
position: absolute;
bottom: 0;
right: 0;
background: #ffffff;
padding: 0.24rem 0.2rem;
box-sizing: border-box;
button {
min-width: 0.9rem;
height: 0.4rem;
font-size: 0.18rem;
text-align: center;
line-height: 0.4rem;
float: right;
margin-left: 0.1rem;
}
}

View File

@@ -0,0 +1,294 @@
import {
getAllotNo,
getAllocateDetailInEdit,
getSkuListForStock,
getStoreLists,
editAllocate,
addAllocate
} from '@/api/stock.js';
export default {
data() {
return {
params: {
search_text: '', //产品名称
temp_store_id: ''
},
goodsList: [],
goodsIdArr: [],
goodsShow: false,
totalData: {
kindsNum: 0,
price: 0
},
isSubmit: false,
remark: '',
// 筛选面板的时间
type: 'in',
storeName: '出库门店',
screen: {
store_id: "",
remark: '',
allot_id: "",
allot_no: "",
storeList: [],
startDate: '1998-01-30 00:00:00',
birthday: '',
allocateTypeList: [{
label: '调拨入库',
value: 'in'
},
{
label: '调拨出库',
value: 'out'
}
]
},
dialogVisible: false, //弹框
inputIndex: -1
};
},
onLoad(option) {
this.screen.allot_id = option.allot_id || '';
if (this.screen.allot_id) {
this.getEditData();
} else {
this.getDocumentNo()
}
},
onShow() {
this.screen.birthday = this.$util.timeFormat(Date.parse(new Date()) / 1000);
this.getStoreLists()
},
watch: {
goodsIdArr(data) {
this.calcTotalData();
},
},
methods: {
getDocumentNo() {//获取单据号
getAllotNo().then(res => {
if (res.code >= 0) {
this.screen.allot_no = res.data
} else {
this.$util.showToast({
title: res.message
});
}
});
},
getEditData() {
// 编辑时获取详情
getAllocateDetailInEdit(this.screen.allot_id).then(res => {
if (res.code >= 0 && res.data) {
this.info = res.data;
//当前门店id===入库id则是商品入库门店选择回填为output_store_id出库门店id否则为商品出库门店选择回填为input_store_id入库门店id
this.type = this.globalStoreInfo.store_id == this.info.input_store_id ? 'in' : 'out'
this.screen.store_id = this.type == 'in' ? this.info.output_store_id : this.info.input_store_id
this.screen.allot_no = this.info.allot_no
this.screen.birthday = this.$util.timeFormat(this.info.allot_time)
this.remark = JSON.parse(JSON.stringify(this.info.remark))
this.screen.remark = this.info.remark
for (let sku_id in this.info.goods_list) {
this.info.goods_list[sku_id].title = this.info.goods_list[sku_id].sku_name
this.goodsIdArr.push(parseInt(sku_id));
this.goodsList.push(this.info.goods_list[sku_id]);
}
}
});
},
selectAllocateType(id) {
this.type = id == -1 ? '' : this.screen.allocateTypeList[id].value;
this.storeName = id == -1 || id == 0 ? '出库门店' : '入库门店';
this.params.temp_store_id = this.type == 'in' ? this.screen.store_id : '' //当是入库的时候,需要查出库门店的商品
this.goodsIdArr = []
this.goodsList = []
},
selectStore(id) {
this.screen.store_id = id == -1 ? '' : this.screen.storeList[id].value;
if (this.type == 'in') {
this.goodsIdArr = []
this.goodsList = []
}
},
changeTime(data) {
this.screen.birthday = data;
},
getGoodsData({detail}, index) { //input回车处理
this.inputIndex = index
var data = {
search: detail ? detail.value : '',
}
if (this.type == 'in') data.temp_store_id = this.screen.store_id;
if (detail && detail.value) {
getSkuListForStock(data).then(res => {
if (res.code >= 0 && res.data.length == 1) {
this.selectGoods(res.data)
} else if (res.code >= 0) {
this.params.search_text = detail ? detail.value : ''
this.dialogVisible = true
} else {
this.$util.showToast({
title: res.message
});
}
});
} else {
this.params.search_text = detail ? detail.value : ''
this.dialogVisible = true
}
},
selectGoods(data) { //选择数据
data.forEach((el, index) => {
el.goods_num = 1;
el.goods_price = 0;
el.title = el.sku_name + ''
//点击或回车行为选择商品后当为第一行并且展示列表不存在选择的商品push到展示列表或者不为第一行并且展示列表中不存在时选择的商品除第一条全部push到展示列表
if (!this.goodsIdArr.includes(el.sku_id)) {
console.log(111);
this.goodsIdArr.push(el.sku_id);
this.goodsList.push(el);
} else {//只要展示列表存在直接累加
var elIndex = this.goodsIdArr.indexOf(el.sku_id)
if(this.params.search_text){
this.goodsList[elIndex].goods_num = parseFloat(this.goodsList[elIndex].goods_num) + 1
}
}
})
this.goodsShow = false;
this.params.search_text = '';
this.$forceUpdate();
},
delGoods(id) {//删除已选择的商品
this.goodsList.splice(this.goodsIdArr.indexOf(id), 1);
this.goodsIdArr.splice(this.goodsIdArr.indexOf(id), 1);
},
getStoreLists() {
this.screen.storeList = [];
getStoreLists().then(res => {
if (res.code >= 0) {
let data = res.data;
for (let i = 0; i < data.length; i++) {
if (this.globalStoreId != data[i]['store_id']) {
this.screen.storeList.push({
'label': data[i]['store_name'],
'value': data[i]['store_id'].toString()
});
}
}
if (this.screen.storeList.length > 0) {
this.screen.store_id = this.screen.storeList[0].value;
this.params.temp_store_id = this.screen.store_id
}
}
});
},
stockOutFn() {
if (!this.screen.allot_no) {
this.$util.showToast({
title: "请输入调拨单号"
});
return false;
}
if (!this.type) {
this.$util.showToast({
title: "请选择调拨方式"
});
return false;
}
if (!this.screen.store_id) {
this.$util.showToast({
title: "请选择出库门店"
});
return false;
}
if (!this.screen.birthday) {
this.$util.showToast({
title: "请选择调拨时间"
});
return false;
}
if (!this.goodsIdArr.length) {
this.$util.showToast({
title: "请选择调拨数据"
});
return false;
}
// 检测库存是否填写,且提取数据
let isStock = false;
let saveData = [];
try {
this.goodsList.forEach((item, index) => {
if (this.goodsIdArr.includes(item.sku_id)) {
if (!parseFloat(item.goods_num || 0)) {
isStock = true;
let toast = "请输入" + item.sku_name + "的调拨数量";
this.$util.showToast({
title: toast
});
throw new Error('end');
}
var obj = {};
obj.goods_num = item.goods_num;
obj.goods_price = item.cost_price;
obj.goods_sku_id = item.sku_id;
saveData.push(obj);
}
})
} catch (e) {
if (e.message != "end") throw e;
}
if (isStock) return false;
if (this.isSubmit) return false;
this.isSubmit = true;
let save = this.screen.allot_id ? editAllocate : addAllocate
save({
allot_type: this.type,
allot_id: this.screen.allot_id,
temp_store_id: this.screen.store_id,
allot_time: this.screen.birthday,
remark: this.screen.remark,
allot_no: this.screen.allot_no,
goods_sku_list: JSON.stringify(saveData)
}).then(res => {
this.isSubmit = false;
this.$util.showToast({
title: res.message
});
if (res.code >= 0) {
setTimeout(() => {
this.backFn();
}, 500);
this.resetFn();
}
});
},
backFn() {
this.$util.redirectTo('/pages/stock/allocate');
},
calcTotalData() {//计算商品种类、金额
this.totalData.kindsNum = 0;
this.totalData.price = 0;
this.goodsList.forEach((item, index) => {
if (this.goodsIdArr.includes(item.sku_id)) {
this.totalData.price += parseFloat(item.cost_price || 0) * parseFloat(item.goods_num || 1);
}
})
this.totalData.kindsNum = this.goodsIdArr.length;
},
resetFn() {
this.goodsIdArr = [];
this.goodsShow = false;
this.totalData.kindsNum = 0;
this.totalData.price = 0;
},
remarkConfirm() {
this.screen.remark = JSON.parse(JSON.stringify(this.remark))
this.$refs.remarkPopup.close()
}
}
};

View File

@@ -0,0 +1,235 @@
import {
getInventoryNo,
getInventoryDetailInEdit,
getSkuListForStock,
editInventory,
addInventory
} from '@/api/stock.js';
export default {
data() {
return {
params: {
search_text: '', //产品名称
},
goodsList: [],
goodsIdArr: [],
goodsShow: false,
totalData: {
kindsNum: 0,
upNum: 0,
downNum: 0,
sameNum: 0
},
screen: {
inventory_id: '',
inventory_no: "",
remark: "",
stock_json: "",
time: ""
},
remark: '',
isSubmit: false,
inputIndex: -1,
dialogVisible: false,
info: null
};
},
onLoad(option) {
this.screen.inventory_id = option.inventory_id || '';
this.screen.time = this.$util.timeFormat(Date.parse(new Date()) / 1000);
if (this.screen.inventory_id) {
this.getEditData();
} else {
this.getDocumentNo()
}
},
watch: {
goodsIdArr(data) {
this.calcTotalData();
},
},
methods: {
getDocumentNo() {//获取单据号
getInventoryNo().then(res => {
if (res.code >= 0) {
this.screen.inventory_no = res.data
} else {
this.$util.showToast({
title: res.message
});
}
});
},
getEditData() {
getInventoryDetailInEdit(this.screen.inventory_id).then(res => {
if (res.code >= 0 && res.data) {
this.info = res.data;
this.screen.inventory_no = this.info.inventory_no
this.screen.time = this.$util.timeFormat(this.info.action_time)
this.remark = JSON.parse(JSON.stringify(this.info.remark))
for (let sku_id in this.info.goods_list) {
this.info.goods_list[sku_id].title = this.info.goods_list[sku_id].sku_name
this.goodsIdArr.push(parseInt(sku_id));
this.goodsList.push(this.info.goods_list[sku_id]);
}
}
});
},
getGoodsData({
detail
}, index) { //input回车处理
this.inputIndex = index
if (detail && detail.value) {
getSkuListForStock({
search: detail ? detail.value : ''
}).then(res => {
if (res.code >= 0 && res.data.length == 1) {
this.selectGoods(res.data)
} else if (res.code >= 0) {
this.params.search_text = detail ? detail.value : ''
this.dialogVisible = true
} else {
this.$util.showToast({
title: res.message
});
}
});
} else {
this.params.search_text = detail ? detail.value : ''
this.dialogVisible = true
}
},
selectGoods(data) { //选择数据
data.forEach((el, index) => {
el.goods_num = 1;
el.goods_price = 0;
el.title = el.sku_name + ''
//点击或回车行为选择商品后当为第一行并且展示列表不存在选择的商品push到展示列表或者不为第一行并且展示列表中不存在时选择的商品除第一条全部push到展示列表
if (!this.goodsIdArr.includes(el.sku_id)) {
console.log(111);
this.goodsIdArr.push(el.sku_id);
this.goodsList.push(el);
} else {//只要展示列表存在直接累加
var elIndex = this.goodsIdArr.indexOf(el.sku_id)
if(this.params.search_text){
this.goodsList[elIndex].goods_num = parseFloat(this.goodsList[elIndex].goods_num) + 1
}
}
})
this.goodsShow = false;
this.params.search_text = '';
this.$forceUpdate();
},
delGoods(id) {
this.goodsList.splice(this.goodsIdArr.indexOf(id), 1);
this.goodsIdArr.splice(this.goodsIdArr.indexOf(id), 1);
},
stockOutFn() {
if (!this.screen.inventory_no) {
this.$util.showToast({
title: "请输入盘点单号"
});
return false;
}
if (!this.screen.time) {
this.$util.showToast({
title: "请选择盘点时间"
});
return false;
}
if (!this.goodsIdArr.length) {
this.$util.showToast({
title: "请选择盘点数据"
});
return false;
}
if (this.globalStoreInfo.stock_config && this.globalStoreInfo.stock_config.is_audit == 1) {
this.$refs.tipsPop.open();
} else {
this.save();
}
},
save() {
// 检测库存是否填写,且提取数据
let isStock = false;
let saveData = [];
try {
this.goodsList.forEach((item, index) => {
if (this.goodsIdArr.includes(item.sku_id)) {
if (!parseFloat(item.goods_num || 0)) {
isStock = true;
let toast = "请输入" + item.sku_name + "的盘点数量";
this.$util.showToast({
title: toast
});
throw new Error('end');
}
var obj = {};
obj.goods_num = item.goods_num;
obj.goods_sku_id = item.sku_id;
saveData.push(obj);
}
})
} catch (e) {
if (e.message != "end") throw e;
}
if (isStock) return false;
if (this.isSubmit) return false;
this.isSubmit = true;
this.screen.stock_json = JSON.stringify(saveData)
let save = this.screen.inventory_id ? editInventory : addInventory
save(this.screen).then(res => {
this.isSubmit = false;
this.$util.showToast({
title: res.message
});
if (res.code >= 0) {
if (this.$refs.tipsPop) this.$refs.tipsPop.close();
setTimeout(() => {
this.backFn();
}, 500);
this.resetFn();
}
});
},
backFn() {
this.$util.redirectTo('/pages/stock/check');
},
calcTotalData() {//计算商品总数、盘盈、盘亏等
this.totalData.kindsNum = 0;
this.totalData.upNum = 0;
this.totalData.downNum = 0;
this.totalData.sameNum = 0;
this.goodsList.forEach((item, index) => {
if (this.goodsIdArr.includes(item.sku_id) && item.goods_num) {
if ((item.goods_num - item.stock) == 0) {
this.totalData.sameNum++;
} else if ((item.goods_num - item.stock) > 0) {
this.totalData.upNum++;
} else if ((item.goods_num - item.stock) < 0) {
this.totalData.downNum++;
}
}
})
this.totalData.kindsNum = this.goodsIdArr.length;
},
resetFn() {
this.goodsIdArr = [];
this.goodsShow = false;
this.totalData.kindsNum = 0;
this.totalData.countNum = 0;
this.totalData.price = 0;
},
changeTime(data) {
this.screen.time = data;
},
remarkConfirm() {
this.screen.remark = JSON.parse(JSON.stringify(this.remark))
this.$refs.remarkPopup.close()
}
}
};

View File

@@ -0,0 +1,224 @@
import {
getStorageDocumentNo,
getStorageDetailInEdit,
getSkuListForStock,
editStorage
} from '@/api/stock.js';
export default {
data() {
return {
params: {
search_text: '', //产品名称
},
goodsList: [], //已选择数据
goodsIdArr: [], //已选择数据id
goodsShow: false,
totalData: {
kindsNum: 0,
price: 0
},
screen: {
document_id: "",
document_no: "",
remark: "",
stock_json: "",
time: ""
},
remark: '',
isSubmit: false, //提交防抖
info: null, //详情原始数据
dialogVisible: false, //弹框
inputIndex: -1
};
},
onLoad(option) {
this.screen.document_id = option.document_id || '';
this.screen.time = this.$util.timeFormat(Date.parse(new Date()) / 1000);
if (this.screen.document_id) {
this.getEditData();
} else {
this.getDocumentNo()
}
},
watch: {
goodsIdArr(data) {
this.calcTotalData();
},
},
methods: {
getDocumentNo() {//获取单据号
getStorageDocumentNo().then(res => {
if (res.code >= 0) {
this.screen.document_no = res.data
} else {
this.$util.showToast({
title: res.message
});
}
});
},
getEditData() { //编辑时获取详情
getStorageDetailInEdit(this.screen.document_id).then(res => {
if (res.code >= 0 && res.data) {
this.info = res.data;
this.screen.document_no = this.info.document_no
this.screen.time = this.$util.timeFormat(this.info.time)
this.remark = JSON.parse(JSON.stringify(this.info.remark))
this.screen.remark = this.info.remark
for (let sku_id in this.info.goods_list) {
this.info.goods_list[sku_id].title = this.info.goods_list[sku_id].sku_name
this.goodsIdArr.push(parseInt(sku_id));
this.goodsList.push(this.info.goods_list[sku_id]);
}
}
});
},
getGoodsData({
detail
}, index) { //input回车处理
this.inputIndex = index
this.params.search_text = detail ? detail.value : ''
if (detail&&detail.value) {
getSkuListForStock({
search: detail ? detail.value : ''
}).then(res => {
if (res.code >= 0 && res.data.length == 1) {
this.selectGoods(res.data)
} else if (res.code >= 0) {
this.dialogVisible = true
} else {
this.$util.showToast({
title: res.message
});
}
});
} else {
this.dialogVisible = true
}
},
selectGoods(data) { //选择数据
data.forEach((el, index) => {
el.goods_num = 1;
el.goods_price = 0;
el.title = el.sku_name + ''
//点击或回车行为选择商品后当为第一行并且展示列表不存在选择的商品push到展示列表或者不为第一行并且展示列表中不存在时选择的商品除第一条全部push到展示列表
if (!this.goodsIdArr.includes(el.sku_id)) {
console.log(111);
this.goodsIdArr.push(el.sku_id);
this.goodsList.push(el);
} else {//只要展示列表存在直接累加
var elIndex = this.goodsIdArr.indexOf(el.sku_id)
if(this.params.search_text){
this.goodsList[elIndex].goods_num = parseFloat(this.goodsList[elIndex].goods_num) + 1
}
}
})
this.goodsShow = false;
this.params.search_text = '';
this.$forceUpdate();
},
delGoods(id) {//删除已选择的商品
this.goodsList.splice(this.goodsIdArr.indexOf(id), 1);
this.goodsIdArr.splice(this.goodsIdArr.indexOf(id), 1);
},
stockOutFn() {
if (!this.screen.document_no) {
this.$util.showToast({
title: "请输入入库单号"
});
return false;
}
if (!this.screen.time) {
this.$util.showToast({
title: "请选择入库时间"
});
return false;
}
if (!this.goodsIdArr.length) {
this.$util.showToast({
title: "请选择入库数据"
});
return false;
}
if (this.globalStoreInfo.stock_config && this.globalStoreInfo.stock_config.is_audit == 1) {
this.$refs.tipsPop.open();
} else {
this.save();
}
},
save() {
// 检测库存是否填写,且提取数据
let isStock = false;
let saveData = [];
try {
this.goodsList.forEach((item, index) => {
if (this.goodsIdArr.includes(item.sku_id)) {
if (!parseFloat(item.goods_num || 0)) {
isStock = true;
let toast = "请输入" + item.sku_name + "的入库数量";
this.$util.showToast({
title: toast
});
throw new Error('end');
}
var obj = {};
obj.goods_num = item.goods_num;
obj.goods_price = item.goods_price;
obj.goods_sku_id = item.sku_id;
saveData.push(obj);
}
})
} catch (e) {
if (e.message != "end") throw e;
}
if (isStock) return false;
if (this.isSubmit) return false;
this.isSubmit = true;
this.screen.stock_json = JSON.stringify(saveData)
editStorage(this.screen).then(res => {
this.isSubmit = false;
this.$util.showToast({
title: res.message
});
if (res.code >= 0) {
if (this.$refs.tipsPop) this.$refs.tipsPop.close();
setTimeout(() => {
this.backFn();
}, 500);
this.resetFn();
}
});
},
backFn() {
this.$util.redirectTo('/pages/stock/storage');
},
calcTotalData() {//计算商品种类、金额
this.totalData.price = 0;
this.totalData.kindsNum = 0;
this.goodsList.forEach((item, index) => {
if (this.goodsIdArr.includes(item.sku_id)) {
this.totalData.price += parseFloat(item.goods_price ?? 0) * parseFloat(item.goods_num ||
1);
}
})
this.totalData.kindsNum = this.goodsIdArr.length;
},
resetFn() {
this.goodsIdArr = [];
this.goodsShow = false;
this.totalData.kindsNum = 0;
this.totalData.price = 0;
},
changeTime(data) {//设置时间
this.screen.time = data;
},
remarkConfirm() {//设置备注
this.screen.remark = JSON.parse(JSON.stringify(this.remark))
this.$refs.remarkPopup.close()
}
}
};

View File

@@ -0,0 +1,217 @@
import {
getWastageDocumentNo,
getWastageDetailInEdit,
getSkuListForStock,
editWastage
} from '@/api/stock.js';
export default {
data() {
return {
params: {
search_text: '', //产品名称
},
goodsList: [], //已选择数据
goodsIdArr: [], //已选择数据id
goodsShow: false,
totalData: {
kindsNum: 0,
price: 0
},
screen: {
document_id: "",
document_no: "",
remark: "",
stock_json: "",
time: ""
},
remark: '',
isSubmit: false, //提交防抖
info: null, //详情原始数据
dialogVisible: false, //弹框
inputIndex: -1
};
},
onLoad(option) {
this.screen.document_id = option.document_id || 0;
this.screen.time = this.$util.timeFormat(Date.parse(new Date()) / 1000);
if (this.screen.document_id) {
this.getEditData();
} else {
this.getDocumentNo()
}
},
watch: {
goodsIdArr(data) {
this.calcTotalData();
},
},
methods: {
getDocumentNo() {//获取单据号
getWastageDocumentNo().then(res => {
if (res.code >= 0) {
this.screen.document_no = res.data
} else {
this.$util.showToast({
title: res.message
});
}
});
},
getEditData() {//编辑时获取详情
getWastageDetailInEdit(this.screen.document_id).then(res => {
if (res.code >= 0 && res.data) {
this.info = res.data;
this.screen.document_no = this.info.document_no
this.screen.time = this.$util.timeFormat(this.info.time)
this.remark = JSON.parse(JSON.stringify(this.info.remark))
this.screen.remark = this.info.remark
for (let sku_id in this.info.goods_list) {
this.info.goods_list[sku_id].title = this.info.goods_list[sku_id].sku_name
this.goodsIdArr.push(parseInt(sku_id));
this.goodsList.push(this.info.goods_list[sku_id]);
}
}
});
},
getGoodsData({
detail
}, index) { //input回车处理
this.inputIndex = index
if (detail && detail.value) {
getSkuListForStock({
search: detail ? detail.value : ''
}).then(res => {
if (res.code >= 0 && res.data.length == 1) {
this.selectGoods(res.data)
} else if (res.code >= 0) {
this.params.search_text = detail ? detail.value : ''
this.dialogVisible = true
} else {
this.$util.showToast({
title: res.message
});
}
});
} else {
this.params.search_text = detail ? detail.value : ''
this.dialogVisible = true
}
},
selectGoods(data) { //选择数据
data.forEach((el, index) => {
el.goods_num = 1;
el.goods_price = 0;
el.title = el.sku_name + ''
//点击或回车行为选择商品后当为第一行并且展示列表不存在选择的商品push到展示列表或者不为第一行并且展示列表中不存在时选择的商品除第一条全部push到展示列表
if (!this.goodsIdArr.includes(el.sku_id)) {
console.log(111);
this.goodsIdArr.push(el.sku_id);
this.goodsList.push(el);
} else {//只要展示列表存在直接累加
var elIndex = this.goodsIdArr.indexOf(el.sku_id)
if(this.params.search_text){
this.goodsList[elIndex].goods_num = parseFloat(this.goodsList[elIndex].goods_num) + 1
}
}
})
this.goodsShow = false;
this.params.search_text = '';
this.$forceUpdate();
},
delGoods(id) {//删除已选择的商品
this.goodsList.splice(this.goodsIdArr.indexOf(id), 1);
this.goodsIdArr.splice(this.goodsIdArr.indexOf(id), 1);
},
stockOutFn() {
if (!this.screen.document_no) {
this.$util.showToast({
title: "请输入出库单号"
});
return false;
}
if (!this.goodsIdArr.length) {
this.$util.showToast({
title: "请选择出库数据"
});
return false;
}
if (this.globalStoreInfo.stock_config && this.globalStoreInfo.stock_config.is_audit == 1) {
this.$refs.tipsPop.open();
} else {
this.save();
}
},
save() {
// 检测库存是否填写,且提取数据
let isStock = false;
let saveData = [];
try {
this.goodsList.forEach((item, index) => {
if (this.goodsIdArr.includes(item.sku_id)) {
if (!parseFloat(item.goods_num || 0)) {
isStock = true;
let toast = "请输入" + item.sku_name + "的出库数量";
this.$util.showToast({
title: toast
});
throw new Error('end');
}
var obj = {};
obj.goods_num = item.goods_num;
obj.goods_price = item.cost_price;
obj.goods_sku_id = item.sku_id;
saveData.push(obj);
}
})
} catch (e) {
if (e.message != "end") throw e;
}
if (isStock) return false;
if (this.isSubmit) return false;
this.isSubmit = true;
this.screen.stock_json = JSON.stringify(saveData)
editWastage(this.screen).then(res => {
this.isSubmit = false;
this.$util.showToast({
title: res.message
});
if (res.code >= 0) {
if (this.$refs.tipsPop) this.$refs.tipsPop.close();
setTimeout(() => {
this.backFn();
}, 500);
this.resetFn();
}
});
},
backFn() {
this.$util.redirectTo('/pages/stock/wastage');
},
calcTotalData() {//计算商品种类、金额
this.totalData.price = 0;
this.totalData.kindsNum = 0;
this.goodsList.forEach((item, index) => {
if (this.goodsIdArr.includes(item.sku_id)) {
this.totalData.price += parseFloat(item.cost_price ?? 0) * parseFloat(item.goods_num || 1);
}
})
this.totalData.kindsNum = this.goodsIdArr.length;
},
resetFn() {
this.goodsIdArr = [];
this.goodsShow = false;
this.totalData.kindsNum = 0;
this.totalData.price = 0;
},
changeTime(data) {
this.screen.time = data;
},
remarkConfirm() {
this.screen.remark = JSON.parse(JSON.stringify(this.remark))
this.$refs.remarkPopup.close()
}
}
}