zhangwencui
2 天以前 a7f3fb7074f42904628deb4fc1697787a02e3a01
付款登记重构
已修改3个文件
483 ■■■■ 文件已修改
src/api/procurementManagement/procurementInvoiceLedger.js 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/procurementManagement/paymentEntry/add.vue 296 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/procurementManagement/paymentEntry/index.vue 165 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/procurementManagement/procurementInvoiceLedger.js
@@ -59,13 +59,13 @@
}
// 查询列表
export function invoiceListPage(query) {
  return request({
    url: "/purchase/registration/listPage",
    method: "get",
    params: query,
  });
}
// export function invoiceListPage(query) {
//   return request({
//     url: "/purchase/registration/listPage",
//     method: "get",
//     params: query,
//   });
// }
export function productRecordPage(query) {
  return request({
@@ -123,3 +123,11 @@
    data: query,
  });
}
// 查询列表
export function invoiceListPage(query) {
  return request({
    url: "/sales/product/listPagePurchaseLedger",
    method: "get",
    params: query,
  });
}
src/pages/procurementManagement/paymentEntry/add.vue
@@ -1,265 +1,261 @@
<template>
  <view class="account-detail">
    <!-- 使用通用页面头部组件 -->
    <PageHeader title="新增付款" @back="onClickLeft" />
    <PageHeader title="新增付款"
                @back="onClickLeft" />
    <!-- 表单内容 -->
    <u-form @submit="onSubmit" ref="formRef" label-width="110" input-align="right" error-message-align="right">
    <u-form @submit="onSubmit"
            ref="formRef"
            label-width="110"
            input-align="right"
            error-message-align="right">
      <!-- 基本信息 -->
      <u-cell-group title="基本信息" class="form-section">
        <u-form-item label="采购合同号" class="form-item">
          <u-input
            v-model="form.purchaseContractNumber"
      <u-cell-group title="基本信息"
                    class="form-section">
        <u-form-item label="采购合同号"
                     class="form-item">
          <u-input v-model="form.purchaseContractNumber"
            placeholder="自动填充"
            readonly
          />
                   readonly />
        </u-form-item>
        <u-form-item label="销售合同号" class="form-item">
          <u-input
            v-model="form.salesContractNo"
        <u-form-item label="销售合同号"
                     class="form-item">
          <u-input v-model="form.salesContractNo"
            placeholder="自动填充"
            readonly
          />
                   readonly />
        </u-form-item>
        <u-form-item label="供应商名称" class="form-item">
          <u-input
            v-model="form.supplierName"
        <u-form-item label="供应商名称"
                     class="form-item">
          <u-input v-model="form.supplierName"
            placeholder="自动填充"
            readonly
          />
                   readonly />
        </u-form-item>
        <u-form-item label="发票号" class="form-item">
        <!-- <u-form-item label="发票号" class="form-item">
          <u-input
            v-model="form.invoiceNumber"
            placeholder="自动填充"
            readonly
          />
        </u-form-item>
        <u-form-item label="发票金额(元)" class="form-item">
        </u-form-item> -->
        <!-- <u-form-item label="发票金额(元)" class="form-item">
          <u-input
            v-model="form.invoiceAmount"
            placeholder="自动填充"
            readonly
          />
        </u-form-item>
        </u-form-item> -->
        <view class="tip-text">待付款金额:{{ currentNoReceiptAmount }} 元</view>
        <u-form-item label="本次付款金额" prop="currentPaymentAmount" required class="form-item">
          <u-input
            v-model="form.currentPaymentAmount"
        <u-form-item label="本次付款金额"
                     prop="currentPaymentAmount"
                     required
                     class="form-item">
          <u-input v-model="form.currentPaymentAmount"
            type="number"
            placeholder="请输入"
            @blur="changeNum"
            clearable
          />
                   clearable />
        </u-form-item>
        <u-form-item label="付款形式" prop="paymentMethod" required class="form-item">
          <u-input
            v-model="form.paymentMethod"
        <u-form-item label="付款形式"
                     prop="paymentMethod"
                     required
                     class="form-item">
          <u-input v-model="form.paymentMethod"
            placeholder="请选择"
            readonly
            @click="showPaymentTypePicker"
          />
                   @click="showPaymentTypePicker" />
          <template #right>
                    <up-icon
                        name="arrow-right"
                        @click="showPaymentTypePicker"
                    ></up-icon>
            <up-icon name="arrow-right"
                     @click="showPaymentTypePicker"></up-icon>
                </template>
        </u-form-item>
        <u-form-item label="付款日期" prop="paymentDate" required class="form-item">
          <u-input
            v-model="form.paymentDate"
        <u-form-item label="付款日期"
                     prop="paymentDate"
                     required
                     class="form-item">
          <u-input v-model="form.paymentDate"
            placeholder="请选择"
            readonly
            @click="showDatePicker"
          />
                   @click="showDatePicker" />
          <template #right>
                    <up-icon
                        name="arrow-right"
                        @click="showDatePicker"
                    ></up-icon>
            <up-icon name="arrow-right"
                     @click="showDatePicker"></up-icon>
                </template>
        </u-form-item>
        <u-form-item label="登记人" class="form-item">
          <u-input
            v-model="form.registrant"
        <u-form-item label="登记人"
                     class="form-item">
          <u-input v-model="form.registrant"
            placeholder="自动填充"
            readonly
          />
                   readonly />
        </u-form-item>
        <u-form-item label="登记日期" prop="registrationtDate" required class="form-item">
          <u-input
            v-model="form.registrationtDate"
        <u-form-item label="登记日期"
                     prop="registrationtDate"
                     required
                     class="form-item">
          <u-input v-model="form.registrationtDate"
            placeholder="请选择"
            readonly
          />
                   readonly />
        </u-form-item>
      </u-cell-group>
      <!-- 提交按钮 -->
      <FooterButtons
        :loading="loading"
      <FooterButtons :loading="loading"
        @cancel="onClickLeft"
        @confirm="onSubmit"
      />
                     @confirm="onSubmit" />
    </u-form>
    <!-- 付款方式选择器 -->
    <up-action-sheet
      :show="showPaymentType"
    <up-action-sheet :show="showPaymentType"
      title="选择付款方式"
      :actions="receipt_payment_type"
      @select="onPaymentTypeConfirm"
      @close="showPaymentType = false"
    />
                     @close="showPaymentType = false" />
    <!-- 日期选择器 -->
     <up-datetime-picker
                    :show="showDate"
    <up-datetime-picker :show="showDate"
                    v-model="form.paymentDate"
                    @confirm="onDateConfirm"
                    @cancel="showDate = false"
                    mode="date"
                />
                        mode="date" />
  </view>
