addOrder.js
4.07 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
(function($$) {
"use strict";
let vm
const util = new window.publicMethod() ;
function init() {
vm = new Vue({
el: '#pageDiv',
data: {
info: {},
confirmFlag: false,
typeArr: [],
deviceArr: [],
pickData: {
isShow: false,
title: '',
typeIndex: 0,
deviceIndex: 0,
dIndex: 0,
ntype: '',
index: 0,
arr: []
},
orderArr: []
},
created: function() {
this.info = JSON.parse(sessionStorage.getItem('huaiAnAppParam'))
this.addOrder()
this.getType()
this.getDevice()
},
methods: {
goBack(){
history.go(-1)
},
onConfirm(value, index) {
let p = this.pickData
if(p.ntype == 'device'){
this.orderArr[this.pickData.index].terminalClass = value
}else{
this.orderArr[this.pickData.index].serviceName = value
}
this.pickData.isShow = false
},
onCancel(){
this.pickData.isShow = false
},
addOrder(){
this.orderArr.push({
orderCode: '',
serviceName: '',
terminalClass: '',
deviceNumber: '',
applyId: this.info.applyId
})
},
goSave(){
let arr = this.orderArr
for(let i=0,j=arr.length;i<j;i++){
let p = arr[i]
if(!p.orderCode){
util.toast('请输入工单'+(i+1)+'的工单ID')
return
}
if(!p.serviceName){
util.toast('请选择工单'+(i+1)+'的工单类型')
return
}
if(!p.terminalClass){
util.toast('请选择工单'+(i+1)+'的添加设备')
return
}
if(p.terminalClass=='软终端' && !p.deviceNumber){
util.toast('请输入工单'+(i+1)+'的设备串号')
return
}
}
this.confirmFlag = true
},
saveOrder(){
util.httpRequest({
url: '/addDevices',
data: {
data: this.orderArr
},
}).then(res=>{
if(res.code == 200){
util.toast('保存成功')
this.confirmFlag = false
history.go(-1)
//window.location.replace('index.html?time='+new Date().getTime())
}else{
util.toast(res.msg)
}
})
},
pickShow(ntype,index){
this.pickData.ntype = ntype
this.pickData.index = index
this.pickData.title = ntype=='device'?'添加设备':'工单类型'
this.pickData.arr = ntype=='device'?this.deviceArr:this.typeArr
this.pickData.isShow = true
},
getType(){
util.httpRequest({
url: '/listEnum',
middleUrl: '/zhijian-trial/common',
data: {
type: 1
},
}).then(res=>{
if(res.code == 200){
this.deviceArr = res.data.map(item=>{
return item.value
})
}
})
},
getDevice(){
util.httpRequest({
url: '/listEnum',
middleUrl: '/zhijian-trial/common',
data: {
type: 2
},
}).then(res=>{
if(res.code == 200){
this.typeArr = res.data.map(item=>{
return item.value
})
}
})
}
}
})
}
init()
window.vm = vm
})(window.jQuery)
window.addEventListener('load', function () {
document.getElementById('pageDiv').style.display = 'block'; // 显示内容
});