修改bug

This commit is contained in:
caoyang
2022-03-18 14:09:42 +08:00
parent 109c2db9a2
commit 3279309a01
25 changed files with 87 additions and 168 deletions
@@ -0,0 +1,652 @@
<template>
<div class="split-add-form">
<div class="split-add-form-wrapper">
<a-drawer
class="split-table-drawer"
:title="title"
placement="right"
:visible="visible"
:after-visible-change="afterVisibleChange"
@close="onClose"
width="900"
>
<a-form>
<a-form-model
class="split-content"
:model="form"
:rules="validatorRules"
ref="splitEditForm"
:label-col="labelCol"
:wrapper-col="wrapperCol"
>
<!-- 条款号-->
<a-row :gutter="24">
<a-col :span="12">
<a-form-model-item :label="$t('clauseNo')" prop="number">
<a-input v-model="form.number" :placeholder="$t('pleaseEnter')+$t('clauseNo')" />
</a-form-model-item>
</a-col>
<!-- 条款名称-->
<a-col :span="12">
<a-form-model-item :label="$t('clauseName')" prop="name">
<a-input v-model="form.name" :placeholder="$t('pleaseEnter')+$t('clauseName')" />
</a-form-model-item>
</a-col>
</a-row>
<!-- 功能领域-->
<a-row :gutter="24">
<a-col :span="12">
<a-form-model-item :label="$t('functionalAreas')" prop="funArea">
<j-dict-select-tag type="list" v-model="form.funArea" dictCode="function_territory" :placeholder="$t('pleaseSelect')+$t('functionalAreas')" />
</a-form-model-item>
</a-col>
<!-- 技术领域-->
<a-col :span="12">
<a-form-model-item :label="$t('technicalField')" prop="tecArea">
<j-dict-select-tag type="list" v-model="form.tecArea" dictCode="technology_territory" :placeholder="$t('pleaseSelect')+$t('technicalField')" />
</a-form-model-item>
</a-col>
</a-row>
<!-- 信息类别-->
<a-row :gutter="24">
<a-col :span="12">
<a-form-model-item :label="$t('informationCategory')" prop="infoType">
<j-dict-select-tag type="list" v-model="form.infoType" dictCode="xxx" :placeholder="$t('pleaseSelect')+$t('informationCategory')" />
</a-form-model-item>
</a-col>
</a-row>
<!-- 内容简介-->
<span class="con-divider">{{$t('contentValidity')}}</span>
<a-divider dashed />
<div class="table-operator">
<div class="operator-text" @click="splitAdd('-1')">
<a-icon type="plus" />
{{$t('Add')}}
</div>
</div>
<a-row :gutter="24" class="split-content" id="split-content" v-for="(item, index) in contentList" :key="index">
<div class="split-row">
<div class="row-left">
<a-textarea v-if="item.type==='TEXT'" v-model="item.textContent" :placeholder="$t('pleaseEnter')+$t('content')" auto-size />
<img v-if="item.type==='IMG'" :src="item.src" alt="" @click="preImg(item)">
<div v-if="item.type==='TABLE'" v-html="item.content" class="item-table"></div>
</div>
<div class="row-right">
<a-button class="row-btn-add" @click="splitAdd(index)">{{$t('Add')}}</a-button>
<a-button @click="splitDelete">{{$t('delete')}}</a-button>
</div>
</div>
</a-row>
</a-form-model>
</a-form>
<div class="split-form-footer">
<a-button type="primary" class="footer-btn-save" @click="splitSave">{{$t('preservation')}}</a-button>
<a-button type="primary" @click="splitCancel">{{$t('cancel')}}</a-button>
</div>
<!-- 图片预览-->
<a-modal
:title="TitlePreImg"
class="split-img"
:visible="preImgVisible"
:confirm-loading="confirmLoading"
@ok="handleOk"
@cancel="handlePreImgCancel"
:footer="false"
>
<img :src="itemSrc" alt="">
</a-modal>
<!-- 类型选择弹框-->
<a-modal
:title="Title"
class="split-title"
:visible="addConVisible"
:confirm-loading="confirmLoading"
@ok="handleOk"
@cancel="handleCancel"
>
<div class="title-wraper">
<div class="title-top">
<span class="title-flex title-text" :class="{'title-flex-active':selected==1}" @click="selectTitle(1)">{{$t('text')}}</span>
<span class="title-flex title-pic" :class="{'title-flex-active':selected==2}" @click="selectTitle(2)">{{$t('picture')}}</span>
<span class="title-flex title-table" :class="{'title-flex-active':selected==3}" @click="selectTitle(3)">{{$t('table')}}</span>
</div>
<div class="title-num" v-if="selectedNum">
<span class="title-num-add">{{$t('addQuantity')}}</span>
<a-input-number class="title-num-edit" :min="1" v-model="textNumber" :placeholder="$t('enterQuantity')" :formatter="limitNumber" :parser="limitNumber"></a-input-number>
</div>
</div>
</a-modal>
<!-- 上传图片弹框-->
<split-upload v-if="splitVisible" ref="uploadFile2" :disabled="disabled" :accept="accept" :title="titleImg" :listType='listType' :splitVisible="splitVisible" @uploadSuccess="uploadSuccess"></split-upload>
<!-- 输入表格行数列数-->
<a-modal
:title="titleColRow"
class="split-col-title"
:visible="tableColVisible"
:confirm-loading="confirmLoading"
@ok="handleColOk"
@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" :placeholder="$t('pleaseEnter')+$t('numberRows')" :formatter="limitNumber" :parser="limitNumber" />
</a-form-item>
<a-form-item :label="$t('numberColumns')">
<a-input-number v-model="colCount" :min="1" :placeholder="$t('pleaseEnter')+$t('numberColumns')" :formatter="limitNumber" :parser="limitNumber" />
</a-form-item>
</a-form>
</a-modal>
<!-- 表格弹框-->
<a-modal
:title="titleTable"
class="split-table-title"
:visible="tableVisible"
:confirm-loading="confirmLoading"
@ok="handleOkTable"
@cancel="handleCancelTable"
width="700"
>
<u-editor v-if="tableVisible" :content="ueContent" :config=config ref="ueditor" @editor-onChange="uEditorChange"></u-editor>
</a-modal>
</a-drawer>
</div>
</div>
</template>
<script>
import Vue from 'vue'
import splitUpload from '@/components/splitUpload/index'
import UEditor from '@/components/ueditor/index'
export default {
name: 'splitAddForm',
components:{
splitUpload,
UEditor
},
data(){
return{
titleTable:this.$t('table'),
titleColRow:this.$t('tableRowsColumns'),
title:this.$t('newClause'),
TitlePreImg:'',
contentList:[
{
id:'001',
type:'TEXT',
textContent:'本标准规定了车辆正面碰撞时前排外侧座椅乘员保护方面的术语和定义、要求和试验方法。'
},
{
id:'002',
type:'TEXT',
textContent:'本标准适用于M1类汽车和最大设计总质量不大于2500kg的N1类汽车,以及多用途货车。'
}
],
content:{},
selected:1,
selectedNum:true,
textNumber:1,
Title:this.$t('add'),
confirmLoading: false,
labelCol: {
xs: { span: 24 },
sm: { span: 5 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 16 },
},
visible:false,
addConVisible:false,
form:{},
validatorRules:{
number:[
{ required:true,message: this.$t('pleaseEnter')+this.$t('clauseNo'),trigger: 'blur' },
{ min:1, max: 200, message: this.$t('cantExeed')+'200'+this.$t('characters'), trigger: 'blur' }
],
name:[
{ required:true,message: this.$t('pleaseEnter')+this.$t('clauseName'),trigger: 'blur' },
{ min:1, max: 200, message: this.$t('cantExeed')+'200'+this.$t('characters'), trigger: 'blur' }
]
},
addIndex:'',
addImgVisible:false, //上传图片弹框
titleImg:this.$t('uploadPictures'),
accept:'image/*',
listType:'picture',
disabled:false,
splitVisible:false,
tableVisible:false,
preImgVisible:false, //图片预览
itemSrc:'', //预览图片
ueContent: '',
// UE编辑器配置
config: {
// 可以在此处定义工具栏的内容
toolbars: [
[
'undo', // 撤销
'redo', // 重做
'bold', // 加粗
'italic', // 斜体
'underline', // 下划线
'strikethrough', // 删除线
'subscript', // 下标
'superscript', // 上标
'fontborder', // 字符边框
'fontfamily', // 字体
'fontsize', // 字号
'forecolor', // 字体颜色
// 'backcolor', // 背景色
'paragraph', // 段落格式
'customstyle', // 自定义标题
'indent', // 首行缩进
'justifyleft', // 居左对齐
'fullscreen', // 全屏
'justifyright', // 居右对齐
'justifycenter', // 居中对齐
'justifyjustify', // 两端对齐
'lineheight', // 行间距,
'rowspacingtop', // 段前距
'rowspacingbottom', // 段后距
'directionalityltr', // 从左向右输入
'directionalityrtl', // 从右向左输入
'cleardoc', // 清空文档
'formatmatch', // 格式刷
'removeformat', // 清除格式
'source', // 源代码
'blockquote', // 引用
'pasteplain', // 纯文本粘贴模式
'selectall', // 全选
'horizontal', // 分隔线
'time', // 时间
'date', // 日期
'link', // 超链接
'unlink', // 取消链接
// 'background', // 背景
// 'simpleupload', // 单图上传
'imagenone', // 默认
'imageleft', // 左浮动
'imageright', // 右浮动
'imagecenter', // 居中
'touppercase', // 字母大写
'tolowercase', // 字母小写
'emotion', // 表情
'spechars', // 特殊字符
'searchreplace', // 查询替换
'insertunorderedlist', // 无序列表
'insertorderedlist', // 有序列表
'pagebreak', // 分页
'insertframe', // 插入Iframe
'charts', // 图表
'edittip ', // 编辑提示
'autotypeset', // 自动排版
'drafts', // 从草稿箱加载
'inserttable', // 插入表格
'deletetable', // 删除表格,
'insertparagraphbeforetable', // ”表格前插入行”
'insertrow', // 前插入行
'insertcol', // 前插入列
'mergeright', // 右合并单元格
'mergedown', // 下合并单元格
'deleterow', // 删除行
'deletecol', // 删除列
'splittorows', // 拆分成行
'splittocols', // 拆分成列
'splittocells', // 完全拆分单元格
'inserttitle', // 插入标题
'deletecaption', // 删除表格标题,
'mergecells', // 合并多个单元格
'edittable', // 表格属性
'edittd' // 单元格属性
]
],
autoHeightEnabled: false,
autoFloatEnabled: false,
initialContent: '', // 初始化编辑器的内容,也可以通过textarea/script给值,看官网例子
autoClearinitialContent: true, // 是否自动清除编辑器初始内容,注意:如果focus属性设置为true,这个也为真,那么编辑器一上来就会触发导致初始化的内容看不到了
initialFrameWidth: 650,
elementPathEnabled: false,
initialFrameHeight: 300,
maximumWords: 4000,
BaseUrl: '',
UEDITOR_HOME_URL: '/ueditor/',
editTableIndex: 1,
},
tableColVisible:false,
colCount:'', //列数
rowCount:'', //行数
}
},
props:{
addVisible:Boolean
},
watch:{
selected(val){
if(this.selected==1){
this.selectedNum=true
}else{
this.selectedNum=false
}
}
},
mounted() {
this.visible=this.addVisible
},
methods:{
afterVisibleChange(){
},
onClose(){
this.$emit('closeVisible',false)
},
//增加按钮
splitAdd(val){
this.addConVisible=true
if(val=='-1'){
this.addIndex=this.contentList.length-1
}else{
this.addIndex=val
}
},
//删除按钮
splitDelete(){
},
//保存
splitSave(){
this.$refs.splitEditForm.validate(valid=>{
if(valid){
}
})
},
//取消
splitCancel(){
this.visible=false
this.$emit('closeVisible',false)
},
//确定增加的类型
handleOk(){
this.addConVisible=false
let contentLength=this.contentList.length
if(this.selected==1){ //文本类型
for(let i=this.contentList.length;i>this.addIndex;i--){
this.contentList[i+contentLength-1]=this.contentList[i-1]
}
for(let j=0;j<this.textNumber;j++){
this.contentList[++this.addIndex]={
id:'003',
type:'TEXT',
textContent:''
}
}
}else if(this.selected==2){ //图片类型
this.splitVisible=true
}else if(this.selected==3){ //表格类型
this.tableColVisible=true
}
console.log('conteend',this.contentList)
},
handleCancel(){
this.addConVisible=false
},
selectTitle(val){
this.selected=val
},
//上传文件
uploadSuccess(data,imgs) {
let lengthImg=imgs.length
for(let i = this.contentList.length;i>this.addIndex;i--){
this.contentList[i+lengthImg-1]=this.contentList[i-1]
}
if(imgs && imgs.length > 0){
imgs.forEach(item => {
this.contentList[++this.addIndex]={
type:'IMG',
src:item.thumbUrl
}
})
}
this.splitVisible=false
},
//点击图片预览
preImg(item){
this.itemSrc=item.src
this.preImgVisible=true
},
//关闭预览图片
handlePreImgCancel(){
this.preImgVisible=false
},
//表格确认按钮
handleOkTable(){
this.tableVisible=false
},
//表格取消按钮
handleCancelTable(){
this.tableVisible=false
},
//获取表格内容
uEditorChange (val) {
// this.itemContent = this.$refs.ueditor.getUEContent()
this.contentList[this.addIndex+1]= {
id:'',
type:'TABLE',
content:val
}
},
//取消行数列数按钮
handleColCancel(){
this.tableColVisible=false
},
//确定行数列数按钮
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)
}
tableStr+=`</tr>`
tableList.push(rowTableList)
}
tableStr+=`</table>`
this.ueContent=tableStr
this.contentList[this.addIndex+1]= {
id:'',
type:'TABLE',
content:tableStr
}
this.$nextTick(() => {
this.$refs.ueditor.setContent(this.ueContent)
})
}
console.log('cont1111',this.addIndex,this.contentList)
},
//正则替换小数点
limitNumber(value) {
if (typeof value === 'string') {
return !isNaN(Number(value)) ? value.replace(/\./g, '') : 0
} else if (typeof value === 'number') {
return !isNaN(value) ? String(value).replace(/\./g, '') : 0
} else {
return 0
}
},
}
}
</script>
<style lang="less" scoped>
@import '~@assets/less/common.less';
.split-add-form{
.split-add-form-wrapper{
}
}
.split-table-drawer{
.split-content{
.con-divider{
font-size: 16px;
font-weight: 500;
color: rgba(0, 0, 0, 0.85)
}
.table-operator{
margin-bottom: 20px;
text-align: right;
}
.split-row{
display: flex;
justify-content: space-between;
margin: 0 20px 20px;
.row-left{
flex: 1;
/*border:1px solid #9e9e9e;*/
img{
cursor: pointer;
width: 32px;
height: 32px;
}
.item-table{
table{
width: 100%!important;
}
}
}
.row-right{
min-width: 150px;
margin-left: 20px;
.row-btn-add{
margin-right: 20px;
}
}
}
}
.split-form-footer{
margin-top: 20px;
text-align: center;
.footer-btn-save{
margin-right: 20px;
}
}
}
.split-title{
.title-wraper {
.title-top {
display: flex;
justify-content: space-around;
.title-flex {
border: 1px solid #d9d9d9;
padding: 10px 40px;
cursor: pointer;
}
.title-flex-active {
background: #00B3BE;
border-color: #00B3BE;
color:#FFFFFF;
}
}
.title-num {
margin: 20px 20px 0;
line-height: 32px;
display: flex;
justify-content: start;
.title-num-add {
min-width: 70px;
}
.title-num-edit {
flex: 1;
}
}
}
}
.split-img{
margin-top: 20px;
text-align: center;
img{
}
}
</style>
<style lang="less">
.split-title{
.ant-modal-footer{
text-align: center;
}
}
.split-table-drawer{
.ant-drawer-content-wrapper{
.row-left{
.item-table{
height: 100%;
table.word-table {
width: 100%;
height: 100%;
}
}
}
}
.ant-col-sm-5{
min-width: 170px;
}
.ant-col-sm-16{
width: 58%;
}
}
.split-table-title{
.ant-modal{
width: 700px;
.ant-modal-content{
width: 700px;
}
}
}
.split-col-title{
.ant-col-5{
.ant-input-number{
min-width: 260px;
}
}
.ant-modal-footer{
text-align: center;
}
}
</style>