|
|
@@ -6,12 +6,15 @@ import android.view.View
|
|
|
import android.view.inputmethod.EditorInfo
|
|
|
import android.widget.EditText
|
|
|
import cn.muchinfo.rma.R
|
|
|
+import cn.muchinfo.rma.global.GlobalDataCollection
|
|
|
import cn.muchinfo.rma.global.data.PermancePlanTmpData
|
|
|
import cn.muchinfo.rma.global.data.WrGoodsPerformanceStepData
|
|
|
import cn.muchinfo.rma.lifecycle.bindOptional
|
|
|
+import cn.muchinfo.rma.protobuf.protoclasses.ManageServiceMI3
|
|
|
import cn.muchinfo.rma.view.autoWidget.*
|
|
|
import cn.muchinfo.rma.view.base.BaseActivity
|
|
|
import cn.muchinfo.rma.view.base.future.trade.itemView
|
|
|
+import com.blankj.utilcode.util.ToastUtils
|
|
|
import mtp.polymer.com.autowidget.adapter.BaseAdapter
|
|
|
import mtp.polymer.com.autowidget.dialog.createLoadingDialog
|
|
|
import mtp.polymer.com.autowidget.utils.bindTaskStatus
|
|
|
@@ -27,6 +30,9 @@ class AddPerformanceTempateActivity : BaseActivity<PerformanceTemplateViewModel>
|
|
|
*/
|
|
|
val type by lazy { intent.getStringExtra("type") }
|
|
|
|
|
|
+
|
|
|
+ val data by lazy { intent.getParcelableExtra<PermancePlanTmpData>("data") as PermancePlanTmpData }
|
|
|
+
|
|
|
// 下拉刷新
|
|
|
private lateinit var swipeToLayout: SwipeToLoadLayout
|
|
|
private lateinit var statusLayout: StatusLayout
|
|
|
@@ -48,11 +54,13 @@ class AddPerformanceTempateActivity : BaseActivity<PerformanceTemplateViewModel>
|
|
|
fun initializeData(){
|
|
|
if (type == "1"){
|
|
|
val newDataList = arrayListOf<WrGoodsPerformanceStepData>()
|
|
|
- newDataList.add(WrGoodsPerformanceStepData(autoid = 1))
|
|
|
+ newDataList.add(WrGoodsPerformanceStepData(stepindex = "1"))
|
|
|
viewModel.wrGoodsPerformanceStepDataList.postValue(newDataList)
|
|
|
viewModel.wrGoodsPerformanceStepCashDataList.postValue(newDataList)
|
|
|
}else{
|
|
|
-
|
|
|
+ val newDataList = data.lstStep
|
|
|
+ viewModel.wrGoodsPerformanceStepDataList.postValue(newDataList)
|
|
|
+ viewModel.wrGoodsPerformanceStepCashDataList.postValue(newDataList)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -73,118 +81,196 @@ class AddPerformanceTempateActivity : BaseActivity<PerformanceTemplateViewModel>
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- linearLayout {
|
|
|
- background = resources.getDrawable(R.color.white)
|
|
|
- gravity = Gravity.CENTER_VERTICAL
|
|
|
-
|
|
|
- textView {
|
|
|
- visibility = View.INVISIBLE
|
|
|
- text = "*"
|
|
|
- textColorInt = R.color.rma_star_color
|
|
|
- textSizeAuto = 31
|
|
|
- }.lparams(wrapContent, wrapContent) {
|
|
|
- marginStart = autoSize(37)
|
|
|
- }
|
|
|
- textView {
|
|
|
- text = "模版名称"
|
|
|
- textSizeAuto = 31
|
|
|
- textColorInt = R.color.rma_black_33
|
|
|
- }.lparams(wrapContent, wrapContent) {
|
|
|
- marginStart = autoSize(10)
|
|
|
- }
|
|
|
+ frameLayout {
|
|
|
+ scrollView {
|
|
|
+ verticalLayout {
|
|
|
+ linearLayout {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
|
|
|
- editText {
|
|
|
- performance_name = this
|
|
|
- hint = "请输入模版名称"
|
|
|
- background = null
|
|
|
- inputType = EditorInfo.TYPE_CLASS_TEXT
|
|
|
- hintColorStr = "#CCCCCC"
|
|
|
- textSizeAuto = 31
|
|
|
- textColorStr = "#333333"
|
|
|
- }.lparams(0, autoSize(132), 1f) {
|
|
|
- marginStart = autoSize(80)
|
|
|
- }
|
|
|
- }.lparams(matchParent, autoSize(132))
|
|
|
+ textView {
|
|
|
+ visibility = View.INVISIBLE
|
|
|
+ text = "*"
|
|
|
+ textColorInt = R.color.rma_star_color
|
|
|
+ textSizeAuto = 31
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(37)
|
|
|
+ }
|
|
|
+ textView {
|
|
|
+ text = "模版名称"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(10)
|
|
|
+ }
|
|
|
|
|
|
- itemView()
|
|
|
+ editText {
|
|
|
+ performance_name = this
|
|
|
+ hint = "请输入模版名称"
|
|
|
+ background = null
|
|
|
+ inputType = EditorInfo.TYPE_CLASS_TEXT
|
|
|
+ hintColorStr = "#CCCCCC"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorStr = "#333333"
|
|
|
+ }.lparams(0, autoSize(132), 1f) {
|
|
|
+ marginStart = autoSize(80)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(132))
|
|
|
|
|
|
- linearLayout {
|
|
|
- background = resources.getDrawable(R.color.white)
|
|
|
- gravity = Gravity.CENTER_VERTICAL
|
|
|
- linearLayout {
|
|
|
- gravity = Gravity.CENTER
|
|
|
- textView {
|
|
|
- text = "步骤类型"
|
|
|
- textSizeAuto = 32
|
|
|
- textColorInt = R.color.rma_black_33
|
|
|
- }.lparams(wrapContent, wrapContent)
|
|
|
- }.lparams(0, autoSize(80),1.5f)
|
|
|
+ itemView()
|
|
|
|
|
|
- linearLayout {
|
|
|
- gravity = Gravity.CENTER
|
|
|
- textView {
|
|
|
- text = "步骤值(%)"
|
|
|
- textSizeAuto = 32
|
|
|
- textColorInt = R.color.rma_black_33
|
|
|
- }.lparams(wrapContent, wrapContent)
|
|
|
- }.lparams(0, autoSize(80),1f)
|
|
|
+ linearLayout {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER
|
|
|
+ textView {
|
|
|
+ text = "步骤类型"
|
|
|
+ textSizeAuto = 32
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }.lparams(wrapContent, wrapContent)
|
|
|
+ }.lparams(0, autoSize(80),1.5f)
|
|
|
|
|
|
- linearLayout {
|
|
|
- gravity = Gravity.CENTER
|
|
|
- textView {
|
|
|
- text = "距离上一步天数"
|
|
|
- textSizeAuto = 32
|
|
|
- textColorInt = R.color.rma_black_33
|
|
|
- }.lparams(wrapContent, wrapContent)
|
|
|
- }.lparams(0, autoSize(80),1.5f)
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER
|
|
|
+ textView {
|
|
|
+ text = "步骤值(%)"
|
|
|
+ textSizeAuto = 32
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }.lparams(wrapContent, wrapContent)
|
|
|
+ }.lparams(0, autoSize(80),1f)
|
|
|
|
|
|
- linearLayout {
|
|
|
- gravity = Gravity.CENTER
|
|
|
- textView {
|
|
|
- text = "操作"
|
|
|
- textSizeAuto = 32
|
|
|
- textColorInt = R.color.rma_black_33
|
|
|
- }.lparams(wrapContent, wrapContent)
|
|
|
- }.lparams(0, autoSize(80),1f)
|
|
|
- }.lparams(matchParent, autoSize(80))
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER
|
|
|
+ textView {
|
|
|
+ text = "距离上一步天数"
|
|
|
+ textSizeAuto = 32
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }.lparams(wrapContent, wrapContent)
|
|
|
+ }.lparams(0, autoSize(80),1.5f)
|
|
|
|
|
|
- statusLayout(contentBlock = {
|
|
|
- statusLayout = this
|
|
|
- setRetryAction {
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER
|
|
|
+ textView {
|
|
|
+ text = "操作"
|
|
|
+ textSizeAuto = 32
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }.lparams(wrapContent, wrapContent)
|
|
|
+ }.lparams(0, autoSize(80),1f)
|
|
|
+ }.lparams(matchParent, autoSize(80))
|
|
|
|
|
|
- }
|
|
|
- swipeToLoadLayout {
|
|
|
- swipeToLayout = this
|
|
|
- setEnableRefresh(false)
|
|
|
- setEnableLoadMore(false)
|
|
|
- setOnRefreshListener {
|
|
|
+ statusLayout(contentBlock = {
|
|
|
+ statusLayout = this
|
|
|
+ setRetryAction {
|
|
|
+
|
|
|
+ }
|
|
|
+ swipeToLoadLayout {
|
|
|
+ swipeToLayout = this
|
|
|
+ setEnableRefresh(false)
|
|
|
+ setEnableLoadMore(false)
|
|
|
+ setOnRefreshListener {
|
|
|
|
|
|
+ }
|
|
|
+ setEnableScrollContentWhenLoaded(false)
|
|
|
+ setEnableLoadMoreWhenContentNotFull(false)
|
|
|
+ // 未提交列表
|
|
|
+ recyclerView {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ adapter = addPerformanceAdapter
|
|
|
+ }.lparams(matchParent, matchParent)
|
|
|
+ }
|
|
|
+ }, emptyBlock = {
|
|
|
+ emptyView(hint = resources.getString(R.string.now_no_data))
|
|
|
+ }).lparams(matchParent, matchParent)
|
|
|
+
|
|
|
+ viewModel.wrGoodsPerformanceStepDataList.bindOptional(context) {
|
|
|
+ if (it?.isEmpty() == true || it?.size == 0) {
|
|
|
+ statusLayout.showEmpty()
|
|
|
+ } else {
|
|
|
+ if (swipeToLayout.getIsRefreshing()) {
|
|
|
+ swipeToLayout.finishRefresh()
|
|
|
+ }
|
|
|
+ statusLayout.showSuccess()
|
|
|
+ addPerformanceAdapter.setNewData(it)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- setEnableScrollContentWhenLoaded(false)
|
|
|
- setEnableLoadMoreWhenContentNotFull(false)
|
|
|
- // 未提交列表
|
|
|
- recyclerView {
|
|
|
- background = resources.getDrawable(R.color.white)
|
|
|
- adapter = addPerformanceAdapter
|
|
|
- }.lparams(matchParent, matchParent)
|
|
|
}
|
|
|
- }, emptyBlock = {
|
|
|
- emptyView(hint = resources.getString(R.string.now_no_data))
|
|
|
- }).lparams(matchParent, matchParent)
|
|
|
-
|
|
|
- viewModel.wrGoodsPerformanceStepDataList.bindOptional(context) {
|
|
|
- if (it?.isEmpty() == true || it?.size == 0) {
|
|
|
- statusLayout.showEmpty()
|
|
|
- } else {
|
|
|
- if (swipeToLayout.getIsRefreshing()) {
|
|
|
- swipeToLayout.finishRefresh()
|
|
|
+ linearLayout {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+
|
|
|
+ if (type == "4") {
|
|
|
+ visibility = View.GONE
|
|
|
+ } else {
|
|
|
+ visibility = View.VISIBLE
|
|
|
}
|
|
|
- statusLayout.showSuccess()
|
|
|
- addPerformanceAdapter.setNewData(it)
|
|
|
+ textView {
|
|
|
+ onThrottleFirstClick {
|
|
|
+
|
|
|
+ if (performance_name.text.toString().isNullOrEmpty()){
|
|
|
+ ToastUtils.showLong("请输入履约模版名称")
|
|
|
+ return@onThrottleFirstClick
|
|
|
+ }
|
|
|
+
|
|
|
+ if (check().not()){
|
|
|
+ ToastUtils.showLong("请输入完成步骤信息")
|
|
|
+ return@onThrottleFirstClick
|
|
|
+ }
|
|
|
+ viewModel.performancePlanTemplateReq(templatename = performance_name.text.toString(),performancesteps = getTemplateInfo(),userid = GlobalDataCollection.instance?.loginRsp?.userID?.toLong() ?: 0){
|
|
|
+ finish()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ gravity = Gravity.CENTER
|
|
|
+ backgroundResource = R.mipmap.rma_submit_bg
|
|
|
+ text = "提交"
|
|
|
+ textColorInt = R.color.white
|
|
|
+ textSizeAuto = 38
|
|
|
+ }.lparams(matchParent, autoSize(119)) {
|
|
|
+ marginStart = autoSize(59)
|
|
|
+ marginEnd = autoSize(59)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(144)) {
|
|
|
+ gravity = Gravity.BOTTOM
|
|
|
}
|
|
|
+ }.lparams(matchParent, matchParent)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ fun getTemplateInfo() : List<ManageServiceMI3.EPerformanceStepTemplateInfo>{
|
|
|
+ val tempateInfoList = arrayListOf<ManageServiceMI3.EPerformanceStepTemplateInfo>()
|
|
|
+ viewModel.wrGoodsPerformanceStepCashDataList.value?.forEach {
|
|
|
+ val tempateInfo = ManageServiceMI3.EPerformanceStepTemplateInfo.newBuilder()
|
|
|
+ tempateInfo.steptypeid = it.steptypeid?.toInt() ?: 0
|
|
|
+ tempateInfo.stepindex = it.stepindex?.toInt() ?: 0
|
|
|
+ if (it.stepvalue.isNullOrEmpty().not()){
|
|
|
+ tempateInfo.stepvalue = it.stepvalue?.toDouble() ?: 0.0
|
|
|
}
|
|
|
+ tempateInfo.isauto = 2
|
|
|
+ tempateInfo.stepdays = it.stepdays?.toInt() ?: 0
|
|
|
+ tempateInfoList.add(tempateInfo.build())
|
|
|
+ }
|
|
|
+ return tempateInfoList
|
|
|
+ }
|
|
|
|
|
|
+
|
|
|
+ fun check() : Boolean{
|
|
|
+ var returnBooble = false
|
|
|
+ val cashDataList = viewModel.wrGoodsPerformanceStepCashDataList.value
|
|
|
+ cashDataList?.forEach {
|
|
|
+ if (it.steptypeid.isNullOrEmpty()){
|
|
|
+ returnBooble = false
|
|
|
+ }else{
|
|
|
+ if (it.steptypeid == "1" || it.steptypeid == "2"){
|
|
|
+ returnBooble = !(it.stepdays.isNullOrEmpty() || it.stepvalue.isNullOrEmpty())
|
|
|
+ }else{
|
|
|
+ returnBooble = !it.stepdays.isNullOrEmpty()
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ return returnBooble
|
|
|
}
|
|
|
|
|
|
}
|