入库流程对接完毕
This commit is contained in:
205
pages/warehousing/uniqueCode/issueUniqueCode/index.vue
Normal file
205
pages/warehousing/uniqueCode/issueUniqueCode/index.vue
Normal file
@@ -0,0 +1,205 @@
|
||||
<!-- 唯一码发放页面 -->
|
||||
<template>
|
||||
<view class="content">
|
||||
<view class="remarkLine">
|
||||
<span>备注:</span>
|
||||
<uni-easyinput type="text" v-model="formData.remark" :inputBorder="false" placeholder="请输入备注" />
|
||||
</view>
|
||||
|
||||
<!-- 物料列表 - 添加物料 -->
|
||||
<material-list ref="materialRef" :formData="formData" :remark="formData.remark" isEdit="1" :backStr="backStr"
|
||||
:pathParams="pathParams" />
|
||||
<button class="bottom-btn" type="primary" @click="handleSubmit">提交</button>
|
||||
</view>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue';
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app';
|
||||
import { addUniqueCode, editUniqueCode } from '@/api/uniqueCode';
|
||||
import MaterialList from '../../../components/MaterialList.vue';
|
||||
import { computed } from 'vue';
|
||||
import _ from 'lodash';
|
||||
|
||||
// 数据:路径参数
|
||||
const pathParams = ref('')
|
||||
// 数据:物料、备注
|
||||
const formData = ref({ remark: '', material: [] })
|
||||
// ref:绑定物料列表
|
||||
const materialRef = ref([])
|
||||
const backStr = computed(() => pathParams.value.back == 'inbound' ? `issueUniqueCode_inbound` : 'issueUniqueCode')
|
||||
// 接收路径参数 - 修改标题- 携带code、id、materialId
|
||||
onLoad((options) => {
|
||||
pathParams.value = options
|
||||
|
||||
})
|
||||
onShow(() => {
|
||||
if (pathParams.value.title) {
|
||||
uni.setNavigationBarTitle({ title: pathParams.value.title })
|
||||
}
|
||||
if (pathParams.value.back == 'inbound') {
|
||||
uni.setNavigationBarTitle({ title: '快速生成唯一码' })
|
||||
}
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
// 快速生成唯一码时 已选择的物料列表初始为空 点击添加物料 去选择
|
||||
if (pathParams.value.back != 'inbound') {
|
||||
getMaterialList();
|
||||
}
|
||||
|
||||
})
|
||||
// 创建/编辑 唯一码
|
||||
const handleSubmit = () => {
|
||||
// 物料最新编辑数据
|
||||
const material = materialRef.value.getMaterialList()?.[0]
|
||||
|
||||
const params = {
|
||||
remark: formData.value.remark,
|
||||
material: { ...material.material, unitId: '23' }
|
||||
}
|
||||
if (pathParams.value.back == `issueUniqueCode_inbound`) {
|
||||
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({
|
||||
url: `/pages/warehousing/uniqueCode/myUniqueCode/detail?id=${pathParams.value.id}&title=${pathParams.value.title}`,
|
||||
});
|
||||
}
|
||||
|
||||
})
|
||||
} else {
|
||||
addUniqueCode(params).then((response) => {
|
||||
if (response.code == 200) {
|
||||
uni.showToast({
|
||||
title: '唯一码创建成功',
|
||||
mask: true,
|
||||
icon: 'success',
|
||||
})
|
||||
if (_.includes(pathParams.value?.back, 'inbound')) {
|
||||
// /pages/warehousing/uniqueCode/myUniqueCode/detail?id=38&code=600038
|
||||
uni.navigateTo({
|
||||
url: `/pages/warehousing/stockIn/components/inbound?billNo=${pathParams.value.billNo}`,
|
||||
});
|
||||
} else {
|
||||
uni.switchTab({
|
||||
url: "/pages/warehousing/index"
|
||||
})
|
||||
}
|
||||
// /pages/warehousing/stockIn/components/inbound?billNo=WR1775032495153
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 获取缓存内的物料列表
|
||||
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;
|
||||
|
||||
span {
|
||||
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>
|
||||
@@ -0,0 +1,218 @@
|
||||
<!-- 物料选择 -->
|
||||
<template>
|
||||
<view class="content">
|
||||
<view class="topSearch" v-if="!backUrl.includes('inbound')">
|
||||
<uni-easyinput type="text" v-model="queryParams.keyword" prefixIcon="search" :inputBorder="false"
|
||||
@iconClick="getMaterialList" placeholder="请输入搜索内容" />
|
||||
</view>
|
||||
|
||||
<!-- 物料列表 -->
|
||||
<z-paging ref="pagingRef" class="containerBox" v-model="materialList" @query="getMaterialList"
|
||||
v-if="!backUrl.includes('inbound')">
|
||||
<uni-list>
|
||||
<uni-list-item v-for="item in materialList" :key="item.id" clickable class="material-card"
|
||||
@click="onMaterial(item)">
|
||||
<template v-slot:body>
|
||||
<p style="display: flex; flex-direction: column; width: 100%;">
|
||||
<p class="title">{{ item.materialName }} ({{ item.materialCode }})</p>
|
||||
<p class="subTitle">
|
||||
<!-- 简称/型号/规格/类型 -->
|
||||
<span v-if="item.materialShortName">{{ item.materialShortName }} / </span>
|
||||
<span v-if="item.model">{{ item.model }} / </span>
|
||||
<span v-if="item.specification">{{ item.specification }} / </span>
|
||||
<span v-if="item.typeName">{{ item.typeName }} </span>
|
||||
</p>
|
||||
<p class="tag">
|
||||
<uni-tag :text="getTypeParentNames(item.typeParentNames)" type="error" />
|
||||
<p>单位:{{ item.unitName }}</p>
|
||||
</p>
|
||||
</p>
|
||||
|
||||
</template>
|
||||
</uni-list-item>
|
||||
</uni-list>
|
||||
</z-paging>
|
||||
|
||||
<view v-if="backUrl.includes('inbound')">
|
||||
<uni-list>
|
||||
<uni-list-item v-for="item in materialList" :key="item.id" clickable class="material-card"
|
||||
@click="onMaterial(item)">
|
||||
<template v-slot:body>
|
||||
<p style="display: flex; flex-direction: column; width: 100%;">
|
||||
<p class="title">{{ item.materialName }} ({{ item.materialCode }})</p>
|
||||
<p class="subTitle">
|
||||
<!-- 简称/型号/规格/类型 -->
|
||||
<span v-if="item.materialShortName">{{ item.materialShortName }} / </span>
|
||||
<span v-if="item.model">{{ item.model }} / </span>
|
||||
<span v-if="item.specification">{{ item.specification }} / </span>
|
||||
<span v-if="item.typeName">{{ item.typeName }} </span>
|
||||
</p>
|
||||
<p class="tag">
|
||||
<uni-tag :text="getTypeParentNames(item.typeParentNames)" type="error" />
|
||||
<p>单位:{{ item.unitName }}</p>
|
||||
</p>
|
||||
</p>
|
||||
|
||||
</template>
|
||||
</uni-list-item>
|
||||
</uni-list>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<script setup>
|
||||
import _ from 'lodash';
|
||||
import { computed, ref } from 'vue';
|
||||
import { getTypeParentNames, } from '../until';
|
||||
import { objectToQuery } from '../../../until';
|
||||
import { getMaterial } from '@/api/uniqueCode'
|
||||
import { onShow, onLoad } from "@dcloudio/uni-app";
|
||||
|
||||
// ref:下拉加载
|
||||
const pagingRef = ref(null)
|
||||
// 数据:查询参数
|
||||
const queryParams = ref({
|
||||
keyword: ''
|
||||
})
|
||||
// 数据:物料
|
||||
const materialList = ref([])
|
||||
// 数据:路径参数
|
||||
const pathParams = ref('')
|
||||
|
||||
// 数据:返回路径标识 stockIn 入库单开单 stockInDetail入库单编辑 issueUniqueCode唯一码 issueUniqueCode_inbound入库生成唯一码
|
||||
const backUrl = computed(() => pathParams?.value?.back)
|
||||
// 方法:获取列表
|
||||
const getMaterialList = () => {
|
||||
getMaterial(queryParams.value).then(res => {
|
||||
res.rows.forEach(e => {
|
||||
e.showMore = false;
|
||||
});
|
||||
pagingRef.value.complete(res.rows)
|
||||
}).catch(res => {
|
||||
pagingRef.value.complete(false)
|
||||
})
|
||||
}
|
||||
// 方法:获取列表 - 入库生成唯一码
|
||||
const getMaterialListInbound = () => {
|
||||
const list = uni.getStorageSync('app_material_select_list')
|
||||
console.log('list',list);
|
||||
materialList.value=list
|
||||
|
||||
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
pagingRef.value?.reload?.()
|
||||
})
|
||||
onLoad((options) => {
|
||||
pathParams.value = options
|
||||
getMaterialListInbound()
|
||||
})
|
||||
// 方法:获取缓存物料信息
|
||||
const getStorageMaterial = (val) => {
|
||||
// 唯一码编辑进入 数量默认1\唯一码物料表id\物料id
|
||||
if (pathParams.value.id) {
|
||||
const value = uni.getStorageSync('app_material');
|
||||
if (value && value?.length > 0) {
|
||||
return [{ ...val, quantity: 1, uniqueCodeMaterialId: value?.[0]?.id, uniqueCodeRemark: value?.[0]?.uniqueCodeRemark, materialId: val.id, isDelete: '0' }]
|
||||
}
|
||||
}
|
||||
return [{ ...val, quantity: 1 }]
|
||||
}
|
||||
// 方法:返回路径
|
||||
const toBack = (back) => {
|
||||
const path = objectToQuery({ ...pathParams.value })
|
||||
let url = ''
|
||||
switch (back) {
|
||||
case 'stockIn':
|
||||
// 入库单开单添加物料进入
|
||||
url = `/pages/warehousing/stockIn/create`
|
||||
break
|
||||
case 'issueUniqueCode':
|
||||
case 'issueUniqueCode_inbound':
|
||||
// 唯一码发放/入库生成唯一码
|
||||
url = `/pages/warehousing/uniqueCode/issueUniqueCode/index`
|
||||
break
|
||||
case 'stockInDetail':
|
||||
//我的入库单/入库单入库
|
||||
url = `/pages/warehousing/stockIn/components/detail`
|
||||
break
|
||||
}
|
||||
uni.navigateTo({
|
||||
url: `${url}${path}`
|
||||
})
|
||||
}
|
||||
// 方法:选择物料
|
||||
const onMaterial = (val) => {
|
||||
let materialChecked = uni.getStorageSync('app_material');
|
||||
if (!Array.isArray(materialChecked)) {
|
||||
materialChecked = [];
|
||||
}
|
||||
|
||||
console.log(materialChecked, 'materialChecked==>');
|
||||
|
||||
const item = _.find(materialChecked, (i) => i.materialId ? i.materialId === val.id : i.id === val.id)
|
||||
console.log(item, 'item==>');
|
||||
|
||||
const idx = _.findIndex(materialChecked, (i) => i.materialId ? i.materialId === val.id : i.id === val.id)
|
||||
console.log(idx, 'idx==>', idx != -1 && item?.isDelete == '0', backUrl.value);
|
||||
|
||||
if (idx != -1 && item?.isDelete == '0') { // isDelete为0表示未删除 1为已删除数据不在对比范围内
|
||||
console.log(backUrl.value == 'stockIn', '11111111111111111111111111');
|
||||
|
||||
if (backUrl.value == 'stockIn') {
|
||||
console.log(111111111111);
|
||||
|
||||
uni.showToast({
|
||||
title: '该物料已添加,请勿重复添加!',
|
||||
mask: true,
|
||||
icon: 'none',
|
||||
})
|
||||
}
|
||||
//! 现在仅允许添加一条物料打印一个唯一码 但保留可添加多个
|
||||
// uni.showToast({
|
||||
// title: '该物料已添加,请勿重复添加!',
|
||||
// mask: true,
|
||||
// icon: 'none',
|
||||
// })
|
||||
toBack(backUrl.value)
|
||||
} else {
|
||||
console.log('执行到这里');
|
||||
|
||||
if (val) {
|
||||
if (backUrl.value == 'stockIn') {
|
||||
materialChecked = [...materialChecked, { ...val, quantity: 1, isDelete: '0' }];
|
||||
} else {
|
||||
materialChecked = getStorageMaterial(val)
|
||||
}
|
||||
uni.setStorageSync('app_material', materialChecked);
|
||||
}
|
||||
toBack(backUrl.value)
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
.topSearch {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 999;
|
||||
padding: 10px;
|
||||
background-color: #fff;
|
||||
border-bottom: 1px solid #eee;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.containerBox {
|
||||
// padding: 0 12rpx;
|
||||
padding-top: 60px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
|
||||
.zp-l-text-rpx {
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
112
pages/warehousing/uniqueCode/myUniqueCode/QrCodeModal.vue
Normal file
112
pages/warehousing/uniqueCode/myUniqueCode/QrCodeModal.vue
Normal file
@@ -0,0 +1,112 @@
|
||||
<template>
|
||||
<view style="display: block;">
|
||||
<view class="top">
|
||||
<uv-image src="../../../../static//logo/logo.jpg" width="40px" height="40px" style="margin-top:10rpx" />
|
||||
|
||||
<!-- 唯一兼容 iPad 的写法:纯 2D Canvas -->
|
||||
<canvas id="barcode" type="2d" class="barcode-canvas"></canvas>
|
||||
</view>
|
||||
|
||||
<view class="content mt-16">
|
||||
<p>物料:
|
||||
<span>{{ material?.materialName }}</span>
|
||||
<span v-if="material?.quantity">x {{ material?.quantity }}</span>
|
||||
</p>
|
||||
<p>描述:
|
||||
<span v-if="material?.description">{{ material?.description || '-' }}</span>
|
||||
<span v-else>
|
||||
<span v-if="material?.materialShortName">{{ material?.materialShortName }} / </span>
|
||||
<span v-if="material?.model">{{ material?.model }} / </span>
|
||||
<span v-if="material?.specification">{{ material?.specification }} / </span>
|
||||
<span v-if="material?.typeName">{{ material?.typeName }} </span>
|
||||
</span>
|
||||
</p>
|
||||
<view class="top">
|
||||
<p>备注:
|
||||
<span>{{ material?.uniqueCodeRemark || '' }}</span>
|
||||
</p>
|
||||
<uv-image :src="qrCode" width="80rpx" height="80rpx" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onMounted, computed, watch } from 'vue';
|
||||
import JsBarcode from 'jsbarcode';
|
||||
|
||||
const props = defineProps({
|
||||
detail: { type: Object, default: null }
|
||||
});
|
||||
|
||||
const qrCode = computed(() => props.detail?.material?.[0]?.qrCode);
|
||||
const material = computed(() => props.detail?.material?.[0]);
|
||||
const barcodeValue = computed(() => props.detail?.material?.[0]?.code || '');
|
||||
|
||||
|
||||
// iPad 兼容核心:不用 document,只用 uni 官方 API
|
||||
const drawBarcode = () => {
|
||||
if (!barcodeValue.value) return;
|
||||
|
||||
const query = uni.createSelectorQuery();
|
||||
query.select('#barcode')
|
||||
.fields({ node: true, size: true })
|
||||
.exec((res) => {
|
||||
const canvas = res[0]?.node;
|
||||
if (!canvas) return;
|
||||
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
// 渲染条形码
|
||||
JsBarcode(canvas, barcodeValue.value, {
|
||||
format: 'CODE128',
|
||||
width: 2,
|
||||
height: 40,
|
||||
displayValue: false,
|
||||
margin: 10,
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// 延迟执行,保证 iPad 能加载
|
||||
onMounted(() => {
|
||||
setTimeout(drawBarcode, 400);
|
||||
});
|
||||
|
||||
// 数据变化重新绘制
|
||||
watch(
|
||||
() => props.detail,
|
||||
() => setTimeout(drawBarcode, 400),
|
||||
{ deep: true }
|
||||
);
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.content {
|
||||
|
||||
// display: flex;
|
||||
p {
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
span {
|
||||
font-weight: 400;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 必须给宽度高度,iPad 才会显示 */
|
||||
.barcode-canvas {
|
||||
width: 40%;
|
||||
height: 20px;
|
||||
}
|
||||
</style>
|
||||
184
pages/warehousing/uniqueCode/myUniqueCode/detail.vue
Normal file
184
pages/warehousing/uniqueCode/myUniqueCode/detail.vue
Normal file
@@ -0,0 +1,184 @@
|
||||
<!-- 唯一码详情 -->
|
||||
<template>
|
||||
<!-- 自定义导航栏 -->
|
||||
<navigation :title="pathParams.code ? pathParams.code : '唯一码发放'">
|
||||
<template #right>
|
||||
<view class="right-btn flex align-center justify-center ">
|
||||
<uv-image @click="toEdit" src="../../../../static/edit.png" class="ml-24" width="20px" height="20px"
|
||||
style="margin-top:10rpx" />
|
||||
</view>
|
||||
</template>
|
||||
</Navigation>
|
||||
<uv-skeletons :loading="loading" :skeleton="skeleton">
|
||||
<view class=" content">
|
||||
<!-- 唯一码展示 -->
|
||||
<uni-list>
|
||||
<uni-list-item v-for="item in uniqueCodeList" :key="item.id" clickable class="material-card">
|
||||
<template v-slot:body>
|
||||
<p style="display: flex; flex-direction: column; width: 100%;">
|
||||
<!-- 编码、状态行 -->
|
||||
<view class="flex-center">
|
||||
<p class="title">编号:{{ item.code }}</p>
|
||||
<p class="status">{{ getStatusName(item.status) }}</p>
|
||||
</view>
|
||||
<!-- 内容行 -->
|
||||
<view class="text">
|
||||
<p>RFID:
|
||||
<span v-if="item.rfidCode">{{ item.remark }}</span>
|
||||
<span v-else style="color: #999;">未绑定RFID</span>
|
||||
</p>
|
||||
<p>生成时间:
|
||||
<span>{{ item?.createTime }}</span>
|
||||
</p>
|
||||
<!-- 备注行-->
|
||||
<view class="flex-center qrCode">
|
||||
<p>备注:
|
||||
<span v-if="item.remark">{{ item.remark }}</span>
|
||||
<span v-else style="color: #999;">未填写</span>
|
||||
</p>
|
||||
<view @click="toViewQrCode">
|
||||
<uv-image src="../../../../static/qrcode.png" width="40rpx" height="40rpx"
|
||||
style="margin-top:10rpx" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</p>
|
||||
</template>
|
||||
</uni-list-item>
|
||||
</uni-list>
|
||||
<!-- 物料列表 -只读 -->
|
||||
<view>
|
||||
<material-list ref="materialRef" :formData="materialList" isEdit="2" />
|
||||
</view>
|
||||
|
||||
<!-- 底部按钮 -->
|
||||
<view class="bottom">
|
||||
<uv-button type="primary" text="唯一码打印"></uv-button>
|
||||
<uv-button type="success" text="溯源" @click="toTraceability"></uv-button>
|
||||
</view>
|
||||
</view>
|
||||
</uv-skeletons>
|
||||
<uv-modal ref="modalRef" :title="none" class="qrCodeModal" width="480rpx" :showConfirmButton="false">
|
||||
<qr-code-modal :detail="materialList" />
|
||||
</uv-modal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app';
|
||||
import { detailUniqueCode } from '@/api/uniqueCode'
|
||||
import { getStatusName, getDetail } from '../until';
|
||||
import QrCodeModal from './QrCodeModal.vue';
|
||||
import MaterialList from '../../../components/MaterialList.vue'
|
||||
import Navigation from '../../../components/Navigation.vue'
|
||||
|
||||
const modalRef = ref()
|
||||
// 路径参数
|
||||
const pathParams = ref('')
|
||||
// 物料列表数组
|
||||
const materialList = ref({
|
||||
material: {},
|
||||
remark: ''
|
||||
})
|
||||
// 唯一码数组
|
||||
const uniqueCodeList = ref([])
|
||||
// 详情数据
|
||||
const detail = ref([])
|
||||
// 骨架屏开关
|
||||
const loading = ref(true)
|
||||
// 骨架屏样式
|
||||
const skeleton = [{
|
||||
type: 'line',
|
||||
num: 3,
|
||||
gap: '20rpx',
|
||||
style: ['width: 200rpx;marginBottom: 50rpx;marginTop:50rpx;padding:24rpx', 'height: 100rpx;', 'width: 500rpx;'],
|
||||
}]
|
||||
const toViewQrCode = () => {
|
||||
modalRef.value.open()
|
||||
|
||||
}
|
||||
// 详情:唯一码
|
||||
const getDetailInfo = () => {
|
||||
detailUniqueCode({ id: pathParams.value.id }).then((res) => {
|
||||
if (res.code == 200) {
|
||||
// ! 写成数组原因 为了适应可多个物料生成唯一码
|
||||
// 将物料写入信息以及物料详细信息解构出来、以及qrCode、唯一码对应的物料code、qrCodeMark仅用于二维码页面的备注展示
|
||||
materialList.value.material = [{
|
||||
...res.data.material,
|
||||
...getDetail(res.data.material.wornMaterial),
|
||||
qrCode: res.data.qrCode,
|
||||
code: res.data.code, //唯一码code
|
||||
uniqueCodeMaterialId: res.data.material.id, //唯一码物料id
|
||||
uniqueCodeRemark: res.data.remark, //唯一码备注
|
||||
}]
|
||||
// 唯一码备注
|
||||
materialList.value.remark = res.data.remark
|
||||
uniqueCodeList.value = [res.data]
|
||||
|
||||
console.log('详情数据:唯一码materialList', materialList);
|
||||
// 更新缓存物料值
|
||||
uni.setStorageSync('app_material', materialList.value.material);
|
||||
|
||||
} else {
|
||||
materialList.value = []
|
||||
uniqueCodeList.value = []
|
||||
uni.showToast({ title: '暂无数据', icon: 'none' })
|
||||
}
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
// 溯源
|
||||
const toTraceability = () => {
|
||||
}
|
||||
|
||||
// 修改:唯一码的物料信息 - 携带title和唯一码id
|
||||
const toEdit = () => {
|
||||
uni.navigateTo({
|
||||
url: `/pages/warehousing/uniqueCode/issueUniqueCode/index?title=${pathParams.value.code}&id=${pathParams.value.id}`,
|
||||
});
|
||||
|
||||
}
|
||||
// 接收id 且修改标题
|
||||
onLoad((options) => {
|
||||
if (!options.id) {
|
||||
loading.value = false
|
||||
uni.showToast({ title: '参数错误,无唯一码ID', icon: 'none' })
|
||||
return
|
||||
}
|
||||
pathParams.value = options
|
||||
getDetailInfo()
|
||||
})
|
||||
|
||||
onShow(() => {
|
||||
uni.setNavigationBarTitle({ title: pathParams.value.code })
|
||||
})
|
||||
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
// 底部按钮
|
||||
.bottom {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
height: 60rpx;
|
||||
font-size: 14px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
|
||||
.uv-button-wrapper {
|
||||
width: 50%;
|
||||
border-radius: 0;
|
||||
}
|
||||
}
|
||||
|
||||
::v-deep.qrCodeModal {
|
||||
.uv-modal__content {
|
||||
display: block !important;
|
||||
padding: 24rpx;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
173
pages/warehousing/uniqueCode/myUniqueCode/index.vue
Normal file
173
pages/warehousing/uniqueCode/myUniqueCode/index.vue
Normal file
@@ -0,0 +1,173 @@
|
||||
<!-- 唯一码 -->
|
||||
<template>
|
||||
<view class="content">
|
||||
<view class="topSearch">
|
||||
<uni-easyinput type="text" v-model="queryParams.code" prefixIcon="search" :inputBorder="false"
|
||||
@iconClick="getMaterialList" placeholder="请输入关键词搜索" />
|
||||
</view>
|
||||
|
||||
<!-- 唯一码列表 -->
|
||||
<z-paging ref="pagingRef" class="containerBox" v-model="uniqueCodeList" @query="getMaterialList">
|
||||
<uni-list>
|
||||
<uni-list-item v-for="item in uniqueCodeList" :key="item.id" clickable class="material-card"
|
||||
@longpress="() => handleItemLongPress(item, index)" @click="toDetail(item)">
|
||||
<template v-slot:body>
|
||||
<p style="display: flex; flex-direction: column; width: 100%;">
|
||||
<!-- 编码、状态行 -->
|
||||
<view class="flex-center">
|
||||
<p class="title">编号:{{ item.code }}</p>
|
||||
<p class="status">{{ getStatusName(item.status) }}</p>
|
||||
</view>
|
||||
<!-- 内容行 -->
|
||||
<view class="text ">
|
||||
<p>RFID:
|
||||
<span v-if="item.rfidCode">{{ item.remark }}</span>
|
||||
<span v-else style="color: #999;">未绑定RFID</span>
|
||||
</p>
|
||||
<p>生成时间:
|
||||
<span>{{ item?.createTime }}</span>
|
||||
</p>
|
||||
<!-- 备注行-->
|
||||
<view class="flex-center qrCode">
|
||||
<p>备注:
|
||||
<span v-if="item.remark">{{ item.remark }}</span>
|
||||
<span v-else style="color: #999;">未填写</span>
|
||||
</p>
|
||||
<view @click.stop="getDetailInfo(item)">
|
||||
<uv-image src="../../../../static/qrcode.png" width="40rpx" height="40rpx"
|
||||
style="margin-top:10rpx" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</p>
|
||||
</template>
|
||||
</uni-list-item>
|
||||
</uni-list>
|
||||
</z-paging>
|
||||
<view>
|
||||
|
||||
<uni-popup ref="alertDialog" type="center">
|
||||
<uni-popup-dialog type="error" v-if="isDialog" cancelText="取消" confirmText="确认" title="是否需要删除该唯一码?"
|
||||
@confirm="dialogConfirm" @close="dialogClose"></uni-popup-dialog>
|
||||
</uni-popup>
|
||||
</view>
|
||||
<!-- 唯一码图形显示弹窗 -->
|
||||
<uv-modal ref="modalRef" :title="none" class="qrCodeModal" :showConfirmButton="false">
|
||||
<qr-code-modal :detail="materialList" />
|
||||
</uv-modal>
|
||||
</view>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { getStatusName, getDetail } from '../until';
|
||||
import { onShow } from "@dcloudio/uni-app";
|
||||
import { getUniqueCodeList, delUniqueCode, detailUniqueCode } from '@/api/uniqueCode'
|
||||
import QrCodeModal from './QrCodeModal.vue';
|
||||
|
||||
const queryParams = ref({
|
||||
code: ''
|
||||
})
|
||||
|
||||
const pagingRef = ref(null)
|
||||
// 开关:唯一码图形
|
||||
const modalRef = ref()
|
||||
// 删除的数据
|
||||
const delItem = ref(null)
|
||||
// 删除弹框相关
|
||||
const alertDialog = ref(null)
|
||||
const isDialog = ref(false)
|
||||
// 唯一码列表
|
||||
const uniqueCodeList = ref([])
|
||||
// 物料列表数组
|
||||
const materialList = ref({
|
||||
material: []
|
||||
})
|
||||
// 列表:唯一码
|
||||
const getMaterialList = (pageNo, pageSize) => {
|
||||
queryParams.value.pageNum = pageNo
|
||||
console.log(pageNo, pageSize, queryParams.value)
|
||||
getUniqueCodeList(queryParams.value).then(res => {
|
||||
res.rows.forEach(e => {
|
||||
e.showMore = false;
|
||||
});
|
||||
pagingRef.value.complete(res.rows)
|
||||
}).catch(res => {
|
||||
pagingRef.value.complete(false)
|
||||
})
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
pagingRef.value?.reload?.()
|
||||
})
|
||||
|
||||
// 详情:唯一码
|
||||
const toDetail = (val) => {
|
||||
uni.navigateTo({
|
||||
url: `/pages/warehousing/uniqueCode/myUniqueCode/detail?id=${val.id}&code=${val.code}`,
|
||||
});
|
||||
}
|
||||
|
||||
// 删除弹窗:显示 长按事件
|
||||
const handleItemLongPress = (val) => {
|
||||
alertDialog.value.open()
|
||||
isDialog.value = true
|
||||
delItem.value = val
|
||||
}
|
||||
//删除弹窗:关闭
|
||||
const dialogClose = () => {
|
||||
alertDialog.value.close()
|
||||
isDialog.value = false
|
||||
}
|
||||
//删除弹窗:确认
|
||||
const dialogConfirm = () => {
|
||||
console.log(delItem.value.id, 'delItem.value.id');
|
||||
delUniqueCode({ ids: [delItem.value.id] }).then(res => {
|
||||
dialogClose()
|
||||
})
|
||||
}
|
||||
// 详情:唯一码
|
||||
const getDetailInfo = (row) => {
|
||||
detailUniqueCode({ id: row.id }).then((res) => {
|
||||
if (res.code == 200) {
|
||||
materialList.value.material = [{ ...res.data.material, ...getDetail(res.data.material.wornMaterial), qrCode: res.data.qrCode, code: res.data.code, uniqueCodeRemark: res.data.remark }]
|
||||
setTimeout(() => {
|
||||
modalRef.value.open()
|
||||
}, 300)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
.topSearch {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 999;
|
||||
padding: 10px;
|
||||
background-color: #fff;
|
||||
border-bottom: 1px solid #eee;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.containerBox {
|
||||
// padding: 0 12rpx;
|
||||
padding-top: 60px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
|
||||
.zp-l-text-rpx {
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
::v-deep.qrCodeModal {
|
||||
.uv-modal__content {
|
||||
display: block;
|
||||
padding: 24rpx;
|
||||
|
||||
}
|
||||
}
|
||||
</style>
|
||||
56
pages/warehousing/uniqueCode/until.js
Normal file
56
pages/warehousing/uniqueCode/until.js
Normal file
@@ -0,0 +1,56 @@
|
||||
export const getTypeParentNames = (val) => {
|
||||
if (val) {
|
||||
let value = val.replace(/\//g, ",");
|
||||
const arr = `${value}`.split(",");
|
||||
return arr[0];
|
||||
}
|
||||
};
|
||||
|
||||
const statusMenu = [
|
||||
{
|
||||
value: 0,
|
||||
label: "初始化创建",
|
||||
},
|
||||
{
|
||||
value: 1,
|
||||
label: "已打印",
|
||||
},
|
||||
{
|
||||
value: 2,
|
||||
label: "已入库",
|
||||
},
|
||||
{
|
||||
value: 3,
|
||||
label: "已出库,",
|
||||
},
|
||||
{
|
||||
value: 3,
|
||||
label: "已配送,",
|
||||
},
|
||||
];
|
||||
export const getStatusName = (val) => {
|
||||
if (val) {
|
||||
return statusMenu.find((i) => i.value == val)?.label || "";
|
||||
}
|
||||
|
||||
return "";
|
||||
};
|
||||
// 唯一码修改 生成想要的对象 切勿解构对象 会覆盖前值 数据错误
|
||||
export const getDetail = (info) => {
|
||||
return {
|
||||
materialName: info.materialName,
|
||||
materialCode: info.materialCode,
|
||||
materialShortName: info.materialShortName,
|
||||
model: info.model,
|
||||
specification: info.specification,
|
||||
typeName: info.typeName,
|
||||
unitName: info.unitName,
|
||||
typeParentNames: info.typeParentNames,
|
||||
description: info.description,
|
||||
weight: info.weight,
|
||||
kgFactor: info.kgFactor,
|
||||
materialId:info.id,//物料id
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user