zhangwencui
16 小时以前 58243a2254afce0cc0fcc7e31f927b9c94a80687
销售台账新增交货日期和生产状态管理功能
已修改4个文件
148 ■■■■■ 文件已修改
src/pages/sales/salesAccount/detail.vue 110 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/sales/salesAccount/index.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/sales/salesAccount/out.vue 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/sales/salesAccount/view.vue 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/sales/salesAccount/detail.vue
@@ -58,6 +58,18 @@
                   @click="showDatePicker = true"></up-icon>
        </template>
      </up-form-item>
      <up-form-item label="交货日期"
                    prop="deliveryDate"
                    required>
        <up-input v-model="form.deliveryDate"
                  readonly
                  placeholder="点击选择时间"
                  @click="showDeliveryDatePicker = true" />
        <template #right>
          <up-icon name="arrow-right"
                   @click="showDeliveryDatePicker = true"></up-icon>
        </template>
      </up-form-item>
      <up-form-item label="付款方式"
                    prop="paymentMethod">
        <up-input v-model="form.paymentMethod"
@@ -89,6 +101,15 @@
                            v-model="pickerDateValue"
                            @confirm="onDateConfirm"
                            @cancel="showDatePicker = false"
                            mode="date" />
      </up-popup>
      <up-popup :show="showDeliveryDatePicker"
                mode="bottom"
                @close="showDeliveryDatePicker = false">
        <up-datetime-picker :show="true"
                            v-model="deliveryDateValue"
                            @confirm="onDeliveryDateConfirm"
                            @cancel="showDeliveryDatePicker = false"
                            mode="date" />
      </up-popup>
      <!-- 客户选择 -->
@@ -219,6 +240,23 @@
              <up-input v-model="product.unit"
                        placeholder="请输入" />
            </up-form-item>
            <up-form-item label="是否生产"
                          prop="isProduction"
                          required>
              <u-radio-group v-model="product.isProduction"
                             :disabled="operationType === 'view'"
                             placement="row">
                <u-radio :customStyle="{ marginRight: '40rpx' }"
                         :disabled="operationType === 'view'"
                         :name="true"
                         label="是">
                </u-radio>
                <u-radio :disabled="operationType === 'view'"
                         :name="false"
                         label="否">
                </u-radio>
              </u-radio-group>
            </up-form-item>
            <!-- 税率 -->
            <up-form-item label="税率(%)"
                          prop="taxRate"
@@ -323,6 +361,7 @@
    customerName: "",
    projectName: "",
    executionDate: "",
    deliveryDate: "",
    paymentMethod: "",
    entryPerson: "",
    entryPersonName: "",
@@ -331,6 +370,8 @@
  const showPicker = ref(false);
  const showDatePicker = ref(false);
  const pickerDateValue = ref(Date.now());
  const showDeliveryDatePicker = ref(false);
  const deliveryDateValue = ref(Date.now());
  const showCustomerPicker = ref(false);
  const userList = ref([]);
  const customerOption = ref([]);
@@ -448,6 +489,9 @@
    executionDate: [
      { required: true, message: "请选择签订日期", trigger: "change" },
    ],
    deliveryDate: [
      { required: true, message: "请选择交货日期", trigger: "change" },
    ],
  };
  const addProduct = () => {
@@ -459,6 +503,7 @@
      specificationModel: "",
      productModelId: "",
      unit: "",
      isProduction: true,
      speculativeTradingName: "",
      taxRate: "",
      taxInclusiveUnitPrice: "",
@@ -479,6 +524,11 @@
    // 保持pickerDateValue为时间戳格式,而不是格式化的字符串
    pickerDateValue.value = e.value;
    showDatePicker.value = false;
  };
  const onDeliveryDateConfirm = e => {
    form.value.deliveryDate = formatDateToYMD(e.value);
    deliveryDateValue.value = e.value;
    showDeliveryDatePicker.value = false;
  };
  // 客户选择事件
