ludc
2023-05-30 e9b405657b6117a8dcfcf8505cfd5d6eccd39cc8
Source/UBCS-WEB/src/components/code-dialog-page/referConfigFormDialog.vue
@@ -64,7 +64,7 @@
                                class="crud-attr"
                                :option="attrOption"
                                @cell-click="clickAttrEdit"
                                :data="attrData">
                                :data="codeShowFieldConfigVOS">
                                <!-- 表格内操作按钮 -->
                                <template slot="menu" slot-scope="scope">
                                    <el-button type="text"
@@ -90,7 +90,7 @@
                                    </el-button>
                                    <div class="tag-group" style="display: inline">
                                        <el-tag
                                            v-for="item in attrData"
                                            v-for="item in codeShowFieldConfigVOS"
                                            v-show="item.isquery && item.title!=''"
                                            style="margin-left: 3px"
                                            :key="item.title"
@@ -105,12 +105,12 @@
                        </el-row>
                    </el-tab-pane>
                    <el-tab-pane name="second">
                        <span slot="label"><i class="el-icon-search"></i>查询条件添加</span>
                        <span slot="label"><i class="el-icon-search"></i>添加查询条件</span>
                        <avue-crud
                            ref="crudAddCondition"
                            :option="addSearchCondtionOption" 
                            @cell-click="clickAddSearchCondtionEdit"
                            :data="addSearchCondtionData">
                            :data="form.codeSrchCondConfigVOS">
                            <!-- 表格内操作按钮 -->
                            <template slot="menu" slot-scope="scope">
                                <el-button type="text"
@@ -276,6 +276,11 @@
                    paramForFormKey: '',
                    isMuti: false,
                    mapFields: '',
                    isOpenGlobal: true, //是否开启全局
                    codeSrchCondConfigVOS: [],
                    isPersistence: true, // 是否持久化
                    id: '',
                    name: '',
                     // 查询条件列表
                    // limit: '15',
                    // sortField: '',
@@ -288,7 +293,21 @@
                    // loadType: 'all',
                    // onlyLeaf: false,
                },
                attrData: [],
                // type切换时对form表单属性进行移除
                removeFormAttr: [
                    'limit',
                    'sortField',
                    'sortType',
                    'parentFieldName',
                    'parentUsedField',
                    'parentValue',
                    'loadType',
                    'onlyLeaf',
                    'sortType',
                    'referContent',
                    'displayTable',
                ],
                codeShowFieldConfigVOS: [],
                attrOption: {
                    height:'180',
                    tip: false,
@@ -353,7 +372,7 @@
                            blur: (value) => this.updateAttrBlur(value),
                        },{
                            label: "排序字段",
                            prop: "sortField",
                            prop: "attrSortField",
                            cell: true,
                            clearable: false,
                            blur: (value) => this.updateAttrBlur(value),
@@ -365,7 +384,7 @@
                            blur: (value) => this.updateAttrBlur(value),
                        },{
                            label: "列固定位置",
                            prop: "fixedText",
                            prop: "fixedPosition",
                            cell: true,
                            type:"select",
                            clearable: false,
@@ -381,7 +400,7 @@
                        },
                    ]
                },
                addSearchCondtionData: [],
                // addSearchCondtionData: [],
                addSearchCondtionOption: {
                    height:'150',
                    tip: false,
@@ -434,6 +453,7 @@
                        }
                    ]
                },
                // 两个表单的ref
                formRefs: ['form','otherForm'],
                // tabs控制
