| | |
| | | <PageHeader :title="pageTitle" @back="goBack" /> |
| | | <view class="account-detail"> |
| | | <view class="box"> |
| | | <view v-if="type == 'add'"> |
| | | <view v-if="type == 'add'" style="margin-bottom: 20rpx;"> |
| | | <button class="mini-btn" type="primary" size="mini" style="margin-left: 0;margin-right: 0;" |
| | | @click="addItem">新增</button> |
| | | </view> |
| | | <view v-for="(item, index) in goodsList" class="form-box"> |
| | | <button v-if="type == 'add'" class="mini-btn del-btn" type="warn" size="mini" style="margin-left: 0;margin-right: 0;" |
| | | @click="delItem(index)">删除</button> |
| | | <uni-forms :key="index" label-position="top" label-width="400rpx"> |
| | | <uni-forms-item label="产品图片" required> |
| | | <view class="add-img"> |
| | | <image v-if="item.url" class="img" :src="baseUrl + item.url" mode="aspectFill" /> |
| | | <image v-if="item.url" class="img" :src="baseUrl + item.url" mode="aspectFill" |
| | | @click="addImg(index)" /> |
| | | <uni-icons v-else type="camera-filled" size="56" style="color: #8a8a8a" |
| | | @click="addImg(index)"></uni-icons> |
| | | </view> |
| | |
| | | <uni-forms-item label="每件数量/支" required> |
| | | <uni-number-box v-model="item.boxNum" :min="0"></uni-number-box> |
| | | </uni-forms-item> |
| | | <uni-forms-item label="单价(元)/支" required> |
| | | <uni-forms-item label="单价(元)/件" required> |
| | | <uni-number-box v-model="item.taxInclusiveUnitPrice" :min="0" :step="0.01"></uni-number-box> |
| | | </uni-forms-item> |
| | | <uni-forms-item label="单价(美元)/件" required> |
| | | <uni-number-box v-model="item.dollarPrice" :min="0" :step="0.01"></uni-number-box> |
| | | </uni-forms-item> |
| | | <uni-forms-item label="入库日期" required> |
| | | <uni-datetime-picker type="date" :clear-icon="false" v-model="item.inboundDate" /> |
| | |
| | | import { getToken } from "@/utils/auth"; |
| | | import { addCustom } from '@/api/inventoryManagement/receiptManagement.js' |
| | | import config from '@/config' |
| | | const baseUrl = config.baseUrl |
| | | const baseUrl = config.imgUrl |
| | | const pageTitle = ref('新增自定义入库') |
| | | const goodsList = ref([]) |
| | | const type = ref('add') |
| | |
| | | taxExclusiveTotalPrice: 0, |
| | | taxInclusiveTotalPrice: 0, |
| | | taxInclusiveUnitPrice: 0, |
| | | dollarPrice: 0, |
| | | taxRate: 0, |
| | | unit: "", |
| | | url: "", |
| | |
| | | const goBack = () => { |
| | | uni.navigateBack() |
| | | } |
| | | const showToast = (msg)=>{ |
| | | uni.showToast({ |
| | | title: msg, |
| | | icon: 'none', |
| | | duration: 1500 |
| | | }) |
| | | } |
| | | const submitForm = async() => { |
| | | if (!goodsList.value.length) { |
| | | showToast('请至少添加一条产品数据') |
| | | return |
| | | } |
| | | |
| | | // 验证自定义添加的数据必填字段 |
| | | for (let i = 0; i < goodsList.value.length; i++) { |
| | | const product = goodsList.value[i]; |
| | | if (!product.productCategory || !product.specificationModel || !product.unit) { |
| | | showToast(`第${i + 1}行产品数据未填写完整(产品、产品高度、高度单位为必填)`) |
| | | return |
| | | } |
| | | if (!product.url) { |
| | | showToast(`第${i + 1}行产品未上传产品图片`) |
| | | return |
| | | } |
| | | if (!product.cartonSpecifications) { |
| | | showToast(`第${i + 1}行产品未填写纸箱规格`) |
| | | return |
| | | } |
| | | // if (!product.itemType) { |
| | | // proxy.$modal.msgError(`第${i + 1}行请选择物品类型`) |
| | | // return |
| | | // } |
| | | const stock = Number(product?.inboundNum ?? 0); |
| | | if (!Number.isFinite(stock) || stock <= 0) { |
| | | showToast(`第${i + 1}行本次入库数量需大于0`) |
| | | return |
| | | } |
| | | const boxNum = Number(product?.boxNum ?? 0); |
| | | if (!Number.isFinite(boxNum) || boxNum <= 0) { |
| | | showToast(`第${i + 1}行每件数量/支需大于0`) |
| | | return |
| | | } |
| | | const taxInclusiveUnitPrice = Number(product?.taxInclusiveUnitPrice ?? 0); |
| | | if (!Number.isFinite(taxInclusiveUnitPrice) || taxInclusiveUnitPrice <= 0) { |
| | | showToast(`第${i + 1}行单价(元)需大于0`) |
| | | return |
| | | } |
| | | const dollarPrice = Number(product?.dollarPrice ?? 0); |
| | | if (!Number.isFinite(dollarPrice) || dollarPrice <= 0) { |
| | | showToast(`第${i + 1}行单价(美元)需大于0`) |
| | | return |
| | | } |
| | | if (!product.inboundDate) { |
| | | showToast(`第${i + 1}行请选择入库日期`) |
| | | return |
| | | } |
| | | |
| | | } |
| | | let res = await addCustom(goodsList.value) |
| | | if(res.code !== 200){ |
| | | uni.showToast({ |
| | |
| | | if (e.errMsg == 'chooseMedia:fail cancel') { |
| | | return |
| | | } |
| | | if (e.errMsg == 'user cancel') { |
| | | return |
| | | } |
| | | uni.showToast({ |
| | | title: "上传失败", |
| | | icon: 'none', |
| | |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | const delItem = (index)=>{ |
| | | console.log('xxxx') |
| | | goodsList.value.splice(index,1) |
| | | } |
| | | const UploadImage = (url, index) => { |
| | | uni.uploadFile({ |
| | |
| | | box-sizing: border-box; |
| | | margin-bottom: 20rpx; |
| | | padding: 20rpx; |
| | | background-color: #f5f5f5; |
| | | // background-color: #f5f5f5; |
| | | box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06); |
| | | transition: box-shadow 0.3s ease; |
| | | border-radius: 20rpx; |
| | | position: relative; |
| | | .del-btn{ |
| | | position: absolute; |
| | | right: 20rpx; |
| | | top: 40rpx; |
| | | z-index: 40; |
| | | } |
| | | } |
| | | |
| | | .form-box:hover { |
| | | box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); |
| | | } |
| | | |
| | | .add-img { |