Commit 5edb0f1a by wusiyi

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

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