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() {
)
}
// 配货分拣 所属客户列表
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,12 +75,11 @@
:value="operator.code"
/>
</el-select>
<template v-if="item.conditionType === 'order_platform'">
<el-select
v-model="item.conditionValue"
class="platform-select"
style="width: 190px"
style="width: 210px"
:disabled="isDisabled"
placeholder="请选择平台"
filterable
......@@ -109,7 +108,7 @@
<el-cascader
v-model="item.conditionValue"
class="category-cascader"
style="width: 190px"
style="width: 210px"
placeholder="请选择商品类目"
:options="categoryList"
:props="{
......@@ -141,39 +140,61 @@
</template>
</el-cascader>
</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>
<el-input-number
v-model="item.conditionValue"
style="width: 190px"
style="width: 210px"
:min="1"
:max="999"
:disabled="isDisabled"
placeholder="请输入数字"
/>
</template>
<el-button
v-if="form.conditions.length < (pickingRuleList?.length ?? 0)"
type="primary"
class="rule-action-btn"
:icon="Plus"
size="small"
circle
:disabled="isDisabled"
@click="addPickingRuleItem"
/>
<el-button
v-if="form.conditions.length > 1"
color="#F56C6C"
class="rule-action-btn"
:icon="Minus"
size="small"
circle
plain
:disabled="isDisabled"
@click="removePickingRuleItem(index)"
/>
<div class="btn-group">
<el-button
v-if="form.conditions.length < (pickingRuleList?.length ?? 0)"
type="primary"
class="rule-action-btn"
:icon="Plus"
size="small"
circle
:disabled="isDisabled"
@click="addPickingRuleItem"
/>
<el-button
v-if="form.conditions.length > 1"
color="#F56C6C"
class="rule-action-btn"
:icon="Minus"
size="small"
circle
plain
:disabled="isDisabled"
@click="removePickingRuleItem(index)"
/>
</div>
</div>
</div>
</el-form-item>
......@@ -238,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
......@@ -247,7 +274,6 @@ const props = defineProps<{
warehouseId: number
warehouseName: string
isDisabled?: boolean
categoryList: OperatorList[]
pickingRuleList: OperatorList[]
operatorList: OperatorList[]
}>()
......@@ -267,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: '',
......@@ -303,6 +331,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 +352,10 @@ const handleConditionTypeChange = (item: SortingRuleCondition) => {
item.conditionValue = undefined
item.operator = 'contain'
break
case 'order_user':
item.conditionValue = undefined
item.operator = 'contain'
break
}
}
......@@ -342,11 +375,13 @@ 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'
? Array.isArray(item.conditionValue) && item.conditionValue.length > 0
: item.conditionValue !== null && item.conditionValue !== undefined
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) {
callback(new Error('请完善配货规则'))
return
......@@ -390,8 +425,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
}
......@@ -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 () => {
form.value.warehouseId = props.warehouseId
......@@ -478,7 +528,7 @@ const handleSubmit = async () => {
}
onMounted(async () => {
await loadAreaList()
await Promise.all([loadAreaList(), getSortingUserList(), getCategoryList()])
if (props.editData) {
form.value = {
...props.editData,
......@@ -523,6 +573,10 @@ onMounted(async () => {
}
}
.btn-group {
display: flex;
}
.rule-action-btn {
font-size: 16px;
}
......
......@@ -134,7 +134,6 @@
:edit-data="editData"
:warehouse-id="searchForm.warehouseId"
:warehouse-name="searchForm.warehouseName"
:category-list="categoryList"
:picking-rule-list="pickingRuleList"
:operator-list="operatorList"
@submit="getSortingRuleList"
......@@ -362,6 +361,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
......@@ -446,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
}
}
// 新增/编辑
......@@ -509,12 +520,10 @@ onMounted(async () => {
await Promise.all([
loadWarehouseList(),
getFunctionSwitch(),
getCategoryList(),
getConditionTypeList(),
getOperatorList(),
])
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