| | |
| | | <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(); |
| | |
| | | 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> |