zhangwencui
2026-05-16 9ce7f98f047f0f54fa93d69a2e3d8892d44c58dc
src/pages/qualityManagement/materialInspection/add.vue
@@ -114,11 +114,12 @@
                    border-bottom>
        <up-input v-model="form.checkTime"
                  placeholder="请选择检测日期"
                  readonly />
        <!-- <template #right>
          <up-icon name="calendar"
                  readonly
                  @click="showDatePicker" />
        <template #right>
          <up-icon name="arrow-right"
                   @click="showDatePicker"></up-icon>
        </template> -->
        </template>
      </up-form-item>
      <!-- <up-form-item label="采购订单号"
                    prop="purchaseContractNo"
@@ -191,11 +192,15 @@
      </up-button>
    </view>
    <!-- 日期选择器 -->
    <up-popup v-model:show="showDate"
              mode="date"
              :start-year="2020"
              :end-year="2030"
              @confirm="confirmDate" />
    <up-popup :show="showDate"
              mode="bottom"
              @close="showDate = false">
      <up-datetime-picker :show="true"
                          v-model="pickerValue"
                          @confirm="confirmDate"
                          @cancel="showDate = false"
                          mode="date" />
    </up-popup>
    <!-- 供应商选择 -->
    <up-action-sheet :show="showSupplierSheet"
                     :actions="supplierOptions"
@@ -309,7 +314,7 @@
<script setup>
  import { ref, computed, onMounted, nextTick } from "vue";
  import { onShow } from "@dcloudio/uni-app";
  import { onShow, onLoad } from "@dcloudio/uni-app";
  import PageHeader from "@/components/PageHeader.vue";
  import dayjs from "dayjs";
  import { getOptions } from "@/api/procurementManagement/procurementLedger.js";
@@ -337,6 +342,7 @@
  const loading = ref(false);
  // 日期选择器
  const showDate = ref(false);
  const pickerValue = ref(Date.now());
  // 供应商选择
  const showSupplierSheet = ref(false);
  // 产品选择
@@ -460,7 +466,7 @@
  // 是否为编辑模式
  const isEdit = computed(() => {
    const id = getPageId();
    const id = optionsId.value;
    return !!id;
  });
@@ -469,13 +475,6 @@
    const v = form.value || {};
    return !!(v.productMainId != null || v.purchaseLedgerId != null);
  });
  // 获取页面ID
  const getPageId = () => {
    const pages = getCurrentPages();
    const currentPage = pages[pages.length - 1];
    return currentPage.options.id;
  };
  // 返回上一页
  const goBack = () => {
@@ -490,6 +489,7 @@
  // 确认日期选择
  const confirmDate = e => {
    form.value.checkTime = dayjs(e.value).format("YYYY-MM-DD");
    showDate.value = false;
  };
  // 选择供应商
@@ -712,7 +712,7 @@
      loading.value = true;
      form.value.inspectType = 0;
      if (isEdit.value) {
      if (!isEdit.value) {
        tableData.value.forEach(item => {
          delete item.id;
        });
@@ -743,7 +743,7 @@
  // 初始化表单
  const initForm = async () => {
    const id = getPageId();
    const id = optionsId.value;
    if (id) {
      // 编辑模式,加载数据
      // 先重置表单数据
@@ -896,6 +896,12 @@
  onShow(() => {
    initForm();
  });
  const optionsId = ref("");
  onLoad(options => {
    optionsId.value = options.id || "";
    initForm();
  });
</script>
<style scoped lang="scss">