@@ -677,7 +697,7 @@
                            icon: 'el-icon-info',
                            label: '必填的参照配置',
                            collapse: true,
                            labelWidth: '110',
                            labelWidth: '115',
                            prop: 'groupDdefaultOrGrid',
                            column: [
                                {
@@ -769,23 +789,11 @@
                                        trigger: "blur",
                                    }],
                                    change: ({ value, column }) => {
                                        // console.log("start",value);
                                        // 复原表单,因为其他分组中如果存在值,在切换时,会保留输入的字段值所以需要还原
                                        let oldForm = this.form;
                                        this.form = {};  // 表单对象赋空
                                        this.form.referType = oldForm.referType
                                        this.form.textField = oldForm.textField
                                        this.form.valueField = oldForm.valueField
                                        this.form.type = oldForm.type //参照窗口类型
                                        this.form.url =  oldForm.url
                                        this.form.backPath =  oldForm.backPath
                                        this.form.method =  oldForm.method
                                        this.form.height =  oldForm.height
                                        this.form.useFormKey =  oldForm.useFormKey
                                        this.form.paramForFormKey =  oldForm.paramForFormKey
                                        this.form.isMuti =  oldForm.isMuti
                                        this.form.mapFields =  oldForm.mapFields
                                        let addFrom = {};  //根据类型需要添加的不同属性
                                        this.activeName = 'first';
                                        let addFrom = {};
                                        this.activeName = 'first'; // 默认切换至第一个tab
                                        //根据类型对form表单属性进行调整
                                        if(value == 'stand'){
                                            addFrom = {
                                                referContent: '',
@@ -809,72 +817,108 @@
                                                sortField: '',
                                                sortType: 'asc',
                                            };
                                            console.log('tree');
                                            // 不知道为什么type为tree的时候会触发两次change事件
                                            // 导致type切换失败
                                            this.form.type = 'tree';
                                            this.isDisabledTabs = false;
                                        }else {
                                            this.isDisabledTabs = true;
                                            this.activeName = 'second';
                                        }
                                       // 类型切换时,对不需要的属性进行筛除
                                        this.removeFormAttr.forEach(attr=>{
                                            // console.log(attr);
                                            this.$delete(this.form,attr)
                                        })
                                        // 合并两个表单
                                        this.form = Object.assign(addFrom,this.form);
                                        // console.log("endFilter",this.form.type);
                                        //console.log(this.form);
                                    },
                                },{
                                    label: '是否开启持久化',
                                    prop: 'isPersistence',
                                    tip: 'true:开启持久化,对当前定义的参照配置进行持久化存储,下次可直接选取;false:仅对当前次码段新增生效。',
                                    tipPlacement: 'bottom',
                                    span: 6,
                                    type: 'switch',
                                },{
                                    display: this.form.isPersistence | this.form.isPersistence=='true',
                                    label: '编号',
                                    prop: 'id',
                                    rules: [{
                                        required: true,
                                        message: "(开始持久化时编号)必填项不能为空",
                                        trigger: "blur",
                                    }],
                                    span: 6,
                                },{
                                    display: this.form.isPersistence | this.form.isPersistence=='true',
                                    label: '名称',
                                    prop: 'name',
                                    rules: [{
                                        required: true,
                                        message: "(开始持久化时名称)必填项不能为空",
                                        trigger: "blur",
                                    }],
                                    span: 6,
                                }
                            ]
                        },
                        {   
                            //display: this.form.type=='default'||this.form.type=='grid',
                            icon: 'el-icon-info',
                            label: '页面参数配置',
                            collapse: false,
                            prop: 'webConfig',
                            column: [{
                                label: '窗口显示的高度',
                                prop: 'height',
                                tip: '默认空着,设置后表示强制显示这样的高度',
                                tipPlacement: 'right',
                                span: 7,
                                rules:[{
                                    validator: validateNumber,
                                    message: "窗口显示的高度必须为数值类型",
                                    trigger: "blur",
                                }]
                            },{
                                label: '过滤(级联)属性',
                                prop: 'useFormKey',
                                tip: '获取表单上的其他属性的属性的值来过滤,或者使用某个属性来级联选择',
                                tipPlacement: 'right',
                                span: 7,
                            },{
                                label: '过滤属性请求参数',
                                prop: 'paramForFormKey',
                                tip: '使用过滤属性时,发送给后台的请求参数',
                                tipPlacement: 'right',
                                span: 7,
                            },{
                                label: '映射其他属性',
                                prop: 'mapFields',
                                tip: '选择数据后,将选择的数据拷贝到表单里的其他属性,书写格式为{当前表单上的属性:选择数据里的属性,XXXXx:yyyy}',
                                tipPlacement: 'right',
                                span: 7,
                            },{
                                label: '是否开启全局',
                                prop: 'isOpenGlobal',
                                tip: '开启全局之后对全部参照配置数据进行查询,默认根据租户进行查询。',
                                tipPlacement: 'right',
                                type: 'switch',
                                span: 7,
                            },{
                                label: '是否多选',
                                type: 'switch',
                                prop: 'isMuti',
                                value: false,
                                span: 7,
                                row: true,
                            }]
                            column: [
                                {
                                    label: '窗口显示的高度',
                                    prop: 'height',
                                    tip: '默认空着,设置后表示强制显示这样的高度',
                                    tipPlacement: 'right',
                                    span: 7,
                                    rules:[{
                                        validator: validateNumber,
                                        message: "窗口显示的高度必须为数值类型",
                                        trigger: "blur",
                                    }]
                                },{
                                    label: '过滤(级联)属性',
                                    prop: 'useFormKey',
                                    tip: '获取表单上的其他属性的属性的值来过滤,或者使用某个属性来级联选择',
                                    tipPlacement: 'right',
                                    span: 7,
                                },{
                                    label: '过滤属性请求参数',
                                    prop: 'paramForFormKey',
                                    tip: '使用过滤属性时,发送给后台的请求参数',
                                    tipPlacement: 'right',
                                    span: 7,
                                },{
                                    label: '映射其他属性',
                                    prop: 'mapFields',
                                    tip: '选择数据后,将选择的数据拷贝到表单里的其他属性,书写格式为{当前表单上的属性:选择数据里的属性,XXXXx:yyyy}',
                                    tipPlacement: 'right',
                                    span: 7,
                                },{
                                    label: '是否开启全局',
                                    prop: 'isOpenGlobal',
                                    tip: '开启全局之后对全部参照配置数据进行查询,默认根据租户进行查询。',
                                    tipPlacement: 'right',
                                    type: 'switch',
                                    span: 7,
                                },{
                                    label: '是否多选',
                                    type: 'switch',
                                    prop: 'isMuti',
                                    value: false,
                                    span: 7,
                                    row: true,
                                }
                            ]
                        },
                        {   
                            //display: this.form.type=='default'||this.form.type=='grid',
                            icon: 'el-icon-info',
                            label: '后台参数配置',
                            collapse: false,
@@ -886,29 +930,29 @@
                                tip: '通常为空;如果是列表,后台必须返回DataGrid,如果是树,后台必须返回List<Tree>',
                                tipPlacement: 'right',
                                span: 7,
                            },{
                                label: '服务的地址',
                                prop: 'backPath',
                                tip: '通常为空,在支持微服务或者分布式部署的时候才配置',
                                tipPlacement: 'right',
                                span: 7,
                            },{
                                label: '请求后台的协议方式',
                                prop: 'method',
                                tip: 'HTTP的协议方式,支持POST,PUT,GET,一般都是GET',
                                tipPlacement: 'right',
                                span: 7,
                                value: 'GET',
                                type: 'select',
                                dicData: [{
                                    label:'GET',value: "GET"
                                },{
                                    label:'PUT',value: "PUT"
                                    label: '服务的地址',
                                    prop: 'backPath',
                                    tip: '通常为空,在支持微服务或者分布式部署的时候才配置',
                                    tipPlacement: 'right',
                                    span: 7,
                                },{
                                    label: '请求后台的协议方式',
                                    prop: 'method',
                                    tip: 'HTTP的协议方式,支持POST,PUT,GET,一般都是GET',
                                    tipPlacement: 'right',
                                    span: 7,
                                    value: 'GET',
                                    type: 'select',
                                    dicData: [{
                                        label:'GET',value: "GET"
                                    },{
                                        label:'PUT',value: "PUT"
                                    },
                                    {
                                        label:'POST',value: "POST"
                                    }],
                                },
                                {
                                    label:'POST',value: "POST"
                                }],
                            },
                            ]
                        },
                    ]
