wjt
2024-06-22 27da067243b78340dac4f75c5131059617594037
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
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
<template>
    <view class="page-box">
        <view class="content-box">
            <view class="form">
                <view class="form-item">
                    <view class="form-label require">
                        执法主题
                    </view>
                    <input type="text" placeholder="请输入" v-model="form.enforceReason"/>
                </view>
                <view class="form-item">
                    <view class="form-label require">
                        执法对象
                    </view>
                    <view class="input">
                        <input type="text"  placeholder="请输入" v-model="form.companyName"/>
                        <!-- <u-icon name="arrow-right"></u-icon> -->
                        <u-text text='搜索' type="primary" @click="search"></u-text>
                    </view>
                </view>
                <view class="form-item">
                    <view class="form-label require">
                        执法时间
                    </view>
                    <view class="input" @click="showTimeFun">
                        <input type="text" placeholder="请输入" disabled v-model="form.planTimeStr"/>
                        <u-icon name="arrow-right"></u-icon>
                    </view>
                </view>
                <view class="form-item" @click="showType = true">
                    <view class="form-label require">
                        执法类型
                    </view>
                    <view class="input">
                        <input type="text" placeholder="请输入" v-model="form.enforceTypeName" disabled/>
                        <u-icon name="arrow-right"></u-icon>
                    </view>
                </view>
                <view class="form-item last">
                    <view class="form-label require">
                        执法内容
                    </view>
                    <view class="back">
                        <u--textarea :height="120" v-model="form.enforceContent" placeholder="请输入" count maxlength="500"></u--textarea>
                    </view>
                </view>
            </view>
        </view>
        <view class="content-box">
            <view class="form ">
                <view class="form-item">
                    <view class="form-label">
                        执法人员
                    </view>
                    <input type="text" placeholder="请输入" v-model="form.applyUser" disabled/>
                </view>
                <view class="form-item">
                    <view class="form-label">
                        执法部门
                    </view>
                    <input type="text" placeholder="请输入" v-model="form.applyDeptName" disabled/>
                </view>
                <view class="form-item sui" style="align-items: flex-start;" @click="openPer">
                    <view class="form-label require ">
                        随行人员
                    </view>
                    <view>
                        <view style="color: #a2a2a2;" class="placeholder" v-if="!form.peers.length">请选择</view>
                        <view v-else>
                            <view style="margin-bottom: 20rpx;" v-for="(item,index) in form.peers"  :key="index">
                                {{item.peerUser}}({{item.peerDeptName}})
                            </view>
                        </view>
                    </view>
                    <!-- <u-textarea  border="none" disabled style="padding: 0;" placeholder="请选择" ></u-textarea> -->
                </view>
                <view class="form-item down-2">
                    <view class="form-label">
                        是否通知企业
                    </view>
                    <u-switch v-model="form.isNoticeCompany" :activeValue="1" :inactiveValue="0"></u-switch>
                </view>
                
            </view>
        </view>
        <view class="down-options">
            <view class="button record" @click="applyRecord">申请记录</view>
            <view class="button submit" @click="submitApply">提交申请</view>
        </view>
        <!-- <u-form label-position="top" label-width="120px">
            <u-form-item label="执法主题">
                <u-input placeholder="请输入" v-model="form.enforceReason"></u-input>
            </u-form-item>
            <u-form-item label="执法对象">
                <u-input placeholder="请输入" v-model="form.companyName">
                    <template  slot="suffix">
                        <text @click="search">搜索</text>
                    </template>
                </u-input>
            </u-form-item>
            <u-form-item label="执法时间" @click="showTimeFun">
                <u-input placeholder="请输入" v-model="form.applyTime" readonly></u-input>
            </u-form-item>
            <u-form-item label="执法类型" @click="showType = true">
                <u-input placeholder="请输入" v-model="form.enforceTypeName" readonly></u-input>
            </u-form-item>
            <u-form-item label="执法内容">
                <u-input placeholder="请输入" v-model="form.regionReason"></u-input>
            </u-form-item>
            <u-form-item label="执法人员">
                <u-input placeholder="请输入" v-model="form.applyName"></u-input>
            </u-form-item>
            <u-form-item label="执法部门">
                <u-input placeholder="请输入" v-model="form.applyDeptName"></u-input>
            </u-form-item>
            <u-form-item label="随行人员数量">
                <u-input placeholder="请输入" v-model="form.userNum"></u-input>
            </u-form-item>
            <u-form-item label="是否通知企业">
                <u-switch v-model="form.isNoticeCompany" :activeValue="1" :inactiveValue="0"></u-switch>
            </u-form-item>
        </u-form> -->
