From 54015e3d0c4a004e067dd3a07baaa02e8b9d7a85 Mon Sep 17 00:00:00 2001 From: Administrator <123456> Date: Tue, 25 May 2021 20:08:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=B1=E6=80=9D=E7=A6=B9=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=EF=BC=9A=E6=95=99=E5=B8=88=E4=BF=A1=E6=81=AFvue=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fieldComponent/FieldRowItem.vue | 179 ++++++++++++++++++ .../formCommon/EditAndViewForm.vue | 89 +++++++-- .../systemConfig/FieldAttributeConfig.vue | 83 ++++---- .../teacherInfo/systemConfig/FieldItem.vue | 32 +++- .../teacherInfo/systemConfig/FieldRowItem.vue | 109 ----------- .../teacherInfo/systemConfig/FormDesign.vue | 171 +++++++++++------ .../attributeConfig/ColItemAttribute.vue | 47 +++++ .../attributeConfig/FieldRowItemAttribute.vue | 73 +++++++ .../systemConfig/fieldAndFormConfig.js | 3 +- .../systemConfig/style/fieldRowItem.scss | 17 +- 10 files changed, 564 insertions(+), 239 deletions(-) create mode 100644 src/views/teacherInfo/fieldComponent/FieldRowItem.vue delete mode 100644 src/views/teacherInfo/systemConfig/FieldRowItem.vue create mode 100644 src/views/teacherInfo/systemConfig/attributeConfig/ColItemAttribute.vue create mode 100644 src/views/teacherInfo/systemConfig/attributeConfig/FieldRowItemAttribute.vue diff --git a/src/views/teacherInfo/fieldComponent/FieldRowItem.vue b/src/views/teacherInfo/fieldComponent/FieldRowItem.vue new file mode 100644 index 0000000..1e2160b --- /dev/null +++ b/src/views/teacherInfo/fieldComponent/FieldRowItem.vue @@ -0,0 +1,179 @@ + + + + + diff --git a/src/views/teacherInfo/formCommon/EditAndViewForm.vue b/src/views/teacherInfo/formCommon/EditAndViewForm.vue index a55b7a0..6f0d3f7 100644 --- a/src/views/teacherInfo/formCommon/EditAndViewForm.vue +++ b/src/views/teacherInfo/formCommon/EditAndViewForm.vue @@ -165,6 +165,7 @@ loadingTip:"加载数据中,请稍候...", approveType:1, showComment:false, + submitFieldList:[], } }, methods:{ @@ -334,15 +335,6 @@ remarkList: ["("+this.BaseConfig.person_info_my.bureau_name+(this.BaseConfig.person_info_my.dep_name && this.BaseConfig.person_info_my.dep_name !== "" && this.BaseConfig.person_info_my.bureau_name !== this.BaseConfig.person_info_my.dep_name?"/" + this.BaseConfig.person_info_my.dep_name:"")+")"], isHasChild:false, - // childList:[{childDataType:2,personInfo: { - // node_label:"操作人:" + this.BaseConfig.userInfo.person_name_cookie, - // person_id:this.BaseConfig.userInfo.person_id_cookie, - // time_stamp:"2021-04-20 15:30:30", - // remarkList: ["("+this.BaseConfig.person_info_my.bureau_name+(this.BaseConfig.person_info_my.dep_name && this.BaseConfig.person_info_my.dep_name !== "" - // && this.BaseConfig.person_info_my.bureau_name !== this.BaseConfig.person_info_my.dep_name?"/" + this.BaseConfig.person_info_my.dep_name:"")+")"], - // },title:"数据变更",list:[{name:"变更1",old_value:"旧值1",new_value:"新值1"},{name:"变更2",old_value:"旧值2",new_value:"新值2"},{name:"变更3",old_value:"旧值3",new_value:"新值3"}, - // {name:"变更4",old_value:"旧值4",new_value:"新值4"},{name:"变更5",old_value:"旧值5",new_value:"新值5"},{name:"变更6",old_value:"旧值6",new_value:"新值6"}, - // {name:"变更7",old_value:"旧值7",new_value:"新值7"},{name:"变更8",old_value:"旧值8",new_value:"新值8"}]}] } return record; }, @@ -361,8 +353,8 @@ testFormData:function(){ let b = true; - for (let i = 0; i < this.field_list.length; i++){ - let item = this.field_list[i]; + for (let i = 0; i < this.submitFieldList.length; i++){ + let item = this.submitFieldList[i]; if (item.tag !== "son_form"){ if (item.is_input_field === 1 && item.field_must_input === 1){//是输入场并且是必填项,检测是否已填写 if(this.isEmptyValue(item.props.value)){ @@ -469,7 +461,30 @@ } } }, + extractData:function(item){ + if (item.tag === "grid"){//栅格 + for (let i = 0; i < item.props.cols.length; i++){ + let col = item.props.cols[i]; + for (let j = 0; j < col.data.length; j++){ + let son = col.data[j]; + if (son.tag === "grid" || son.tag === "table"){ + this.extractData(son) + }else{ + son.is_main = false;//不在主表单内,在布局字段内 + this.submitFieldList.push(son) + } + } + } + } + }, submitFormData:function(){ + this.submitFieldList = _.cloneDeep(this.field_list); + for (let i = 0; i < this.submitFieldList.length; i++){ + let item = this.submitFieldList[i]; + if (item.tag === "grid" || item.tag === "table"){//判断是栅格和表格布局字段,提取字段内容 + this.extractData(item); + } + } if (this.testFormData() === false){ return } @@ -478,7 +493,7 @@ this.is_loading = true; let dataValue = [{form_id:this.form_id,value_list:[]}] let obj = {}; - this.field_list.forEach((item)=>{ + this.submitFieldList.forEach((item)=>{ if (item.tag === "son_form"){// let sonFormData = { form_id:item.child_form_id, @@ -578,6 +593,46 @@ }); } }, + findAndReplaceData:function(json,targetFiled){ + if (targetFiled.tag === "grid"){ + for (let j = 0; j < targetFiled.props.cols.length; j++){ + let col = targetFiled.props.cols[j]; + for (let k = 0; k < col.data.length; k++){ + let item = col.data[k]; + if (item.tag === "grid" || item.tag === "table"){//布局字段中嵌套布局字段 + return this.findAndReplaceData(json,item); + }else{ + if(json.id === item.id){//找到布局字段中对应的字段 + targetFiled.props.cols[j].data[k] = json; + return true; + } + } + } + } + }else if(targetFiled.tag === "table"){ + console.log("table") + } + + return false; + }, + deleteNotMainField:function(){ + for (let j = this.field_list.length - 1; j >= 0; j--){ + let item = this.field_list[j]; + if (item.is_main === false){ + for (let i = 0; i < this.field_list.length; i ++){ + let find = false; + let fieldJSON = this.field_list[i]; + if (fieldJSON.tag === "grid" || fieldJSON.tag === "table"){//找到布局字段 + find = this.findAndReplaceData(item,fieldJSON); + } + if (find === true){ + this.field_list.splice(j,1); + break; + } + } + } + } + }, setFieldList:function(filedList,data){ this.sonFormCount = 0; this.hasGetFormDataCount = 0; @@ -630,6 +685,7 @@ this.mainFormErgodicComplete = true;//主表单遍历完成 if (this.sonFormCount === this.hasGetFormDataCount){//子表单数据已经全部整理完毕 + this.deleteNotMainField(); this.is_loading = false; } }, @@ -654,7 +710,7 @@ } }); }, - getChildFormData:function(json,data_id,version_no){ + getChildFormData:function(json,data_id,version_no){ let params = { org_id:this.BaseConfig.person_info_my.bureau_id, system_id:10, @@ -685,12 +741,6 @@ data[field.id + "_json"] = _.cloneDeep(field) data[field.id + "_json_copy"] = _.cloneDeep(field) - - // if (field.column_name && field.column_name !== ""){ - // data[field.column_name + "_json"] = _.cloneDeep(field) - // }else{ - // data[field.id + "_json"] = _.cloneDeep(field) - // } }) tableData.push(data); @@ -698,6 +748,7 @@ this.$set(json.props,"tableData",tableData); } if (this.mainFormErgodicComplete === true && this.sonFormCount === this.hasGetFormDataCount){//子表单数据已经全部整理完毕 + this.deleteNotMainField() this.is_loading = false; } } diff --git a/src/views/teacherInfo/systemConfig/FieldAttributeConfig.vue b/src/views/teacherInfo/systemConfig/FieldAttributeConfig.vue index 0131eae..66e5bf0 100644 --- a/src/views/teacherInfo/systemConfig/FieldAttributeConfig.vue +++ b/src/views/teacherInfo/systemConfig/FieldAttributeConfig.vue @@ -3,46 +3,51 @@
-
-
标题内容
- - -
-
-
标题宽度
- -
-
-
标题对齐方式
- - 右对齐 - 中间对齐 - 左对齐 - 顶部对齐 - -
-
-
字段内容宽度
- -
+ + -
-
展示方式
- 只读 - 禁用 - 隐藏 -
-
-
校验
- 字段必填 -
-
-
其它
- 作为高级查询字段 -
+
diff --git a/src/views/teacherInfo/systemConfig/FieldItem.vue b/src/views/teacherInfo/systemConfig/FieldItem.vue index cbaf87d..10d8d56 100644 --- a/src/views/teacherInfo/systemConfig/FieldItem.vue +++ b/src/views/teacherInfo/systemConfig/FieldItem.vue @@ -2,7 +2,8 @@
+ padding:fieldData.tag === 'grid'?'0':'0.5rem 0 0 0',borderBottom:fieldData.field_type < 21 || (fieldData.field_type > 24 && fieldData.field_type < 200)?'1px solid #e5e5e5':null, + margin:fieldData.tag === 'grid'?'0':'0 0.5rem'}" :data-operate="design">
@@ -52,6 +53,7 @@
+
@@ -105,6 +107,9 @@ return "字段值最大长度为" + this.fieldData.props.max_length + "个字符" } }, + addCol:function(){ + this.$emit("addCol",this.fieldData) + }, copyItem:function(){ this.$emit("copy",[this.fieldData]) }, @@ -153,6 +158,8 @@ }, computed:{ com: function (){ + // eslint-disable-next-line no-debugger + debugger; // eslint-disable-next-line no-debugger // let a = this // let url ="Input.vue" @@ -172,4 +179,17 @@ diff --git a/src/views/teacherInfo/systemConfig/FieldRowItem.vue b/src/views/teacherInfo/systemConfig/FieldRowItem.vue deleted file mode 100644 index 88b7b98..0000000 --- a/src/views/teacherInfo/systemConfig/FieldRowItem.vue +++ /dev/null @@ -1,109 +0,0 @@ - - - - - diff --git a/src/views/teacherInfo/systemConfig/FormDesign.vue b/src/views/teacherInfo/systemConfig/FormDesign.vue index 9096740..be7e99f 100644 --- a/src/views/teacherInfo/systemConfig/FormDesign.vue +++ b/src/views/teacherInfo/systemConfig/FormDesign.vue @@ -52,7 +52,7 @@ - +
请拖拽或者点击左侧字段添加表单内容
@@ -118,7 +118,8 @@ export default { {title : '布局字段',list: layoutFields} ], is_spinning:true,//是否为加载总的状态, - form_width:100 + form_width:100, + submitList:[] } }, computed: { @@ -183,6 +184,8 @@ export default { this.fieldsList.push(person_num_data); this.fieldsList.push(person_name_data); this.fieldsList.push(person_org_dept); + }else{//去掉实际在布局字段中的数据 + this.fieldsList = this.fieldsList.filter((item)=>{return item.is_main !== false}) } if (this.data.form_config_json && this.data.form_config_json !== ""){ @@ -290,6 +293,12 @@ export default { this.selectedItem = this.curItem.item this.$bus.emit("clickItem",copyRowData) }, + onAddCol:function(data){ + if (data.props.cols.length < 24){ + let col = _.cloneDeep({tag:"col",id:"col_" + Common.getRandom(12),span:24,offset:0,pull:0,push:0,attributeUrl:"ColItemAttribute",data:[]}) + data.props.cols.push(col); + } + }, deleteRowData: function (data) { let item = data[0]; let index = this.fieldsList.findIndex((field)=>{return field.id === item.id}) @@ -307,50 +316,97 @@ export default { } this.fieldsList.splice(index,1) }, - submitData:function () {//提交表单信息 - if (this.fieldsList.length === 3){ - Modal.warning({ - title: '表单提交失败', - content:"表单中最少要包含一个除默认字段(教师编号、教师姓名、单位(部门))的字段", - okText:'我知道了', - centered:true - }) - return; - } - if (this.testData(this.fieldsList)){ - this.organizeData(this.fieldsList); - let has_certificate = 0; - if (this.fieldsList.some((item)=>{return item.is_certificate === 1})){ - has_certificate = 1 + extractData:function(item){ + if (item.tag === "grid"){//栅格 + if(item.props.cols.length === 0 || item.props.cols.every((col)=>{return !col.data || col.data.length === 0})){ + Modal.warning({ + title: '表单提交失败', + content:"栅格布局字段中最少要包含一个字段", + okText:'我知道了', + centered:true + }) + return false; + }else{ + for (let i = 0; i < item.props.cols.length; i++){ + let col = item.props.cols[i]; + for (let j = 0; j < col.data.length; j++){ + let son = col.data[j]; + if (son.tag === "grid" || son.tag === "table"){ + if (this.extractData(son) === false){ + return false + } + }else{ + son.is_main = false;//不在主表单内,在布局字段内 + this.submitList.push(son) + } + } + + } + } } - let fom_config = this.$refs.formAttributeCom?this.$refs.formAttributeCom.config:this.formConfig - fom_config.include_certificate = has_certificate + return true; + }, + submitData:function () {//提交表单信息 + this.submitList = _.cloneDeep(this.fieldsList); + if (this.submitList.length === 3){ + Modal.warning({ + title: '表单提交失败', + content:"表单中最少要包含一个除默认字段(教师编号、教师姓名、单位(部门))的字段", + okText:'我知道了', + centered:true + }) + return; + } + let extract = true; + for (let i = 0; i < this.submitList.length; i++){ + let item = this.submitList[i]; + if (item.tag === "grid" || item.tag === "table"){//判断是栅格和表格布局字段,提取字段内容 + item.field_type = item.tag === "grid"?240:210; + extract = this.extractData(item); + if (extract === false){ + break; + } + } + } - let params = { - org_id:this.BaseConfig.person_info_my.bureau_id, - form_id:this.data.form_id, - form_json:JSON.stringify(this.fieldsList), - form_config_json:JSON.stringify(fom_config), - person_id:this.BaseConfig.userInfo.person_id_cookie, - system_id:10 + if (extract === false){ + return; } + if (this.testData(this.submitList)){ + this.organizeData(this.submitList); + let has_certificate = 0; + if (this.submitList.some((item)=>{return item.is_certificate === 1})){ + has_certificate = 1 + } + + let fom_config = this.$refs.formAttributeCom?this.$refs.formAttributeCom.config:this.formConfig + fom_config.include_certificate = has_certificate - this.InterfaceConfig.callInterface([{ - url:InterfaceConfig.saveAllCustomizeFormField.url, - method:InterfaceConfig.saveAllCustomizeFormField.method, - params:params, - isTestLogin:InterfaceConfig.saveAllCustomizeFormField.isTestLogin - }],(result)=>{ - if (result && result[0]){ - this.curItem.item = {} - if (result[0].data.code === 2000){ - this.$toast("表单提交成功") - this.$emit("back") + let params = { + org_id:this.BaseConfig.person_info_my.bureau_id, + form_id:this.data.form_id, + form_json:JSON.stringify(this.submitList), + form_config_json:JSON.stringify(fom_config), + person_id:this.BaseConfig.userInfo.person_id_cookie, + system_id:10 } - } - }) - } + + this.InterfaceConfig.callInterface([{ + url:InterfaceConfig.saveAllCustomizeFormField.url, + method:InterfaceConfig.saveAllCustomizeFormField.method, + params:params, + isTestLogin:InterfaceConfig.saveAllCustomizeFormField.isTestLogin + }],(result)=>{ + if (result && result[0]){ + this.curItem.item = {} + if (result[0].data.code === 2000){ + this.$toast("表单提交成功") + this.$emit("back") + } + } + }) + } }, organizeData:function(ary,isChild = false){ let i = 1; @@ -487,13 +543,25 @@ export default { let stopTest = false; for(let m = 0; m < ary.length; m++){ let item = ary[m]; - if (item.props.data){//子表单 - index += 1 - let result = this.testData(item.props.data,true,index) - if (result === false){ - stopTest = true; - break; - } + if (item.tag === "son_form"){ + //子表单 + index += 1 + let result = true; + if (!item.props.data || item.props.data.length === 0){ + Modal.warning({ + title: '表单提交失败', + content:"子表单中至少包含一个字段", + okText:'我知道了', + centered:true + }) + result = false + }else { + result = this.testData(item.props.data,true,index) + } + if (result === false){ + stopTest = true; + break; + } }else{ if ([3,4,6].some((type)=>{return type === item.field_type}) && (item.props.datas === null || item.props.datas === undefined || (TypesCheck.isString(item.props.datas) && item.props.datas === "") || (TypesCheck.isArray(item.props.datas) && item.props.datas.length === 0))){ @@ -526,15 +594,6 @@ export default { stopTest = true; break; } - }else if ((item.field_type === 23 || item.field_type === 231) && item.props.data.length === 0){ - Modal.warning({ - title: '表单提交失败', - content:"子表单中必须至少包含一个字段", - okText:'我知道了', - centered:true - }) - stopTest = true; - break; } if (item.props.max_length){ diff --git a/src/views/teacherInfo/systemConfig/attributeConfig/ColItemAttribute.vue b/src/views/teacherInfo/systemConfig/attributeConfig/ColItemAttribute.vue new file mode 100644 index 0000000..34db464 --- /dev/null +++ b/src/views/teacherInfo/systemConfig/attributeConfig/ColItemAttribute.vue @@ -0,0 +1,47 @@ + + + + + diff --git a/src/views/teacherInfo/systemConfig/attributeConfig/FieldRowItemAttribute.vue b/src/views/teacherInfo/systemConfig/attributeConfig/FieldRowItemAttribute.vue new file mode 100644 index 0000000..b62baeb --- /dev/null +++ b/src/views/teacherInfo/systemConfig/attributeConfig/FieldRowItemAttribute.vue @@ -0,0 +1,73 @@ + + + + + diff --git a/src/views/teacherInfo/systemConfig/fieldAndFormConfig.js b/src/views/teacherInfo/systemConfig/fieldAndFormConfig.js index ca5fb94..30de275 100644 --- a/src/views/teacherInfo/systemConfig/fieldAndFormConfig.js +++ b/src/views/teacherInfo/systemConfig/fieldAndFormConfig.js @@ -111,7 +111,8 @@ export const businessFields = [ ] export const layoutFields = [ - { field_type: 24, field_name: '栅格',tag:"grid",content_width:100}, + { field_type: 24, field_name: '栅格',tag:"grid",content_width:100,el:"FieldRowItem.vue",attributeUrl:"FieldRowItemAttribute", + props:{type:"flex",align:"top",justify:"start",gutter:[0,0],cols:[]}}, { field_type: 21, field_name: '表格',tag:"table",content_width:100}, { field_type: 22, field_name: '分隔线/符',tag:"divider",el:"Divider.vue",attributeUrl:"DividerAttribute", props:{value:"",can_search:false,is_search:false,dashed:false,orientation:"center",type:1,marginTop:8,marginBottom:8,height:40}} diff --git a/src/views/teacherInfo/systemConfig/style/fieldRowItem.scss b/src/views/teacherInfo/systemConfig/style/fieldRowItem.scss index 51bafc6..8811dfa 100644 --- a/src/views/teacherInfo/systemConfig/style/fieldRowItem.scss +++ b/src/views/teacherInfo/systemConfig/style/fieldRowItem.scss @@ -1,21 +1,20 @@ .grid-row-style{ - border:1px dotted rgba(0,0,0,0.2); - min-height: 4rem; - background-color: rgba(242,242,242,0.2); - //padding: 0.25rem; - margin-bottom: 0.2rem; - &:hover{ - background-color: rgba(242,242,242,0.5); - border: 1px solid #31a8fa; - } + padding: 0.25rem; + width: 100%; + flex-flow: nowrap !important; .col-style{ border: 1px dotted rgba(0,0,0,0.3); min-height: 3.5rem; padding:0.25rem 0.25rem 1rem 0.25rem ; position: relative; + background-color: white; + flex: initial!important; &:hover{ border: 1px solid #31a8fa; } + .col-draggable-style{ + min-height: 3rem; + } } .col-selected-style{ border:2px solid #31a8fa !important;