Commit fa7175ac by 黄燕娟

fix:初始化修改

parent 591be54a
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"scripts": { "scripts": {
"serve": "vue-cli-service serve", "serve": "vue-cli-service serve",
"build": "vue-cli-service build --mode test", "build": "vue-cli-service build --mode test",
"build:test": "vue-cli-service build --mode test", "build:test": "vue-cli-service build --mode test",
...@@ -14,6 +13,7 @@ ...@@ -14,6 +13,7 @@
"test": "vue-cli-service inspect" "test": "vue-cli-service inspect"
}, },
"dependencies": { "dependencies": {
"@babel/plugin-proposal-optional-chaining": "^7.21.0",
"@tinymce/tinymce-vue": "2.1.0", "@tinymce/tinymce-vue": "2.1.0",
"@vant/area-data": "^1.3.1", "@vant/area-data": "^1.3.1",
"@zxing/library": "^0.19.1", "@zxing/library": "^0.19.1",
......
import Vue from "vue";
import axios from "axios"; import axios from "axios";
import qs from "qs";
import { Message, MessageBox, Loading } from "element-ui";
import store from "@/store";
import router from "@/router";
// 超时时间 // 超时时间
axios.defaults.timeout = 300000; axios.defaults.timeout = 300000;
......
...@@ -41,4 +41,5 @@ body{ ...@@ -41,4 +41,5 @@ body{
.card-page-box{ .card-page-box{
background: #fff; background: #fff;
height: 100vh; height: 100vh;
padding: 10px;
} }
\ No newline at end of file
...@@ -50,7 +50,6 @@ ...@@ -50,7 +50,6 @@
v-for="(item, index) in forms" v-for="(item, index) in forms"
:key="item.name + index" :key="item.name + index"
> >
<form-item <form-item
v-if="item.name !== 'SpanLayout' && item.name !== 'Description'" v-if="item.name !== 'SpanLayout' && item.name !== 'Description'"
:model="_value" :model="_value"
...@@ -367,12 +366,14 @@ export default { ...@@ -367,12 +366,14 @@ export default {
case "TextInput": case "TextInput":
case "TextareaInput": case "TextareaInput":
case "SelectInput": case "SelectInput":
case "RadioGroup":
case "Location": case "Location":
case "SelectInputApi":
case "Provinces": case "Provinces":
compareType = "strCompare"; compareType = "strCompare";
break; break;
case "RadioGroup":
case "SelectInputApi":
compareType = "customSelectCompare";
break;
case "MultipleSelect": case "MultipleSelect":
compareType = "strArrCompare"; compareType = "strArrCompare";
break; break;
...@@ -387,6 +388,15 @@ export default { ...@@ -387,6 +388,15 @@ export default {
compareType = "orgCompare"; compareType = "orgCompare";
break; break;
} }
console.log(
"ckkk.",
CompareFuncs[compareType][condition.compare](
source,
condition.fixed
? condition.compareVal
: this._value[condition.compareVal[0]]
)
);
return CompareFuncs[compareType][condition.compare]( return CompareFuncs[compareType][condition.compare](
source, source,
condition.fixed condition.fixed
......
...@@ -2,61 +2,71 @@ ...@@ -2,61 +2,71 @@
import moment from "moment"; import moment from "moment";
const strCompareOptions = [ const strCompareOptions = [
{name: '等于', symbol: 'EQ', compare: (a, b) => a == b[0]}, { name: '等于', symbol: 'EQ', compare: (a, b) => a == b[0] },
{name: '不等于', symbol: 'NEQ', compare: (a, b) => a != b[0]}, { name: '不等于', symbol: 'NEQ', compare: (a, b) => a != b[0] },
{name: '为其之一', symbol: 'IN', compare: (a, b) => (b || []).includes(a)}, { name: '为其之一', symbol: 'IN', compare: (a, b) => (b || []).includes(a) },
{name: '不为其之一', symbol: 'NIN', compare: (a, b) => !(b || []).includes(a)}, { name: '不为其之一', symbol: 'NIN', compare: (a, b) => !(b || []).includes(a) },
{name: '含有', symbol: 'LIKE', compare: (a, b) => (b || '').includes(a)}, { name: '含有', symbol: 'LIKE', compare: (a, b) => (b || '').includes(a) },
]
const customSelectCompareOptions = [
{
name: '等于', symbol: 'EQ', compare: (a, b) => {
return (a?.id || a) == (b[0].id || b[0])
}
},
] ]
const strArrCompareOptions = [ const strArrCompareOptions = [
{name: '包含', symbol: 'HS', compare: (a, b) => checkElementsExistInArray(b, a)}, { name: '包含', symbol: 'HS', compare: (a, b) => checkElementsExistInArray(b, a) },
{name: '不包含', symbol: 'NHS', compare: (a, b) => !checkElementsExistInArray(b, a)}, { name: '不包含', symbol: 'NHS', compare: (a, b) => !checkElementsExistInArray(b, a) },
] ]
const numCompareOptions = [ const numCompareOptions = [
{name: '大于', symbol: 'GT', compare: (a, b) => a > b}, { name: '大于', symbol: 'GT', compare: (a, b) => a > b },
{name: '小于', symbol: 'LT', compare: (a, b) => a < b}, { name: '小于', symbol: 'LT', compare: (a, b) => a < b },
{name: '等于', symbol: 'EQ', compare: (a, b) => a == b}, { name: '等于', symbol: 'EQ', compare: (a, b) => a == b },
{name: '不等于', symbol: 'NEQ', compare: (a, b) => a != b}, { name: '不等于', symbol: 'NEQ', compare: (a, b) => a != b },
{name: '大于等于', symbol: 'GT_EQ', compare: (a, b) => a >= b}, { name: '大于等于', symbol: 'GT_EQ', compare: (a, b) => a >= b },
{name: '小于等于', symbol: 'LT_EQ', compare: (a, b) => a <= b}, { name: '小于等于', symbol: 'LT_EQ', compare: (a, b) => a <= b },
{name: '在内或相等', symbol: 'IN_EQ', compare: (a, b) => a >= b[0] && a <= b[1]}, { name: '在内或相等', symbol: 'IN_EQ', compare: (a, b) => a >= b[0] && a <= b[1] },
{name: '在内或不等', symbol: 'IN_NEQ', compare: (a, b) => a == b}, { name: '在内或不等', symbol: 'IN_NEQ', compare: (a, b) => a == b },
{name: '为其之一', symbol: 'IN', compare: (a, b) => (b || []).includes(a)}, { name: '为其之一', symbol: 'IN', compare: (a, b) => (b || []).includes(a) },
{name: '不为其之一', symbol: 'NIN', compare: (a, b) => !(b || []).includes(a)}, { name: '不为其之一', symbol: 'NIN', compare: (a, b) => !(b || []).includes(a) },
] ]
const orgCompareOptions = [ const orgCompareOptions = [
{name: '是', symbol: 'EQ', compare: (a, b) => a[0].id == b[0].id}, { name: '是', symbol: 'EQ', compare: (a, b) => a[0].id == b[0].id },
{name: '不是', symbol: 'NEQ', compare: (a, b) => a[0].id != b[0].id}, { name: '不是', symbol: 'NEQ', compare: (a, b) => a[0].id != b[0].id },
{name: '为其之一', symbol: 'IN', compare: (a, b) => checkElementsExistInArray(a, b, 'id')}, { name: '为其之一', symbol: 'IN', compare: (a, b) => checkElementsExistInArray(a, b, 'id') },
{name: '含有', symbol: 'HS', compare: (a, b) => checkElementsExistInArray(b, a, 'id')}, { name: '含有', symbol: 'HS', compare: (a, b) => checkElementsExistInArray(b, a, 'id') },
{name: '不含有', symbol: 'NHS', compare: (a, b) => !checkElementsExistInArray(b, a, 'id')}, { name: '不含有', symbol: 'NHS', compare: (a, b) => !checkElementsExistInArray(b, a, 'id') },
] ]
const timeCompareOptions = [ const timeCompareOptions = [
{name: '在之前', symbol: 'LT', compare: (a, b) => moment(a).isBefore(moment(b[0]))}, { name: '在之前', symbol: 'LT', compare: (a, b) => moment(a).isBefore(moment(b[0])) },
{name: '在之后', symbol: 'GT', compare: (a, b) => moment(a).isAfter(moment(b[0]))}, { name: '在之后', symbol: 'GT', compare: (a, b) => moment(a).isAfter(moment(b[0])) },
{name: '在其中', symbol: 'IN', compare: (a, b) => moment(b[0]).isBefore(moment(a)) && moment(b[1]).isAfter(moment(a))}, { name: '在其中', symbol: 'IN', compare: (a, b) => moment(b[0]).isBefore(moment(a)) && moment(b[1]).isAfter(moment(a)) },
] ]
const timeArrCompareOptions = [ const timeArrCompareOptions = [
{name: '包含', symbol: 'LT', compare: (a, b) => moment(a[0]).isBefore(moment(b[0])) && moment(a[1]).isAfter(moment(b[0]))}, { name: '包含', symbol: 'LT', compare: (a, b) => moment(a[0]).isBefore(moment(b[0])) && moment(a[1]).isAfter(moment(b[0])) },
{name: '不包含', symbol: 'GT', compare: (a, b) => moment(b[0]).isBefore(moment(a[0])) || moment(b[0]).isAfter(moment(a[1]))}, { name: '不包含', symbol: 'GT', compare: (a, b) => moment(b[0]).isBefore(moment(a[0])) || moment(b[0]).isAfter(moment(a[1])) },
] ]
//加载比较函数对象 //加载比较函数对象
function getCompareFucs(){ function getCompareFucs() {
let cpFuncs = { let cpFuncs = {
strCompare:{}, strCompare: {},
strArrCompare:{}, customSelectCompare: {},
numCompare:{}, strArrCompare: {},
orgCompare:{}, numCompare: {},
timeCompare:{}, orgCompare: {},
timeArrCompare:{} timeCompare: {},
timeArrCompare: {}
} }
strCompareOptions.forEach(v => cpFuncs.strCompare[v.symbol] = v.compare) strCompareOptions.forEach(v => cpFuncs.strCompare[v.symbol] = v.compare)
customSelectCompareOptions.forEach(v => cpFuncs.customSelectCompare[v.symbol] = v.compare)
strArrCompareOptions.forEach(v => cpFuncs.strArrCompare[v.symbol] = v.compare) strArrCompareOptions.forEach(v => cpFuncs.strArrCompare[v.symbol] = v.compare)
numCompareOptions.forEach(v => cpFuncs.numCompare[v.symbol] = v.compare) numCompareOptions.forEach(v => cpFuncs.numCompare[v.symbol] = v.compare)
orgCompareOptions.forEach(v => cpFuncs.orgCompare[v.symbol] = v.compare) orgCompareOptions.forEach(v => cpFuncs.orgCompare[v.symbol] = v.compare)
...@@ -70,12 +80,12 @@ function checkElementsExistInArray(A, B, key) { ...@@ -70,12 +80,12 @@ function checkElementsExistInArray(A, B, key) {
for (let i = 0; i < A.length; i++) { for (let i = 0; i < A.length; i++) {
let found = false; let found = false;
for (let j = 0; j < B.length; j++) { for (let j = 0; j < B.length; j++) {
if (key){ if (key) {
if (A[i][key] == B[j][key]) { if (A[i][key] == B[j][key]) {
found = true; found = true;
break; break;
} }
}else { } else {
if (A[i] == B[j]) { if (A[i] == B[j]) {
found = true; found = true;
break; break;
...@@ -94,5 +104,5 @@ export const CompareFuncs = getCompareFucs() ...@@ -94,5 +104,5 @@ export const CompareFuncs = getCompareFucs()
export default { export default {
strCompareOptions, strArrCompareOptions, strCompareOptions, strArrCompareOptions,
numCompareOptions, orgCompareOptions, numCompareOptions, orgCompareOptions,
timeCompareOptions, timeArrCompareOptions timeCompareOptions, timeArrCompareOptions, customSelectCompareOptions
} }
<template>
<component
:is="context.fieldType"
:readonly="false"
mode="PC"
v-model="context.compareVal[0]"
v-bind="context.config.props"
/>
</template>
<script>
let SelectInputApi = () => import("../../components/SelectInputApi.vue");
let RadioGroup = () => import("../../components/RadioGroup.vue");
export default {
name: "CustomSelectCompare",
components: { SelectInputApi, RadioGroup },
props: {
context: {
require: true,
type: Object,
},
},
};
</script>
<template> <template>
<div> <div style="display: flex">
<el-select <el-select
style="width: 150px; margin: 5px" style="width: 150px; margin: 5px"
@change="fieldChange" @change="fieldChange"
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
></el-option> ></el-option>
</el-select> </el-select>
<template v-if="_value.field"> <template v-if="_value.field">
<div style="display: flex">
<el-select <el-select
style="width: 110px; margin: 5px" style="width: 110px; margin: 5px"
v-model="_value.compare" v-model="_value.compare"
...@@ -27,13 +28,17 @@ ...@@ -27,13 +28,17 @@
:label="cp.name" :label="cp.name"
/> />
</el-select> </el-select>
<el-radio-group v-model="_value.fixed" @change="_value.compareVal = []"> <el-radio-group
style="margin: 5px"
v-model="_value.fixed"
@change="_value.compareVal = []"
>
<el-radio-button :label="true">固定</el-radio-button> <el-radio-button :label="true">固定</el-radio-button>
<el-radio-button :label="false">动态</el-radio-button> <el-radio-button :label="false">动态</el-radio-button>
</el-radio-group> </el-radio-group>
<component <component
style="width: calc(100% - 410px); margin-left: 5px"
v-if="_value.fixed" v-if="_value.fixed"
style="margin: 5px"
:is="condition.name" :is="condition.name"
:context="_value" :context="_value"
/> />
...@@ -51,6 +56,7 @@ ...@@ -51,6 +56,7 @@
:label="item.title" :label="item.title"
></el-option> ></el-option>
</el-select> </el-select>
</div>
</template> </template>
</div> </div>
</template> </template>
...@@ -62,6 +68,8 @@ export default { ...@@ -62,6 +68,8 @@ export default {
name: "ConditionItem", name: "ConditionItem",
components: { components: {
StrCompare: () => import("../../components/compare/StrCompare.vue"), StrCompare: () => import("../../components/compare/StrCompare.vue"),
CustomSelectCompare: () =>
import("../../components/compare/CustomSelectCompare.vue"),
NumCompare: () => import("../../components/compare/NumCompare.vue"), NumCompare: () => import("../../components/compare/NumCompare.vue"),
OrgCompare: () => import("../../components/compare/OrgCompare.vue"), OrgCompare: () => import("../../components/compare/OrgCompare.vue"),
StrArrCompare: () => import("../../components/compare/StrArrCompare.vue"), StrArrCompare: () => import("../../components/compare/StrArrCompare.vue"),
...@@ -136,12 +144,17 @@ export default { ...@@ -136,12 +144,17 @@ export default {
case "TextInput": case "TextInput":
case "TextareaInput": case "TextareaInput":
case "SelectInput": case "SelectInput":
case "RadioGroup":
case "SelectInputApi":
return { return {
name: "strCompare", name: "strCompare",
options: compareOptions.strCompareOptions, options: compareOptions.strCompareOptions,
}; };
case "RadioGroup":
case "SelectInputApi":
return {
name: "customSelectCompare",
options: compareOptions.customSelectCompareOptions,
};
case "MultipleSelect": case "MultipleSelect":
return { return {
name: "strArrCompare", name: "strArrCompare",
...@@ -178,6 +191,9 @@ export default { ...@@ -178,6 +191,9 @@ export default {
this._value.compare = null; this._value.compare = null;
this._value.compareVal = []; this._value.compareVal = [];
this._value.fieldType = this.formItemMap.get(this._value.field).name; this._value.fieldType = this.formItemMap.get(this._value.field).name;
this._value.config = this._formItems.find((item) => {
return this._value.field == item.id;
});
}, },
}, },
}; };
......
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 sign in to comment