Commit 9e016cfd by wusiyi

feat: 打开弹窗实时更新下拉数据 #1012529

parent 551fb03e
......@@ -259,7 +259,13 @@ import type {
SortingRuleCondition,
SortingRuleDetail,
} from '@/types/api/order'
import { getAreaListApi, addAreaApi, editAreaApi } from '@/api/order'
import {
getAreaListApi,
addAreaApi,
editAreaApi,
getSortingUserListApi,
getCategoryListApi,
} from '@/api/order'
const props = defineProps<{
modelValue: boolean
......@@ -268,10 +274,8 @@ const props = defineProps<{
warehouseId: number
warehouseName: string
isDisabled?: boolean
categoryList: OperatorList[]
pickingRuleList: OperatorList[]
operatorList: OperatorList[]
sortingUserList: OperatorList[]
}>()
const emit = defineEmits<{
(e: 'update:modelValue', value: boolean): void
......@@ -289,6 +293,8 @@ const visible = computed({
const formRef = ref<FormInstance>()
const areaList = ref<OperatorList[]>([])
const sortingUserList = ref<OperatorList[]>([])
const categoryList = ref<OperatorList[]>([])
const form = ref<SortingRuleDetail>({
areaDesc: '',
areaCode: '',
......@@ -475,6 +481,20 @@ const loadAreaList = async () => {
}
}
// 获取所属客户列表
const getSortingUserList = async () => {
const res = await getSortingUserListApi()
if (res.code !== 200) return
sortingUserList.value = res.data
}
// 获取商品类目
const getCategoryList = async () => {
const res = await getCategoryListApi()
if (res.code !== 200) return
categoryList.value = res.data
}
// 提交
const handleSubmit = async () => {
form.value.warehouseId = props.warehouseId
......@@ -508,7 +528,7 @@ const handleSubmit = async () => {
}
onMounted(async () => {
await loadAreaList()
await Promise.all([loadAreaList(), getSortingUserList(), getCategoryList()])
if (props.editData) {
form.value = {
...props.editData,
......
......@@ -134,10 +134,8 @@
:edit-data="editData"
:warehouse-id="searchForm.warehouseId"
:warehouse-name="searchForm.warehouseName"
:category-list="categoryList"
:picking-rule-list="pickingRuleList"
:operator-list="operatorList"
:sorting-user-list="sortingUserList"
@submit="getSortingRuleList"
/>
<el-dialog
......@@ -172,7 +170,6 @@ import {
getCategoryListApi,
getConditionTypeListApi,
getOperatorListApi,
getSortingUserListApi,
} from '@/api/order'
import TableView from '@/components/TableView.vue'
import LogList from '@/components/LogList.vue'
......@@ -245,7 +242,6 @@ const sortingList = ref<SortingList[]>([]) // 规则列表
const categoryList = ref<OperatorList[]>([]) // 商品类目
const pickingRuleList = ref<OperatorList[]>([]) // 配货规则条件
const operatorList = ref<OperatorList[]>([]) // 配货规则操作符
const sortingUserList = ref<OperatorList[]>([]) // 所属客户列表
const isEnableSorting = ref(false) // 是否开启配货分拣
const currentId = ref(0) // 当前操作id
const isEdit = ref(false) // 是否编辑
......@@ -413,13 +409,6 @@ const loadWarehouseList = async () => {
}
}
// 获取所属客户列表
const getSortingUserList = async () => {
const res = await getSortingUserListApi()
if (res.code !== 200) return
sortingUserList.value = res.data
}
const handleWarehouseChange = (warehouseId: number) => {
searchForm.value.warehouseId = warehouseId
if (!isEnableSorting.value) return
......@@ -462,12 +451,18 @@ const updateConfig = async () => {
// 查询列表
const getSortingRuleList = async () => {
loading.value = true
const res = await getSortingRuleListApi({
warehouseId: searchForm.value.warehouseId,
})
if (res.code !== 200) return
sortingList.value = res.data.records
loading.value = false
try {
const [, res] = await Promise.all([
getCategoryList(),
getSortingRuleListApi({
warehouseId: searchForm.value.warehouseId,
}),
])
if (res.code !== 200) return
sortingList.value = res.data.records
} finally {
loading.value = false
}
}
// 新增/编辑
......@@ -525,13 +520,10 @@ onMounted(async () => {
await Promise.all([
loadWarehouseList(),
getFunctionSwitch(),
getCategoryList(),
getConditionTypeList(),
getOperatorList(),
getSortingUserList(),
])
await getSortingRuleList()
loading.value = false
})
</script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment