Commit 5edb0f1a by wusiyi

feat: 配货分拣规则增加订单所属客户条件 #1012529

parent 08060a26
......@@ -776,6 +776,13 @@ export function getOperatorListApi() {
)
}
// 配货分拣 所属客户列表
export function getSortingUserListApi() {
return axios.get<never, BaseRespData<OperatorList[]>>(
'dbDiyUser/userMarkListByFactory',
)
}
// 配货分拣 操作日志
export function getSortingLogApi(id: number) {
return axios.get<never, BaseRespData<LogListData[]>>('sorting/getLog', {
......
......@@ -75,7 +75,6 @@
:value="operator.code"
/>
</el-select>
<template v-if="item.conditionType === 'order_platform'">
<el-select
v-model="item.conditionValue"
......@@ -141,6 +140,27 @@
</template>
</el-cascader>
</template>
<template v-else-if="item.conditionType === 'order_user'">
<el-select
v-model="item.conditionValue"
class="platform-select"
style="width: 190px"
placeholder="请选择所属客户"
:disabled="isDisabled"
filterable
multiple
collapse-tags
:max-collapse-tags="1"
clearable
>
<el-option
v-for="user in sortingUserList"
:key="user"
:label="user"
:value="user"
/>
</el-select>
</template>
<template v-else>
<el-input-number
......@@ -250,6 +270,7 @@ const props = defineProps<{
categoryList: OperatorList[]
pickingRuleList: OperatorList[]
operatorList: OperatorList[]
sortingUserList: OperatorList[]
}>()
const emit = defineEmits<{
(e: 'update:modelValue', value: boolean): void
......@@ -303,6 +324,7 @@ const getAvailableOperators = (conditionType: string) => {
order_total_num: (code) => code !== 'in' && code !== 'contain',
order_platform: (code) => code === 'in',
order_category: (code) => code === 'contain',
order_user: (code) => code === 'contain',
}
const matcher = matchers[conditionType]
return matcher ? list.filter((operator) => matcher(operator.code)) : list
......@@ -323,6 +345,10 @@ const handleConditionTypeChange = (item: SortingRuleCondition) => {
item.conditionValue = undefined
item.operator = 'contain'
break
case 'order_user':
item.conditionValue = undefined
item.operator = 'contain'
break
}
}
......@@ -342,9 +368,11 @@ const validateConditions = (
const items = form.value.conditions
for (let i = 0; i < items.length; i++) {
const item = items[i]
const isValueValid =
item.conditionType === 'order_platform' ||
item.conditionType === 'order_category'
const isValueValid = [
'order_platform',
'order_category',
'order_user',
].includes(item.conditionType)
? Array.isArray(item.conditionValue) && item.conditionValue.length > 0
: item.conditionValue !== null && item.conditionValue !== undefined
if (!item.conditionType || !isValueValid || !item.operator) {
......@@ -390,8 +418,9 @@ const formatConditionsForForm = (conditions: SortingRuleCondition[]) =>
conditions.map((item) => {
if (
typeof item.conditionValue !== 'string' ||
(item.conditionType !== 'order_platform' &&
item.conditionType !== 'order_category')
!['order_platform', 'order_category', 'order_user'].includes(
item.conditionType,
)
) {
return item
}
......
......@@ -137,6 +137,7 @@
:category-list="categoryList"
:picking-rule-list="pickingRuleList"
:operator-list="operatorList"
:sorting-user-list="sortingUserList"
@submit="getSortingRuleList"
/>
<el-dialog
......@@ -171,6 +172,7 @@ import {
getCategoryListApi,
getConditionTypeListApi,
getOperatorListApi,
getSortingUserListApi,
} from '@/api/order'
import TableView from '@/components/TableView.vue'
import LogList from '@/components/LogList.vue'
......@@ -243,6 +245,7 @@ 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) // 是否编辑
......@@ -362,6 +365,12 @@ const formatConditionText = (item: SortingRuleCondition) => {
.filter(Boolean)
.join('、')
break
case 'order_user':
valueText = String(item.conditionValue ?? '')
.split(',')
.filter(Boolean)
.join('、')
break
default:
valueText = String(item.conditionValue ?? '')
break
......@@ -404,6 +413,13 @@ 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
......@@ -512,6 +528,7 @@ onMounted(async () => {
getCategoryList(),
getConditionTypeList(),
getOperatorList(),
getSortingUserList(),
])
await getSortingRuleList()
loading.value = false
......
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