朱思禹提交:教师信息vue项目

init
Administrator 4 years ago
parent 4b90bb63fc
commit 4927df1174

@ -52,6 +52,7 @@
import FieldFilter from '../commonComponents/fieldFilter/FieldFilter'
import CertificateDetail from './CertificateDetail'
import ShowAttachment from '../../../components/common/showAttachment/ShowAttachment'
import GUID_UUID from '../../../global-llibs/guid-uuid'
export default {
name: "CertificateManagement",
props:{
@ -260,7 +261,7 @@
{return record.org_name + (record.dept_name && record.dept_name !== "" && record.dept_name !== record.org_name?
"(" + record.dept_name + ")":"")},fixed:'left',align:'center',width:200})
this.tableColumn.forEach((form)=>{
let obj = {title:form.form_name,key:form.form_id,dataIndex:"certificate_map",align:'center',scopedSlots:{"customRender":"img"}};
let obj = {title:form.form_name,key:GUID_UUID.guid(),dataIndex:"certificate_map",align:'center',scopedSlots:{"customRender":"img"}};
columns.push(obj);
})
columns.push({title:"操作",scopedSlots:{customRender:"operate"},fixed:'right',align:'center'})

@ -1,6 +1,6 @@
<template>
<a-select :mode="data.props.mode" :placeholder="data.props.placeholder" v-model="data.props.value" :disabled="data.props.is_disabled"
:allowClear="data.props.allowClear" :showSearch="data.props.showSearch" style="width: 12rem">
:allowClear="data.props.allowClear" :showSearch="data.props.showSearch" class="drop-select-style">
<a-select-option v-for="item in data.props.datas" :key="item.dic_code" :value="item.dic_code">
{{ item.dic_value }}
</a-select-option>
@ -30,6 +30,8 @@
}
</script>
<style scoped>
<style scoped lang="scss">
.drop-select-style{
width: 100%;
}
</style>

@ -1,7 +1,7 @@
<template>
<a-input-number v-model="data.props.value" :disabled="data.props.is_disabled"
:step="data.props.step" :max="data.props.max?data.props.max:undefined"
:min="data.props.min?data.props.min:undefined"/>
:min="data.props.min?data.props.min:undefined" class="item-input-number"/>
</template>
<script>
@ -26,6 +26,8 @@
}
</script>
<style scoped>
<style scoped lang="scss">
.item-input-number{
width: 100%;
}
</style>

@ -9,7 +9,7 @@
</div>
<a-table class="table-style" :rowSelection="canEdit && data.props.multiple && this.fieldData.props.data.length > 0?{selectedRowKeys:selectedRowKeys,columnWidth:60,
onChange:onSelectedChange,getCheckboxProps:setCheckboxProps}:null" :columns="columns" :pagination="false" :dataSource="tableData" rowKey="value_id"
:scroll="{x:true}" size="small">
:scroll="{x:getScrollWidth()}" size="small">
<SonFieldItem slot="col" slot-scope="value,record" :item="value" :is_edit="!!(curEditItem && curEditItem.value_id === record.value_id)"/>
<template slot="operate" slot-scope="value,record,index">
<template v-if="canEdit">
@ -41,7 +41,7 @@
selectedRowKeys:[],
tableData:this.fieldData.props.tableData?this.fieldData.props.tableData:(this.fieldData.props.defaultLineCount === 0?[]:this.getDefaultTableData()),
columns:this.getColumns(),
curEditItem:null
curEditItem:null,
}
},
components:{
@ -53,6 +53,13 @@
// ShowAttachment,
},
methods:{
getScrollWidth:function(){
let count = 0;
this.columns.forEach((column)=>{
count += column.width;
});
return count;
},
onDeleteRecords:function(){
if (this.selectedRowKeys.length === 0){
Modal.warning({
@ -213,14 +220,16 @@
ary.push({title:"序号",customRender:(text,record,index)=>{return index + 1},align:'center',width:60})
}
this.fieldData.props.data.forEach((item)=>{
let obj = {align:item.props.label_alignment === "flex-start"?"left":(item.props.label_alignment === "center"?"center":"right"),
title:item.props.label_prefix + item.field_name + item.props.label_suffix,dataIndex:item.id + "_json_copy",
scopedSlots:{customRender:"col"},slots:{title:"headerTitle"},width:item.field_type === 11?300:150,};
let obj = {title:item.props.label_prefix + item.field_name + item.props.label_suffix,align:item.props.label_alignment === "flex-start"?"left":(item.props.label_alignment === "center"?"center":"right"),
dataIndex:item.id + "_json_copy",scopedSlots:{customRender:"col"},width:item.field_type === 11?300:150,};
if (item.props.is_must === true){
obj.className = "must-style";
}
ary.push(obj)
})
if (this.edit !== false){
ary.push({align:"center",title:"操作", scopedSlots:{customRender: 'operate'},width:64})
ary.push({align:"center",title:"操作", scopedSlots:{customRender: 'operate'},width:80})
}
}
return ary
@ -230,6 +239,9 @@
fieldData:function (newData) {
this.data = newData;
this.tableData = newData.props.tableData?newData.props.tableData:(newData.props.defaultLineCount === 0?[]:this.getDefaultTableData());
},
edit:function (newData) {
this.canEdit = newData !== false;
}
}
}
@ -270,5 +282,9 @@
/deep/.ant-table-body{
overflow-y: hidden;
}
/deep/th.must-style:before{
content: '*';
color:red;
}
}
</style>

