|
|
@@ -23,7 +23,6 @@
|
|
|
<el-option v-for="item in getOperations(domain.attrCode)" :key="item.value" :label="item.label"
|
|
|
:value="item.value" />
|
|
|
</el-select>
|
|
|
-
|
|
|
<!-- 3. 值输入区域(动态切换) -->
|
|
|
<!-- 单选按钮组 -->
|
|
|
<el-radio-group v-model="domain.min" v-if="getConditionType(domain.attrCode) === 'radio'">
|
|
|
@@ -34,13 +33,26 @@
|
|
|
<!-- 多选下拉 -->
|
|
|
<el-select v-model="domain.minArray" placeholder="选择值" multiple style="width: 341px"
|
|
|
v-if="getConditionType(domain.attrCode) === 'checkbox'" :disabled="!domain.operator" clearable>
|
|
|
+ <template #header>
|
|
|
+ <el-checkbox v-model="domain.checkAll" :indeterminate="domain.indeterminate"
|
|
|
+ @change="(val) => handleCheckAll(domain, val)">
|
|
|
+ 全选
|
|
|
+ </el-checkbox>
|
|
|
+ </template>
|
|
|
<el-option v-for="item in getOptions(domain.attrCode)" :key="item.id" :label="item.name"
|
|
|
:value="item.id" />
|
|
|
</el-select>
|
|
|
|
|
|
<!-- 单选下拉 -->
|
|
|
<el-select v-model="domain.minArray" placeholder="选择值" style="width: 341px" multiple
|
|
|
- v-if="getConditionType(domain.attrCode) === 'select'" :disabled="!domain.operator" clearable>
|
|
|
+ @change="change(domain)" v-if="getConditionType(domain.attrCode) === 'select'"
|
|
|
+ :disabled="!domain.operator" clearable>
|
|
|
+ <template #header>
|
|
|
+ <el-checkbox v-model="domain.checkAll" :indeterminate="domain.indeterminate"
|
|
|
+ @change="(val) => handleCheckAll(domain, val)">
|
|
|
+ 全选
|
|
|
+ </el-checkbox>
|
|
|
+ </template>
|
|
|
<el-option v-for="item in getOptions(domain.attrCode)" :key="item.code" :label="item.name"
|
|
|
:value="item.code" />
|
|
|
</el-select>
|
|
|
@@ -213,6 +225,8 @@ interface ConditionRow {
|
|
|
attrCode: string;
|
|
|
max: any;
|
|
|
errorMsg: string;
|
|
|
+ checkAll: boolean;
|
|
|
+ indeterminate: boolean;
|
|
|
minArray?: string[];
|
|
|
}
|
|
|
|
|
|
@@ -280,83 +294,30 @@ const dictionaries = ref([]);
|
|
|
const dispatchId = ref(""); //调度id
|
|
|
const editType = ref("");
|
|
|
|
|
|
-// 表单校验规则
|
|
|
-// 先定义独立校验函数(放在formRules之前)
|
|
|
-const validateConditionGroups = (
|
|
|
- rule: any,
|
|
|
- value: ConditionGroup[],
|
|
|
- callback: any
|
|
|
-) => {
|
|
|
- // 1. 校验:至少1组条件
|
|
|
- if (value.length === 0) {
|
|
|
- return callback(new Error("至少配置1组“或者”条件"));
|
|
|
- }
|
|
|
-
|
|
|
- // 2. 遍历每组校验
|
|
|
- for (const group of value) {
|
|
|
- // 2.1 校验:每组至少1行“并且”条件
|
|
|
- if (group.actions.length === 0) {
|
|
|
- return callback(new Error("每组条件至少包含1条“并且”规则"));
|
|
|
- }
|
|
|
-
|
|
|
- // 2.2 遍历每行校验完整性
|
|
|
- for (const row of group.actions) {
|
|
|
- row.errorMsg = ""; // 清空历史错误,避免残留
|
|
|
- const attrType = getConditionType(row.attrCode);
|
|
|
- const isRangeOp = row.operator === "1"; // 是否为“介于”等范围运算符
|
|
|
|
|
|
- // 校验1:条件类型未选择
|
|
|
- if (!row.attrCode) {
|
|
|
- row.errorMsg = "请选择条件类型(如“报价金额”“车辆类型”)";
|
|
|
- return callback(new Error(row.errorMsg));
|
|
|
- }
|
|
|
+const handleCheckAll = (item, val: boolean) => {
|
|
|
|
|
|
- // 校验2:运算符未选择
|
|
|
- if (!row.operator) {
|
|
|
- row.errorMsg = "请选择运算符(如“等于”“大于”)";
|
|
|
- return callback(new Error(row.errorMsg));
|
|
|
- }
|
|
|
+ item.indeterminate = false
|
|
|
+ if (val) {
|
|
|
+ item.minArray = getOptions(item.attrCode).map((_) => _.code)
|
|
|
+ } else {
|
|
|
+ item.minArray = []
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
- // 校验3:根据条件类型校验“值”
|
|
|
- // 3.1 多选/标签类型(依赖minArray)
|
|
|
- if (["checkbox", "inputTag"].includes(attrType)) {
|
|
|
- if (!row.minArray || row.minArray.length === 0) {
|
|
|
- row.errorMsg = `请选择至少一个条件值(当前为${attrType === "checkbox" ? "多选" : "标签"
|
|
|
- }类型)`;
|
|
|
- return callback(new Error(row.errorMsg));
|
|
|
- }
|
|
|
- }
|
|
|
- // 3.2 范围类型(需同时填min和max)
|
|
|
- else if (isRangeOp) {
|
|
|
- if (row.min === null || row.min === "" || row.min === undefined) {
|
|
|
- row.errorMsg = "请填写范围起始值(如“1000”)";
|
|
|
- return callback(new Error(row.errorMsg));
|
|
|
- }
|
|
|
- if (row.max === null || row.max === "" || row.max === undefined) {
|
|
|
- row.errorMsg = "请填写范围结束值(如“2000”)";
|
|
|
- return callback(new Error(row.errorMsg));
|
|
|
- }
|
|
|
- }
|
|
|
- // 3.3 普通类型(单选/输入框,依赖min或max)
|
|
|
- else {
|
|
|
- const targetVal = ["radio", "select", "plate", "datetime"].includes(
|
|
|
- attrType
|
|
|
- )
|
|
|
- ? row.max
|
|
|
- : row.min;
|
|
|
- if (targetVal === null || targetVal === "" || targetVal === undefined) {
|
|
|
- row.errorMsg = `请${attrType === "datetime" ? "选择" : "输入"
|
|
|
- }条件值(当前为${attrType === "select" ? "下拉选择" : "文本输入"
|
|
|
- }类型)`;
|
|
|
- return callback(new Error(row.errorMsg));
|
|
|
- }
|
|
|
- }
|
|
|
+const change = (item: any) => {
|
|
|
+ if (item?.attrType == 'select') {
|
|
|
+ if (item.minArray.length === 0) {
|
|
|
+ item.checkAll = false
|
|
|
+ item.indeterminate = false
|
|
|
+ } else if (item.minArray.length === getOptions(item.attrCode).length) {
|
|
|
+ item.checkAll = true
|
|
|
+ item.indeterminate = false
|
|
|
+ } else {
|
|
|
+ item.indeterminate = true
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- // 所有校验通过
|
|
|
- callback();
|
|
|
-};
|
|
|
+}
|
|
|
|
|
|
const validateAgreementId = (rule: any, value: string, callback: any) => {
|
|
|
if (!value) {
|
|
|
@@ -473,12 +434,16 @@ const handleConditionChange = (domain: ConditionRow, val: string) => {
|
|
|
const target = dispatchList.value.find((item: any) => item.attrCode == val)
|
|
|
domain.max = null;
|
|
|
domain.operator = "";
|
|
|
+ domain.checkAll = false;
|
|
|
+ domain.indeterminate = false
|
|
|
domain.attrType = target?.attrType || "input";
|
|
|
};
|
|
|
|
|
|
// 运算符切换时重置值
|
|
|
const handleOperatorChange = (domain: ConditionRow) => {
|
|
|
const attrType = getConditionType(domain.attrCode);
|
|
|
+ domain.checkAll = false;
|
|
|
+ domain.indeterminate = false
|
|
|
// 重置对应类型的值
|
|
|
if (["checkbox", "inputTag", "select"].includes(attrType)) {
|
|
|
domain.minArray = [];
|