<!--         <u-button @click="submitApply">提交申请</u-button>
        <u-button @click="applyRecord">申请记录</u-button> -->
        <u-picker :show="show" @close="show = false" @confirm="confirmSearch" @cancel="show = false" :columns="columns" keyName="companyName"></u-picker>
        <!-- <u-datetime-picker
            :show="showTime"
            @close="showTime = false"
            @cancel="showTime = false"
            @confirm="confirmTime"
            :minDate="minDate"
            v-model="currentTime"
            @change="changeValue"
            mode="datetime"
            ref="datetimePicker"
            ></u-datetime-picker> -->
             <yt-dateTimePicker
                  ref="myPicker"
                  @submit="confirmTime"
                  :start-year="year"
                  :end-year="endYear"
                  :time-init="timeInit"
                  :time-hide="[true, true, true, true, false, false]"
                />
            <u-picker :show="showType" @close="showType = false" @confirm="confirmType" @cancel="showType = false" :columns="columnsType" keyName="dictLabel"></u-picker>
            <perPage :list="list" ref="perpage" @selectValue="selectValue"></perPage>
    </view>
</template>
 
<script>
    import { orderAdd, companyList, enforceList } from '@/api/policy.js'
    import { getInfo } from '@/api/auth.js'
    import { getDicts } from '@/api/data'
    import perPage from './perPage'
    import YtDateTimePicker from "uni_modules/yt-dateTimePicker/components/yt-dateTimePicker/yt-dateTimePicker.vue"
    export default {
        components: {
            YtDateTimePicker,
            perPage
        },
        data() {
            return {
                currentTime: "",
                form: {
                    applyUser: '',
                    applyDeptName: '',
                    enforceType: 1,
                    isNoticeCompany: 0,
                    // regionReason: 0,
                    planTimeStr: '',
                    peers: [],
                    orderStatus: 1,
                    enforceContent: ""
                },
                show: false,
                columns: [],
                showTime: false,
                columnsType: [],
                showType: false,
                minDate: '',
                year: '',
                endYear: '',
                timeInit: '',
                list: []
            }
        },
        onLoad() {
            this.year = new Date().getFullYear()
            this.endYear = this.year + 5
            this.minDate = new Date().valueOf()
            this.timeInit = this.$u.timeFormat(new Date(), 'yyyy-mm-dd')
            this.getInfo()
            this.getDicts()
            this.enforceList()
        },
        methods: {
            enforceList() {
                enforceList().then(val => {
                    this.list = val.data.data
                })
            },
            getDicts() {
                getDicts('enforce_type').then(val =>{
                    this.columnsType = [val.data.data]
                })
            },
            getInfo() {
                getInfo().then(val => {
                    const value = val.data.data
                    // this.form.applyName = value.nickName
                    this.form.applyUser = value.nickName
                    this.form.applyId = value.userId
                    this.form.applyDeptName = value.dept.deptName
                    this.form.applyDeptId = value.dept.deptId
                    this.form.applyPhone = value.phonenumber
                })
            },
            timeFilter(mode, options) {
                let d = new Date()
                // console.log(d.getFullYear());
                if(mode === 'year'){
                    return options.filter((option)=>option>= d.getFullYear())
                }
                if(mode === 'month'){
                    return options.filter((option)=>option>= d.getMonth()+1)
                }
                if (mode === 'minute') {
                    return options.filter((option) => option === '00' || option === '30');
                }
                return options;
            },
            authFile() {
                if(!this.form.enforceReason){
                    return '请填写主题'
                }
                if(!this.form.companyName){
                    return '请填写确认执法对象'
                }
                if(!this.form.companyId) {
                    return '请点击搜索确认执法对象'
                }
                if(!this.form.planTimeStr) {
                    return '请填写执法时间'
                }
                if(!this.form.enforceTypeName){
                    return '请选择执法类型'
                }
                if(!this.form.enforceContent) {
                    return '请填写执法内容'
                }
                if(!this.form.peers.length){
                    return '请添加同行人'
                }
                return ''
            },
            submitApply(){
                const res =    this.authFile()
                if(res){
                    uni.showToast({
                        title: res,
                        icon: 'none'
                    })
                    return
                }
                orderAdd(this.form).then(val => {
                    if(val.data.code == 200) {
                        uni.showToast({
                            title: '提交成功',
                            icon: 'none'
                        })
                        setTimeout(() => {
                            uni.navigateBack()
                        }, 500)
                    }
                })
            },
            applyRecord() {
                uni.navigateTo({
                    url:`/policy/applyRecord/applyRecord`
                })
            },
            search() {
                companyList({companyName: this.form.companyName}).then(val => {
                    if(val.data.code == 200){
                        if(!val.data.rows.length || !val.data.rows){
                            uni.showToast({
                                title: '没有符合的数据,请检查输入的执法对象',
                                icon: 'none',
                                duration: 3000
                            })
                        } else {
                            this.columns = [val.data.rows]
                            this.show = true
                        }
                        
                    }
                })
            },
            confirmSearch(e){
                const value =    this.columns[0].find(item => item.companyName == e.value[0].companyName)
                this.form.companyName = e.value[0].companyName
                this.form.companyCode = value.companyCode
                this.form.companyId     = value.companyId    
                this.form.companyPhone = value.companyPhone
                this.form.companyUser = value.companyUser
                this.form.companyAddress = value.companyAddress
                this.show = false
            },
            confirmTime(e) {
                this.form.planTime = e.year + '-' + e.month+ '-' + + e.day + ' ' + e.hour + ":" + "00:00"
                this.form.planTimeStr = e.year + '-' + e.month+ '-' + + e.day + ' ' + e.hour
            },
            showTimeFun() {
                // this.showTime = true
                          this.$refs.myPicker.show();
 
            },
            sheet(){
                
            },
            confirmType(e){
                this.form.enforceType = e.value[0].dictCode
                this.form.enforceTypeName = e.value[0].dictLabel
                this.showType = false
            },
            changeValue(e, e1) {
                this.currentTime = e.value
            },
            openPer() {
                this.$refs.perpage.open(this.list)
            },
            selectValue(value) {
                this.list.forEach(item => {
                    if(value.includes(item.userId)) {
                        this.form.peers.push({
                            peerDeptId: item.dept.deptId,
                            peerDeptName: item.dept.deptName,
                            peerId: item.userId,
                            peerPhone: item.phonenumber,
                            peerType: 2,
                            peerUser: item.nickName
                        })
                    }
                })
            }
        }
    }
