Przeglądaj źródła

风险管理9月20日提交代码-liu.bolan-天津掉期

Liu.bolan 4 lat temu
rodzic
commit
b5fa0a1678

+ 2 - 0
RMA/app/src/main/AndroidManifest.xml

@@ -471,6 +471,8 @@
         <activity android:name=".view.base.hnstmain.contractorders.unwind.AgreementUnwindActivity"/>
 
         <activity android:name=".view.base.home.spotaudit.SpotAuditActivity"/>
+
+        <activity android:name=".view.base.home.commodity.newspot.NewAddSpotGoodsActivity"/>
     </application>
 
 </manifest>

+ 52 - 0
RMA/app/src/main/java/cn/muchinfo/rma/business/commodity/CommodityManager.kt

@@ -8,6 +8,7 @@ import cn.muchinfo.rma.netcore.packet.Packet50
 import cn.muchinfo.rma.netcore.socket.Callback
 import cn.muchinfo.rma.protobuf.funcode.FunCode
 import cn.muchinfo.rma.protobuf.protoclasses.ManageServiceMI2
+import cn.muchinfo.rma.protobuf.protoclasses.ManageServiceMI3
 import cn.muchinfo.rma.view.MyApplication
 import cn.muchinfo.rma.view.autoWidget.guard
 import cn.muchinfo.rma.view.base.app.BaseResult
@@ -576,4 +577,55 @@ class CommodityManager {
         )
     }
 
+    /**
+     * 现货品种申请请求云平台版本
+     * @param version String
+     * @param deliverygoodscode String
+     * @param deliverygoodsname String
+     * @param deliverygoodsid Long
+     * @param unitid Long
+     * @param type Int
+     * @param remark String
+     * @param gldwrstandards List<GLDWRStandardCloudEx>
+     * @param glddgfactoryItems List<GLDDGFactoryItemEx>
+     */
+    fun deliveryGoodsApplyCloudReq(
+        version : String = "",//接口版本号(目前支持2.0 3.1 3.2)
+        deliverygoodscode : String = "",//交割商品代码
+        deliverygoodsname : String = "",//交割商品名称
+        deliverygoodsid : Long = 0,//交割商品id(修改时有值)
+        unitid : Long = 0,//单位ID
+        type : Int = 0,//类型 1 新增 2 修改
+        remark : String = "",//备注
+        gldwrstandards : List<ManageServiceMI3.GLDWRStandardCloudEx> = arrayListOf(),//GLDWRStandardCloudEx 现货商品型号数据
+        glddgfactoryItems : List<ManageServiceMI3.GLDDGFactoryItemEx> = arrayListOf(),//GLDDGFactoryItemEx 现货商品品牌数据
+        callback: (isCompleted: Boolean, err: Error?) -> Unit
+    ){
+        val tradeSocketManager = MyApplication.getInstance()?.tradeSocketManager.guard {
+            callback(false, Error("交易链路未初始化"))
+            return
+        }
+
+        val reqPacket = CommodityAdapter.getDeliveryGoodsApplyCloudReqInfo(
+            version, deliverygoodscode, deliverygoodsname, deliverygoodsid, unitid, type, remark, gldwrstandards, glddgfactoryItems
+        )
+
+        tradeSocketManager.send(
+            reqPacket,
+            FunCode.ErmsMiddelGoodsStopRsp,
+            object : Callback<Packet50> {
+                override fun onSuccess(rsp: Packet50?) {
+                    val rst = CommodityAdapter.analysisDeliveryGoodsApplyCloudRsp(rsp!!)
+                    callback(rst.first, rst.second)
+                }
+
+                override fun onFail(err: Error?) {
+                    // 发送数据失败
+                    callback(false, err)
+                }
+
+            }
+        )
+    }
+
 }

+ 73 - 0
RMA/app/src/main/java/cn/muchinfo/rma/business/commodity/adapter/CommodityAdapter.kt

@@ -6,6 +6,7 @@ import cn.muchinfo.rma.global.GlobalDataCollection
 import cn.muchinfo.rma.netcore.packet.Packet50
 import cn.muchinfo.rma.protobuf.funcode.FunCode
 import cn.muchinfo.rma.protobuf.protoclasses.ManageServiceMI2
+import cn.muchinfo.rma.protobuf.protoclasses.ManageServiceMI3
 import java.io.ByteArrayOutputStream
 import java.lang.Exception
 
