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

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.EditText;

import com.alibaba.fastjson.JSON;
import com.wd.workoffice.R;
import com.wd.workoffice.app.WorkToolBarActivity;
import com.wd.workoffice.util.WorkUtils;

import java.util.Map;

import androidx.core.widget.NestedScrollView;
import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * author : flexible
 * email : lgd19940421@163.com
 * github: https://github.com/FlexibleXd
 **/
public class MesSearchConditionActivity extends WorkToolBarActivity {
    @BindView(R.id.et_type)
    EditText etType;
    @BindView(R.id.et_name)
    EditText etName;
    @BindView(R.id.et_img_code)
    EditText etImgCode;
    @BindView(R.id.et_spec)
    EditText etSpec;
    @BindView(R.id.et_series)
    EditText etSeries;
    @BindView(R.id.et_weight)
    EditText etWeight;
    @BindView(R.id.et_client)
    EditText etClient;
    @BindView(R.id.et_years)
    EditText etYears;
    @BindView(R.id.et_drawing)
    EditText etDrawing;
    @BindView(R.id.et_section)
    EditText etSection;
    @BindView(R.id.et_steel)
    EditText etSteel;
    private Map<String, Object> param;
    @Override
    protected void initView() {
        ButterKnife.bind(this);
        param = WorkUtils.simpleParam();
    }


    @Override
    protected void initData() {
    }


    @Override
    protected void initEvent() {
    }

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

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_finish, menu);
        return super.onCreateOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.finish:
                if (!TextUtils.isEmpty(etClient.getText().toString())) {
                    param.put("customerUserName", etClient.getText().toString());
                }
                if (!TextUtils.isEmpty(etDrawing.getText().toString())) {
                    param.put("drawingNumberProd", etDrawing.getText().toString());
                }
                if (!TextUtils.isEmpty(etImgCode.getText().toString())) {
                    param.put("drawingNumberProc", etImgCode.getText().toString());
                }
                if (!TextUtils.isEmpty(etName.getText().toString())) {
                    param.put("productName", etName.getText().toString());
                }
                if (!TextUtils.isEmpty(etSection.getText().toString())) {
                    param.put("fractureSurface", etSection.getText().toString());
                }
                if (!TextUtils.isEmpty(etSeries.getText().toString())) {
                    param.put("seriesName", etSeries.getText().toString());
                }
                if (!TextUtils.isEmpty(etSpec.getText().toString())) {
                    param.put("specification", etSpec.getText().toString());
                }
                if (!TextUtils.isEmpty(etSteel.getText().toString())) {
                    param.put("steelGrade", etSteel.getText().toString());
                }
                if (!TextUtils.isEmpty(etType.getText().toString())) {
                    param.put("productType", etType.getText().toString());
                }
                if (!TextUtils.isEmpty(etWeight.getText().toString())) {
                    param.put("weight", etWeight.getText().toString());
                }
                if (!TextUtils.isEmpty(etYears.getText().toString())) {
                    param.put("designedLife", etYears.getText().toString());
                }
                Intent intent = new Intent();
                intent.putExtra("param", JSON.toJSONString(param));
                setResult(10001, intent);
                finish();
                break;
        }
        return super.onOptionsItemSelected(item);
    }


}
