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
<!-- ******************* 配件选择 ******************* -->
<template>
<view>
<view class="list u-flex u-row-between">
<image class="item-image" :src="mixingImage" v-if="item.required"></image>
<view class="u-m-r-20">{{item.fieldsTitle}}</view>
<view class="u-flex-1 add-parts" @click="toParts" v-if="!disabled">
添加备件<u-icon name="arrow-right" color="#2979ff" size="30"></u-icon>
</view>
</view>
<view class="complete-part">
<view v-if="lists.length > 0">
<adjust-parts v-for="(item, index) in lists" :key="index" :info="item" @change="partsChange($event, index)" :disabled="disabled"></adjust-parts>
</view>
<view class="u-flex select-part" v-else>
<view class="img">
<image :src="noPartsImage" class="part-icon" />
</view>
<view class="u-flex content">
<text class="title">暂无备件信息</text>
<text class="desc">可选择备件仓配件</text>
</view>
<view class="btn">
<u-button shape="circle" :custom-style="customStyle" @click="toParts">
去选择
</u-button>
</view>
</view>
</view>
</view>
</template>
<script>
import adjustParts from "@/components/select-parts/adjust"
import stringMixin from './stringMixin'
export default {
name: 'XhParts',
components: {
adjustParts
},
mixins: [stringMixin],
props: {
orderId: {
type: String,
default: ''
}
},
data() {
return {
lists: []
}
},
computed: {
customStyle() {
return {
'width': '200rpx',
'height': '80rpx',
'color': '#2272FF',
'font-size': '32rpx',
}
},
mixingImage() {
return process.uniEnv.qn_base_url + 'mixing.png'
},
noPartsImage() {
return process.uniEnv.qn_base_url + 'no_parts.png'
},
},
mounted() {
this.getWorkOrderParts()
},
methods: {
getWorkOrderParts() {
// this.lists = JSON.parse(this.dataValue) || []
this.lists = this.dataValue ? JSON.parse(this.dataValue) : []
},
partsChange(val, index) {
this.$set(this.lists[index], 'quantity', val)
this.valueChange(JSON.stringify(this.lists))
},
valChange(val) {
val.forEach(v => {
const index = this.lists.findIndex(k => k.part_id === v.part_id)
if (index < 0) {
this.lists.push(v)
} else {
this.$set(this.lists, index, v)
}
})
this.valueChange(JSON.stringify(this.lists))
},
toParts() {
uni.navigateTo({
url: `/pages/order/parts?workOrderId=${this.orderId}`
})
}
}
}
</script>
<style lang="scss" scoped>
.item-image {
width: 24rpx;
height: 24rpx;
margin-right: 10rpx;
}
.required {
padding-right: 10rpx;
font-size: 28rpx;
line-height: 40rpx;
color: #fa3534;
}
.add-parts {
color: #2272FF;
text-align: right;
}
.complete-part {
.select-part {
align-items: center;
height: 240rpx;
.img {
display: flex;
align-items: center;
margin-right: 30rpx;
.part-icon {
width: 110rpx;
height: 110rpx;
border-radius: 50%;
}
}
.content {
padding-right: 8px;
flex: 1;
color: #3b4144;
flex-direction: column;
justify-content: space-between;
overflow: hidden;
.title {
text-align: left;
color: #2272FF;
font-size: 38rpx;
font-weight: bold;
margin-right: auto;
}
.desc {
text-align: left;
color: #999;
font-size: 26rpx;
margin-right: auto;
}
}
}
}
</style>