From d5fdc05a9deae35f0c996379d3b6a228d8e31c2f Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期二, 24 三月 2026 13:53:00 +0800
Subject: [PATCH] fix: 出库编辑,去掉采购人

---
 src/pages/consumablesLogistics/dispatchLog/index.vue |  202 +++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 157 insertions(+), 45 deletions(-)

diff --git a/src/pages/consumablesLogistics/dispatchLog/index.vue b/src/pages/consumablesLogistics/dispatchLog/index.vue
index 132494f..50b15b4 100644
--- a/src/pages/consumablesLogistics/dispatchLog/index.vue
+++ b/src/pages/consumablesLogistics/dispatchLog/index.vue
@@ -1,17 +1,6 @@
 <template>
   <view class="dispatch-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">
         <view class="search-input-wrap">
@@ -40,17 +29,14 @@
               <view class="row"><text class="l">瑙勬牸鍨嬪彿</text><text class="r">{{ item.model }}</text></view>
               <view class="row"><text class="l">鍗曚綅</text><text class="r">{{ item.unit }}</text></view>
               <view class="row"><text class="l">鍑哄簱鏁伴噺</text><text class="r highlight">{{ item.stockOutNum }}</text></view>
+              <!-- <view class="row"><text class="l">閲囪喘鍛�</text><text class="r">{{ item.purchaser || '-' }}</text></view> -->
               <view class="row"><text class="l">鍑哄簱浜�</text><text class="r">{{ item.createBy }}</text></view>
               <view class="row" v-if="item.recordType !== undefined"><text class="l">鏉ユ簮</text><text class="r">{{ getRecordType(item.recordType) || item.recordType }}</text></view>
-              <view class="row"><text class="l">姣涢噸(鍚�)</text><text class="r">{{ item.grossWeight ?? '-' }}</text></view>
-              <view class="row"><text class="l">鐨噸(鍚�)</text><text class="r">{{ item.tareWeight ?? '-' }}</text></view>
-              <view class="row"><text class="l">鍑�閲�(鍚�)</text><text class="r">{{ item.netWeight ?? '-' }}</text></view>
-              <view class="row"><text class="l">杩囩鏃ユ湡</text><text class="r">{{ item.weighingDate || '-' }}</text></view>
-              <view class="row"><text class="l">杩囩鍛�</text><text class="r">{{ item.weighingOperator || '-' }}</text></view>
             </view>
           </view>
           <view class="card-actions">
-            <view class="btn-delete" @click.stop="handleDeleteSingle(item)">鍒犻櫎</view>
+            <view v-if="hasCDispatchEdit" class="btn-edit" @click.stop="handleEdit(item)">缂栬緫</view>
+            <view v-if="hasCDispatchCancel" class="btn-delete" @click.stop="handleDeleteSingle(item)">鍒犻櫎</view>
           </view>
         </view>
       </view>
@@ -59,30 +45,47 @@
     <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 class="popup-body" scroll-y>
+          <view class="form-row">
+            <text class="form-label required">鏁伴噺</text>
+            <up-input v-model="editForm.qualitity" type="number" placeholder="璇疯緭鍏ユ暟閲�" />
+          </view>
+        </scroll-view>
+        <view class="popup-footer">
+          <view class="btn-cancel" @click="showEditModal = false">鍙栨秷</view>
+          <view class="btn-ok" @click="handleEditSubmit">纭</view>
+        </view>
+      </view>
+    </up-popup>
   </view>
 </template>
 
 <script setup>
-import { reactive, ref, toRefs, watch } from "vue";
+import { computed, reactive, ref, toRefs } from "vue";
 import { onReachBottom, onShow } from "@dcloudio/uni-app";
 import PageHeader from "@/components/PageHeader.vue";
-import { getConsumablesOutRecordPage, delConsumablesOutRecord } from "@/api/consumablesLogistics/consumablesOutRecord.js";
-import { findAllQualifiedStockOutRecordTypeOptions, findAllUnQualifiedStockOutRecordTypeOptions } from "@/api/basicData/enum.js";
+import { getConsumablesOutRecordPage, delConsumablesOutRecord, editStockOut } from "@/api/consumablesLogistics/consumablesOutRecord.js";
+import { findAllQualifiedStockOutRecordTypeOptions } from "@/api/basicData/enum.js";
+import { checkPermi } from "@/utils/permission";
 
-const activeTab = ref("qualified");
+const hasCDispatchEdit = computed(() => checkPermi(["c_dispatch_edit"]));
+const hasCDispatchCancel = computed(() => checkPermi(["c_dispatch_cancel"]));
+
 const stockRecordTypeOptions = ref([]);
-const tabs = [
-  { label: "鍚堟牸鍑哄簱", name: "qualified", type: "0" },
-  { label: "涓嶅悎鏍煎嚭搴�", name: "unqualified", type: "1" },
-];
 const tableData = ref([]);
 const total = ref(0);
 const loadStatus = ref("loadmore");
 const page = reactive({ current: 1, size: 20 });
 const data = reactive({ searchForm: { productName: "" } });
 const { searchForm } = toRefs(data);
