| | |
| | | @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" |
| | |
| | | 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> |
| | | <!-- 客户选择 --> |
| | |
| | | <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" |
| | |
| | | customerName: "", |
| | | projectName: "", |
| | | executionDate: "", |
| | | deliveryDate: "", |
| | | paymentMethod: "", |
| | | entryPerson: "", |
| | | entryPersonName: "", |
| | |
| | | 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([]); |
| | |
| | | executionDate: [ |
| | | { required: true, message: "请选择签订日期", trigger: "change" }, |
| | | ], |
| | | deliveryDate: [ |
| | | { required: true, message: "请选择交货日期", trigger: "change" }, |
| | | ], |
| | | }; |
| | | |
| | | const addProduct = () => { |
| | |
| | | specificationModel: "", |
| | | productModelId: "", |
| | | unit: "", |
| | | isProduction: true, |
| | | speculativeTradingName: "", |
| | | taxRate: "", |
| | | taxInclusiveUnitPrice: "", |
| | |
| | | // 保持pickerDateValue为时间戳格式,而不是格式化的字符串 |
| | | pickerDateValue.value = e.value; |
| | | showDatePicker.value = false; |
| | | }; |
| | | const onDeliveryDateConfirm = e => { |
| | | form.value.deliveryDate = formatDateToYMD(e.value); |
| | | deliveryDateValue.value = e.value; |
| | | showDeliveryDatePicker.value = false; |
| | | }; |
| | | |
| | | // 客户选择事件 |
| | |
| | | }); |
| | | 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}:请选择税率`, |
| | |
| | | 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); |
| | | // 填充基本信息 |
| | |
| | | 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 || ""; |
| | |
| | | |
| | | // 设置日期选择器的值 |
| | | 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 = () => { |