spring
14 小时以前 ce92cb3a3645ca473798698522f477c8c2eb2e7f
fix: 仓储物流和耗材物流可编辑删除
已添加1个文件
已修改5个文件
464 ■■■■■ 文件已修改
src/api/consumablesLogistics/consumablesInRecord.js 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/consumablesLogistics/consumablesOutRecord.js 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/consumablesLogistics/dispatchLog/index.vue 157 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/consumablesLogistics/receiptManagement/Record.vue 104 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/consumablesLogistics/receiptManagement/index.vue 162 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/consumablesLogistics/receiptManagement/view.vue 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/consumablesLogistics/consumablesInRecord.js
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,29 @@
import request from '@/utils/request'
// è€—材入库管理-查询入库记录列表
export const getConsumablesInRecordListPage = (params) => {
  return request({
    url: '/consumablesInRecord/listPage',
    method: 'get',
    params
  })
}
// ç¼–辑耗材入库(仅用于台账编辑)
export const editStockInStock = (data) => {
  return request({
    url: '/consumablesInRecord/editStockInStock',
    method: 'post',
    data
  })
}
// æ‰¹é‡åˆ é™¤å…¥åº“记录
export const batchDeleteConsumablesInRecords = (ids) => {
  return request({
    url: '/consumablesInRecord',
    method: 'delete',
    data: ids
  })
}
src/api/consumablesLogistics/consumablesOutRecord.js
@@ -16,3 +16,12 @@
  });
};
// ç¼–辑耗材出库(仅用于台账编辑)
export const editStockOut = (data) => {
  return request({
    url: "/consumablesOutRecord/editStockOut",
    method: "post",
    data,
  });
};
src/pages/consumablesLogistics/dispatchLog/index.vue
@@ -35,7 +35,8 @@
            </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>
@@ -44,15 +45,42 @@
    <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>
          <view class="form-row">
            <text class="form-label required">采购员</text>
            <up-input v-model="editForm.purchaser" 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 } 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 { getConsumablesOutRecordPage, delConsumablesOutRecord, editStockOut } from "@/api/consumablesLogistics/consumablesOutRecord.js";
import { findAllQualifiedStockOutRecordTypeOptions } from "@/api/basicData/enum.js";
import { checkPermi } from "@/utils/permission";
const hasCDispatchEdit = computed(() => checkPermi(["c_dispatch_edit"]));
const hasCDispatchCancel = computed(() => checkPermi(["c_dispatch_cancel"]));
const stockRecordTypeOptions = ref([]);
const tableData = ref([]);
@@ -142,6 +170,7 @@
const handleDeleteSingle = (item) => {
  if (!item?.id) return;
  if (!hasCDispatchCancel.value) return;
  uni.showModal({
    title: "删除",
    content: "确认删除该条出库记录?",
@@ -157,6 +186,53 @@
        });
    },
  });
};
// ---------------- ç¼–辑出库 ----------------
const showEditModal = ref(false);
const editForm = reactive({
  id: null,
  qualitity: "",
  purchaser: "",
});
const handleEdit = (row) => {
  if (!hasCDispatchEdit.value) return;
  editForm.id = row?.id ?? null;
  editForm.qualitity = row?.qualitity ?? row?.stockOutNum ?? "";
  editForm.purchaser = row?.purchaser ?? "";
  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;
  }
  if (!editForm.purchaser) {
    uni.showToast({ title: "请输入采购员", icon: "none" });
    return;
  }
  uni.showLoading({ title: "保存中...", mask: true });
  editStockOut({
    id: editForm.id,
    qualitity: q,
    purchaser: editForm.purchaser,
  })
    .then(() => {
      uni.showToast({ title: "编辑成功", icon: "success" });
      showEditModal.value = false;
      getList();
    })
    .catch(() => {
      uni.showToast({ title: "编辑失败", icon: "none" });
    })
    .finally(() => {
      uni.hideLoading();
    });
};
const goBack = () => uni.navigateBack();
@@ -188,14 +264,83 @@
  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 36rpx;
  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;
  border: 1rpx solid rgba(245, 108, 108, 0.55);
  background: rgba(245, 108, 108, 0.08);
  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; }
src/pages/consumablesLogistics/receiptManagement/Record.vue
@@ -37,7 +37,12 @@
        <el-button type="primary" @click="handleQuery" style="margin-left: 10px">搜索</el-button>
      </div>
      <div>
        <el-button type="danger" plain @click="handleDelete">删除</el-button>
        <el-button
          v-if="hasCReceiptCancel"
          type="danger"
          plain
          @click="handleDelete"
        >删除</el-button>
      </div>
    </div>
