master
hwf452 2 years ago
parent 9f9f9b66ce
commit 0174a6cb3b

@ -20,6 +20,7 @@ import com.rehome.zhdcoa.bean.WhpListItemBean
import com.rehome.zhdcoa.bean.WhpListItemListBean import com.rehome.zhdcoa.bean.WhpListItemListBean
import com.rehome.zhdcoa.databinding.ActivityAddDagerEnterApplyBinding import com.rehome.zhdcoa.databinding.ActivityAddDagerEnterApplyBinding
import com.rehome.zhdcoa.utils.HttpUtils import com.rehome.zhdcoa.utils.HttpUtils
import com.rehome.zhdcoa.weiget.AuditDialog
import com.rehome.zhdcoa.weiget.DateTimeMinutePickDialog import com.rehome.zhdcoa.weiget.DateTimeMinutePickDialog
import okhttp3.MediaType.Companion.toMediaTypeOrNull import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody import okhttp3.RequestBody
@ -36,15 +37,16 @@ class AddDagerEnterApplyActivity :
private var id: String? = null; private var id: String? = null;
private val whpList: MutableList<WhpListItemBean> = mutableListOf() private val whpList: MutableList<WhpListItemBean> = mutableListOf()
private val whpDeleteList: MutableList<WhpListItemBean> = mutableListOf() private val whpDeleteList: MutableList<WhpListItemBean> = mutableListOf()
private val whpChangeList: MutableList<WhpListItemBean> = mutableListOf()
private lateinit var adapter: WhpListAdapter private lateinit var adapter: WhpListAdapter
private val userInfos: ArrayList<StaffInfoBean.StaffInfo> = ArrayList() private val userInfos: ArrayList<StaffInfoBean.StaffInfo> = ArrayList()
override fun getViewBinding() = ActivityAddDagerEnterApplyBinding.inflate(layoutInflater)
private lateinit var launcherResult: ActivityResultLauncher<Intent> private lateinit var launcherResult: ActivityResultLauncher<Intent>
private lateinit var launcherResultAddList: ActivityResultLauncher<Intent> private lateinit var launcherResultAddList: ActivityResultLauncher<Intent>
override fun getViewBinding() = ActivityAddDagerEnterApplyBinding.inflate(layoutInflater)
override fun getToolbar() = binding.toolbarView.toolbar override fun getToolbar() = binding.toolbarView.toolbar
override fun initView() { override fun initView() {
@ -53,25 +55,31 @@ class AddDagerEnterApplyActivity :
launcherResult = createActivityResultLauncher() launcherResult = createActivityResultLauncher()
launcherResultAddList = createActivityResultLauncherAddList() launcherResultAddList = createActivityResultLauncherAddList()
initToolbar("危化品入厂申请", "下一步") { initToolbar("危化品入厂申请", "下一步") {
if (checkForm()) {
if(whpDeleteList.size>0){
}else{
}
}
} }
// userInfo = App.getInstance().getUserInfo(); // userInfo = App.getInstance().getUserInfo();
binding.ilDinnerApply.content = userInfo!!.usernames binding.ilNAME.content = userInfo!!.usernames
// setAdapter(); // setAdapter();
binding.ilAddDagerList.setIbtnSelectIcon() binding.ilAddDagerList.setIbtnSelectIcon()
binding.ilDinnerUnit.setTvContentOnClickListener { binding.ilDCFZBZ.setTvContentOnClickListener {
//val intent = Intent(context, DeparmentTreeActivity::class.java) //val intent = Intent(context, DeparmentTreeActivity::class.java)
val intent = Intent(context, PartDeparmentTreeActivity::class.java) val intent = Intent(context, PartDeparmentTreeActivity::class.java)
launcherResult.launch(intent) launcherResult.launch(intent)
} }
binding.ilStartTime.setTvContentOnClickListener { binding.ilSQSJ.setTvContentOnClickListener {
val calendar = Calendar.getInstance() val calendar = Calendar.getInstance()
val dialog = DateTimeMinutePickDialog( val dialog = DateTimeMinutePickDialog(
context, calendar, true context, calendar, true
) { outPutDate: String?, outPutDate1: String?, outPutDate2: String? -> ) { outPutDate: String?, outPutDate1: String?, outPutDate2: String? ->
binding.ilStartTime.content = outPutDate binding.ilSQSJ.content = outPutDate
} }
dialog.show() dialog.show()
} }
@ -83,7 +91,8 @@ class AddDagerEnterApplyActivity :
this, this,
AddDagerEnterApplyListActivity::class.java 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) 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() { private fun setAdapter() {
adapter = WhpListAdapter(context, whpList, object : WhpListAdapter.CallBack { adapter = WhpListAdapter(context, whpList, object : WhpListAdapter.CallBack {
override fun deleteClick(position: Int) { override fun deleteClick(position: Int) {
// val intent = Intent(context, AddDagerEnterApplyActivity::class.java) val dialog =
// intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP) AuditDialog(
// intent.putExtra("isEdit",true) context,
// intent.putExtra("id",item.id) "确定要删除当前这条危化品清单吗?",
// startActivity(intent) 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) val intent = Intent(context, AddDagerEnterApplyListActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP) intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
intent.putExtra("item", item) intent.putExtra("item", item)
intent.putExtra("position", position)
launcherResultAddList.launch(intent) launcherResultAddList.launch(intent)
} }
} }
@ -128,7 +173,7 @@ class AddDagerEnterApplyActivity :
if (data != null) { if (data != null) {
departmentId = data.getStringExtra("departmentId") departmentId = data.getStringExtra("departmentId")
departmentName = data.getStringExtra("departmentName") departmentName = data.getStringExtra("departmentName")
binding.ilDinnerUnit.content = departmentName binding.ilDCFZBZ.content = departmentName
} }
} }
} }
@ -145,6 +190,7 @@ class AddDagerEnterApplyActivity :
showLog("---------------------") showLog("---------------------")
showLog("$callbackItem") showLog("$callbackItem")
if (data != null) { if (data != null) {
val position: Int = data.getIntExtra("position", -1)
val item: WhpListItemBean? = val item: WhpListItemBean? =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
data.getParcelableExtra("item", WhpListItemBean::class.java) data.getParcelableExtra("item", WhpListItemBean::class.java)
@ -156,7 +202,19 @@ class AddDagerEnterApplyActivity :
showLog("$callbackItem1") showLog("$callbackItem1")
if (item != null) { if (item != null) {
if (item.id == null) { if (item.id == null) {
if(position==-1){
whpList.add(item) 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 { } else {
for (i in whpList.indices) { for (i in whpList.indices) {
val itemBean = whpList[i] val itemBean = whpList[i]
@ -169,6 +227,28 @@ class AddDagerEnterApplyActivity :
itemBean.ccdd = item.ccdd itemBean.ccdd = item.ccdd
itemBean.rt = item.rt itemBean.rt = item.rt
itemBean.msds = item.msds 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)) showToast(Gson().toJson(bean))
if (bean.datas != null && bean.datas.size > 0) { if (bean.datas != null && bean.datas.size > 0) {
val rowsBean: DagerEnterApplyBean.RowsBean = bean.datas[0] val rowsBean: DagerEnterApplyBean.RowsBean = bean.datas[0]
binding.ilDinnerApply.content = rowsBean.name binding.ilNAME.content = rowsBean.name
binding.ilTravelAddress.content = rowsBean.sqgys binding.ilSQGYS.content = rowsBean.sqgys
binding.ilTravelsRemark.content = rowsBean.xmname binding.ilXMNAME.content = rowsBean.xmname
binding.ilStartTime.content = rowsBean.sqsj binding.ilSQSJ.content = rowsBean.sqsj
binding.ilDinnerUnit.content = rowsBean.dcfzbzname binding.ilDCFZBZ.content = rowsBean.dcfzbzname
departmentId = rowsBean.dcfzbz departmentId = rowsBean.dcfzbz
departmentName = rowsBean.dcfzbzname departmentName = rowsBean.dcfzbzname
id = rowsBean.id id = rowsBean.id

@ -12,6 +12,7 @@ class AddDagerEnterApplyListActivity :
BaseActivityOaToolbarViewBinding<ActivityAddDagerEnterApplyListBinding>() { BaseActivityOaToolbarViewBinding<ActivityAddDagerEnterApplyListBinding>() {
private var itemSource: WhpListItemBean? = null private var itemSource: WhpListItemBean? = null
private var position = -1;
override fun getViewBinding() = ActivityAddDagerEnterApplyListBinding.inflate(layoutInflater) override fun getViewBinding() = ActivityAddDagerEnterApplyListBinding.inflate(layoutInflater)
@ -35,6 +36,7 @@ class AddDagerEnterApplyListActivity :
//处理回填 //处理回填
val intent = Intent() val intent = Intent()
intent.putExtra("item", item) intent.putExtra("item", item)
intent.putExtra("position", position)
setResult(RESULT_OK, intent) setResult(RESULT_OK, intent)
finish() finish()
} }
@ -44,6 +46,7 @@ class AddDagerEnterApplyListActivity :
} else { } else {
intent.getParcelableExtra("item") intent.getParcelableExtra("item")
} }
position = intent.getIntExtra("position", -1)
} }
override fun initData() { override fun initData() {

@ -24,27 +24,27 @@
android:orientation="vertical"> android:orientation="vertical">
<com.rehome.zhdcoa.weiget.InputLayout <com.rehome.zhdcoa.weiget.InputLayout
android:id="@+id/il_DinnerApply" android:id="@+id/il_NAME"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:isShowTextView="true" app:isShowTextView="true"
app:must="true" app:must="true"
app:tv_title="申请人"/> app:tv_title="申请人"/>
<com.rehome.zhdcoa.weiget.InputLayout <com.rehome.zhdcoa.weiget.InputLayout
android:id="@+id/il_TravelAddress" android:id="@+id/il_SQGYS"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:must="true" app:must="true"
app:tv_title="公司名称" /> app:tv_title="申请公司名称" />
<com.rehome.zhdcoa.weiget.InputLayout <com.rehome.zhdcoa.weiget.InputLayout
android:id="@+id/il_TravelsRemark" android:id="@+id/il_XMNAME"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:must="true" app:must="true"
app:tv_title="工程项目名称" /> app:tv_title="工程项目名称" />
<com.rehome.zhdcoa.weiget.InputLayout <com.rehome.zhdcoa.weiget.InputLayout
android:id="@+id/il_startTime" android:id="@+id/il_SQSJ"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:visibility="visible" android:visibility="visible"
@ -54,7 +54,7 @@
app:tv_title="申请入厂时间" /> app:tv_title="申请入厂时间" />
<com.rehome.zhdcoa.weiget.InputLayout <com.rehome.zhdcoa.weiget.InputLayout
app:must="true" app:must="true"
android:id="@+id/il_DinnerUnit" android:id="@+id/il_DCFZBZ"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:hintText="点击选择责任分部" app:hintText="点击选择责任分部"

Loading…
Cancel
Save