From d99cbed8146991dbaea2f50897ccde8ba40493e6 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期一, 23 三月 2026 17:49:01 +0800
Subject: [PATCH] fix: 仓储物流增加编辑功能
---
src/pages/inventoryManagement/receiptManagement/index.vue | 312 ++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 253 insertions(+), 59 deletions(-)
diff --git a/src/pages/inventoryManagement/receiptManagement/index.vue b/src/pages/inventoryManagement/receiptManagement/index.vue
index 60a3ccc..002b2d9 100644
--- a/src/pages/inventoryManagement/receiptManagement/index.vue
+++ b/src/pages/inventoryManagement/receiptManagement/index.vue
@@ -2,19 +2,6 @@
<view class="receipt-page">
<PageHeader title="鍏ュ簱绠$悊" @back="goBack" />
- <!-- 鏍囩锛氬悎鏍煎叆搴� / 涓嶅悎鏍煎叆搴� -->
- <view class="tabs-wrap">
- <view
- v-for="tab in tabs"
- :key="tab.name"
- class="tab-item"
- :class="{ active: activeTab === tab.name }"
- @click="activeTab = tab.name"
- >
- <text>{{ tab.label }}</text>
- </view>
- </view>
-
<!-- 鎼滅储鍖哄煙 -->
<view class="search-section">
<view class="search-row">
@@ -34,7 +21,7 @@
</view>
</view>
- <!-- 鍒楄〃锛堝悎鏍�/涓嶅悎鏍煎叡鐢ㄦ帴鍙� type 鍖哄垎锛� -->
+ <!-- 鍒楄〃 -->
<view class="list-section" v-if="activeTab !== 'custom'">
<view v-if="tableData.length > 0">
<view
@@ -59,7 +46,20 @@
</view>
</view>
<view class="card-actions">
- <view class="btn-delete" @click.stop="handleDeleteSingle(item)">鍒犻櫎</view>
+ <view
+ v-if="isQualifiedRow(item) && hasReceiptEdit"
+ class="btn-edit"
+ @click.stop="handleEdit(item)"
+ >
+ 缂栬緫
+ </view>
+ <view
+ v-if="hasReceiptCancel"
+ class="btn-delete"
+ @click.stop="handleDeleteSingle(item)"
+ >
+ 鍒犻櫎
+ </view>
</view>
</view>
</view>
@@ -69,32 +69,93 @@
<view class="load-more-wrap" v-if="tableData.length > 0">
<u-loadmore :status="loadStatus" @loadmore="loadMore" />
</view>
+
+ <!-- 缂栬緫寮圭獥 -->
+ <up-popup :show="showEditModal" mode="bottom" @close="showEditModal = false">
+ <view class="edit-popup">
+ <view class="popup-header">
+ <text class="popup-title">缂栬緫鍏ュ簱</text>
+ </view>
+ <scroll-view scroll-y class="popup-body">
+ <view class="form-row">
+ <text class="form-label required">杞︾墝鍙�</text>
+ <up-input v-model="editForm.licensePlateNo" placeholder="璇疯緭鍏ヨ溅鐗屽彿" />
+ </view>
+ <view class="form-row">
+ <text class="form-label required">姣涢噸(鍚�)</text>
+ <up-input v-model="editForm.grossWeight" type="digit" placeholder="璇疯緭鍏ユ瘺閲�" @blur="computeNetWeightEdit" />
+ </view>
+ <view class="form-row">
+ <text class="form-label required">鐨噸(鍚�)</text>
+ <up-input v-model="editForm.tareWeight" type="digit" placeholder="璇疯緭鍏ョ毊閲�" @blur="computeNetWeightEdit" />
+ </view>
+ <view class="form-row">
+ <text class="form-label required">鍑�閲�(鍚�)</text>
+ <up-input v-model="editForm.netWeight" type="digit" placeholder="鑷姩璁$畻" disabled />
+ </view>
+ <view class="form-row">
+ <text class="form-label required">杩囩鏃ユ湡</text>
+ <view class="selector-trigger" @click="openWeighingDatePicker">
+ <text class="selector-text" :class="{ placeholder: !editForm.weighingDate }">
+ {{ editForm.weighingDate || '璇烽�夋嫨杩囩鏃ユ湡' }}
+ </text>
+ <up-icon name="calendar" size="16" color="#999" />
+ </view>
+ </view>
+ <view class="form-row">
+ <text class="form-label required">杩囩鍛�</text>
+ <up-input v-model="editForm.weighingOperator" placeholder="璇疯緭鍏ヨ繃纾呭憳" />
+ </view>
+ <view class="form-row">
+ <text class="form-label">澶囨敞</text>
+ <up-input v-model="editForm.remark" type="textarea" placeholder="閫夊~" />
+ </view>
+ </scroll-view>
+ <view class="popup-footer">
+ <view class="btn-cancel" @click="showEditModal = false">鍙栨秷</view>
+ <view class="btn-ok" @click="handleEditSubmit">纭</view>
+ </view>
+
+ <!-- 杩囩鏃ユ湡閫夋嫨 -->
+ <up-popup :show="showWeighingDatePicker" mode="bottom" @close="showWeighingDatePicker = false">
+ <up-datetime-picker
+ :show="true"
+ v-model="weighingDateValue"
+ mode="datetime"
+ @confirm="onWeighingDateConfirm"
+ @cancel="showWeighingDatePicker = false"
+ />
+ </up-popup>
+ </view>
+ </up-popup>
</view>
</template>
<script setup>
-import { ref, reactive, toRefs, watch } from 'vue'
+import { computed, ref, reactive, toRefs, watch } from 'vue'
import { onShow, onReachBottom } from '@dcloudio/uni-app'
+import dayjs from 'dayjs'
import PageHeader from '@/components/PageHeader.vue'
import {
getStockInRecordListPage,
- batchDeleteStockInRecords
+ batchDeleteStockInRecords,
+ editStockInStock
} from '@/api/inventoryManagement/stockInRecord.js'
import {
- findAllQualifiedStockInRecordTypeOptions,
- findAllUnQualifiedStockInRecordTypeOptions
+ findAllQualifiedStockInRecordTypeOptions
} from '@/api/basicData/enum.js'
+import { checkPermi } from '@/utils/permission'
-const activeTab = ref('qualified')
const stockRecordTypeOptions = ref([])
-const tabs = [
- { label: '鍚堟牸鍏ュ簱', name: 'qualified', type: '0' },
- { label: '涓嶅悎鏍煎叆搴�', name: 'unqualified', type: '1' }
-]
+const currentType = () => '0'
const tableData = ref([])
const total = ref(0)
const loadStatus = ref('loadmore') // loadmore | loading | nomore | error
+
+// 鏉冮檺鎺у埗
+const hasReceiptEdit = computed(() => checkPermi(['receipt_edit']))
+const hasReceiptCancel = computed(() => checkPermi(['receipt_cancel']))
const page = reactive({ current: 1, size: 4 })
const data = reactive({
@@ -104,18 +165,17 @@
})
const { searchForm } = toRefs(data)
-const currentType = () => tabs.find(t => t.name === activeTab.value)?.type || '0'
-
function getRecordType(recordType) {
if (recordType == null || recordType === '') return ''
return stockRecordTypeOptions.value.find(item => item.value === recordType)?.label || ''
}
+function isQualifiedRow(row) {
+ return row?.recordType === 0 || row?.recordType === '0'
+}
+
function fetchRecordTypeOptions() {
- const api = currentType() === '1'
- ? findAllUnQualifiedStockInRecordTypeOptions
- : findAllQualifiedStockInRecordTypeOptions
- api()
+ findAllQualifiedStockInRecordTypeOptions()
.then(res => {
const data = res.data != null ? res.data : res
stockRecordTypeOptions.value = Array.isArray(data) ? data : []
@@ -126,7 +186,6 @@
}
const getList = () => {
- if (activeTab.value === 'custom') return
const isFirstPage = page.current === 1
if (isFirstPage) {
uni.showLoading({ title: '鍔犺浇涓�...', mask: true })
@@ -170,13 +229,6 @@
getList()
}
-watch(activeTab, () => {
- page.current = 1
- loadStatus.value = 'loadmore'
- stockRecordTypeOptions.value = []
- getList()
-})
-
const handleQuery = () => {
page.current = 1
loadStatus.value = 'loadmore'
@@ -188,7 +240,7 @@
try {
uni.setStorageSync('receiptDetailItem', JSON.stringify({
item,
- type: currentType()
+ type: '0'
}))
} catch (e) {}
uni.navigateTo({
@@ -215,10 +267,81 @@
})
}
+// ---------------- 缂栬緫鍏ュ簱 ----------------
+const showEditModal = ref(false)
+const showWeighingDatePicker = ref(false)
+const weighingDateValue = ref(Date.now())
+
+const editForm = reactive({
+ id: null,
+ licensePlateNo: '',
+ grossWeight: '',
+ tareWeight: '',
+ netWeight: '',
+ weighingDate: '',
+ weighingOperator: '',
+ remark: ''
+})
+
+const computeNetWeightEdit = () => {
+ const gross = Number(editForm.grossWeight)
+ const tare = Number(editForm.tareWeight)
+ if (Number.isFinite(gross) && Number.isFinite(tare)) {
+ const net = gross - tare
+ const safeNet = Number(net.toFixed(2))
+ editForm.netWeight = safeNet > 0 ? safeNet : 0
+ }
+}
+
+watch(
+ () => [editForm.grossWeight, editForm.tareWeight],
+ () => {
+ if (showEditModal.value) computeNetWeightEdit()
+ }
+)
+
+const openWeighingDatePicker = () => {
+ weighingDateValue.value = editForm.weighingDate ? dayjs(editForm.weighingDate).valueOf() : Date.now()
+ showWeighingDatePicker.value = true
+}
+
+const onWeighingDateConfirm = (e) => {
+ editForm.weighingDate = dayjs(e.value).format('YYYY-MM-DD HH:mm:ss')
+ showWeighingDatePicker.value = false
+}
+
+const handleEdit = (row) => {
+ Object.assign(editForm, row || {})
+ computeNetWeightEdit()
+ showEditModal.value = true
+}
+
+const handleEditSubmit = () => {
+ if (!editForm.licensePlateNo) return uni.showToast({ title: '璇疯緭鍏ヨ溅鐗屽彿', icon: 'none' })
+ if (editForm.grossWeight === '' || Number(editForm.grossWeight) < 0) return uni.showToast({ title: '璇疯緭鍏ユ瘺閲�', icon: 'none' })
+ if (editForm.tareWeight === '' || Number(editForm.tareWeight) < 0) return uni.showToast({ title: '璇疯緭鍏ョ毊閲�', icon: 'none' })
+ if (!editForm.weighingDate) return uni.showToast({ title: '璇烽�夋嫨杩囩鏃ユ湡', icon: 'none' })
+ if (!editForm.weighingOperator) return uni.showToast({ title: '璇疯緭鍏ヨ繃纾呭憳', icon: 'none' })
+
+ uni.showLoading({ title: '淇濆瓨涓�...', mask: true })
+ editStockInStock({ ...editForm })
+ .then(() => {
+ uni.showToast({ title: '缂栬緫鎴愬姛', icon: 'success' })
+ showEditModal.value = false
+ getList()
+ })
+ .catch(() => {
+ uni.showToast({ title: '缂栬緫澶辫触', icon: 'none' })
+ })
+ .finally(() => {
+ uni.hideLoading()
+ })
+}
+
const goBack = () => uni.navigateBack()
onShow(() => {
- if (activeTab.value !== 'custom') getList()
+ getList()
})
onReachBottom(() => {
@@ -231,25 +354,6 @@
min-height: 100vh;
background: #f5f5f5;
padding-bottom: 40rpx;
-}
-.tabs-wrap {
- display: flex;
- background: #fff;
- padding: 24rpx;
- gap: 24rpx;
-}
-.tab-item {
- flex: 1;
- text-align: center;
- padding: 20rpx;
- border-radius: 12rpx;
- background: #f0f0f0;
- font-size: 28rpx;
- color: #666;
-}
-.tab-item.active {
- background: #2979ff;
- color: #fff;
}
.search-section {
background: #fff;
@@ -340,11 +444,27 @@
display: flex;
justify-content: center;
align-items: center;
+ width: 100%;
+ text-align: center;
}
.btn-delete {
font-size: 28rpx;
color: #f56c6c;
padding: 12rpx 32rpx;
+ margin: 0 auto;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+}
+
+.btn-edit {
+ font-size: 28rpx;
+ color: #2979ff;
+ padding: 12rpx 32rpx;
+ margin: 0 auto;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
}
.no-data {
text-align: center;
@@ -355,4 +475,78 @@
.load-more-wrap {
padding: 24rpx 0 40rpx;
}
+
+/* 缂栬緫寮圭獥鏍峰紡 */
+.edit-popup {
+ background: #fff;
+ border-radius: 24rpx 24rpx 0 0;
+ padding-bottom: env(safe-area-inset-bottom);
+}
+.popup-header {
+ padding: 24rpx;
+ border-bottom: 1rpx solid #eee;
+ text-align: center;
+}
+.popup-title {
+ font-size: 30rpx;
+ font-weight: 500;
+ color: #333;
+}
+.popup-body {
+ padding: 24rpx 24rpx 0;
+ max-height: 60vh;
+}
+.popup-footer {
+ display: flex;
+ gap: 24rpx;
+ padding: 16rpx 24rpx calc(16rpx + env(safe-area-inset-bottom));
+ border-top: 1rpx solid #eee;
+}
+.btn-cancel,
+.btn-ok {
+ flex: 1;
+ height: 88rpx;
+ border-radius: 999rpx;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 30rpx;
+}
+.btn-cancel {
+ background: #f0f0f0;
+ color: #666;
+}
+.btn-ok {
+ background: #2979ff;
+ color: #fff;
+}
+.form-row {
+ margin-bottom: 24rpx;
+}
+.form-label {
+ display: block;
+ font-size: 26rpx;
+ color: #666;
+ margin-bottom: 12rpx;
+}
+.form-label.required:before {
+ content: '*';
+ color: #f56c6c;
+ margin-right: 6rpx;
+}
+.selector-trigger {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 20rpx 24rpx;
+ background: #f5f5f5;
+ border-radius: 12rpx;
+}
+.selector-text {
+ font-size: 28rpx;
+ color: #333;
+}
+.selector-text.placeholder {
+ color: #999;
+}
</style>
--
Gitblit v1.9.3