@@ -56,11 +61,21 @@
        <el-table-column label="产品名称" prop="productName" min-width="160" show-overflow-tooltip />
        <el-table-column label="规格型号" prop="model" min-width="160" show-overflow-tooltip />
        <el-table-column label="单位" prop="unit" width="100" show-overflow-tooltip />
        <el-table-column label="入库数量" prop="stockInNum" width="110" show-overflow-tooltip />
        <el-table-column label="入库数量" prop="qualitity" width="110" show-overflow-tooltip />
        <el-table-column label="入库人" prop="createBy" width="120" show-overflow-tooltip />
        <el-table-column label="来源" prop="recordType" width="140" show-overflow-tooltip>
          <template #default="scope">
            {{ getRecordType(scope.row.recordType) }}
          </template>
        </el-table-column>
        <el-table-column label="操作" width="120" align="center">
          <template #default="scope">
            <el-button
              v-if="hasCReceiptEdit"
              type="primary"
              size="mini"
              @click="handleEdit(scope.row)"
            >编辑</el-button>
          </template>
        </el-table-column>
      </el-table>
@@ -73,20 +88,67 @@
        @pagination="paginationChange"
      />
    </div>
    <el-dialog
      v-model="isShowEditModal"
      title="编辑入库"
      width="600"
      @close="closeEditModal"
    >
      <el-form
        label-width="100px"
        :model="editForm"
        label-position="top"
        ref="editFormRef"
      >
        <el-form-item
          label="数量"
          prop="qualitity"
          :rules="[{ required: true, message: '请输入数量', trigger: ['blur', 'change'] }]"
        >
          <el-input-number
            v-model="editForm.qualitity"
            :min="0"
            :step="1"
            :precision="0"
            controls-position="right"
            style="width: 100%"
            placeholder="请输入数量"
          />
        </el-form-item>
        <el-form-item
          label="采购员"
          prop="purchaser"
          :rules="[{ required: true, message: '请输入采购员', trigger: ['blur', 'change'] }]"
        >
          <el-input v-model="editForm.purchaser" placeholder="请输入采购员" />
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="handleEditSubmit">确认</el-button>
          <el-button @click="closeEditModal">取消</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>
<script setup>
import { onMounted, reactive, ref, toRefs, watch } from "vue";
import { computed, onMounted, reactive, ref, toRefs, watch } from "vue";
import { ElMessage, ElMessageBox } from "element-plus";
import Pagination from "@/components/PIMTable/Pagination.vue";
import {
  batchDeleteConsumablesInRecords,
  getConsumablesInRecordListPage,
  editStockInStock,
} from "@/api/consumablesLogistics/consumablesInRecord.js";
import {
  findAllQualifiedStockInRecordTypeOptions,
} from "@/api/basicData/enum.js";
import { checkPermi } from "@/utils/permission.js";
const props = defineProps({
  type: {
@@ -95,6 +157,9 @@
    default: "0",
  },
});
const hasCReceiptEdit = computed(() => checkPermi(['c_receipt_edit']))
const hasCReceiptCancel = computed(() => checkPermi(['c_receipt_cancel']))
const tableData = ref([]);
const selectedRows = ref([]);
@@ -158,6 +223,7 @@
};
const handleDelete = () => {
  if (!hasCReceiptCancel.value) return
  const ids = selectedRows.value.map(i => i.id).filter(Boolean);
  if (ids.length === 0) {
    ElMessage.warning("请选择数据");
@@ -176,6 +242,38 @@
    .catch(() => {});
};
// ç¼–辑入库
const isShowEditModal = ref(false);
const editFormRef = ref(null);
const editForm = ref({});
const handleEdit = (row) => {
  if (!hasCReceiptEdit.value) return
  editForm.value = {
    id: row?.id,
    qualitity: row?.qualitity,
    purchaser: row?.purchaser,
  };
  isShowEditModal.value = true;
};
const closeEditModal = () => {
  isShowEditModal.value = false;
  editForm.value = {};
  editFormRef.value?.clearValidate?.();
};
const handleEditSubmit = () => {
  editFormRef.value?.validate?.((valid) => {
    if (!valid) return;
    editStockInStock(editForm.value).then(() => {
      closeEditModal();
      ElMessage.success("编辑成功");
      getList();
    });
  });
};
watch(
  () => props.type,
  () => {
src/pages/consumablesLogistics/receiptManagement/index.vue
@@ -28,14 +28,15 @@
            <view class="card-body">
              <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.stockInNum }}</text></view>
              <view class="row"><text class="l">入库数量</text><text class="r highlight">{{ item.qualitity ?? item.stockInNum }}</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>
          </view>
          <view class="card-actions">
            <view class="btn-delete" @click.stop="handleDeleteSingle(item)">删除</view>
            <view v-if="hasCReceiptEdit" class="btn-edit" @click.stop="handleEdit(item)">编辑</view>
            <view v-if="hasCReceiptCancel" class="btn-delete" @click.stop="handleDeleteSingle(item)">删除</view>
          </view>
        </view>
      </view>
@@ -44,15 +45,43 @@
    <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>
          <view class="form-row">
            <text class="form-label required">采购员</text>
            <up-input v-model="editForm.purchaser" 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 } from "vue";