</template>
<script setup>
import { ref, onMounted, computed } from 'vue'
import FooterButtons from '@/components/FooterButtons.vue'
import useUserStore from '@/store/modules/user'
import { useDict } from '@/utils/dict'
  import { ref, onMounted, computed } from "vue";
  import FooterButtons from "@/components/FooterButtons.vue";
  import useUserStore from "@/store/modules/user";
  import { useDict } from "@/utils/dict";
import {paymentRegistrationAdd} from "@/api/procurementManagement/paymentEntry";
import { formatDateToYMD } from '@/utils/ruoyi'
  import { formatDateToYMD } from "@/utils/ruoyi";
// 替换 toast 和 notify 方法
const showToast = (message) => {
  const showToast = message => {
  uni.showToast({
    title: message,
    icon: 'none'
  })
}
      icon: "none",
    });
  };
const showNotify = ({ type, message }) => {
  uni.showToast({
    title: message,
    icon: type === 'warning' ? 'none' : 'success'
  })
}
      icon: type === "warning" ? "none" : "success",
    });
  };
const userStore = useUserStore()
  const userStore = useUserStore();
// 表单引用
const formRef = ref()
  const formRef = ref();
// 响应式数据
const loading = ref(false)
const showPaymentType = ref(false)
const showDate = ref(false)
  const loading = ref(false);
  const showPaymentType = ref(false);
  const showDate = ref(false);
// 表单数据
const form = ref({
    purchaseContractNumber: '',
  salesContractNo: '',
  supplierName: '',
  invoiceNumber: '',
  invoiceAmount: '',
  taxRate: '',
  currentPaymentAmount: '',
  receiptPaymentType: '',
    paymentMethod: '',
  registrant: '',
    paymentDate: '',
    registrationtDate: '',
  ticketRegistrationId: ''
})
const currentNoReceiptAmount = ref(0)
    purchaseContractNumber: "",
    salesContractNo: "",
    supplierName: "",
    invoiceNumber: "",
    invoiceAmount: "",
    taxRate: "",
    currentPaymentAmount: "",
    receiptPaymentType: "",
    paymentMethod: "",
    registrant: "",
    paymentDate: "",
    registrationtDate: "",
    ticketRegistrationId: "",
  });
  const currentNoReceiptAmount = ref(0);
// 获取字典数据
const { receipt_payment_type: dictReceiptPaymentType } = useDict('receipt_payment_type')
  const { receipt_payment_type: dictReceiptPaymentType } = useDict(
    "receipt_payment_type"
  );
// 转换字典数据格式为选择器需要的格式
const receipt_payment_type = computed(() => {
  return dictReceiptPaymentType.value.map(item => ({
    name: item.label,
    value: item.value
  }))
})
      value: item.value,
    }));
  });
// 返回上一页
const onClickLeft = () => {
    uni.removeStorageSync('invoiceLedgerEditRow');
    uni.navigateBack()
}
    uni.removeStorageSync("invoiceLedgerEditRow");
    uni.navigateBack();
  };
// 显示付款方式选择器
const showPaymentTypePicker = () => {
  showPaymentType.value = true
}
    showPaymentType.value = true;
  };
const changeNum = () => {
    if (form.value.currentPaymentAmount > currentNoReceiptAmount.value) {
        form.value.currentPaymentAmount = currentNoReceiptAmount.value
        showToast('不可大于待付款金额')
      form.value.currentPaymentAmount = currentNoReceiptAmount.value;
      showToast("不可大于待付款金额");
    }
}
  };
// 确认付款方式选择
const onPaymentTypeConfirm = (item) => {
  form.value.receiptPaymentType = item.value
  form.value.paymentMethod = item.name
  showPaymentType.value = false
}
  const onPaymentTypeConfirm = item => {
    form.value.receiptPaymentType = item.value;
    form.value.paymentMethod = item.name;
    showPaymentType.value = false;
  };
// 显示日期选择器
const showDatePicker = () => {
  showDate.value = true
}
    showDate.value = true;
  };
// 确认日期选择
const onDateConfirm = (e) => {
  form.value.paymentDate = formatDateToYMD(e.value)
  showDate.value = false
}
  const onDateConfirm = e => {
    form.value.paymentDate = formatDateToYMD(e.value);
    showDate.value = false;
  };
// 提交表单
const onSubmit = () => {
  // 表单验证
  if (!form.value.currentPaymentAmount) {
    showNotify({ type: 'warning', message: '请输入付款金额' })
    return
      showNotify({ type: "warning", message: "请输入付款金额" });
      return;
  }
  if (!form.value.receiptPaymentType) {
    showNotify({ type: 'warning', message: '请选择付款形式' })
    return
      showNotify({ type: "warning", message: "请选择付款形式" });
      return;
  }
  if (!form.value.paymentDate) {
    showNotify({ type: 'warning', message: '请选择付款日期' })
    return
      showNotify({ type: "warning", message: "请选择付款日期" });
      return;
  }
  loading.value = true
    loading.value = true;
    paymentRegistrationAdd(form.value)
    .then(() => {
      showToast('提交成功')
            onClickLeft()
        showToast("提交成功");
        onClickLeft();
    })
    .catch((error) => {
            loading.value = false
    })
}
      .catch(error => {
        loading.value = false;
      });
  };
// 初始化数据
const initData = () => {
    const rowStr = uni.getStorageSync('invoiceLedgerEditRow')
    const row = JSON.parse(rowStr)
    const rowStr = uni.getStorageSync("invoiceLedgerEditRow");
    const row = JSON.parse(rowStr);
    form.value = { ...row };
    form.value.ticketRegistrationId = row.id;
    form.value.id = null;
    form.value.id = "";
    currentNoReceiptAmount.value = row.unPaymentAmountTotal
    form.value.registrant = userStore.nickName
    currentNoReceiptAmount.value = row.pendingTicketsTotal
      ? parseFloat(row.pendingTicketsTotal).toFixed(2)
      : "0";
    form.value.registrant = userStore.nickName;
    form.value.registrationtDate = getCurrentDate();
    form.value.paymentDate = getCurrentDate();
}
  };
