周宾
22 小时以前 b54a94b098a5a0a3375bab0d6493bacf45dd0a58
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<template>
    <PageHeader :title="pageTitle" @back="goBack" />
    <view class="account-detail">
        <view class="box">
            <view class="form-box">
                <uni-forms :key="index" label-position="top" label-width="400rpx">
 
                    <uni-forms-item label="名称" required>
                        <uni-easyinput v-model="productCategory" placeholder="" disabled />
                    </uni-forms-item>
                    <uni-forms-item label="出库数量/件" required>
                        <uni-number-box v-model="goods.quantity" :min="0" :max="inboundNum0"></uni-number-box>
                    </uni-forms-item>
                    <uni-forms-item label="出库日期" required>
                        <uni-datetime-picker type="date" :clear-icon="false" v-model="goods.time" />
                    </uni-forms-item>
                    <uni-forms-item label="出库人" required>
                        <picker :range="userList" @change="swichUser" range-key="nickName">
                            <view  style="border: 1px solid #f5f5f5;border-radius: 4rpx;padding: 20rpx;">
                                <text>{{ userName||'请选择' }}</text>
                            </view>
                        </picker>
                    </uni-forms-item>
                </uni-forms>
            </view>
            <view style="display: flex;justify-content: flex-end;">
                <button class="mini-btn" type="primary" size="mini"
                    style="margin-left: 0;margin-right: 0;margin-right: 20rpx;" @click="submitForm">确定</button>
                <button class="mini-btn" size="mini" style="margin-left: 0;margin-right: 0;" @click="goBack">取消</button>
            </view>
        </view>
    </view>
</template>
 
<script setup>
import { onMounted, ref } from 'vue'
import { stockout } from '@/api/inventoryManagement/issueManagement.js'
const productCategory = ref('')
import { userListNoPageByTenantId } from "@/api/system/user"
const pageTitle = ref('领用产品')
const userList = ref([])
const userName = ref('')
const inboundNum0 = ref(0)
const goods = ref({
    id: 0,
    quantity: 0,
    salesLedgerProductId: 0,
    time: "",
    type: 3,
    userId: undefined
})
const props = defineProps(['goods'])
 
const goBack = () => {
    uni.navigateBack()
}
const submitForm = async () => {
    if(!goods.value.quantity){
        uni.showToast({
            title:'请添加出库数量',
            icon: 'none',
            duration: 1500
        })
        return
    }
    if(!goods.value.time){
        uni.showToast({
            title:'请选择出库日期',
            icon: 'none',
            duration: 1500
        })
        return
    }
    if(!goods.value.userId){
        uni.showToast({
            title:'请选择出库人',
            icon: 'none',
            duration: 1500
        })
        return
    }
    let res = await stockout(goods.value)
    if (res.code !== 200) {
        uni.showToast({
            title: res.msg,
            icon: 'none'
        })
        return
    }
    uni.showToast({
        title: '成功领用',
        icon: 'none'
    })
    goBack()
}
const initContacts = () => {
  userListNoPageByTenantId().then((res) => {
    console.log('userListNoPageByTenantId',res.data)
    userList.value = res.data
  })
}
 
const swichUser = (e) => {
    goods.value.userId = userList.value[e.detail.value].userId
    userName.value = userList.value[e.detail.value].nickName
}
 
 
onMounted(() => {
    let _goods = JSON.parse(props.goods)
    goods.value.id = _goods.id
    productCategory.value = _goods.productCategory
    inboundNum0.value = _goods.inboundNum0
    goods.value.type = _goods.purchaseContractNumber?1:3
    initContacts()
})
</script>
<style lang="scss" scoped>
.box {
    background-color: #fff;
    box-sizing: border-box;
    padding: 20rpx;
    min-height: 80rpx;
    padding-bottom: calc(30rpx + env(safe-area-inset-bottom));
}
 
.form-box {
    box-sizing: border-box;
    margin-bottom: 20rpx;
    padding: 20rpx;
    
    border-radius: 20rpx;
}
 
.add-img {
    .img {
        background-color: #efefef;
        border-radius: 10rpx;
        width: 200rpx;
        height: 200rpx;
    }
}
</style>