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

import android.os.Bundle;
import android.text.TextUtils;
import android.widget.Button;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.wd.workoffice.R;
import com.wd.workoffice.app.BaseMesBean;
import com.wd.workoffice.app.WorkToolBarActivity;
import com.wd.workoffice.bean.mesBean.MesOrderDetailBean;
import com.wd.workoffice.bean.mesBean.ProBadBean;
import com.wd.workoffice.retrofit.RtfUtils;
import com.wd.workoffice.retrofit.WorkObserver;
import com.wd.workoffice.util.MathUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import flexible.xd.android_base.network.rtfhttp.Transformer;
import flexible.xd.android_base.utils.LogUtils;
import io.reactivex.disposables.Disposable;

/**
 * 质量报告 废品报表 -详情
 * author : flexible
 * email : lgd19940421@163.com
 * github: https://github.com/FlexibleXd
 **/
public class MesReportProBadDetailActivity extends WorkToolBarActivity {


    @BindView(R.id.btn_detail)
    Button btnDetail;
    @BindView(R.id.tv_type)
    TextView tvType;
    @BindView(R.id.tv_num)
    TextView tvNum;
    @BindView(R.id.tv_weight)
    TextView tvWeight;
    @BindView(R.id.tv_bad)
    TextView tvBad;
    @BindView(R.id.tv_coefficient)
    TextView tvCoefficient;
    @BindView(R.id.tv_price)
    TextView tvPrice;
    @BindView(R.id.tv_order_num)
    TextView tvOrderNum;
    @BindView(R.id.tv_reason)
    TextView tvReason;
    @BindView(R.id.tv_cost)
    TextView tvCost;
    private ProBadBean.DataBean dataBean;

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

    @Override
    protected void initData() {
        String data = getIntent().getStringExtra("data");
        if (!TextUtils.isEmpty(data)){
            dataBean = JSON.parseObject(data,ProBadBean.DataBean.class);
            tvType.setText(dataBean.getVariety());
            tvNum.setText(dataBean.getScrapCount()+"");
            tvWeight.setText(MathUtils.converData(dataBean.getScrapWeight(),3));
            tvBad.setText(MathUtils.converData(dataBean.getScrapRate(),3));
//            tvCoefficient.setText(MathUtils.converData(dataBean.getScrapRate(),3));
//            tvPrice.setText();
            tvReason.setText(dataBean.getScapReason());
            tvCost.setText(dataBean.getNonCompliant());
        }
    }

    @Override
    protected void initEvent() {
    }

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


    @OnClick(R.id.btn_detail)
    public void onViewClicked() {
        startActivity(MesReportProActivity.class,
                "beginDate",getIntent().getStringExtra("beginDate"),
                "endDate",getIntent().getStringExtra("endDate"),
                "scapReason",dataBean.getScapReason(),
                "id",dataBean.getSeriesId());
    }
}