@ -155,9 +155,14 @@
if (trIndex === this.data.props.tr.length - 1 || trIndex + td.rowspan === this.data.props.tr.length){
return false;
}else{
return td.colspan === this.data.props.tr[trIndex + td.rowspan].td.filter((item) => {
let item = this.data.props.tr[trIndex + td.rowspan].td.filter((item) => {
return item.index === td.index
})[0].colspan;
});
if (item && item.length > 0){
return item[0].index === td.index
}else{
return false;
}
}
},
onClick:function(data){
@ -188,9 +193,9 @@
// eslint-disable-next-line no-case-declarations
let curTdColspan = td.rowspan
// eslint-disable-next-line no-case-declarations
let bottomTdRowspan = this.data.props.tr[trIndex + curTdColspan].td[tdIndex].rowspan;
td.rowspan += bottomTdRowspan;
this.data.props.tr[trIndex + curTdColspan].td.splice(tdIndex,1);
let bottonTdIndex = this.data.props.tr[trIndex + curTdColspan].td.findIndex((item)=>{ return item.index === td.index});
td.rowspan += this.data.props.tr[trIndex + curTdColspan].td[bottonTdIndex].rowspan;
this.data.props.tr[trIndex + curTdColspan].td.splice(bottonTdIndex,1);
break;
case "splitToRow":
for (let i = trIndex + 1; i < trIndex + td.rowspan; i++){
@ -217,10 +222,10 @@
this.addRow(trIndex + td.rowspan);
break;
case "inertColToLeft":
this.addCol(tdIndex)
this.addCol(td.index)
break;
case "inertColToRight":
this.addCol(tdIndex + 1)
this.addCol(td.index + td.colspan)
break;
case "deleteCurRow":
if (tr.td.some((item)=>{return item.rowspan > 1})){
@ -273,8 +278,35 @@
let trId = "tr_" + Common.getRandom(12);
let tdCount = this.getTdMaxCount();
let ary = [];
for (let i = 0; i < tdCount; i++){
ary.push({id:"td_" + Common.getRandom(12),colspan:1,rowspan:1,data:[],tag:"td",index:i})
if (index !== -1 && index < this.data.props.tr.length && this.data.props.tr[index].td.length < tdCount){
ary = _.cloneDeep(this.data.props.tr[index].td);
ary.forEach((item,index)=>{
item.id = "td_" + Common.getRandom(12);
item.rowspan = 1;
item.data.splice(0);
if (item.colspan > 1){
let createTd = item.colspan - 1;
for (let i = 0; i < createTd; i++){
let td = {id:"td_" + Common.getRandom(12),colspan:1,rowspan:1,data:[],tag:"td",index:item.index + i + 1}
ary.splice(index + i + 1,0,td);
}
item.colspan = 1;
}
});
for (let i = 0; i < index; i++){
let tr = this.data.props.tr[i];
for (let j = 0; j < tr.td.length; j++){
let td = tr.td[j];
if(td.rowspan > 1 && td.rowspan + i > index){
td.rowspan += 1;
}
}
}
}else{
for (let i = 0; i < tdCount; i++){
ary.push({id:"td_" + Common.getRandom(12),colspan:1,rowspan:1,data:[],tag:"td",index:i})
}
}
if (index === -1 || index === this.data.props.tr.length){
this.data.props.tr.push({id:trId,td:ary})
@ -292,18 +324,29 @@
})
return count
},
addCol:function (index = -1) {
this.data.props.tr.forEach((tr)=>{
let tdId = "td_" + Common.getRandom(12);
let tdIndex;
if (index === -1 || index === tr.td.length){//
tdIndex = tr.td[tr.td.length - 1].index + tr.td[tr.td.length - 1].colspan;
tr.td.push({id:tdId,colspan:1,rowspan:1,data:[],tag:"td",index:tdIndex})
if (index === -1){//
tr.td.push({id:tdId,colspan:1,rowspan:1,data:[],tag:"td",index:tr.td[tr.td.length - 1].index +tr.td[tr.td.length - 1].colspan })
}else{//
tdIndex = tr.td[index].index;
tr.td.splice(index,0,{id:tdId,colspan:1,rowspan:1,data:[],tag:"td",index:tdIndex});
for (let i = index + 1; i < tr.td.length; i++){
tr.td[i].index += 1;
let tdIndex = tr.td.findIndex((item)=>{return item.index === index});
if (tdIndex === -1){
for (let i = 0; i < tr.td.length; i++){
if (i + tr.td[i].colspan > index){
tr.td[i].colspan += 1;
for (let j = i + 1; j < tr.td.length; j++){
tr.td[j].index += 1;
}
break;
}
}
}else{
tr.td.splice(tdIndex,0,{id:tdId,colspan:1,rowspan:1,data:[],tag:"td",index:index});
for (let i = tdIndex + 1; i < tr.td.length; i++){
tr.td[i].index += 1;
}
}
}
})
@ -325,6 +368,7 @@
width: 100%;
border-radius: 4px;
border-style: solid;
border-right: none;
.table-style{
table-layout: fixed;
.tr-style{
@ -337,9 +381,9 @@
height: 2rem;
border-right-style:solid;
position:relative;
&:nth-last-of-type(1){
border-right: none;
}
/*&:nth-last-of-type(1){*/
/* border-right: none;*/
/*}*/
.td-draggable-style{
margin: 0.1rem 0.2rem;
background-color: white;

@ -75,6 +75,7 @@
import ApprovalComment from '../approve/ApprovalComment'
import CommonOperate from '../utils/commonOperate'
import GUID_UUID from '../../../global-llibs/guid-uuid'
import InterfaceConfig from '../../../commonInterface/interfaceConfig'
/*
* @props
* pageType 1新建 2编辑 3查看 4审批
@ -709,8 +710,74 @@
})
this.mainFormErgodicComplete = true;//
if (this.sonFormCount === this.hasGetFormDataCount){//
this.getDicKeys();
}
},
getDicKeys:function(){
let keys = [];
if (this.type < 3){//
this.field_list.forEach((item)=>{
if (item.tag === "son_form"){//
item.props.data.forEach((data)=>{
if ([3,4,6].some((num)=>{return num === data.field_type})){//
if (parseInt(data.data_resource) === 1){
keys.push(data.data_resource_info)
}
}
});
}else if ([3,4,6].some((num)=>{return num === item.field_type})){//
if (parseInt(item.data_resource) === 1){
if (keys.every((code)=>{return code !== item.data_resource_info})){
keys.push(item.data_resource_info)
}
}
}
});
}
if (keys.length === 0){
this.deleteNotMainField();
this.is_loading = false;
}else {
this.InterfaceConfig.callInterface([{
url:InterfaceConfig.getIntellioaDicByCodes.url,
method:InterfaceConfig.getIntellioaDicByCodes.method,
params:{
dic_codes:keys.join(",")
},
isTestLogin:InterfaceConfig.getIntellioaDicByCodes.isTestLogin
}],(data)=>{
let result = data[0].data;
if (result.code === 2000){
let keyCodes = Object.keys(result.data);
keyCodes.forEach((code)=>{
this.field_list.forEach((item)=>{
if (item.tag === "son_form"){//
item.props.data.forEach((data)=>{
if ([3,4,6].some((num)=>{return num === data.field_type})){//
if (data.data_resource_info === code){
data.props.datas = result.data[code];
if (item.props.tableData && item.props.tableData.length > 0){
item.props.tableData.forEach((table)=>{
table[data.id+"_json"].props.datas = result.data[code];
table[data.id+"_json_copy"].props.datas = result.data[code];
})
}
}
}
});
}else if ([3,4,6].some((num)=>{return num === item.field_type})){//
if (code === item.data_resource_info){
item.props.datas = result.data[code];
}
}
});
})
this.deleteNotMainField();
this.is_loading = false;
}
})
}
},
editForm:function () {
@ -772,8 +839,9 @@
this.$set(json.props,"tableData",tableData);
}
if (this.mainFormErgodicComplete === true && this.sonFormCount === this.hasGetFormDataCount){//
this.deleteNotMainField()
this.is_loading = false;
this.getDicKeys();
// this.deleteNotMainField()
// this.is_loading = false;
}
}
})

@ -1,13 +1,14 @@
<template>
<div :class="['field-item-style',{'select-style':(selected_id === fieldData.id || curItem.item.id === fieldData.id) && design},
{'sonForm-field-style':fieldData.props.is_sonForm_field === true && design}]" @click.stop="onSelect(fieldData)"
:style="design?{backgroundColor:fieldData.props.is_hidden?'rgba(255,11,124,0.1)':''}:{display:fieldData.props.is_hidden && !design?'none':'block',
:style="design?{backgroundColor:fieldData.props.is_hidden?'rgba(255,11,124,0.1)':''}:{display:fieldData.props.is_hidden && !design?'none':
(fieldData.props.is_table_field?'flex':'block'),
padding:fieldData.tag === 'grid' || fieldData.props.is_table_field?'0':'0.5rem 0 0 0',borderBottom:(fieldData.field_type < 21 || (fieldData.field_type > 24 && fieldData.field_type < 200)) && !fieldData.props.is_table_field?'1px solid #e5e5e5':null,
margin:fieldData.tag === 'grid' || fieldData.props.is_table_field?'0':'0 0.5rem',minHeight:fieldData.props.is_table_field?'auto':'3.5rem'}" :data-operate="design">
margin:fieldData.tag === 'grid' || fieldData.props.is_table_field?'0':'0 0.5rem',minHeight:fieldData.props.is_table_field?'100%':'3.5rem'}" :data-operate="design">
<span v-if="fieldData.props.show_title === true || (design && fieldData.props.is_sonForm_field === true)"
class="label-style" ref="label" :style="[23,230,231].some((num)=>{return num === fieldData.field_type})?{display:'flex',width:'100%',justifyContent:fieldData.props.label_alignment}:
{display:fieldData.props.label_alignment === 'top'?'flex':'inline-flex',justifyContent:fieldData.props.label_alignment === 'top'?'flex-start':fieldData.props.label_alignment,
width:fieldData.props.label_width + 'rem',opacity:fieldData.props.is_disabled?'0.5':null}">
width:fieldData.props.label_width + 'rem',opacity:fieldData.props.is_disabled?'0.5':null,height:!design && fieldData.props.is_table_field?'auto':'2.5rem'}">
<span v-if="fieldData.props.is_must === true" style="color:red">*</span>
{{fieldData.props.label_prefix + fieldData.field_name + fieldData.props.label_suffix}}
</span>
@ -17,7 +18,7 @@
fieldData.props.showTitle === false || [21,22,23,24,210,211,230,231,240,241].some((num)=>{return num === fieldData.field_type})?null:'0.5rem',marginBottom:design ||
(design === false && fieldData.props.is_table_field === true)?null:'0.5rem',paddingRight:!design && fieldData.props.is_table_field === true?'0.5rem':null,
pointerEvents:(design && (fieldData.tag !== 'son_form' && fieldData.tag !== 'grid' && fieldData.tag !== 'table')) ||
(edit === false && (fieldData.field_type !== 9 && fieldData.field_type !== 10))?'none':null,borderLeft:design ||
(edit === false && (fieldData.tag !== 'son_form' && fieldData.field_type !== 9 && fieldData.field_type !== 10))?'none':null,borderLeft:design ||
fieldData.props.show_title === false || [21,22,23,24,230,231,210,211,240,241].some((num)=>{return num === fieldData.field_type}) || fieldData.props.is_sonForm_field === true ||
(fieldData.props.is_table_field && fieldData.props.titleDivider === false)?null:'1px solid #e5e5e5',
borderLeftColor:fieldData.props.is_table_field && fieldData.props.titleDivider === true?fieldData.props.borderColor:'#e5e5e5',
@ -183,9 +184,16 @@
is_edit:function (newData) {
this.edit = newData
},
item:function (newData) {
item: function (newData) {
this.fieldData = newData
}
} ,
// fieldData:{
// handler () {
// // eslint-disable-next-line no-debugger
// debugger
// },
// deep:true
// }
}
}
</script>

@ -50,6 +50,7 @@
import 'ant-design-vue/es/radio/style/css'
import InterfaceConfig from './interfaceConfig';
import StaticParams from "../../../global-llibs/staticParams";
import CommonInterfaceConfig from '../../../commonInterface/interfaceConfig';
import FormDesign from './FormDesign';
export default {
name: "FormConfig",
@ -65,7 +66,9 @@
page_size:10,
total_row:0,
showList:true,//true false
formData:null
formData:null,
fieldsList:[],
formWidth:""
}
},
components:{
@ -77,14 +80,6 @@
APagination:Pagination
},
methods:{
deleteNotMainField:function(list){
for (let j = list.length - 1; j >= 0; j--){
let item = list[j];
if (item.is_main === false){
list.splice(j,1);
}
}
},
onBack:function(){
this.showList = true;
this.getList();
@ -211,15 +206,137 @@
}],(result)=>{
if (result && result[0]){
let data = result[0].data
let fieldList = JSON.parse(data.data.form_json);
let formWidth = JSON.parse(data.data.form_config_json).form_width;
this.deleteNotMainField(fieldList);
if (data.code === 2000){
StaticParams.showPopModal(this,'预览','views/teacherInfo/formCommon/ViewForm.vue',
{"fieldsList":fieldList,"form_width":formWidth},false,true,null,"calc(55% + 48px)","preview-style")
this.fieldsList = JSON.parse(data.data.form_json);
this.formWidth = JSON.parse(data.data.form_config_json).form_width;
this.getDicKeys();
}
}
});
},
getDicKeys:function(){
let keys = [];
this.fieldsList.forEach((item)=>{
if (item.tag === "son_form"){//
item.props.data.forEach((data)=>{
if ([3,4,6].some((num)=>{return num === data.field_type})){//
if (parseInt(data.data_resource) === 1){
keys.push(data.data_resource_info)
}
}
});
}else if ([3,4,6].some((num)=>{return num === item.field_type})){//
if (parseInt(item.data_resource) === 1){
if (keys.every((code)=>{return code !== item.data_resource_info})){
keys.push(item.data_resource_info)
}
}
}
});
if (keys.length === 0){
this.deleteNotMainField();
StaticParams.showPopModal(this,'预览','views/teacherInfo/formCommon/ViewForm.vue',
{"fieldsList":this.fieldsList,"form_width":this.formWidth},false,true,null,"calc(55% + 48px)","preview-style")
}else {
this.InterfaceConfig.callInterface([{
url:CommonInterfaceConfig.getIntellioaDicByCodes.url,
method:CommonInterfaceConfig.getIntellioaDicByCodes.method,
params:{
dic_codes:keys.join(",")
},
isTestLogin:CommonInterfaceConfig.getIntellioaDicByCodes.isTestLogin
}],(data)=>{
let result = data[0].data;
if (result.code === 2000){
let keyCodes = Object.keys(result.data);
keyCodes.forEach((code)=>{
this.fieldsList.forEach((item)=>{
if (item.tag === "son_form"){//
item.props.data.forEach((data)=>{
if ([3,4,6].some((num)=>{return num === data.field_type})){//
if (data.data_resource_info === code){
data.props.datas = result.data[code];
if (item.props.tableData && item.props.tableData.length > 0){
item.props.tableData.forEach((table)=>{
table[data.id+"_json"].props.datas = result.data[code];
table[data.id+"_json_copy"].props.datas = result.data[code];
})
}
}
}
});
}else if ([3,4,6].some((num)=>{return num === item.field_type})){//
if (code === item.data_resource_info){
item.props.datas = result.data[code];
}
}
});
})
this.deleteNotMainField();
StaticParams.showPopModal(this,'预览','views/teacherInfo/formCommon/ViewForm.vue',
{"fieldsList":this.fieldsList,"form_width":this.formWidth},false,true,null,"calc(55% + 48px)","preview-style")
}
})
}
},
deleteNotMainField:function(){
for (let j = this.fieldsList.length - 1; j >= 0; j--){
let item = this.fieldsList[j];
if (item.is_main === false){
for (let i = 0; i < this.fieldsList.length; i ++){
let find = false;
let fieldJSON = this.fieldsList[i];
if (fieldJSON.tag === "grid" || fieldJSON.tag === "table"){//
find = this.findAndReplaceData(item,fieldJSON);
}
if (find === true){
this.fieldsList.splice(j,1);
break;
}
}
}
}
},
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"){
for (let i = 0; i < targetFiled.props.tr.length; i++){
let tr = targetFiled.props.tr[i];
for (let j = 0; j < tr.td.length; j++){
let td = tr.td[j];
for(let k = 0; k < td.data.length; k++){
let item = td.data[k];
if (item.tag === "grid" || item.tag === "table"){//
return this.findAndReplaceData(json,item);
}else{
if(json.id === item.id){//
targetFiled.props.tr[i].td[j].data[k] = json;
return true;
}
}
}
}
}
}
return false;
},
/*
* 查看字段详情
@ -433,6 +550,7 @@
let data = result[0].data;
if (data.code === 2000){
this.$toast("编辑类目权限成功");
this.$bus.emit("menuChang");
this.getList();
}
}

@ -1,5 +1,5 @@
<template >
<div @dragover="dragOver" style="width: 100%">
<div v-if="!isLoading" @dragover="dragOver" style="width: 100%">
<a-row class="formTitle" type='flex' align='middle'>
{{data.form_name}}
</a-row>
@ -51,10 +51,11 @@
<div class="itemOuterContainer" style="height: calc(100% - 3rem);padding: 0.5rem 0;background-color: #f2f2f2">
<vue-scroll :ops="ops" style="height:100%">
<draggable group="itemGroup" v-model="fieldsList" class="itemInnerContainer"
:style="{width:form_width !== 100 ? form_width + '%':'calc(100% - 1rem)',margin: '0 auto',minHeight:draggableMinHeight}" handle=".move"
:style="{width:form_width !== 100 ? form_width + '%':'calc(100% - 1rem)',margin: '0 auto',paddingBottom:'1rem',
minHeight:draggableMinHeight}" handle=".move"
filter=".no-field" forceFallback="true" chosenClass="chosen" ghostClass="ghost" @add="onAdd">
<FieldItem v-for="field in fieldsList" :key="field.id" :item="field" @delete="deleteRowData" @copy="copyRowData" :design="true" @addCol="onAddCol"/>
<div v-if="fieldsList.length <= 0" class="no-field"></div>
<div v-if="fieldsList.length <= 0" class="no-field"></div>
</draggable>
</vue-scroll>
@ -68,18 +69,19 @@
<div v-else :style="{height: innerItemContainerHeight,display:'flex',justifyContent:'center',alignItems:'center',fontSize:'1rem'}">
请选择显示属性字段</div>
</a-tab-pane>
<a-tab-pane key="tab2" tab="表单属性">
<a-tab-pane key="tab2" tab="类目属性">
<FormAttributeConfig :dataConfig="getFormConfigData" ref="formAttributeCom"/>
</a-tab-pane>
</a-tabs>
</a-col>
</a-row>
</div>
<a-spin v-else tip="正在加载,请稍候..." size="large" style="padding-top: 20%"/>
</template>
<script>
import draggable from 'vuedraggable'
import { Row, Col, Tabs, Icon} from 'ant-design-vue'
import { Row, Col, Tabs, Icon,Spin} from 'ant-design-vue'
import { baseFields, advancedFields, businessFields, layoutFields,formConfig,commonConfig,curItem} from "./fieldAndFormConfig"
import _ from 'lodash'
import Common from '../../../utils/common'
@ -92,6 +94,7 @@ import { Modal } from 'ant-design-vue'
import StaticParams from '../../../global-llibs/staticParams'
import TypesCheck from '../../../global-llibs/under-score/types-check'
import CommonOperate from '../utils/commonOperate';
import CommonInterfaceConfig from '../../../commonInterface/interfaceConfig'
// import Upload from '../../components/common/uploader/Upload'
// import RichEditor from '../../components/common/richEditor/RichEditor'
const MyIcon = Icon.createFromIconfontCN({
@ -121,9 +124,10 @@ export default {
{title : '业务字段',list: businessFields},
{title : '布局字段',list: layoutFields}
],
is_spinning:true,//,
// is_spinning:true,//,
form_width:100,
submitList:[]
submitList:[],
isLoading:true
}
},
computed: {
@ -149,12 +153,15 @@ export default {
if (result && result[0]){
let data = result[0].data
if (data.code === 2000){
this.is_spinning = false;
// this.is_spinning = false;
// this.data = data.data;
this.data.form_json = data.data.form_json
this.data.form_config_json = data.data.form_config_json
this.fieldsList = this.data.form_json && this.data.form_json !== ""?JSON.parse(this.data.form_json): []
if (this.data.form_config_json && this.data.form_config_json !== ""){
this.data.formConfig = this.$set(this.data,"formConfig",JSON.parse(this.data.form_config_json))
this.form_width = this.data.formConfig.form_width
}
if(this.fieldsList.length === 0){
let person_num_data = _.cloneDeep(baseFields.filter((item)=>{return item.tag === "input"})[0])
Object.keys(this.commonConfig).forEach((prop)=>{
@ -188,14 +195,16 @@ 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})
this.isLoading = false;
}else{//
this.getDicKeys()
// this.fieldsList = this.fieldsList.filter((item)=>{return item.is_main !== false})
}
if (this.data.form_config_json && this.data.form_config_json !== ""){
this.data.formConfig = this.$set(this.data,"formConfig",JSON.parse(this.data.form_config_json))
this.form_width = this.data.formConfig.form_width
}
// if (this.data.form_config_json && this.data.form_config_json !== ""){
// this.data.formConfig = this.$set(this.data,"formConfig",JSON.parse(this.data.form_config_json))
// this.form_width = this.data.formConfig.form_width
// }
// this.data.formConfig = this.data.form_config_json && this.data.form_config_json !== ""?JSON.parse(this.data.form_config_json):{}
}
}
@ -206,6 +215,126 @@ export default {
this.$bus.off("clickItem",this.selectItem)
},
methods: {
getDicKeys:function(){
let keys = [];
this.fieldsList.forEach((item)=>{
if (item.tag === "son_form"){//
item.props.data.forEach((data)=>{
if ([3,4,6].some((num)=>{return num === data.field_type})){//
if (parseInt(data.data_resource) === 1){
keys.push(data.data_resource_info)
}
}
});
}else if ([3,4,6].some((num)=>{return num === item.field_type})){//
if (parseInt(item.data_resource) === 1){
if (keys.every((code)=>{return code !== item.data_resource_info})){
keys.push(item.data_resource_info)
}
}
}
});
if (keys.length === 0){
this.deleteNotMainField();
this.isLoading = false;
}else {
this.InterfaceConfig.callInterface([{
url:CommonInterfaceConfig.getIntellioaDicByCodes.url,
method:CommonInterfaceConfig.getIntellioaDicByCodes.method,
params:{
dic_codes:keys.join(",")
},
isTestLogin:CommonInterfaceConfig.getIntellioaDicByCodes.isTestLogin
}],(data)=>{
let result = data[0].data;
if (result.code === 2000){
let keyCodes = Object.keys(result.data);
keyCodes.forEach((code)=>{
this.fieldsList.forEach((item)=>{
if (item.tag === "son_form"){//
item.props.data.forEach((data)=>{
if ([3,4,6].some((num)=>{return num === data.field_type})){//
if (data.data_resource_info === code){
data.props.datas = result.data[code];
if (item.props.tableData && item.props.tableData.length > 0){
item.props.tableData.forEach((table)=>{
table[data.id+"_json"].props.datas = result.data[code];
table[data.id+"_json_copy"].props.datas = result.data[code];
})
}
}
}
});
}else if ([3,4,6].some((num)=>{return num === item.field_type})){//
if (code === item.data_resource_info){
item.props.datas = result.data[code];
}
}
});
})
this.deleteNotMainField();
this.isLoading = false;
}
})
}
},
deleteNotMainField:function(){
for (let j = this.fieldsList.length - 1; j >= 0; j--){
let item = this.fieldsList[j];
if (item.is_main === false){
for (let i = 0; i < this.fieldsList.length; i ++){
let find = false;
let fieldJSON = this.fieldsList[i];
if (fieldJSON.tag === "grid" || fieldJSON.tag === "table"){//
find = this.findAndReplaceData(item,fieldJSON);
}
if (find === true){
this.fieldsList.splice(j,1);
break;
}
}
}
}
},
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"){
for (let i = 0; i < targetFiled.props.tr.length; i++){
let tr = targetFiled.props.tr[i];
for (let j = 0; j < tr.td.length; j++){
let td = tr.td[j];
for(let k = 0; k < td.data.length; k++){
let item = td.data[k];
if (item.tag === "grid" || item.tag === "table"){//
return this.findAndReplaceData(json,item);
}else{
if(json.id === item.id){//
targetFiled.props.tr[i].td[j].data[k] = json;
return true;
}
}
}
}
}
}
return false;
},
fieldClick:function(field){
this.curItem.item = _.cloneDeep(field);
this.curItem.item.id = this.curItem.item.tag + "_" + Common.getRandom(12);
@ -222,7 +351,7 @@ export default {
if (this.curItem.item.field_type <=24 && this.curItem.item.field_type >= 21){
this.curItem.item.props.show_title = false;
if (this.curItem.item.field_type === 23){//
if (this.curItem.item.field_type === 23){//
this.curItem.item.props.label_alignment = "center"
}
}
@ -242,7 +371,7 @@ export default {
Modal.warning({
title:"预览失败",
centered:true,
content:"当前表单没有字段,无法预览",
content:"当前类目没有字段,无法预览",
okText:'我知道了'
})
}else{
@ -311,7 +440,7 @@ export default {
if (this.curItem.item.field_type <=24 && this.curItem.item.field_type >= 21){
this.curItem.item.props.show_title = false;
if (this.curItem.item.field_type === 23){//
if (this.curItem.item.field_type === 23){//
this.curItem.item.props.label_alignment = "center"
}
}
@ -362,7 +491,7 @@ export default {
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: '表单提交失败',
title: '类目提交失败',
content:"栅格布局字段中最少要包含一个字段",
okText:'我知道了',
centered:true
@ -378,7 +507,7 @@ export default {
return false
}
}else{
son.is_main = false;//
son.is_main = false;//
this.submitList.push(son)
}
}
@ -387,7 +516,7 @@ export default {
}else{
if (item.props.tr.every((tr)=>{ return tr.td.every((td)=>{ return !td.data || td.data.length === 0})})){
Modal.warning({
title: '表单提交失败',
title: '类目提交失败',
content:"表格布局字段中最少要包含一个字段",
okText:'我知道了',
centered:true
@ -405,7 +534,7 @@ export default {
return false
}
}else{
data.is_main = false;//
data.is_main = false;//
this.submitList.push(data)
}
}
@ -416,17 +545,8 @@ export default {
return true;
},
submitData:function () {//
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];
@ -451,7 +571,23 @@ export default {
let fom_config = this.$refs.formAttributeCom?this.$refs.formAttributeCom.config:this.formConfig
fom_config.include_certificate = has_certificate
if (JSON.stringify(this.submitList).length > 16777215){
Modal.warning({
title: '类目提交失败',
content:"类目内容过多无法提交,请精简类目内容后再提交",
okText:'我知道了',
centered:true
})
return;
}else if(this.submitList.length === 3 && this.submitList.every((item)=>{return item.field_input_type === 2})){
Modal.warning({
title: '类目提交失败',
content:"类目中最少要包含一个除默认字段(教师编号、教师姓名、单位(部门))的字段",
okText:'我知道了',
centered:true
})
return;
}
let params = {
org_id:this.BaseConfig.person_info_my.bureau_id,
form_id:this.data.form_id,
@ -470,7 +606,7 @@ export default {
if (result && result[0]){
this.curItem.item = {}
if (result[0].data.code === 2000){
this.$toast("表单提交成功")
this.$toast("类目提交成功")
this.$emit("back")
}
}
@ -515,12 +651,16 @@ export default {
// field.data_resource = parseInt(field.props.data_resource);
if (parseInt(field.data_resource) === 2){
field.data_resource_info = JSON.stringify(field.props.datas);
}else{
field.props.datas = [];//
}
}else if (curType === 4){//
field.is_multiple_choice = 1
if (parseInt(field.data_resource) === 2){
field.data_resource_info = JSON.stringify(field.props.datas);
}else{
field.props.datas = [];//
}
}else if (curType === 5){//
field.date_format = field.props.format
@ -528,6 +668,8 @@ export default {
// field.data_resource = parseInt(field.props.data_resource);
if (parseInt(field.data_resource) === 2){
field.data_resource_info = JSON.stringify(field.props.datas);
}else{
field.props.datas = [];//
}
if(field.props.mode === "default"){
field.is_multiple_choice = 0
@ -584,7 +726,7 @@ export default {
}
}else {//
field.is_input_field = 0;
if (curType !== 20 && curType !== 22){//
if (curType !== 20 && curType !== 22){//
if(field.props.data && field.props.data.length > 0){//
field.field_type = parseInt(field.field_type.toString().substr(0,2) + "1")
this.organizeData(field.props.data,true);
@ -613,13 +755,13 @@ export default {
for(let m = 0; m < ary.length; m++){
let item = ary[m];
if (item.tag === "son_form"){
//
//
index += 1
let result = true;
if (!item.props.data || item.props.data.length === 0){
Modal.warning({
title: '表单提交失败',
content:"子表单中至少包含一个字段",
title: '类目提交失败',
content:"子类目中至少包含一个字段",
okText:'我知道了',
centered:true
})
@ -635,7 +777,7 @@ export default {
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))){
Modal.warning({
title: '表单提交失败',
title: '类目提交失败',
content:"请设置“" + item.field_name + "”字段的数据源",
okText:'我知道了',
centered:true
@ -646,7 +788,7 @@ export default {
let tips = "";
if (!item.props.data_source_form_id || item.props.data_source_form_id === ""){
// eslint-disable-next-line no-debugger
tips = "请选择“" + item.field_name + "”字段的数据更新来源表单";
tips = "请选择“" + item.field_name + "”字段的数据更新来源类目";
}else if (!item.props.data_source_field_id || item.props.data_source_field_id === ""){
tips = "请选择“" + item.field_name + "”字段的数据更新来源字段";
}else if (!item.props.compare_standard){
@ -655,7 +797,7 @@ export default {
if (tips !== ""){
Modal.warning({
title: '表单提交失败',
title: '类目提交失败',
content:tips,
okText:'我知道了',
centered:true
@ -682,24 +824,24 @@ export default {
}
if (i > 80){
Modal.warning({
title: '表单提交失败',
content:(isChild?'子表单' + index:"") + '字段值最大限制为1-50包含50的字段不能超过80个请更改后再试',
title: '类目提交失败',
content:(isChild?'子类目' + index:"") + '字段值最大限制为1-50包含50的字段不能超过80个请更改后再试',
okText:'我知道了',
centered:true
})
return false;
}else if(j > 20){
Modal.warning({
title: '表单提交失败',
content:(isChild?'子表单' + index:"") + '字段值最大限制为51-200包含200的字段不能超过20个请更改后再试',
title: '类目提交失败',
content:(isChild?'子类目' + index:"") + '字段值最大限制为51-200包含200的字段不能超过20个请更改后再试',
okText:'我知道了',
centered:true
})
return false;
}else if (k > 20){
Modal.warning({
title: '表单提交失败',
content: (isChild?'子表单' + index:"") + '字段值最大限制为200包含不限制以外的字段不能超过20个请更改后再试',
title: '类目提交失败',
content: (isChild?'子类目' + index:"") + '字段值最大限制为200包含不限制以外的字段不能超过20个请更改后再试',
okText:'我知道了',
centered:true
})
@ -718,8 +860,15 @@ export default {
FieldItem,
FormAttributeConfig,
FieldAttributeConfig,
MyIcon
MyIcon,
ASpin:Spin
},
// watch:{
// fieldsList:function () {
// // eslint-disable-next-line no-debugger
// debugger
// }
// }
}
</script>

@ -204,17 +204,18 @@
this.loadingDicContent = false;
if (this.attribute.data_resource_info && this.attribute.data_resource_info !== "" &&
this.attribute.data_resource_info !== []){//
let ary = [];
this.attribute.props.datas.forEach((item)=>{
ary.push(
{
dic_code:item.dic_code,
dic_value:item.dic_value
}
)
})
this.dicContent = ary;
this.dicSelected();
// let ary = [];
// this.attribute.props.datas.forEach((item)=>{
// ary.push(
// {
// dic_code:item.dic_code,
// dic_value:item.dic_value
// }
// )
// })
//
// this.dicContent = ary;
}
})
}

Loading…
Cancel
Save