|
|
|
|
@ -3,7 +3,6 @@ package com.rehome.zhdcoa.ui.activity
|
|
|
|
|
import android.content.Intent
|
|
|
|
|
import android.os.Build
|
|
|
|
|
import android.text.TextUtils
|
|
|
|
|
import android.util.Log
|
|
|
|
|
import android.view.View
|
|
|
|
|
import android.widget.AdapterView
|
|
|
|
|
import androidx.activity.result.ActivityResultLauncher
|
|
|
|
|
@ -15,9 +14,7 @@ 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
|
|
|
|
|
@ -28,14 +25,12 @@ 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.rehome.zhdcoa.weiget.SaveOrCommitDialog
|
|
|
|
|
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
|
|
|
|
|
import java.util.Calendar
|
|
|
|
|
import java.util.TreeMap
|
|
|
|
|
|
|
|
|
|
class AddDagerEnterApplyActivity :
|
|
|
|
|
BaseActivityOaToolbarViewBinding<ActivityAddDagerEnterApplyBinding>() {
|
|
|
|
|
@ -65,11 +60,19 @@ class AddDagerEnterApplyActivity :
|
|
|
|
|
launcherResultAddList = createActivityResultLauncherAddList()
|
|
|
|
|
initToolbar("危化品入厂申请", "下一步") {
|
|
|
|
|
if (checkForm()) {
|
|
|
|
|
if (whpList.size > 0) {
|
|
|
|
|
//弹框提示 保存或提交
|
|
|
|
|
} else {
|
|
|
|
|
//危化品清单没有添加,提示添加危化品清单
|
|
|
|
|
val dialog = SaveOrCommitDialog(
|
|
|
|
|
context,
|
|
|
|
|
object : SaveOrCommitDialog.SaveOrCommitDialogListener {
|
|
|
|
|
override fun saveData() {
|
|
|
|
|
saveOrCommitApply(false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun commitData() {
|
|
|
|
|
saveOrCommitApply(true)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
dialog.show()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -111,6 +114,28 @@ class AddDagerEnterApplyActivity :
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//创建一个ActivityResultLauncher,添加一条危化品清单数据
|
|
|
|
|
private fun saveOrCommitApply(isSubmit: Boolean) {
|
|
|
|
|
if (isSubmit) {
|
|
|
|
|
//保存并提交
|
|
|
|
|
if (isEdit) {
|
|
|
|
|
//编辑,新增一条危化品清单
|
|
|
|
|
//addWhpListByID(item)
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
//仅保存
|
|
|
|
|
if (isEdit) {
|
|
|
|
|
//编辑
|
|
|
|
|
updateWhpByFirst()
|
|
|
|
|
} else {
|
|
|
|
|
//新增
|
|
|
|
|
addWhpByFirst()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun checkForm(): Boolean {
|
|
|
|
|
|
|
|
|
|
if (TextUtils.isEmpty(binding.ilSQGYS.content)) {
|
|
|
|
|
@ -330,10 +355,11 @@ class AddDagerEnterApplyActivity :
|
|
|
|
|
override fun onSucceed(what: Int, response: Response<String?>?) {
|
|
|
|
|
val result = response?.get()
|
|
|
|
|
showLog(result)
|
|
|
|
|
val bean: DagerEnterApplyBaseBean? = GsonUtils.GsonToBean(result, DagerEnterApplyBaseBean::class.java)
|
|
|
|
|
val bean: DagerEnterApplyBaseBean? =
|
|
|
|
|
GsonUtils.GsonToBean(result, DagerEnterApplyBaseBean::class.java)
|
|
|
|
|
if (bean != null && bean.isFlag) {
|
|
|
|
|
adapter.notifyDataSetChanged()
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
showToast("删除危化品清单失败")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -354,10 +380,11 @@ class AddDagerEnterApplyActivity :
|
|
|
|
|
override fun onSucceed(what: Int, response: Response<String?>?) {
|
|
|
|
|
val result = response?.get()
|
|
|
|
|
showLog(result)
|
|
|
|
|
val bean: DagerEnterApplyBaseBean? = GsonUtils.GsonToBean(result, DagerEnterApplyBaseBean::class.java)
|
|
|
|
|
val bean: DagerEnterApplyBaseBean? =
|
|
|
|
|
GsonUtils.GsonToBean(result, DagerEnterApplyBaseBean::class.java)
|
|
|
|
|
if (bean != null && bean.isFlag) {
|
|
|
|
|
adapter.notifyDataSetChanged()
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
showToast("修改危化品清单失败")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -379,11 +406,11 @@ class AddDagerEnterApplyActivity :
|
|
|
|
|
override fun onSucceed(what: Int, response: Response<String?>?) {
|
|
|
|
|
val result = response?.get()
|
|
|
|
|
showLog(result)
|
|
|
|
|
val bean: DagerEnterApplyBaseBean? = GsonUtils.GsonToBean(result, DagerEnterApplyBaseBean::class.java)
|
|
|
|
|
val bean: DagerEnterApplyBaseBean? =
|
|
|
|
|
GsonUtils.GsonToBean(result, DagerEnterApplyBaseBean::class.java)
|
|
|
|
|
if (bean != null && bean.isFlag) {
|
|
|
|
|
showToast("新增危化品清单成功")
|
|
|
|
|
adapter.notifyDataSetChanged()
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
showToast("新增危化品清单失败")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -394,4 +421,72 @@ class AddDagerEnterApplyActivity :
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//新增危化品入厂申请
|
|
|
|
|
private fun addWhpByFirst() {
|
|
|
|
|
val url: String = Contans.BASE_URL + Contans.DAGER_ENTER_APPLY_ADD_WHP_URL
|
|
|
|
|
val request = NoHttp.createStringRequest(url, RequestMethod.POST)
|
|
|
|
|
|
|
|
|
|
val map: MutableMap<String, String> = mutableMapOf()
|
|
|
|
|
map["NAME"] = userInfo!!.usernames
|
|
|
|
|
map["SQSJ"] = binding.ilSQSJ.content
|
|
|
|
|
map["SQGYS"] = binding.ilSQGYS.content
|
|
|
|
|
map["XMNAME"] = binding.ilXMNAME.content
|
|
|
|
|
map["DCFZBZ"] = departmentId!!
|
|
|
|
|
map["SQRID"] = userInfo!!.manid
|
|
|
|
|
map["SQRDEPTID"] = userInfo!!.bzbh
|
|
|
|
|
|
|
|
|
|
request.setDefineRequestBodyForJson(Gson().toJson(map))
|
|
|
|
|
NohttpUtils.getInstance().add(this, 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?>?) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}, true, true, "提交数据中...")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//修改危化品入厂申请
|
|
|
|
|
private fun updateWhpByFirst() {
|
|
|
|
|
val url: String = Contans.BASE_URL + Contans.DAGER_ENTER_APPLY_UPDATE_WHP_URL
|
|
|
|
|
val request = NoHttp.createStringRequest(url, RequestMethod.POST)
|
|
|
|
|
|
|
|
|
|
val map: MutableMap<String, String> = mutableMapOf()
|
|
|
|
|
map["ID"] = id!!
|
|
|
|
|
map["SQSJ"] = binding.ilSQSJ.content
|
|
|
|
|
map["SQGYS"] = binding.ilSQGYS.content
|
|
|
|
|
map["XMNAME"] = binding.ilXMNAME.content
|
|
|
|
|
map["DCFZBZ"] = departmentId!!
|
|
|
|
|
|
|
|
|
|
request.setDefineRequestBodyForJson(Gson().toJson(map))
|
|
|
|
|
NohttpUtils.getInstance().add(this, 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?>?) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}, true, true, "提交数据中...")
|
|
|
|
|
}
|
|
|
|
|
}
|