cashier_app/pageConsumables/inventoryCheck.vue

212 lines
3.9 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="warehouseEntry">
<view>
<view>
<view>
账存数量
</view>
<view>
{{datas.item.balance}}
</view>
</view>
<view>
<view>
实际数量
</view>
<view>
<input type="number" v-model="datas.form.balance" placeholder="输入数量" name="" id="">
</view>
</view>
<view>
<view>
单价
</view>
<view>
{{datas.item.price}}
</view>
</view>
<view>
<view>
盈亏数量
</view>
<view>
{{profitNumber}}
</view>
</view>
<view>
<view>
总盈亏
</view>
<view>
{{profitPrice}}
</view>
</view>
</view>
</view>
<view class="bottombutton">
<up-button type="primary" style="background-color: #318AFE;color: #fff;" @tap="toggle" :plain="true"
text="保存"></up-button>
<!-- <up-button type="text" style="background-color: #f9f9f9;color: #999;" @tap="toggle" :plain="true"
text="取消"></up-button> -->
</view>
</template>
<script setup>
import {
ref,
computed,
onMounted,
reactive
} from 'vue';
import go from '@/commons/utils/go.js';
import color from '@/commons/color.js';
import {
tbConsInfotbConCheck
} from '@/http/yskApi/requestAll.js';
let showStatus = ref(false)
const props = defineProps({
item: {
type: ''
}
})
let datas = reactive({
item: "",
form: {}
})
onMounted(() => {
datas.item = JSON.parse(props.item)
datas.form = {
...datas.item
}
})
let profitPrice = computed(() => {
// 如果剩余数量为负数
if (datas.form.balance == '-') {
return (0 - datas.item.balance) * datas.item.price
} else {
return ((datas.form.balance - datas.item.balance) * datas.item.price).toFixed(2);
}
})
let profitNumber = computed(() => {
// 盈亏数量
if (datas.form.balance == '-') {
return 0 - datas.item.balance
} else {
return datas.form.balance - datas.item.balance
}
})
function toggle() {
if(!datas.form.balance){
return
}
tbConsInfotbConCheck({
stockNumber: datas.form.balance,
conInfoId: datas.form.id,
lpNum: profitNumber._value
}).then(res => {
// go.to('PAGES_SALES_CONSUMABLES')
go.back()
})
}
/**
* 保留小数n位不进行四舍五入
* num你传递过来的数字,
* decimal你保留的几位,默认保留小数后两位
* isInt 是否保留0
*/
function formatDecimal(num = 0, decimal = 2, isInt = false) {
num = num.toFixed(3).toString();
const index = num.indexOf(".");
if (index !== -1) {
num = num.substring(0, decimal + index + 1);
} else {
num = num.substring(0);
}
//截取后保留两位小数
if (isInt) {
return parseFloat(num);
} else {
return parseFloat(num).toFixed(decimal);
}
}
function showStatusToggle() {
showStatus.value = !showStatus.value
}
</script>
<style>
page {
background-color: #f9f9f9;
}
</style>
<style scoped lang="less">
.df() {
display: flex;
align-items: center;
}
ul,
li {
list-style: none;
padding: 0;
}
.status {
margin: 0 32rpx;
position: absolute;
left: 0;
right: 0;
z-index: 10;
background-color: #fff;
}
.warehouseEntry {
width: 694rpx;
height: 650rpx;
background: #FFFFFF;
border-radius: 18rpx 18rpx 18rpx 18rpx;
margin: 32rpx;
padding: 1rpx 24rpx;
box-sizing: border-box;
>view {
>view {
width: 646rpx;
height: 84rpx;
background: #fcfcfc;
border: 2rpx solid #F9F9F9;
margin-top: 32rpx;
.df;
>view:first-child {
width: 190rpx;
height: 84rpx;
line-height: 84rpx;
// text-align: left;
padding-left: 24rpx;
background: #F9F9F9;
border-radius: 8rpx 0rpx 0rpx 8rpx;
border: 2rpx solid #F9F9F9;
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 400;
font-size: 32rpx;
color: #333333;
}
}
}
}
.bottombutton {
margin-top: 84rpx;
padding: 0 24rpx;
>button {
width: 530rpx;
height: 80rpx;
border-radius: 56rpx 56rpx 56rpx 56rpx;
}
}
</style>