|
|
|
|
@ -13,15 +13,24 @@ import com.rehome.zhdcoa.Contans
|
|
|
|
|
import com.rehome.zhdcoa.adapter.WhpListAdapter
|
|
|
|
|
import com.rehome.zhdcoa.base.BaseActivityOaToolbarViewBinding
|
|
|
|
|
import com.rehome.zhdcoa.base.BaseCallBack
|
|
|
|
|
import com.rehome.zhdcoa.bean.DagerEnterApplyBaseBean
|
|
|
|
|
import com.rehome.zhdcoa.bean.DagerEnterApplyBean
|
|
|
|
|
import com.rehome.zhdcoa.bean.GetAuditBean
|
|
|
|
|
import com.rehome.zhdcoa.bean.StaffInfoBean
|
|
|
|
|
import com.rehome.zhdcoa.bean.UserInfoBean
|
|
|
|
|
import com.rehome.zhdcoa.bean.WhpListItemBean
|
|
|
|
|
import com.rehome.zhdcoa.bean.WhpListItemListBean
|
|
|
|
|
import com.rehome.zhdcoa.databinding.ActivityAddDagerEnterApplyBinding
|
|
|
|
|
import com.rehome.zhdcoa.utils.GsonUtils
|
|
|
|
|
import com.rehome.zhdcoa.utils.HttpListener
|
|
|
|
|
import com.rehome.zhdcoa.utils.HttpUtils
|
|
|
|
|
import com.rehome.zhdcoa.utils.NoProgresshttpUtils
|
|
|
|
|
import com.rehome.zhdcoa.utils.NohttpUtils
|
|
|
|
|
import com.rehome.zhdcoa.weiget.AuditDialog
|
|
|
|
|
import com.rehome.zhdcoa.weiget.DateTimeMinutePickDialog
|
|
|
|
|
import com.yolanda.nohttp.NoHttp
|
|
|
|
|
import com.yolanda.nohttp.RequestMethod
|
|
|
|
|
import com.yolanda.nohttp.rest.Response
|
|
|
|
|
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
|
|
|
|
import okhttp3.RequestBody
|
|
|
|
|
import retrofit2.Call
|
|
|
|
|
@ -36,8 +45,8 @@ class AddDagerEnterApplyActivity :
|
|
|
|
|
private var isEdit = false;
|
|
|
|
|
private var id: String? = null;
|
|
|
|
|
private val whpList: MutableList<WhpListItemBean> = mutableListOf()
|
|
|
|
|
private val whpDeleteList: MutableList<WhpListItemBean> = mutableListOf()
|
|
|
|
|
private val whpChangeList: MutableList<WhpListItemBean> = mutableListOf()
|
|
|
|
|
// private val whpDeleteList: MutableList<WhpListItemBean> = mutableListOf()
|
|
|
|
|
// private val whpChangeList: MutableList<WhpListItemBean> = mutableListOf()
|
|
|
|
|
|
|
|
|
|
private lateinit var adapter: WhpListAdapter
|
|
|
|
|
|
|
|
|
|
@ -56,18 +65,16 @@ class AddDagerEnterApplyActivity :
|
|
|
|
|
launcherResultAddList = createActivityResultLauncherAddList()
|
|
|
|
|
initToolbar("危化品入厂申请", "下一步") {
|
|
|
|
|
if (checkForm()) {
|
|
|
|
|
if(whpDeleteList.size>0){
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
|
|
if (whpList.size > 0) {
|
|
|
|
|
//弹框提示 保存或提交
|
|
|
|
|
} else {
|
|
|
|
|
//危化品清单没有添加,提示添加危化品清单
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// userInfo = App.getInstance().getUserInfo();
|
|
|
|
|
binding.ilNAME.content = userInfo!!.usernames
|
|
|
|
|
|
|
|
|
|
// setAdapter();
|
|
|
|
|
binding.ilAddDagerList.setIbtnSelectIcon()
|
|
|
|
|
binding.ilDCFZBZ.setTvContentOnClickListener {
|
|
|
|
|
//val intent = Intent(context, DeparmentTreeActivity::class.java)
|
|
|
|
|
@ -139,9 +146,12 @@ class AddDagerEnterApplyActivity :
|
|
|
|
|
object : AuditDialog.AuditDialogListener {
|
|
|
|
|
override fun confirm() {
|
|
|
|
|
val item = whpList[position]
|
|
|
|
|
whpDeleteList.add(item)
|
|
|
|
|
whpList.removeAt(position)
|
|
|
|
|
adapter.notifyDataSetChanged()
|
|
|
|
|
if (item.id != null) {
|
|
|
|
|
//调接口,删除一条危化品清单数据
|
|
|
|
|
deleteWhpListByID(item.id)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun cancel() {}
|
|
|
|
|
@ -202,9 +212,16 @@ class AddDagerEnterApplyActivity :
|
|
|
|
|
showLog("$callbackItem1")
|
|
|
|
|
if (item != null) {
|
|
|
|
|
if (item.id == null) {
|
|
|
|
|
if(position==-1){
|
|
|
|
|
//新增
|
|
|
|
|
if (position == -1) {
|
|
|
|
|
//添加一条危化品清单
|
|
|
|
|
whpList.add(item)
|
|
|
|
|
}else{
|
|
|
|
|
if (isEdit) {
|
|
|
|
|
//编辑,新增一条危化品清单
|
|
|
|
|
addWhpListByID(item)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
//更新一条危化品清单
|
|
|
|
|
val itemBean = whpList[position]
|
|
|
|
|
itemBean.hspmc = item.hspmc
|
|
|
|
|
itemBean.wslb = item.wslb
|
|
|
|
|
@ -216,6 +233,7 @@ class AddDagerEnterApplyActivity :
|
|
|
|
|
itemBean.msds = item.msds
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
//编辑
|
|
|
|
|
for (i in whpList.indices) {
|
|
|
|
|
val itemBean = whpList[i]
|
|
|
|
|
if (itemBean.id.equals(item.id)) {
|
|
|
|
|
@ -227,27 +245,10 @@ class AddDagerEnterApplyActivity :
|
|
|
|
|
itemBean.ccdd = item.ccdd
|
|
|
|
|
itemBean.rt = item.rt
|
|
|
|
|
itemBean.msds = item.msds
|
|
|
|
|
if(whpChangeList.size>0){
|
|
|
|
|
var needAddToChange:Boolean = true
|
|
|
|
|
for (j in whpChangeList.indices) {
|
|
|
|
|
val itemChangeBean = whpChangeList[j]
|
|
|
|
|
if (itemChangeBean.id.equals(item.id)) {
|
|
|
|
|
itemChangeBean.hspmc = item.hspmc
|
|
|
|
|
itemChangeBean.wslb = item.wslb
|
|
|
|
|
itemChangeBean.sybm = item.sybm
|
|
|
|
|
itemChangeBean.zrr = item.zrr
|
|
|
|
|
itemChangeBean.srcl = item.srcl
|
|
|
|
|
itemChangeBean.ccdd = item.ccdd
|
|
|
|
|
itemChangeBean.rt = item.rt
|
|
|
|
|
itemChangeBean.msds = item.msds
|
|
|
|
|
needAddToChange = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(needAddToChange){
|
|
|
|
|
whpChangeList.add(itemBean)
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
whpChangeList.add(itemBean)
|
|
|
|
|
//更新危化品一条清单数据
|
|
|
|
|
if (isEdit) {
|
|
|
|
|
//编辑
|
|
|
|
|
changeWhpListByID(itemBean)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -270,7 +271,7 @@ class AddDagerEnterApplyActivity :
|
|
|
|
|
) {
|
|
|
|
|
val bean = response?.body()
|
|
|
|
|
if (bean != null && bean.isFlag) {
|
|
|
|
|
showToast(Gson().toJson(bean))
|
|
|
|
|
//showToast(Gson().toJson(bean))
|
|
|
|
|
if (bean.datas != null && bean.datas.size > 0) {
|
|
|
|
|
val rowsBean: DagerEnterApplyBean.RowsBean = bean.datas[0]
|
|
|
|
|
binding.ilNAME.content = rowsBean.name
|
|
|
|
|
@ -304,7 +305,7 @@ class AddDagerEnterApplyActivity :
|
|
|
|
|
) {
|
|
|
|
|
val bean = response?.body()
|
|
|
|
|
if (bean != null && bean.isFlag) {
|
|
|
|
|
showToast(Gson().toJson(bean))
|
|
|
|
|
showLog(Gson().toJson(bean))
|
|
|
|
|
if (bean.datas != null && bean.datas.size > 0) {
|
|
|
|
|
whpList.addAll(bean.datas)
|
|
|
|
|
adapter.notifyDataSetChanged()
|
|
|
|
|
@ -317,4 +318,80 @@ class AddDagerEnterApplyActivity :
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//删除危化品清单
|
|
|
|
|
private fun deleteWhpListByID(listId: String) {
|
|
|
|
|
val map: MutableMap<String, String> = mutableMapOf()
|
|
|
|
|
map["ID"] = listId
|
|
|
|
|
val url: String = Contans.BASE_URL + Contans.DAGER_ENTER_APPLY_DELETE_ITEM_LIST_URL
|
|
|
|
|
val request = NoHttp.createStringRequest(url, RequestMethod.POST)
|
|
|
|
|
request.setDefineRequestBodyForJson(Gson().toJson(map))
|
|
|
|
|
NoProgresshttpUtils.getInstance().add(0, request, object : HttpListener<String?> {
|
|
|
|
|
override fun onSucceed(what: Int, response: Response<String?>?) {
|
|
|
|
|
val result = response?.get()
|
|
|
|
|
showLog(result)
|
|
|
|
|
val bean: DagerEnterApplyBaseBean? = GsonUtils.GsonToBean(result, DagerEnterApplyBaseBean::class.java)
|
|
|
|
|
if (bean != null && bean.isFlag) {
|
|
|
|
|
adapter.notifyDataSetChanged()
|
|
|
|
|
}else{
|
|
|
|
|
showToast("删除危化品清单失败")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onFailed(what: Int, response: Response<String?>?) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//修改危化品清单
|
|
|
|
|
private fun changeWhpListByID(item: WhpListItemBean) {
|
|
|
|
|
val url: String = Contans.BASE_URL + Contans.DAGER_ENTER_APPLY_CHANGE_ITEM_LIST_URL
|
|
|
|
|
val request = NoHttp.createStringRequest(url, RequestMethod.POST)
|
|
|
|
|
request.setDefineRequestBodyForJson(Gson().toJson(item))
|
|
|
|
|
NoProgresshttpUtils.getInstance().add(0, request, object : HttpListener<String?> {
|
|
|
|
|
override fun onSucceed(what: Int, response: Response<String?>?) {
|
|
|
|
|
val result = response?.get()
|
|
|
|
|
showLog(result)
|
|
|
|
|
val bean: DagerEnterApplyBaseBean? = GsonUtils.GsonToBean(result, DagerEnterApplyBaseBean::class.java)
|
|
|
|
|
if (bean != null && bean.isFlag) {
|
|
|
|
|
adapter.notifyDataSetChanged()
|
|
|
|
|
}else{
|
|
|
|
|
showToast("修改危化品清单失败")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onFailed(what: Int, response: Response<String?>?) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//新增危化品清单
|
|
|
|
|
private fun addWhpListByID(item: WhpListItemBean) {
|
|
|
|
|
val url: String = Contans.BASE_URL + Contans.DAGER_ENTER_APPLY_ADD_ITEM_LIST_URL
|
|
|
|
|
val request = NoHttp.createStringRequest(url, RequestMethod.POST)
|
|
|
|
|
item.mainid = id
|
|
|
|
|
request.setDefineRequestBodyForJson(Gson().toJson(item))
|
|
|
|
|
NoProgresshttpUtils.getInstance().add(0, request, object : HttpListener<String?> {
|
|
|
|
|
override fun onSucceed(what: Int, response: Response<String?>?) {
|
|
|
|
|
val result = response?.get()
|
|
|
|
|
showLog(result)
|
|
|
|
|
val bean: DagerEnterApplyBaseBean? = GsonUtils.GsonToBean(result, DagerEnterApplyBaseBean::class.java)
|
|
|
|
|
if (bean != null && bean.isFlag) {
|
|
|
|
|
showToast("新增危化品清单成功")
|
|
|
|
|
adapter.notifyDataSetChanged()
|
|
|
|
|
}else{
|
|
|
|
|
showToast("新增危化品清单失败")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onFailed(what: Int, response: Response<String?>?) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|