Browse Source

1.数据标题配置

2.关联表单的隐藏条件和数据范围条件编辑校验提醒
lwx_13
liwenxuan 1 year ago
parent
commit
bfeab594dd
  1. 3
      src/api/DesignForm/types.ts
  2. 15
      src/components/DesignForm/formControlAttr.vue
  3. 14
      src/components/DesignForm/formControlPropertiNew.vue
  4. 4
      src/views/sysworkflow/lowcodepage/appPage/appPageForm/openAppFormPage.vue
  5. 3
      src/views/sysworkflow/lowcodepage/appPage/createAppFormPage.vue
  6. 49
      src/widget/associatedforms/associatedForms.vue
  7. 134
      src/widget/associatedforms/associatedFormsTinyace.vue
  8. 125
      src/widget/associatedforms/associatedFormsTinyaceRange.vue

3
src/api/DesignForm/types.ts

@ -103,7 +103,8 @@ export interface formData{
form: {
size: any;
name:any,
formName:any
formName:any,
dataTitle:any
};
config: any;
events?:any;

15
src/components/DesignForm/formControlAttr.vue

@ -3457,6 +3457,21 @@ const disabledIstrue = (val:string) => {
<el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
</el-upload>
</el-form-item>
<el-form-item class="form_cont">
数据标题
<el-tree-select
v-model="formData.dataTitle"
multiple
clearable
collapse-tags
:data="associatedFormsCurrentFormFieldTree"
:render-after-expand="false"
style="width: 240px"
/>
</el-form-item>
<template v-if="!state.isSearch">
<el-divider content-position="left">接口数据事件</el-divider>

14
src/components/DesignForm/formControlPropertiNew.vue

@ -3491,6 +3491,20 @@ const disabledIstrue = (val:string) => {
<el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
</el-upload>
</el-form-item>
<el-form-item class="form_cont">
数据标题
<el-tree-select
v-model="formData.dataTitle"
multiple
clearable
collapse-tags
:data="associatedFormsCurrentFormFieldTree"
:render-after-expand="false"
style="width: 240px"
/>
</el-form-item>
<template v-if="!state.isSearch">
<el-divider content-position="left">接口数据事件</el-divider>

4
src/views/sysworkflow/lowcodepage/appPage/appPageForm/openAppFormPage.vue

@ -170,7 +170,7 @@ const gainAppFormPageInit = () =>{
if(stateData.tableData.columns.length>0){
for(let i = 0;i<stateData.tableData.columns.length;i++){
if(stateData.tableData.columns[i].config!=undefined && stateData.tableData.columns[i].control!=undefined){
console.log(stateData.tableData.columns[i])
//console.log(stateData.tableData.columns[i])
let paramx:string = ""+stateData.tableData.columns[i].control.optionsValue3Field
/*
在这里请求后台获取字段
@ -179,7 +179,7 @@ const gainAppFormPageInit = () =>{
stateData.tableData.columns[i].options = data
if(stateData.searchData.length>0){
for(let j = 0;j<stateData.searchData.length;j++){
console.log(stateData.searchData[j])
//console.log(stateData.searchData[j])
if(stateData.searchData[j].id==stateData.tableData.columns[i].id){
stateData.searchData[j].options = data
}

3
src/views/sysworkflow/lowcodepage/appPage/createAppFormPage.vue

@ -73,7 +73,8 @@ const state = reactive<formStruct>({
form: {
size: 'default',
name:'',
formName: formConfigCont.formName
formName: formConfigCont.formName,
dataTitle: []
},
config: {
groupKey:props.groupKey

49
src/widget/associatedforms/associatedForms.vue

@ -1,15 +1,52 @@
<template>
<el-input v-model="input" style="width: 240px" placeholder="" />
<!-- <el-input v-model="input" style="width: 240px" placeholder="" /> -->
<el-select v-model="value1" placeholder="请选择" style="width: 240px">
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</template>
<script setup >
<script setup>
const props = defineProps({
// eslint-disable-next-line vue/require-default-prop
data: {
type: Object,
}
})
const value1 = ref('')
const options = [
{
value: 'Option1',
label: 'Option1',
},
{
value: 'Option2',
label: 'Option2',
},
{
value: 'Option3',
label: 'Option3',
},
{
value: 'Option4',
label: 'Option4',
},
{
value: 'Option5',
label: 'Option5',
},
]
onMounted(()=>{
console.log(props.data.control.hideConditionHtml)
console.log(props.data.control.dataRangeConditionHtml)
})
</script>
<style>
</style>
<style></style>

134
src/widget/associatedforms/associatedFormsTinyace.vue

@ -6,6 +6,7 @@ import "tinymce/models/dom"; // 特别注意 tinymce 6.0.0 版本之后必须引
import "tinymce/themes/silver/theme";
import Editor from "@tinymce/tinymce-vue"; //
import { v4 as uuidv4 } from "uuid";
import { ElMessage } from 'element-plus'
let onlyNumber = uuidv4().replaceAll('-','').toString(); //
@ -46,17 +47,131 @@ let $emit = defineEmits(["textChange"]);
const tinymceHtml = ref("")
tinymceHtml.value = props.aftText
const tinymceBox = ref(null)
onMounted(() => {
tinymce.init({}); //
});
watch(()=>tinymceHtml.value, (val:any) => {
$emit('textChange',val);
},
$emit('textChange',val);
nextTick(()=>{
let formulaOne = [];
let formulaTwo = [];
tinymceBox.value.childNodes.forEach(element => {
element.childNodes.forEach(child => {
formulaOne.push(child.innerText?child.innerText:child.data)
if(child.dataset&&child.dataset.keyid){
formulaTwo.push(child.dataset.keyid)
}else{
formulaTwo.push(child.innerText?child.innerText:child.data)
}
})
});
let suanShitwo = formulaTwo.join('').replace(/\s+/g, "");
let gongShi ={
formulaHtml:tinymceBox.value.innerHTML,
mathsString:tinymceBox.value.innerText,
mathsFormula:suanShitwo,
}
if(containsNewline(gongShi.mathsString)){
errorCondition("条件不允许换行")
}else if(!gongShi.formulaHtml.startsWith("<p><span")){
errorCondition("条件需以蓝色块开头")
}else if(gongShi.formulaHtml.endsWith("</span></p>")){
errorCondition("条件不能以蓝色块结尾")
}else if(countSpanTags(gongShi.formulaHtml)>1){
errorCondition("不允许出现多个蓝色块")
}else if(!containsSingleComparator(gongShi.mathsFormula)){
errorCondition("不存在有效符号")
}else if(checkEnding(gongShi.mathsFormula)){
errorCondition("不能以符号为结尾")
}else{
succCondition()
}
})
},
{ deep: true }
)
function checkEnding(str: string) {
const symbols = ['==', '>=', '>', '<=', '<', '!=', '='];
const trimmedStr = str.trim();
for (let symbol of symbols) {
if (trimmedStr.endsWith(symbol)) {
return true;
}
}
return false;
}
function containsSingleComparator(str: string) {
//
const comparators = ['==', '>=', '>', '<=', '<', '!='];
let found = false; //
let i = 0; //
while (i < str.length - 1) { //
//
for (const comparator of comparators) {
if (str.substr(i, comparator.length) === comparator) {
//
if (found) {
// false
return false;
}
found = true; //
//
i += comparator.length - 1;
break; //
}
}
i++; //
}
//
return found;
}
function containsComparator(str: string) {
if(str.includes("==")||str.includes("!=")||str.includes(">")||str.includes(">=")||str.includes("<")||str.includes("<=")){
return true
}else{
return false
}
}
const containsNewline = (str: string) => {
//console.log("Testing string:", str); //
return /\n/.test(str);
};
const countSpanTags = (str: string) => {
// 使<span>
const matches = str.match(/<span\b[^>]*>/gi);
// matchesnull0
//
return matches ? matches.length : 0;
};
function succCondition(){
ElMessage.closeAll()
ElMessage({
showClose: true,
message: '条件格式校验通过',
type: 'success',
duration:3500,
})
}
function errorCondition(str:string){
ElMessage.closeAll()
ElMessage({
showClose: true,
message: '条件格式错误 : '+str+' , 正确条件格式如 : 年龄==10',
type: 'error',
duration:3500,
})
}
const addIcon = (currentObject:any) =>{
@ -83,6 +198,7 @@ const focusEditor = ()=>{
}
defineExpose({
tinymceHtml,
addIcon,
@ -96,12 +212,20 @@ defineExpose({
</script>
<template >
<div >
<editor :id="onlyNumber" v-model="tinymceHtml" :init="tinymceInit"></editor>
<editor :id="onlyNumber" v-model="tinymceHtml" :init="tinymceInit" ></editor>
</div>
<div class="isHidde">
<div ref="tinymceBox" v-html="tinymceHtml"> </div>
</div>
</template>
<style lang='scss' scoped>
.isHidde{
display:none;
position: fixed;
z-index: 1;
margin-top: -10px
}
</style>

125
src/widget/associatedforms/associatedFormsTinyaceRange.vue

@ -46,7 +46,7 @@ let $emit = defineEmits(["textChange"]);
const tinymceHtml = ref("")
tinymceHtml.value = props.aftText
const tinymceBox = ref(null)
onMounted(() => {
@ -54,9 +54,122 @@ onMounted(() => {
});
watch(()=>tinymceHtml.value, (val:any) => {
$emit('textChange',val);
nextTick(()=>{
let formulaOne = [];
let formulaTwo = [];
tinymceBox.value.childNodes.forEach(element => {
element.childNodes.forEach(child => {
formulaOne.push(child.innerText?child.innerText:child.data)
if(child.dataset&&child.dataset.keyid){
formulaTwo.push(child.dataset.keyid)
}else{
formulaTwo.push(child.innerText?child.innerText:child.data)
}
})
});
let suanShitwo = formulaTwo.join('').replace(/\s+/g, "");
let gongShi ={
formulaHtml:tinymceBox.value.innerHTML,
mathsString:tinymceBox.value.innerText,
mathsFormula:suanShitwo,
}
if(containsNewline(gongShi.mathsString)){
errorCondition("条件不允许换行")
}else if(!gongShi.formulaHtml.startsWith("<p><span")){
errorCondition("条件需以蓝色块开头")
}else if(gongShi.formulaHtml.endsWith("</span></p>")){
errorCondition("条件不能以蓝色块结尾")
}else if(countSpanTags(gongShi.formulaHtml)>1){
errorCondition("不允许出现多个蓝色块")
}else if(!containsSingleComparator(gongShi.mathsFormula)){
errorCondition("不存在有效符号")
}else if(checkEnding(gongShi.mathsFormula)){
errorCondition("不能以符号为结尾")
}else{
succCondition()
}
})
},
{ deep: true }
)
function containsSingleComparator(str: string) {
//
const comparators = ['==', '>=', '>', '<=', '<', '!='];
let found = false; //
let i = 0; //
while (i < str.length - 1) { //
//
for (const comparator of comparators) {
if (str.substr(i, comparator.length) === comparator) {
//
if (found) {
// false
return false;
}
found = true; //
//
i += comparator.length - 1;
break; //
}
}
i++; //
}
//
return found;
}
function checkEnding(str: string) {
const symbols = ['==', '>=', '>', '<=', '<', '!=', '='];
const trimmedStr = str.trim();
for (let symbol of symbols) {
if (trimmedStr.endsWith(symbol)) {
return true;
}
}
return false;
}
function containsComparator(str: string) {
if(str.includes("==")||str.includes("!=")||str.includes(">")||str.includes(">=")||str.includes("<")||str.includes("<=")){
return true
}else{
return false
}
}
const containsNewline = (str: string) => {
//console.log("Testing string:", str); //
return /\n/.test(str);
};
const countSpanTags = (str: string) => {
// 使<span>
const matches = str.match(/<span\b[^>]*>/gi);
// matchesnull0
//
return matches ? matches.length : 0;
};
function errorCondition(str:string){
ElMessage.closeAll()
ElMessage({
showClose: true,
//message: ' : '+str+' , : ==10',
message: str,
type: 'error',
duration:3500,
})
}
function succCondition(){
ElMessage.closeAll()
ElMessage({
showClose: true,
message: '条件格式校验通过',
type: 'success',
duration:3500,
})
}
const addIcon = (currentObject:any) =>{
@ -99,10 +212,18 @@ defineExpose({
<div >
<editor :id="onlyNumber" v-model="tinymceHtml" :init="tinymceInit"></editor>
</div>
<div class="isHidde">
<div ref="tinymceBox" v-html="tinymceHtml"> </div>
</div>
</template>
<style lang='scss' scoped>
.isHidde{
display:none;
position: fixed;
z-index: 1;
margin-top: -10px
}
</style>

Loading…
Cancel
Save