@@ -14,6 +15,78 @@ import java.lang.Exception
  */
 object CommodityAdapter {
 
+
+    /**
+     * 现货品种申请请求云平台版本
+     */
+    fun getDeliveryGoodsApplyCloudReqInfo(
+        version : String = "",//接口版本号(目前支持2.0 3.1 3.2)
+        deliverygoodscode : String = "",//交割商品代码
+        deliverygoodsname : String = "",//交割商品名称
+        deliverygoodsid : Long = 0,//交割商品id(修改时有值)
+        unitid : Long = 0,//单位ID
+        type : Int = 0,//类型 1 新增 2 修改
+        remark : String = "",//备注
+        gldwrstandards : List<ManageServiceMI3.GLDWRStandardCloudEx> = arrayListOf(),//GLDWRStandardCloudEx 现货商品型号数据
+        glddgfactoryItems : List<ManageServiceMI3.GLDDGFactoryItemEx> = arrayListOf()//GLDDGFactoryItemEx 现货商品品牌数据
+
+    ) : Packet50{
+        val builder = ManageServiceMI3.DeliveryGoodsApplyCloudReq.newBuilder()
+        val loginInfo = GlobalDataCollection.instance?.loginRsp!!
+        // FIXME: - 250000000005
+        builder.setHeader(
+            MessageHeadModel.getHead(
+                FunCode.FID_DeliveryGoodsApplyCloudReq,
+                loginInfo.userID,
+                0,
+                0,
+                18
+            )
+        )
+        builder.version = version
+        builder.userid = loginInfo.userID.toLong()
+        builder.loginid = loginInfo.loginID
+        builder.deliverygoodscode = deliverygoodscode
+        builder.deliverygoodsname = deliverygoodsname
+        if (type == 2){
+            builder.deliverygoodsid = deliverygoodsid
+        }
+        builder.unitid = unitid
+        builder.remark = remark
+        builder.type = type
+        builder.addAllGldwrstandards(gldwrstandards)
+        builder.addAllGlddgfactoryItems(glddgfactoryItems)
+        val arrayOutputStream = ByteArrayOutputStream();
+        builder.build().writeTo(arrayOutputStream)
+        return Packet50(FunCode.FID_DeliveryGoodsApplyCloudReq, arrayOutputStream.toByteArray())
+    }
+
+
+    /**
+     * 现货品种申请响应
+     * @param packet50 Packet50
+     * @return Triple<Boolean, Error?, ManageServiceMI2.DeliveryGoodsApplyRsp?>
+     */
+    fun analysisDeliveryGoodsApplyCloudRsp(packet50: Packet50): Triple<Boolean, Error?, ManageServiceMI3.DeliveryGoodsApplyCloudRsp?> {
+        return try {
+            val loginRsp = ManageServiceMI3.DeliveryGoodsApplyCloudRsp.parseFrom(packet50.content)
+            if (loginRsp.retCode == 0) {
+                // 操作成功
+                Triple(true, null, loginRsp)
+            } else {
+                // 操作失败
+                if (loginRsp.retCode == -1){
+                    Triple(false, Error(loginRsp.retDesc), null)
+                }else{
+                    Triple(false, Error(ErrorMessageUtils.getErrorString(loginRsp.retCode)), null)
+                }
+            }
+        } catch (e: Exception) {
+            // 操作失败
+            Triple(false, Error("装箱失败"), null)
+        }
+    }
+
     /**
      * 现货品种申请请求报文装箱
      * @param deliverygoodscode String 交割商品代码(新增时有值)

+ 2 - 2
RMA/app/src/main/java/cn/muchinfo/rma/view/base/app/Constant.kt

@@ -7,7 +7,7 @@ object Constant {
      * 获取基础url的接口
      */
 //    const val baseurl = "http://103.40.249.123:38280/cfg?key=mtp_20" // 天津麦顿
-    const val baseurl = "http://103.40.249.123:28280/cfg?key=mtp_20"//云融大宗
+//    const val baseurl = "http://103.40.249.123:28280/cfg?key=mtp_20"//云融大宗
 //    const val baseurl = "http://103.40.249.123:8280/cfg?key=mtp_20"//千海金外盘
 //    const val baseurl = "http://103.40.249.127:28280/cfg?key=mtp_20"
 
@@ -30,7 +30,7 @@ object Constant {
 //    const val baseurl = "http://192.168.31.136:8080/cfg?key=test_136"//黄老板 华南顺通
 
 //    const val baseurl = "http://192.168.31.176:8080/cfg?key=test_176"//黄老板 天津麦顿调试
-//    const val baseurl = "http://192.168.31.167:8080/cfg?key=test_167"//黄老板 平安云平台(企业风管)
+    const val baseurl = "http://192.168.31.167:8080/cfg?key=test_167"//黄老板 平安云平台(企业风管)
 
     /**
      * 用sp存储基础url的key

+ 2 - 1
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/commodity/CommodityInformationActivity.kt

@@ -9,6 +9,7 @@ import androidx.viewpager.widget.ViewPager
 import cn.muchinfo.rma.R
 import cn.muchinfo.rma.view.autoWidget.*
 import cn.muchinfo.rma.view.base.BaseActivity
+import cn.muchinfo.rma.view.base.home.commodity.newspot.NewAddSpotGoodsActivity
 import cn.muchinfo.rma.view.base.home.customerdata.AddCustomerDataActivity
 import com.blankj.utilcode.util.ActivityUtils
 import com.blankj.utilcode.util.ConvertUtils
@@ -129,7 +130,7 @@ class CommodityInformationActivity : BaseActivity<CommodityInformationViewModel>
                     if (selectedTabIndex == 0){
                         val intent = Intent()
                         intent.putExtra("type","1")
-                        intent.setClass(context, AddSpotGoodsActivity::class.java)
+                        intent.setClass(context, NewAddSpotGoodsActivity::class.java)
                         ActivityUtils.startActivity(intent)
                     }else if (selectedTabIndex == 1){
                         val intent = Intent()

+ 2 - 1
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/commodity/newcommodity/NewCommodityInformationActivity.kt

@@ -20,6 +20,7 @@ import cn.muchinfo.rma.view.autoWidget.*
 import cn.muchinfo.rma.view.base.BaseActivity
 import cn.muchinfo.rma.view.base.home.commodity.AddSpotGoodsActivity
 import cn.muchinfo.rma.view.base.home.commodity.newcommodity.newhedge.NewHedgeSpeciesViewHolder
+import cn.muchinfo.rma.view.base.home.commodity.newspot.NewAddSpotGoodsActivity
 import cn.muchinfo.rma.view.base.home.contract.emptyView
 import cn.muchinfo.rma.view.base.home.registration.showPopups
 import com.blankj.utilcode.util.ActivityUtils
@@ -145,7 +146,7 @@ class NewCommodityInformationActivity : BaseActivity<NewCommodityInformationView
                     onThrottleFirstClick {
                         val intent = Intent()
                         intent.putExtra("type", "1")
-                        intent.setClass(context, AddSpotGoodsActivity::class.java)
+                        intent.setClass(context, NewAddSpotGoodsActivity::class.java)
                         ActivityUtils.startActivity(intent)
                     }
                 }.lparams(autoSize(48),autoSize(48)){

+ 297 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/commodity/newspot/NewAddSpotCategoryViewHolder.kt

@@ -0,0 +1,297 @@
+package cn.muchinfo.rma.view.base.home.commodity.newspot
+
+import android.view.Gravity
+import android.view.View
+import android.view.inputmethod.EditorInfo
+import android.widget.EditText
+import androidx.appcompat.app.AppCompatActivity
+import androidx.lifecycle.MutableLiveData
+import cn.muchinfo.rma.R
+import cn.muchinfo.rma.lifecycle.bindOptional
+import cn.muchinfo.rma.view.autoWidget.*
+import cn.muchinfo.rma.view.base.home.commodity.CommodityInformationViewModel
+import cn.muchinfo.rma.view.base.home.commodity.viewholder.SpotInfoData
+import cn.muchinfo.rma.view.base.home.contract.emptyView
+import cn.muchinfo.rma.view.base.home.contract.viewItemUI
+import com.blankj.utilcode.util.LogUtils
+import com.blankj.utilcode.util.ToastUtils
+import mtp.polymer.com.autowidget.adapter.BaseAdapter
+import mtp.polymer.com.autowidget.adapter.BaseViewHolder
+import mtp.polymer.com.autowidget.dialog.SelectData
+import mtp.polymer.com.autowidget.dialog.creatBottomSheetDialog
+import org.jetbrains.anko.*
+import org.jetbrains.anko.sdk25.coroutines.textChangedListener
+
+/**
+ * 品类的viewholder
+ * @property activity AppCompatActivity
+ * @property viewModel CommodityInformationViewModel
+ * @property operationType String
+ * * operationType 1 是新增,2是修改,3是停用,4详情 5恢复
+ * @property itemSize IntArray
+ * @constructor
+ */
+class NewAddSpotCategoryViewHolder(
+    private val activity: AppCompatActivity,
+    private val viewModel: NewAddSpotGoodsViewModel,
+    private val operationType: String = ""
+) : BaseViewHolder<NewSpotInfoData>(activity) {
+    override val itemSize: IntArray = intArrayOf(matchParent, wrapContent)
+
+
+    /** 选择的单位 **/
+    val selectUnitType: MutableLiveData<SelectData> = MutableLiveData()
+
+    //输入的品类信息
+    lateinit var category_edittext : EditText
+
+    //输入的标仓系数
+    lateinit var coefficient_of_warehouse : EditText
+
+    //套保
+    private val middleGoodsAdapter: BaseAdapter<NewSpotInfoData, NewInsuredVarietyViewHolder> =
+        BaseAdapter { _, _ ->
+            NewInsuredVarietyViewHolder(
+                activity,
+                viewModel,
+                operationType = operationType
+            )
+        }
+
+
+    override fun _FrameLayout.createContentView() {
+        verticalLayout {
+            //商品名称
+            linearLayout {
+                background = resources.getDrawable(R.color.white)
+                gravity = Gravity.CENTER_VERTICAL
+                textView {
+                    text = "*"
+                    textColorInt = R.color.rma_star_color
+                    textSizeAuto = 31
+                }.lparams(wrapContent, wrapContent) {
+                    marginStart = autoSize(37)
+                }
+
+                textView {
+                    data.bindOptional(context) {
+                        text = "品类" + dataIndex.plus(1)
+                    }
+
+                    textSizeAuto = 31
+                    textColorInt = R.color.rma_black_33
+                }.lparams(wrapContent, wrapContent) {
+                    marginStart = autoSize(10)
+                }
+
+                editText {
+                    category_edittext = this
+                    isEnabled =
+                        !(operationType == "4" || operationType == "3" || operationType == "5")
+                    hint = "请输入品类"
+                    textChangedListener {
+                        afterTextChanged {
+                            if (it.toString().isNotEmpty()) {//修改品类
+                                viewModel.changeSpotModelList(id = data.value?.id.toString(),type = "3",value = it.toString(),coefficientwarehouse = "")
+                            }
+                        }
+                    }
+                    data.bindOptional(context) {
+                        setText(it?.value)
+                    }
+                    background = null
+                    inputType = EditorInfo.TYPE_CLASS_TEXT
+                    hintColorStr = "#CCCCCC"
+                    textSizeAuto = 31
+                    textColorStr = "#333333"
+                }.lparams(autoSize(300), autoSize(132)) {
+                    marginStart = autoSize(40)
+                }
+
+                emptyView()
+
+                imageView {
+                    if (operationType == "4"){//页面类型为详情时则需要屏蔽相关操作
+                        visibility = View.GONE
+                    }else{
+                        visibility = View.VISIBLE
+                    }
+                    isEnabled =
+                        !(operationType == "4" || operationType == "3" || operationType == "5")
+                    onThrottleFirstClick {
+                        if (viewModel.spotModelList.value?.size.toString() == "1"){
+                            ToastUtils.showLong("最少输入一个品类")
+                            return@onThrottleFirstClick
+                        }
+                        viewModel.changeSpotModelList("2",data.value?.id.toString(),value = "")
+                    }
+                    imageResource = R.mipmap.rma_delete
+                }.lparams(autoSize(30), autoSize(30)) {
+                    marginEnd = autoSize(31)
+                }
+            }.lparams(matchParent, autoSize(132))
+
+            viewItemUI()
+
+            //单位
+            linearLayout {
+                background = resources.getDrawable(R.color.white)
+                gravity = Gravity.CENTER_VERTICAL
+
+                onThrottleFirstClick {
+                    //对于修改,停用,复用的操作不能选择
+                    if (operationType == "4" || operationType == "3" || operationType == "5") {
+                        return@onThrottleFirstClick
+                    }
+                    val selectDataList = arrayListOf(
+                        SelectData(
+                            id = "1",
+                            value = "吨"
+                        ),
+                        SelectData(
+                            id = "2",
+                            value = "千克"
+                        ), SelectData(
+                            id = "3",
+                            value = "克"
+                        ),
+                        SelectData(
+                            id = "4",
+                            value = "股"
+                        ),
+                        SelectData(
+                            id = "6",
+                            value = "张"
+                        ),
+                        SelectData(
+                            id = "7",
+                            value = "桶"
+                        )
+                    )
+                    activity.creatBottomSheetDialog("请选择单位", selectDataList) {
+                        viewModel.changeSpotModelList(type = "4",id = data.value?.id.toString(),value = category_edittext.text.toString(),coefficientwarehouse = coefficient_of_warehouse.text.toString(),enumdicnameid = this.id,enumdicname = this.value)
+                    }
+                }
+                textView {
+                    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)
+                }
+
+                textView {
+                    data.bindOptional(context){
+                        if (it?.enumdicname.isNullOrEmpty()){
+                            text = "请选择单位"
+                            textColorInt = R.color.rma_hint_text_color_ccc
+                        }else{
+                            text = it?.enumdicname
+                            textColorInt = R.color.rma_black_33
+                        }
+
+                    }
+//                    selectUnitType.bindOptional(context) {
+//                        text = it?.value
+//                        textColorInt = R.color.rma_black_33
+//                    }
+                    text = "请选择单位"
+                    textSizeAuto = 31
+                    textColorInt = R.color.rma_hint_text_color_ccc
+                }.lparams(wrapContent, wrapContent) {
+                    marginStart = autoSize(80)
+                }
+
+                emptyView()
+
+                imageView {
+                    if (operationType == "4"){//页面类型为详情时则需要屏蔽相关操作
+                        visibility = View.GONE
+                    }else{
+                        visibility = View.VISIBLE
+                    }
+                    imageResource = R.mipmap.rma_more
+                }.lparams(autoSize(36), autoSize(36)) {
+                    marginEnd = autoSize(25)
+                }
+            }.lparams(matchParent, autoSize(132))
+
+            viewItemUI()
+
+            //增值税税率-之前的标仓系数
+            linearLayout {
+                background = resources.getDrawable(R.color.white)
+                gravity = Gravity.CENTER_VERTICAL
+                textView {
+                    text = "*"
+                    textColorInt = R.color.rma_star_color
+                    textSizeAuto = 31
+                }.lparams(wrapContent, wrapContent) {
+                    marginStart = autoSize(37)
+                }
+
+                textView {
+                    data.bindOptional(context) {
+                        text = "增值税税率%"
+                    }
+                    textSizeAuto = 31
+                    textColorInt = R.color.rma_black_33
+                }.lparams(wrapContent, wrapContent) {
+                    marginStart = autoSize(10)
+                }
+
+                editText {
+                    coefficient_of_warehouse = this
+                    isEnabled =
+                        !(operationType == "4" || operationType == "3" || operationType == "5")
+                    data.bindOptional(context) {
+                        setText(it?.coefficientwarehouse)
+                        LogUtils.eTag("hkjahdjkahjksdha",dataIndex.toString() + "------" +it?.coefficientwarehouse)
+                        textColorInt = R.color.rma_black_33
+                    }
+                    hint = "请输入增值税税率"
+                    textChangedListener {
+                        afterTextChanged {
+                            if (it.toString().isNotEmpty()) {
+                                viewModel.changeSpotModelList(
+                                    "3",
+                                    data.value?.id.toString(),
+                                    coefficientwarehouse = it.toString()
+                                )
+                            }
+                        }
+                    }
+                    background = null
+                    inputType = EditorInfo.TYPE_CLASS_TEXT
+                    hintColorStr = "#CCCCCC"
+                    textSizeAuto = 31
+                    textColorStr = "#333333"
+                }.lparams(autoSize(300), autoSize(132)) {
+                    marginStart = autoSize(60)
+                }
+            }.lparams(matchParent, wrapContent)
+
+            viewItemUI()
+
+            //添加套保品种信息
+            recyclerView {
+                background = resources.getDrawable(R.color.white)
+                adapter = middleGoodsAdapter
+                isNestedScrollingEnabled = false
+            }.lparams(matchParent, wrapContent)
+
+            data.bindOptional(context){
+                middleGoodsAdapter.setNewData(it?.middleGoodsList)
+            }
+        }
+    }
+
+}

+ 668 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/commodity/newspot/NewAddSpotGoodsActivity.kt

@@ -0,0 +1,668 @@
+package cn.muchinfo.rma.view.base.home.commodity.newspot
+
+import android.os.Bundle
+import android.view.Gravity
+import android.view.View
+import android.view.inputmethod.EditorInfo
+import android.widget.EditText
+import androidx.lifecycle.MutableLiveData
+import cn.muchinfo.rma.R
+import cn.muchinfo.rma.global.MTPEnums
+import cn.muchinfo.rma.global.data.ContractData
+import cn.muchinfo.rma.global.data.DeliveryGoodsDetailData
+import cn.muchinfo.rma.global.data.MiddleGoodsData
+import cn.muchinfo.rma.global.data.WrStandardData
+import cn.muchinfo.rma.lifecycle.bindOptional
+import cn.muchinfo.rma.protobuf.protoclasses.ManageServiceMI2
+import cn.muchinfo.rma.view.autoWidget.*
+import cn.muchinfo.rma.view.base.BaseActivity
+import cn.muchinfo.rma.view.base.home.commodity.newcommodity.SpotCategoryViewHolder
+import cn.muchinfo.rma.view.base.home.commodity.viewholder.AddSpotCategoryViewHolder
+import cn.muchinfo.rma.view.base.home.commodity.viewholder.InsuredVarietyViewHolder
+import cn.muchinfo.rma.view.base.home.commodity.viewholder.SpotInfoData
+import cn.muchinfo.rma.view.base.home.commodity.viewholder.SpotModelViewHolder
+import cn.muchinfo.rma.view.base.home.contract.ContractDataViewHolder
+import cn.muchinfo.rma.view.base.home.contract.baseInformationView
+import cn.muchinfo.rma.view.base.home.contract.emptyView
+import cn.muchinfo.rma.view.base.home.contract.viewItemUI
+import com.blankj.utilcode.util.LogUtils
+import com.blankj.utilcode.util.ToastUtils
+import mtp.polymer.com.autowidget.adapter.BaseAdapter
+import mtp.polymer.com.autowidget.dialog.SelectData
+import mtp.polymer.com.autowidget.dialog.creatBottomSheetDialog
+import mtp.polymer.com.autowidget.dialog.createLoadingDialog
+import mtp.polymer.com.autowidget.utils.bindTaskStatus
+import org.jetbrains.anko.*
+
+/**
+ * 新增现货品种
+ */
+class NewAddSpotGoodsActivity : BaseActivity<NewAddSpotGoodsViewModel>() {
+
+    /** 备注 **/
+    lateinit var remask_edittext: EditText
+
+    /** 商品名称 **/
+    lateinit var spot_variety_name_edittext: EditText
+
+    /** 商品代码 **/
+    lateinit var spot_variety_code_edittext: EditText
+
+    /** 现货品种代码 **/
+    lateinit var spot_variety_enauname_edittext: EditText
+
+    /**
+     * type 1 新增 2 修改 3 停用 4 详情 5 恢复
+     */
+    val type by lazy {
+        intent.getStringExtra("type")
+    }
+
+    /**
+     * 用作修改,停用,恢复时的数据
+     */
+    val data: DeliveryGoodsDetailData by lazy {
+        intent.getParcelableExtra<DeliveryGoodsDetailData>("data") as DeliveryGoodsDetailData
+    }
+
+    //型号适配/////第三期修改为品类
+    private val spotModelAdapter: BaseAdapter<NewSpotInfoData, NewAddSpotCategoryViewHolder> =
+        BaseAdapter { _, _ ->
+            NewAddSpotCategoryViewHolder(
+                this,
+                viewModel,
+                operationType = type ?: ""
+            )
+        }
+
+    //品牌适配
+    private val brandModelAdapter: BaseAdapter<NewSpotInfoData, NewSpotModelViewHolder> =
+        BaseAdapter { _, _ ->
+            NewSpotModelViewHolder(
+                this,
+                viewModel,
+                "2",
+                operationType = type ?: ""
+            )
+        }
+
+
+    /** 选择的单位 **/
+    val selectUnitType: MutableLiveData<SelectData> = MutableLiveData()
+
+    val dialog by lazy { createLoadingDialog(hintStr = "请求中...") }
+
+    override fun onCreate(savedInstanceState: Bundle?) {
+        super.onCreate(savedInstanceState)
+        //页面内容UI
+        contentUI()
+        init()
+    }
+
+    //初始化数据
+    fun init() {
+        if (type == "1") {
+            val spotModelList = arrayListOf(NewSpotInfoData(id = "1", value = ""))
+            viewModel.spotModelList.postValue(spotModelList)
+            viewModel.spotModelcacheList.postValue(spotModelList)
+            val beandModelList = arrayListOf(NewSpotInfoData(id = "1", value = ""))
+            viewModel.brandModelList.postValue(beandModelList)
+            viewModel.brandModelcacheList.postValue(beandModelList)
+
+            viewModel.queryGoodsGroup()
+        } else {
+            viewModel.queryGoodsGroup()
+            viewModel.initSpotGoodsActivity(data)
+            selectUnitType.postValue(
+                SelectData(
+                    id = data.data?.goodsunitid ?: "",
+                    value = data.data?.enumdicname ?: ""
+                )
+            )
+//            viewModel.queryWrStandardDetails(data.data?.deliverygoodsid ?: "")
+        }
+    }
+
+    fun contentUI() {
+        verticalLayout {
+            dialog.bindTaskStatus(context, viewModel.loadingDialogStatus)
+            background = resources.getDrawable(R.color.segtabment_bg_color)
+            //头部标题
+            topBar {
+                commonLeftButton()
+                commonTitle {
+                    if (type == "1") {
+                        text = "新增现货品种"
+                    } else if (type == "2") {
+                        text = "修改现货品种"
+                    } else if (type == "3") {
+                        text = "停用现货品种"
+                    } else if (type == "5") {
+                        text = "恢复现货品种"
+                    } else {
+                        text = "现货品种详情"
+                    }
+                }
+            }
+
+            frameLayout {
+                nestedScrollView {
+                    verticalLayout {
+                        baseInformationView("基本信息")
+
+                        linearLayout {
+                            background = resources.getDrawable(R.color.white)
+                            gravity = Gravity.CENTER_VERTICAL
+                            textView {
+                                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)
+                            }
+
+                            editText {
+                                if (type == "2" || type == "4" || type == "3" || type == "5") {
+                                    isEnabled = false
+                                    setText(data.data?.deliverygoodsname)
+                                } else {
+                                    isEnabled = true
+                                }
+                                spot_variety_name_edittext = this
+                                hint = "请输入现货品种名称"
+                                background = null
+                                inputType = EditorInfo.TYPE_CLASS_TEXT
+//                                setDecimalInputType()
+                                hintColorStr = "#CCCCCC"
+                                textSizeAuto = 31
+                                textColorStr = "#333333"
+                            }.lparams(matchParent, autoSize(132)) {
+                                marginStart = autoSize(40)
+                            }
+                        }.lparams(matchParent, autoSize(132))
+
+                        viewItemUI()
+
+
+                        linearLayout {
+                            background = resources.getDrawable(R.color.white)
+                            gravity = Gravity.CENTER_VERTICAL
+
+                            textView {
+                                text = "现货品种代码"
+                                textSizeAuto = 31
+                                textColorInt = R.color.rma_black_33
+                            }.lparams(wrapContent, wrapContent) {
+                                marginStart = autoSize(50)
+                            }
+
+                            editText {
+                                if (type == "2" || type == "4" || type == "3" || type == "5") {
+                                    isEnabled = false
+                                    setText(data.data?.deliverygoodscode)
+                                } else {
+                                    isEnabled = true
+                                }
+                                spot_variety_code_edittext = this
+                                hint = "请输入现货品种代码"
+                                background = null
+                                inputType = EditorInfo.TYPE_TEXT_VARIATION_PASSWORD
+//                                setDecimalInputType()
+                                hintColorStr = "#CCCCCC"
+                                textSizeAuto = 31
+                                textColorStr = "#333333"
+                            }.lparams(matchParent, autoSize(132)) {
+                                marginStart = autoSize(40)
+                            }
+                        }.lparams(matchParent, autoSize(132))
+
+                        viewItemUI()
+
+                        linearLayout {
+                            background = resources.getDrawable(R.color.white)
+                            gravity = Gravity.CENTER_VERTICAL
+
+                            onThrottleFirstClick {
+                                //对于修改,停用,复用的操作不能选择
+                                if (type == "4" || type == "3" || type == "5") {
+                                    return@onThrottleFirstClick
+                                }
+                                val selectDataList = arrayListOf(
+                                    SelectData(
+                                        id = "1",
+                                        value = "吨"
+                                    ),
+                                    SelectData(
+                                        id = "2",
+                                        value = "千克"
+                                    ), SelectData(
+                                        id = "3",
+                                        value = "克"
+                                    ),
+                                    SelectData(
+                                        id = "4",
+                                        value = "股"
+                                    ),
+                                    SelectData(
+                                        id = "6",
+                                        value = "张"
+                                    ),
+                                    SelectData(
+                                        id = "7",
+                                        value = "桶"
+                                    )
+                                )
+                                creatBottomSheetDialog("请选择单位", selectDataList) {
+                                    selectUnitType.postValue(this)
+                                }
+                            }
+                            textView {
+                                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)
+                            }
+
+                            textView {
+                                selectUnitType.bindOptional(context) {
+                                    if (it?.value.isNullOrEmpty()) {
+                                        text = data.data?.enumdicname
+                                        textColorInt = R.color.rma_black_33
+                                    } else {
+                                        text = it?.value
+                                        textColorInt = R.color.rma_black_33
+                                    }
+
+                                }
+                                text = "请选择单位"
+                                textSizeAuto = 31
+                                textColorInt = R.color.rma_hint_text_color_ccc
+                            }.lparams(wrapContent, wrapContent) {
+                                marginStart = autoSize(80)
+                            }
+
+                            emptyView()
+
+                            imageView {
+                                if (type == "4"){
+                                    visibility = View.GONE
+                                }else{
+                                    visibility = View.VISIBLE
+                                }
+                                imageResource = R.mipmap.rma_more
+                            }.lparams(autoSize(36), autoSize(36)) {
+                                marginEnd = autoSize(25)
+                            }
+                        }.lparams(matchParent, autoSize(132))
+
+                        baseInformationView("品类信息")
+
+                        //添加型号信息
+                        recyclerView {
+                            background = resources.getDrawable(R.color.white)
+                            adapter = spotModelAdapter
+                            isNestedScrollingEnabled = false
+                        }.lparams(matchParent, wrapContent)
+
+                        viewModel.spotModelList.bindOptional(context) {
+                            spotModelAdapter.setNewData(it)
+                        }
+
+                        viewItemUI()
+
+                        linearLayout {
+                            if (type == "4"){
+                                visibility = View.GONE
+                            }else{
+                                visibility = View.VISIBLE
+                            }
+                            onThrottleFirstClick {
+                                if (type == "4" || type == "3" || type == "5") {
+                                    return@onThrottleFirstClick
+                                }
+                                viewModel.changeSpotModelList(
+                                    "1",
+                                    viewModel.spotModelList.value?.size?.plus(1).toString(),
+                                    value = ""
+                                )
+                            }
+                            background = resources.getDrawable(R.color.main_hit_bg_color)
+                            gravity = Gravity.CENTER_VERTICAL
+                            emptyView()
+                            imageView {
+                                imageResource = R.mipmap.rma_add
+                            }.lparams(autoSize(36), autoSize(36))
+
+                            textView {
+                                text = "添加品类"
+                                textColorInt = R.color.rma_blue_color
+                                textSizeAuto = 31
+                            }.lparams(wrapContent, wrapContent) {
+                                marginEnd = autoSize(35)
+                            }
+                        }.lparams(matchParent, autoSize(80))
+
+                        //添加型号信息
+                        recyclerView {
+                            background = resources.getDrawable(R.color.white)
+                            adapter = brandModelAdapter
+                            isNestedScrollingEnabled = false
+                        }.lparams(matchParent, wrapContent)
+
+                        viewModel.brandModelList.bindOptional(context) {
+                            brandModelAdapter.setNewData(it)
+                        }
+
+                        viewItemUI()
+
+                        linearLayout {
+                            if (type == "4"){
+                                visibility = View.GONE
+                            }else{
+                                visibility = View.VISIBLE
+                            }
+                            onThrottleFirstClick {
+                                if (type == "4" || type == "3" || type == "5") {
+                                    return@onThrottleFirstClick
+                                }
+                                viewModel.changeBrandModelList(
+                                    "1",
+                                    viewModel.brandModelList.value?.size?.plus(1).toString(),
+                                    value = ""
+                                )
+                            }
+                            background = resources.getDrawable(R.color.white)
+                            gravity = Gravity.CENTER_VERTICAL
+                            emptyView()
+                            imageView {
+                                imageResource = R.mipmap.rma_add
+                            }.lparams(autoSize(36), autoSize(36))
+
+                            textView {
+
+                                text = "添加品牌"
+                                textColorInt = R.color.rma_blue_color
+                                textSizeAuto = 31
+                            }.lparams(wrapContent, wrapContent) {
+                                marginEnd = autoSize(35)
+                            }
+                        }.lparams(matchParent, autoSize(80))
+
+
+
+//                        linearLayout {
+//                            if (type == "4"){//页面类型为详情时则需要屏蔽相关操作
+//                                visibility = View.GONE
+//                            }else{
+//                                visibility = View.VISIBLE
+//                            }
+//                            background = resources.getDrawable(R.color.white)
+//                            gravity = Gravity.CENTER_VERTICAL
+//                            emptyView()
+//                            imageView {
+//                                imageResource = R.mipmap.rma_add
+//                            }.lparams(autoSize(36), autoSize(36))
+//
+//                            textView {
+//                                onThrottleFirstClick {
+//                                    if (type == "4" || type == "3" || type == "5") {
+//                                        return@onThrottleFirstClick
+//                                    }
+//                                    viewModel.changeMiddleGoodsList(
+//                                        "1",
+//                                        viewModel.middlegoodList.value?.size?.plus(1).toString()
+//                                    )
+//                                }
+//                                text = "添加套保品种"
+//                                textColorInt = R.color.rma_blue_color
+//                                textSizeAuto = 31
+//                            }.lparams(wrapContent, wrapContent) {
+//                                marginEnd = autoSize(35)
+//                            }
+//                        }.lparams(matchParent, autoSize(80))
+
+                        baseInformationView("其他信息")
+
+                        linearLayout {
+                            background = resources.getDrawable(R.color.white)
+                            gravity = Gravity.CENTER_VERTICAL
+                            textView {
+                                text = "备        注"
+                                textSizeAuto = 31
+                                textColorInt = R.color.rma_black_33
+                            }.lparams(wrapContent, wrapContent) {
+                                marginStart = autoSize(59)
+                            }
+
+                            editText {
+                                isEnabled = if (type == "4" || type == "3" || type == "5") {
+                                    false
+                                } else {
+                                    true
+                                }
+                                remask_edittext = this
+                                hint = "请输入备注"
+                                background = null
+                                inputType = EditorInfo.TYPE_CLASS_TEXT
+                                hintColorStr = "#CCCCCC"
+                                textSizeAuto = 31
+                                textColorStr = "#333333"
+                            }.lparams(matchParent, autoSize(260)) {
+                                marginStart = autoSize(80)
+                            }
+                        }.lparams(matchParent, autoSize(136)) {
+                            bottomMargin = autoSize(200)
+                        }
+
+                    }
+                }
+
+                linearLayout {
+                    background = resources.getDrawable(R.color.white)
+                    gravity = Gravity.CENTER_VERTICAL
+
+                    if (type == "4") {
+                        visibility = View.GONE
+                    } else {
+                        visibility = View.VISIBLE
+                    }
+                    textView {
+                        onThrottleFirstClick {
+                            if (checkUpdate().not()) {
+                                return@onThrottleFirstClick
+                            }
+//                            if (type == "1") {
+//                                viewModel.requestGoodsApply(
+//                                    deliverygoodscode = spot_variety_code_edittext.text.toString(),
+//                                    deliverygoodsname = spot_variety_name_edittext.text.toString(),
+//                                    unitid = selectUnitType.value?.id?.toLong()!!,
+//                                    type = 1,
+//                                    remark = remask_edittext.text.toString(),
+//                                    spotgoodsmodels = getSpotModelList(),
+//                                    spotgoodsbrands = getBrandModelList(),
+//                                    wrsconvertdetails = getMiddleModelList()
+//                                ) {
+//                                    finish()
+//                                }
+//                            } else if (type == "2") {//修改
+//                                viewModel.requestGoodsApply(
+//                                    deliverygoodscode = spot_variety_code_edittext.text.toString(),
+//                                    deliverygoodsname = spot_variety_name_edittext.text.toString(),
+//                                    unitid = selectUnitType.value?.id?.toLong()!!,
+//                                    wrstandardid = data.data?.deliverygoodsid?.toLong() ?: 0,
+//                                    type = 2,
+//                                    remark = remask_edittext.text.toString(),
+//                                    spotgoodsmodels = getSpotModelList(isAdd = false),
+//                                    spotgoodsbrands = getBrandModelList(isAdd = false),
+//                                    wrsconvertdetails = getMiddleModelList()
+//                                ) {
+//                                    finish()
+//                                }
+//                            } else if (type == "3") {//停用
+//                                viewModel.requestGoodsCancelReq(
+//                                    wrstandardid = data.data?.deliverygoodsid?.toLong() ?: 0,
+//                                    isvalid = 0
+//                                ) {
+//                                    finish()
+//                                }
+//                            } else if (type == "5") {//恢复
+//                                viewModel.requestGoodsCancelReq(
+//                                    wrstandardid = data.data?.deliverygoodsid?.toLong() ?: 0,
+//                                    isvalid = 1
+//                                ) {
+//                                    finish()
+//                                }
+//                            }
+                        }
+                        gravity = Gravity.CENTER
+                        backgroundResource = R.mipmap.rma_submit_bg
+                        if (type == "1") {
+                            text = "完成"
+                        } else if (type == "2") {
+                            text = "修改"
+                        } else if (type == "3") {
+                            text = "停用"
+                        } else if (type == "5") {
+                            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)
+
+
+        }
+    }
+
+    /**
+     * 型号列表//三期修改为品类
+     * isAdd 是否是新增
+     * @return List<ManageServiceMI2.SpotGoodsModelEx>
+     */
+    private fun getSpotModelList(isAdd: Boolean = true): List<ManageServiceMI2.GLDWRStandardEx> {
+        val spotgoodsmodels = arrayListOf<ManageServiceMI2.GLDWRStandardEx>()
+        viewModel.spotModelcacheList.value?.forEach {
+            val spotGoodsData = ManageServiceMI2.GLDWRStandardEx.newBuilder()
+            spotGoodsData.wrstandardname = it.value
+            if (it.middleGoodsId.isNullOrEmpty()){
+                spotGoodsData.wrstandardid = 0//修改时才加
+            }else{
+                spotGoodsData.wrstandardid = it.middleGoodsId.toLong()//修改时才加
+            }
+            spotGoodsData.unitid = it.enumdicnameid.toLong()
+            spotGoodsData.convertfactor = it.coefficientwarehouse.toDouble()
+//            LogUtils.eTag("asdhahsdkjahdjka",spotGoodsData.modelid)
+            spotgoodsmodels.add(spotGoodsData.build())
+        }
+        return spotgoodsmodels
+    }
+
+    /**
+     * 品牌列表
+     * @return List<ManageServiceMI2.SpotGoodsModelEx>
+     */
+    private fun getBrandModelList(isAdd: Boolean = true): List<ManageServiceMI2.GLDDGFactoryItemEx> {
+        val brandgoodsmodels = arrayListOf<ManageServiceMI2.GLDDGFactoryItemEx>()
+        viewModel.brandModelcacheList.value?.forEach {
+            val spotGoodsData = ManageServiceMI2.GLDDGFactoryItemEx.newBuilder()
+            spotGoodsData.dgfactoryitemvalue = it.value
+            if (it.middleGoodsId.isNullOrEmpty()){
+                spotGoodsData.dgfactoryitemid = 0
+            }else{
+                spotGoodsData.dgfactoryitemid = it.middleGoodsId.toLong()
+            }
+            if (isAdd.not()) {
+            }
+            LogUtils.eTag("asdhahsdkjahdjka", spotGoodsData.dgfactoryitemid)
+            brandgoodsmodels.add(spotGoodsData.build())
+        }
+        return brandgoodsmodels
+    }
+
+    /**
+     * 套保品牌列表
+     * @return List<ManageServiceMI2.SpotGoodsModelEx>
+     */
+    private fun getMiddleModelList(isAdd: Boolean = true): List<ManageServiceMI2.WRSConvertDetailEx> {
+        val middlegoodsmodels = arrayListOf<ManageServiceMI2.WRSConvertDetailEx>()
+//        viewModel.middlegoodCacheList.value?.forEach {
+//            val spotGoodsData = ManageServiceMI2.WRSConvertDetailEx.newBuilder()
+//            spotGoodsData.middlegoodsid = it.middleGoodsId.toLong()
+//            spotGoodsData.unitid = it.enumdicnameid.toLong()
+//            spotGoodsData.convertratio = it.value.toDouble()
+//            middlegoodsmodels.add(spotGoodsData.build())
+//        }
+        return middlegoodsmodels
+    }
+
+    /**
+     * 提交资料前的效验
+     * @return Boolean
+     */
+    private fun checkUpdate(): Boolean {
+
+        if (type == "1"){
+            if (spot_variety_name_edittext.text.toString().isNullOrEmpty()) {
+                ToastUtils.showLong("请输入商品名称")
+                return false
+            }
+        }
+
+
+        if (selectUnitType.value?.id.isNullOrEmpty()) {
+            ToastUtils.showLong("请选择单位")
+            return false
+        }
+
+        viewModel.spotModelcacheList.value?.forEach {
+            if (it.value.isNullOrEmpty()) {
+                ToastUtils.showLong("请输入完整品类信息")
+                return false
+            }
+        }
+
+        viewModel.brandModelcacheList.value?.forEach {
+            if (it.value.isNullOrEmpty()) {
+                ToastUtils.showLong("请输入品牌")
+                return false
+            }
+        }
+
+//        viewModel.middlegoodCacheList.value?.forEach {
+//            if (it.middleGoodsName.isNullOrEmpty()) {
+//                ToastUtils.showLong("请选择套保类型")
+//                return false
+//            }
+//            if (it.value.isNullOrEmpty()) {
+//                ToastUtils.showLong("请输入套保系数")
+//                return false
+//            }
+//        }
+
+        return true
+    }
+
+}

+ 275 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/commodity/newspot/NewAddSpotGoodsViewModel.kt

@@ -0,0 +1,275 @@
+package cn.muchinfo.rma.view.base.home.commodity.newspot
+
+import androidx.lifecycle.MutableLiveData
+import cn.muchinfo.rma.global.GlobalDataCollection
+import cn.muchinfo.rma.global.data.DeliveryGoodsDetailData
+import cn.muchinfo.rma.global.data.GoodsGroupData
+import cn.muchinfo.rma.view.MyApplication
+import cn.muchinfo.rma.view.autoWidget.toArrayList
+import cn.muchinfo.rma.view.base.BaseViewModel
+import cn.muchinfo.rma.view.base.home.commodity.viewholder.SpotInfoData
+import mtp.polymer.com.autowidget.utils.TaskUiModel
+
+/**
+ * 新版新增现货品种的viewmodel
+ */
+class NewAddSpotGoodsViewModel : BaseViewModel(){
+
+    /**
+     * 加载状态控制
+     */
+    val loadingDialogStatus: MutableLiveData<TaskUiModel> = MutableLiveData()
+
+    /**
+     * 新增现货品种时的品牌列表数据
+     */
+    val brandModelList: MutableLiveData<List<NewSpotInfoData>> = MutableLiveData()
+
+    /**
+     * 新增现货品种时的品牌列表数据
+     */
+    val brandModelcacheList: MutableLiveData<List<NewSpotInfoData>> = MutableLiveData()
+
+
+    /**
+     * 新增现货品种时的型号列表数据(三期为品类)
+     */
+    val spotModelList: MutableLiveData<List<NewSpotInfoData>> = MutableLiveData()
+
+    /**
+     * 暂存的型号列表数据(三期为品类)
+     */
+    val spotModelcacheList: MutableLiveData<List<NewSpotInfoData>> = MutableLiveData()
+
+    /**
+     * 套保品种正常列表
+     */
+    val middleGoodsNormalList: MutableLiveData<List<GoodsGroupData>> = MutableLiveData()
+
+
+    /**
+     * 用来在现货品种信息的修改,恢复,停用,详情时的页面数据回填
+     */
+    fun initSpotGoodsActivity(respData: DeliveryGoodsDetailData) {
+        val newbrandModelList = arrayListOf<NewSpotInfoData>()//品牌列表
+        val newspotModelList = arrayListOf<NewSpotInfoData>()//品类列表
+        val newmiddlegoodList = arrayListOf<NewSpotInfoData>()//套保品种
+        respData.gmlist?.forEach {//品类列表
+            newspotModelList.add(
+                NewSpotInfoData(
+                    id = respData.gmlist.indexOf(it).plus(1).toString(),
+                    value = it.wrstandardname ?: "",
+                    enumdicname = it.enumdicname ?: "",
+                    enumdicnameid = it.unitid ?: "",
+                    coefficientwarehouse = it.convertfactor ?: "",
+                    middleGoodsId = it.wrstandardid ?: ""
+                )
+            )
+        }
+        respData.gblist?.forEach {//品牌列表
+            newbrandModelList.add(
+                NewSpotInfoData(
+                    id = respData.gblist.indexOf(it).plus(1).toString(),
+                    value = it.brandname ?: "",
+                    middleGoodsId = it.brandid ?: ""
+                )
+            )
+        }
+        respData.mgList?.forEach {//套保品种
+            newmiddlegoodList.add(
+                NewSpotInfoData(
+                    id = respData.mgList.indexOf(it).plus(1).toString(),
+                    value = it.convertratio ?: "",
+                    enumdicnameid = it.mg?.goodsunitid ?: "",
+                    middleGoodsId = it.mg?.goodsgroupid ?: "",
+                    middleGoodsName = it.mg?.middlegoodsname ?: "",
+                    enumdicname = it.mg?.enumdicname ?: ""
+                )
+            )
+        }
+        spotModelcacheList.postValue(newspotModelList)
+        brandModelcacheList.postValue(newbrandModelList)
+
+        brandModelList.postValue(newbrandModelList)
+        spotModelList.postValue(newspotModelList)
+
+    }
+
+
+    /**
+     * 查询期货商品组(原套保品种)
+     * @param wrstandardid String
+     */
+    fun queryGoodsGroup() {
+        val params = mutableMapOf<String, String>().apply {
+            put("userid", GlobalDataCollection.instance?.loginRsp?.userID.toString())
+            put("usertype", GlobalDataCollection.instance?.userAccountData?.usertype?.toString() ?: "")
+//            put("deliverygoodsid", deliverygoodsid)
+        }
+        MyApplication.getInstance()?.futureManager?.queryGoodsGroup(params = params) { isSuccess, respData, _ ->
+            if (isSuccess) {
+                middleGoodsNormalList.postValue(respData)
+            }
+        }
+    }
+
+
+    /**
+     * 品类列表
+     * type 1为添加,2为删除 ,3为更换资料
+     */
+    fun changeSpotModelList(
+        type: String,//类型
+        id: String,//列表下标id
+        value: String = "",//品类名称
+        enumdicname: String = "",//单位名称
+        enumdicnameid: String = "",//单位id
+        coefficientwarehouse: String = ""//标仓系数
+    ) {
+        val oldDatacacheList = spotModelcacheList.value?.toArrayList()
+        val oldDataList = spotModelList.value?.toArrayList()
+        val newDataList = arrayListOf<NewSpotInfoData>()
+        if (type == "1") {//新增
+            oldDatacacheList?.forEach {
+                newDataList.add(it)
+            }
+            newDataList.add(NewSpotInfoData(id = id))
+            spotModelList.postValue(newDataList)
+            spotModelcacheList.postValue(newDataList)
+        } else if (type == "2") {//删除
+            oldDatacacheList?.forEach {
+                if (id.toInt() < it.id.toInt()) {
+                    newDataList.add(it.copy(id = oldDatacacheList.indexOf(it).toString(),value = it.value,coefficientwarehouse = it.coefficientwarehouse))
+                }else if (id.toInt() > it.id.toInt()){
+                    newDataList.add(it.copy(id = oldDatacacheList.indexOf(it).toString(),value = it.value,coefficientwarehouse = it.coefficientwarehouse))
+                }
+            }
+            spotModelList.postValue(newDataList)
+            spotModelcacheList.postValue(newDataList)
+        } else if (type == "3") {//更换资料
+            oldDatacacheList?.forEach {
+                var newValue = ""
+                var newEnumdicnameid = ""
+                var newEnumdicname = ""
+                var newCoefficientwarehouse = ""
+                var newData: NewSpotInfoData
+                if (it.id == id) {
+                    newValue = if (value.isNullOrEmpty()) {
+                        it.value
+                    } else {
+                        value
+                    }
+                    newEnumdicnameid = if (enumdicnameid.isNullOrEmpty()) {
+                        it.enumdicnameid
+                    } else {
+                        enumdicnameid
+                    }
+                    newEnumdicname = if (newEnumdicname.isNullOrEmpty()) {
+                        it.enumdicname
+                    } else {
+                        enumdicname
+                    }
+                    newCoefficientwarehouse = if (coefficientwarehouse.isNullOrEmpty()) {
+                        it.coefficientwarehouse
+                    } else {
+                        coefficientwarehouse
+                    }
+                    newData = it.copy(
+                        id = id,
+                        value = newValue,
+                        enumdicname = newEnumdicname,
+                        coefficientwarehouse = newCoefficientwarehouse,
+                        enumdicnameid = newEnumdicnameid
+                    )
+                    newDataList.add(newData)
+                } else {
+                    newDataList.add(it)
+                }
+            }
+//            spotModelList.postValue(newDataList)
+            spotModelcacheList.postValue(newDataList)
+        }else if (type == "4") {//更换资料
+            oldDatacacheList?.forEach {
+                var newValue = ""
+                var newEnumdicnameid = ""
+                var newEnumdicname = ""
+                var newCoefficientwarehouse = ""
+                var newData: NewSpotInfoData
+                if (it.id == id) {
+                    newValue = if (value.isNullOrEmpty()) {
+                        it.value
+                    } else {
+                        value
+                    }
+                    newEnumdicnameid = if (enumdicnameid.isNullOrEmpty()) {
+                        it.enumdicnameid
+                    } else {
+                        enumdicnameid
+                    }
+                    newEnumdicname = if (enumdicname.isNullOrEmpty()) {
+                        it.enumdicname
+                    } else {
+                        enumdicname
+                    }
+                    newCoefficientwarehouse = if (coefficientwarehouse.isNullOrEmpty()) {
+                        it.coefficientwarehouse
+                    } else {
+                        coefficientwarehouse
+                    }
+                    newData = it.copy(
+                        id = id,
+                        value = newValue,
+                        enumdicname = newEnumdicname,
+                        coefficientwarehouse = newCoefficientwarehouse,
+                        enumdicnameid = newEnumdicnameid
+                    )
+                    newDataList.add(newData)
+                } else {
+                    newDataList.add(it)
+                }
+            }
+            spotModelList.postValue(newDataList)
+            spotModelcacheList.postValue(newDataList)
+        }
+
+    }
+
+    /**
+     * 现货品种品牌列表数据刷新
+     * type 1为添加,2为删除 ,3为更换资料
+     */
+    fun changeBrandModelList(type: String, id: String, value: String) {
+        val oldDataCacheList = brandModelcacheList.value?.toArrayList()
+        val oldDataList = brandModelList.value?.toArrayList()
+        val newDataList = arrayListOf<NewSpotInfoData>()
+        if (type == "1") {
+            oldDataCacheList?.forEach {
+                newDataList.add(it)
+            }
+            newDataList.add(NewSpotInfoData(id = id))
+            brandModelList.postValue(newDataList)
+            brandModelcacheList.postValue(newDataList)
+        } else if (type == "2") {
+            oldDataCacheList?.forEach {
+                if (id.toInt() < it.id.toInt()) {
+                    newDataList.add(it.copy(id = oldDataCacheList.indexOf(it).toString(),value = it.value))
+                }else if (id.toInt() > it.id.toInt()){
+                    newDataList.add(it.copy(id = oldDataCacheList.indexOf(it).toString(),value = it.value))
+                }
+            }
+            brandModelList.postValue(newDataList)
+            brandModelcacheList.postValue(newDataList)
+        } else if (type == "3") {
+            oldDataCacheList?.forEach {
+                if (it.id == id) {
+                    newDataList.add(it.copy(value = value))
+                } else {
+                    newDataList.add(it)
+                }
+            }
+            brandModelcacheList.postValue(newDataList)
+        }
+
+    }
+
+}

+ 233 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/commodity/newspot/NewInsuredVarietyViewHolder.kt

@@ -0,0 +1,233 @@
+package cn.muchinfo.rma.view.base.home.commodity.newspot
+
+import android.view.Gravity
+import android.view.View
+import android.view.inputmethod.EditorInfo
+import android.widget.EditText
+import androidx.appcompat.app.AppCompatActivity
+import cn.muchinfo.rma.R
+import cn.muchinfo.rma.global.MTPEnums
+import cn.muchinfo.rma.global.data.MiddleGoodsData
+import cn.muchinfo.rma.lifecycle.bindOptional
+import cn.muchinfo.rma.view.autoWidget.*
+import cn.muchinfo.rma.view.base.home.commodity.CommodityInformationViewModel
+import cn.muchinfo.rma.view.base.home.commodity.viewholder.SpotInfoData
+import cn.muchinfo.rma.view.base.home.contract.emptyView
+import cn.muchinfo.rma.view.base.home.contract.viewItemUI
+import com.blankj.utilcode.util.ToastUtils
+import mtp.polymer.com.autowidget.adapter.BaseViewHolder
+import mtp.polymer.com.autowidget.dialog.SelectData
+import mtp.polymer.com.autowidget.dialog.creatBottomSheetDialog
+import mtp.polymer.com.autowidget.dialog.creatGoodsHedgeBottomSheetDialog
+import org.jetbrains.anko.*
+import org.jetbrains.anko.sdk25.coroutines.textChangedListener
+
+/**
+ * 现货品种的套保品种选择
+ * @property activity AppCompatActivity
+ * @property viewModel CommodityInformationViewModel
+ * @property operationType String  1 是新增,2是修改,3是停用,4详情 5恢复
+ * @property itemSize IntArray
+ * @constructor
+ */
+class NewInsuredVarietyViewHolder(
+    private val activity: AppCompatActivity,
+    private val viewModel: NewAddSpotGoodsViewModel,
+    private val operationType : String = ""
+) : BaseViewHolder<NewSpotInfoData>(activity) {
+    override val itemSize: IntArray = intArrayOf(matchParent, wrapContent)
+
+    //套保系数
+    lateinit var hedge_coefficient : EditText
+
+    override fun _FrameLayout.createContentView() {
+        verticalLayout {
+            linearLayout {
+                background = resources.getDrawable(R.color.white)
+                gravity = Gravity.CENTER_VERTICAL
+                onThrottleFirstClick {
+                    if (operationType == "4" || operationType == "3" || operationType == "5"){
+                        return@onThrottleFirstClick
+                    }
+
+//                    activity.creatGoodsHedgeBottomSheetDialog("请选择套保品种", viewModel.getRemainingMiddleGoodsList()) {
+//                        viewModel.changeMiddleGoodsList(type = "4",id = data.value?.id.toString(),ano = "",middlegoodsId = this.goodsgroupid ?: "",enumdicnameid = this.goodunitid ?: "",enumdicname = this.enumdicname ?: "" ?: "",middleGoodsName = this.goodsgroupname ?: "")
+//                        hedge_coefficient.setText("")
+//                    }
+                }
+                textView {
+                    text = "*"
+                    textColorInt = R.color.rma_star_color
+                    textSizeAuto = 31
+                }.lparams(wrapContent, wrapContent) {
+                    marginStart = autoSize(37)
+                }
+
+                textView {
+                    data.bindOptional(context) {
+                        text = "套保品种"  + data.value?.id.toString()
+                    }
+                    textSizeAuto = 31
+                    textColorInt = R.color.rma_black_33
+                }.lparams(wrapContent, wrapContent) {
+                    marginStart = autoSize(10)
+                }
+
+                textView {
+                    data.bindOptional(context){
+                        if (it?.middleGoodsName.isNullOrEmpty()){
+                            text = "请选择套保品种"
+                            textColorInt = R.color.rma_hint_text_color_ccc
+                        }else{
+                            text = it?.middleGoodsName
+                            textColorInt = R.color.rma_black_33
+                        }
+                    }
+                    textSizeAuto = 31
+                    textColorInt = R.color.rma_hint_text_color_ccc
+                }.lparams(wrapContent, wrapContent) {
+                    marginStart = autoSize(80)
+                }
+
+                emptyView()
+
+                imageView {
+                    if (operationType == "4"){//页面类型为详情时则需要屏蔽相关操作
+                        visibility = View.GONE
+                    }else{
+                        visibility = View.VISIBLE
+                    }
+                    imageResource = R.mipmap.rma_more
+                }.lparams(autoSize(36), autoSize(36)) {
+                    marginEnd = autoSize(25)
+                }
+            }.lparams(matchParent, autoSize(132))
+
+            viewItemUI()
+
+            //单位
+            linearLayout {
+                background = resources.getDrawable(R.color.white)
+                gravity = Gravity.CENTER_VERTICAL
+
+                textView {
+                    text = "单位"
+                    textSizeAuto = 31
+                    textColorInt = R.color.rma_black_33
+                }.lparams(wrapContent, wrapContent) {
+                    marginStart = autoSize(60)
+                }
+
+                textView {
+                    data.bindOptional(context){data ->
+                        text = data?.enumdicname
+                        textColorInt = R.color.rma_black_33
+                        viewModel.middleGoodsNormalList.value?.forEach {
+                            if (data?.middleGoodsId == it.goodsgroupid){
+                                text = it.goodunitid ?: ""
+                                textColorInt = R.color.rma_black_33
+                            }else{
+                                text = data?.enumdicname
+                            }
+                        }
+//                        if (it?.enumdicname.isNullOrEmpty()){
+//                            text = ""
+//                        }else{
+//
+//                        }
+                    }
+                    text = "请选择套保品种后自动填入"
+                    textSizeAuto = 31
+                    textColorInt = R.color.rma_hint_text_color_ccc
+                }.lparams(wrapContent, wrapContent) {
+                    marginStart = autoSize(150)
+                }
+
+                emptyView()
+
+            }.lparams(matchParent, autoSize(132))
+
+            viewItemUI()
+
+            //折算系数-之前是套保系数(反正改回来改回去的)
+            linearLayout {
+                background = resources.getDrawable(R.color.white)
+                gravity = Gravity.CENTER_VERTICAL
+                textView {
+                    text = "*"
+                    textColorInt = R.color.rma_star_color
+                    textSizeAuto = 31
+                }.lparams(wrapContent, wrapContent) {
+                    marginStart = autoSize(37)
+                }
+
+                textView {
+                    data.bindOptional(context) {
+                        text = "折算系数" + dataIndex.plus(1)
+                    }
+                    textSizeAuto = 31
+                    textColorInt = R.color.rma_black_33
+                }.lparams(wrapContent, wrapContent) {
+                    marginStart = autoSize(10)
+                }
+
+                editText {
+                    hedge_coefficient = this
+                    isEnabled = !(operationType == "4" || operationType == "3" || operationType == "5")
+                    data.bindOptional(context){
+                        if (it?.value.isNullOrEmpty().not()){
+                            setText(it?.value)
+                            textColorInt = R.color.rma_black_33
+                        }
+                    }
+                    hint = "请输入套保系数"
+                    textChangedListener {
+                        afterTextChanged {
+                            if (it.toString().isNotEmpty()) {
+//                                viewModel.changeMiddleGoodsList(
+//                                    "3",
+//                                    data.value?.id.toString(),
+//                                    ano = it.toString()
+//                                )
+                            }
+                        }
+                    }
+                    background = null
+                    inputType = EditorInfo.TYPE_CLASS_TEXT
+                    hintColorStr = "#CCCCCC"
+                    textSizeAuto = 31
+                    textColorStr = "#333333"
+                }.lparams(autoSize(300), autoSize(132)) {
+                    marginStart = autoSize(60)
+                }
+
+                emptyView()
+
+                imageView {
+                    if (operationType == "4"){//页面类型为详情时则需要屏蔽相关操作
+                        visibility = View.GONE
+                    }else{
+                        visibility = View.VISIBLE
+                    }
+                    isEnabled = !(operationType == "4" || operationType == "3" || operationType == "5")
+                    onThrottleFirstClick {
+//                        if (viewModel.middlegoodList.value?.size.toString() == "1") {
+//                            ToastUtils.showLong("最少选择一个套保品种")
+//                            return@onThrottleFirstClick
+//                        }
+//                        viewModel.changeMiddleGoodsList(
+//                            "2",
+//                            dataIndex.plus(1).toString(),
+//                            middlegoodsId = ""
+//                        )
+
+                    }
+                    imageResource = R.mipmap.rma_delete
+                }.lparams(autoSize(30), autoSize(30)) {
+                    marginEnd = autoSize(31)
+                }
+            }.lparams(matchParent, autoSize(132))
+        }
+    }
+
+}

+ 15 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/commodity/newspot/NewSpotInfoData.kt

@@ -0,0 +1,15 @@
+package cn.muchinfo.rma.view.base.home.commodity.newspot
+
+/**
+ * 用于新增现货品种型号,品牌
+ */
+data class NewSpotInfoData(
+    var id : String = "",//用来区分的id
+    var value: String = "",//输入的型号(三期为品类)或者品牌 是套保品牌是此字段代表套保系数
+    var coefficientwarehouse : String = "",//用于输入品类时的标仓系数
+    var middleGoodsId : String = "",//存储套保品种时用来存储套保品种id,其他情况此字段不使用
+    var enumdicname : String = "",//单位名称
+    var enumdicnameid : String = "",//单位id
+    var middleGoodsName : String = "",//套保品种名称
+    var middleGoodsList : List<NewSpotInfoData> = arrayListOf()//商品下的套保品种
+)

+ 127 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/commodity/newspot/NewSpotModelViewHolder.kt

@@ -0,0 +1,127 @@
+package cn.muchinfo.rma.view.base.home.commodity.newspot
+
+import android.annotation.SuppressLint
+import android.view.Gravity
+import android.view.View
+import android.view.inputmethod.EditorInfo
+import androidx.appcompat.app.AppCompatActivity
+import cn.muchinfo.rma.R
+import cn.muchinfo.rma.lifecycle.bindOptional
+import cn.muchinfo.rma.view.autoWidget.*
+import cn.muchinfo.rma.view.base.home.commodity.CommodityInformationViewModel
+import cn.muchinfo.rma.view.base.home.commodity.viewholder.SpotInfoData
+import cn.muchinfo.rma.view.base.home.contract.emptyView
+import com.blankj.utilcode.util.ToastUtils
+import mtp.polymer.com.autowidget.adapter.BaseViewHolder
+import org.jetbrains.anko.*
+import org.jetbrains.anko.sdk25.coroutines.textChangedListener
+
+/**
+ * 输入型号和品牌的适配器
+ * @property activity AppCompatActivity
+ * @property viewModel CommodityInformationViewModel
+ * @property type String 1是型号输入,2是品牌输入
+ * operationType 1 是新增,2是修改,3是停用,4详情 5恢复
+ * @property itemSize IntArray
+ * @constructor
+ */
+class NewSpotModelViewHolder(
+    private val activity: AppCompatActivity,
+    private val viewModel: NewAddSpotGoodsViewModel,
+    private val type : String,
+    private val operationType : String = ""
+): BaseViewHolder<NewSpotInfoData>(activity) {
+    override val itemSize: IntArray = intArrayOf(matchParent, wrapContent)
+
+    @SuppressLint("SetTextI18n")
+    override fun _FrameLayout.createContentView() {
+        linearLayout {
+            background = resources.getDrawable(R.color.white)
+            gravity = Gravity.CENTER_VERTICAL
+            textView {
+                text = "*"
+                textColorInt = R.color.rma_star_color
+                textSizeAuto = 31
+            }.lparams(wrapContent, wrapContent) {
+                marginStart = autoSize(37)
+            }
+
+            textView {
+                data.bindOptional(context){
+                    if (type == "1"){
+                        text = "型号" + dataIndex.plus(1)
+                    }else{
+                        text = "品牌" + dataIndex.plus(1)
+                    }
+                }
+
+                textSizeAuto = 31
+                textColorInt = R.color.rma_black_33
+            }.lparams(wrapContent, wrapContent) {
+                marginStart = autoSize(10)
+            }
+
+            editText {
+                isEnabled = !(operationType == "4" || operationType == "3" || operationType == "5")
+                if (type == "1"){
+                    hint = "请输入型号"
+                }else{
+                    hint = "请输入品牌"
+                }
+                textChangedListener {
+                    afterTextChanged {
+                        if (it.toString().isNotEmpty()){
+                            if (type == "1"){
+                                viewModel.changeSpotModelList("3",dataIndex.plus(1).toString(),it.toString())
+                            }else{
+                                viewModel.changeBrandModelList("3",dataIndex.plus(1).toString(),it.toString())
+                            }
+                        }
+                    }
+                }
+                data.bindOptional(context){
+                    setText(it?.value)
+                }
+                background = null
+                inputType = EditorInfo.TYPE_CLASS_TEXT
+                hintColorStr = "#CCCCCC"
+                textSizeAuto = 31
+                textColorStr = "#333333"
+            }.lparams(autoSize(300), autoSize(132)) {
+                marginStart = autoSize(40)
+            }
+
+            emptyView()
+
+            imageView {
+                if (operationType == "4"){//页面类型为详情时则需要屏蔽相关操作
+                    visibility = View.GONE
+                }else{
+
+                    visibility = View.VISIBLE
+                }
+                isEnabled = !(operationType == "4" || operationType == "3" || operationType == "5")
+                onThrottleFirstClick {
+                    if (type == "1"){
+                        if (viewModel.spotModelList.value?.size.toString() == "1"){
+                            ToastUtils.showLong("最少输入一个型号")
+                            return@onThrottleFirstClick
+                        }
+                        viewModel.changeSpotModelList("2",data.value?.id.toString(),value = "")
+                    }else if (type == "2"){
+                        if (viewModel.brandModelList.value?.size.toString() == "1"){
+                            ToastUtils.showLong("最少输入一个品牌")
+                            return@onThrottleFirstClick
+                        }
+                        viewModel.changeBrandModelList("2",data.value?.id.toString(),value = "")
+                    }
+
+                }
+                imageResource = R.mipmap.rma_delete
+            }.lparams(autoSize(30), autoSize(30)){
+                marginEnd = autoSize(31)
+            }
+        }.lparams(matchParent, autoSize(132))
+    }
+
+}