-
-const currentType = () => tabs.find((t) => t.name === activeTab.value)?.type || "0";
+const currentType = () => "0";
 
 function getRecordType(recordType) {
   if (recordType == null || recordType === "") return "";
@@ -90,11 +93,7 @@
 }
 
 function fetchRecordTypeOptions() {
-  const api =
-    currentType() === "1"
-      ? findAllUnQualifiedStockOutRecordTypeOptions
-      : findAllQualifiedStockOutRecordTypeOptions;
-  api()
+  findAllQualifiedStockOutRecordTypeOptions()
     .then((res) => {
       const list = res.data != null ? res.data : res;
       stockRecordTypeOptions.value = Array.isArray(list) ? list : [];
@@ -143,13 +142,6 @@
   getList();
 };
 
-watch(activeTab, () => {
-  page.current = 1;
-  loadStatus.value = "loadmore";
-  stockRecordTypeOptions.value = [];
-  getList();
-});
-
 const handleQuery = () => {
   page.current = 1;
   loadStatus.value = "loadmore";
@@ -163,7 +155,7 @@
       "dispatchDetailItem",
       JSON.stringify({
         item,
-        type: currentType(),
+        type: "0",
       })
     );
   } catch (e) {}
@@ -174,6 +166,7 @@
 
 const handleDeleteSingle = (item) => {
   if (!item?.id) return;
+  if (!hasCDispatchCancel.value) return;
   uni.showModal({
     title: "鍒犻櫎",
     content: "纭鍒犻櫎璇ユ潯鍑哄簱璁板綍锛�",
@@ -191,6 +184,45 @@
   });
 };
 
+// ---------------- 缂栬緫鍑哄簱 ----------------
+const showEditModal = ref(false);
+const editForm = reactive({
+  id: null,
+  qualitity: "",
+});
+
+const handleEdit = (row) => {
+  if (!hasCDispatchEdit.value) return;
+  editForm.id = row?.id ?? null;
+  editForm.qualitity = row?.qualitity ?? row?.stockOutNum ?? "";
+  showEditModal.value = true;
+};
+
+const handleEditSubmit = () => {
+  if (!hasCDispatchEdit.value) return;
+  const q = Number(editForm.qualitity);
+  if (!Number.isFinite(q) || q <= 0) {
+    uni.showToast({ title: "璇疯緭鍏ユ纭暟閲�", icon: "none" });
+    return;
+  }
+  uni.showLoading({ title: "淇濆瓨涓�...", mask: true });
+  editStockOut({
+    id: editForm.id,
+    qualitity: q,
+  })
+    .then(() => {
+      uni.showToast({ title: "缂栬緫鎴愬姛", icon: "success" });
+      showEditModal.value = false;
+      getList();
+    })
+    .catch(() => {
+      uni.showToast({ title: "缂栬緫澶辫触", icon: "none" });
+    })
+    .finally(() => {
+      uni.hideLoading();
+    });
+};
+
 const goBack = () => uni.navigateBack();
 onShow(() => getList());
 onReachBottom(() => loadMore());
@@ -198,9 +230,6 @@
 
 <style lang="scss" scoped>
 .dispatch-page { 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; margin: 24rpx; padding: 24rpx; border-radius: 16rpx; }
 .search-row { display: flex; align-items: center; }
 .search-input-wrap { flex: 1; margin-right: 20rpx; min-width: 0; }
@@ -216,8 +245,91 @@
 .card-body .l { color: #666; }
 .card-body .r { color: #333; }
 .card-body .r.highlight { color: #2979ff; font-weight: 500; }
-.card-actions { display: flex; justify-content: flex-end; margin-top: 12rpx; }
-.btn-delete { color: #f56c6c; font-size: 28rpx; }
+.card-actions {
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  margin-top: 16rpx;
+  padding-top: 16rpx;
+  border-top: 1rpx solid #eee;
+  width: 100%;
+  text-align: center;
+}
+.btn-edit {
+  color: #2979ff;
+  font-size: 28rpx;
+  padding: 12rpx 32rpx;
+  margin: 0 auto;
+  display: inline-flex;
+  align-items: center;
+  justify-content: center;
+}
+.btn-delete {
+  color: #f56c6c;
+  font-size: 28rpx;
+  padding: 12rpx 32rpx;
+  margin: 0 auto;
+  display: inline-flex;
+  align-items: center;
+  justify-content: center;
+}
+.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;
+}
+.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;
+}
+.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;
+}
 .no-data { text-align: center; padding: 60rpx 0; color: #999; font-size: 28rpx; }
 .load-more-wrap { padding: 24rpx 24rpx 8rpx; }
 </style>

--
Gitblit v1.9.3