mb.vue
8.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
<template>
<div>
<TitleWithCircle title="模版" style="margin-bottom: 20px;" />
<el-form :model="forminfo" :rules="rulesmb" ref="ruleForm1" label-width="130px" class="demo-ruleForm">
<el-row :gutter="20">
<el-col :span="12" >
<el-form-item label="模版名称" prop="templateName">
<div class="duiqi">{{forminfo.templateName || '无'}}</div>
</el-form-item>
</el-col>
<el-col :span="12" style="display: flex;align-items: center;">
<el-form-item label="word模板" prop="templateAttachment" >
<div class="duiqi tableBtn" :class="forminfo.templateAttachment?'greens':''" @click ="forminfo.templateAttachment?openfile($baseURL+forminfo.templateAttachment):''">{{forminfo.templateAttachment?'查看详情':'无'}}</div>
</el-form-item>
</el-col>
</el-row>
</el-form>
<TitleWithCircle title="合同信息" style="margin-bottom: 20px;" />
<mbadd :list1="list1" />
<div v-if="info.id" style="margin-top: 20px;margin-left: 65px;">
<el-button @click="close()" class="buttonHover"
style="color: #606266;border: 1px solid #DBDBDB;background-color: #fff;">返回</el-button>
</div>
<div v-else style="margin-top: 20px;margin-left: 65px;">
<el-button @click="add()" style="background-color: #3F9B6A;color: #fff;">确定</el-button>
<el-button @click="close()" class="buttonHover"
style="color: #606266;border: 1px solid #DBDBDB;background-color: #fff;">取消</el-button>
</div>
</div>
</template>
<script>
import upfile from "@/components/fujianUpload/fujianList"
import TitleWithCircle from '@/components/top/index';
import mbadd from '@/components/change/mbadd';
import {
cereContractTemplateadd
} from '@/api/newly.js'
import { Input } from "element-ui";
export default {
components: {
TitleWithCircle,
mbadd,
upfile
},
data() {
return {
list1: [
{
name: '合同名称',
key: 'contractName',
type: '单行文本',
isrequired: '是',
width: '50%(半行)',
length: '50',
value: '',
},
],
rulesmb:{
templateName: [{
required: true,
message: '请填写模版名称',
trigger: 'change'
}],
templateAttachment: [{
required: true,
message: '请上传word模板',
trigger: 'change'
}],
},
ruleAddData:{},
forminfo:{
templateName: '', // 模板名称
templateAttachment: '', // 模板附件路径或名称
otherInfo: '', // 其他信息
templateType: '', // 模板类型
creator: '', // 创建人
createTime: '', // 创建时间
remark1: '', // 备注1
remark2: '' // 备注2
},
ruleaddmbitem:{
name: [{
required: true,
message: '请填写字段名称',
trigger: 'change'
}],
key: [{
required: true,
message: '请填写字段key',
trigger: 'change'
}],
type: [{
required: true,
message: '请选择字段类型',
trigger: 'change'
}],
isrequired: [{
required: true,
message: '请选择是否必填',
trigger: 'change'
}],
width: [{
required: true,
message: '请选择字段宽度',
trigger: 'change'
}],
// length: [{
// required: true,
// message: '请填写限制规则',
// trigger: 'change'
// }],
},
addmbitem: {
name: '',
key: '',
type: '',
isrequired: '',
width: '',
length: '',
value: '',
list:[]
},
addMing:false,
}
},
computed: {
mobantype() {
return this.$store.state.app.mobantype;
}
},
props: {
info: {
type: Object,
default: {}
}
},
async created() {
if (this.info.id) {
this.info.otherInfo = JSON.parse(this.info.otherInfo)
this.list1 = this.info.otherInfo
console.error(this.list1)
this.forminfo = this.info
}
},
methods: {
inputvalue(e,index){
console.error(e)
this.addmbitem.list[index].value = e
},
additemlist() {
this.addmbitem.list.push({
label: '',
value: ''
})
},
async mingShow() {
this.addMing = true
},
minSev() {
// return
this.$refs.addmbitem.validate((valid) => {
console.log(valid)
if (valid) {
this.list1.push(this.addmbitem)
this.addmbitem = {
name: '',
key: '',
type: '',
isrequired: '',
width: '',
length: '',
value: '',
}
this.addMing = false
} else {
this.$message({
message: '请填写完整信息',
type: 'error'
})
return false;
}
})
},
mingClose() {
this.addMing = false
},
openfile(e) {
if (e) {
const fullUrl = e;
try {
window.open(fullUrl, '_blank'); // 在新标签页中打开文件
} catch (error) {
console.error('打开文件失败:', error);
}
} else {
console.error('无文件可查看');
}
},
changimg(e, type) {
this.forminfo[type] = e
},
changimg(e, type) {
this.forminfo[type] = e
},
openfile(e) {
if (e) {
const fullUrl = e;
try {
window.open(fullUrl, '_blank'); // 在新标签页中打开文件
} catch (error) {
console.error('打开文件失败:', error);
}
} else {
console.error('无文件可查看');
}
},
//获取当前时间
updateCurrentTime() {
const now = new Date();
const year = now.getFullYear();
const month = (now.getMonth() + 1).toString().padStart(2, '0');
const day = now.getDate().toString().padStart(2, '0');
const hours = now.getHours().toString().padStart(2, '0');
const minutes = now.getMinutes().toString().padStart(2, '0');
const seconds = now.getSeconds().toString().padStart(2, '0');
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
},
add() {
console.error(this.list1)
this.$refs.ruleForm1.validate((valid) => {
console.log(valid)
if (valid) {
this.forminfo.otherInfo = JSON.stringify(this.list1)
console.log(
{...this.forminfo}
)
// return
cereContractTemplateadd({
...this.forminfo,
creator: localStorage.getItem('roleName'),
createTime: this.updateCurrentTime(),
}).then(res => {
console.error(res)
if (res.code == 200) {
this.$message({
message: '添加成功',
type: 'success'
})
this.$emit('removeonaction', '1')
} else {
this.$message({
message: res.msg,
type: 'error'
})
}
})
} else {
this.$message({
message: '请填写完整信息',
type: 'error'
})
return false;
}
})
},
close() {
this.$emit('removeonaction', '1')
},
}
}
</script>
<style lang="css">
.el-upload {
display: block;
text-align: left;
}
.el-dialog__header {
background-color: #F2F3F5;
text-align: left;
}
.el-dialog__title {
line-height: 30px;
font-size: 15px;
color: #303133;
}
.iterem {
z-index: 99;
margin-left: 10px;
height: 40px;
line-height: 25px;
}
</style>