content: package com.zhongou.view.examination.approvaldetail;
  
  import android.os.Bundle;
  import android.os.Message;
  import android.util.Log;
  import android.view.View;
  import android.widget.Button;
  import android.widget.LinearLayout;
  import android.widget.RelativeLayout;
  import android.widget.TextView;
  
  import com.zhongou.R;
  import com.zhongou.application.MyApplication;
  import com.zhongou.base.BaseActivity;
  import com.zhongou.common.MyException;
  import com.zhongou.dialog.Loading;
  import com.zhongou.helper.UserHelper;
  import com.zhongou.inject.ViewInject;
  import com.zhongou.model.MyApprovalModel;
  import com.zhongou.model.approvaldetailmodel.TakeDaysOffApvlModel;
  import com.zhongou.utils.PageUtil;
  
  /**
   * 调休
   * Created by sjy on 2016/12/2.
   */
  
  public class TakeDaysOffDetailApvlActivity extends BaseActivity {
      //back
      @ViewInject(id = R.id.layout_back, click = "forBack")
      RelativeLayout layout_back;
      //
      @ViewInject(id = R.id.tv_title)
      TextView tv_title;
      //
      @ViewInject(id = R.id.tv_right)
      TextView tv_right;
  
      //标题
      @ViewInject(id = R.id.tv_startOffTitle)
      TextView tv_startOffTitle;
  
      //调休开始时间
      @ViewInject(id = R.id.tv_offStartTime)
      TextView tv_offStartTime;
  
      //调休结束时间
      @ViewInject(id = R.id.tv_offEndTime)
      TextView tv_offEndTime;
  
      //原工作开始时间
      @ViewInject(id = R.id.tv_orgStartTime)
      TextView tv_orgStartTime;
  
      //原工作调休结束时间
      @ViewInject(id = R.id.tv_orgEndTime)
      TextView tv_orgEndTime;
  
      //说明
      @ViewInject(id = R.id.tv_reason, click = "ReasonExpended")
      TextView tv_reason;
  
      //备注
      @ViewInject(id = R.id.tv_remark, click = "RemarkExpended")
      TextView tv_remark;
  
  
      //申请人
      @ViewInject(id = R.id.tv_ApprovalPerson)
      TextView tv_ApprovalPerson;
  
      //部门
      @ViewInject(id = R.id.tv_approvaldept)
      TextView tv_approvaldept;
  
      //公司
      @ViewInject(id = R.id.tv_approvalCo)
      TextView tv_approvalCo;
  
      //申请时间
      @ViewInject(id = R.id.tv_approvalTime)
      TextView tv_approvalTime;
  
  
      //未审批bottom
      @ViewInject(id = R.id.laytout_decide)
      LinearLayout laytout_decide;
  
      //驳回
      @ViewInject(id = R.id.btn_refulse, click = "forRefulse")
      Button btn_refulse;
  
      //批准
      @ViewInject(id = R.id.btn_commit, click = "toForCommit")
      Button btn_commit;
  
      //转交
      @ViewInject(id = R.id.btn_transfer, click = "forTransfer")
      Button btn_transfer;
  
      //审批bottom
      @ViewInject(id = R.id.laytout_copy)
      LinearLayout laytout_copy;
  
      //抄送
      @ViewInject(id = R.id.btn_copytp, click = "forCopyto")
      Button btn_copytp;
  
      private MyApprovalModel myApprovalModel;
      private TakeDaysOffApvlModel model;
  
  
      //常量
      public static final int POST_SUCCESS = 11;
      public static final int POST_FAILED = 12;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.act_apps_examination_takedaysoff_d2);
          tv_title.setText(getResources().getString(R.string.workRest_d));
          tv_right.setText("");
  
          Bundle bundle = this.getIntent().getExtras();
          myApprovalModel = (MyApprovalModel) bundle.getSerializable("MyApprovalModel");
          Log.d("SJY", "详情MyApprovalModel");
  
          bottomType();
          //
          getDetailData();
          MyApplication.getInstance().addACT(this);
      }
  
      private void setShow(TakeDaysOffApvlModel model) {
          tv_ApprovalPerson.setText(model.getEmployeeName());
          tv_approvaldept.setText(model.getDepartmentName());
          tv_approvalCo.setText(model.getStoreName());
          tv_approvalTime.setText(model.getApplicationCreateTime());
  
          tv_startOffTitle.setText(model.getApplicationTitle());
          tv_offStartTime.setText(model.getStartOffDate());
          tv_offEndTime.setText(model.getEndOffDate());
          tv_orgStartTime.setText(model.getStartTakeDate());
          tv_orgEndTime.setText(model.getEndTakeDate());
          tv_reason.setText(model.getReason());
          tv_remark.setText(model.getRemark());
  
      }
  
      private void bottomType() {
          //
          if (myApprovalModel.getApprovalStatus().contains("1")) {
  
              laytout_decide.setVisibility(View.GONE);
              laytout_copy.setVisibility(View.VISIBLE);
  
          } else {
              laytout_decide.setVisibility(View.VISIBLE);
              laytout_copy.setVisibility(View.GONE);
          }
      }
  
      private void getDetailData() {
          Loading.run(this, new Runnable() {
              @Override
              public void run() {
                  //泛型
                  try {
                      TakeDaysOffApvlModel model1 = new UserHelper<>(TakeDaysOffApvlModel.class)
                              .approvalDetailPost(TakeDaysOffDetailApvlActivity.this,
                                      myApprovalModel.getApplicationID(),
                                      myApprovalModel.getApplicationType());
                      sendMessage(POST_SUCCESS, model1);
                  } catch (MyException e) {
                      e.printStackTrace();
                      sendMessage(POST_FAILED, e.getMessage());
                  }
              }
          });
      }
  
      @Override
      protected void handleMessage(Message msg) {
          super.handleMessage(msg);
          switch (msg.what) {
              case POST_SUCCESS:
                  model = (TakeDaysOffApvlModel) msg.obj;
                  setShow(model);
                  break;
              case POST_FAILED:
                  PageUtil.DisplayToast((String) msg.obj);
                  break;
              default:
                  break;
          }
      }
  
      //驳回
      public void forRefulse(View view) {
          Bundle bundle = new Bundle();
          bundle.putSerializable("MyApprovalModel", myApprovalModel);
          startActivity(CommonDisagreeActivity.class, bundle);
      }
  
      //同意
      public void toForCommit(View view) {
          Bundle bundle = new Bundle();
          bundle.putSerializable("MyApprovalModel", myApprovalModel);
          startActivity(CommonAgreeActivity.class, bundle);
      }
  
      //转交
      public void forTransfer(View view) {
          Bundle bundle = new Bundle();
          bundle.putSerializable("MyApprovalModel", myApprovalModel);
          startActivity(CommonTransfertoActivity.class, bundle);
      }
  
      // 抄送
      public void forCopyto(View view) {
          Bundle bundle = new Bundle();
          bundle.putSerializable("MyApprovalModel", myApprovalModel);
          startActivity(CommonCopytoCoActivity.class, bundle);
      }
  
      /**
       * back
       *
       * @param view
       */
      public void forBack(View view) {
          this.finish();
      }
  
      private boolean isExpend = false;
  
      public void ReasonExpended(View view) {
          if (!isExpend) {
              tv_reason.setMinLines(0);
              tv_reason.setMaxLines(Integer.MAX_VALUE);
              isExpend = true;
          } else {
              tv_reason.setLines(3);
              isExpend = false;
          }
  
      }
  
      private boolean isRemarkExpend = false;
  
      public void RemarkExpended(View view) {
          if (!isRemarkExpend) {
              tv_remark.setMinLines(0);
              tv_remark.setMaxLines(Integer.MAX_VALUE);
              isRemarkExpend = true;
          } else {
              tv_remark.setLines(3);
              isRemarkExpend = false;
          }
  
      }
  }
  