Commit d2b3b13e by wusiyi

Merge branch 'dev_sorting_rule' into 'dev'

Dev sorting rule

See merge request !299
parents 18f72f82 9e016cfd
...@@ -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,12 +75,11 @@ ...@@ -75,12 +75,11 @@
: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"
class="platform-select" class="platform-select"
style="width: 190px" style="width: 210px"
:disabled="isDisabled" :disabled="isDisabled"
placeholder="请选择平台" placeholder="请选择平台"
filterable filterable
...@@ -109,7 +108,7 @@ ...@@ -109,7 +108,7 @@
<el-cascader <el-cascader
v-model="item.conditionValue" v-model="item.conditionValue"
class="category-cascader" class="category-cascader"
style="width: 190px" style="width: 210px"
placeholder="请选择商品类目" placeholder="请选择商品类目"
:options="categoryList" :options="categoryList"
:props="{ :props="{
...@@ -141,18 +140,39 @@ ...@@ -141,18 +140,39 @@
</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: 210px"
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
v-model="item.conditionValue" v-model="item.conditionValue"
style="width: 190px" style="width: 210px"
:min="1" :min="1"
:max="999" :max="999"
:disabled="isDisabled" :disabled="isDisabled"
placeholder="请输入数字" placeholder="请输入数字"
/> />
</template> </template>
<div class="btn-group">
<el-button <el-button
v-if="form.conditions.length < (pickingRuleList?.length ?? 0)" v-if="form.conditions.length < (pickingRuleList?.length ?? 0)"
type="primary" type="primary"
...@@ -176,6 +196,7 @@ ...@@ -176,6 +196,7 @@
/> />
</div> </div>
</div> </div>
</div>
</el-form-item> </el-form-item>
<el-form-item label="自动打单" prop="autoPrint"> <el-form-item label="自动打单" prop="autoPrint">
...@@ -238,7 +259,13 @@ import type { ...@@ -238,7 +259,13 @@ import type {
SortingRuleCondition, SortingRuleCondition,
SortingRuleDetail, SortingRuleDetail,
} from '@/types/api/order' } from '@/types/api/order'
import { getAreaListApi, addAreaApi, editAreaApi } from '@/api/order' import {
getAreaListApi,
addAreaApi,
editAreaApi,
getSortingUserListApi,
getCategoryListApi,
} from '@/api/order'
const props = defineProps<{ const props = defineProps<{
modelValue: boolean modelValue: boolean
...@@ -247,7 +274,6 @@ const props = defineProps<{ ...@@ -247,7 +274,6 @@ const props = defineProps<{
warehouseId: number warehouseId: number
warehouseName: string warehouseName: string
isDisabled?: boolean isDisabled?: boolean
categoryList: OperatorList[]
pickingRuleList: OperatorList[] pickingRuleList: OperatorList[]
operatorList: OperatorList[] operatorList: OperatorList[]
}>() }>()
...@@ -267,6 +293,8 @@ const visible = computed({ ...@@ -267,6 +293,8 @@ const visible = computed({
const formRef = ref<FormInstance>() const formRef = ref<FormInstance>()
const areaList = ref<OperatorList[]>([]) const areaList = ref<OperatorList[]>([])
const sortingUserList = ref<OperatorList[]>([])
const categoryList = ref<OperatorList[]>([])
const form = ref<SortingRuleDetail>({ const form = ref<SortingRuleDetail>({
areaDesc: '', areaDesc: '',
areaCode: '', areaCode: '',
...@@ -303,6 +331,7 @@ const getAvailableOperators = (conditionType: string) => { ...@@ -303,6 +331,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 +352,10 @@ const handleConditionTypeChange = (item: SortingRuleCondition) => { ...@@ -323,6 +352,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,9 +375,11 @@ const validateConditions = ( ...@@ -342,9 +375,11 @@ 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',
'order_user',
].includes(item.conditionType)
? Array.isArray(item.conditionValue) && item.conditionValue.length > 0 ? Array.isArray(item.conditionValue) && item.conditionValue.length > 0
: item.conditionValue !== null && item.conditionValue !== undefined : item.conditionValue !== null && item.conditionValue !== undefined
if (!item.conditionType || !isValueValid || !item.operator) { if (!item.conditionType || !isValueValid || !item.operator) {
...@@ -390,8 +425,9 @@ const formatConditionsForForm = (conditions: SortingRuleCondition[]) => ...@@ -390,8 +425,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
} }
...@@ -445,6 +481,20 @@ const loadAreaList = async () => { ...@@ -445,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 () => { const handleSubmit = async () => {
form.value.warehouseId = props.warehouseId form.value.warehouseId = props.warehouseId
...@@ -478,7 +528,7 @@ const handleSubmit = async () => { ...@@ -478,7 +528,7 @@ const handleSubmit = async () => {
} }
onMounted(async () => { onMounted(async () => {
await loadAreaList() await Promise.all([loadAreaList(), getSortingUserList(), getCategoryList()])
if (props.editData) { if (props.editData) {
form.value = { form.value = {
...props.editData, ...props.editData,
...@@ -523,6 +573,10 @@ onMounted(async () => { ...@@ -523,6 +573,10 @@ onMounted(async () => {
} }
} }
.btn-group {
display: flex;
}
.rule-action-btn { .rule-action-btn {
font-size: 16px; font-size: 16px;
} }
......
...@@ -134,7 +134,6 @@ ...@@ -134,7 +134,6 @@
:edit-data="editData" :edit-data="editData"
:warehouse-id="searchForm.warehouseId" :warehouse-id="searchForm.warehouseId"
:warehouse-name="searchForm.warehouseName" :warehouse-name="searchForm.warehouseName"
:category-list="categoryList"
:picking-rule-list="pickingRuleList" :picking-rule-list="pickingRuleList"
:operator-list="operatorList" :operator-list="operatorList"
@submit="getSortingRuleList" @submit="getSortingRuleList"
...@@ -362,6 +361,12 @@ const formatConditionText = (item: SortingRuleCondition) => { ...@@ -362,6 +361,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
...@@ -446,12 +451,18 @@ const updateConfig = async () => { ...@@ -446,12 +451,18 @@ const updateConfig = async () => {
// 查询列表 // 查询列表
const getSortingRuleList = async () => { const getSortingRuleList = async () => {
loading.value = true loading.value = true
const res = await getSortingRuleListApi({ try {
const [, res] = await Promise.all([
getCategoryList(),
getSortingRuleListApi({
warehouseId: searchForm.value.warehouseId, warehouseId: searchForm.value.warehouseId,
}) }),
])
if (res.code !== 200) return if (res.code !== 200) return
sortingList.value = res.data.records sortingList.value = res.data.records
} finally {
loading.value = false loading.value = false
}
} }
// 新增/编辑 // 新增/编辑
...@@ -509,12 +520,10 @@ onMounted(async () => { ...@@ -509,12 +520,10 @@ onMounted(async () => {
await Promise.all([ await Promise.all([
loadWarehouseList(), loadWarehouseList(),
getFunctionSwitch(), getFunctionSwitch(),
getCategoryList(),
getConditionTypeList(), getConditionTypeList(),
getOperatorList(), getOperatorList(),
]) ])
await getSortingRuleList() await getSortingRuleList()
loading.value = false
}) })
</script> </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