|
|
@@ -0,0 +1,398 @@
|
|
|
+package cn.muchinfo.rma.view.base.main.invoice
|
|
|
+
|
|
|
+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.WrUserReceiptInfoData
|
|
|
+import cn.muchinfo.rma.lifecycle.bindOptional
|
|
|
+import cn.muchinfo.rma.view.autoWidget.*
|
|
|
+import cn.muchinfo.rma.view.base.BaseActivity
|
|
|
+import cn.muchinfo.rma.view.base.future.trade.itemView
|
|
|
+import cn.muchinfo.rma.view.base.home.contract.emptyView
|
|
|
+import cn.muchinfo.rma.view.base.home.contract.verticalEmptyView
|
|
|
+import com.blankj.utilcode.util.ToastUtils
|
|
|
+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.*
|
|
|
+
|
|
|
+/**
|
|
|
+ * 新建/修改发票抬头页面
|
|
|
+ */
|
|
|
+@Suppress("DEPRECATION")
|
|
|
+class AddInvoiceInformationActivity : BaseActivity<InvoiceInformationViewModel>(){
|
|
|
+
|
|
|
+ //1 是新增 2 是修改 3 是详情
|
|
|
+ val type by lazy { intent.getStringExtra("type") }
|
|
|
+
|
|
|
+ val data by lazy { intent.getParcelableExtra<WrUserReceiptInfoData>("data") as WrUserReceiptInfoData }
|
|
|
+
|
|
|
+ private val dialog by lazy { createLoadingDialog(hintStr = "请求中...") }
|
|
|
+
|
|
|
+ //输入的发票抬头
|
|
|
+ lateinit var invoice_looked_up_edittext : EditText
|
|
|
+
|
|
|
+ //纳税人识别号
|
|
|
+ lateinit var taxpayer_identification_number : EditText
|
|
|
+
|
|
|
+ //银行名称
|
|
|
+ lateinit var bank_name_edit : EditText
|
|
|
+
|
|
|
+ //银行账号
|
|
|
+ lateinit var bank_account : EditText
|
|
|
+
|
|
|
+ //企业地址
|
|
|
+ lateinit var address_edittext : EditText
|
|
|
+
|
|
|
+ //企业电话
|
|
|
+ lateinit var phone_number : EditText
|
|
|
+
|
|
|
+ //选择的发票类型
|
|
|
+ val selectInvoiceType : MutableLiveData<SelectData> = MutableLiveData()
|
|
|
+
|
|
|
+ //页面数据的初始化
|
|
|
+ fun initData(){
|
|
|
+ if (type == "1"){
|
|
|
+ selectInvoiceType.postValue(SelectData(id = "2",value = "企业"))
|
|
|
+ }else{
|
|
|
+ selectInvoiceType.postValue(SelectData(id = data.receipttype ?: "",value = if (data.receipttype == "1"){"个人"}else{"企业"}))
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
+ super.onCreate(savedInstanceState)
|
|
|
+ verticalLayout {
|
|
|
+ background = resources.getDrawable(R.color.segtabment_bg_color)
|
|
|
+ dialog.bindTaskStatus(context, viewModel.loadingDialogStatus)
|
|
|
+ initData()
|
|
|
+ topBar {
|
|
|
+ commonLeftButton()
|
|
|
+ commonTitle {
|
|
|
+ if (type == "1"){
|
|
|
+ text = "新建发票抬头"
|
|
|
+ }else if (type == "2"){
|
|
|
+ text = "修改发票抬头"
|
|
|
+ }else{
|
|
|
+ text = "发票抬头详情"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ onThrottleFirstClick {
|
|
|
+ if (type != "3"){
|
|
|
+ val selectDataList = arrayListOf(
|
|
|
+ SelectData(
|
|
|
+ id = "1",
|
|
|
+ value = "个人"
|
|
|
+ ),
|
|
|
+ SelectData(
|
|
|
+ id = "2",
|
|
|
+ value = "企业"
|
|
|
+ )
|
|
|
+ )
|
|
|
+ creatBottomSheetDialog("请选择发票类型", selectDataList) {
|
|
|
+ selectInvoiceType.postValue(this)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "发票类型"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorInt = R.color.rma_hint_text_color_ccc
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ }
|
|
|
+ }.lparams(autoSize(250), autoSize(132))
|
|
|
+
|
|
|
+ textView {
|
|
|
+ selectInvoiceType.bindOptional(context) {
|
|
|
+ text = it?.value
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorInt = R.color.rma_hint_text_color_ccc
|
|
|
+ }.lparams(wrapContent, wrapContent)
|
|
|
+
|
|
|
+ emptyView()
|
|
|
+
|
|
|
+ imageView {
|
|
|
+ if (type == "3"){
|
|
|
+ visibility = View.GONE
|
|
|
+ }else{
|
|
|
+ visibility = View.VISIBLE
|
|
|
+ }
|
|
|
+ imageResource = R.mipmap.rma_more
|
|
|
+ }.lparams(autoSize(36), autoSize(36)) {
|
|
|
+ marginEnd = autoSize(25)
|
|
|
+ }
|
|
|
+
|
|
|
+ }.lparams(matchParent, autoSize(132))
|
|
|
+
|
|
|
+ itemView()
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "发票抬头"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorInt = R.color.rma_hint_text_color_ccc
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ }
|
|
|
+ }.lparams(autoSize(250), autoSize(132))
|
|
|
+
|
|
|
+ editText {
|
|
|
+ if (type == "2" || type == "3"){
|
|
|
+ setText(data.username)
|
|
|
+ }
|
|
|
+ if (type == "3"){
|
|
|
+ isEnabled = false
|
|
|
+ }
|
|
|
+ invoice_looked_up_edittext = this
|
|
|
+ hint = "抬头名称"
|
|
|
+ background = null
|
|
|
+ inputType = EditorInfo.TYPE_CLASS_TEXT
|
|
|
+// setDecimalInputType()
|
|
|
+ hintColorStr = "#CCCCCC"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorStr = "#333333"
|
|
|
+ }.lparams(matchParent, autoSize(132))
|
|
|
+ }.lparams(matchParent, autoSize(132))
|
|
|
+
|
|
|
+ verticalLayout {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ selectInvoiceType.bindOptional(context){
|
|
|
+ if (it?.id == "1"){
|
|
|
+ visibility = View.GONE
|
|
|
+ }else{
|
|
|
+ visibility = View.VISIBLE
|
|
|
+ }
|
|
|
+ }
|
|
|
+ itemView()
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "税号"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorInt = R.color.rma_hint_text_color_ccc
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ }
|
|
|
+ }.lparams(autoSize(250), autoSize(132))
|
|
|
+
|
|
|
+ editText {
|
|
|
+ if (type == "2" || type == "3"){
|
|
|
+ setText(data.taxpayerid)
|
|
|
+ }
|
|
|
+ if (type == "3"){
|
|
|
+ isEnabled = false
|
|
|
+ }
|
|
|
+ taxpayer_identification_number = this
|
|
|
+ hint = "纳税人识别号"
|
|
|
+ background = null
|
|
|
+ inputType = EditorInfo.TYPE_CLASS_TEXT
|
|
|
+// setDecimalInputType()
|
|
|
+ hintColorStr = "#CCCCCC"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorStr = "#333333"
|
|
|
+ }.lparams(matchParent, autoSize(132))
|
|
|
+ }.lparams(matchParent, autoSize(132))
|
|
|
+
|
|
|
+ itemView()
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "开户银行"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorInt = R.color.rma_hint_text_color_ccc
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ }
|
|
|
+ }.lparams(autoSize(250), autoSize(132))
|
|
|
+
|
|
|
+ editText {
|
|
|
+ if (type == "2" || type == "3"){
|
|
|
+ setText(data.receiptbank)
|
|
|
+ }
|
|
|
+ if (type == "3"){
|
|
|
+ isEnabled = false
|
|
|
+ }
|
|
|
+ bank_name_edit = this
|
|
|
+ hint = "选填"
|
|
|
+ background = null
|
|
|
+ inputType = EditorInfo.TYPE_CLASS_TEXT
|
|
|
+// setDecimalInputType()
|
|
|
+ hintColorStr = "#CCCCCC"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorStr = "#333333"
|
|
|
+ }.lparams(matchParent, autoSize(132))
|
|
|
+ }.lparams(matchParent, autoSize(132))
|
|
|
+
|
|
|
+ itemView()
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "银行账号"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorInt = R.color.rma_hint_text_color_ccc
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ }
|
|
|
+ }.lparams(autoSize(250), autoSize(132))
|
|
|
+
|
|
|
+ editText {
|
|
|
+ if (type == "2" || type == "3"){
|
|
|
+ setText(data.receiptaccount)
|
|
|
+ }
|
|
|
+ if (type == "3"){
|
|
|
+ isEnabled = false
|
|
|
+ }
|
|
|
+ bank_account = this
|
|
|
+ hint = "选填"
|
|
|
+ background = null
|
|
|
+ inputType = EditorInfo.TYPE_CLASS_NUMBER
|
|
|
+// setDecimalInputType()
|
|
|
+ hintColorStr = "#CCCCCC"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorStr = "#333333"
|
|
|
+ }.lparams(matchParent, autoSize(132))
|
|
|
+ }.lparams(matchParent, autoSize(132))
|
|
|
+
|
|
|
+ itemView()
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "企业地址"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorInt = R.color.rma_hint_text_color_ccc
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ }
|
|
|
+ }.lparams(autoSize(250), autoSize(132))
|
|
|
+
|
|
|
+ editText {
|
|
|
+ if (type == "2" || type == "3"){
|
|
|
+ setText(data.address)
|
|
|
+ }
|
|
|
+ if (type == "3"){
|
|
|
+ isEnabled = false
|
|
|
+ }
|
|
|
+ address_edittext = this
|
|
|
+ hint = "选填"
|
|
|
+ background = null
|
|
|
+ inputType = EditorInfo.TYPE_CLASS_TEXT
|
|
|
+// setDecimalInputType()
|
|
|
+ hintColorStr = "#CCCCCC"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorStr = "#333333"
|
|
|
+ }.lparams(matchParent, autoSize(132))
|
|
|
+ }.lparams(matchParent, autoSize(132))
|
|
|
+
|
|
|
+ itemView()
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "企业电话"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorInt = R.color.rma_hint_text_color_ccc
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ }
|
|
|
+ }.lparams(autoSize(250), autoSize(132))
|
|
|
+
|
|
|
+ editText {
|
|
|
+ if (type == "2" || type == "3"){
|
|
|
+ setText(data.contactinfo)
|
|
|
+ }
|
|
|
+ if (type == "3"){
|
|
|
+ isEnabled = false
|
|
|
+ }
|
|
|
+ phone_number = this
|
|
|
+ hint = "选填"
|
|
|
+ background = null
|
|
|
+ inputType = EditorInfo.TYPE_CLASS_NUMBER
|
|
|
+// setDecimalInputType()
|
|
|
+ hintColorStr = "#CCCCCC"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorStr = "#333333"
|
|
|
+ }.lparams(matchParent, autoSize(132))
|
|
|
+ }.lparams(matchParent, autoSize(132))
|
|
|
+ }.lparams(matchParent, wrapContent)
|
|
|
+
|
|
|
+
|
|
|
+ verticalEmptyView()
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ onThrottleFirstClick {
|
|
|
+ if (check()){
|
|
|
+ return@onThrottleFirstClick
|
|
|
+ }
|
|
|
+ viewModel.userReceiptInfoReq(UserName = invoice_looked_up_edittext.text.toString(),
|
|
|
+ ReceiptType = selectInvoiceType.value?.id?.toInt() ?: 0,
|
|
|
+ TaxpayerID = taxpayer_identification_number.text.toString(),
|
|
|
+ ContactInfo = phone_number.text.toString(),
|
|
|
+ ReceiptInfoId = data.autoid?.toLong() ?: 0,
|
|
|
+ ReceiptBank = bank_name_edit.text.toString(),
|
|
|
+ ReceiptAccount = bank_account.text.toString(),
|
|
|
+ Address = address_edittext.text.toString()){
|
|
|
+ finish()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ gravity = Gravity.CENTER
|
|
|
+ backgroundResource = R.mipmap.rma_submit_bg
|
|
|
+ text = "提交"
|
|
|
+ textColorInt = R.color.white
|
|
|
+ textSizeAuto = 38
|
|
|
+ }.lparams(0, autoSize(119),1f) {
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ marginEnd = autoSize(36)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(144))
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ fun check() : Boolean{
|
|
|
+ var returnBoolean = false
|
|
|
+
|
|
|
+ if (invoice_looked_up_edittext.text.toString().isNullOrEmpty()){
|
|
|
+ ToastUtils.showLong("请输入抬头名称")
|
|
|
+ return true
|
|
|
+ }
|
|
|
+
|
|
|
+ if (selectInvoiceType.value?.id == "2"){
|
|
|
+ if (taxpayer_identification_number.text.toString().isNullOrEmpty()){
|
|
|
+ ToastUtils.showLong("请输入纳税人识别号")
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return returnBoolean
|
|
|
+ }
|
|
|
+
|
|
|
+}
|