Files
laws_chery_client/src/views/documentTool/documentSplit/modules/SplitAddForm.vue
T

1062 lines
37 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<a-drawer
:title="title"
placement="right"
:visible="visible"
@close="handleCancel"
width="900"
class="custom-drawer-style">
<div class="custom-drawer-style-scroll">
<a-spin :spinning="loading">
<!--表单部分-->
<a-form-model :model="formInline" v-if="isFormInline" class="form-add" :rules="rules" ref="ruleForm">
<div class="form-flex-box">
<template v-for="(item, index) in dataList">
<div :key="index"
class="box-title-text form-flex-item"
v-if="!hiddenFieldList.includes(item.dbFieldName)">
<div class="title-text">
<span class="required" v-if="item.fieldMustInput === '1'">*</span>
<span class="title-text-text" :title="item.dbFieldTxt">{{ item.dbFieldTxt }}</span>
</div>
<a-form-model-item class="item-model" :prop="item.dbFieldName">
<!--条文解读-->
<template v-if="item.dbFieldName === 'interpretation_articles'">
<div class="unscramble-item"
v-for="(unscramble, unscrambleIndex) in interpretationArticlesList"
:key="unscrambleIndex + 'interpretation_articles'">
<div class="unscramble-item-content">
<!--文本-->
<a-input type="textarea" :maxLength="500" v-model="unscramble.itemContent" />
</div>
<div class="unscramble-item-operate">
<a-button @click="handleAddUnscramble(unscrambleIndex)" icon='plus'></a-button>
<a-button @click="handleDeleteUnscramble(unscrambleIndex, unscramble)" icon='minus'
:disabled="interpretationArticlesList.length === 1 && unscrambleIndex === interpretationArticlesList.length - 1">
</a-button>
</div>
</div>
</template>
<!-- 1, 日期单选 -->
<a-date-picker v-else-if="item.fieldShowType === FieldType.DATE_SINGLE.value"
class="box-input"
:placeholder="$t('pleaseSelect')+item.dbFieldTxt + getPlaceholderSuffix(item)"
:getCalendarContainer="(trigger) => trigger.parentNode"
format="YYYY-MM-DD"
value-format="YYYY-MM-DD"
v-model="formInline[item.dbFieldName]"
:disabled="disabled || disabledFieldList.includes(item.dbFieldName)"
@change="updateDom"
style="width: 100%" />
<!-- 2, 单选用户 -->
<user-selection v-else-if="item.fieldShowType === FieldType.USER_SINGLE.value"
:placeholder="$t('pleaseSelect')+item.dbFieldTxt + getPlaceholderSuffix(item)"
v-model="formInline[item.dbFieldName]"
:filedName="item.dbFieldName"
@nameChange="userSelectNameChange"
:nameStr="formInline[item.dbFieldName + '_dictText']"
type="radio"
:disabled="disabled || disabledFieldList.includes(item.dbFieldName)" />
<!-- 3, 单选组织机构 -->
<j-select-depart v-else-if="item.fieldShowType === FieldType.ORGAN_SINGLE.value"
v-model="formInline[item.dbFieldName]"
:backDepart="true" />
<!-- 4, 日期多选 -->
<j-multiple-date-picker v-else-if="item.fieldShowType === FieldType.DATE_MORE.value"
class="box-input"
v-model="formInline[item.dbFieldName]"
:fieldName="item.dbFieldName"
:disabled="disabled || disabledFieldList.includes(item.dbFieldName)" />
<!-- 5, 多行文本 -->
<a-textarea v-else-if="item.fieldShowType === FieldType.TEXTAREA.value"
:placeholder="$t('pleaseEnter')+item.dbFieldTxt + getPlaceholderSuffix(item)"
:disabled="disabled || disabledFieldList.includes(item.dbFieldName)"
:maxLength="item.dbLength || 500"
v-model="formInline[item.dbFieldName]" :rows="4" />
<!-- 6, 标准多选 -->
<standard-selection v-else-if="item.fieldShowType === FieldType.STANDARD_MORE.value"
:source="flag"
:disabledSourceSearch="true"
:disabled="disabled || disabledFieldList.includes(item.dbFieldName)"
v-model="formInline[item.dbFieldName]" />
<!-- 7, 多选组织机构 -->
<j-select-depart v-else-if="item.fieldShowType === FieldType.ORGAN_MORE.value"
v-model="formInline[item.dbFieldName]"
:multi="true"
:backDepart="true"
:treeOpera="true" />
<!-- 8, 上传文件 -->
<a-button v-else-if="item.fieldShowType === FieldType.FILE_UP.value" type="primary" class="button-text"
@click="clickButtonToUpload(item)">
{{
(formInline[item.dbFieldName] === 'null' || formInline[item.dbFieldName] === ''
|| formInline[item.dbFieldName] === null || formInline[item.dbFieldName] === undefined)
? $t('uploadFile.clickUpload')
: $t('uploadFile.viewUploadedFiles')
}}
</a-button>
<!-- 9, 文本框 -->
<a-input v-else-if="item.fieldShowType === FieldType.TEXT_BOX.value"
class="box-input"
:disabled="disabled || disabledFieldList.includes(item.dbFieldName)"
v-model="formInline[item.dbFieldName]"
:maxLength="item.dbLength || 50"
:placeholder="(specialPlaceholder[item.dbFieldName] || $t('pleaseEnter')+item.dbFieldTxt) || + getPlaceholderSuffix(item)" />
<!-- 10, 下拉单选数据字典 -->
<j-dict-select-tag v-else-if="item.fieldShowType === FieldType.OPTION_SINGLE.value"
class="box-input"
v-model="formInline[item.dbFieldName]"
:disabled="disabled || disabledFieldList.includes(item.dbFieldName)"
:placeholder="$t('pleaseSelect')+item.dbFieldTxt + getPlaceholderSuffix(item)"
:type="radioDictSelect.includes(item.dbFieldName)? 'radio' : 'select'"
:triggerChange="false"
@change="updateDom"
:dictCode="item.dictField" />
<!-- 11, 下拉多选数据字典 -->
<j-multi-select-tag v-else-if="item.fieldShowType === FieldType.OPTION_MORE.value"
class="box-input"
v-model="formInline[item.dbFieldName]"
:disabled="disabled || disabledFieldList.includes(item.dbFieldName)"
:placeholder="$t('pleaseSelect')+item.dbFieldTxt + getPlaceholderSuffix(item)"
:type="'select'"
@change="updateDom"
:triggerChange="false"
:dictCode="item.dictField" />
<!-- 12, 树选择 -->
<s-tree-select
v-else-if="item.fieldShowType === FieldType.TREE.value"
:replaceFields="getReplaceFields(item.dbFieldName)"
v-model="formInline[item.dbFieldName]"
:disabled="disabled || disabledFieldList.includes(item.dbFieldName)"
:tree-data="optionsData[item.dbFieldName]"
tree-checkable
treeCheckStrictly
:label-in-value="false"
@change="updateDom"
:placeholder="$t('pleaseSelect')+item.dbFieldTxt + getPlaceholderSuffix(item)" />
<!-- 14, 年份选择 -->
<j-date v-else-if="item.fieldShowType === FieldType.YEAR_PICKER.value"
show-type="year"
:disabled="disabled || disabledFieldList.includes(item.dbFieldName)"
v-model="formInline[item.dbFieldName]"
:default-value="defaultValue[item.dbFieldName]"
date-format="YYYY"
:placeholder="$t('pleaseSelect')+item.dbFieldTxt + getPlaceholderSuffix(item)" />
<!-- 15, 树选择单选 -->
<s-tree-select v-else-if="item.fieldShowType === FieldType.TREE_SINGLE.value"
v-model="formInline[item.dbFieldName]"
:replaceFields="getReplaceFields(item.dbFieldName)"
:disabled="disabled || disabledFieldList.includes(item.dbFieldName)"
:tree-data="optionsData[item.dbFieldName]"
:label-in-value="false"
@change="updateDom"
:placeholder="$t('pleaseSelect')+item.dbFieldTxt + getPlaceholderSuffix(item)" />
<!--16树形弹框选择-->
<!--<tree-selection v-else-if="item.fieldShowType === FieldType.TREE_MODAL_SELECT.value || item.fieldShowType === FieldType.TREE_MODAL_SELECT_SEARCH_DIFF.value"-->
<!-- :placeholder="$t('pleaseSelect')+item.dbFieldTxt + getPlaceholderSuffix(item)"-->
<!-- v-model="formInline[item.dbFieldName]"-->
<!-- :filedName="item.dbFieldName"-->
<!-- type="checkbox"-->
<!-- :options-href="item.fieldHref"-->
<!-- :nameStr="formInline[item.dbFieldName + '_dictText']"-->
<!-- :dict-id="item.dictId"-->
<!-- :disabled="disabled || disabledFieldList.includes(item.dbFieldName)"-->
<!-- :children-column-name="getTreeSelectionChildrenColumnName(item)"-->
<!-- :is-tag-library-restriction="item.dbFieldName === 'property_tag'"-->
<!-- :search-field-name="item.dbFieldName === 'property_tag' ? 'firstNodeName' : null" />-->
<tree-data-selection v-else-if="item.fieldShowType === FieldType.TREE_MODAL_SELECT.value || item.fieldShowType === FieldType.TREE_MODAL_SELECT_SEARCH_DIFF.value"
:placeholder="$t('pleaseSelect')+item.dbFieldTxt"
v-model="formInline[item.dbFieldName]"
:fieldName="item.dbFieldName"
:nameStr="formInline[item.dbFieldName + '_dictText']"
@nameChange="treeDataSelectNameChange"
:optionsHref="item.treeFirstHref"
:dict-id="item.dictId"/>
</a-form-model-item>
</div>
</template>
</div>
<upload-file ref="uploadFile" @change="uploadFileChange" :return-url="false"></upload-file>
</a-form-model>
<!--条款内容部分-->
<div class="header-text">
{{ $t('docTool.split.clauseContent') }} / {{ $t('docTool.split.translation') }}
<!--新增条款项-->
<a-button type="primary" icon="plus" ghost @click="handleAddClauseContent(-1)">{{ $t('newlyAdded') }}</a-button>
</div>
<template v-if="contentList && contentList.length > 0">
<div class="clause-item" v-for="(clause, index) in contentList" :key="clause.uuid || (index + 'clause')">
<div class="clause-item-operate">
<a-button @click="handleAddClauseContent(index)">{{ $t('newlyAdded') }}</a-button>
<a-button v-if="clause.type === TypeOfClauseItem.TABLE.value" @click="splitEdit(index,clause)">
{{ $t('edit') }}
</a-button>
<!--编辑译文表格-->
<a-button v-if="clause.type === TypeOfClauseItem.TABLE.value"
@click="splitEditTranslation(index,clause)">
{{ $t('edit') + $t('docTool.split.translation') }}
</a-button>
<!--没有图片时,新增译文图片-->
<a-button v-if="clause.type === TypeOfClauseItem.IMG.value && !clause.translation"
@click="splitEditTranslation(index,clause)">
{{ $t('newlyAdded') + $t('docTool.split.translation') + $t('docTool.split.picture') }}
</a-button>
<a-button @click="handleDeleteClauseContent(index, clause)">{{ $t('delete') }}</a-button>
</div>
<div class="clause-item-box">
<div class="clause-item-content">
<!--文本-->
<a-input type="textarea"
:maxLength="500"
v-model="clause.itemContent"
v-if="clause.type === TypeOfClauseItem.TEXT.value" />
<!--图片-->
<viewer>
<img v-if="clause.type === TypeOfClauseItem.IMG.value"
:src="clause[operateField.content.tempUrlField] ? clause[operateField.content.tempUrlField] : clause.itemContent"
alt="">
</viewer>
<!--表格-->
<div v-if="clause.type === TypeOfClauseItem.TABLE.value" v-html="clause.itemContent"></div>
</div>
<div class="clause-item-content" style="margin-left: 20px;">
<!--文本-->
<a-input type="textarea"
:maxLength="500"
v-model="clause.translation"
v-if="clause.type === TypeOfClauseItem.TEXT.value" />
<!--图片-->
<viewer>
<img v-if="clause.type === TypeOfClauseItem.IMG.value"
:src="clause[operateField.translation.tempUrlField] ? clause[operateField.translation.tempUrlField] : clause.translation"
alt="">
</viewer>
<!--表格-->
<div v-if="clause.type === TypeOfClauseItem.TABLE.value" v-html="clause.translation"></div>
</div>
</div>
</div>
</template>
</a-spin>
</div>
<div class="custom-drawer-style-bottom-btn">
<a-button @click="handleCancel">{{ $t('cancel') }}</a-button>
<a-button type="primary" class="footer-btn-save" @click="handleSave">{{ $t('preservation') }}</a-button>
</div>
<!-- 上传图片弹框 -->
<split-add-clause-upload-image
ref="uploadImg"
:disabled="disabled"
:title="$t('uploadPictures')"
listType="picture"
:multiple="false"
accept=".png,.jpeg,.jpg,.gif"
@uploadSuccess="uploadSuccess">
</split-add-clause-upload-image>
<!-- 类型选择弹框 -->
<split-detail-add-type-check ref="splitDetailAddTypeCheck" @ok="handleAddOk" />
<!-- 编辑表格弹框 -->
<split-detail-add-table ref="splitDetailAddTable" @editOk="editTableOk" />
</a-drawer>
</template>
<script>
import UploadFile from '../../../../components/UploadFile.vue'
import StandardSelection from '../../../../components/selection/StandardSelection.vue'
// 类型选择弹框
import SplitDetailAddTypeCheck from './SplitDetailAddTypeCheck.vue'
import SplitDetailAddTable from './SplitDetailAddTable.vue'
import {
getDocSplitEditForm,
getDocSplitEditFormData,
addClause,
editClause,
getEditClauseContent,
getInterpretationArticlesList
} from '../../../../api/documentToolApi.js'
import JMultipleDatePicker from '../../../../components/JMultipleDatePicker.vue'
import { FieldType, TypeOfClauseItem } from '../../../../enums/commonEnums'
import { getAction } from '../../../../api/manage'
import { getFormDictTreeList } from '../../../../api/api'
import STreeSelect from '../../../../components/STreeSelect'
import TreeSelection from '../../../../components/selection/TreeSelection'
import { randomUUID } from '@/utils/util'
import TreeDataSelection from '@comp/selection/TreeDataSelection'
import SplitAddClauseUploadImage from '@comp/splitUpload/SplitAddClauseUploadImage'
export default {
name: 'SplitAddForm',
components: {
SplitAddClauseUploadImage,
TreeDataSelection,
TreeSelection,
JMultipleDatePicker,
SplitDetailAddTable,
UploadFile,
StandardSelection,
SplitDetailAddTypeCheck,
STreeSelect
},
data () {
return {
FieldType,
TypeOfClauseItem,
hiddenFieldList: ['item_content', 'translation'], // 隐藏的字段
radioDictSelect: [], // 使用radio样式的数据字典单选
disabledFieldList: [], // 禁用的字段
// 需要英文状态下翻译下拉的字段
dictTextFieldList: [
'professional_field', // 全部-专业领域
'applicable_market', // 适用市场
'domain_area' // 条款-专业领域
],
specialPlaceholder: {}, // 特殊的placeholder
optionsData: {}, // 通过接口获取的下拉数据
title: this.$t('newlyAdded'),
contentList: [], // 条款内容数据
visible: false,
addIndex: 0, // 新增条款的index
// 操作的字段
operateField: {
content: { field: 'itemContent', tempUrlField: 'itemContentThumbUrl' },
translation: { field: 'translation', tempUrlField: 'translationThumbUrl' }
},
// 当前操作的字段,保存上面对象,方便扩展(用于回调使用)
currentFieldObj: {},
disabled: false,
formInline: {},
isFormInline: false,
dataList: [],
ruleList: [],
rules: {},
uploadName: '',
type: 'add',
loading: false,
submitFlag: false,
deleteIds: [],
itemVal: {},
contentTrees: '',
isTableEdit: false,
interpretationArticlesList: [] // 条文解读数据
}
},
props: {
flag: {
type: String,
default: ''
},
infoId: {
type: String,
default: ''
},
menuId: {
type: String,
default: ''
},
itemId: {
type: String,
default: ''
}
},
methods: {
/**
* 处理英文下树结构下拉的字段替换
* @param field - 字段名
*/
getReplaceFields (field) {
const obj = {}
// 数据字典或标签内容管理英文是enTitle
if (this.dictTextFieldList.includes(field)) {
obj.title = this.isChinese() ? 'title' : 'enTitle'
}
return obj
},
/**
* 新增
*/
add () {
this.visible = true
this.formInline = {}
this.contentList = []
this.type = 'add'
this.getForm()
},
/**
* 编辑
* @param item
*/
edit (item) {
this.visible = true
this.type = 'edit'
this.itemVal = item
this.formInline = {}
this.getForm(() => {
this.loadFormInfo()
this.getClauseContentList()
this.initInterpretationArticlesList()
})
},
/**
* 获取表单字段
* @param callBack
*/
getForm (callBack) {
this.loading = true
const params = {
flag: this.flag,
type: this.type
}
getDocSplitEditForm(params).then((res) => {
if (res.success) {
this.dataList = res.result
this.ruleList = res.result
this.integrateData()
this.getOptionsData()
callBack && callBack()
}
}).finally(() => {
this.loading = false
})
},
/**
* 处理需要通过接口获取的下拉数据
*/
getOptionsData () {
const formList = Object.values(this.dataList).reduce((acc, cur) => acc.concat(cur), [])
formList.forEach(item => {
if (item.fieldShowType === FieldType.TREE.value || item.fieldShowType === FieldType.TREE_SINGLE.value) {
// 展示类型是树选择,且有接口的
if (item.fieldHref) {
getAction(item.fieldHref).then(res => {
if (res.success) {
this.$set(this.optionsData, item.dbFieldName, res.result)
}
})
} else if (item.dictId) {
getFormDictTreeList({ dictId: item.dictId }).then(res => {
if (res.success) {
this.$set(this.optionsData, item.dbFieldName, res.result)
}
})
}
}
})
},
/**
* 设置表单校验信息
*/
integrateData () {
this.isFormInline = false
const ruleList = JSON.parse(JSON.stringify(this.ruleList))
console.log(this.ruleList)
const rules = {}
ruleList.forEach((res, index) => {
const rule = []
if (res.fieldMustInput === '1') {
if ([FieldType.TEXT_BOX.value, FieldType.TEXTAREA.value].includes(res.fieldShowType)) {
rule.push({
required: true,
message: res.dbFieldTxt + this.$t('cannotEmpty'),
trigger: 'blur'
})
} else {
rule.push({
required: true,
message: res.dbFieldTxt + this.$t('cannotEmpty'),
trigger: 'change'
})
}
} else {
if ([FieldType.TEXT_BOX.value, FieldType.TEXTAREA.value].includes(res.fieldShowType)) {
rule.push({
required: false,
message: res.dbFieldTxt + this.$t('cannotEmpty'),
trigger: 'blur'
})
} else {
rule.push({
required: false,
message: res.dbFieldTxt + this.$t('cannotEmpty'),
trigger: 'change'
})
}
}
if (rule.length > 0) {
rules[res.dbFieldName] = rule
}
})
this.rules = rules
this.isFormInline = true
this.loading = false
},
/**
* 获取表单信息
*/
loadFormInfo () {
getDocSplitEditFormData({ id: this.itemVal.id }).then(res => {
if (res.success) {
// 处理树结构多选回显
const formList = Object.values(this.dataList).reduce((acc, cur) => acc.concat(cur), [])
const treeMultipleField = formList.filter(tt => tt.fieldShowType === FieldType.TREE.value)
const data = res.result || {}
treeMultipleField.forEach(field => {
const valueArr = []
if (data[field.dbFieldName]) {
const values = data[field.dbFieldName].split(',')
for (let i = 0; i < values.length; i++) {
valueArr[i] = {
value: values[i]
}
}
data[field.dbFieldName] = valueArr
} else {
data[field.dbFieldName] = undefined
}
})
const dictField = formList.filter(tt => tt.fieldShowType === FieldType.OPTION_SINGLE.value)
dictField.forEach(field => {
data[field.dbFieldName] = data[field.dbFieldName] || null
})
// 处理条文解读
if (!data.interpretation_articles) {
data.interpretation_articles = ''
}
this.formInline = Object.assign({}, { ...data })
}
})
},
/**
* 获取条款内容列表
*/
getClauseContentList () {
this.loading = true
getEditClauseContent({ id: this.itemVal.id }).then(res => {
if (res.success) {
this.contentList = [...res.result]
this.contentList.forEach(item => {
const imgData = item.itemContent.split('fileName=')[1]
const imgDataTranslation = item.itemContent.split('fileName=')[1]
if (item.type === TypeOfClauseItem.IMG.value) {
item[this.operateField.content.tempUrlField] = window._CONFIG.domianURL + '/sys/split/file/getImage?fileName=' + imgData
item[this.operateField.translation.tempUrlField] = window._CONFIG.domianURL + '/sys/split/file/getImage?fileName=' + imgDataTranslation
}
})
}
}).finally(() => {
this.loading = false
})
},
/**
* 新增条款内容
* @param index
*/
handleAddClauseContent (index) {
this.currentFieldObj = this.operateField.content
if (index === -1) {
this.addIndex = this.contentList.length - 1
} else {
this.addIndex = index
}
this.$refs.splitDetailAddTypeCheck.open()
},
// 增加条款内容成功
handleAddOk (type, content) {
const insertArr = []
switch (type) {
case TypeOfClauseItem.TEXT.value:
for (let i = 0; i < content; i++) {
insertArr.push({
id: '',
uuid: randomUUID(),
type: TypeOfClauseItem.TEXT.value,
itemContent: '',
translation: ''
})
}
break
case TypeOfClauseItem.IMG.value:
// 处理上传接口报错的情况
if (content.imgs) {
content.imgs.forEach(file => {
insertArr.push({
id: '',
uuid: randomUUID(),
type: TypeOfClauseItem.IMG.value,
[this.currentFieldObj.field]: file.response.result.url,
[this.currentFieldObj.tempUrlField]: window._CONFIG.domianURL + '/sys/split/file/getImage?fileName=' + file.response.result.fileName
})
})
}
break
case TypeOfClauseItem.TABLE.value:
insertArr[0] = {
id: '',
uuid: randomUUID(),
type: 'TABLE',
[this.currentFieldObj.field]: content[0]
}
}
if (this.addIndex !== -1) {
this.contentList.splice(this.addIndex + 1, 0, ...insertArr)
} else {
this.contentList.push(...insertArr)
}
},
/**
* 译文编辑
* @param index
* @param item
*/
splitEditTranslation (index, item) {
this.currentFieldObj = this.operateField.translation
this.addIndex = index
// 图片
if (item.type === TypeOfClauseItem.IMG.value) {
this.$refs.uploadImg.open()
} else if (item.type === TypeOfClauseItem.TABLE.value) {
this.$refs.splitDetailAddTable.open(item.translation)
this.$refs.splitDetailAddTable.isTableEdit = true
}
},
// 译文上传图片
uploadSuccess (file, data, imgs) {
Object.assign(this.contentList[this.addIndex], {
type: TypeOfClauseItem.IMG.value,
[this.currentFieldObj.field]: file.response.result.url,
[this.currentFieldObj.tempUrlField]: window._CONFIG.domianURL + '/sys/split/file/getImage?fileName=' + file.response.result.fileName
})
this.$forceUpdate()
},
/**
* 表格编辑
* @param index
* @param item
*/
splitEdit (index, item) {
this.currentFieldObj = this.operateField.content
this.addIndex = index
this.$refs.splitDetailAddTable.open(item.itemContent)
this.$refs.splitDetailAddTable.isTableEdit = true
},
/**
* 编辑表格类型成功
* @param ueContent
*/
editTableOk (ueContent) {
// 如果内容和译文有一个有内容,就不进行覆盖
if (this.contentList[this.addIndex][this.operateField.content.field] || this.contentList[this.addIndex][this.operateField.translation.field]) {
this.contentList[this.addIndex][this.currentFieldObj.field] = ueContent[0]
} else {
this.contentList[this.addIndex] = {
id: '',
type: 'TABLE',
[this.currentFieldObj.field]: ueContent[0]
}
}
this.contentList = JSON.parse(JSON.stringify(this.contentList))
},
// 点击点击上传按钮
clickButtonToUpload (item) {
this.$refs.uploadFile.open(this.formInline[item.dbFieldName])
this.uploadName = item.dbFieldName
},
// 文件上传改变后的回调
uploadFileChange (data) {
const 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 }
},
// 正则替换小数点
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
}
},
/**
* 删除条款内容
* @param index
* @param clause
*/
handleDeleteClauseContent (index, clause) {
this.contentList.splice(index, 1)
if (clause.id) {
this.deleteIds.push(clause.id)
}
},
handleCancel () {
this.close()
},
close () {
this.visible = false
this.formInline = {}
this.contentList = []
this.interpretationArticlesList = []
},
handleSave () {
if (this.submitFlag) {
return
}
this.$refs.ruleForm.validate(valid => {
console.log(valid)
if (valid) {
this.submitFlag = true
this.loading = true
// 判断新增编辑
let submitFunc
if (this.formInline.id) {
submitFunc = editClause
} else {
submitFunc = addClause
}
// 处理请求参数
const formData = JSON.parse(JSON.stringify(this.formInline))
// 处理动态表单多选的值
Object.keys(formData).forEach(res => {
if (formData[res] instanceof Array) {
if (formData[res][0] instanceof Object) {
// 说明是树选择
formData[res] = formData[res].map(item => item.value).join(',')
} else {
formData[res] = formData[res].join(',')
}
}
})
formData.info_id = this.infoId
formData.menu_id = this.menuId
const contentList = JSON.parse(JSON.stringify(this.contentList))
contentList.forEach((item, index) => {
if (item.type === 'IMG') {
delete item[this.operateField.content.tempUrlField]
delete item[this.operateField.translation.tempUrlField]
}
})
formData.itemValEOList = contentList
formData.interpretationArticlesList = this.interpretationArticlesList.filter(tt => !!tt.itemContent)
formData.delItemIds = this.deleteIds.join(',')
submitFunc(formData).then(res => {
if (res.success) {
this.$message.success(res.message)
this.$emit('ok')
this.close()
} else {
this.$message.warning(res.message)
}
}).finally(() => {
this.loading = false
this.submitFlag = false
})
}
})
},
/**
* 新增一条条文解读
* @param index
*/
handleAddUnscramble (index) {
this.interpretationArticlesList.splice(index + 1, 0, { id: '', itemContent: null, displaySeq: 1 })
},
/**
* 删除条文解读
*/
handleDeleteUnscramble (index, item) {
this.interpretationArticlesList.splice(index, 1)
if (item.id) {
this.deleteIds.push(item.id)
}
},
/**
* 获取条文解读数据
*/
initInterpretationArticlesList () {
getInterpretationArticlesList({ id: this.itemVal.id }).then(res => {
if (res.success) {
if (res.result && res.result.length > 0) {
this.interpretationArticlesList = res.result
} else {
this.interpretationArticlesList = [{
itemContent: null,
displaySeq: 1
}]
}
}
})
},
updateDom () {
this.$forceUpdate()
},
filterTreeOption (input, option) {
const text = option.componentOptions.propsData.title || option.componentOptions.propsData.label
return text.toLowerCase().indexOf(input.toLowerCase()) >= 0
},
/**
* 属性标识的子集字段处理
* @param field
* @returns {null|string}
*/
getTreeSelectionChildrenColumnName (field) {
if (field.dbFieldName === 'property_tag') {
return 'childrenList'
}
return null
},
treeDataSelectNameChange (value, fieldName) {
this.formInline[fieldName + '_dictText'] = value
},
/**
* 如果字段中的usableRange只有一个值,那么就需要在placeholder中标识
* @param field
*/
getPlaceholderSuffix (field) {
// let fieldUsableRange = []
// if (field.usableRange) {
// fieldUsableRange = field.usableRange.split(',')
// }
// if (fieldUsableRange.length === 1) {
// return `${ClauseUsableRange.nameOfIndex(fieldUsableRange[0])}`
// }
return ''
}
}
}
</script>
<style scoped lang="less">
.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;
}
}
.item-model {
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 {
/deep/ 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 {
width: 75px;
height: 35px;
text-align: center;
border-radius: 5px;
border: 1px solid #d9d9d9;
padding: 7px;
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 {
}
}
/*用到的css代码*/
.form-flex-box {
display: flex;
flex-wrap: wrap;
}
.form-flex-item {
width: 100%;
}
.header-text {
display: flex;
justify-content: space-between;
align-items: center;
}
.clause-item {
margin: 0 0 20px 20px;
&-box {
display: flex;
justify-content: space-between;
.clause-item-content {
width: 0;
flex: 1;
/deep/ table {
width: 100%;
border: 1px solid;
td {
border: 1px solid;
}
}
/deep/ img {
max-width: 100%;
max-height: 500px;
}
}
}
&-operate {
margin-bottom: 15px;
.ant-btn:not(:first-child) {
margin-left: 15px
}
}
}
.clause-item:last-child {
margin-bottom: 0;
}
/deep/ .ant-select-tree-dropdown {
max-height: 50vh !important;
}
.unscramble-item {
display: flex;
justify-content: space-between;
margin-bottom: 20px;
&-content {
width: 0;
flex: 1;
}
&-operate {
.ant-btn {
margin-left: 15px
}
}
}
.unscramble-item:last-child {
margin-bottom: 0;
}
</style>