| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import {ref, computed, getCurrentInstance, watch, defineAsyncComponent} from "vue"; |
| | | import {ref, computed, getCurrentInstance, watch, onMounted, defineAsyncComponent} from "vue"; |
| | | import {createPurchaseReturnOrder} from "@/api/procurementManagement/purchase_return_order.js"; |
| | | import {getOptions, purchaseList} from "@/api/procurementManagement/procurementLedger.js"; |
| | | import {userListNoPageByTenantId} from "@/api/system/user.js"; |
| | | import dayjs from "dayjs"; |
| | | import useUserStore from "@/store/modules/user"; |
| | | const ProductList = defineAsyncComponent(() => import("@/views/procurementManagement/purchaseReturnOrder/ProductList.vue")); |
| | | const props = defineProps({ |
| | | visible: { |
| | |
| | | } |
| | | }); |
| | | let { proxy } = getCurrentInstance() |
| | | const userStore = useUserStore() |
| | | const payment_methods = [ |
| | | { |
| | | "label": "现金", |
| | |
| | | supplierId: undefined, |
| | | projectId: undefined, |
| | | projectPhase: undefined, |
| | | preparedAt: undefined, |
| | | preparedUserId: undefined, |
| | | preparedAt: dayjs().format("YYYY-MM-DD"), |
| | | preparedUserId: userStore.id || undefined, |
| | | preparedUserName: userStore.nickName || '', |
| | | returnUserId: undefined, |
| | | purchaseLedgerId: undefined, |
| | | purchaseReturnOrderProductsDtos: [], |
| | |
| | | } |
| | | |
| | | |
| | | // 同步制单人姓名(默认制单人为当前登录人,用户选项加载后保证下拉框按姓名回显) |
| | | const syncPreparedUser = () => { |
| | | if (!formState.value.preparedUserId && userStore.id) { |
| | | formState.value.preparedUserId = userStore.id |
| | | } |
| | | if (!formState.value.preparedUserId) { |
| | | return |
| | | } |
| | | const matchedUser = userOptions.value.find(item => item.userId === formState.value.preparedUserId) |
| | | formState.value.preparedUserName = matchedUser?.nickName || userStore.nickName || formState.value.preparedUserName || '' |
| | | } |
| | | |
| | | // 获取用户选项 |
| | | const fetchUserOptions = () => { |
| | | if (userOptions.value.length > 0) { |
| | | return |
| | | } |
| | | userListNoPageByTenantId().then((res) => { |
| | | userOptions.value = res.data; |
| | | userOptions.value = res.data || []; |
| | | syncPreparedUser() |
| | | }); |
| | | } |
| | | |
| | | // 弹窗打开时即加载用户选项,保证默认制单人(当前登录人)能正确显示姓名 |
| | | onMounted(() => { |
| | | fetchUserOptions() |
| | | }) |
| | | |
| | | // 处理改变供应商数据 |
| | | const handleChangeSupplierId = () => { |
| | | formState.value.purchaseLedgerId = undefined |