// 获取当前日期并格式化为 YYYY-MM-DD
function getCurrentDate() {
    const today = new Date();
@@ -269,10 +265,16 @@
    return `${year}-${month}-${day}`;
}
onMounted(() => {
  initData()
})
    initData();
  });
</script>
<style scoped lang="scss">
@import '@/static/scss/form-common.scss';
  @import "@/static/scss/form-common.scss";
  .tip-text {
    font-size: 16px;
    color: #383838;
    margin-top: 10px;
    margin-bottom: 10px;
  }
</style>
src/pages/procurementManagement/paymentEntry/index.vue
@@ -1,44 +1,51 @@
<template>
    <view class="sales-account">
        <!-- 使用通用页面头部组件 -->
        <PageHeader title="付款登记" @back="goBack" />
    <PageHeader title="付款登记"
                @back="goBack" />
        <!-- 搜索和筛选区域 -->
        <view class="search-section">
            <view class="search-bar">
                <view class="search-input">
                    <up-input
                        class="search-text"
          <up-input class="search-text"
                        placeholder="请输入供应商名称/合同号搜索"
                        v-model="searchForm.supplierNameOrContractNo"
                        @change="getList"
                        clearable
                    />
                    clearable />
                </view>
                <view class="filter-button" @click="getList">
                    <up-icon name="search" size="24" color="#999"></up-icon>
        <view class="filter-button"
              @click="getList">
          <up-icon name="search"
                   size="24"
                   color="#999"></up-icon>
                </view>
            </view>
            <!-- 筛选开关 -->
            <view class="switch-row">
                <text class="switch-label">不显示待付款为0</text>
                <u-switch v-model="searchForm.status" @change="getList" active-color="#2979ff" inactive-color="#e5e5e5"/>
        <u-switch v-model="searchForm.status"
                  @change="getList"
                  active-color="#2979ff"
                  inactive-color="#e5e5e5" />
            </view>
        </view>
        <!-- 列表区域 -->
        <view class="ledger-list" v-if="tableData.length > 0">
            <view v-for="(item, index) in tableData" :key="index">
    <view class="ledger-list"
          v-if="tableData.length > 0">
      <view v-for="(item, index) in tableData"
            :key="index">
                <view class="ledger-item">
                    <view class="item-header">
                        <view class="item-left">
                            <view class="document-icon">
                                <up-icon name="file-text" size="16" color="#ffffff"></up-icon>
                <up-icon name="file-text"
                         size="16"
                         color="#ffffff"></up-icon>
                            </view>
                            <text class="item-id">{{ item.purchaseContractNumber }}</text>
            </view>
            <view class="item-tag">
              <u-tag :type="getTagClass(item.statusName)">{{ item.statusName || '--' }}</u-tag>
                        </view>
                    </view>
                    <up-divider></up-divider>
@@ -56,103 +63,123 @@
                            <text class="detail-value">{{ item.invoiceNumber }}</text>
                        </view>
                        <view class="detail-row">
                            <text class="detail-label">发票金额(元)</text>
                            <text class="detail-value">{{ item.invoiceAmount }}</text>
              <text class="detail-label">产品大类</text>
              <text class="detail-value">{{ item.productCategory }}</text>
                        </view>
                        <view class="detail-row">
              <text class="detail-label">规格型号</text>
              <text class="detail-value">{{ item.specificationModel }}</text>
            </view>
            <!-- <view class="detail-row">
              <text class="detail-label">发票金额(元)</text>
              <text class="detail-value">{{ item.invoiceAmount }}</text>
            </view> -->
            <view class="detail-row">
                            <text class="detail-label">已付款金额(元)</text>
                            <text class="detail-value">{{ item.paymentAmountTotal || '-' }}</text>
              <text class="detail-value">{{ item.ticketsTotal ? parseFloat(item.ticketsTotal).toFixed(2) : '0' }}</text>
                        </view>
                        <view class="detail-row">
                            <text class="detail-label">待付款金额(元)</text>
                            <text class="detail-value highlight">{{ formatNumber(item.unPaymentAmountTotal) }}</text>
              <text class="detail-value highlight">{{ item.pendingTicketsTotal ? parseFloat(item.pendingTicketsTotal).toFixed(2) : '0' }}</text>
                        </view>
                    </view>
                    <!-- 操作按钮 -->
                    <view class="action-buttons">
                        <u-button
                            type="primary"
            <u-button type="primary"
                            size="small"
                            class="action-btn"
                            :disabled="item.unPaymentAmountTotal == 0"
                            @click="openForm('add', item)"
                        >
                      @click="openForm('add', item)">
                            新增付款
                        </u-button>
                    </view>
                </view>
            </view>
        </view>
        <!-- 无数据提示 -->
        <view class="no-data" v-else>
    <view class="no-data"
          v-else>
            <text>暂无付款数据</text>
        </view>
    </view>