@@ -931,21 +975,21 @@
                                {
                                    label: '每页显示条数',
                                    prop: 'limit',
                                    span: 7,
                                    span: 8,
                                    tip: '分页时每页显示的数量,不分页填-1',
                                    //value: 15,
                                    tipPlacement: 'right',
                                },{
                                    label: '排序字段',
                                    prop: 'sortField',
                                    span: 7,
                                    span: 8,
                                    tip: '查询数据时的排序字段',
                                    //clearable: false,
                                    tipPlacement: 'right',
                                },{
                                    label: '排序类型',
                                    prop: 'sortType',
                                    span: 7,
                                    span: 8,
                                    dicData: [{
                                        label: '升序', value: 'asc'
                                    }, {
@@ -968,14 +1012,14 @@
                                {
                                    label: '参考的UI上下文',
                                    prop: 'referContent',
                                    span: 7,
                                    span: 8,
                                    tip: '只有参照窗口类型是stand时才必须设置,且在stand类型下才能生效',
                                    tipPlacement: 'right',
                                },
                                {
                                    label: '平台的表格编号',
                                    prop: 'displayTable',
                                    span: 7,
                                    span: 8,
                                    tip: '与参照的UI上下文互斥,只有参照窗口类型是stand时才必须设置,且在stand类型下才能生效',
                                    tipPlacement: 'right',
                                },
@@ -1076,8 +1120,7 @@
        },
        watch: {
            // 贼坑,切换类型时表格,隐藏再显示就会出现表格错位问题,
            'form.type'(val) {
                //console.log(val);
            'form.type'(value) {
                this.onloadAttrData();
            }
        },
@@ -1086,33 +1129,39 @@
            // 单击表格实现表格行编辑
            clickAttrEdit(row, column, event){
                if(this.preClickAttrRow && this.preClickAttrRow != row){
                    //console.log(this.attrData[this.preClickAttrRow.$index]);
                    this.attrData[this.preClickAttrRow.$index].$cellEdit = false;
                    //console.log(this.codeShowFieldConfigVOS[this.preClickAttrRow.$index]);
                    this.codeShowFieldConfigVOS[this.preClickAttrRow.$index].$cellEdit = false;
                }
                row.$cellEdit = true;
                this.preClickAttrRow = row;
            },
            // 属性表格行编辑失去焦点时保存方法
            // updateAttrBlur(value){
                //console.log(this.attrData[0]);
                //console.log(this.codeShowFieldConfigVOS[0]);
                
            // },
            // 单击表格实现表格行编辑
            clickAddSearchCondtionEdit(row, column, event){
                if(this.preClickAddSearchConditionRow && this.preClickAddSearchConditionRow != row){
                    //console.log(this.attrData[this.preClickAttrRow.$index]);
                    this.addSearchCondtionData[this.preClickAddSearchConditionRow.$index].$cellEdit = false;
                    //console.log(this.codeShowFieldConfigVOS[this.preClickAttrRow.$index]);
                    this.form.codeSrchCondConfigVOS[this.preClickAddSearchConditionRow.$index].$cellEdit = false;
                }
                row.$cellEdit = true;
                this.preClickAddSearchConditionRow = row;
            },
            //上一个页面已经选中参照应用的业务类型的情况,和上一次已经配置过参照配置的情况下进行页面初始化渲染
            initPageData(val){
                console.log(val);
                //console.log(val);
                if(func.notEmpty(val.referConfig)){
                    this.form = JSON.parse(val.referConfig);
                    //console.log(val);
                    // console.log(this.form);
                    this.form.isPersistence = this.form.isPersistence == 'true' ? true:false;
                    // 参照引用的业务类型不可选
                    this.referTypeIsReadOnly = true;
                    if((this.form.type == 'default' || this.form.type  == 'grid') && (this.form.codeShowFieldConfigVOS != undefined && this.form.codeShowFieldConfigVOS.length > 0)){
                        this.codeShowFieldConfigVOS = this.form.codeShowFieldConfigVOS;
                    }
                    return;
                }
                if(func.notEmpty(val.referType)){
@@ -1127,7 +1176,6 @@
            async selectedListReferConfig(){
                // 标记所有表单是否通过校验的变量
                let isValid = true;
                // 遍历表单数组,依次对每个表单进行校验
                await this.formRefs.forEach(ref => {
                    this.$refs[ref].validate((valid, done, msg) => {
@@ -1142,12 +1190,11 @@
                        done();
                    })
                })
                // 如果所有表单都校验通过,执行提交操作
                if (isValid) {
                    // 根据类型对form表单中的参数进行过滤,只保留非空且需要的属性
                    let submitForm = this.filterForm();
                    //console.log(submitForm);
                    // console.log(submitForm);
                    this.$emit('echoReferConfig', submitForm) // 触发update:data将子组件值传递给父组件
                    this.isShowReferConfigForm = false;
                }
@@ -1155,14 +1202,14 @@
            /** 其实选取属性表格的默认数据不需要加载,
             但是弹窗打开会有表格错行问题所以需要在这调用doLayout方法*/
            onloadAttrData(){
                this.attrData = [
                this.codeShowFieldConfigVOS = [
                    {
                        field: 'id',
                        title: '编号',
                        fieldType: 'text',
                        fieldTypeText: '文本框',
                        sort: true,
                        sortField: 'id',
                        attrSortField: 'id',
                        width: '150',
                        isquery: true,
                        $cellEdit: false
@@ -1172,7 +1219,7 @@
                        fieldType: 'text',
                        fieldTypeText: '文本框',
                        sort: true,
                        sortField: 'name',
                        attrSortField: 'name',
                        width: '180',
                        isquery: true,
                        $cellEdit: false
@@ -1185,10 +1232,10 @@
            // 属性选择表格中的移除按钮功能
            removeCurrentRow(row,condition){
                if(condition=='removeAttr'){
                    this.$delete(this.attrData, row.$index);
                    this.$delete(this.codeShowFieldConfigVOS, row.$index);
                    return;
                }
                this.$delete(this.addSearchCondtionData, row.$index);
                this.$delete(this.form.codeSrchCondConfigVOS, row.$index);
            },
            // 该界面的数据进行初始化复原
            recoveryDataAndForm(condition){
@@ -1224,7 +1271,9 @@
                    'paramForFormKey',
                    'isMuti',
                    'mapFields', 
                    'searchCondition',
                    'codeSrchCondConfigVOS',
                    'isOpenGlobal', //是否开启全局
                    'isPersistence',
                ];
                let addArray = [];
                let newForm ={};
@@ -1244,14 +1293,18 @@
                        'sortType'
                    ];
                }
                // 开启持久化参照配置
                if(oldForm.isPersistence=='true' | oldForm.isPersistence){
                    submittDefaultForm =  submittDefaultForm.concat(['id','name'])
                }
                submittDefaultForm = submittDefaultForm.concat(addArray);
                if(!this.checkArrayIsUndefined(this.addSearchCondtionData)){
                if(!this.checkArrayIsUndefined(this.form.codeSrchCondConfigVOS)){
                    newForm = {
                        searchCondition: this.addSearchCondtionData,
                        codeSrchCondConfigVOS: this.form.codeSrchCondConfigVOS,
                    }
                }
                if((oldForm.type == 'default' || oldForm.type  == 'grid') && (this.attrData.length >= 0 && !this.checkArrayIsUndefined(this.addSearchCondtionData))){
                    newForm = Object.assign(newForm,{attrData:this.attrData});
                if((oldForm.type == 'default' || oldForm.type  == 'grid') && (this.codeShowFieldConfigVOS.length >= 0 && !this.checkArrayIsUndefined(this.codeShowFieldConfigVOS))){
                    newForm = Object.assign(newForm,{codeShowFieldConfigVOS:this.codeShowFieldConfigVOS});
                }
                // 过滤出空值属性和不需要的属性
                submittDefaultForm.forEach(item=>{
@@ -1261,7 +1314,7 @@
                        newForm = Object.assign(newForm,{[item]:oldForm[item]});  
                    }
                });
                // console.log(newForm);
                //console.log(newForm);
                return newForm;
            },
            /**
@@ -1488,14 +1541,14 @@
                }
                //this.showFieldSelectList;
                this.showFieldSelectList.forEach(item => {
                    this.attrData.push(
                    this.codeShowFieldConfigVOS.push(
                        {
                            field: item.id,
                            title: item.id,
                            fieldType: item.attrType,
                            fieldTypeText: item.attrTypeText,
                            sort: false,
                            sortField: item.id,
                            attrSortField: item.id,
                            width: item.attrLength,
                            isquery: false,
                            $cellEdit: false
@@ -1550,16 +1603,17 @@
                this.sortFieldOnLoad();
            },
            selectedSearchCondition(){
                console.log(this.searchConditionSelectList);
                // console.log(this.searchConditionSelectList);
                if(this.searchConditionSelectList.length <= 0) {
                    this.$message.warning("请至少选择一条数据");
                    return;
                }
                this.searchConditionSelectList.forEach(item => {
                    this.addSearchCondtionData.push(
                    this.form.codeSrchCondConfigVOS.push(
                        {
                            filterField: item.id,
                            filterType: '=',
                            filterTypeText: item.name,
                            filterValue: '',
                            $cellEdit: false
                        }