lmw
2024-05-21 0af0750101f969b6ff18d7ade37354b4bcdccd03
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
package com.future.dispatch.ui.order.change_order
 
import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.oktrip.netUtls.callNet
import com.example.oktrip.netUtls.createView
import com.future.dispatch.R
import com.future.dispatch.base.BaseEvent
import com.future.dispatch.base.BaseRecyclerActivity
import com.future.dispatch.base.BaseRvAdapter
import com.future.dispatch.bean.DriverListBean
import com.future.dispatch.netUtls.Api
import com.future.dispatch.ui.adapter.ChangeNewAdapter
import com.future.dispatch.utils.clickDelay
import com.future.dispatch.utils.getMapByAny
import kotlinx.android.synthetic.main.view_btn_sure.view.*
import org.greenrobot.eventbus.EventBus
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.toast
import java.util.HashMap
 
/**
 * @ClassName ChangeNowActivity
 * @Description 改派 选择司机 更换线路
 * @Author Administrator
 * @Date 2020/10/9 15:14
 * @Version 1.0
 */
class ChangeNowActivity:BaseRecyclerActivity<DriverListBean.DataBean>() {
 
    val reassignId by lazy {
        intent.getStringExtra("reassignId")
    }
 
    val changeNewAdapter by lazy {
        ChangeNewAdapter()
    }
 
    override fun getDatas(t: String?): List<DriverListBean.DataBean> {
        return gson.fromJson<DriverListBean>(t,DriverListBean::class.java).data
    }
 
    override fun pathUrl(): String? {
        return Api.queryReassignDriver
    }
 
    override fun mapObject(): HashMap<String?, Any?>? {
        var map = getMapByAny()
        map["reassignId"] = reassignId
        return map
    }
 
    override fun getAdapter(): BaseRvAdapter<DriverListBean.DataBean>? {
        return changeNewAdapter
    }
 
    override fun getlayoutManager(): RecyclerView.LayoutManager? {
        return LinearLayoutManager(this)
    }
 
    override fun setOnItemClickListener(view: View?, position: Int) {
    }
 
    override fun initView() {
        setTitleText("改派")
        var view = createView(R.layout.view_btn_sure,this)
        addMainBottomViewSimple(view)
        view.tv_sure_view.clickDelay {
            callChange()
        }
    }
 
    private fun callChange() {
        if (changeNewAdapter.selectPosition == -1){
            toast("请选择司机")
            return
        }
        var map = getMapByAny()
        map["driverId"] = changeNewAdapter.data[changeNewAdapter.selectPosition].id
        map["id"] = reassignId
        callNet(Api.executeReassign,map){
            toast("改派成功")
            startActivity<RightAwayActivity>("id" to reassignId,"type" to "2")
            EventBus.getDefault().post(BaseEvent(BaseEvent.FILTER_CHANGE_ORDER))
            finish()
        }
 
    }
 
    override fun setOnclick() {
 
    }
}