</template>
<script setup>
import { ref } from 'vue'
import useUserStore from '@/store/modules/user'
  import { ref } from "vue";
  import useUserStore from "@/store/modules/user";
// 替换 toast 方法
const showToast = (message) => {
  const showToast = message => {
  uni.showToast({
    title: message,
    icon: 'none'
  })
}
      icon: "none",
    });
  };
import {onShow} from "@dcloudio/uni-app";
import {invoiceListPage} from "@/api/procurementManagement/procurementInvoiceLedger";
// 响应式数据
const tableData = ref([])
const tableLoading = ref(false)
  const tableData = ref([]);
  const tableLoading = ref(false);
// 查询参数设置为-1获取全部数据
const page = ref({
    current: -1,
    size: -1
})
    size: -1,
  });
// 搜索表单
const searchForm = ref({
    supplierNameOrContractNo: '',
    supplierNameOrContractNo: "",
    status: true,
    customerName: '',
    customerContractNo: '',
    projectName: ''
})
// 格式化数字
const formatNumber = (value) => {
    return parseFloat(value || 0).toFixed(2)
    customerName: "",
    customerContractNo: "",
    projectName: "",
  });
  // 获取标签样式类
  const getTagClass = type => {
    if (!type) {
      return "info";
}
    if (type == "未完成付款") {
      return "warning";
    } else if (type == "已完成付款") {
      return "success";
    } else {
      return "info";
    }
  };
  // 格式化数字
  const formatNumber = value => {
    return parseFloat(value || 0).toFixed(2);
  };
// 返回上一页
const goBack = () => {
    uni.navigateBack()
}
    uni.navigateBack();
  };
// 获取列表数据
const getList = () => {
    showLoadingToast('加载中...')
    tableLoading.value = true
    invoiceListPage({ ...searchForm.value, ...page.value }).then((res) => {
        tableLoading.value = false
        tableData.value = res.records || []
        closeToast()
    }).catch(() => {
        tableLoading.value = false
        closeToast()
    showLoadingToast("加载中...");
    tableLoading.value = true;
    invoiceListPage({ ...searchForm.value, ...page.value })
      .then(res => {
        console.log(res.data);
        tableLoading.value = false;
        tableData.value = res.data.records || [];
        closeToast();
    })
}
      .catch(() => {
        tableLoading.value = false;
        closeToast();
      });
  };
// 显示加载提示
const showLoadingToast = (message) => {
  const showLoadingToast = message => {
    uni.showLoading({
        title: message,
        mask: true
      mask: true,
    });
};
@@ -164,21 +191,21 @@
// 打开新增表单
const openForm = (type, item) => {
    if (item.unPaymentAmountTotal == 0) {
        showToast('无需再付款')
        return
      showToast("无需再付款");
      return;
    }
    uni.setStorageSync('operationType', type);
    uni.setStorageSync('invoiceLedgerEditRow', JSON.stringify(item))
    uni.navigateTo({ url: '/pages/procurementManagement/paymentEntry/add' })
}
    uni.setStorageSync("operationType", type);
    uni.setStorageSync("invoiceLedgerEditRow", JSON.stringify(item));
    uni.navigateTo({ url: "/pages/procurementManagement/paymentEntry/add" });
  };
onShow(() => {
    getList()
})
    getList();
  });
</script>
<style scoped lang="scss">
@import '@/styles/procurement-common.scss';
  @import "@/styles/procurement-common.scss";
// 付款登记特有样式
.detail-value {