diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/activity/AddDagerEnterApplyActivity.kt b/app/src/main/java/com/rehome/zhdcoa/ui/activity/AddDagerEnterApplyActivity.kt index 48d099c..7be3291 100644 --- a/app/src/main/java/com/rehome/zhdcoa/ui/activity/AddDagerEnterApplyActivity.kt +++ b/app/src/main/java/com/rehome/zhdcoa/ui/activity/AddDagerEnterApplyActivity.kt @@ -20,6 +20,7 @@ import com.rehome.zhdcoa.bean.WhpListItemBean import com.rehome.zhdcoa.bean.WhpListItemListBean import com.rehome.zhdcoa.databinding.ActivityAddDagerEnterApplyBinding import com.rehome.zhdcoa.utils.HttpUtils +import com.rehome.zhdcoa.weiget.AuditDialog import com.rehome.zhdcoa.weiget.DateTimeMinutePickDialog import okhttp3.MediaType.Companion.toMediaTypeOrNull import okhttp3.RequestBody @@ -36,15 +37,16 @@ class AddDagerEnterApplyActivity : private var id: String? = null; private val whpList: MutableList = mutableListOf() private val whpDeleteList: MutableList = mutableListOf() + private val whpChangeList: MutableList = mutableListOf() private lateinit var adapter: WhpListAdapter private val userInfos: ArrayList = ArrayList() - override fun getViewBinding() = ActivityAddDagerEnterApplyBinding.inflate(layoutInflater) - private lateinit var launcherResult: ActivityResultLauncher private lateinit var launcherResultAddList: ActivityResultLauncher + + override fun getViewBinding() = ActivityAddDagerEnterApplyBinding.inflate(layoutInflater) override fun getToolbar() = binding.toolbarView.toolbar override fun initView() { @@ -53,25 +55,31 @@ class AddDagerEnterApplyActivity : launcherResult = createActivityResultLauncher() launcherResultAddList = createActivityResultLauncherAddList() initToolbar("危化品入厂申请", "下一步") { + if (checkForm()) { + if(whpDeleteList.size>0){ + + }else{ + } + } } // userInfo = App.getInstance().getUserInfo(); - binding.ilDinnerApply.content = userInfo!!.usernames + binding.ilNAME.content = userInfo!!.usernames // setAdapter(); binding.ilAddDagerList.setIbtnSelectIcon() - binding.ilDinnerUnit.setTvContentOnClickListener { + binding.ilDCFZBZ.setTvContentOnClickListener { //val intent = Intent(context, DeparmentTreeActivity::class.java) val intent = Intent(context, PartDeparmentTreeActivity::class.java) launcherResult.launch(intent) } - binding.ilStartTime.setTvContentOnClickListener { + binding.ilSQSJ.setTvContentOnClickListener { val calendar = Calendar.getInstance() val dialog = DateTimeMinutePickDialog( context, calendar, true ) { outPutDate: String?, outPutDate1: String?, outPutDate2: String? -> - binding.ilStartTime.content = outPutDate + binding.ilSQSJ.content = outPutDate } dialog.show() } @@ -83,7 +91,8 @@ class AddDagerEnterApplyActivity : this, AddDagerEnterApplyListActivity::class.java ) - //intent.putExtra("item", Contans.MODUETYPE.KQ_LEVEKIND) + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP) + intent.putExtra("position", -1) launcherResultAddList.launch(intent) }) } @@ -95,14 +104,49 @@ class AddDagerEnterApplyActivity : } } + private fun checkForm(): Boolean { + + if (TextUtils.isEmpty(binding.ilSQGYS.content)) { + showToast("申请公司名称必填") + return false + } + if (TextUtils.isEmpty(binding.ilXMNAME.content)) { + showToast("工程项目名称必填") + return false + } + if (TextUtils.isEmpty(binding.ilSQSJ.content)) { + showToast("申请入厂时间必填") + return false + } + if (TextUtils.isEmpty(binding.ilDCFZBZ.content)) { + showToast("责任分部必填") + return false + } + if (whpList.size <= 0) { + showToast("请添加危化品清单") + return false + } + return true + } + private fun setAdapter() { adapter = WhpListAdapter(context, whpList, object : WhpListAdapter.CallBack { override fun deleteClick(position: Int) { -// val intent = Intent(context, AddDagerEnterApplyActivity::class.java) -// intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP) -// intent.putExtra("isEdit",true) -// intent.putExtra("id",item.id) -// startActivity(intent) + val dialog = + AuditDialog( + context, + "确定要删除当前这条危化品清单吗?", + object : AuditDialog.AuditDialogListener { + override fun confirm() { + val item = whpList[position] + whpDeleteList.add(item) + whpList.removeAt(position) + adapter.notifyDataSetChanged() + } + + override fun cancel() {} + }) + dialog.show() } }) @@ -114,6 +158,7 @@ class AddDagerEnterApplyActivity : val intent = Intent(context, AddDagerEnterApplyListActivity::class.java) intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP) intent.putExtra("item", item) + intent.putExtra("position", position) launcherResultAddList.launch(intent) } } @@ -128,7 +173,7 @@ class AddDagerEnterApplyActivity : if (data != null) { departmentId = data.getStringExtra("departmentId") departmentName = data.getStringExtra("departmentName") - binding.ilDinnerUnit.content = departmentName + binding.ilDCFZBZ.content = departmentName } } } @@ -145,6 +190,7 @@ class AddDagerEnterApplyActivity : showLog("---------------------") showLog("$callbackItem") if (data != null) { + val position: Int = data.getIntExtra("position", -1) val item: WhpListItemBean? = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { data.getParcelableExtra("item", WhpListItemBean::class.java) @@ -152,15 +198,27 @@ class AddDagerEnterApplyActivity : data.getParcelableExtra("item") } - val callbackItem1 =item != null + val callbackItem1 = item != null showLog("$callbackItem1") if (item != null) { if (item.id == null) { - whpList.add(item) + if(position==-1){ + whpList.add(item) + }else{ + val itemBean = whpList[position] + itemBean.hspmc = item.hspmc + itemBean.wslb = item.wslb + itemBean.sybm = item.sybm + itemBean.zrr = item.zrr + itemBean.srcl = item.srcl + itemBean.ccdd = item.ccdd + itemBean.rt = item.rt + itemBean.msds = item.msds + } } else { - for (i in whpList.indices){ + for (i in whpList.indices) { val itemBean = whpList[i] - if(itemBean.id.equals(item.id)){ + if (itemBean.id.equals(item.id)) { itemBean.hspmc = item.hspmc itemBean.wslb = item.wslb itemBean.sybm = item.sybm @@ -169,6 +227,28 @@ 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) + } } } } @@ -193,11 +273,11 @@ class AddDagerEnterApplyActivity : showToast(Gson().toJson(bean)) if (bean.datas != null && bean.datas.size > 0) { val rowsBean: DagerEnterApplyBean.RowsBean = bean.datas[0] - binding.ilDinnerApply.content = rowsBean.name - binding.ilTravelAddress.content = rowsBean.sqgys - binding.ilTravelsRemark.content = rowsBean.xmname - binding.ilStartTime.content = rowsBean.sqsj - binding.ilDinnerUnit.content = rowsBean.dcfzbzname + binding.ilNAME.content = rowsBean.name + binding.ilSQGYS.content = rowsBean.sqgys + binding.ilXMNAME.content = rowsBean.xmname + binding.ilSQSJ.content = rowsBean.sqsj + binding.ilDCFZBZ.content = rowsBean.dcfzbzname departmentId = rowsBean.dcfzbz departmentName = rowsBean.dcfzbzname id = rowsBean.id diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/activity/AddDagerEnterApplyListActivity.kt b/app/src/main/java/com/rehome/zhdcoa/ui/activity/AddDagerEnterApplyListActivity.kt index 60ef73b..9e69a03 100644 --- a/app/src/main/java/com/rehome/zhdcoa/ui/activity/AddDagerEnterApplyListActivity.kt +++ b/app/src/main/java/com/rehome/zhdcoa/ui/activity/AddDagerEnterApplyListActivity.kt @@ -12,6 +12,7 @@ class AddDagerEnterApplyListActivity : BaseActivityOaToolbarViewBinding() { private var itemSource: WhpListItemBean? = null + private var position = -1; override fun getViewBinding() = ActivityAddDagerEnterApplyListBinding.inflate(layoutInflater) @@ -35,6 +36,7 @@ class AddDagerEnterApplyListActivity : //处理回填 val intent = Intent() intent.putExtra("item", item) + intent.putExtra("position", position) setResult(RESULT_OK, intent) finish() } @@ -44,6 +46,7 @@ class AddDagerEnterApplyListActivity : } else { intent.getParcelableExtra("item") } + position = intent.getIntExtra("position", -1) } override fun initData() { @@ -52,10 +55,10 @@ class AddDagerEnterApplyListActivity : binding.ilWSLB.content = itemSource!!.wslb binding.ilSYBM.content = itemSource!!.sybm binding.ilZRR.content = itemSource!!.zrr - binding.ilSRCL.content= itemSource!!.srcl - binding.ilCCDD.content= itemSource!!.ccdd - binding.ilRT.content= itemSource!!.rt - binding.ilMSDS.content= itemSource!!.msds + binding.ilSRCL.content = itemSource!!.srcl + binding.ilCCDD.content = itemSource!!.ccdd + binding.ilRT.content = itemSource!!.rt + binding.ilMSDS.content = itemSource!!.msds } } diff --git a/app/src/main/res/layout/activity_add_dager_enter_apply.xml b/app/src/main/res/layout/activity_add_dager_enter_apply.xml index 8c62b88..fce6356 100644 --- a/app/src/main/res/layout/activity_add_dager_enter_apply.xml +++ b/app/src/main/res/layout/activity_add_dager_enter_apply.xml @@ -24,27 +24,27 @@ android:orientation="vertical"> + app:tv_title="申请公司名称" />