addVue.html
17.9 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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script th:src="@{/js/vue.js}"></script>
<script th:src="@{/js/elementNew.js}"></script>
<!-- <script src="https://unpkg.com/element-ui/lib/index.js"></script>-->
<link rel="stylesheet" th:href="@{/css/elementNew.css}">
<!-- <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">-->
</head>
<body class="gray-bg" style="padding: 20px">
<div id="app" v-cloak>
<el-form ref="form" label-width="180px" :model="form" :rules="rules">
<el-form-item label="合作机构名称" prop="deptName" :rules='{ required: true, trigger: ["blur","change"], message: "合作机构名称不能为空" }'>
<el-input v-model="form.deptName"></el-input>
</el-form-item>
<el-form-item label="关联合同名称" prop="deptName">
<el-input v-model="form.contractName" placeholder="请输入合同名称">
<template #append>
<el-button @click="selectDeptTree" icon="el-icon-search" size="mini">搜索</el-button>
</template>
</el-input>
</el-form-item>
<el-form-item label="负责人">
{{form.owner}}
<el-input v-model="form.contractId" v-show="false"></el-input>
</el-form-item>
<el-form-item label="合同备注">
{{form.contractRemark}}
</el-form-item>
<el-form-item label="服务备注">
{{form.serviceRemark}}
</el-form-item>
<el-form-item label="报告业务形式" prop="reportForm" :rules='{ required: true, trigger: ["blur","change"], message: "报告业务形式不能为空" }'>
<el-radio-group v-model="form.reportForm">
<el-radio label="1">正式报告</el-radio>
<el-radio label="0">试用报告</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="报告业务类型" prop="typeIds" :rules='{ required: true, trigger: ["blur","change"], message: "报告业务类型不能为空" }'>
<el-checkbox-group v-model="form.typeIds">
<el-checkbox v-for="item in reportList" :label="item.dictValue" v-on:change="handleChoice">{{ item.dictLabel }}</el-checkbox>
</el-checkbox-group>
</el-form-item>
<el-form-item label="定制模板类型" v-if="form.typeIds.includes('-11')" prop="clientIds"><!--:rules='{ required: true, trigger: ["blur","change"], message: "定制模板类型不能为空" }'-->
<el-checkbox-group v-model="form.clientIds">
<el-checkbox v-for="item in customReportTypeList" :label="item.id" @change="handleChoiceCustom">{{ item.tname }}</el-checkbox>
</el-checkbox-group>
</el-form-item>
<div v-for="(item, index) in form.templateConfigurationParameters">
<el-row>
<template v-if="item.clientType !== null">
<el-col :span="8">
<el-form-item :label="index%6 === 0 ? item.typeName : ''">
<el-checkbox v-model="item.checked" true-label="Y" @change="handleChoiceClient(item.typeId, item.clientId)" :disabled="item.disable">{{getClientName(item.clientType)}}</el-checkbox>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="交付天数" :prop="'templateConfigurationParameters.'+index+'.deliveryDays'">
<el-input v-model="item.deliveryDays"></el-input>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="业务单价" :prop="'templateConfigurationParameters.'+index+'.typePrice'">
<el-input v-model="item.typePrice"></el-input>
</el-form-item>
</el-col>
</template>
<template v-else>
<el-col :span="12" :offset="4">
<el-form-item label="报告语种翻译" :prop="'templateConfigurationParameters.'+index+'.reportTranslationType'" :rules='{ required: true, trigger: ["blur","change"], message: "此项不能为空" }'>
<el-select v-model="item.reportTranslationType" placeholder="请选择报告语种翻译" clearable>
<el-option v-for="item in reportTranslationTypeList" :label="item.dictLabel" :value="item.dictValue"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="单价新增" :prop="'templateConfigurationParameters.'+index+'.reportPrice'" :rules='{ required: true, trigger: ["blur","change"], message: "此项不能为空" }'>
<el-input v-model="item.reportPrice"></el-input>
</el-form-item>
</el-col>
</template>
</el-row>
</div>
</el-form>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
var backgroundReportType = [[${backgroundReportType}]]
let frontDept = [[${frontDept}]]
let customReportType = [[${customReportType}]]
let clientType = [[${clientType}]]
let reportTranslationType = [[${reportTranslationType}]]
let templateConfiguration = [[${templateConfiguration}]]
var prefix = ctx + "business/templateConfiguration"
/*<![CDATA[*/
var app = new Vue({
el: '#app',
data() {
return {
form: {
deptName: frontDept.deptName,
orgId: frontDept.id,
contractName: '',
reportForm: '1',
typeIds: [],
clientIds: [],
templateConfigurationParameters: [],
contractId: '',
own: '',
contractRemark: '',
serviceRemark: '',
},
rules: {
},
reportList: backgroundReportType,
customReportTypeList: [],
clientTypeList: clientType,
reportTranslationTypeList: reportTranslationType,
templateConfigurationInfo: templateConfiguration
}
},
mounted() {
this.customReportTypeList = customReportType
if (this.templateConfigurationInfo) {
console.log(this.templateConfigurationInfo)
let allSelectTypeIds = []
let allSelectClientIds = []
this.templateConfigurationInfo.templateConfigurationParameters.forEach(item => {
let tempJson = {typeId: item.typeId, isNow: false}
let tempClientJson = {clientId: item.clientId, isNow: false}
if (tempClientJson.length == 0){
if (item.typeId == -11) {
allSelectClientIds.push(tempClientJson)
}
} else {
let isHaveClient = false
if (item.typeId == -11) {
allSelectClientIds.forEach((item2, index) => {
if (item2.clientId == item.clientId){
isHaveClient = true
}
})
if (!isHaveClient && item.typeId == '-11'){
allSelectClientIds.push(tempClientJson)
}
}
}
if (allSelectTypeIds.length == 0){
if (item.typeId != -11) {
allSelectTypeIds.push(tempJson)
}
} else {
let isExist = false
if (item.typeId != '-11') {
allSelectTypeIds.forEach((item2, index) => {
if (item2.typeId == item.typeId){
isExist = true
}
})
}
if (!isExist && item.typeId!= '-11'){
allSelectTypeIds.push(tempJson)
}
}
})
console.log("所有选中的=>",allSelectTypeIds)
console.log("所有选中的clientIds=>",allSelectClientIds)
this.templateConfigurationInfo.templateConfigurationParameters.forEach(item => {
})
this.form = this.templateConfigurationInfo
this.form.typeIds = this.templateConfigurationInfo.typeId.split(",")
this.form.clientIds = this.templateConfigurationInfo.clientId ? this.templateConfigurationInfo.clientId.split(',').map(Number) : []
}
},
methods: {
selectDeptTree() {
// 获取输入框的值
var entName = this.form.contractName;
// 配置模态框的选项
var options = {
title: '合同选择',
width: "600",
url: prefix + "/selectDeptTreeByEntName/" + entName,
callBack: this.doSubmit // 使用 this 绑定到 Vue 实例
};
// 打开模态框
$.modal.openOptions(options);
},
// 模态框回调函数
doSubmit(index, layero) {
// 这里你可以处理模态框返回的数据
var body = layer.getChildFrame('body', index);
this.form.contractId = body.find('#contractId').val();
this.form.contractName = body.find('#contractName').val();
this.form.owner = body.find('#protocolResponsibilityStaffName').val();
this.form.contractRemark = body.find('#remark').val();
this.form.serviceRemark = body.find('#serviceRemark').val();
layer.close(index);
},
initData(){
},
handleChoice(){
let beforeTypeIds = []
this.form.templateConfigurationParameters.forEach((item, index) => {
if (!beforeTypeIds.includes(parseInt(item.typeId))){
beforeTypeIds.push(parseInt(item.typeId))
}
})
console.log("之前=>",beforeTypeIds)
let isHaveDz = false
this.form.typeIds.forEach((item, index) => {
if (item == '-11'){
isHaveDz = true
}
})
if (!isHaveDz){
this.form.clientIds = []
this.form.clientId = ''
}
this.form.typeIds.forEach((item, index) => {
this.reportList.forEach((report, index2) => {
if (report.dictValue == item && item != '-11'){
this.clientTypeList.forEach((client, index3) => {
// 新增
if (!beforeTypeIds.includes(parseInt(item))){
this.form.templateConfigurationParameters.push({
reportTranslationType: '',
typePrice: '',
typeName: report.dictLabel,
typeId: report.dictValue,
checked: "",
deliveryDays: "",
reportPrice: "",
clientType: client.dictValue,
})
}
})
if (!beforeTypeIds.includes(parseInt(item))){
this.form.templateConfigurationParameters.push({
reportTranslationType: '',
typePrice: '',
typeName: '',
typeId: report.dictValue,
reportPrice: "",
clientType: null,
})
}
}
})
})
let noSelect = []
console.log("选中=>",this.form.typeIds)
this.form.templateConfigurationParameters.forEach((item, index) => {
console.log("当前=>",item.typeId)
if (!this.form.typeIds.includes(item.typeId+"")){
if (!noSelect.includes(item.typeId)){
noSelect.push(item.typeId)
}
}
})
console.log("已取消的=>",noSelect)
this.form.templateConfigurationParameters = this.form.templateConfigurationParameters.filter((item, index) => {
return !noSelect.includes(item.typeId)
})
},
handleChoiceCustom(){
let beforeCustomIds = []
this.form.templateConfigurationParameters.forEach((item, index) => {
if (item.clientId && !beforeCustomIds.includes(parseInt(item.clientId))){
beforeCustomIds.push(parseInt(item.clientId))
}
})
this.form.clientIds.forEach((item, index) => {
this.customReportTypeList.forEach((report, index2) => {
if (item == report.id) {
this.clientTypeList.forEach((client, index3) => {
// 新增
if (!beforeCustomIds.includes(parseInt(item))){
this.form.templateConfigurationParameters.push({
reportTranslationType: '',
typePrice: '',
typeName: report.tname,
typeId: "-11",
clientId: report.id,
checked: "",
deliveryDays: "",
reportPrice: "",
clientType: client.dictValue,
})
}
})
if (!beforeCustomIds.includes(parseInt(item))){
this.form.templateConfigurationParameters.push({
reportTranslationType: '',
typePrice: '',
typeName: report.tname,
typeId: "-11",
clientId: report.id,
reportPrice: "",
clientType: null,
})
}
}
})
})
let noSelect = []
this.form.templateConfigurationParameters.forEach((item, index) => {
if (!this.form.clientIds.includes(item.clientId)){
if (!noSelect.includes(item.clientId)){
noSelect.push(item.clientId)
}
}
})
this.form.templateConfigurationParameters = this.form.templateConfigurationParameters.filter((item, index) => {
return parseInt(item.typeId) != -11 || (parseInt(item.typeId) == -11 && !noSelect.includes(parseInt(item.clientId)))
})
},
handleChoiceClient(typeId, clientId){
let isHaveNow = false
this.form.templateConfigurationParameters.forEach((item, index) => {
if (item.typeId == typeId && item.typeId != '-11'){
if (item.checked == 'Y' && item.clientType == '3') {
isHaveNow = true
}
}
if (item.typeId == '-11'){
if (item.clientId == clientId){
if (item.checked == 'Y' && item.clientType == '3') {
isHaveNow = true
}
}
}
})
// 选择了立即交付
if (isHaveNow){
this.form.templateConfigurationParameters.forEach((item, index) => {
if (item.typeId == typeId && item.typeId != '-11'){
if (item.clientType != '3') {
item.disable = true
item.checked = ''
}
}
if (item.typeId == '-11'){
if (item.clientId == clientId){
if (item.clientType!= '3') {
item.disable = true
item.checked = ''
}
}
}
})
} else {
this.form.templateConfigurationParameters.forEach((item, index) => {
if (item.typeId == typeId && item.typeId!= '-11'){
item.disable = false
}
if (item.typeId == '-11'){
if (item.clientId === clientId){
item.disable = false
}
}
})
}
},
getClientName(clientType){
let clientName = ''
this.clientTypeList.forEach((item, index) => {
if (item.dictValue == clientType){
clientName = item.dictLabel
}
})
return clientName
},
handleSubmit(callback) {
this.$refs["form"].validate(valid => {
if (valid) {
$.modal.loading("正在处理中,请稍后...");
$.modal.disable();
this.form.typeId = this.form.typeIds.join(',')
this.form.clientId = this.form.clientIds.join(',')
let url = this.templateConfigurationInfo ? "/edit": "/add"
console.log("是否包含定制=>",this.form.typeIds.includes("-11"))
if (this.form.typeIds.includes("-11")){
this.form.clientIds = this.form.clientIds.map(item => parseInt(item))
this.form.clientId = this.form.clientIds.join(',')
} else {
this.form.clientIds = []
this.form.clientId = ''
this.form.templateConfigurationParameters.filter(item => {
console.log(parseInt(item.typeId) != -11)
return parseInt(item.typeId) != -11
})
}
console.log("格式化后=>",this.form.templateConfigurationParameters)
fetch(prefix + url, {
method: "POST",
headers: {
'Content-Type': 'application/json;charset=utf-8'
},
body: JSON.stringify(this.form)
}).then(response => response.json()).then(data => {
// 处理响应数据
console.log(data);
callback && callback(data)
}).finally(() => {
// 无论请求成功还是失败,都会执行的代码
console.log("请求已完成");
})
}
})
}
}
})
/*]]>*/
function submitHandler() {
app.handleSubmit(function (data) {
$.modal.closeLoading();
$.modal.enable();
if (data.code === 2000) {
$.modal.msgSuccess("保存成功", {
time: 1000,
afterClose: function () {
}
});
setTimeout(function () {
$.modal.close();
}, 1000)
} else {
$.modal.msgError(data.msg);
}
})
}
</script>
</body>
</html>