Browse Source

关联表单-数据填充规则-v0.33

lwx_v6
liwenxuan 1 year ago
parent
commit
b852651f0d
  1. 33
      src/components/DesignForm/formControlPropertiNew.vue
  2. 258
      src/widget/associatedforms/asfTmFillRoleFilterCondi.vue
  3. 45
      src/widget/associatedforms/associatedFormsChildFillRole.vue

33
src/components/DesignForm/formControlPropertiNew.vue

@ -2101,6 +2101,8 @@ const asfasfMasterFieldTree = ref<Tree[]>()
const asfasfChildTableList = ref<Tree[]>()
const asfasfChildTableFields = ref<Tree[]>()
const asfasfFieldTreeOptionsValue3 = ref<Tree[]>()
let currentChildTableCount = 0
@ -2118,13 +2120,19 @@ function formidChanged(){
let resData = ref(data.children)
let dataExceptChild = JSON.parse(JSON.stringify(data.children))
let dataOnlyChild = JSON.parse(JSON.stringify(data.children))
let dataOnlyChild1 = JSON.parse(JSON.stringify(data.children))
dataExceptChild = dataExceptChild.filter((obj: { type: string }) => obj.type!== 'table');
dataOnlyChild = dataOnlyChild.filter((obj: { type: string }) => obj.type== 'table');
dataOnlyChild1 = dataOnlyChild1.filter((obj: { type: string }) => obj.type== 'table');
/* console.log(dataOnlyChild1)
console.log(dataOnlyChild) */
for(let m = 0;m<dataOnlyChild.length;m++){
dataOnlyChild[m].children = []
}
let resDataExceptChild = ref(dataExceptChild)
let resDataOnlyChild = ref(dataOnlyChild)
let resDataOnlyChild1 = ref(dataOnlyChild1)
console.log(resDataOnlyChild1.value)
//console.log(resDataOnlyChild.value)
let childTableCount = 0
for(let n = 0;n<resDataOnlyChild.value.length;n++){
@ -2155,6 +2163,13 @@ function formidChanged(){
treeAttrs: data.treeAttrs,
disabled:true,
}]
asfasfChildTableFields.value = [{
id: 'rootid_'+data.label,
label: '关联的表单-'+data.label,
children: [...resDataOnlyChild1.value],
treeAttrs: data.treeAttrs,
disabled:true,
}]
}
controlData.value.control.asfasfLabel = data.label
});
@ -2443,13 +2458,19 @@ function associatedFormsDataRangeDialoghandle(){
let resData = ref(data.children)
let dataExceptChild = JSON.parse(JSON.stringify(data.children))
let dataOnlyChild = JSON.parse(JSON.stringify(data.children))
let dataOnlyChild1 = JSON.parse(JSON.stringify(data.children))
dataExceptChild = dataExceptChild.filter((obj: { type: string }) => obj.type!== 'table');
dataOnlyChild = dataOnlyChild.filter((obj: { type: string }) => obj.type== 'table');
dataOnlyChild1 = dataOnlyChild1.filter((obj: { type: string }) => obj.type== 'table');
/* console.log(dataOnlyChild1)
console.log(dataOnlyChild) */
for(let m = 0;m<dataOnlyChild.length;m++){
dataOnlyChild[m].children = []
}
let resDataExceptChild = ref(dataExceptChild)
let resDataOnlyChild = ref(dataOnlyChild)
let resDataOnlyChild1 = ref(dataOnlyChild1)
console.log(resDataOnlyChild1.value)
//console.log(asfasfChildTableList.value)
//console.log(resDataOnlyChild.value)
let childTableCount = 0
@ -2481,7 +2502,13 @@ function associatedFormsDataRangeDialoghandle(){
treeAttrs: data.treeAttrs,
disabled:true,
}]
asfasfChildTableFields.value = [{
id: 'rootid_'+data.label,
label: '关联的表单-'+data.label,
children: [...resDataOnlyChild1.value],
treeAttrs: data.treeAttrs,
disabled:true,
}]
}
});
@ -4553,6 +4580,7 @@ const radioChangeSet = (val:any) => {
v-model:selected-child-table="controlData.control.fillRoles.child[index].tableKey"
v-model:filter-condition="controlData.control.fillRoles.child[index].filterCondition"
v-model:child-roles = "controlData.control.fillRoles.child[index].childRoles"
v-model:child-table-list="asfasfChildTableList"
:asfasf-field-tree="asfasfFieldTree"
:tree-default-props="treeDefaultProps"
:filter-node="filterNode"
@ -4562,8 +4590,9 @@ const radioChangeSet = (val:any) => {
:role-tree="roleTree"
:handle-role-tree-contextmenu-range="handleRoleTreeContextmenuRange"
:associated-forms-current-form-field-tree= "associatedFormsCurrentFormFieldTree"
:asfasf-child-table-fields = "asfasfChildTableFields"
:current-key="controlData.control.fillRoles.child[index].id"
:child-table-list="asfasfChildTableList"
@del-role = "delChildRole"
>
</AssociatedFormsChildFillRole>

258
src/widget/associatedforms/asfTmFillRoleFilterCondi.vue

@ -0,0 +1,258 @@
<script lang='ts' setup>
import { ref, onMounted } from "vue";
import tinymce from "tinymce/tinymce";
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";
let onlyNumber = uuidv4().replaceAll('-','').toString(); //
/**
* 初始富文本组件
*/
const tinymceInit = {
selector: "#"+onlyNumber,
language_url: "/tinymce/langs/zh-Hans.js", // public
language: "zh-Hans", // zh-Hans.js
skin_url: "/tinymce/skins/ui/oxide", //
height: 164, //
statusbar:false,
toolbar:false,
branding: false, //Powered by TinyMCE
menubar: false, //
forced_root_block:'',
newline_behavior:"",
content_css: "/tinymce/skins/content/default/content.css", //csscsscss
auto_focus : true,
}
const props = defineProps({
aftText:{
type: String,
default(){
return {}
}
},
aftTextCopy:{
type: String,
default(){
return {}
}
},
})
let $emit = defineEmits(["textChange","gongshiChange"]);
const tinymceHtml = ref("")
tinymceHtml.value = props.aftText
const tinymceBox = ref(null)
onMounted(() => {
tinymce.init({}); //
});
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,
}
$emit('gongshiChange',gongShi);
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)&&!gongShi.mathsFormula.includes("包含")&&!gongShi.mathsFormula.includes("不包含")){
errorCondition("不存在有效符号或关键字")
}else if(checkEnding(gongShi.mathsFormula)){
errorCondition("不能以符号或关键字为结尾")
}else if(checkRoleStartAndOrgEnd(gongShi.mathsFormula)||checkFormFieldStartAndOrgEnd(gongShi.mathsFormula)||checkFormFieldStartAndOrgEnd2(gongShi.mathsFormula)){
errorCondition("此条件无无实际意义")
}else{
succCondition()
}
})
},
{ deep: true }
)
function checkRoleStartAndOrgEnd(str: string) {
if (str.startsWith('roleid:') && str.endsWith('数据所属部门')) {
return true;
} else {
return false;
}
}
function checkFormFieldStartAndOrgEnd(str: string) {
if (str.startsWith('formField:') && str.endsWith('数据所属部门')) {
return true;
} else {
return false;
}
}
function checkFormFieldStartAndOrgEnd2(str: string) {
if (str.startsWith('formField:') && str.endsWith('数据拥有者')) {
return true;
} else {
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 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) =>{
tinymce.activeEditor?.execCommand('mceInsertContent', false, `<span style="margin:3px;background-color: #4189EF;border-radius: 5px; padding:3px" contenteditable="false" data-keyid= "${currentObject.id}" >${currentObject.label}</span>`);
}
const addIcon_field = (currentObject:any) =>{
tinymce.activeEditor?.execCommand('mceInsertContent', false, `<span style="margin:3px;background-color: #4189EF;border-radius: 5px; padding:3px" contenteditable="false" data-keyid= "${currentObject.id}" >${currentObject.treeAttrs.show}</span>`);
}
const addIcon_org = (currentObject:any) =>{
let id = "orgOrPerson:"+currentObject.id
tinymce.activeEditor?.execCommand('mceInsertContent', false, `<span style="margin:3px;background-color: #4189EF;border-radius: 5px; padding:3px" contenteditable="false" data-keyid= "${id}" >${currentObject.label}</span>`);
}
//
const handelCancel = (associatedFormsHideDialogTextCopy:any) =>{
tinymceHtml.value = associatedFormsHideDialogTextCopy
}
const tinymceReInit = ()=>{
//console.log(props.aftTextCopy)
let str:string = props.aftTextCopy
tinymceHtml.value = props.aftTextCopy
}
const focusEditor = ()=>{
tinymce.EditorManager.get(onlyNumber)?.focus(true)
}
defineExpose({
tinymceHtml,
addIcon,
addIcon_org,
addIcon_field,
handelCancel,
tinymceReInit,
focusEditor,
})
</script>
<template >
<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>

45
src/widget/associatedforms/associatedFormsChildFillRole.vue

@ -1,12 +1,12 @@
<!-- eslint-disable vue/no-v-html -->
<template>
<div
style="background-color: #F0F0F0;padding: 12px;border-radius: 5px;padding-left:45px;margin-bottom:20px;margin-right:11px;min-height: 65px;padding-top: 16px;color: black;">
style="background-color: #F0F0F0;padding: 12px;border-radius: 5px;padding-left:45px;margin-bottom:20px;margin-right:11px;min-height: 65px;padding-top: 16px;padding-bottom:16px;color: black;"><!-- {{asfasfChildTableFields}} -->
<el-button
:icon="Close" size="small" circle type="info" plain
style="float: right;margin-top: -22px;margin-right: -22px" @click="delRole" />
<el-tree-select
v-model="selectedChildTable1" style="width: 270px;margin-bottom: -1px" :data="childTableList"
v-model="selectedChildTable1" style="width: 270px;margin-bottom: -1px" :data="childTableList1"
placeholder="请选择关联表单子表" check-strictly :render-after-expand="false" filterable
@change="selectedChildTableChanged" />
<el-popover placement="top-end" title="" :width="200" trigger="hover" content="若【设置筛选条件】,则仅填充满足筛选条件的子表数据">
@ -26,14 +26,14 @@
v-if="selectedChildTable1 !== ''"
style="background-color: #F0F0F0;border-radius: 5px;padding-bottom: 1px;margin-right: 10px;"><!-- #F5F7FA #E6F3FE #F0F0F0 #F5F7FA-->
<template v-for="(item, index) in childRoles" :key="childRoles[index].id">
<div style="display: flex;margin-bottom: 10px;">
<div style="display: flex;margin-bottom: 10px;"><!-- {{ asfasfChildTableFields[0].children.filter((item :any)=>{return item.id==selectedChildTable}) }} -->
<el-tree-select
v-model="leftValue1" style="width: 270px;" :data="leftTreeSource" placeholder="关联表单表字段"
v-model="leftValue1" style="width: 270px;" :data="asfasfChildTableFields[0].children.filter((item :any)=>{return item.id==selectedChildTable})" placeholder="关联表单表字段"
check-strictly :render-after-expand="false" filterable @change="leftChanged" />
<span style="margin-left: 8px;margin-right: 8px;">的值填充到</span>
<el-tree-select
v-model="rightValue1" style="width: 270px;" :data="rightTreeSource"
check-strictly :render-after-expand="false" placeholder="当前表单字段" filterable @change="rightChanged" />
check-strictly :render-after-expand="false" placeholder="当前表单子表字段" filterable @change="rightChanged" />
<Delete style="width: 22px; height: 22px;cursor: pointer; color: #50A6FF; display: block; float:right;margin-left: 35px;margin-top: 4px;" @click="delChildRole(item)" />
</div>
@ -41,7 +41,7 @@
</template>
</div>
<el-link v-if="selectedChildTable1 !== ''" type="primary" @click="addChildRole"> 添加规则</el-link>
<el-link v-if="selectedChildTable1 !== ''" type="primary" style="margin-bottom: 10px;" @click="addChildRole" > 添加规则</el-link>
</div>
@ -75,10 +75,10 @@
style="border: 1px solid gainsboro; height: 7%; border-bottom: 0px; padding-top: 3px; padding-left: 5px; background-color: #E6F3FE;">
仅可选择符合以下条件的数据</div>
<div id="associatedFormsHideEditArea" style="border: 1px solid gainsboro; height: 38%; border-bottom: 0px;">
<AssociatedFormsTinyaceFillRoleFilterCondition
<AsfTmFillRoleFilterCondi
ref="tinymceRef" :aft-text="filterCondition1.conditionHtml"
:aft-text-copy="filterCondition1.conditionHtmlCopy" @text-change="aftTextChangedRange"
@gongshi-change="aftGongshiChangedRange"></AssociatedFormsTinyaceFillRoleFilterCondition>
@gongshi-change="aftGongshiChangedRange"></AsfTmFillRoleFilterCondi>
</div>
<div style="border: 1px solid gainsboro; height: 55%; padding-top: 20px;">
<ul>
@ -110,10 +110,16 @@
<script setup lang="ts">
import { Close } from '@element-plus/icons-vue'
import AssociatedFormsTinyaceFillRoleFilterCondition from '@/widget/associatedforms/associatedFormsTinyaceFillRoleFilterCondition.vue'
import AsfTmFillRoleFilterCondi from '@/widget/associatedforms/asfTmFillRoleFilterCondi.vue'
import { v4 as uuidv4 } from "uuid";
let emit = defineEmits(["delRole", "update:selectedChildTable",]);
let emit = defineEmits(["delRole", "update:selectedChildTable","update:childTableList"]);
const props = defineProps({
asfasfChildTableFields: {
type: Object,
default() {
return {}
}
},
orgAndManTree: {
type: Object,
default() {
@ -191,6 +197,9 @@ const filterConditionDialogFlag = ref(false)
const selectedChildTable1 = ref()
selectedChildTable1.value = props.selectedChildTable
const childTableList1 = ref()
childTableList1.value = props.childTableList
const childRoles1 = ref()
childRoles1.value = props.childRoles
@ -199,6 +208,14 @@ filterCondition1.value = props.filterCondition
/* for(let i=0;i<props.asfasfChildTableFields.value[0].children.length;i++){
childTable.push({
id:props.asfasfChildTableFields.value[0].children[i].id
})
}
*/
function filterConditionDialogHandle() {
filterConditionDialogFlag.value = !filterConditionDialogFlag.value
}
@ -215,6 +232,14 @@ function aftGongshiChangedRange(gongshi: any) {
function selectedChildTableChanged() {
emit('update:selectedChildTable', selectedChildTable1)
//,
console.log(childTableList1.value)
for(let i = 0;i<childTableList1.value[0].children.length;i++){
if(childTableList1.value[0].children[i].id==selectedChildTable1.value){
childTableList1.value[0].children[i].disable = true
}
}
emit('update:childTableList', childTableList1)
}
function delChildRole(item: any) {

Loading…
Cancel
Save