SecondStep.js
8.29 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
// packageEquity/pages/carEquity/components/SecondStep/SecondStep.js
import data from '../constant/stepData'
import fn from '../constant/ruleFn'
import { ImgUrl } from '~/config'
import {
compareCentAmounts,
yuanToCentInteger
} from '../../services/quotationMoney.helpers.js'
const defaultLabelWidth = 'var(--fontSize140)'
const IMG_URL = ImgUrl + '/'
Component({
options: {
styleIsolation: 'apply-shared'
},
// behaviors: ['wx://component-export'],
attached() {
console.log('component attached')
this.makeYear()
},
/**
* 组件的属性列表
*/
pageLifetimes: {
show: function () {},
attached: function () {
// 在组件实例进入页面节点树时执行
},
hide: function () {}
},
properties: {
serviceInfo: {
type: Object,
value: () => {}
},
orderInfo: {
type: Object,
observer: function (n) {
if (n.quotedPriceUpdate) {
this.setData({
testQuotedPriceUpdate: n.quotedPriceUpdate
})
}
if (n?.modifyEquityQuotation) {
this.setData({
activeNames: ['3'],
disable: true
})
} else {
this.setData({
activeNames: ['1', '2', '3', '4'],
disable: false
})
}
}
},
quotationGoodsList: {
type: Array,
value: () => {}
}
},
observers: {
'orderInfo.outTradeNo': function (value) {
console.log(value, 'outTradeNo')
this.setData({
textNameObj: {
confirmName: '下一步(2/4)'
}
})
}
},
/**
* 组件的初始数据
*/
data: {
IMG_URL,
defaultLabelWidth,
showYear: false,
// 选择时间的年份
columns: [],
disable: false,
currentDate: new Date().getTime(),
// 默认当前年份
currentIndex: new Date().getFullYear() - (new Date().getFullYear() - 25),
currentName: new Date().getFullYear() + '年',
popupShow: false,
popupInputShow: false,
// customInput: true,
// secondObj: data.secondObj,
formRule: data.formRule,
textNameObj: {
confirmName: '下一步·生成告知书(2/4)',
// editName: '修改',
cancelName: '存草稿'
},
// '1', '2', '3',
activeNames: ['1', '2', '3', '4'],
showPicker: false,
// optionsSelect: Object.freeze(optionsSelect),
popObj: {
popValue: ''
},
popinputobj: {
type: 'add'
},
showError: false,
insuranceCheck: false,
testQuotedPriceUpdate: 0
},
/**
* 组件的方法列表
*/
methods: {
// test() {
// let { activeNames } = this.data
// console.log('activeNames', activeNames)
// },
onChangeInsurance(e) {
const { detail } = e
const { id: goodsId } = e.currentTarget.dataset
if (!detail) {
this.setData({
insuranceCheck: false
})
return this.triggerEvent('orderChange', {
patch: {
quotedPriceUpdate: '',
goodsId: '',
goodsName: '',
valueAddedVehicleLoss: {
appreciation: '',
goodsName: '',
type: 3
}
}
})
}
return this.triggerEvent('quoteRequested', { goodsId: goodsId })
},
//--------自定义方法----------
// 选择年份的区域,弹出弹窗框
chooseYear() {
console.log('选择年份')
this.setData({
showYear: true
})
},
// 弹出框确认事件
onConfirm(e) {
const { value } = e.detail
const vehiclesAndVessels = {
...(this.properties.orderInfo?.vehiclesAndVessels || {}),
compensation: value + '年'
}
this.triggerEvent('orderChange', {
patch: { vehiclesAndVessels }
})
this.setData({
showYear: false
})
this.cancelInsuranceCheck()
},
cancelInsuranceCheck() {
this.triggerEvent('orderChange', {
patch: {
quotedPriceUpdate: '',
goodsId: '',
goodsName: '',
valueAddedVehicleLoss: {
appreciation: '',
goodsName: '',
type: 3
}
}
})
},
// 取消选择年份的弹框
onCancel() {
let that = this
that.setData({
showYear: false
})
},
// 对选择时间进行单独的处理
makeYear() {
// console.log('makeYear')
let year = []
let currentDate = new Date()
console.log(currentDate.getFullYear())
for (let j = currentDate.getFullYear() - 25; j < currentDate.getFullYear(); j++) {
year.push(j)
}
for (let i = currentDate.getFullYear(); i <= currentDate.getFullYear() + 25; i++) {
year.push(i)
}
// console.log(year, 'year')
this.setData({
columns: year
})
},
handlePopupShow(e) {
// console.log(e)
let { disable } = this.data
if (disable) return false //修改权益价时,不可修改
// let { attrtype, attrname, typename } = e.target.dataset
let { attrtype, attrname, typename } = e.currentTarget.dataset
console.log(attrtype, attrname, typename, 'attrType, attrName')
let popValue = this.properties.orderInfo?.[attrtype]?.[attrname] || ''
this.setData({
popupShow: true,
// popValue
popObj: {
attrtype,
attrname,
popValue,
typename
}
})
},
handlePopInputShow(e) {
// console.log(e)
let { disable } = this.data
if (disable) return false //修改权益价时,不可修改
let { handletype, index } = e.currentTarget.dataset
// console.log(handletype, index, 'type, index')
let popValue = ''
if (handletype == 'edit') {
popValue = this.properties.orderInfo?.otherInsuranceList?.[index] || ''
}
// console.log(popValue, 'popValue')
this.setData({
popupInputShow: true,
popinputobj: {
handletype,
index,
...popValue
}
})
},
btnTap(e) {
// console.log(e)
let { name } = e.detail
// let { attrtype, attrname, typename } = this.data.tableObj
let { showError, insuranceCheck, orderInfo } = this.data
if (showError) return wx.$util.showToast('权益价不能小于最低权益价')
if (name == 'confirm') {
// 不是修改报价时,需要勾选保险
// if (!insuranceCheck && !orderInfo.modifyEquityQuotation) return wx.$util.showToast('请先勾选保险')
if (!orderInfo.quotedPriceUpdate && !orderInfo.modifyEquityQuotation) return wx.$util.showToast('请先勾选增值车损险')
this.triggerEvent('confirm')
} else {
this.triggerEvent('editSave')
}
},
onChange(event) {
console.log(event, 'event')
this.setData({
activeNames: event.detail
})
},
handleInput(e) {
let value = e.detail
console.log(e)
let { attrname, attrtype, type } = e.currentTarget.dataset
value = type == 'number' ? wx.$util.numberFixedDigit(value) : value
if (type == 'number') {
const inputAmount = yuanToCentInteger(value)
const compared = inputAmount.ok
? compareCentAmounts(inputAmount.value, 200000000)
: { ok: false }
value = compared.ok && compared.value > 0 ? 2000000 : value
}
console.log(attrtype)
if (attrtype == 'modifyEquityQuotation') {
let { orderInfo } = this.data
let showError = orderInfo.modifyEquityQuotation.minEquityPrice <= value ? false : true
this.setData({
showError
})
}
// ['orderInfo' + '.' + attrType]
// console.log(['orderInfo' + '.' + attrType], '2')
const patch = attrtype
? {
[attrtype]: {
...(this.properties.orderInfo?.[attrtype] || {}),
[attrname]: value
}
}
: { [attrname]: value }
this.triggerEvent('orderChange', {
patch: patch
})
this.cancelInsuranceCheck()
// console.log(thisPage.data)
}
// numberFixedDigit (e) { // 固定两位小数
// e.target.value = (e.target.value.match(/^\d*(\.?\d{0,2})/g)[0]) || ''
// this.$nextTick(() => {
// this.number= e.target.value
// })
// },
}
})