chenhaozhe
8 小时以前 269f0bbe965ab2cd17d6acc69ac32070a4d98746
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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
<template>
    <view class="content">
        <view class="mains" v-if="num==1">
            <view class="title">故障登记信息</view>
            <view class="table" >
                <uni-collapse accordion>
                    <uni-collapse-item v-for="(item,index) in hformList" :key="index">
                        <template v-slot:title>
                            <view class="table-line">
                                <view class="line">
                                    <view class="font">
                                        <text>故障原因:</text>{{item.HConkReasonName}}
                                    </view>
                                    <view>
                                        <text>负责人:</text>{{item.HManagerName}}
                                    </view>
                                </view>
                            </view>
                        </template>
                        <view class="table-detail">
                            <view class="detail">
                                <text>故障原因描述:</text>{{item.HClaim?item.HClaim:'暂无描述'}}
                            </view>
                            <view class="detail" v-if="item.HRemark">
                                <text>备注:</text>{{item.HRemark}}
                            </view>
                            <view class="btns">
                                <button class="btnd" size="mini" @tap="edit(index)">编辑</button>
                                <button class="btne" size="mini" @tap="del(index)">删除</button>
                            </view>
                        </view>
                    </uni-collapse-item>
                </uni-collapse>
            </view>
            <view class="foot">
                <button class="btna" size="mini" @tap="creat">新增</button>
                <button class="btnb" size="mini" @tap="over">确认</button>
            </view>
        </view>
        
        <view class="mains" v-if="num == 2">
            <view class="title">故障编辑</view>
            <view class="form">
                <view class="form-item">
                    <view class="item-title">故障原因:</view>
                    <view class="item-right">
                        <uni-combox :candidates="arrayHConkReasonName" placeholder="请选择故障原因" v-model="hform.HConkReasonName" @input="HConkReasonNameInput"></uni-combox>
                    </view>
                </view>
                <view class="form-item">
                    <view class="item-title">负责人:</view>
                    <view class="item-right">
                        <uni-combox :candidates="arrayHManagerName" placeholder="请选择负责人" v-model="hform.HManagerName" @input="HManagerNameInput"></uni-combox>
                    </view>
                </view>
                <view class="form-item" style="align-items: flex-start;">
                    <view class="item-title">故障原因描述:</view>
                    <view class="item-right" style="min-height: 150rpx;">
                        <textarea v-model="hform.HConkExplanation" auto-height maxlength="-1" placeholder="请输入故障原因描述"></textarea>
                    </view>
                </view>
                <view class="form-item">
                    <view class="item-title">备注:</view>
                    <view class="item-right">
                        <input v-model="hform.HRemark" placeholder="请输入备注" />
                    </view>
                </view>
            </view>
            <view class="foot">
                <button class="btnc" size="mini" @tap="back">返回</button>
                <button class="btnb" size="mini" @tap="add">确认</button>
            </view>
        </view>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                serverUrl: uni.getStorageSync('serverUrl')||'http://47.96.97.237/API',
                num:1,
                editIndex:-1,
                
                HConkReasonNameList:[],
                arrayHConkReasonName:[],
                
                HManagerNameList:[],
                arrayHManagerName:[],
                
                hformList:[],
                hform:{},
            }
        },
        props: {
            form1List: {
                type: Array,
                default () {
                    return []
                }
            },
        },
        created() {
            this.getHConkReasonList()
            this.getHManagerNameList()
            this.hformList = this.form1List
        },
        methods: {
            //故障原因
            getHConkReasonList(){
                uni.request({
                    url: this.serverUrl + '/PublicPageMethod/FaultReasonList', 
                    data: { sWhere: '' },
                    success: (res) => {
                        console.log(1,res.data.data);
                        if(res.data.count == 1){
                            this.HConkReasonNameList = res.data.data
                            for(var i=0;i<res.data.data.length;i++){
                                this.arrayHConkReasonName[i] = res.data.data[i].HName
                            }
                            this.$forceUpdate();
                        }else{
                            uni.showToast({
                                title:res.data.Message,
                                icon:'none'
                            })
                        }
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title:'接口请求失败',
                            icon:'none'
                        })
                    },
                });
            },
            HConkReasonNameInput(e){
                console.log(e)
                for(var i=0;i<this.HConkReasonNameList.length;i++){
                    if(this.HConkReasonNameList[i].HName == e){
                        this.hform.HConkReasonID = this.HConkReasonNameList[i].HItemID
                        this.hform.HConkReasonCode = this.HConkReasonNameList[i].HNumber
                    }
                }
            },
            
            //负责人
            getHManagerNameList(){
                uni.request({
                    url: this.serverUrl + '/PublicPageMethod/UserList', 
                    data: { sWhere: '' },
                    success: (res) => {
                        console.log(2,res.data.data);
                        if(res.data.count == 1){
                            this.HManagerNameList = res.data.data
                            for(var i=0;i<res.data.data.length;i++){
                                this.arrayHManagerName[i] = res.data.data[i].HName
                            }
                        }else{
                            uni.showToast({
                                title:res.data.Message,
                                icon:'none'
                            })
                        }
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title:'接口请求失败',
                            icon:'none'
                        })
                    },
                });
            },
            HManagerNameInput(e){
                console.log(e)
                for(var i=0;i<this.HManagerNameList.length;i++){
                    if(this.HManagerNameList[i].HName == e){
                        this.hform.HManagerID = this.HManagerNameList[i].HItemID
                        this.hform.HManagerCode = this.HManagerNameList[i].HNumber
                        this.hform.HManagerName = this.HManagerNameList[i].HName
                    }
                }
            },
            
            creat(){
                this.hform={
                    HConkReasonID:'',
                    HConkReasonCode:'',
                    HConkReasonName:'',
                    HConkExplanation:'',
                    HManagerID:'',
                    HManagerCode:'',
                    HManagerName:'',
                    HRemark:'',
                },
                this.num = 2
            },
            back(){
                this.hformList[this.editIndex] = uni.getStorageSync('hform')
                uni.removeStorageSync('hform')
                this.editIndex = -1 
                this.num = 1
            },
            edit(index){
                this.hform = this.hformList[index]
                uni.setStorageSync('hform', this.hformList[index]);
                this.editIndex = index
                this.num = 2
            },
            del(index){
                this.hformList.splice(index, 1);
            },
            add(){
                if(!this.hform.HConkReasonID){
                    uni.showToast({
                        title:'请选择故障原因',
                        icon:'none'
                    })
                }else if(!this.hform.HManagerID){
                    uni.showToast({
                        title:'请选择负责人',
                        icon:'none'
                    })
                }else{
                    uni.showModal({
                        title: '提示',
                        content: '是否确认提交故障原因,是的话将添加到故障原因信息中。',
                        success: (res) => {
                            if (res.confirm) {
                                if(this.editIndex > -1){
                                    this.hformList.splice(this.editIndex, 1);
                                    this.editIndex = -1
                                    
                                    uni.showToast({
                                        title:'修改完成',
                                        icon:'none'
                                    })
                                }
                                this.num = 1
                                this.hformList.unshift(this.hform)
                            }
                        }
                    });
                }
            },
            
            over(){
                this.$emit('hformList', this.hformList)
            },
        }
    }
