update 文档拆分

This commit is contained in:
赵霄
2023-09-21 17:28:13 +08:00
parent d4c30733c4
commit a609348cbf
10 changed files with 922 additions and 859 deletions
@@ -0,0 +1,783 @@
<template>
<a-drawer
:title="formTitle"
placement="right"
:visible="visible"
@close="splitCancel"
width="900"
class="custom-drawer-style">
<div class="custom-drawer-style-scroll">
<a-spin :spinning="loading">
<a-form>
<a-form-model
class="split-content"
:model="formInline"
:rules="rules"
ref="splitEditForm"
>
<a-row :gutter="24">
<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="item-model" :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="item-model" :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="item-model" :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="item-model-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="item-model" :prop="item.db_field_name">
<a-date-picker class="box-input"
format="YYYY-MM-DD"
value-format="YYYY-MM-DD"
:getCalendarContainer="(trigger) => trigger.parentNode"
v-model="formInline[item.db_field_name]"
:disabled="disabled"
style="width: 100%" />
</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="item-model" :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="item-model" :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>
</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="item-model" :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 === '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="item-model" :prop="item.db_field_name">
<standard-selection :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="item-model" :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="item-model" :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="item-model-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>
<upload-file ref="uploadFile" @change="uploadFileChange" :return-url="false"></upload-file>
<span class="con-divider">{{ $t('docTool.split.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>
</a-spin>
</div>
<div class="custom-drawer-style-bottom-btn">
<a-button type="primary" class="footer-btn-save" @click="splitSave">{{ $t('preservation') }}</a-button>
<a-button @click="splitCancel">{{ $t('cancel') }}</a-button>
</div>
<!-- 类型选择弹框 -->
<split-detail-add-type-check
ref="splitDetailAddTypeCheck"
@addTextOk="addTextOk"
@addTableOk="addTableOk"
@addImageOk="addImageOk"
>
</split-detail-add-type-check>
<!-- 编辑表格弹框 -->
<split-detail-add-table ref="splitDetailAddTable" @editOk="editTableOk"></split-detail-add-table>
</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 } from '../../../../api/documentToolApi.js'
export default {
name: 'SplitAddForm',
components: {
SplitDetailAddTable,
UploadFile,
StandardSelection,
SplitDetailAddTypeCheck
},
data () {
return {
formTitle: this.$t('newlyAdded'),
contentList: [],
visible: false,
addIndex: '',
disabled: false,
formInline: {},
isFormInline: false,
dataList: [],
ruleList: [],
rules: {},
uploadName: '',
type: 'add',
loading: false,
submitFlag: false,
deleteIds: [],
itemVal: {},
contentTrees: '',
isTableEdit: false
}
},
props: {
url: {
type: Object,
default: () => {
return {}
}
},
flag: {
type: String,
default: ''
},
infoId: {
type: String,
default: ''
},
menuId: {
type: String,
default: ''
},
itemId: {
type: String,
default: ''
}
},
methods: {
loadData () {
this.loading = true
getEditClauseContent({ itemId: this.itemId }).then(res => {
if (res.success) {
this.contentList = [...res.result]
this.contentList.forEach(item => {
const imgData = item.itemContent.split('fileUrl=')[1]
item.thumbUrl = window._CONFIG.domianURL + '/sys/split/file/getImage?fileUrl=' + imgData
})
}
}).finally(() => {
this.loading = false
})
},
// 获取表单信息
loadFormInfo () {
getDocSplitEditFormData({ id: this.itemId }).then(res => {
if (res.success) {
this.formInline = [...res.result]
}
})
},
// 增加按钮
splitAdd (val) {
if (val === '-1') {
this.addIndex = this.contentList.length - 1
} else {
this.addIndex = val
}
this.$refs.splitDetailAddTypeCheck.open()
},
// 编辑按钮
splitEdit (index, item) {
// console.log('item',item)
this.addIndex = index
console.log('&&&&&&&&&&&&&&&&&&&&&&&', item.itemContent)
this.$refs.splitDetailAddTable.open(item.itemContent)
this.$refs.splitDetailAddTable.isTableEdit = true
},
// 删除按钮
splitDelete (item, index) {
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()
},
// 保存
splitSave () {
this.$refs.splitEditForm.validate(valid => {
if (valid) {
this.loading = true
if (!this.submitFlag) {
this.submitFlag = true
let submitFunc
if (this.formInline.id) {
submitFunc = editClause
} else {
submitFunc = addClause
}
const 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
}
const contentList = JSON.parse(JSON.stringify(this.contentList))
contentList.forEach((item, index) => {
if (item.type === 'IMG') {
this.$delete(item, 'thumbUrl')
}
})
params.itemValEOList = contentList
params.delItemIds = this.deleteIds.join(',')
submitFunc(params).then((res) => {
if (res.data.success) {
this.loading = false
this.$message.success(this.$t('operationSuccessful'))
this.visible = false
// this.$emit('closeVisible',false)
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)
},
// 增加文本类型成功
addTextOk (number) {
for (let i = this.contentList.length; i > this.addIndex; i--) {
this.contentList[i + number - 1] = this.contentList[i - 1]
}
for (let j = 0; j < number; j++) {
this.contentList[++this.addIndex] = {
id: '',
type: 'TEXT',
itemContent: ''
}
}
this.contentList = JSON.parse(JSON.stringify(this.contentList))
},
// 增加表格类型成功
addTableOk (ueContent) {
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.contentList = JSON.parse(JSON.stringify(this.contentList))
},
// 编辑表格类型成功
editTableOk (ueContent) {
console.log(ueContent)
this.contentList[this.addIndex] = {
id: '',
type: 'TABLE',
itemContent: ueContent[0]
}
this.contentList = JSON.parse(JSON.stringify(this.contentList))
},
// 增加图片类型成功
addImageOk (file, data, imgs) {
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]
}
this.contentList = JSON.parse(JSON.stringify(this.contentList))
},
onChange (item) {
if (this.queryParam[item] && this.queryParam[item].length > 0) {
const startDate = item + '_start'
const endDate = item + '_end'
this.queryParam[startDate] = this.queryParam[item][0]
this.queryParam[endDate] = this.queryParam[item][1]
} else {
this.queryParam[item] = []
}
},
// 点击点击上传按钮
clickButtonToUpload (item) {
this.$refs.uploadFile.open(this.formInline[item.db_field_name])
this.uploadName = item.db_field_name
},
// 文件上传改变后的回调
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 }
},
handleInput (value) {
this.$nextTick(() => {
this.formInline = { ...this.formInline }
this.$refs.splitEditForm.validateField([value])
})
},
integrateData () {
this.isFormInline = false
const 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.loading = false
// console.log('this.column',this.column)
},
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()
callBack && callBack()
}
}).finally(() => {
this.loading = false
})
},
edit (item) {
this.visible = true
this.type = 'edit'
this.itemVal = item
this.getForm(() => {
getDocSplitEditFormData({ id: item.id }).then((res) => {
if (res.success) {
this.formInline = res.result
}
})
})
},
add () {
this.getForm()
this.loadData()
this.loadFormInfo()
this.visible = true
this.formInline = {}
this.contentList = []
this.type = 'add'
},
// 树结果选择
changeTree (value, label, extra) {
// console.log('changeValue',value, label, extra)
const 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 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 {
}
}
.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;
}
/deep/ .ant-select-tree {
width: auto;
height: 300px;
overflow: auto;
position: absolute;
/*background: #fff;*/
}
/deep/ .ant-select-tree-dropdown {
min-height: 320px;
}
</style>