package com.wd.workoffice.ui.activity.mes.user;

import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.wd.workoffice.R;
import com.wd.workoffice.app.BaseBean;
import com.wd.workoffice.app.WorkToolBarActivity;
import com.wd.workoffice.bean.AccountBean;
import com.wd.workoffice.bean.event.AddUserDataEvent;
import com.wd.workoffice.bean.mesBean.UserDataBean;
import com.wd.workoffice.retrofit.RtfUtils;
import com.wd.workoffice.retrofit.WorkObserver;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

import androidx.annotation.Nullable;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import flexible.xd.android_base.network.rtfhttp.Transformer;
import io.reactivex.disposables.Disposable;

/**
 * 用户数据采集，选择炼钢厂
 * author : flexible
 * email : lgd19940421@163.com
 * github: https://github.com/FlexibleXd
 **/
public class MesUserDataAdd2Activity extends WorkToolBarActivity {
    @BindView(R.id.tv_client)
    TextView tvClient;
    @BindView(R.id.rl_client)
    RelativeLayout rlClient;
    @BindView(R.id.tv_factory)
    TextView tvFactory;
    @BindView(R.id.rl_factory)
    RelativeLayout rlFactory;
    @BindView(R.id.tv_company)
    TextView tvCompany;
    @BindView(R.id.tv_manager)
    TextView tvManager;
    private AccountBean dataBean;
    private UserDataBean.ListBean data;

    @Override
    protected void initView() {
        ButterKnife.bind(this);
    }

    @Override
    protected void initData() {
        data = JSON.parseObject(getIntent().getStringExtra("data"), UserDataBean.ListBean.class);
        tvClient.setText(data.getCustomerUserName());
        tvCompany.setText(data.getSalesCompanyName());
        tvManager.setText(data.getSalesManagerName());
    }


    @Override
    protected void initEvent() {
    }

    @Override
    protected int layoutId() {
        return R.layout.activity_mes_user_data_add2;
    }


    @OnClick(R.id.rl_factory)
    public void onViewClicked() {
//        startActivityForResult(MesChooseFactoryActivity.class, 10001);
        startActivity(MesChooseFactoryActivity.class, "data", JSON.toJSONString(data));
    }
    @Override
    public void onStart() {
        super.onStart();
        EventBus.getDefault().register(this);
    }

    @Override
    public void onStop() {
        super.onStop();
        EventBus.getDefault().unregister(this);
    }

    @Subscribe
    public void refresh(AddUserDataEvent event) {
        finish();
    }
}
