quanyawei
2023-11-10 0a24ffeb3eff074c8f11e9f94fdf2c2cb4929799
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
<template>
    <view class="mainContent">
        <basicInfor :basic-infor="basicInfor" v-if="isShow" />
        <rectificationInfor ref="rectificationInfor" :basic-infor="basicInfor"
            v-if="!(pageState === 'view' && basicInfor.state === 20)&&isShow" />
        <approvalnfor ref="approvalnfor" v-if="basicInfor.state >= 30 && basicInfor.stateName!=='待完成' && isShow"
            :basic-infor="basicInfor" />
        <view class="bunts" v-if="isShow">
            <view class="but butRight">
                <u-button shape="square" @click="refuse" type="error"
                    v-if="pageState==='edit'&& basicInfor.state >= 30">拒绝</u-button>
                <u-button shape=" square" @click="close" v-else>关闭</u-button>
            </view>
            <view class="but butleft" v-if="pageState==='edit'">
                <u-button shape="square" type="primary" @click="submit"> 提交 </u-button>
            </view>
        </view>
        <u-overlay :show="show" :mask-click-able='false' opacity='0.8'>
        </u-overlay>
    </view>
</template>
<script>
    import basicInfor from '../components/basicInfor.vue'
    import rectificationInfor from '../components/rectificationInfor.vue'
    import approvalnfor from '../components/approvalnfor.vue'
    export default {
        components: {
            basicInfor,
            rectificationInfor,
            approvalnfor,
        },
        data() {
            return {
                basicInfor: {},
                unitListL: [],
                userInfor: null,
                show: true,
                isShow: false,
                option: {}
            }
        },
        computed: {
            pageState() {
                return this.basicInfor.pageState
            },
        },
        created() {
            this.getUnitList()
        },
        onLoad(option) {
            //option为object类型,会序列化上个页面传递的参数
            this.basicInfor = JSON.parse(option.infor)
            // let type = JSON.parse(option.type)
            console.log('option', option)
            this.option = option
        },
        async mounted() {
            await this.$onLaunched
            //等待登录成功 
            this.userInfor = JSON.parse(uni.getStorageSync('userInfor') || 'null')
            console.log('详情页的用户信息', this.userInfor)
            if (this.option.type === 'share' && this.userInfor) {
                let params = {
                    allocationNum: this.basicInfor.allocationNum,
                    userId: this.userInfor.userId
                }
                this.$http.httpGet('/allocationApp/authority', params).then(res => {
                    console.log('权限控制参数', res)
                    if (res.data.code === 3) {
                        uni.showModal({
                            content: '您暂无操作权限,请联系管理员!',
                            showCancel: false,
                            confirmText: '确定',
                            success: res => {
                                if (res.confirm) {
                                    uni.reLaunch({
                                        url: '/pages/index/index',
                                    })
                                }
                            },
                        })
                    } else if (res.data.code === 1) {
                        // 可以编辑
                        this.basicInfor.pageState = 'edit'
                        this.basicInfor.stateName = res.data.name
                        this.getData()
                    } else if (res.data.code === 2) {
                        // 可以看
                        this.basicInfor.pageState = 'view'
                        this.basicInfor.stateName = res.data.name
                        this.getData()
                    }
                }).catch(errors => {
                    console.log('获取失败的信息', errors)
                    console.log('获取失败的信息params', params)
                })
            } else {
                this.isShow = true
                this.getData()
            }
            console.log('this.basicInfor123', this.basicInfor)
        },
        methods: {
            getData() {
                this.$http.httpGet('/allocation/detail', {
                    id: this.basicInfor.allocationId
                }).then(res => {
                    this.isShow = true
                    this.show = false
                    this.basicInfor = {
                        ...this.basicInfor,
                        ...res.data
                    }
                })
            },
            getUnitList() {
                this.$http.httpGet('/allocation/unit').then(res => {
                    this.unitList = res.data
                    let data = ''
                    if (this.basicInfor.unitId && this.unitList.length > 0) {
                        data = this.unitList && this.unitList.find(a => Number(a.unitId) === Number(this.basicInfor
                            .unitId)).unitName
                        let time = this.basicInfor.time.slice(5)
                        this.share.title = `${data}-${time}的交办单`
                    }
                })
            },
            radioGroupChange(e) {
                console.log('radioGroupe,e', this.workForme.isChange)
            },
            close() {
                uni.$emit('currIndex', {
                    data: {
                        index: '0',
                        showTabBar: true
                    }
                })
                uni.redirectTo({
                    url: '/pages/index/index',
                })
            },
            refuse() {
                Promise.all([this.$refs.rectificationInfor && this.$refs.rectificationInfor.formVali(), this.$refs
                        .approvalnfor && this.$refs.approvalnfor.formVali()
                    ]) //
                    .then(() => {
                        let api = this.basicInfor.state >= 30 ? '/allocation/check' : '/allocation/change' //审批
                        let form = this.basicInfor.state >= 30 ? this.$refs.approvalnfor.form : this.$refs
                            .rectificationInfor.form
                        let data = {
                            allocationId: this.basicInfor.allocationId,
                            ...form,
                            state: 50,
                        }
                        this.$http.httpPost(api, data).then(res => {
                            this.close()
                        })
                    }).catch(err => {
                        console.log('拒绝失败:', err)
                    })
            },
            submit() {
                Promise.all([this.$refs.rectificationInfor && this.$refs.rectificationInfor.formVali(), this.$refs
                        .approvalnfor && this.$refs.approvalnfor.formVali()
                    ]) //
                    .then(() => {
                        let api = this.basicInfor.state >= 30 ? '/allocation/check' : '/allocation/change' //审批
                        let form = this.basicInfor.state >= 30 ? this.$refs.approvalnfor.form : this.$refs
                            .rectificationInfor.form
                        let data = {
                            allocationId: this.basicInfor.allocationId,
                            ...form,
                            state: this.basicInfor.state === 20 ? 30 : 40,
                        }
                        this.$http.httpPost(api, data).then(res => {
                            this.close()
                        })
                    }).catch(err => {
                        console.log('提交失败:', err)
                    })
            }
        },
    }
</script>
<style scoped lang="scss">
    .mainContent {
        padding-bottom: 38.46rpx;
    }
 
    .bunts {
        display: flex;
        margin-top: 20px;
        margin-bottom: 96.15rpx;
        padding: 0 20px;
        justify-content: center;
 
        .but {
            width: 50%;
        }
 
        .butRight {
            padding-right: 20px;
        }
 
        .butleft {
            padding-left: 20px;
        }
    }
</style>