244 lines
5.9 KiB
Vue
244 lines
5.9 KiB
Vue
<template>
|
||
<up-popup :show="popShow" @close="close" @open="open" mode="center" :round="9">
|
||
<view class="u-p-32 box u-font-28">
|
||
<view class="u-flex u-relative u-row-center">
|
||
<view class="u-font-32">修改库存</view>
|
||
<view class="u-absolute close">
|
||
<up-icon @click="close" :size="16" color="#000" name="close-circle-fill"></up-icon>
|
||
</view>
|
||
</view>
|
||
<view class="u-m-t-48">
|
||
<up-form labelPosition="left" :model="data" :rules="rules" ref="refForm" errorType="toast">
|
||
<view>商品名称</view>
|
||
<view class="u-m-t-16" v-if="isSku">{{data.name}}</view>
|
||
<view class="u-m-t-38">
|
||
<template v-if="!isSku">
|
||
<view class="u-m-b-32" >
|
||
<view class="u-flex u-row-between">
|
||
<view class="up-line-1" style="width: 60%;">{{data.name}}</view>
|
||
<view class="u-font-24" style="flex-shrink: 1;">
|
||
<text>变动数量:</text>
|
||
<text class="number">{{data.stockNumber-data._stockNumber}}</text>
|
||
</view>
|
||
</view>
|
||
<view class="u-m-t-16">
|
||
<up-form-item prop="stockNumber">
|
||
<up-input v-model="data.stockNumber" type="number">
|
||
<template #suffix>
|
||
<view>{{data.unitName||''}}</view>
|
||
</template>
|
||
</up-input>
|
||
</up-form-item>
|
||
|
||
</view>
|
||
</view>
|
||
<view class="u-m-b-32">
|
||
<view class="u-flex u-row-between">
|
||
<view>备注</view>
|
||
</view>
|
||
<view class="u-m-t-16">
|
||
<up-textarea :height="42" v-model="form.note" placeholder="请输入备注"></up-textarea>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
<template v-else>
|
||
<scroll-view scroll-y="true" style="max-height: 30vh;">
|
||
<view class="u-m-b-32" v-for="(item,index) in data.skuList" :key="index">
|
||
<view class="u-flex u-row-between">
|
||
<view>{{item.name}}</view>
|
||
<view class="u-font-24">
|
||
<text>变动数量:</text>
|
||
<text class="number">{{(item.stockNumber-item._stockNumber).toFixed(2)}}</text>
|
||
</view>
|
||
</view>
|
||
<view class="u-m-t-16">
|
||
<up-input v-model="item.stockNumber">
|
||
<template #suffix>
|
||
<view>{{data.unitName||''}}</view>
|
||
</template>
|
||
</up-input>
|
||
</view>
|
||
</view>
|
||
<view class="u-m-b-32">
|
||
<view class="u-flex u-row-between">
|
||
<view>备注</view>
|
||
</view>
|
||
<view class="u-m-t-16">
|
||
<up-textarea :height="42" v-model="form.note" placeholder="请输入备注"></up-textarea>
|
||
</view>
|
||
</view>
|
||
</scroll-view>
|
||
</template>
|
||
|
||
<view class="u-m-t-60">
|
||
<my-button type="primary" shape="circle" @tap="save">
|
||
<view class="u-font-32">
|
||
保存
|
||
</view>
|
||
</my-button>
|
||
<view class="u-m-t-30">
|
||
<template v-if="!recoders.show">
|
||
<view class="color-999 u-font-24 u-flex u-row-center u-col-center">
|
||
<view class="u-flex" @click="changeShowRecoders(true)">
|
||
<view class="u-m-r-6">查看记录</view>
|
||
<up-icon name="arrow-down" :size="12"></up-icon>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<template v-else>
|
||
<scroll-view scroll-y="true" style="max-height: 30vh;">
|
||
<my-step :list="recoders.list"></my-step>
|
||
</scroll-view>
|
||
<view class="color-999 u-font-24 u-flex u-row-center u-col-center">
|
||
<!-- <view class="u-flex" @click="changeShowRecoders(false)"> -->
|
||
<view class="u-flex" @click="toRecodes">
|
||
<view class="u-m-r-6">全部记录</view>
|
||
<up-icon name="arrow-right" :size="12"></up-icon>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
</view>
|
||
|
||
</view>
|
||
</view>
|
||
</up-form>
|
||
</view>
|
||
</view>
|
||
</up-popup>
|
||
</template>
|
||
|
||
<script setup>
|
||
import { reactive, ref, watch, onMounted, computed } from 'vue';
|
||
|
||
import { productStockFlow } from '@/http/api/product.js'
|
||
import go from '@/commons/utils/go.js'
|
||
const refForm = ref(null)
|
||
const props = defineProps({
|
||
show: {
|
||
type: Boolean,
|
||
default: false
|
||
},
|
||
category: {
|
||
type: Array,
|
||
default: () => []
|
||
},
|
||
goods: {
|
||
type: Object,
|
||
default: () => {
|
||
return{
|
||
id:'',
|
||
skuList: []
|
||
}
|
||
}
|
||
}
|
||
})
|
||
const rules =reactive({
|
||
'stockNumber': [{
|
||
type: 'number',
|
||
required: true,
|
||
message: '请填写库存',
|
||
trigger: ['blur', 'change']
|
||
}
|
||
]
|
||
})
|
||
function toRecodes(){
|
||
go.to('PAGES_PRODUCT_INVOICING_LIST',{
|
||
productId:props.goods.id
|
||
})
|
||
}
|
||
function changeShowRecoders(show) {
|
||
recoders.show = show
|
||
}
|
||
const recoders = reactive({
|
||
list: [],
|
||
show: true,
|
||
active: 0
|
||
})
|
||
|
||
const data = ref({
|
||
name:''
|
||
})
|
||
const emits = defineEmits(['update:show', 'save'])
|
||
const form = reactive({
|
||
note: ''
|
||
})
|
||
let popShow = ref(props.show)
|
||
watch(() => props.show, (newval) => {
|
||
popShow.value = newval
|
||
if (newval) {
|
||
data.value = props.goods
|
||
getProductStockDetail()
|
||
}
|
||
})
|
||
|
||
async function getProductStockDetail(){
|
||
const { records }=await productStockFlow({
|
||
page: 1,
|
||
size: 2,
|
||
productId: props.goods.id,
|
||
})
|
||
recoders.list = records.map(v=>{
|
||
return {
|
||
...v,
|
||
title: v.createTime,
|
||
content: uni.$dict.getDiceName(v.inOutItem,'invoicingType')+':'+Math.abs(v.inOutNumber)
|
||
}
|
||
})
|
||
}
|
||
const isSku = computed(() => {
|
||
// return data.value.type == 'sku'
|
||
return false
|
||
})
|
||
watch(() => popShow.value, (newval) => {
|
||
emits('update:show', newval)
|
||
})
|
||
|
||
function close() {
|
||
popShow.value = false
|
||
form.note=''
|
||
}
|
||
|
||
function open() {
|
||
|
||
}
|
||
function save() {
|
||
refForm.value.validate().then(valid => {
|
||
if (valid) {
|
||
emits('save', {
|
||
remark: form.note,
|
||
...data.value,
|
||
})
|
||
} else {
|
||
console.log(err);
|
||
}
|
||
}).catch(() => {
|
||
// 处理验证错误
|
||
});
|
||
}
|
||
|
||
|
||
onMounted(()=>{
|
||
// #ifndef H5
|
||
refForm.value.setRules(rules)
|
||
// #endif
|
||
})
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.box {
|
||
width: 556rpx;
|
||
border-radius: 18rpx 18rpx 18rpx 18rpx;
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
.close {
|
||
position: absolute;
|
||
right: 0;
|
||
}
|
||
|
||
.number {
|
||
color: #F0465B;
|
||
}
|
||
</style> |