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.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<WhpListItemBean> = mutableListOf()
private val whpDeleteList: MutableList<WhpListItemBean> = mutableListOf()
private val whpChangeList: MutableList<WhpListItemBean> = mutableListOf()
private lateinit var adapter: WhpListAdapter
private val userInfos: ArrayList<StaffInfoBean.StaffInfo> = ArrayList()
override fun getViewBinding() = ActivityAddDagerEnterApplyBinding.inflate(layoutInflater)
private lateinit var launcherResult: ActivityResultLauncher<Intent>
private lateinit var launcherResultAddList: ActivityResultLauncher<Intent>
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) {
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

@ -12,6 +12,7 @@ class AddDagerEnterApplyListActivity :
BaseActivityOaToolbarViewBinding<ActivityAddDagerEnterApplyListBinding>() {
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
}
}

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

Loading…
Cancel
Save