import { computed, reactive, ref, toRefs } from "vue";
import { onReachBottom, onShow } from "@dcloudio/uni-app";
import PageHeader from "@/components/PageHeader.vue";
import request from "@/utils/request";
import { findAllQualifiedStockInRecordTypeOptions } from "@/api/basicData/enum.js";
import { checkPermi } from "@/utils/permission";
import { editStockInStock } from "@/api/consumablesLogistics/consumablesInRecord.js";
const hasCReceiptEdit = computed(() => checkPermi(['c_receipt_edit']))
const hasCReceiptCancel = computed(() => checkPermi(['c_receipt_cancel']))
const stockRecordTypeOptions = ref([]);
const tableData = ref([]);
@@ -146,6 +175,7 @@
const handleDeleteSingle = (item) => {
  if (!item?.id) return;
  if (!hasCReceiptCancel.value) return
  uni.showModal({
    title: "删除",
    content: "确认删除该条入库记录?",
@@ -166,6 +196,53 @@
    },
  });
};
// ---------------- ç¼–辑入库 ----------------
const showEditModal = ref(false)
const editForm = reactive({
  id: null,
  qualitity: '',
  purchaser: ''
})
const handleEdit = (row) => {
  if (!hasCReceiptEdit.value) return
  editForm.id = row?.id ?? null
  editForm.qualitity = row?.qualitity ?? row?.stockInNum ?? ''
  editForm.purchaser = row?.purchaser ?? ''
  showEditModal.value = true
}
const handleEditSubmit = () => {
  if (!hasCReceiptEdit.value) return
  const q = Number(editForm.qualitity)
  if (!Number.isFinite(q) || q <= 0) {
    uni.showToast({ title: "请输入正确数量", icon: "none" })
    return
  }
  if (!editForm.purchaser) {
    uni.showToast({ title: "请输入采购员", icon: "none" })
    return
  }
  uni.showLoading({ title: "保存中...", mask: true })
  editStockInStock({
    id: editForm.id,
    qualitity: q,
    purchaser: editForm.purchaser
  })
    .then(() => {
      uni.showToast({ title: "编辑成功", icon: "success" })
      showEditModal.value = false
      getList()
    })
    .catch(() => {
      uni.showToast({ title: "编辑失败", icon: "none" })
    })
    .finally(() => {
      uni.hideLoading()
    })
}
const goBack = () => uni.navigateBack();
@@ -201,14 +278,91 @@
  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;
  border-radius: 999rpx;
  border: 1rpx solid rgba(41, 121, 255, 0.25);
  background: rgba(41, 121, 255, 0.06);
  margin: 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-delete {
  color: #f56c6c;
  font-size: 28rpx;
  padding: 12rpx 36rpx;
  padding: 12rpx 32rpx;
  border-radius: 999rpx;
  border: 1rpx solid rgba(245, 108, 108, 0.55);
  background: rgba(245, 108, 108, 0.08);
  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; }
src/pages/consumablesLogistics/receiptManagement/view.vue
@@ -37,7 +37,7 @@
          </view>
          <view class="detail-row detail-row-highlight">
            <text class="label">入库数量</text>
            <text class="value value-num">{{ detail.stockInNum ?? '-' }}</text>
            <text class="value value-num">{{ detail.qualitity ?? detail.stockInNum ?? '-' }}</text>
          </view>
          <view class="detail-row">
            <text class="label">入库人</text>
@@ -89,6 +89,7 @@
    model: d.model,
    unit: d.unit,
    stockInNum: d.stockInNum,
    qualitity: d.qualitity,
    createBy: d.createBy,
    recordType: d.recordType,
    purchaser: d.purchaser,