Files

219 lines
5.8 KiB
Vue
Raw Permalink Normal View History

<!-- 唯一码发放页面 - 唯一码发放唯一码编辑入库单快速生成唯一码 -->
2026-04-03 08:38:34 +08:00
<template>
2026-04-14 08:46:29 +08:00
<navigation :title="title" :back-url="backUrl"></navigation>
<view class="contentBox">
2026-04-03 08:38:34 +08:00
<view class="remarkLine">
2026-04-23 14:35:54 +08:00
<text>备注</text>
2026-04-03 08:38:34 +08:00
<uni-easyinput type="text" v-model="formData.remark" :inputBorder="false" placeholder="请输入备注" />
</view>
<!-- 物料列表 - 添加物料 -->
2026-04-14 08:46:29 +08:00
<material-list ref="materialRef" :formData="formData" :remark="formData.remark" isEdit="1"
2026-04-03 08:38:34 +08:00
:pathParams="pathParams" />
2026-04-23 14:35:54 +08:00
<button class="bottom-btn" type="primary" @tap="handleSubmit">提交</button>
2026-04-03 08:38:34 +08:00
</view>
</template>
<script setup>
import { ref, onMounted } from 'vue';
2026-04-14 08:46:29 +08:00
import { onLoad } from '@dcloudio/uni-app';
2026-04-03 08:38:34 +08:00
import { addUniqueCode, editUniqueCode } from '@/api/uniqueCode';
import MaterialList from '../../../components/MaterialList.vue';
import Navigation from '../../../components/Navigation.vue';
import { objectToQuery } from '../../../until';
2026-04-03 08:38:34 +08:00
import _ from 'lodash';
2026-04-14 08:46:29 +08:00
const OPERATE_CONFIG = {
// 唯一码创建
issueUniqueCode: {
title: '唯一码发放',
back: 'pages/warehousing/index'
},
//唯一码编辑
issueUniqueCode_edit: {
title: '',
back: '/pages/warehousing/uniqueCode/myUniqueCode'
},
//入库单入库
stockIn_inbound: {
title: '快速生成唯一码',
back: '/pages/warehousing/stockIn/components/inbound'
},
}
// ref标题
2026-04-14 08:46:29 +08:00
const title = ref('')
const backUrl = ref('')
2026-04-03 08:38:34 +08:00
// 数据:路径参数
const pathParams = ref('')
// 数据:物料、备注
const formData = ref({ remark: '', material: [] })
// ref:绑定物料列表
const materialRef = ref([])
// 接收路径参数 - 修改标题- 携带code、id、materialId
onLoad((options) => {
2026-04-14 08:46:29 +08:00
const query = objectToQuery(options)
2026-04-03 08:38:34 +08:00
pathParams.value = options
2026-04-14 08:46:29 +08:00
const config = options.type ? OPERATE_CONFIG[options.type] : OPERATE_CONFIG.issueUniqueCode
title.value = config.title ? config.title : options.title
backUrl.value = config.back + query
2026-04-03 08:38:34 +08:00
})
onMounted(() => {
// 快速生成唯一码时 已选择的物料列表初始为空 点击添加物料 去选择
2026-04-14 08:46:29 +08:00
if (pathParams.value.type != 'inbound') {
2026-04-03 08:38:34 +08:00
getMaterialList();
}
})
// 创建/编辑 唯一码
const handleSubmit = () => {
// 物料最新编辑数据
const material = materialRef.value.getMaterialList()?.[0]
2026-04-14 08:46:29 +08:00
const query = objectToQuery(pathParams.value)
2026-04-03 08:38:34 +08:00
const params = {
remark: formData.value.remark,
material: { ...material.material, unitId: '23' }
}
2026-04-23 14:35:54 +08:00
if (pathParams.value.type == `stockIn_inbound`) {
2026-04-03 08:38:34 +08:00
params.billNo = pathParams.value.billNo
}
if (pathParams.value.id) {
params.id = pathParams.value.id; //唯一码id
params.material.id = formData.value.material?.[0]?.uniqueCodeMaterialId; //唯一码物料id
params.material.materialId = formData.value.material?.[0]?.materialId; //物料id
editUniqueCode(params).then((response) => {
if (response.code == 200) {
uni.showToast({
title: '唯一码编辑成功',
mask: true,
icon: 'success',
})
uni.navigateTo({
2026-04-14 08:46:29 +08:00
url: OPERATE_CONFIG.issueUniqueCode_edit.back + query
2026-04-03 08:38:34 +08:00
});
}
})
} else {
addUniqueCode(params).then((response) => {
if (response.code == 200) {
uni.showToast({
title: '唯一码创建成功',
mask: true,
icon: 'success',
})
2026-04-14 08:46:29 +08:00
if (_.includes(pathParams.value?.type, 'inbound')) {
2026-04-03 08:38:34 +08:00
uni.navigateTo({
2026-04-14 08:46:29 +08:00
url: OPERATE_CONFIG.stockIn_inbound.back + query
2026-04-03 08:38:34 +08:00
});
} else {
uni.switchTab({
2026-04-14 08:46:29 +08:00
url: OPERATE_CONFIG.issueUniqueCode.back
2026-04-03 08:38:34 +08:00
})
}
}
})
}
}
// 获取缓存内的物料列表
const getMaterialList = () => {
const value = uni.getStorageSync('app_material');
if (value) {
formData.value.material = value
if (value?.[0]?.uniqueCodeRemark) {
formData.value.remark = value?.[0]?.uniqueCodeRemark
}
}
}
</script>
<style scoped lang="scss">
.remarkLine {
display: flex;
align-items: center;
background-color: #fff;
justify-content: space-between;
padding: 8rpx 24rpx;
margin-bottom: 8rpx;
min-height: 40rpx;
2026-04-23 14:35:54 +08:00
text {
2026-04-03 08:38:34 +08:00
font-size: 14px;
}
p {
font-weight: 700;
font-size: 14px;
}
}
::v-deep .uv-button {
height: 20px;
}
::v-deep .form {
.title {
color: #424242;
}
.tag {
.uni-tag {
display: flex;
align-items: center;
height: calc(25px - 6px);
}
.tag-form {
display: flex;
align-items: center;
}
.uni-forms-item {
margin-bottom: 0;
align-items: center;
.uni-easyinput__content,
.uni-easyinput__content-input {
height: 25px;
width: 80px;
}
}
}
.remark {
.uni-forms-item {
margin-bottom: 0;
margin-top: 16rpx;
display: flex;
align-items: center;
.uni-forms-item__label {
color: #212121;
height: 40rpx;
}
.uni-easyinput__content-input {
height: 40rpx;
.uni-input-wrapper {
text-align: right;
}
}
.uni-input-placeholder {
text-align: right;
font-size: 13px;
}
}
}
}
</style>