| | |
| | | <PageHeader title="台账详情" @back="goBack" /> |
| | | |
| | | <!-- 表单区域 --> |
| | | <van-form @submit="onSubmit" label-width="110px" input-align="right" style="margin-top: 10px" error-message-align="right" scroll-to-error scroll-to-error-position="center"> |
| | | <van-field label="采购合同号" name="purchaseContractNumber" borderBottom="true" v-model="form.purchaseContractNumber" placeholder="自动生成" :rules="[{ required: true, message: '请输入' }]"> |
| | | </van-field> |
| | | <van-field |
| | | v-model="form.salesContractNo" |
| | | is-link |
| | | readonly |
| | | name="salesContractNo" |
| | | label="销售合同号" |
| | | required |
| | | placeholder="点击选择销售合同号" |
| | | :rules="[{ required: true, message: '请选择销售合同号' }]" |
| | | @click="showPicker = true" |
| | | /> |
| | | <van-field |
| | | v-model="form.supplierName" |
| | | is-link |
| | | readonly |
| | | required |
| | | name="supplierName" |
| | | label="供应商名称" |
| | | placeholder="点击选择供应商" |
| | | :rules="[{ required: true, message: '请选择供应商' }]" |
| | | @click="showCustomerPicker = true" |
| | | /> |
| | | <van-field label="项目名称" name="projectName" borderBottom="true" v-model="form.projectName" placeholder="请输入项目名称" :rules="[{ required: true, message: '项目名称不能为空' }]" required> |
| | | </van-field> |
| | | <van-field label="付款方式" name="paymentMethod" borderBottom="true" v-model="form.paymentMethod" placeholder="请输入付款方式"> |
| | | </van-field> |
| | | <van-field label="录入人" name="recorderName" borderBottom="true" v-model="form.recorderName" placeholder="请输入" disabled> |
| | | </van-field> |
| | | <van-field label="录入日期" name="entryDate" borderBottom="true" v-model="form.entryDate" placeholder="请输入" disabled> |
| | | </van-field> |
| | | <van-popup v-model:show="showPicker" destroy-on-close position="bottom"> |
| | | <van-picker |
| | | :columns="salesContractList" |
| | | v-model="pickerValue" |
| | | @confirm="onConfirm" |
| | | @cancel="showPicker = false" |
| | | <up-form @submit="onSubmit" label-width="110" ref="formRef" :rules="rules" :model="form"> |
| | | <up-form-item label="采购合同号" prop="purchaseContractNumber"> |
| | | <up-input v-model="form.purchaseContractNumber" placeholder="自动生成" disabled /> |
| | | </up-form-item> |
| | | <up-form-item |
| | | label="销售合同号" |
| | | prop="salesContractNo" |
| | | required |
| | | @click="showPicker = true" |
| | | > |
| | | <up-input |
| | | v-model="form.salesContractNo" |
| | | readonly="" |
| | | @click="showPicker = true" |
| | | placeholder="点击选择销售合同号" |
| | | /> |
| | | <template #right> |
| | | <up-icon |
| | | name="arrow-right" |
| | | @click="showPicker = true" |
| | | ></up-icon> |
| | | </template> |
| | | </up-form-item> |
| | | <up-form-item |
| | | label="供应商名称" |
| | | prop="supplierName" |
| | | required |
| | | @click="showCustomerPicker = true" |
| | | > |
| | | <up-input |
| | | v-model="form.supplierName" |
| | | readonly="" |
| | | @click="showCustomerPicker = true" |
| | | placeholder="点击选择供应商" |
| | | /> |
| | | <template #right> |
| | | <up-icon |
| | | name="arrow-right" |
| | | @click="showCustomerPicker = true" |
| | | ></up-icon> |
| | | </template> |
| | | </up-form-item> |
| | | <up-form-item label="项目名称" prop="projectName" required > |
| | | <up-input |
| | | v-model="form.projectName" |
| | | placeholder="请输入项目名称" |
| | | /> |
| | | </up-form-item> |
| | | <up-form-item label="付款方式" prop="paymentMethod" > |
| | | <up-input v-model="form.paymentMethod" placeholder="请输入付款方式" /> |
| | | </up-form-item> |
| | | <up-form-item label="录入人" prop="recorderName" > |
| | | <up-input v-model="form.recorderName" placeholder="请输入" disabled /> |
| | | </up-form-item> |
| | | <up-form-item label="录入日期" prop="entryDate" > |
| | | <up-input v-model="form.entryDate" placeholder="请输入" disabled /> |
| | | </up-form-item> |
| | | |
| | | <!-- 销售合同号选择 --> |
| | | <up-action-sheet |
| | | :show="showPicker" |
| | | :actions="salesContractActionList" |
| | | title="选择销售合同号" |
| | | @select="onSalesmanSelect" |
| | | @close="showPicker = false" |
| | | /> |
| | | </van-popup> |
| | | <van-popup v-model:show="showCustomerPicker" destroy-on-close position="bottom"> |
| | | <van-picker |
| | | :columns="supplierList" |
| | | v-model="pickerCustomerValue" |
| | | @confirm="onCustomerConfirm" |
| | | @cancel="showCustomerPicker = false" |
| | | |
| | | <!-- 供应商选择 --> |
| | | <up-action-sheet |
| | | :show="showCustomerPicker" |
| | | :actions="supplierActionList" |
| | | title="选择供应商" |
| | | @select="onCustomerSelect" |
| | | @close="showCustomerPicker = false" |
| | | /> |
| | | </van-popup> |
| | | |
| | | <!-- 产品大类选择器 --> |
| | | <van-popup v-model:show="showCategoryPicker" destroy-on-close position="bottom"> |
| | | <!-- 头部按钮区域 --> |
| | | <view class="popup-header"> |
| | | <view @click="showCategoryPicker = false" class="cancelButton">取消</view> |
| | | <view @click="confirmCategorySelection" class="confirmButton">确定</view> |
| | | </view> |
| | | <up-tree |
| | | :data="productOptions" |
| | | :props="defaultProps" |
| | | show-checkbox |
| | | default-expand-all |
| | | check-strictly |
| | | @check-change="onCategoryConfirm" |
| | | |
| | | <!-- 产品大类选择器 --> |
| | | <up-popup :show="showCategoryPicker" mode="bottom"> |
| | | <!-- 头部按钮区域 --> |
| | | <view class="popup-header"> |
| | | <view @click="showCategoryPicker = false" class="cancelButton">取消</view> |
| | | <view @click="confirmCategorySelection" class="confirmButton">确定</view> |
| | | </view> |
| | | <u-tree |
| | | :data="productOptions" |
| | | :props="defaultProps" |
| | | show-checkbox |
| | | default-expand-all |
| | | check-strictly |
| | | @check-change="onCategoryConfirm" |
| | | /> |
| | | </up-popup> |
| | | |
| | | <!-- 规格型号选择器 --> |
| | | <up-action-sheet |
| | | :show="showSpecificationPicker" |
| | | :actions="specificationActionList" |
| | | title="选择规格型号" |
| | | @select="onSpecificationSelect" |
| | | @close="showSpecificationPicker = false" |
| | | /> |
| | | </van-popup> |
| | | |
| | | <!-- 规格型号选择器 --> |
| | | <van-popup v-model:show="showSpecificationPicker" destroy-on-close position="bottom"> |
| | | <van-picker |
| | | :columns="modelOptions" |
| | | v-model="pickerSpecificationValue" |
| | | @confirm="onSpecificationConfirm" |
| | | @cancel="showSpecificationPicker = false" |
| | | |
| | | <!-- 税率选择器 --> |
| | | <up-action-sheet |
| | | :show="showTaxRatePicker" |
| | | :actions="taxRateActionList" |
| | | title="选择税率" |
| | | @select="onTaxRateSelect" |
| | | @close="showTaxRatePicker = false" |
| | | /> |
| | | </van-popup> |
| | | |
| | | <!-- 税率选择器 --> |
| | | <van-popup v-model:show="showTaxRatePicker" destroy-on-close position="bottom"> |
| | | <van-picker |
| | | :columns="taxRateOptions" |
| | | v-model="pickerTaxRateValue" |
| | | @confirm="onTaxRateConfirm" |
| | | @cancel="showTaxRatePicker = false" |
| | | |
| | | <!-- 发票类型选择器 --> |
| | | <up-action-sheet |
| | | :show="showInvoiceTypePicker" |
| | | :actions="invoiceTypeActionList" |
| | | title="选择发票类型" |
| | | @select="onInvoiceTypeSelect" |
| | | @close="showInvoiceTypePicker = false" |
| | | /> |
| | | </van-popup> |
| | | |
| | | <!-- 发票类型选择器 --> |
| | | <van-popup v-model:show="showInvoiceTypePicker" destroy-on-close position="bottom"> |
| | | <van-picker |
| | | :columns="invoiceTypeOptions" |
| | | v-model="pickerInvoiceTypeValue" |
| | | @confirm="onInvoiceTypeConfirm" |
| | | @cancel="showInvoiceTypePicker = false" |
| | | /> |
| | | </van-popup> |
| | | <!-- 产品信息 --> |
| | | <view class="product-section"> |
| | | <view class="section-header"> |
| | | <text class="section-title">产品信息</text> |
| | | <van-button type="primary" size="small" @click="addProduct" class="add-btn" icon="plus" v-if="operationType !== 'view'">新增</van-button> |
| | | </view> |
| | | <view class="product-card" v-for="(product, idx) in productData" :key="idx"> |
| | | <!-- 产品类 --> |
| | | <view class="product-header"> |
| | | <view class="product-title"> |
| | | <van-icon name="description" color="#2979ff" size="15" /> |
| | | <text class="product-productCategory">产品 {{ idx + 1 }}</text> |
| | | <!-- 产品信息 --> |
| | | <view class="product-section"> |
| | | <view class="section-header"> |
| | | <view> |
| | | <text class="section-title">产品信息</text> |
| | | </view> |
| | | <!-- 操作按钮 --> |
| | | <view class="product-actions" v-if="operationType !== 'view'"> |
| | | <van-button type="danger" size="mini" @click="removeProduct(idx)" class="del-btn" icon="delete">删除</van-button> |
| | | <view> |
| | | <up-button type="primary" size="small" @click="addProduct" class="add-btn" v-if="operationType !== 'view'"> |
| | | 新增 |
| | | </up-button> |
| | | </view> |
| | | </view> |
| | | |
| | | <!-- 产品信息表单 --> |
| | | <view class="product-form"> |
| | | <!-- 产品大类 --> |
| | | <van-field |
| | | v-model="product.productCategory" |
| | | is-link |
| | | readonly |
| | | name="productCategory" |
| | | label="产品大类" |
| | | required |
| | | placeholder="请选择" |
| | | :rules="[{ required: true, message: '请选择' }]" |
| | | @click="openCategoryPicker(idx)" |
| | | /> |
| | | <view class="product-card" v-for="(product, idx) in productData" :key="idx"> |
| | | <!-- 产品类 --> |
| | | <view class="product-header"> |
| | | <view class="product-title"> |
| | | <up-icon name="file-text" size="16" color="#2979ff"></up-icon> |
| | | <text class="product-productCategory">产品 {{ idx + 1 }}</text> |
| | | </view> |
| | | <!-- 操作按钮 --> |
| | | <view class="product-actions" v-if="operationType !== 'view'"> |
| | | <up-button type="error" size="mini" @click="removeProduct(idx)" class="del-btn"> |
| | | 删除 |
| | | </up-button> |
| | | </view> |
| | | </view> |
| | | |
| | | <!-- 规格型号 --> |
| | | <van-field |
| | | v-model="product.specificationModel" |
| | | is-link |
| | | readonly |
| | | name="specificationModel" |
| | | label="规格型号" |
| | | required |
| | | :rules="[{ required: true, message: '请选择' }]" |
| | | placeholder="请选择" |
| | | @click="openSpecificationPicker(idx)" |
| | | /> |
| | | |
| | | <!-- 单位 --> |
| | | <van-field |
| | | v-model="product.unit" |
| | | name="unit" |
| | | label="单位" |
| | | required |
| | | :rules="[{ required: true, message: '请输入' }]" |
| | | placeholder="请输入" |
| | | /> |
| | | |
| | | <!-- 税率 --> |
| | | <van-field |
| | | v-model="product.taxRate" |
| | | is-link |
| | | readonly |
| | | name="taxRate" |
| | | label="税率(%)" |
| | | required |
| | | :rules="[{ required: true, message: '请选择' }]" |
| | | placeholder="请选择" |
| | | @click="openTaxRatePicker(idx)" |
| | | /> |
| | | |
| | | <!-- 含税单价 --> |
| | | <van-field |
| | | v-model="product.taxInclusiveUnitPrice" |
| | | name="taxInclusiveUnitPrice" |
| | | label="含税单价(元)" |
| | | type="number" |
| | | required |
| | | :rules="[{ required: true, message: '请输入' }]" |
| | | placeholder="请输入" |
| | | @blur="formatTaxPrice(idx)" |
| | | /> |
| | | |
| | | <!-- 数量 --> |
| | | <van-field |
| | | v-model="product.quantity" |
| | | name="quantity" |
| | | label="数量" |
| | | type="number" |
| | | :rules="[{ required: true, message: '请输入' }]" |
| | | required |
| | | placeholder="请输入" |
| | | @blur="formatAmount(idx)" |
| | | /> |
| | | |
| | | <!-- 含税总价 --> |
| | | <van-field |
| | | v-model="product.taxInclusiveTotalPrice" |
| | | name="taxInclusiveTotalPrice" |
| | | label="含税总价(元)" |
| | | type="number" |
| | | :rules="[{ required: true, message: '请输入' }]" |
| | | required |
| | | placeholder="请输入" |
| | | @blur="formatTaxTotal(idx)" |
| | | /> |
| | | |
| | | <!-- 不含税总价 --> |
| | | <van-field |
| | | v-model="product.taxExclusiveTotalPrice" |
| | | name="taxExclusiveTotalPrice" |
| | | label="不含税总价(元)" |
| | | type="number" |
| | | required |
| | | :rules="[{ required: true, message: '请输入' }]" |
| | | placeholder="请输入" |
| | | @blur="formatNoTaxTotal(idx)" |
| | | /> |
| | | |
| | | <!-- 发票类型 --> |
| | | <van-field |
| | | v-model="product.invoiceType" |
| | | is-link |
| | | readonly |
| | | name="invoiceType" |
| | | label="发票类型" |
| | | :rules="[{ required: true, message: '请选择' }]" |
| | | required |
| | | placeholder="请选择" |
| | | @click="openInvoiceTypePicker(idx)" |
| | | /> |
| | | <!-- 产品信息表单 --> |
| | | <view class="product-form"> |
| | | <!-- 产品大类 --> |
| | | <up-form-item |
| | | label="产品大类" |
| | | prop="productCategory" |
| | | required |
| | | :rules="productRules" |
| | | > |
| | | <up-input |
| | | v-model="product.productCategory" |
| | | readonly |
| | | placeholder="请选择" |
| | | @click="openCategoryPicker(idx)" |
| | | /> |
| | | <template #right> |
| | | <up-icon |
| | | name="arrow-right" |
| | | @click="showCategoryPicker = true" |
| | | ></up-icon> |
| | | </template> |
| | | </up-form-item> |
| | | |
| | | <!-- 规格型号 --> |
| | | <up-form-item |
| | | label="规格型号" |
| | | prop="specificationModel" |
| | | required |
| | | :rules="productRules" |
| | | > |
| | | <up-input |
| | | v-model="product.specificationModel" |
| | | readonly |
| | | placeholder="请选择" |
| | | @click="openSpecificationPicker(idx)" |
| | | /> |
| | | <template #right> |
| | | <up-icon |
| | | name="arrow-right" |
| | | @click="showSpecificationPicker = true" |
| | | ></up-icon> |
| | | </template> |
| | | </up-form-item> |
| | | |
| | | <!-- 单位 --> |
| | | <up-form-item |
| | | label="单位" |
| | | prop="unit" |
| | | required |
| | | :rules="productRules" |
| | | > |
| | | <up-input |
| | | v-model="product.unit" |
| | | placeholder="请输入" |
| | | /> |
| | | </up-form-item> |
| | | |
| | | <!-- 税率 --> |
| | | <up-form-item |
| | | label="税率(%)" |
| | | prop="taxRate" |
| | | required |
| | | :rules="productRules" |
| | | > |
| | | <up-input |
| | | v-model="product.taxRate" |
| | | readonly |
| | | placeholder="请选择" |
| | | @click="openTaxRatePicker(idx)" |
| | | /> |
| | | <template #right> |
| | | <up-icon |
| | | name="arrow-right" |
| | | @click="showTaxRatePicker = true" |
| | | ></up-icon> |
| | | </template> |
| | | </up-form-item> |
| | | |
| | | <!-- 含税单价 --> |
| | | <up-form-item |
| | | label="含税单价(元)" |
| | | prop="taxInclusiveUnitPrice" |
| | | required |
| | | :rules="productRules" |
| | | > |
| | | <up-input |
| | | v-model="product.taxInclusiveUnitPrice" |
| | | type="number" |
| | | placeholder="请输入" |
| | | @blur="formatTaxPrice(idx)" |
| | | /> |
| | | </up-form-item> |
| | | |
| | | <!-- 数量 --> |
| | | <up-form-item |
| | | label="数量" |
| | | prop="quantity" |
| | | required |
| | | :rules="productRules" |
| | | > |
| | | <up-input |
| | | v-model="product.quantity" |
| | | type="number" |
| | | placeholder="请输入" |
| | | @blur="formatAmount(idx)" |
| | | /> |
| | | </up-form-item> |
| | | |
| | | <!-- 含税总价 --> |
| | | <up-form-item |
| | | label="含税总价(元)" |
| | | prop="taxInclusiveTotalPrice" |
| | | required |
| | | :rules="productRules" |
| | | > |
| | | <up-input |
| | | v-model="product.taxInclusiveTotalPrice" |
| | | type="number" |
| | | placeholder="请输入" |
| | | @blur="formatTaxTotal(idx)" |
| | | /> |
| | | </up-form-item> |
| | | |
| | | <!-- 不含税总价 --> |
| | | <up-form-item |
| | | label="不含税总价(元)" |
| | | prop="taxExclusiveTotalPrice" |
| | | required |
| | | :rules="productRules" |
| | | > |
| | | <up-input |
| | | v-model="product.taxExclusiveTotalPrice" |
| | | type="number" |
| | | placeholder="请输入" |
| | | @blur="formatNoTaxTotal(idx)" |
| | | /> |
| | | </up-form-item> |
| | | |
| | | <!-- 发票类型 --> |
| | | <up-form-item |
| | | label="发票类型" |
| | | prop="invoiceType" |
| | | required |
| | | :rules="productRules" |
| | | > |
| | | <up-input |
| | | v-model="product.invoiceType" |
| | | readonly |
| | | placeholder="请选择" |
| | | @click="openInvoiceTypePicker(idx)" |
| | | /> |
| | | <template #right> |
| | | <up-icon |
| | | name="arrow-right" |
| | | @click="showInvoiceTypePicker = true" |
| | | ></up-icon> |
| | | </template> |
| | | </up-form-item> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | <view class="footer-btns" v-if="operationType !== 'view'"> |
| | | <van-button class="cancel-btn" @click="goBack">取消</van-button> |
| | | <van-button class="save-btn" native-type="submit" form-type="submit">保存</van-button> |
| | | </view> |
| | | </van-form> |
| | | |
| | | <!-- 使用公共底部按钮组件 --> |
| | | <FooterButtons |
| | | :show="operationType !== 'view'" |
| | | cancelText="取消" |
| | | confirmText="保存" |
| | | @cancel="goBack" |
| | | @confirm="onSubmit" |
| | | /> |
| | | </up-form> |
| | | </view> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import {onMounted, ref} from 'vue'; |
| | | import {onMounted, ref, computed} from 'vue'; |
| | | import { modelList, productTreeList } from "@/api/basicData/product.js"; |
| | | import useUserStore from "@/store/modules/user"; |
| | | import {calculateTaxExclusiveTotalPrice} from "@/utils/summarizeTable"; |
| | | import {formatDateToYMD} from '@/utils/ruoyi' |
| | | import { |
| | | addOrEditPurchase, createPurchaseNo, |
| | | getOptions, |
| | | getPurchaseById, |
| | | getSalesNo |
| | | } from "@/api/procurementManagement/procurementLedger"; |
| | | import PageHeader from '@/components/PageHeader.vue'; |
| | | import FooterButtons from '@/components/FooterButtons.vue'; |
| | | |
| | | // 获取页面参数 |
| | | const operationType = ref(''); |
| | | const editData = ref(null); |
| | | const formRef = ref(null); |
| | | |
| | | const userStore = useUserStore() |
| | | const form = ref({ |
| | |
| | | recorderName: '', |
| | | entryDate: '', |
| | | }); |
| | | const pickerValue = ref(['']); |
| | | const pickerDateValue = ref([]); |
| | | const showPicker = ref(false); |
| | | const pickerCustomerValue = ref(['']); |
| | | const showCustomerPicker = ref(false); |
| | | const salesContractList = ref([]); |
| | | const supplierList = ref([]); |
| | | const productData = ref([]); |
| | | |
| | | // 计算销售合同号选择列表 |
| | | const salesContractActionList = computed(() => { |
| | | return salesContractList.value.map(item => ({ |
| | | name: item.text, |
| | | value: item.value |
| | | })) |
| | | }) |
| | | |
| | | // 计算供应商选择列表 |
| | | const supplierActionList = computed(() => { |
| | | return supplierList.value.map(item => ({ |
| | | name: item.text, |
| | | value: item.value |
| | | })) |
| | | }) |
| | | |
| | | // 选择器相关变量 |
| | | const showCategoryPicker = ref(false); |
| | | const showSpecificationPicker = ref(false); |
| | | const showTaxRatePicker = ref(false); |
| | | const showInvoiceTypePicker = ref(false); |
| | | const pickerSpecificationValue = ref(['']); |
| | | const pickerTaxRateValue = ref(['']); |
| | | const pickerInvoiceTypeValue = ref(['']); |
| | | const currentProductIndex = ref(0); |
| | | |
| | | // 选项数据 |
| | |
| | | }); |
| | | |
| | | const modelOptions = ref([]); |
| | | // 防止循环计算的标志 |
| | | const taxRateOptions = ref([ |
| | | { text: '1', value: '1' }, |
| | | { text: '6', value: '6' }, |
| | |
| | | { text: '增普票', value: '增普票' }, |
| | | { text: '增专票', value: '增专票' }, |
| | | ]); |
| | | |
| | | // 计算规格型号选择列表 |
| | | const specificationActionList = computed(() => { |
| | | return modelOptions.value.map(model => ({ |
| | | name: model.text, |
| | | value: model.value, |
| | | unit: model.unit |
| | | })) |
| | | }) |
| | | |
| | | // 计算税率选择列表 |
| | | const taxRateActionList = computed(() => { |
| | | return taxRateOptions.value.map(rate => ({ |
| | | name: rate.text, |
| | | value: rate.value |
| | | })) |
| | | }) |
| | | |
| | | // 计算发票类型选择列表 |
| | | const invoiceTypeActionList = computed(() => { |
| | | return invoiceTypeOptions.value.map(type => ({ |
| | | name: type.text, |
| | | value: type.value |
| | | })) |
| | | }) |
| | | |
| | | // 表单校验规则 |
| | | const rules = { |
| | | salesContractNo: [ |
| | | { required: true, message: '请选择销售合同号', trigger: 'blur' } |
| | | ], |
| | | supplierName: [ |
| | | { required: true, message: '请选择供应商名称', trigger: 'blur' } |
| | | ], |
| | | projectName: [ |
| | | { required: true, message: '请输入项目名称', trigger: 'blur' } |
| | | ] |
| | | }; |
| | | |
| | | // 产品信息校验规则 |
| | | const productRules = { |
| | | productCategory: [ |
| | | { required: true, message: '请选择产品大类', trigger: 'blur' } |
| | | ], |
| | | specificationModel: [ |
| | | { required: true, message: '请选择规格型号', trigger: 'blur' } |
| | | ], |
| | | unit: [ |
| | | { required: true, message: '请输入单位', trigger: 'blur' } |
| | | ], |
| | | taxRate: [ |
| | | { required: true, message: '请选择税率', trigger: 'blur' } |
| | | ], |
| | | taxInclusiveUnitPrice: [ |
| | | { required: true, message: '请输入含税单价', trigger: 'blur' }, |
| | | { type: 'number', min: 0, message: '含税单价必须大于0', trigger: 'blur' } |
| | | ], |
| | | quantity: [ |
| | | { required: true, message: '请输入数量', trigger: 'blur' }, |
| | | { type: 'number', min: 0, message: '数量必须大于0', trigger: 'blur' } |
| | | ], |
| | | taxInclusiveTotalPrice: [ |
| | | { required: true, message: '请输入含税总价', trigger: 'blur' }, |
| | | { type: 'number', min: 0, message: '含税总价必须大于0', trigger: 'blur' } |
| | | ], |
| | | taxExclusiveTotalPrice: [ |
| | | { required: true, message: '请输入不含税总价', trigger: 'blur' }, |
| | | { type: 'number', min: 0, message: '不含税总价必须大于0', trigger: 'blur' } |
| | | ], |
| | | invoiceType: [ |
| | | { required: true, message: '请选择发票类型', trigger: 'blur' } |
| | | ] |
| | | }; |
| | | |
| | | const addProduct = () => { |
| | | if (productData.value === null) { |
| | |
| | | invoiceType: '' |
| | | }); |
| | | }; |
| | | const onConfirm = ({ selectedValues, selectedOptions }) => { |
| | | form.value.salesContractNo = selectedOptions[0]?.text; |
| | | form.value.salesLedgerId = selectedOptions[0]?.value; |
| | | pickerValue.value = [selectedValues[0]]; |
| | | |
| | | // 销售合同号选择事件 |
| | | const onSalesmanSelect = (item) => { |
| | | form.value.salesContractNo = item.name |
| | | // 查找对应的id |
| | | const selectedItem = salesContractList.value.find(contract => contract.text === item.name); |
| | | if (selectedItem) { |
| | | form.value.salesLedgerId = selectedItem.value; |
| | | } |
| | | showPicker.value = false; |
| | | }; |
| | | const onCustomerConfirm = ({ selectedValues, selectedOptions }) => { |
| | | form.value.supplierName = selectedOptions[0]?.text; |
| | | form.value.supplierId = selectedOptions[0]?.value; |
| | | pickerCustomerValue.value = [selectedValues[0]]; |
| | | } |
| | | |
| | | // 供应商选择事件 |
| | | const onCustomerSelect = (item) => { |
| | | form.value.supplierName = item.name |
| | | // 查找对应的id |
| | | const selectedItem = supplierList.value.find(supplier => supplier.text === item.name); |
| | | if (selectedItem) { |
| | | form.value.supplierId = selectedItem.value; |
| | | } |
| | | showCustomerPicker.value = false; |
| | | }; |
| | | } |
| | | |
| | | const removeProduct = (idx) => { |
| | | productData.value.splice(idx, 1); |
| | | }; |
| | |
| | | selectedCategoryNode.value = null; |
| | | productData.value[currentProductIndex.value].specificationModel = '' |
| | | productData.value[currentProductIndex.value].productModelId = '' |
| | | productData.value[currentProductIndex.value].pickerSpecificationValue = [''] |
| | | getModels(id) |
| | | } |
| | | showCategoryPicker.value = false; |
| | | }; |
| | | |
| | | // 获取规格型号 |
| | | const getModels = (value) => { |
| | | modelList({ id: value }).then((res) => { |
| | |
| | | })); |
| | | }); |
| | | }; |
| | | // 选择规格型号 |
| | | const onSpecificationConfirm = ({ selectedValues, selectedOptions }) => { |
| | | productData.value[currentProductIndex.value].specificationModel = selectedOptions[0]?.text; |
| | | productData.value[currentProductIndex.value].productModelId = selectedOptions[0]?.value; |
| | | productData.value[currentProductIndex.value].unit = selectedOptions[0]?.unit; |
| | | pickerSpecificationValue.value = [selectedValues[0]]; |
| | | showSpecificationPicker.value = false; |
| | | }; |
| | | // 选择税率 |
| | | const onTaxRateConfirm = ({ selectedValues, selectedOptions }) => { |
| | | productData.value[currentProductIndex.value].taxRate = selectedOptions[0]?.value; |
| | | pickerTaxRateValue.value = [selectedValues[0]]; |
| | | showTaxRatePicker.value = false; |
| | | // if (isCalculating.value) return; |
| | | const inclusiveTotalPrice = parseFloat(productData.value[currentProductIndex.value].taxInclusiveTotalPrice); |
| | | const taxRate = parseFloat(productData.value[currentProductIndex.value].taxRate); |
| | | if (!inclusiveTotalPrice || !taxRate) { |
| | | return; |
| | | } |
| | | // isCalculating.value = true; |
| | | // 计算不含税总价 |
| | | productData.value[currentProductIndex.value].taxExclusiveTotalPrice = |
| | | calculateTaxExclusiveTotalPrice( |
| | | inclusiveTotalPrice, |
| | | taxRate |
| | | ); |
| | | // isCalculating.value = false; |
| | | |
| | | // 规格型号选择事件 |
| | | const onSpecificationSelect = (item) => { |
| | | productData.value[currentProductIndex.value].specificationModel = item.name |
| | | productData.value[currentProductIndex.value].productModelId = item.value |
| | | productData.value[currentProductIndex.value].unit = item.unit |
| | | showSpecificationPicker.value = false; |
| | | }; |
| | | |
| | | const onInvoiceTypeConfirm = ({ selectedValues, selectedOptions }) => { |
| | | productData.value[currentProductIndex.value].invoiceType = selectedOptions[0]?.text; |
| | | pickerInvoiceTypeValue.value = [selectedValues[0]]; |
| | | showInvoiceTypePicker.value = false; |
| | | // 税率选择事件 |
| | | const onTaxRateSelect = (item) => { |
| | | productData.value[currentProductIndex.value].taxRate = item.value |
| | | showTaxRatePicker.value = false; |
| | | // 重新计算不含税总价 |
| | | const inclusiveTotalPrice = parseFloat(productData.value[currentProductIndex.value].taxInclusiveTotalPrice) |
| | | const taxRate = parseFloat(item.value) |
| | | if (inclusiveTotalPrice && taxRate) { |
| | | productData.value[currentProductIndex.value].taxExclusiveTotalPrice = |
| | | calculateTaxExclusiveTotalPrice(inclusiveTotalPrice, taxRate) |
| | | } |
| | | }; |
| | | |
| | | // 发票类型选择事件 |
| | | const onInvoiceTypeSelect = (item) => { |
| | | productData.value[currentProductIndex.value].invoiceType = item.name |
| | | showInvoiceTypePicker.value = false; |
| | | }; |
| | | |
| | | // 格式化函数 - 固定两位小数 |
| | |
| | | |
| | | // 如果有税率,计算不含税总价 |
| | | if (productData.value[currentProductIndex.value].taxRate) { |
| | | productData.value[currentProductIndex.value].taxExclusiveTotalPrice = |
| | | productData.value[currentProductIndex.value].taxExclusiveTotalPrice = |
| | | calculateTaxExclusiveTotalPrice( |
| | | productData.value[currentProductIndex.value].taxInclusiveTotalPrice, |
| | | productData.value[currentProductIndex.value].taxRate |
| | | ); |
| | | } |
| | | }; |
| | | |
| | | // 数量输入框失焦 |
| | | const formatAmount = (idx) => { |
| | | if (productData.value[idx].quantity) { |
| | |
| | | productData.value[currentProductIndex.value].taxInclusiveTotalPrice = (unitPrice * quantity).toFixed(2); |
| | | // 如果有税率,计算不含税总价 |
| | | if (productData.value[currentProductIndex.value].taxRate) { |
| | | productData.value[currentProductIndex.value].taxExclusiveTotalPrice = |
| | | productData.value[currentProductIndex.value].taxExclusiveTotalPrice = |
| | | calculateTaxExclusiveTotalPrice( |
| | | productData.value[currentProductIndex.value].taxInclusiveTotalPrice, |
| | | productData.value[currentProductIndex.value].taxRate |
| | | ); |
| | | } |
| | | }; |
| | | |
| | | // 含税总价失焦,根据含税总价计算含税单价和数量 |
| | | const formatTaxTotal = (idx) => { |
| | | if (productData.value[idx].taxInclusiveTotalPrice) { |
| | |
| | | productData.value[currentProductIndex.value].taxInclusiveUnitPrice = (totalPrice / quantity).toFixed(2); |
| | | // 如果有税率,计算不含税总价 |
| | | if (productData.value[currentProductIndex.value].taxRate) { |
| | | productData.value[currentProductIndex.value].taxExclusiveTotalPrice = |
| | | productData.value[currentProductIndex.value].taxExclusiveTotalPrice = |
| | | calculateTaxExclusiveTotalPrice( |
| | | totalPrice, |
| | | productData.value[currentProductIndex.value].taxRate |
| | | ); |
| | | } |
| | | }; |
| | | |
| | | // 不含税总价失焦, 根据不含税总价计算含税单价和数量 |
| | | const formatNoTaxTotal = (idx) => { |
| | | if (productData.value[idx].taxExclusiveTotalPrice) { |
| | |
| | | // 计算含税单价 = 含税总价 / 数量 |
| | | productData.value[currentProductIndex.value].taxInclusiveUnitPrice = (inclusiveTotalPrice / quantity).toFixed(2); |
| | | }; |
| | | |
| | | const goBack = () => { |
| | | // 清理本地存储的数据 |
| | | uni.removeStorageSync('operationType'); |
| | | uni.removeStorageSync('editData'); |
| | | uni.navigateBack(); |
| | | }; |
| | | |
| | | const onSubmit = () => { |
| | | if (productData.value !== null && productData.value.length > 0) { |
| | | form.value.productData = JSON.parse(JSON.stringify(productData.value)); |
| | |
| | | goBack(); |
| | | }); |
| | | }; |
| | | |
| | | const setUserInfo = () => { |
| | | form.value.recorderId = userStore.id; |
| | | form.value.recorderName = userStore.nickName; |
| | |
| | | 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.toString(), month.toString(), day.toString()] |
| | | } |
| | | }; |
| | | |
| | | // 填充表单数据(编辑模式) |
| | | const fillFormData = () => { |
| | | if (!editData.value) return; |
| | |
| | | form.value.salesContractNo = editData.value.salesContractNo || ''; |
| | | form.value.supplierName = editData.value.supplierName || ''; |
| | | form.value.projectName = editData.value.projectName || ''; |
| | | form.value.executionDate = editData.value.executionDate || ''; |
| | | form.value.paymentMethod = editData.value.paymentMethod || ''; |
| | | form.value.salesLedgerId = editData.value.salesLedgerId || ''; |
| | | form.value.recorderId = editData.value.recorderId || ''; |
| | |
| | | form.value.entryDate = editData.value.entryDate || ''; |
| | | form.value.id = editData.value.id || ''; |
| | | form.value.supplierId = editData.value.supplierId || ''; |
| | | |
| | | // 设置销售合同号选择器的值 |
| | | if (editData.value.salesContractNo) { |
| | | const salesmanIndex = salesContractList.value.findIndex(user => user.text === editData.value.salesContractNo); |
| | | if (salesmanIndex !== -1) { |
| | | pickerValue.value = [salesContractList.value[salesmanIndex].value]; |
| | | } |
| | | } |
| | | |
| | | // 设置供应商选择器的值 |
| | | if (editData.value.supplierName) { |
| | | const customerIndex = supplierList.value.findIndex(customer => customer.text === editData.value.supplierName); |
| | | if (customerIndex !== -1) { |
| | | pickerCustomerValue.value = [supplierList.value[customerIndex].value] |
| | | } |
| | | } |
| | | |
| | | // 设置日期选择器的值 |
| | | if (editData.value.executionDate) { |
| | | pickerDateValue.value = editData.value.executionDate.split('-').map(num => parseInt(num, 10)) |
| | | console.log(pickerDateValue.value) |
| | | } |
| | | }; |
| | | |
| | | const getSalesNoList = () => { |
| | | getSalesNo().then((res) => { |
| | | // 将用户数据组装成 picker 需要的格式 |
| | |
| | | value: user.id |
| | | })); |
| | | }) |
| | | } |
| | | }; |
| | | |
| | | const getOptionsLIst = () => { |
| | | getOptions().then((res) => { |
| | | // 将用户数据组装成 picker 需要的格式 |
| | |
| | | value: item.id |
| | | })); |
| | | }) |
| | | } |
| | | }; |
| | | |
| | | const convertIdToValue = (data) => { |
| | | // 如果传入的不是数组,则返回空数组 |
| | | if (!Array.isArray(data)) { |
| | |
| | | return mappedItem; |
| | | }); |
| | | }; |
| | | |
| | | // 获取产品大类tree数据 |
| | | const getProductOptions = () => { |
| | | productTreeList().then((res) => { |
| | | productOptions.value = convertIdToValue(res); |
| | | }); |
| | | }; |
| | | |
| | | onMounted(() => { |
| | | // 获取页面参数 |
| | | operationType.value = uni.getStorageSync('operationType') || ''; |
| | |
| | | </script> |
| | | |
| | | <style scoped lang="scss"> |
| | | .account-detail { |
| | | min-height: 100vh; |
| | | background: #f8f9fa; |
| | | padding-bottom: 5rem; |
| | | } |
| | | .header { |
| | | display: flex; |
| | | align-items: center; |
| | | background: #fff; |
| | | padding: 1rem 1.25rem; |
| | | border-bottom: 0.0625rem solid #f0f0f0; |
| | | position: sticky; |
| | | top: 0; |
| | | z-index: 100; |
| | | /* 兼容 iOS 刘海/灵动岛安全区 */ |
| | | padding-top: env(safe-area-inset-top); |
| | | } |
| | | .title { |
| | | flex: 1; |
| | | text-align: center; |
| | | font-size: 1.125rem; |
| | | font-weight: 600; |
| | | color: #333; |
| | | } |
| | | .form-section { |
| | | margin-top: 1rem; |
| | | } |
| | | .van-field { |
| | | height: 3.4rem; |
| | | } |
| | | .van-cell { |
| | | align-items: center; |
| | | } |
| | | .product-section { |
| | | background: #fff; |
| | | margin-top: 1rem; |
| | | padding: 1rem; |
| | | box-shadow: 0 0.125rem 0.5rem rgba(0,0,0,0.04); |
| | | } |
| | | .section-header { |
| | | display: flex; |
| | | align-items: center; |
| | | justify-content: space-between; |
| | | margin-bottom: 1rem; |
| | | } |
| | | .section-title { |
| | | font-size: 1rem; |
| | | font-weight: 600; |
| | | color: #333; |
| | | } |
| | | .product-card { |
| | | background: #FFFFFF; |
| | | box-shadow: 0 0 1.25rem 0 rgba(0,57,117,0.08); |
| | | border-radius: 0.5rem 0.5rem 0.5rem 0.5rem; |
| | | padding: 1rem 0.5rem 0 0.5rem; |
| | | position: relative; |
| | | } |
| | | .product-header { |
| | | display: flex; |
| | | align-items: center; |
| | | justify-content: space-between; |
| | | padding: 0 0.5rem 0.75rem 0.5rem; |
| | | border-bottom: 0.0625rem solid #e8e8e8; |
| | | } |
| | | .product-productCategory { |
| | | margin-left: 0.5rem; |
| | | font-size: 0.875rem; |
| | | font-weight: 500; |
| | | color: #333; |
| | | } |
| | | .info-grid { |
| | | display: grid; |
| | | grid-template-columns: 1fr 1fr; |
| | | gap: 0.75rem; |
| | | margin-bottom: 1rem; |
| | | } |
| | | .info-item { |
| | | display: flex; |
| | | flex-direction: column; |
| | | gap: 0.25rem; |
| | | } |
| | | .info-label { |
| | | font-size: 0.75rem; |
| | | color: #666; |
| | | font-weight: 400; |
| | | } |
| | | .info-value { |
| | | font-size: 0.875rem; |
| | | color: #333; |
| | | font-weight: 500; |
| | | } |
| | | .info-value.highlight { |
| | | color: #2979ff; |
| | | font-weight: 600; |
| | | } |
| | | .product-form { |
| | | margin-bottom: 1rem; |
| | | } |
| | | .footer-btns { |
| | | position: fixed; |
| | | left: 0; |
| | | right: 0; |
| | | bottom: 0; |
| | | background: #fff; |
| | | display: flex; |
| | | justify-content: space-around; |
| | | align-items: center; |
| | | padding: 0.75rem 0; |
| | | box-shadow: 0 -0.125rem 0.5rem rgba(0,0,0,0.05); |
| | | z-index: 1000; |
| | | } |
| | | .cancel-btn { |
| | | font-weight: 400; |
| | | font-size: 1rem; |
| | | color: #FFFFFF; |
| | | width: 6.375rem; |
| | | background: #C7C9CC; |
| | | box-shadow: 0 0.25rem 0.625rem 0 rgba(3,88,185,0.2); |
| | | border-radius: 2.5rem 2.5rem 2.5rem 2.5rem; |
| | | } |
| | | .save-btn { |
| | | font-weight: 400; |
| | | font-size: 1rem; |
| | | color: #FFFFFF; |
| | | width: 14rem; |
| | | background: linear-gradient( 140deg, #00BAFF 0%, #006CFB 100%); |
| | | box-shadow: 0 0.25rem 0.625rem 0 rgba(3,88,185,0.2); |
| | | border-radius: 2.5rem 2.5rem 2.5rem 2.5rem; |
| | | } |
| | | |
| | | .popup-header { |
| | | display: flex; |
| | | justify-content: space-between; |
| | | align-items: center; |
| | | padding: 1rem; |
| | | background: #fff; |
| | | position: sticky; |
| | | top: 0; |
| | | z-index: 10; |
| | | } |
| | | .cancelButton { |
| | | color: #969799 |
| | | } |
| | | .confirmButton { |
| | | color: #1989FA |
| | | } |
| | | .u-tree { |
| | | height: 13rem; |
| | | } |
| | | @import '@/static/scss/form-common.scss'; |
| | | </style> |