Browse Source

关联表单多变量数据填充条件

lwx_v14
liwenxuan 1 year ago
parent
commit
1cd3aed35b
  1. 2
      src/components/DesignForm/formControlPropertiNew.vue
  2. 9
      src/components/DesignForm/public/form/form.vue
  3. 19
      src/widget/associatedforms/associatedForms.vue
  4. 45
      src/widget/associatedforms/associatedFormsTinyaceRange.vue

2
src/components/DesignForm/formControlPropertiNew.vue

@ -4821,7 +4821,7 @@ const radioChangeSet = (val:any) => {
<el-main style="border: 1px solid gainsboro; padding: 3px;" class="associatedFormsHideDialogMain">
<div 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;">
<AssociatedFormsTinyaceRange ref="aftRange" :aft-text="controlData.control.dataRangeConditionHtml" :aft-text-copy = "controlData.control.dataRangeConditionHtmlCopy" @text-change = "aftTextChangedRange" @gongshi-change = "aftGongshiChangedRange"></AssociatedFormsTinyaceRange>
<AssociatedFormsTinyaceRange ref="aftRange" :aft-text="controlData.control.dataRangeConditionHtml" :aft-text-copy = "controlData.control.dataRangeConditionHtmlCopy" :current-form = "props.customerformid" @text-change = "aftTextChangedRange" @gongshi-change = "aftGongshiChangedRange"></AssociatedFormsTinyaceRange>
<!-- <div style="border: 1px solid #4189EF;width:90px;height:26px;border-radius: 3px;padding:2px;text-align: center;cursor:pointer;float: right;margin-top: -32px;margin-right: 5px;z-index:99999999;position: relative;">
<span style="color: #4189EF;font:6px;margin-right: 5px;">fx</span>插入函数
</div> -->

9
src/components/DesignForm/public/form/form.vue

@ -443,6 +443,8 @@ if(formProps.value.type!=5){
return hideFieldArr
}
let asfRangeDoubleCondiChangeObj = ref()
provide('asfRangeDoubleCondiChangeObj',asfRangeDoubleCondiChangeObj)
let oldModelStr = ""
watch(() => model.value,(newVal) => {
@ -472,7 +474,12 @@ watch(() => model.value,(newVal) => {
let field = a[a.length-1]
if(currentChangeKey==field){
let toShowDoubleCondiValVal = model.value[currentChangeKey]
console.log("关联表单"+asfName+"应该更新其选项,只显示doubleCondiVal为"+toShowDoubleCondiValVal+"的选项")
//console.log(""+asfName+",doubleCondiVal"+toShowDoubleCondiValVal+"")
let obj = {
asfName:asfName,
toShowDoubleCondiValVal:toShowDoubleCondiValVal
}
asfRangeDoubleCondiChangeObj.value = obj
//console.log(field)
}
}

19
src/widget/associatedforms/associatedForms.vue

@ -16,7 +16,7 @@
<script lang='ts' setup>
import request from '@/utils/request';
import { formProps } from 'element-plus';
import { inject } from 'vue'
import { FormItem, FormList } from '@/api/DesignForm/types'
/* const props = defineProps({
// eslint-disable-next-line vue/require-default-prop
@ -31,6 +31,21 @@ import { FormItem, FormList } from '@/api/DesignForm/types'
},
}) */
const asfRangeDoubleCondiChangeObj = inject('asfRangeDoubleCondiChangeObj')
watch(() => asfRangeDoubleCondiChangeObj,(newVal:any) => {
value1.value = ""
value2.value = ""
//console.log(newVal.value)
let newValObj = JSON.parse(JSON.stringify(newVal.value));
//console.log(newValObj)
//console.log(asfDataTitlesData)
let toShowDoubleCondiValValStr = newValObj.toShowDoubleCondiValVal+"";
//console.log(toShowDoubleCondiValValStr)
const filteredData = asfDataTitlesData.filter((item: any) => item.doubleCondiVal == toShowDoubleCondiValValStr);
//console.log(filteredData)
options.value = filteredData
//console.log(options.value)
},{deep: true})
const props = withDefaults(
defineProps<{
data: FormList
@ -56,9 +71,11 @@ function hasTableProperty(obj: object): boolean {
}
return false;
}
let asfDataTitlesData: any = []
onMounted(()=>{
if(props.data.control.formid!=null&&props.data.control.formid!=""){
getAsfDataTitles().then(({ data }) => {
asfDataTitlesData = data
//console.log(data)
options.value = data
value1.value = props.formProps.model[props.data.name]

45
src/widget/associatedforms/associatedFormsTinyaceRange.vue

@ -40,6 +40,12 @@ const props = defineProps({
return {}
}
},
currentForm:{
type: String,
default(){
return {}
}
},
})
let $emit = defineEmits(["textChange","gongshiChange"]);
@ -74,16 +80,45 @@ watch(()=>tinymceHtml.value, (val:any) => {
mathsString:tinymceBox.value.innerText,
mathsFormula:suanShitwo,
}
/*
console.log(props.currentForm)
console.log(countSpanTags(gongShi.formulaHtml)) */
$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(countSpanTags(gongShi.formulaHtml)>=2){
if(countSpanTags(gongShi.formulaHtml)>2){
errorCondition("不允许超过2个蓝色块")
}else{
if(!gongShi.formulaHtml.endsWith("</span></p>")){
errorCondition("请检查您的条件")
}else{
/* console.log(gongShi)
console.log(props.currentForm) */
const parts = gongShi.formulaHtml.split(':');
if (parts.length >= 2) {
const result = parts[parts.length - 2];
//console.log(result);
if(result.startsWith("table")){
errorCondition("第二个蓝色块不支持选择子表中的字段")
}else{
if(props.currentForm+""==result){
//console.log(result)
succCondition()
}else{
//errorCondition(",: .A==.B")
errorCondition("请对调这两个蓝色块")
}
}
} else {
console.log("输入的字符串不符合预期格式");
}
}
}
}else if(!containsSingleComparator(gongShi.mathsFormula)&&!gongShi.mathsFormula.includes("包含")&&!gongShi.mathsFormula.includes("不包含")){
errorCondition("不存在有效符号或关键字")

Loading…
Cancel
Save