@@ -756,6 +806,23 @@
        });
        return;
      }
      const rawIsProduction = product.isProduction;
      const normalizedIsProduction =
        rawIsProduction === true || rawIsProduction === false
          ? rawIsProduction
          : rawIsProduction === 1 || rawIsProduction === 0
          ? Boolean(rawIsProduction)
          : rawIsProduction === "1" || rawIsProduction === "0"
          ? rawIsProduction === "1"
          : null;
      if (normalizedIsProduction === null) {
        uni.showToast({
          title: `产品${i + 1}:请选择是否生产`,
          icon: "none",
        });
        return;
      }
      product.isProduction = normalizedIsProduction;
      if (!product.taxRate) {
        uni.showToast({
          title: `产品${i + 1}:请选择税率`,
@@ -815,19 +882,34 @@
    form.value.entryPerson = userStore.id;
    form.value.entryPersonName = userStore.nickName;
    // 设置当天日期
    const today = new Date();
    const year = today.getFullYear();
    const month = String(today.getMonth() + 1).padStart(2, "0");
    const day = String(today.getDate()).padStart(2, "0");
    form.value.entryDate = `${year}-${month}-${day}`;
    // 设置日期选择器默认值为今天
    pickerDateValue.value = `${year}-${month}-${day}`;
    const now = new Date();
    const year = now.getFullYear();
    const month = String(now.getMonth() + 1).padStart(2, "0");
    const day = String(now.getDate()).padStart(2, "0");
    const todayStr = `${year}-${month}-${day}`;
    form.value.entryDate = todayStr;
    form.value.executionDate = todayStr;
    form.value.deliveryDate = todayStr;
    pickerDateValue.value = now.getTime();
    deliveryDateValue.value = now.getTime();
  };
  // 填充表单数据(编辑模式)
  const fillFormData = () => {
    if (!editData.value) return;
    getSalesLedgerWithProducts({ id: editData.value.id, type: 1 }).then(res => {
      productData.value = res.productData;
      const list = Array.isArray(res?.productData) ? res.productData : [];
      productData.value = list.map(item => {
        const raw = item?.isProduction;
        const normalized =
          raw === true || raw === false
            ? raw
            : raw === 1 || raw === 0
            ? Boolean(raw)
            : raw === "1" || raw === "0"
            ? raw === "1"
            : true;
        return { ...item, isProduction: normalized };
      });
    });
    console.log(editData.value);
    // 填充基本信息
@@ -835,6 +917,7 @@
    form.value.customerName = editData.value.customerName || "";
    form.value.projectName = editData.value.projectName || "";
    form.value.executionDate = editData.value.executionDate || "";
    form.value.deliveryDate = editData.value.deliveryDate || "";
    form.value.paymentMethod = editData.value.paymentMethod || "";
    form.value.salesman = editData.value.salesman || "";
    form.value.entryPerson = editData.value.entryPerson || "";
@@ -845,7 +928,16 @@
    // 设置日期选择器的值
    if (editData.value.executionDate) {
      pickerDateValue.value = editData.value.executionDate;
      const ts = new Date(
        String(editData.value.executionDate).replace(/-/g, "/")
      ).getTime();
      pickerDateValue.value = Number.isFinite(ts) ? ts : Date.now();
    }
    if (editData.value.deliveryDate) {
      const ts = new Date(
        String(editData.value.deliveryDate).replace(/-/g, "/")
      ).getTime();
      deliveryDateValue.value = Number.isFinite(ts) ? ts : Date.now();
    }
  };
  const getUserList = () => {
src/pages/sales/salesAccount/index.vue
@@ -66,6 +66,10 @@
              <text class="detail-label">签订日期</text>
              <text class="detail-value">{{ item.executionDate }}</text>
            </view>
            <view class="detail-row">
              <text class="detail-label">交货日期</text>
              <text class="detail-value">{{ item.deliveryDate || "-" }}</text>
            </view>
            <up-divider></up-divider>
            <view class="detail-info">
              <view class="detail-row">
src/pages/sales/salesAccount/out.vue
@@ -56,6 +56,11 @@
                  class="detail-value danger">不足</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">是否生产</text>
            <u-tag size="mini"
                   :type="getIsProductionType(item)">{{ getIsProductionText(item) }}</u-tag>
          </view>
          <view class="detail-row">
            <text class="detail-label">发货状态</text>
            <u-tag size="mini"
                   :type="getShippingStatusType(item)">{{ getShippingStatusText(item) }}</u-tag>
@@ -186,6 +191,20 @@
    };
    return statusTextMap[statusStr] || "待发货";
  };
  const getIsProductionText = row => {
    const v = row?.isProduction;
    if (v === true || v === 1 || v === "1") return "是";
    if (v === false || v === 0 || v === "0") return "否";
    return "-";
  };
  const getIsProductionType = row => {
    const v = row?.isProduction;
    if (v === true || v === 1 || v === "1") return "success";
    if (v === false || v === 0 || v === "0") return "info";
    return "info";
  };
  // 获取页面参数
  const getPageParams = () => {
    // 从本地存储获取供应商ID
src/pages/sales/salesAccount/view.vue
@@ -28,6 +28,10 @@
          <text class="info-value">{{ form.executionDate }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">交货日期</text>
          <text class="info-value">{{ form.deliveryDate || '-' }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">付款方式</text>
          <text class="info-value">{{ form.paymentMethod }}</text>
        </view>
@@ -74,6 +78,10 @@
            <view class="info-item">
              <text class="info-label">单位</text>
              <text class="info-value">{{ product.unit }}</text>
            </view>
            <view class="info-item">
              <text class="info-label">是否生产</text>
              <text class="info-value">{{ formatIsProduction(product.isProduction) }}</text>
            </view>
            <view class="info-item">
              <text class="info-label">税率(%)</text>
@@ -125,6 +133,7 @@
    customerName: "",
    projectName: "",
    executionDate: "",
    deliveryDate: "",
    paymentMethod: "",
    entryPerson: "",
    entryPersonName: "",
@@ -153,6 +162,12 @@
    });
  };
  const formatIsProduction = value => {
    if (value === true || value === 1 || value === "1") return "是";
    if (value === false || value === 0 || value === "0") return "否";
    return "-";
  };
  onMounted(() => {
    // 获取编辑数据并填充表单
    const editDataStr = uni.getStorageSync("editData");