</script>
<style>
    page{
        background-color: #F4F4F4;
    }
    .sui  .u-textarea{
        padding: 0 !important;
    }
</style>
<style scoped lang="scss">
.page-box{
    padding-bottom: 140rpx;
    .content-box{
        margin:20rpx 32rpx;
        background-color: white;
        padding: 24rpx;
        border-radius: 10rpx;
    }
    .form{
        .form-item{
            display: flex;
            justify-content: flex-start;
            align-items: center;
            border-bottom: 2rpx solid #F1F1F1;
            padding-bottom: 26rpx;
            margin-bottom: 24rpx;
            .form-label{
                font-size: 30rpx;
                color: #4A4E60;
                width: 40%;
            }
            .input{
                width: 60%;
                display: flex;
                justify-content: space-between;
                align-items: center;
            }
            .require{
                &::after{
                    content: '*';
                    color: #FF7500;
                }
            }
        
        }
        .down-2{
            margin-bottom: 0;
            padding-bottom: 0;
            border: none;
        }
        .last{
            margin-bottom: 0;
            padding-bottom: 0;
            border-bottom: none;
            display: block;
            .form-label{
                margin-bottom: 16rpx;
                
            }
            .back{
                /deep/ .u-textarea{
                    background-color: #F4F4F4;
                    border: none;
                    .u-textarea__count{
                        background: none !important;
                    }
                }
            }
        }
        
    }
}
.down-options{
    background-color: white;
    position: fixed;
    bottom: 0;
    padding-bottom: 40rpx;
    width: 100%;
    padding: 22rpx 30rpx 40rpx;
    z-index: 800;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
    .record{
        box-sizing: border-box;
        border-radius: 20rpx;
        border: 2rpx solid #ABD2FF;
        background: #F0F8FF;
        color: #1171E0;
        font-size: 32rpx;
        padding: 20rpx 30rpx;
        width: 30%;
        text-align: center;
    }
    .submit{
        border-radius: 20rpx;
        border: 2rpx solid #1171E0;
        background-color: #1171E0;
        color: white;
        width: 65%;
        box-sizing: border-box;
        padding: 20rpx 30rpx;
        text-align: center;
    }
}
.sui{
 
}
    
</style>