index.js
4.12 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
// tabRepairOrder/components/outboundPopup/index.js
const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/'
import { createQrcodeImage } from '~/api/api'
import api from '../../api'
Component({
/**
* 组件的属性列表
*/
properties: {
show: {
type: Boolean,
observer: function(n) {
if (n) {
this.setData({
scrollTop: 0
})
let { detailInfo } = this.data
this.setData({
infoData: wx.$util.deepClone(detailInfo),
'infoData.outBoundTime': new Date().format('yyyy-MM-dd hh:mm:ss')?.replace(/\//g, '-')
}, () => {
this.getDetailInfo(this.data.infoData)
})
}
}
},
title: String,
detailInfo: {
type: Object
},
userPermissions: Array
},
/**
* 组件的初始数据
*/
data: {
IMG_URL,
infoData: {},
filmRollNoList: [],
scrollTop: 0
},
/**
* 组件的方法列表
*/
methods: {
async getDetailInfo(data) {
let oParams = {}
oParams.appId = wx.getAccountInfoSync().miniProgram.appId
oParams.qrcodeType = 'QR_WXA_UNLIMIT'
oParams.path = 'tabRepairOrder/pages/repairOrderDetail/repairOrderDetail'
oParams.scene = `merchantId=${data.merchantId}&yqMerchantId=${data.sellerMerchantId}&id=${data.id}&constructionCode=${data.constructionCode}&orderCode=${data.orderCode}`
oParams.channelType = 1
const res = await createQrcodeImage(oParams)
this.setData({
weappQrcode: res.data
})
},
// 选择膜卷号
handleRollNumber(e) {
let { target, index } = e.currentTarget.dataset
let { detailInfo } = this.data
// 获取膜卷号数据
api.getfilmRollNoByGoods({
upgradeGoodsId: target.upgradeGoodsId,
yqMerchantId: detailInfo?.sellerMerchantId,
merchantId: detailInfo?.merchantId
}).then(res => {
let { code, data, message } = res
if (code == 0) {
this.setData({
filmRollNoList: data || [],
filmRollNoVisible: true,
filmSelectedItem: target.rollNumber,
selectRollIndex: index
})
} else {
wx.$util.showToast(message)
}
})
},
// 膜卷号确认
changefilmRollNo(e) {
let { selectRollIndex } = this.data
if (e.detail) {
this.setData({
[`infoData.subOrderList[${selectRollIndex}].rollNumber`]: e.detail
})
}
this.handelCancelRollPopup()
},
// 膜卷号取消
handelCancelRollPopup() {
this.setData({filmRollNoVisible: false})
},
// 实际用料输入框
handleInput(e) {
const { index } = e.currentTarget.dataset
let value = e.detail.value
value = value.replace(/[^\d.]/g, '')
// 处理多个小数点的情况,只保留第一个
const dotIndex = value.indexOf('.')
if (dotIndex !== -1) {
value = value.substring(0, dotIndex + 1) + value.substring(dotIndex + 1).replace(/\./g, '')
}
// 限制小数点后最多两位
if (dotIndex !== -1) {
const decimalPart = value.substring(dotIndex + 1)
if (decimalPart.length > 2) {
value = value.substring(0, dotIndex + 3)
}
}
// 转换为数字进行最大值验证
const numValue = parseFloat(value || 0)
if (!isNaN(numValue) && numValue > 99999.99) {
value = '99999.99'
}
this.setData({
[`infoData.subOrderList[${index}].materialsUsed`]: value
});
},
// 产品出库时间
handleOutboundTime() {
this.setData({
timeVisible: true
})
},
// 产品出库时间确认
onTimeConfirm(e) {
this.setData({
'infoData.outBoundTime': e.detail
})
this.onClosePicker()
},
// 产品出库时间弹窗取消
onClosePicker() {
this.setData({timeVisible: false})
},
// 关闭物料出库弹窗
cancel() {
this.triggerEvent('cancel')
},
confirm() {
let { infoData } = this.data
this.triggerEvent('confirm', infoData)
}
}
})