拆分详情表格修改

This commit is contained in:
caoyang
2022-04-12 13:47:33 +08:00
parent 52d1d32ebb
commit 350ed839d5
8 changed files with 143 additions and 69 deletions
@@ -321,12 +321,23 @@
@cancel="handleColCancel"
>
<a-form :form="form" :label-col="{ span: 8 }" :wrapper-col="{ span: 14 }">
<a-form-item :label="$t('numberRows')">
<a-input-number v-model="rowCount" :min="1" :max="99999" :placeholder="$t('pleaseEnter')+$t('numberRows')" :formatter="limitNumber" :parser="limitNumber" style="width: 100%" />
</a-form-item>
<a-form-item :label="$t('numberColumns')">
<a-input-number v-model="colCount" :min="1" :max="99999" :placeholder="$t('pleaseEnter')+$t('numberColumns')" :formatter="limitNumber" :parser="limitNumber" style="width: 100%" />
</a-form-item>
<a-form-model
class="number-content"
:model="rowColForm"
:rules="validatorRowColRules"
ref="numberRowColForm"
>
<a-form-model-item :label="$t('numberRows')" prop="rowCount">
<!-- <a-form-item :label="$t('numberRows')">-->
<a-input-number v-model="rowColForm.rowCount" :min="1" :max="100" :placeholder="$t('pleaseEnter')+$t('numberRows')" :formatter="limitNumber" :parser="limitNumber" style="width: 100%" />
<!-- </a-form-item>-->
</a-form-model-item>
<a-form-model-item :label="$t('numberColumns')" prop="colCount">
<!-- <a-form-item :label="$t('numberColumns')">-->
<a-input-number v-model="rowColForm.colCount" :min="1" :max="100" :placeholder="$t('pleaseEnter')+$t('numberColumns')" :formatter="limitNumber" :parser="limitNumber" style="width: 100%" />
<!-- </a-form-item>-->
</a-form-model-item>
</a-form-model>
</a-form>
</a-modal>
<!-- 表格弹框-->
@@ -533,8 +544,18 @@
]
},
numberFlag:false,
rowColForm:{},
validatorRowColRules:{
colCount:[
{ required: true, message: this.$t('pleaseEnter')+this.$t('numberRows'),trigger: 'blur'},
],
rowCount:[
{ required: true, message: this.$t('pleaseEnter')+this.$t('numberColumns'),trigger: 'blur'},
]
},
itemVal:{},
contentTrees:'',
isTableEdit:false,
}
},
@@ -634,7 +655,11 @@
},
//编辑按钮
splitEdit(index,item){
console.log('item',item)
this.addIndex=index
this.tableVisible=true
this.isTableEdit=true
this.ueContent=item.itemContent
this.$nextTick(() => {
this.$refs.ueditor.setContent(item.itemContent)
})
@@ -810,68 +835,90 @@
},
//表格确认按钮
handleOkTable(){
this.tableVisible=false
this.contentList[this.addIndex+1]= {
id:'',
type:'TABLE',
itemContent:this.ueContent
let ueContent=[]
ueContent = this.ueContent.match(/<table.{0,}?.+?>{0,}?<\/table>/g)||[];
// console.log('uuuuuu',ueContent)
if(ueContent&&ueContent.length>1){
this.$message.warning(this.$t('oneTableAdded'))
}else if(!ueContent||ueContent.length<1){
this.$message.warning(this.$t('addATable'))
} if(ueContent&&ueContent.length==1){
this.tableVisible=false
if(this.isTableEdit){
this.contentList[this.addIndex]= {
id:'',
type:'TABLE',
itemContent:ueContent[0]
}
}else{
for(let i = this.contentList.length;i>this.addIndex;i--){
this.contentList[i+ueContent.length-1]=this.contentList[i-1]
}
this.contentList[++this.addIndex]= {
id:'',
type:'TABLE',
itemContent:ueContent[0]
}
}
this.isTableEdit=false
}
// this.uEditorChange()
// console.log('this.contentList',this.contentList)
},
//表格取消按钮
handleCancelTable(){
this.tableVisible=false
this.isTableEdit=false
},
//获取表格内容
uEditorChange (val) {
// this.itemContent = this.$refs.ueditor.getUEContent()
this.contentList[this.addIndex+1]= {
id:'',
type:'TABLE',
itemContent:val
}
this.ueContent=val
this.ueContent = val
// this.ueContent=val
},
//取消行数列数按钮
handleColCancel(){
this.tableColVisible=false
this.rowCount=''
this.colCount=''
this.rowColForm.rowCount=''
this.rowColForm.colCount=''
},
//确定行数列数按钮
handleColOk(){
this.tableColVisible=false
this.tableVisible=true
if(this.rowCount>0&&this.colCount>0){
let tableList=[]
let tableStr=''
tableStr='<table class=\"word-table\" border="1" cellpadding="0" cellspacing="0">'
for(let r=0;r<this.rowCount;r++){
let rowTableList=[]
tableStr+='<tr>'
for(let c=0;c<this.colCount;c++){
tableStr+=`<td></td>`
let tableItem={}
tableItem.id=''
tableItem.rowNum=r+1
tableItem.colNum=c+1
tableItem.content=''
rowTableList.push(tableItem)
this.$refs.numberRowColForm.validate(valid=>{
if(valid){
this.tableColVisible=false
this.tableVisible=true
if(this.rowColForm.rowCount>0&&this.rowColForm.colCount>0){
let tableList=[]
let tableStr=''
tableStr='<table class=\"word-table\" border="1" cellpadding="0" cellspacing="0">'
for(let r=0;r<this.rowColForm.rowCount;r++){
let rowTableList=[]
tableStr+='<tr>'
for(let c=0;c<this.rowColForm.colCount;c++){
tableStr+=`<td></td>`
let tableItem={}
tableItem.id=''
tableItem.rowNum=r+1
tableItem.colNum=c+1
tableItem.content=''
rowTableList.push(tableItem)
}
tableStr+=`</tr>`
tableList.push(rowTableList)
}
tableStr+=`</tr>`
tableList.push(rowTableList)
}
tableStr+=`</table>`
this.ueContent=tableStr
tableStr+=`</table>`
this.ueContent=tableStr
this.$nextTick(() => {
this.$refs.ueditor.setContent(this.ueContent)
})
this.rowCount=''
this.colCount=''
}
this.$nextTick(() => {
this.$refs.ueditor.setContent(this.ueContent)
})
this.rowColForm.rowCount=''
this.rowColForm.colCount=''
}
}
})
// console.log('cont1111',this.addIndex,this.contentList)
},
dateChange(item) {