index.js
1.6 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
// tabRepairOrder/components/relateGoodsPop/index.js
Component({
/**
* 组件的属性列表
*/
properties: {
goodsList: Array,
selected: Array,
baseConfigData: Object,
show: {
type: Boolean,
observer: function (n) {
if (n) {
let { goodsList, selected } = this.data
goodsList?.map(val => {
val.active = false
if (
selected?.findIndex(v => v.subOrderCode == val.subOrderCode) > -1
)
val.active = true
return val
})
this.setData({ goodsList })
}
}
}
},
/**
* 组件的初始数据
*/
data: {},
/**
* 组件的方法列表
*/
methods: {
openInventoryPopup(e){
console.log(e)
let {inventory:{
upgradeGoodsCommodityCode,
upgradeGoodsCustomCode,
specification,
stock
}} = e.target.dataset
const inventoryData ={
upgradeGoodsCommodityCode,
upgradeGoodsCustomCode,
specification,
stock
}
this.triggerEvent('openInventory', inventoryData)
},
choose(e) {
let { item } = e.currentTarget.dataset
let { goodsList } = this.data
goodsList?.forEach(val => {
if (val.subOrderCode == item.subOrderCode) val.active = !val.active
})
this.setData({
goodsList
})
},
cancel() {
this.triggerEvent('cancel')
},
confirm() {
let { goodsList } = this.data
const arr = goodsList?.filter(val => val.active)
if (!arr.length) return wx.$util.showToast('请选择关联商品')
this.triggerEvent('confirm', arr)
}
}
})