</script>
 
<style lang="scss" scoped>
.content{
    width: 100%;
    height: 100%;
    position: fixed;
    z-index: 999;
    top: 0;
    left: 0;
    background-color: rgba(0, 0, 0, 0.5);
}
 
.mains{
    width: 88%;
    height: 88%;
    background-color: #f5f5f5;
    margin: 12% auto;
    border-radius: 14rpx;
    .title{
        width: 100%;
        height: 6%;
        background-color: #fff;
        border-bottom: 1px solid #acacac;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 14rpx 14rpx 0 0;
    }
    .foot{
        padding: 0 40rpx;
        height: 8%;
        background-color: #fff;
        border-top: 1px solid #eee;
        display: flex;
        align-items: center;
        border-radius: 0 0 14rpx 14rpx;
        button{
            width: 180rpx;
        }
    }
    .table{
        width: 100%;
        height: 86%;
        overflow: hidden;
        overflow-y: auto;
        .table-line{
            padding: 18rpx 10rpx 18rpx 20rpx;
            display: flex;
            align-items: center;
            justify-content: space-between;
            .line{
                font-size: 30rpx;
                color: #555;
                text{
                    color: #999;
                    font-size: 27rpx;
                }
                .font{
                    color: #333;
                    line-height: 150%;
                }
            }
        }
        .table-detail{
            font-size: 30rpx;
            color: #555;
            padding: 0 10rpx 24rpx 20rpx;
            text{
                color: #999;
                font-size: 27rpx;
            }
            .detail{}
            .btns{
                text-align: right;
                margin-top: 14rpx;
                button{
                    width: 150rpx;
                    margin-right: 30rpx;
                }
            }
        }
    }
    .form{
        height: 82%;
        padding: 4%;
        overflow: hidden;
        overflow-y: auto;
        .form-item{
            display: flex;
            align-items: center;
            justify-content: space-between;
            font-size: 30rpx;
            padding: 10rpx 0;
            .item-title{
                width: 140rpx;
                text{
                    color: red;
                    font-weight: bold;
                }
            }
            .item-right{
                width: 450rpx;
                border-radius: 22rpx;
                border: 1px solid #acacac;
                background-color: #fff;
            }
            input{
                width: 100%;
                padding: 8rpx 20rpx;
                font-size: 30rpx;
            }
            textarea{
                width: 98%;
                padding: 8rpx 20rpx;
                font-size: 30rpx;
            }
        }
    }
}
 
.btna{
    background-color: #41a863;
    color: #fff;
}
.btnb{
    background-color: #3A78FF;
    color: #fff;
}
.btnc{
    background-color: #acacac;
    color: #fff;
}
.btnd{
    background-color: #d98d00;
    color: #fff;
}
.btne{
    background-color: #da0000;
    color: #fff;
}
</style>