Files
laws_weilai/jero-web/src/views/documentManage/splitting/modules/SplitAddForm.vue
T
2022-09-02 11:31:29 +08:00

1433 lines
52 KiB
Java

<template>
<div class="split-add-form">
<div class="split-add-form-wrapper">
<a-drawer
class="split-table-drawer"
:title="formTitle"
placement="right"
:visible="visible"
:after-visible-change="afterVisibleChange"
@close="onClose"
width="900"
>
<!-- :label-col="labelCol"-->
<!-- :wrapper-col="wrapperCol"-->
<a-spin :spinning="loading">
<a-form>
<a-form-model
class="split-content"
:model="formInline"
:rules="rules"
ref="splitEditForm"
>
<a-row :gutter="24" class="split-form-row">
<a-col :span="12" v-for="(item,index) in dataList" :key="index">
<div class="box-title-text" v-if="item.field_show_type === '1' || item.field_show_type === '11'">
<div class="title-text">
<span class="Required" v-if="item.field_must_input == 1">*</span>
<span class="title-text-text" :title="item.db_field_txt">{{item.db_field_txt}}</span>
</div>
<a-form-model-item class="itemModel" :prop="item.db_field_name">
<a-input class="box-input"
:disabled="disabled"
v-model="formInline[item.db_field_name]"
:placeholder="$t('PleaseEnter')+item.db_field_txt"/>
</a-form-model-item>
</div>
<div class="box-title-text" v-else-if="item.field_show_type === '2'">
<div class="title-text">
<span class="Required" v-if="item.field_must_input == 1">*</span>
<span class="title-text-text" :title="item.db_field_txt">{{item.db_field_txt}}</span>
</div>
<a-form-model-item class="itemModel" :prop="item.db_field_name">
<a-input-number class="box-input"
:placeholder="$t('PleaseEnter')+item.db_field_txt"
:disabled="disabled"
:min="0"
v-model="formInline[item.db_field_name]" :max="99999999"/>
</a-form-model-item>
</div>
<div class="box-title-text" v-else-if="item.field_show_type === '3'">
<div class="title-text">
<span class="Required" v-if="item.field_must_input == 1">*</span>
<span class="title-text-text" :title="item.db_field_txt">{{item.db_field_txt}}</span>
</div>
<a-form-model-item class="itemModel" :prop="item.db_field_name">
<j-dict-select-tag class="box-input" v-model="formInline[item.db_field_name]"
:disabled="disabled"
@input="handleInput(item.db_field_name)"
:placeholder="$t('PleaseSelect')+item.db_field_txt"
:type="'select'"
:triggerChange="false" :dictCode="item.dict_field"/>
</a-form-model-item>
</div>
<div class="box-title-text" v-else-if="item.field_show_type === '4'">
<div class="title-text">
<span class="Required" v-if="item.field_must_input == 1">*</span>
<span class="title-text-text" :title="item.db_field_txt">{{item.db_field_txt}}</span>
</div>
<a-form-model-item class="itemModel-multi" :prop="item.db_field_name">
<j-multi-select-tag class="box-input" v-model="formInline[item.db_field_name]"
:disabled="disabled"
:placeholder="$t('PleaseSelect')+item.db_field_txt"
:type="'select'"
:triggerChange="false" :dictCode="item.dict_field"/>
</a-form-model-item>
</div>
<div class="box-title-text" v-else-if="item.field_show_type === '5'">
<div class="title-text">
<span class="Required" v-if="item.field_must_input == 1">*</span>
<span class="title-text-text" :title="item.db_field_txt">{{item.db_field_txt}}</span>
</div>
<a-form-model-item class="itemModel" :prop="item.db_field_name">
<a-date-picker class="box-input"
@change="dateChange(item)"
format="YYYY-MM-DD"
:getCalendarContainer="(trigger) => trigger.parentNode"
v-model="formInline[item.db_field_name]"
:disabled="disabled"
style="width: 100%"/>
<!-- :disabledDate="disabledDate"-->
</a-form-model-item>
</div>
<div class="box-title-text" v-else-if="item.field_show_type === '6'">
<div class="title-text">
<span class="Required" v-if="item.field_must_input == 1">*</span>
<span class="title-text-text" :title="item.db_field_txt">{{item.db_field_txt}}</span>
</div>
<a-form-model-item class="itemModel" :prop="item.db_field_name">
<a-range-picker class="box-input" v-model="formInline[item.db_field_name]"
:disabled="disabled"
@change="onChange(item.db_field_name)"></a-range-picker>
</a-form-model-item>
</div>
<div class="box-title-text" v-else-if="item.field_show_type === '7'">
<div class="title-text">
<span class="Required" v-if="item.field_must_input == 1">*</span>
<span class="title-text-text" :title="item.db_field_txt">{{item.db_field_txt}}</span>
</div>
<a-form-model-item class="itemModel" :prop="item.db_field_name">
<a-button type="primary" class="button-text"
@click="clickButtonToUpload(item)">
{{ (formInline[item.db_field_name] === 'null' || formInline[item.db_field_name] === '' ||
formInline[item.db_field_name] == null) ? $t('clickUpload') : $t('viewUploadedFiles')
}}
</a-button>
<!-- <span class="button-text-text" v-if="formInline[item.db_field_name]">-->
<!-- {{formInline[item.db_field_name].split(',').length}}-->
<!-- </span>-->
</a-form-model-item>
</div>
<div class="box-title-text" v-else-if="item.field_show_type === '8'">
<div class="title-text">
<span class="Required" v-if="item.field_must_input == 1">*</span>
<span class="title-text-text" :title="item.db_field_txt">{{item.db_field_txt}}</span>
</div>
<a-form-model-item class="itemModel" :prop="item.db_field_name">
<a-textarea
:placeholder="$t('PleaseEnter')+item.db_field_txt"
:disabled="disabled"
v-model="formInline[item.db_field_name]" :rows="4"/>
</a-form-model-item>
</div>
<div class="box-title-text" v-else-if="item.field_show_type === '9' || item.field_show_type == 'sel_user'">
<div class="title-text">
<span class="Required" v-if="item.field_must_input == 1">*</span>
<span class="title-text-text" :title="item.db_field_txt">{{item.db_field_txt}}</span>
</div>
<a-form-model-item class="itemModel" :prop="item.db_field_name">
<PersonnelSelection :query="item"
:personneQuery="formInline"
@change="PersonnelSelectionChange"
:disabled="disabled"
v-model="formInline[item.db_field_name]"/>
</a-form-model-item>
</div>
<div class="box-title-text" v-else-if="item.field_show_type === '10'">
<div class="title-text">
<span class="Required" v-if="item.field_must_input == 1">*</span>
<span class="title-text-text" :title="item.db_field_txt">{{item.db_field_txt}}</span>
</div>
<a-form-model-item class="itemModel" :prop="item.db_field_name">
<Standardselection :query="item"
:disabled="disabled"
:standard="formInline"
v-model="formInline[item.db_field_name]"/>
</a-form-model-item>
</div>
<div class="box-title-text" v-else-if="item.field_show_type === 'RADIO'">
<div class="title-text">
<span class="Required" v-if="item.field_must_input == 1">*</span>
<span class="title-text-text" :title="item.db_field_txt">{{item.db_field_txt}}</span>
</div>
<a-form-model-item class="itemModel" :prop="item.db_field_name">
<j-dict-select-tag v-model="formInline[item.db_field_name]"
:disabled="disabled"
class="box-input"
@input="handleInput(item.db_field_name)"
:placeholder="$t('PleaseSelect')+item.db_field_txt"
:type="'radio'" :triggerChange="false" :dictCode="item.dict_field"/>
</a-form-model-item>
</div>
<div class="box-title-text" :title="item.db_field_txt" v-else-if="item.field_show_type === '0'">
<div class="title-text">
<span class="Required" v-if="item.field_must_input == 1">*</span>
<span class="title-text-text">{{item.db_field_txt}}</span>
</div>
<a-form-model-item class="itemModel" :prop="item.db_field_name">
<a-tree-select
tree-node-filter-prop="title"
v-model="formInline[item.db_field_name]"
class="box-input"
:getPopupContainer="triggerNode=> triggerNode.parentNode"
style="width: 100%"
:tree-data="item.tree"
tree-checkable
:placeholder="$t('PleaseSelect')+item.db_field_txt"
@change="changeTree"
/>
</a-form-model-item>
</div>
<div class="box-title-text" v-else-if="item.field_show_type === 'CHECKBOX'">
<div class="title-text">
<span class="Required" v-if="item.field_must_input == 1">*</span>
<span class="title-text-text" :title="item.db_field_txt">{{item.db_field_txt}}</span>
</div>
<a-form-model-item class="itemModel-multi" :prop="item.db_field_name">
<j-multi-select-tag class="box-input" v-model="formInline[item.db_field_name]"
:disabled="disabled"
:placeholder="$t('PleaseSelect')+item.db_field_txt"
:type="'checkbox'"
:triggerChange="false" :dictCode="item.dict_field"/>
</a-form-model-item>
</div>
</a-col>
</a-row>
<uploadFile ref="uploadFile" :accept="accept" @uploadSuccess="uploadSuccess"></uploadFile>
<span class="con-divider">{{$t('clauseContent')}}</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-row" 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.itemContent" :show-count="true" :maxlength="1000" :placeholder="$t('pleaseEnter')+$t('content')" />
<viewer>
<img v-if="item.type==='IMG'" :src="item.thumbUrl?item.thumbUrl:item.itemContent" alt="">
</viewer>
<!-- <img v-if="item.type==='IMG'" :src="item.thumbUrl?item.thumbUrl:item.itemContent" alt="" @click="preImg(item)">-->
<div v-if="item.type==='TABLE'" v-html="item.itemContent" class="item-table"></div>
</div>
<div class="row-right">
<a-button class="row-btn-add" @click="splitAdd(index)">{{$t('Add')}}</a-button>
<a-button class="row-btn-edit" @click="splitEdit(index,item)" v-if="item.type=='TABLE'">{{$t('edit')}}</a-button>
<a-button @click="splitDelete(item,index)">{{$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 @click="splitCancel">{{$t('cancel')}}</a-button>
</div>
</a-spin>
<!-- 图片预览-->
<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="$t('Add')"
class="split-title"
:visible="addConVisible"
@ok="handleOk"
@cancel="handleCancel"
>
<div class="title-wraper">
<div class="title-top">
<span class="title-flex title-text-flex" :class="{'title-flex-active':selected=='TEXT'}" @click="selectTitle('TEXT')">{{$t('text')}}</span>
<span class="title-flex title-pic" :class="{'title-flex-active':selected=='IMG'}" @click="selectTitle('IMG')">{{$t('picture')}}</span>
<span class="title-flex title-table" :class="{'title-flex-active':selected=='TABLE'}" @click="selectTitle('TABLE')">{{$t('table')}}</span>
</div>
<div class="title-num" v-if="selectedNum">
<a-form>
<a-form-model
class="number-content"
:model="numberForm"
:rules="validatorRules"
ref="numberForm"
>
<a-form-model-item :label="$t('addQuantity')" prop="textNumber">
<!-- <span class="title-num-add">{{$t('addQuantity')}}</span>-->
<a-row :gutter="24">
<a-col :span="24">
<a-input-number class="title-num-edit box-input" :min="0" :max="100" v-model="numberForm.textNumber" :placeholder="$t('enterQuantity')" :formatter="limitNumber" :parser="limitNumber" ></a-input-number>
</a-col>
</a-row>
</a-form-model-item>
</a-form-model>
</a-form>
</div>
</div>
</a-modal>
<!-- 上传图片弹框-->
<split-upload v-if="splitVisible" ref="uploadFile2" :disabled="disabled" :title="titleImg" :listType='listType' :splitVisible="splitVisible" :accept="accept" @coloseHandle="coloseHandle" @uploadSuccess="uploadSuccess1"></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-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 class="box-input" 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 class="box-input" 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>
<!-- 表格弹框-->
<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 {Base64} from 'js-base64'
import uploadFile from '@/components/uploadFile/file'
import Standardselection from '@/components/Standardselection/index'
import PersonnelSelection from '@/components/PersonnelSelection/index'
import SplitUpload from '@/components/SplitUpload/index'
import UEditor from '@/components/ueditor/index'
import moment from 'moment'
import axios from 'axios'
import { getAction, postAction } from '@/api/manage'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import eventBUs from '../../../../common/event'
// import eventBUs from '../../common/event'
export default {
name: 'splitAddForm',
components:{
uploadFile,
Standardselection,
PersonnelSelection,
SplitUpload,
UEditor
},
data(){
return{
titleTable:this.$t('table'),
titleColRow:this.$t('tableRowsColumns'),
title:this.$t('newClause'),
TitlePreImg:'',
contentList:[],
content:{},
selected:'TEXT',
selectedNum:true,
textNumber:null,
Title:this.$t('add'),
confirmLoading: false,
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:'', //行数
formInline: {},
isFormInline: false,
labelCol: {
xs: { span: 24 },
sm: { span: 6 }
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 17 }
},
dataList: [],
ruleList: [],
rules: {},
confirmLoading: false,
uploadName: '',
type: 'add',
loading:false,
token:Vue.ls.get(ACCESS_TOKEN),
submitFlag:false,
deleteIds:[],
numberForm:{},
validatorRules:{
textNumber:[
{ required: true, message: this.$t('enterQuantity'),trigger: 'blur'},
]
},
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,
// 新增添加字段
standardSelectionContent: [], // 所选择的标准选择的全部字段
formArrayName: [], // 标准选择的名字
formArrayId: [], // 标准选择的id
valueItem: '' // 标准选择的自定义字段名
}
},
props:{
addVisible: {
type:Boolean,
default:false
},
formTitle:{
type:String,
default:''
},
url: {
type: Object,
default: {}
},
flag: {
type: String,
default: ''
},
infoId:{
type:String,
default:''
},
menuId:{
type:String,
default:''
},
itemId:{
type:String,
default:''
},
// itemVal:{
// type:Object,
// default:{}
// }
},
watch:{
selected(val){
if(this.selected==='TEXT'){
this.selectedNum=true
}else{
this.selectedNum=false
}
},
// itemVal(oldVal,newVal){
// console.log('new',oldVal,newVal)
// }
},
mounted() {
this.visible=this.addVisible
// this.formInline=this.item
// console.log('form',this.formInline,this.item)
this.loadData()
this.loadFormInfo()
},
methods:{
loadData(){
this.loading=true
getAction(`split/sarFileSplitItemsVal/getItemsValList`,{itemId:this.itemId}).then(res=>{
if(res.success){
this.contentList=[...res.result]
this.contentList.forEach(item=>{
let imgData=item.itemContent.split('fileUrl=')[1]
// console.log('imgData',imgData)
item.thumbUrl=window._CONFIG['domianURL']+'/sys/split/file/getImage?fileUrl='+imgData
// item.thumbUrl=Base64.encode(item.itemContent)
})
// window._CONFIG['domianURL']+'/sys/split/file/getImage?fileUrl='+Base64.encode(file.response.result.url)
}
}).finally(()=>{
this.loading=false
})
},
//获取表单信息
loadFormInfo(){
getAction(`split/sarFileSplitItems/getSplitItemsById`,{id:this.itemId}).then(res=>{
if(res.success){
// todo
// console.log(res,'res...')
this.formInline=[...res.result]
}
})
},
afterVisibleChange(){
},
onClose(){
this.$emit('closeVisible',false)
},
//增加按钮
splitAdd(val){
this.addConVisible=true
// this.numberForm.textNumber=null
if(val=='-1'){
this.addIndex=this.contentList.length-1
}else{
this.addIndex=val
}
},
//编辑按钮
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)
})
// console.log('ineciem',index,item)
},
//删除按钮
splitDelete(item,index){
// console.log('itme',item,this.contentList)
if(item.id){
this.deleteIds.push(item.id)
}
for(let i=index;i<this.contentList.length-1;i++){
this.contentList[index]=this.contentList[index+1]
}
this.contentList.pop()
// console.log('this.content',this.contentList)
},
//保存
splitSave(){
// todo
this.$refs.splitEditForm.validate(valid=>{
if(valid){
this.loading = true
if(!this.submitFlag){
this.submitFlag=true
let url = ''
if (this.formInline.id) {
url = this.url.updateInfo
} else {
url = this.url.addInfo
// 标准编号 -- 选取或者填写的
// let _formInlinevalueItem = this.formInline[this.valueItem].split(',')
// // 标准编号的id临时变量
// let _valueItemArr = []
// if(this.formArrayName.length > 0) {
// this.formArrayName.forEach((item, index) => {
// _formInlinevalueItem.forEach((itemlabel, indexlabel) => {
// if(itemlabel === item) {
// _valueItemArr.push(this.formArrayId[index])
// }
// })
// })
// }
// if(_valueItemArr.length > 0) {
// this.formInline[this.valueItem + '_id'] = _valueItemArr.join(',')
// } else {
// this.formInline[this.valueItem + '_id'] = ''
// }
}
let params = JSON.parse(JSON.stringify(this.formInline))
Object.keys(params).forEach(res => {
if (params[res] instanceof Array) {
params[res] = params[res].join(',')
}
})
params.info_id=this.infoId
params.menu_id=this.menuId
if (this.formInline.id) {
params.menu_id=this.itemVal.menu_id
}
// console.log(this.contentList,'this.contentListthis.contentList')
let contentList=JSON.parse(JSON.stringify(this.contentList))
contentList.forEach((item,index)=>{
if(item.type==='IMG'){
// console.log('img',item)
this.$delete(item,'thumbUrl')
// contentList[index]= { ...item }
}
})
// console.log('contentList',contentList)
params.itemValEOList=contentList
// console.log('paramsformInline',params)
params.delItemIds=this.deleteIds.join(',')
axios({
url: url,
method: 'post',
data: params,
headers: {
'X-Access-Token':this.token
}
})
.then( (res) =>{
if (res.data.success) {
this.loading = false
this.$message.success(this.$t('OperationSuccessful'))
this.visible=false
// this.$emit('closeVisible',false)
let queryParam={
menu_id:this.menuId,
info_id: this.infoId,
}
eventBUs.$emit('searchGetData', JSON.parse(JSON.stringify(queryParam)))
// eventBUs.$emit('searchReset')
this.$emit('sumber')
}else{
this.$message.warning(this.$t('operationFailed'))
}
})
.catch( (error) =>{
console.log(error);
}).finally(()=>{
this.visible=false
this.$emit('closeVisible',false)
this.loading=false
this.submitFlag=false
})
}
}
})
},
//取消
splitCancel(){
this.visible=false
this.$emit('closeVisible',false)
},
//确定增加的类型
handleOk(){
// console.log('seletype',this.selected)
let contentLength=this.contentList.length
if(this.selected=='TEXT'){ //文本类型
// console.log('contentList111111',this.contentList)
this.$refs.numberForm.validate(valid=>{
if(valid){
if(!this.numberFlag){
this.numberFlag=true
for(let i=this.contentList.length;i>this.addIndex;i--){
this.contentList[i+this.numberForm.textNumber-1]=this.contentList[i-1]
}
for(let j=0;j<this.numberForm.textNumber;j++){
this.contentList[++this.addIndex]={
id:'',
type:'TEXT',
itemContent:''
}
}
this.addConVisible=false
this.numberFlag=false
this.numberForm.textNumber=null
// console.log('contentList',this.contentList)
}
}
})
}else if(this.selected=='IMG'){ //图片类型
// this.$refs.uploadFile2.visible=true
this.splitVisible=true
this.addConVisible=false
}else if(this.selected=='TABLE'){ //表格类型
this.tableColVisible=true
this.addConVisible=false
}
},
handleCancel(){
this.addConVisible=false
},
selectTitle(val){
this.selected=val
},
//上传文件
uploadSuccess1(file,data,imgs ,uploadFileFlag) {
// console.log('dataimg',file,data,imgs,uploadFileFlag)
for(let i = this.contentList.length;i>this.addIndex;i--){
this.contentList[i]=this.contentList[i-1]
}
this.contentList[++this.addIndex]={
id:'',
type:'IMG',
itemContent:file.response.result.url,
thumbUrl:window._CONFIG['domianURL']+'/sys/split/file/getImage?fileUrl='+file.response.result.url.split('fileUrl=')[1]
}
// console.log('baseDecode',Base64.decode(this.contentList[this.addIndex].thumbUrl))
// 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]={
// id:'',
// type:'IMG',
// itemContent:item.response.result.id,
// thumbUrl:item.response.result.url
// }
// })
// }
// this.$refs.uploadFile2.visible=false
if(uploadFileFlag==0){
this.splitVisible=false
}
// console.log('conteend',imgs,this.contentList)
},
//点击图片预览
// preImg(item){
// this.itemSrc=item.thumbUrl?item.thumbUrl:item.itemContent
// this.preImgVisible=true
// },
//关闭预览图片
handlePreImgCancel(){
this.preImgVisible=false
},
//表格确认按钮
handleOkTable(){
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
}
},
//表格取消按钮
handleCancelTable(){
this.tableVisible=false
this.isTableEdit=false
},
//获取表格内容
uEditorChange (val) {
// this.itemContent = this.$refs.ueditor.getUEContent()
this.ueContent = val
// this.ueContent=val
},
//取消行数列数按钮
handleColCancel(){
this.tableColVisible=false
this.rowColForm.rowCount=''
this.rowColForm.colCount=''
},
//确定行数列数按钮
handleColOk(){
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+=`</table>`
this.ueContent=tableStr
this.$nextTick(() => {
this.$refs.ueditor.setContent(this.ueContent)
})
this.rowColForm.rowCount=''
this.rowColForm.colCount=''
}
}
})
// console.log('cont1111',this.addIndex,this.contentList)
},
dateChange(item) {
this.formInline[item.db_field_name] = this.formInline[item.db_field_name] ? moment(this.formInline[item.db_field_name]).format('YYYY-MM-DD') : ''
},
onChange(item) {
let dateOne = moment(this.formInline[item][0]).format('YYYY-MM-DD')
let dateTwo = moment(this.formInline[item][1]).format('YYYY-MM-DD')
this.formInline[item] = dateOne ? [dateOne, dateTwo] : []
},
clickButtonToUpload(item) {
this.$refs.uploadFile.perentHandleFunc()
this.$refs.uploadFile.state = item.flag
this.$refs.uploadFile.visible = true
this.uploadName = item.db_field_name
getAction('sys/common/getFileInfos', { id: this.formInline[item.db_field_name] }).then((res) => {
if (res.success) {
this.$refs.uploadFile.perentHandleFunc(res.result)
} else {
this.$refs.uploadFile.perentHandleFunc()
}
})
},
/** 上传文件的回调 */
uploadSuccess(data) {
// console.log('dataaaaa',data)
let attIdList = []
if (data && data.length > 0) {
data.map(item => {
attIdList.push(item.id || data.name)
})
}
/** 赋值给当前对应的表单文件 */
this.formInline[this.uploadName] = attIdList.join(',')
this.formInline = { ...this.formInline }
},
//关闭上传
coloseHandle(){
this.splitVisible=false
},
handleInput(value) {
this.$nextTick(() => {
this.formInline = { ...this.formInline }
this.$refs.splitEditForm.validateField([value])
})
},
IntegrateData() {
this.isFormInline = false
let ruleList = []
// this.ruleList.forEach(res => {
// Object.keys(res).forEach(val => {
// res[val].forEach(ol => {
// ruleList.push(ol)
// })
// })
// })
let rules = {}
this.ruleList.forEach((res, index) => {
const rule = []
if (res.field_must_input == 1) {
if (res.field_show_type === '1') {
rule.push({
required: true,
message: res.db_field_txt + this.$t('cannotEmpty'),
trigger: 'blur'
})
} else if (res.field_show_type === '4' || res.field_show_type === '6' ||
res.field_show_type === '5' || res.field_show_type === '7'
) {
rule.push({
required: true,
message: res.db_field_txt + this.$t('cannotEmpty'),
trigger: 'change'
})
} else if (res.field_show_type === '2') {
rule.push({
required: true,
message: res.db_field_txt + this.$t('cannotEmpty'),
trigger: 'blur'
})
} else if (res.field_show_type === '8' || res.field_show_type === '9' || res.field_show_type === '10' || res.field_show_type === '11') {
rule.push({
required: true,
message: res.db_field_txt + this.$t('cannotEmpty'),
trigger: 'blur'
})
} else if (res.field_show_type === '3') {
rule.push({
required: true,
message: res.db_field_txt + this.$t('cannotEmpty'),
trigger: 'change'
})
}
}
if (res.field_show_type === '1' ||
res.field_show_type === '8' || res.field_show_type === '9' || res.field_show_type === '10'
|| res.field_show_type === '11') {
rule.push({
max: res.db_length,
message: res.db_field_txt + this.$t('cantExeed') + res.db_length + this.$t('characters'),
trigger: 'blur'
})
}
if (rule.length > 0) {
rules[res.db_field_name] = rule
}
})
this.$set(this, 'rules', rules)
// console.log('rules',this.rules)
this.isFormInline = true
this.confirmLoading = false
// console.log('this.column',this.column)
},
getForm(callBack) {
this.confirmLoading = true
let params = {
flag: this.flag,
type: this.type
}
getAction(this.url.getAddForm, params).then((res) => {
if (res.success) {
this.dataList = res.result
this.ruleList = res.result
// console.log('res',this.dataList)
this.IntegrateData()
callBack && callBack()
}
})
},
edit(item) {
this.visible=true
this.type = 'edit'
this.itemVal=item
// this.getForm(() => {
// this.formInline=item
// })
this.getForm(() => {
getAction(this.url.getDocumentInfo, { id: item.id }).then((res) => {
if (res.success) {
this.formInline = res.result
// console.log('form11111',this.formInline)
}
})
})
},
add() {
this.getForm()
this.visible=true
this.formInline = {}
this.contentList=[]
this.type = 'add'
},
// changeContent(val) {
// this.standardSelectionContent = val
// },
// StandardselectionChange(value, id) {
// todo
// this.valueItem = value
// if(this.formInline[value] !== undefined) {
// this.formArrayName = this.formInline[value].split(',')
// this.formArrayId = id.split(',')
// }
// this.formInline[value + '_id'] = id
// this.formInline = { ...this.formInline }
// },
PersonnelSelectionChange(value, id) {
this.formInline[value + '_id'] = id
this.formInline = { ...this.formInline }
},
//树结果选择
changeTree(value, label, extra){
// console.log('changeValue',value, label, extra)
let labelValues = label
labelValues.shift()
this.contentTrees= labelValues.join(',')
},
//正则替换小数点
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{
.box-title-text {
line-height: 1.4;
display: flex;
.title-text {
width: 114px;
text-align: right;
display: inline-block;
font-weight: 500;
font-size: 14px;
margin-right: 16px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
height: 42px;
line-height: 42px;
.Required {
color: red;
margin-right: 4px;
}
.title-text-text {
margin-top: 9px;
}
}
.itemModel {
width: calc(100% - 130px);
display: inline-block;
margin-top: 2px;
}
}
.con-divider{
font-size: 16px;
font-weight: 500;
color: rgba(0, 0, 0, 0.85)
}
.table-operator{
margin-bottom: 20px;
text-align: right;
}
}
.split-content-row{
.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, .row-btn-edit{
margin-right: 20px;
}
}
}
}
.split-form-footer{
margin-top: 20px;
text-align: center;
position: fixed;
bottom:0px;
right: 0;
width: 900px;
padding-bottom:10px;
background: #FFFFFF;
.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;
.title-num-add {
min-width: 70px;
}
.title-num-edit {
flex: 1;
}
}
}
}
.split-img{
margin-top: 20px;
text-align: center;
img{
}
}
.box-input {
/*min-width: 200px;*/
display: inline-block;
height: 38px;
margin-top: 2px;
}
.button-text {
height: 38px;
width: calc(100% - 100px);
line-height: 38px;
background: #fff;
border: 1px #00B3BE solid;
color: #00B3BE;
}
::v-deep .ant-select-tree {
width: auto;
height: 300px;
overflow: auto;
position: absolute;
/*background: #fff;*/
}
::v-deep .ant-select-tree-dropdown {
min-height: 320px;
}
</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%;
.wordImg{
width:40px;
height: auto;
}
}
}
}
}
.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;
}
}
.split-content{
/*.box-input .ant-input-number-input-wrap{*/
/* height: 30px;*/
/* line-height: 30px;*/
/*}*/
.ant-input-number{
width: 100%;
}
.split-form-row{
display: flex;
flex-wrap: wrap;
justify-content: start;
}
}
.split-img{
.ant-modal-body{
img{
margin-top: 20px;
width: 470px;
height: 100%;
}
}
}
.number-content{
.ant-form-item{
display: flex;
.ant-form-item-control-wrapper{
flex: 1;
.title-num-edit{
width: 100%;
}
}
}
}
/*.box-tree-text{*/
/* .ant-select-selection--multiple{*/
/* height: 32px;*/
/* overflow-y: auto;*/
/* }*/
/*}*/
</style>