b25b036d
wuxw
v1.9 优化日期
|
1
|
<template>
|
bc37d685
wuxw
开发完成合同功能
|
2
|
<el-dialog :title="$t('contractTypeManage.template.title')" :visible.sync="visible" width="80%" @close="handleClose">
|
eb48bd86
wuxw
合同功能测试完成
|
3
4
5
6
7
8
|
<div class="attr-buttons">
<el-button v-for="(item, index) in contractTypeAttrs" :key="index" type="primary" size="small"
@click="insertAttrs(item)">
{{ item }}
</el-button>
</div>
|
bc37d685
wuxw
开发完成合同功能
|
9
|
|
eb48bd86
wuxw
合同功能测试完成
|
10
11
12
|
<el-form label-width="120px">
<el-form-item :label="$t('contractTypeManage.template.content')">
<div class="editor-container">
|
aaff7ab5
wuxw
优化一些bug
|
13
|
<rich-text-editor ref="richTextEditor" v-model="context" />
|
eb48bd86
wuxw
合同功能测试完成
|
14
15
16
|
</div>
</el-form-item>
</el-form>
|
bc37d685
wuxw
开发完成合同功能
|
17
18
19
20
21
22
23
24
25
26
27
28
|
<div slot="footer" class="dialog-footer">
<el-button @click="visible = false">
{{ $t('common.cancel') }}
</el-button>
<el-button type="primary" @click="saveTemplateInfo">
{{ $t('common.submit') }}
</el-button>
</div>
</el-dialog>
</template>
<script>
|
eb48bd86
wuxw
合同功能测试完成
|
29
|
import { saveContractTypeTemplate, updateContractTypeTemplate, queryContractTypeTemplate, printContractTemplate } from '@/api/contract/contractTypeManageApi'
|
aaff7ab5
wuxw
优化一些bug
|
30
|
import RichTextEditor from '@/components/editor/RichTextEditor'
|
bc37d685
wuxw
开发完成合同功能
|
31
32
33
|
export default {
name: 'AddTemplateView',
|
aaff7ab5
wuxw
优化一些bug
|
34
35
36
|
components: {
RichTextEditor
},
|
bc37d685
wuxw
开发完成合同功能
|
37
38
39
40
41
42
43
|
data() {
return {
visible: false,
contractTypeId: '',
context: '',
templateId: '',
contractTypeAttrs: [],
|
eb48bd86
wuxw
合同功能测试完成
|
44
|
contractTypeSpec: []
|
bc37d685
wuxw
开发完成合同功能
|
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
}
},
methods: {
open(contractType) {
this.contractTypeId = contractType.contractTypeId
this.visible = true
this._loadContractAttrs(contractType.contractTypeId)
this._loadTemplate()
},
async _loadContractAttrs(contractTypeId) {
try {
const params = {
page: 1,
row: 1,
contractTypeId
}
const { data } = await printContractTemplate(params)
this.contractTypeAttrs = []
this.contractTypeSpec = data.contractTypeSpec
this.contractTypeSpec.forEach(e => {
const rname = e.specName
const reg = `#${rname}#`
this.contractTypeAttrs.push(reg)
})
|
9ce23427
wuxw
优化一些bug
|
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
// 处理基本属性
if (data.baseRepalce) {
data.baseRepalce.forEach(e => {
const rname = e.name
const rkey = e.key
const contractarr = Object.keys(data.contract[0] || {})
for (const a in contractarr) {
if (rkey === contractarr[a]) {
const reg = `#${rname}#`
this.contractTypeAttrs.push(reg)
}
}
})
}
|
bc37d685
wuxw
开发完成合同功能
|
85
86
87
88
89
|
} catch (error) {
console.error('加载合同属性失败:', error)
}
},
insertAttrs(attr) {
|
aaff7ab5
wuxw
优化一些bug
|
90
91
92
|
if (this.$refs.richTextEditor && this.$refs.richTextEditor.editor) {
this.$refs.richTextEditor.editor.txt.append(attr)
}
|
bc37d685
wuxw
开发完成合同功能
|
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
},
async saveTemplateInfo() {
if (!this.addTemplateValidate()) {
return
}
try {
// const url = this.templateId ? '/contract/updateContractTypeTemplate' : '/contract/saveContractTypeTemplate'
const data = {
contractTypeId: this.contractTypeId,
context: this.context,
templateId: this.templateId
}
const res = this.templateId
? await updateContractTypeTemplate(data)
: await saveContractTypeTemplate(data)
if (res.code === 0) {
|
6ec243d6
wuxw
v1.9 点击提交后,成功提示没有...
|
112
|
this.$message.success(this.$t('common.operationSuccess'))
|
bc37d685
wuxw
开发完成合同功能
|
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
this.visible = false
this.$emit('success')
} else {
this.$message.error(res.msg)
}
} catch (error) {
this.$message.error(this.$t('common.operateFailed'))
}
},
addTemplateValidate() {
if (!this.contractTypeId) {
this.$message.error(this.$t('contractTypeManage.validate.contractTypeRequired'))
return false
}
if (!this.context) {
this.$message.error(this.$t('contractTypeManage.validate.contentRequired'))
return false
}
return true
},
async _loadTemplate() {
try {
const params = {
page: 1,
row: 1,
contractTypeId: this.contractTypeId
}
const { data } = await queryContractTypeTemplate(params)
if (data.length > 0) {
this.templateId = data[0].templateId
this.context = data[0].context
|
aaff7ab5
wuxw
优化一些bug
|
144
145
146
|
if (this.$refs.richTextEditor) {
this.$refs.richTextEditor.setContent(this.context)
}
|
bc37d685
wuxw
开发完成合同功能
|
147
148
149
|
} else {
this.templateId = ''
this.context = ''
|
aaff7ab5
wuxw
优化一些bug
|
150
151
152
|
if (this.$refs.richTextEditor) {
this.$refs.richTextEditor.clear()
}
|
bc37d685
wuxw
开发完成合同功能
|
153
154
155
156
157
158
159
160
161
|
}
} catch (error) {
console.error('加载模板失败:', error)
}
},
handleClose() {
this.contractTypeId = ''
this.context = ''
this.templateId = ''
|
aaff7ab5
wuxw
优化一些bug
|
162
163
164
|
if (this.$refs.richTextEditor) {
this.$refs.richTextEditor.clear()
}
|
bc37d685
wuxw
开发完成合同功能
|
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
}
}
}
</script>
<style lang="scss" scoped>
.attr-buttons {
margin-bottom: 20px;
.el-button {
margin-right: 10px;
margin-bottom: 10px;
}
}
.editor-container {
::v-deep .el-textarea__inner {
min-height: 300px;
}
}
</style>
|