|
|
@@ -3,10 +3,13 @@ package com.xzjmyk.pm.activity.ui.erp.activity.oa;
|
|
|
import android.content.Context;
|
|
|
import android.content.Intent;
|
|
|
import android.graphics.drawable.BitmapDrawable;
|
|
|
-import android.graphics.drawable.Drawable;
|
|
|
import android.os.Bundle;
|
|
|
import android.os.Handler;
|
|
|
import android.os.Message;
|
|
|
+import android.support.v4.app.Fragment;
|
|
|
+import android.support.v4.app.FragmentManager;
|
|
|
+import android.support.v4.app.FragmentPagerAdapter;
|
|
|
+import android.support.v4.view.ViewPager;
|
|
|
import android.util.Log;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.Menu;
|
|
|
@@ -15,16 +18,15 @@ import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
import android.view.WindowManager;
|
|
|
import android.widget.AdapterView;
|
|
|
-import android.widget.BaseAdapter;
|
|
|
import android.widget.ImageView;
|
|
|
import android.widget.LinearLayout;
|
|
|
import android.widget.ListView;
|
|
|
import android.widget.PopupWindow;
|
|
|
-import android.widget.ScrollView;
|
|
|
import android.widget.SimpleAdapter;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.lidroid.xutils.ViewUtils;
|
|
|
import com.lidroid.xutils.view.annotation.ViewInject;
|
|
|
@@ -36,23 +38,24 @@ import com.xzjmyk.pm.activity.ui.erp.activity.ErpMenActivity;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.activity.crm.TaskAddActivity;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.activity.crm.VisitReportAddActivity;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.activity.crm.VisitReportPlanActivity;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.adapter.OAListAdapter;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.fragment.CalendarFragmet;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.model.Employees;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.net.ViewUtil;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.CommonUtil;
|
|
|
-import com.xzjmyk.pm.activity.ui.erp.util.ListUtils;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.StringUtils;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.view.EmptyLayout;
|
|
|
-import com.xzjmyk.pm.activity.util.CalendarUtils;
|
|
|
import com.xzjmyk.pm.activity.util.DisplayUtil;
|
|
|
import com.xzjmyk.pm.activity.util.TimeUtils;
|
|
|
import com.xzjmyk.pm.activity.util.ToastUtil;
|
|
|
-import com.xzjmyk.pm.activity.view.CalendarView;
|
|
|
import com.xzjmyk.pm.activity.view.MyListView;
|
|
|
+import com.xzjmyk.pm.activity.view.crouton.Crouton;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.HashSet;
|
|
|
import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
@@ -60,153 +63,120 @@ import java.util.Set;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
+import static com.alibaba.fastjson.JSON.parseObject;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Created by pengminggong on 2016/9/27.
|
|
|
+ */
|
|
|
+
|
|
|
public class OAActivity extends BaseActivity implements View.OnClickListener {
|
|
|
- private final int WHAT_LOAD = 0x11;
|
|
|
@ViewInject(R.id.oa_rl_choose)
|
|
|
private LinearLayout oa_rl_choose;
|
|
|
- @ViewInject(R.id.oa_picker)
|
|
|
- private CalendarView picker;
|
|
|
- @ViewInject(R.id.oa_listview)
|
|
|
- private MyListView listview;
|
|
|
+ @ViewInject(R.id.yeas_tv)
|
|
|
+ private TextView yeas_tv;
|
|
|
+ @ViewInject(R.id.day_tv)
|
|
|
+ private TextView day_tv;
|
|
|
+ @ViewInject(R.id.viewPager)
|
|
|
+ private ViewPager viewPager;
|
|
|
@ViewInject(R.id.all_task_num)
|
|
|
- private TextView all_task_num; //所有任务个数
|
|
|
+ private TextView all_task_num;
|
|
|
@ViewInject(R.id.ok_task_num)
|
|
|
- private TextView ok_task_num;//完成任务个数
|
|
|
+ private TextView ok_task_num;
|
|
|
@ViewInject(R.id.uok_task_num)
|
|
|
- private TextView uok_task_num;//未完成个数
|
|
|
- @ViewInject(R.id.ok_scale)
|
|
|
- private ImageView ok_scale;//完成比例
|
|
|
- @ViewInject(R.id.date_tv)
|
|
|
- private TextView date_tv; //当前月份
|
|
|
- @ViewInject(R.id.my_client_log)
|
|
|
- private TextView my_client_log; //我的下属签到日志
|
|
|
- @ViewInject(R.id.my_client_log_tag)
|
|
|
- private View my_client_log_tag;//我的下属工作日志标识
|
|
|
+ private TextView uok_task_num;
|
|
|
+ @ViewInject(R.id.week_tv)
|
|
|
+ private TextView week_tv;
|
|
|
+ @ViewInject(R.id.oa_listview)
|
|
|
+ private MyListView oa_listview;
|
|
|
+
|
|
|
+ @ViewInject(R.id.subord_log)
|
|
|
+ private TextView subord_log;
|
|
|
+ @ViewInject(R.id.my_log)
|
|
|
+ private TextView my_log;
|
|
|
+ @ViewInject(R.id.subord_log_tag)
|
|
|
+ private View subord_log_tag;
|
|
|
@ViewInject(R.id.my_log_tag)
|
|
|
- private View my_log_tag;//我的工作日志标识
|
|
|
- private int tag = 2;
|
|
|
- private int selectDay = -1;
|
|
|
- private ArrayList<OABean> meBeans = null;
|
|
|
- private ArrayList<OABean> otherBeans = null;
|
|
|
- private List<OABean> showOtherBeans = null;
|
|
|
- private MyListViewAdapter adapter;
|
|
|
- private EmptyLayout mEmptyLayout;
|
|
|
-
|
|
|
+ private View my_log_tag;
|
|
|
+ @ViewInject(R.id.ok_scale)
|
|
|
+ private ImageView ok_scale;
|
|
|
+ private EmptyLayout emptyLayout;
|
|
|
+
|
|
|
+ private boolean isCrm = false;
|
|
|
+ private boolean isMe = false;
|
|
|
+ private boolean hasOther = true;
|
|
|
+ private JSONArray meArray; //当月我的数组
|
|
|
+ private JSONArray otherArray; //当月我的下属的数组
|
|
|
+ private OAListAdapter adapter; //当前列表的数据
|
|
|
+ private PagerAdapter pagerAdapter;//当前Viewpager适配器
|
|
|
+ private Date curDate; //当前显示的日期 包含年月日信息
|
|
|
+
|
|
|
+ private Set<Integer> meInt; //我的任务
|
|
|
+ private Set<Integer> otherInt; //我的下属的任务
|
|
|
+ private int posItem; //当前为滑动到的哪个Viewpager
|
|
|
private Handler handler = new Handler() {
|
|
|
@Override
|
|
|
public void handleMessage(Message msg) {
|
|
|
- progressDialog.dismiss();
|
|
|
+ if (progressDialog.isShowing())
|
|
|
+ progressDialog.dismiss();
|
|
|
String message = (String) msg.getData().get("result");
|
|
|
switch (msg.what) {
|
|
|
- case WHAT_LOAD:
|
|
|
- JSONObject jsonObject = JSON.parseObject(message);
|
|
|
- if (jsonObject.isEmpty())
|
|
|
+ case 0x11:
|
|
|
+ JSONObject jsonObject = parseObject(message);
|
|
|
+ if (!jsonObject.containsKey("success") || !jsonObject.getBoolean("success") || jsonObject.isEmpty()) {
|
|
|
+ emptyLayout.showEmpty();
|
|
|
return;
|
|
|
- loadSuccess(jsonObject);
|
|
|
+ }
|
|
|
+ JSONObject chche = null;
|
|
|
+ meArray = new JSONArray();
|
|
|
+ otherArray = new JSONArray();
|
|
|
+ //处理我的
|
|
|
+ if (jsonObject.containsKey("me")) {
|
|
|
+ chche = jsonObject.getJSONObject("me");
|
|
|
+ addJsonToArray(meArray, chche);
|
|
|
+ meInt.clear();
|
|
|
+ if (meArray != null && meArray.size() > 0) {
|
|
|
+ meInt.addAll(getDay(meArray));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //处理下属
|
|
|
+ if (jsonObject.containsKey("other")) {
|
|
|
+ chche = jsonObject.getJSONObject("other");
|
|
|
+ addJsonToArray(otherArray, chche);
|
|
|
+ otherInt.clear();
|
|
|
+ if (otherArray != null && otherArray.size() > 0) {
|
|
|
+ otherInt.addAll(getDay(otherArray));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ loadSuccess();
|
|
|
+ break;
|
|
|
+ case 0x12:
|
|
|
+ JSONArray array = JSON.parseObject(message).getJSONArray("datas");//获取到数据
|
|
|
+ if (array == null || array.size() <= 0) {//无下属
|
|
|
+ hasOther = false;
|
|
|
+ chaneTAG(true);
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- /**
|
|
|
- * 下拉网络数据成功
|
|
|
- *
|
|
|
- * @param jsonObject
|
|
|
- */
|
|
|
- private void loadSuccess(JSONObject jsonObject) {
|
|
|
- Map<Integer, String> map = null;
|
|
|
- //获取下属数据
|
|
|
- JSONObject jsonOther = jsonObject.containsKey("other") ? jsonObject.getJSONObject("other") : null;
|
|
|
- if (jsonOther != null) {
|
|
|
- map = new HashMap<>();
|
|
|
- map.put(1, jsonOther.containsKey("task") ? jsonOther.getJSONArray("task").toString() : null);
|
|
|
- map.put(2, jsonOther.containsKey("schedule") ? jsonOther.getJSONArray("schedule").toString() : null);
|
|
|
- map.put(3, jsonOther.containsKey("visitPlan") ? jsonOther.getJSONArray("visitPlan").toString() : null);
|
|
|
- otherBeans = dealingData(map);
|
|
|
- }
|
|
|
- //我的数据
|
|
|
- JSONObject jsonMe = jsonObject.containsKey("me") ? jsonObject.getJSONObject("me") : null;
|
|
|
- if (jsonOther != null) {
|
|
|
- map = new HashMap<>();
|
|
|
- map.put(1, jsonMe.containsKey("task") ? jsonMe.getJSONArray("task").toString() : null);
|
|
|
- map.put(2, jsonMe.containsKey("schedule") ? jsonMe.getJSONArray("schedule").toString() : null);
|
|
|
- map.put(3, jsonMe.containsKey("visitPlan") ? jsonMe.getJSONArray("visitPlan").toString() : null);
|
|
|
- meBeans = dealingData(map);
|
|
|
- }
|
|
|
- Calendar c = Calendar.getInstance();
|
|
|
- ArrayList<OABean> chche = new ArrayList<>();
|
|
|
- for (OABean b : tag == 1 ? meBeans : otherBeans) {
|
|
|
- String time = b.getStartdate() == null ? b.getEnddate() : b.getStartdate();
|
|
|
- if (time == null) continue;
|
|
|
- c.setTimeInMillis(TimeUtils.f_str_2_long(time));
|
|
|
- if (c.get(Calendar.DAY_OF_MONTH) == CalendarUtils.getCurrentDate()) {//当前天的任务
|
|
|
- chche.add(b);
|
|
|
- }
|
|
|
- }
|
|
|
- if (adapter == null) {
|
|
|
- adapter = new MyListViewAdapter(chche);
|
|
|
- listview.setAdapter(adapter);
|
|
|
- } else {
|
|
|
- adapter.setBeans(chche);
|
|
|
- }
|
|
|
- setTaskDay(tag == 1 ? meBeans : otherBeans);
|
|
|
- }
|
|
|
-
|
|
|
- private void setTaskDay(List<OABean> beans) {
|
|
|
+ private Set<Integer> getDay(JSONArray array) {
|
|
|
+ JSONObject object = null;
|
|
|
+ Set<Integer> integers = new HashSet<>();
|
|
|
Calendar c = Calendar.getInstance();
|
|
|
- ArrayList<Integer> tasks = new ArrayList<>();
|
|
|
- for (OABean b : beans) {
|
|
|
- String time = b.getStartdate() == null ? b.getEnddate() : b.getStartdate();
|
|
|
- if (time == null) continue;
|
|
|
- if (getIntent() == null || getIntent().getIntExtra("type", 0) != 1) {//非crm
|
|
|
- c.setTimeInMillis(TimeUtils.f_str_2_long(time));
|
|
|
- tasks.add(c.get(Calendar.DAY_OF_MONTH));
|
|
|
- } else {//crm
|
|
|
- if (b != null && b.getClient() != null) {
|
|
|
- c.setTimeInMillis(TimeUtils.f_str_2_long(time));
|
|
|
- tasks.add(c.get(Calendar.DAY_OF_MONTH));
|
|
|
- }
|
|
|
+ String chche = null;
|
|
|
+ for (int i = 0; i < array.size(); i++) {
|
|
|
+ object = array.getJSONObject(i);
|
|
|
+ chche = (object.containsKey("startdate") && !StringUtils.isEmpty(object.getString("startdate"))) ? object.getString("startdate") : ((
|
|
|
+ object.containsKey("vr_visittime") && !StringUtils.isEmpty(object.getString("vr_visittime"))) ? object.getString("vr_visittime") : null);
|
|
|
+ if (!StringUtils.isEmpty(chche)) {
|
|
|
+ c.setTimeInMillis(TimeUtils.f_str_2_long(chche));
|
|
|
+ integers.add(c.get(Calendar.DAY_OF_MONTH));
|
|
|
}
|
|
|
}
|
|
|
- int[] t = new int[tasks.size()];
|
|
|
- for (int i = 0; i < tasks.size(); i++) {
|
|
|
- t[i] = tasks.get(i);
|
|
|
- }
|
|
|
- picker.setTaskDay(t);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 设置数据到对象中
|
|
|
- *
|
|
|
- * @param map 数据对象
|
|
|
- */
|
|
|
- private ArrayList<OABean> dealingData(Map<Integer, String> map) {
|
|
|
- if (map.isEmpty()) return null;
|
|
|
- ArrayList<OABean> beans = new ArrayList<>();
|
|
|
- Set<Integer> key = map.keySet();
|
|
|
- for (int k : key) {
|
|
|
- if (!map.containsKey(k) || map.get(k) == null || map.get(k).length() <= 0)
|
|
|
- continue;//如果获取没有数据 退出
|
|
|
- List<OABean> chche = JSON.parseArray(map.get(k), OABean.class);
|
|
|
- if (chche == null || chche.size() <= 0) continue;
|
|
|
- for (int i = 0; i < chche.size(); i++)
|
|
|
- chche.get(i).setType(k);
|
|
|
- beans.addAll(chche);
|
|
|
- }
|
|
|
- return beans;
|
|
|
+ return integers;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- protected void onCreate(Bundle savedInstanceState) {
|
|
|
- if (getIntent() != null && getIntent().getIntExtra("type", 0) == 1)
|
|
|
- setTheme(R.style.CrmThemeVisit);
|
|
|
- super.onCreate(savedInstanceState);
|
|
|
- Log.i(TAG, "onCreate:");
|
|
|
- setContentView(R.layout.activity_oa);
|
|
|
- ViewUtils.inject(this);
|
|
|
- getSupportActionBar().setTitle("办公自动化");
|
|
|
- initView();
|
|
|
- }
|
|
|
|
|
|
@Override
|
|
|
public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
@@ -222,153 +192,276 @@ public class OAActivity extends BaseActivity implements View.OnClickListener {
|
|
|
return super.onOptionsItemSelected(item);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
- if (data == null) return;
|
|
|
- if (requestCode == 0x11 && 0x11 == resultCode) {
|
|
|
+ if (requestCode == 0x20) {
|
|
|
+ loadNetData(TimeUtils.ym_format.format(curDate));
|
|
|
+ } else if (requestCode == 0x11 && resultCode == 0x11) {
|
|
|
+ if (data == null) return;
|
|
|
Employees entity = data.getParcelableExtra("data");
|
|
|
- if (entity == null || entity.getEm_name() == null) return;
|
|
|
- my_client_log.setText(entity.getEm_name());
|
|
|
- //下属选项
|
|
|
- if (otherBeans == null) {
|
|
|
- adapter.setBeans(new ArrayList<OABean>());
|
|
|
- return;
|
|
|
- }
|
|
|
- List<OABean> chche = new ArrayList<>();
|
|
|
- String name = "," + entity.getEm_name().trim() + ",";
|
|
|
- if (name == null) return;
|
|
|
- String nameStr;
|
|
|
- for (OABean e : otherBeans) {
|
|
|
- if (e.getHandler() != null) {//任务日程
|
|
|
- if (e.getHandler() == null || e.getHandler().length() <= 0) continue;
|
|
|
- nameStr = "," + e.getHandler().trim() + ",";
|
|
|
- if (getResult(nameStr, name)) {//是该下属任务日程
|
|
|
- chche.add(e);
|
|
|
- }
|
|
|
- } else if (e.getRecordman() != null) {//拜访
|
|
|
- if (e.getRecordman() == null || e.getRecordman().length() <= 0) continue;
|
|
|
- nameStr = "," + e.getRecordman().trim() + ",";
|
|
|
- if (getResult(nameStr, name)) {//是该下属任务日程
|
|
|
- chche.add(e);
|
|
|
+ if (entity == null) return;
|
|
|
+ //TODO 选择下属后返回
|
|
|
+ String otherName = entity.getEm_name();
|
|
|
+ if (!StringUtils.isEmpty(otherName)) {
|
|
|
+ JSONArray array = new JSONArray();
|
|
|
+ for (int i = 0; i < otherArray.size(); i++) {
|
|
|
+ JSONObject object = otherArray.getJSONObject(i);
|
|
|
+ String name = "," + (object.containsKey("handler") ? object.getString("handler") :
|
|
|
+ (object.containsKey("recordman") ? object.getString("recordman") :
|
|
|
+ (object.containsKey("visitman") ? object.getString("visitman") : ""))) + ",";
|
|
|
+ if (StringUtils.isEmpty(otherName)//没有选择下属
|
|
|
+ || getIsDecorat(name, "," + otherName + ",")) {
|
|
|
+ array.add(object);
|
|
|
}
|
|
|
}
|
|
|
+ Set<Integer> aa = getDay(array);
|
|
|
+ setDateToListener(aa);
|
|
|
+ setAdapterBeans(array);
|
|
|
}
|
|
|
- setTaskDay(chche);
|
|
|
- showOtherBeans = chche;
|
|
|
- adapter.setBeans(chche);
|
|
|
- }
|
|
|
- if (requestCode == 0x20 && 0x20 == resultCode) {
|
|
|
- loadNetData();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onClick(View view) {
|
|
|
- switch (view.getId()) {
|
|
|
- case R.id.ok_scale: //筛选
|
|
|
- Intent intent = new Intent(ct, UserSelectActivity.class);
|
|
|
- intent.putExtra("single", true);
|
|
|
- intent.putExtra("net", true);
|
|
|
- startActivityForResult(intent, 0x11);
|
|
|
- break;
|
|
|
- case R.id.signin://打卡签到
|
|
|
- startActivity(new Intent(activity, SigninActivity.class));
|
|
|
- break;
|
|
|
- case R.id.outoffice: //外勤签到
|
|
|
- startActivity(new Intent(activity, OutofficeActivity.class));
|
|
|
- break;
|
|
|
- case R.id.meeting://会议管理
|
|
|
- startActivity(new Intent(activity, MeetingActivity.class));
|
|
|
- break;
|
|
|
- case R.id.worklog://工作日志
|
|
|
- startActivity(new Intent(activity, WorkLogsActivity.class));
|
|
|
- break;
|
|
|
- case R.id.stroke://我的行程
|
|
|
- //TODO 审批先不做
|
|
|
- ToastUtil.showToast(activity, "该功能还在内测中");
|
|
|
- break;
|
|
|
- case R.id.erp://考勤单据
|
|
|
- startActivity(new Intent(activity, ErpMenActivity.class));
|
|
|
- break;
|
|
|
- case R.id.outoffice_task://差旅费报销
|
|
|
- ToastUtil.showToast(activity, "该功能还在内测中");
|
|
|
- break;
|
|
|
- case R.id.statistics://考勤统计
|
|
|
- ToastUtil.showToast(activity, "该功能还在内测中");
|
|
|
- break;
|
|
|
- case R.id.my_client_log://我的下属工作日志
|
|
|
- if (tag == 1)
|
|
|
- chaneTAG(false);
|
|
|
- break;
|
|
|
- case R.id.my_log://我的工作日志
|
|
|
- if (tag == 2)
|
|
|
- chaneTAG(true);
|
|
|
- break;
|
|
|
- }
|
|
|
+ protected void onCreate(Bundle savedInstanceState) {
|
|
|
+ setCustomTheme();
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
+ setContentView(R.layout.activity_oamain);
|
|
|
+ ViewUtils.inject(this);
|
|
|
+ initView();
|
|
|
+ initEvent();
|
|
|
}
|
|
|
|
|
|
- private void initView() {
|
|
|
- mEmptyLayout = new EmptyLayout(this, listview);
|
|
|
- mEmptyLayout.setShowLoadingButton(false);
|
|
|
- mEmptyLayout.setShowEmptyButton(false);
|
|
|
- mEmptyLayout.setShowErrorButton(false);
|
|
|
- chaneTAG(false);
|
|
|
- initData();
|
|
|
- setListener();
|
|
|
- selectDay = picker.getDownIndex();
|
|
|
- Log.i("gongpengming", "selectDay=" + selectDay);
|
|
|
- loadNetData();
|
|
|
- listview.setFocusable(false);
|
|
|
+ private void setCustomTheme() {
|
|
|
+ isCrm = getIntent() == null ? false : (getIntent().getIntExtra("type", 0) == 1);
|
|
|
+ if (isCrm) {//crm
|
|
|
+ setTheme(R.style.CrmThemeVisit);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- private void initData() {
|
|
|
-// rootScrollView.requestDisallowInterceptTouchEvent(false);
|
|
|
- picker.setCalendarData(new Date());
|
|
|
- picker.setSelectMore(false);
|
|
|
- adapter = new MyListViewAdapter();
|
|
|
- listview.setAdapter(adapter);
|
|
|
- date_tv.setText(TimeUtils.long2str(System.currentTimeMillis(), "yyyy-MM-dd") + " " + TimeUtils.getWeek(System.currentTimeMillis()));
|
|
|
- //CRM链入 隐藏菜单
|
|
|
- if (getIntent() == null || getIntent().getIntExtra("type", 0) != 1) return;
|
|
|
- oa_rl_choose.setVisibility(View.GONE);
|
|
|
- getSupportActionBar().setTitle("客户拜访");
|
|
|
+ private void initEvent() {
|
|
|
+ findViewById(R.id.signin).setOnClickListener(this);
|
|
|
+ findViewById(R.id.outoffice).setOnClickListener(this);
|
|
|
+ findViewById(R.id.meeting).setOnClickListener(this);
|
|
|
+ findViewById(R.id.worklog).setOnClickListener(this);
|
|
|
+ findViewById(R.id.erp).setOnClickListener(this);
|
|
|
+ findViewById(R.id.stroke).setOnClickListener(this);
|
|
|
+ findViewById(R.id.outtask).setOnClickListener(this);
|
|
|
+ findViewById(R.id.signinlog).setOnClickListener(this);
|
|
|
+ findViewById(R.id.subord_log).setOnClickListener(this);
|
|
|
+ findViewById(R.id.my_log).setOnClickListener(this);
|
|
|
+ findViewById(R.id.ok_scale).setOnClickListener(this);
|
|
|
+ oa_listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
|
|
+ JSONArray array = adapter.getArray();
|
|
|
+ JSONObject object = array.getJSONObject(i);
|
|
|
+ Intent intent = null;
|
|
|
+ if (adapter.isTask(object)) {
|
|
|
+ intent = new Intent(ct, DetailTaskActivity.class);
|
|
|
+ intent.putExtra("description", object.getString("department"));
|
|
|
+ intent.putExtra("isMe", isMe);
|
|
|
+ intent.putExtra("duration", object.getString("department"));
|
|
|
+ intent.putExtra("status", object.getString("status"));
|
|
|
+ intent.putExtra("taskname", object.getString("name"));//名称
|
|
|
+ intent.putExtra("taskemcode", object.getString("recorder"));//发起人
|
|
|
+ intent.putExtra("tasktime", object.getString("startdate"));//发起时间
|
|
|
+ intent.putExtra("performer", object.getString("handler"));//处理人编号
|
|
|
+ intent.putExtra("taskcode", object.getString("taskcode"));//处理人编号
|
|
|
+ intent.putExtra("ra_taskid", String.valueOf(object.getIntValue("ra_taskid")));//取回复内容id
|
|
|
+ intent.putExtra("taskid", String.valueOf(object.getIntValue("ra_id")));//编号
|
|
|
+ intent.putExtra("endtime", object.getString("enddate"));
|
|
|
+ startActivityForResult(intent, isMe ? 0x20 : 0x21);
|
|
|
+ } else if (adapter.isVisit(object)) {
|
|
|
+ intent = new Intent(activity, VisitReportAddActivity.class);
|
|
|
+ intent.putExtra("type", 1);
|
|
|
+ String chche = object.containsKey("status") ? object.getString("status") == null ? "" : object.getString("status") : "";
|
|
|
+ Log.i("gongpengming","chche="+chche);
|
|
|
+ boolean me = (isMe && !"已拜访".equals(chche));
|
|
|
+ Log.i("gongpengming", "me=" + me);
|
|
|
+ intent.putExtra("isMe", me);
|
|
|
+ intent.putExtra("isAgen", true);
|
|
|
+ OABean bean = JSON.parseObject(object.toString(), OABean.class);
|
|
|
+ intent.putExtra("data", bean);
|
|
|
+ startActivityForResult(intent, isMe ? 0x20 : 0x21);
|
|
|
+ } else if (adapter.isVisitRecord(object)) {
|
|
|
+ intent = new Intent(activity, VisitReportAddActivity.class);
|
|
|
+ intent.putExtra("type", 2);
|
|
|
+ String chche = object.containsKey("status") ? object.getString("status") == null ? "" : object.getString("status") : "";
|
|
|
+ Log.i("gongpengming","chche="+chche);
|
|
|
+ boolean me = (isMe && !"已拜访".equals(chche) && !"".equals(chche));
|
|
|
+ Log.i("gongpengming", "me=" + me);
|
|
|
+ intent.putExtra("isMe", me);
|
|
|
+ intent.putExtra("isAgen", true);
|
|
|
+ intent.putExtra("data", object.toString());
|
|
|
+ startActivityForResult(intent, isMe ? 0x20 : 0x21);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
|
|
+ @Override
|
|
|
+ public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onPageSelected(int position) {
|
|
|
+ posItem = position;
|
|
|
+ curDate = date[position];
|
|
|
+ Calendar c = Calendar.getInstance();
|
|
|
+ c.setTime(curDate);
|
|
|
+ setDateTag(curDate);
|
|
|
+ loadNetData(TimeUtils.ym_format.format(curDate));
|
|
|
+ }
|
|
|
|
|
|
+ @Override
|
|
|
+ public void onPageScrollStateChanged(int state) {
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initView() {
|
|
|
+ //设置为空显示列表
|
|
|
+ emptyLayout = new EmptyLayout(ct, oa_listview);
|
|
|
+ emptyLayout.setShowLoadingButton(false);
|
|
|
+ emptyLayout.setShowEmptyButton(false);
|
|
|
+ emptyLayout.setShowErrorButton(false);
|
|
|
+ emptyLayout.setEmptyViewRes(R.layout.oa_empty_list);
|
|
|
+
|
|
|
+ listenerMap = new HashMap<>();
|
|
|
+ curDate = new Date();
|
|
|
+ meInt = new HashSet<>();
|
|
|
+ otherInt = new HashSet<>();
|
|
|
+ String title = "";
|
|
|
+ if (isCrm) {
|
|
|
+ oa_rl_choose.setVisibility(View.GONE);
|
|
|
+ title = "客户拜访";
|
|
|
+ subord_log.setText("下属拜访");
|
|
|
+ my_log.setText("我的拜访");
|
|
|
+ } else {
|
|
|
+ title = "办公自动化";
|
|
|
+ }
|
|
|
+ getSupportActionBar().setTitle(title);
|
|
|
+ adapter = new OAListAdapter(ct);
|
|
|
+ oa_listview.setAdapter(adapter);
|
|
|
+ setDateTag(new Date());
|
|
|
+ getDataByNet();
|
|
|
+ loadNetData(String.valueOf(TimeUtils.ym_long_2_str(System.currentTimeMillis())));
|
|
|
+ //TODO 以下待优化代码
|
|
|
+ posItem = MAX_PAGER / 2;
|
|
|
+ setDate();
|
|
|
+ LinearLayout.LayoutParams linearParams = (LinearLayout.LayoutParams) viewPager.getLayoutParams(); // 取控件mGrid当前的布局参数 搜索
|
|
|
+ linearParams.height = (getResources().getDisplayMetrics().heightPixels * 1 / 3);// 当控件的高强制设成50象素
|
|
|
+ viewPager.setLayoutParams(linearParams); // 使设置好的布局参数应用到控件myGrid
|
|
|
+ pagerAdapter = new PagerAdapter(getSupportFragmentManager());
|
|
|
+ viewPager.setAdapter(pagerAdapter);
|
|
|
+ viewPager.setCurrentItem(MAX_PAGER / 2);
|
|
|
}
|
|
|
|
|
|
- //获取数据
|
|
|
- public void loadNetData() {
|
|
|
+ /**
|
|
|
+ * 获取数据
|
|
|
+ *
|
|
|
+ * @param date 月份 yyyyMM
|
|
|
+ */
|
|
|
+ public void loadNetData(String date) {
|
|
|
+ progressDialog.show();
|
|
|
String url = CommonUtil.getSharedPreferences(ct, "erp_baseurl") + "mobile/crm/gettaskscheduleandvisitplanmsg.action";
|
|
|
//获取网络数据
|
|
|
final Map<String, Object> param = new HashMap<>();
|
|
|
param.put("emcode", CommonUtil.getSharedPreferences(this, "erp_username"));
|
|
|
- param.put("date", TimeUtils.ym_long_2_str(System.currentTimeMillis()));
|
|
|
+ param.put("date", date);
|
|
|
LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
- ViewUtil.httpSendRequest(this, url, param, handler, headers, WHAT_LOAD, null, null, "get");
|
|
|
+ ViewUtil.httpSendRequest(this, url, param, handler, headers, 0x11, null, null, "get");
|
|
|
}
|
|
|
|
|
|
- //判断是否管理员
|
|
|
- private void judgeManager() {
|
|
|
- Map<String, Object> param = new HashMap<>();
|
|
|
- String emcode = CommonUtil.getSharedPreferences(ct, "erp_username");
|
|
|
- String url = CommonUtil.getSharedPreferences(ct, "erp_baseurl") + "mobile/ifadmin.action";
|
|
|
- param.put("emcode", emcode);
|
|
|
+ private void getDataByNet() {
|
|
|
+ progressDialog.show();
|
|
|
+ //获取网络数据
|
|
|
+ String url = CommonUtil.getSharedPreferences(ct, "erp_baseurl") + "mobile/crm/getstaffmsg.action";
|
|
|
+ final Map<String, Object> param = new HashMap<>();
|
|
|
+ param.put("emcode", CommonUtil.getSharedPreferences(ct, "erp_username"));
|
|
|
param.put("sessionId", CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
ViewUtil.httpSendRequest(ct, url, param, handler, headers, 0x12, null, null, "get");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param array 填充的对象
|
|
|
+ * @param chche
|
|
|
+ */
|
|
|
+ private void addJsonToArray(JSONArray array, JSONObject chche) {
|
|
|
+ array.addAll(addJsonToArray(chche, "schedule"));
|
|
|
+ array.addAll(addJsonToArray(chche, "visitPlan"));
|
|
|
+ array.addAll(addJsonToArray(chche, "task"));
|
|
|
+ array.addAll(addJsonToArray(chche, "visitRecord"));
|
|
|
+ }
|
|
|
|
|
|
- private boolean getResult(String text, String str) {
|
|
|
- Pattern p = Pattern.compile(str);
|
|
|
- Matcher m = p.matcher(text);
|
|
|
- return m.find();
|
|
|
+ /*添加json数据到数组里面 区别crm和oa*/
|
|
|
+ private JSONArray addJsonToArray(JSONObject chche, String key) {
|
|
|
+ JSONArray chcheArray = new JSONArray();
|
|
|
+ if (chche.containsKey(key) && chche.getJSONArray(key).size() > 0) {
|
|
|
+ JSONArray a = chche.getJSONArray(key);
|
|
|
+ if (isCrm) {
|
|
|
+ JSONObject o = null;
|
|
|
+ if (adapter == null)
|
|
|
+ adapter = new OAListAdapter(ct);
|
|
|
+ for (int i = 0; i < a.size(); i++) {
|
|
|
+ o = a.getJSONObject(i);
|
|
|
+ if (adapter.isVisit(o) || adapter.isVisitRecord(o))
|
|
|
+ chcheArray.add(o);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ chcheArray = a;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return chcheArray;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void loadSuccess() {//下拉成功后添加到适配器
|
|
|
+ setAdapterBeans();
|
|
|
+ if (isMe) {
|
|
|
+ setDateToListener(meInt);
|
|
|
+ } else {
|
|
|
+ setDateToListener(otherInt);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ private void setAdapterBeans() {
|
|
|
+ setAdapterBeans(isMe ? meArray : otherArray);
|
|
|
+ }
|
|
|
|
|
|
- //需要抽取的代码
|
|
|
+ private void setAdapterBeans(JSONArray array) {
|
|
|
+ if (array == null) return;
|
|
|
+ int ok = 0, size = 0;
|
|
|
+ JSONObject object = null;
|
|
|
+ JSONArray chche = new JSONArray();
|
|
|
+ String time = null;
|
|
|
+ for (int i = 0; i < array.size(); i++) {
|
|
|
+ object = array.getJSONObject(i);
|
|
|
+ time = (object.containsKey("startdate") && !StringUtils.isEmpty(object.getString("startdate"))) ? object.getString("startdate") :
|
|
|
+ ((object.containsKey("vr_visittime") && !StringUtils.isEmpty(object.getString("vr_visittime"))) ? object.getString("vr_visittime") : "");
|
|
|
+ if (!StringUtils.isEmpty(time) && getIsDecorat(time, TimeUtils.s_format.format(curDate))) {//该时间为选择时间
|
|
|
+ //判断是否为该下属
|
|
|
+ chche.add(object);
|
|
|
+ size++;
|
|
|
+ if (!object.containsKey("status") || (object.containsKey("status") && !StringUtils.isEmpty(object.getString("status")) && "已拜访".equals(object.getString("status")) || "已完成".equals(object.getString("status")))) {
|
|
|
+ ok++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (chche.size() <= 0) {
|
|
|
+ emptyLayout.showEmpty();
|
|
|
+ }
|
|
|
+ all_task_num.setText("工作日历 " + size);
|
|
|
+ ok_task_num.setText("已完成 " + ok);
|
|
|
+ uok_task_num.setText("未完成 " + (size - ok));
|
|
|
+ adapter.setArray(chche, isMe);
|
|
|
+ adapter.notifyDataSetChanged();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //弹出菜单
|
|
|
private PopupWindow popupWindow = null;
|
|
|
|
|
|
public void showPopupWindow(View parent) {
|
|
|
@@ -378,11 +471,7 @@ public class OAActivity extends BaseActivity implements View.OnClickListener {
|
|
|
LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
|
view = layoutInflater.inflate(R.layout.pop_crm_list, null);
|
|
|
ListView plist = (ListView) view.findViewById(R.id.mList);
|
|
|
- SimpleAdapter adapter = new SimpleAdapter(
|
|
|
- this,
|
|
|
- getPopData(),
|
|
|
- R.layout.item_pop_list,
|
|
|
- new String[]{"item_name"}, new int[]{R.id.tv_item_name});
|
|
|
+ SimpleAdapter adapter = new SimpleAdapter(ct, getPopData(), R.layout.item_pop_list, new String[]{"item_name"}, new int[]{R.id.tv_item_name});
|
|
|
plist.setAdapter(adapter);
|
|
|
plist.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
@Override
|
|
|
@@ -456,297 +545,150 @@ public class OAActivity extends BaseActivity implements View.OnClickListener {
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
- //设置控件点击事件
|
|
|
- private void setListener() {
|
|
|
- findViewById(R.id.signin).setOnClickListener(this);
|
|
|
- findViewById(R.id.outoffice).setOnClickListener(this);
|
|
|
- findViewById(R.id.meeting).setOnClickListener(this);
|
|
|
- findViewById(R.id.worklog).setOnClickListener(this);
|
|
|
- findViewById(R.id.erp).setOnClickListener(this);
|
|
|
- findViewById(R.id.stroke).setOnClickListener(this);
|
|
|
- findViewById(R.id.outoffice_task).setOnClickListener(this);
|
|
|
- findViewById(R.id.statistics).setOnClickListener(this);
|
|
|
- findViewById(R.id.my_client_log).setOnClickListener(this);
|
|
|
- findViewById(R.id.my_log).setOnClickListener(this);
|
|
|
- findViewById(R.id.ok_scale).setOnClickListener(this);
|
|
|
-
|
|
|
- picker.setOnItemClickListener(new CalendarView.OnItemClickListener() {
|
|
|
- @Override
|
|
|
- public void OnItemClick(int downDate) {
|
|
|
- selectDay = downDate;
|
|
|
- String chche = TimeUtils.long2str(System.currentTimeMillis(), "yyyy-MM") + "-" + (downDate < 10 ? "0" : "") + downDate;
|
|
|
- date_tv.setText(chche + " " + TimeUtils.getWeek(chche));
|
|
|
- Calendar c = Calendar.getInstance();
|
|
|
- selectDay = downDate;
|
|
|
- List<OABean> beans = new ArrayList<>();
|
|
|
- try {
|
|
|
- List<OABean> b;
|
|
|
- if (tag == 1) {
|
|
|
- b = meBeans == null ? new ArrayList<OABean>() : meBeans;
|
|
|
- } else {
|
|
|
- b = showOtherBeans == null ? (otherBeans == null ? new ArrayList<OABean>() : otherBeans) : showOtherBeans;
|
|
|
- }
|
|
|
- for (OABean e : b) {
|
|
|
- if (e.getStartdate() == null) continue;
|
|
|
- c.setTimeInMillis(TimeUtils.f_str_2_long(e.getStartdate()));
|
|
|
- int day = c.get(Calendar.DAY_OF_MONTH);
|
|
|
- if (day == downDate) {//选择那天的任务
|
|
|
- beans.add(e);
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (NullPointerException e) {
|
|
|
- e.printStackTrace();
|
|
|
- } finally {
|
|
|
- adapter.setBeans(beans);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
- @Override
|
|
|
- public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
|
|
- if (tag!=1) return;
|
|
|
- List<OABean> beans = adapter.getBeans();
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- private void setPoithNum(List<OABean> beans) {
|
|
|
- int ok = 0, noOk = 0;
|
|
|
- if (!ListUtils.isEmpty(beans)) {
|
|
|
- for (OABean b : beans) {
|
|
|
- if (StringUtils.isEmpty(b.getStatus())) continue;
|
|
|
- if ("已完成".equals(b.getStatus()) || "已拜访".equals(b.getStatus())) {
|
|
|
- ok++;
|
|
|
- } else {
|
|
|
- noOk++;
|
|
|
- }
|
|
|
+ //设置标签
|
|
|
+ private void chaneTAG(boolean isMe) {
|
|
|
+ this.isMe = isMe;
|
|
|
+ if (isMe) {
|
|
|
+ if (!subord_log.getText().toString().trim().equals("下属工作日历")) {
|
|
|
+ subord_log.setText("下属工作日历");
|
|
|
}
|
|
|
- }
|
|
|
- all_task_num.setText("工作日历:" + (ok + noOk));
|
|
|
- ok_task_num.setText("已完成:" + ok);
|
|
|
- uok_task_num.setText("未完成:" + noOk);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 点击我和我的下属的工作日志中的标识变化
|
|
|
- *
|
|
|
- * @param isMy 是否是 我的工作日志
|
|
|
- */
|
|
|
- private void chaneTAG(boolean isMy) {
|
|
|
- if (isMy) {
|
|
|
- mEmptyLayout.setEmptyMessage("多见一个客户就多一个机会哦");
|
|
|
- showOtherBeans = null;
|
|
|
- if (!my_client_log.getText().toString().trim().equals("下属工作日历")) {
|
|
|
- my_client_log.setText("下属工作日历");
|
|
|
- }
|
|
|
- tag = 1;
|
|
|
+ setDateToListener(meInt);
|
|
|
ok_scale.setVisibility(View.GONE);
|
|
|
my_log_tag.setBackgroundResource(R.color.darkorange);
|
|
|
- my_client_log_tag.setBackgroundDrawable(null);
|
|
|
- if (adapter != null && meBeans != null) {
|
|
|
- adapter.setBeans(meBeans);
|
|
|
- setTaskDay(meBeans);
|
|
|
- }
|
|
|
+ subord_log_tag.setBackgroundDrawable(null);
|
|
|
} else {
|
|
|
- mEmptyLayout.setEmptyMessage("无拜访计划");
|
|
|
- tag = 2;
|
|
|
+ setDateToListener(otherInt);
|
|
|
ok_scale.setVisibility(View.VISIBLE);
|
|
|
- my_client_log_tag.setBackgroundResource(R.color.darkorange);
|
|
|
+ subord_log_tag.setBackgroundResource(R.color.darkorange);
|
|
|
my_log_tag.setBackgroundDrawable(null);
|
|
|
- if (adapter != null && otherBeans != null) {
|
|
|
- adapter.setBeans(otherBeans);
|
|
|
- setTaskDay(otherBeans);
|
|
|
- }
|
|
|
}
|
|
|
+ setAdapterBeans();
|
|
|
}
|
|
|
|
|
|
- //列表适配器
|
|
|
- class MyListViewAdapter extends BaseAdapter {
|
|
|
- private List<OABean> beans;//适配器使用
|
|
|
+ private int MAX_PAGER = 30;
|
|
|
+ private Date[] date = new Date[MAX_PAGER];
|
|
|
|
|
|
- public MyListViewAdapter() {
|
|
|
- }
|
|
|
+ private void setDateTag(Date date) {
|
|
|
+ Calendar c = Calendar.getInstance();
|
|
|
+ c.setTime(date);
|
|
|
+ int yeas = c.get(Calendar.YEAR);
|
|
|
+ int month = c.get(Calendar.MONTH) + 1;
|
|
|
+ int day = c.get(Calendar.DAY_OF_MONTH);
|
|
|
+ yeas_tv.setText(yeas + "年" + month + "月");
|
|
|
+ day_tv.setText(day + "日");
|
|
|
+ week_tv.setText(TimeUtils.getWeek(TimeUtils.s_format.format(date)));
|
|
|
+ }
|
|
|
|
|
|
- public MyListViewAdapter(List<OABean> beans) {
|
|
|
- if (ListUtils.isEmpty(beans) && tag == 1) mEmptyLayout.showEmpty();
|
|
|
- this.beans = getBeans(beans);
|
|
|
+ private void setDate() {
|
|
|
+ //当前天在 MAX_PAGER/2 位置
|
|
|
+ Calendar c = Calendar.getInstance();
|
|
|
+ Date date = new Date();
|
|
|
+ for (int i = 0; i < MAX_PAGER; i++) {
|
|
|
+ c.setTime(date);
|
|
|
+ c.add(Calendar.MONTH, i - (MAX_PAGER / 2));
|
|
|
+ c.set(Calendar.DAY_OF_MONTH, 1);
|
|
|
+ this.date[i] = c.getTime();
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- private List<OABean> getBeans(List<OABean> beans) {
|
|
|
- List<OABean> chche = new ArrayList<>();
|
|
|
- if (beans == null) return null;
|
|
|
- Calendar c = Calendar.getInstance();
|
|
|
- int day = 0;
|
|
|
- if (getIntent() == null || getIntent().getIntExtra("type", 0) != 1) {
|
|
|
- if (selectDay > 0) {
|
|
|
- for (OABean e : beans) {
|
|
|
- if (e.getStartdate() == null) continue;
|
|
|
- c.setTimeInMillis(TimeUtils.f_str_2_long(e.getStartdate()));
|
|
|
- day = c.get(Calendar.DAY_OF_MONTH);
|
|
|
- if (day == selectDay) {//选择那天的任务
|
|
|
- chche.add(e);
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- chche = beans;
|
|
|
- }
|
|
|
- } else {//crm
|
|
|
- //只显示拜访
|
|
|
- for (OABean e : beans) {
|
|
|
- if (e.getStartdate() == null) continue;
|
|
|
- c.setTimeInMillis(TimeUtils.f_str_2_long(e.getStartdate()));
|
|
|
- day = c.get(Calendar.DAY_OF_MONTH);
|
|
|
- if (e != null && e.getClient() != null) {
|
|
|
- if (selectDay <= 0 || day == selectDay)
|
|
|
- chche.add(e);
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ switch (view.getId()) {
|
|
|
+ case R.id.ok_scale: //筛选
|
|
|
+ Intent intent = new Intent(ct, UserSelectActivity.class);
|
|
|
+ intent.putExtra("single", true);
|
|
|
+ intent.putExtra("net", true);
|
|
|
+ startActivityForResult(intent, 0x11);
|
|
|
+ break;
|
|
|
+ case R.id.signin://打卡签到
|
|
|
+ startActivity(new Intent(activity, SigninActivity.class));
|
|
|
+ break;
|
|
|
+ case R.id.outoffice: //外勤签到
|
|
|
+ startActivity(new Intent(activity, OutofficeActivity.class));
|
|
|
+ break;
|
|
|
+ case R.id.meeting://会议管理
|
|
|
+ startActivity(new Intent(activity, MeetingActivity.class));
|
|
|
+ break;
|
|
|
+ case R.id.worklog://工作日志
|
|
|
+ startActivity(new Intent(activity, WorkLogsActivity.class));
|
|
|
+ break;
|
|
|
+ case R.id.stroke://我的行程
|
|
|
+ //TODO 审批先不做
|
|
|
+ ToastUtil.showToast(activity, "该功能还在内测中");
|
|
|
+ break;
|
|
|
+ case R.id.erp://考勤单据
|
|
|
+ startActivity(new Intent(activity, ErpMenActivity.class));
|
|
|
+ break;
|
|
|
+ case R.id.outtask://差旅费报销
|
|
|
+ ToastUtil.showToast(activity, "该功能还在内测中");
|
|
|
+ break;
|
|
|
+ case R.id.signinlog://考勤统计
|
|
|
+ ToastUtil.showToast(activity, "该功能还在内测中");
|
|
|
+ break;
|
|
|
+ case R.id.subord_log://我的下属工作日志
|
|
|
+ if (isMe)
|
|
|
+ if (hasOther) {
|
|
|
+ chaneTAG(false);
|
|
|
+ } else {
|
|
|
+ Crouton.makeText(ct, "当前账号没有下属,如有问题请联系系统管理员");
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
- setPoithNum(chche);
|
|
|
- return chche;
|
|
|
+ break;
|
|
|
+ case R.id.my_log://我的工作日志
|
|
|
+ if (!isMe)
|
|
|
+ chaneTAG(true);
|
|
|
+ break;
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- public List<OABean> getBeans() {
|
|
|
- return beans;
|
|
|
- }
|
|
|
+ public void setDateToListener(Set<Integer> in) {
|
|
|
+ if (listenerMap.containsKey(TimeUtils.ym_format.format(curDate)) && listenerMap.get(TimeUtils.ym_format.format(curDate)) != null)
|
|
|
+ listenerMap.get(TimeUtils.ym_format.format(curDate)).onChange(in);
|
|
|
+ }
|
|
|
|
|
|
- public void setBeans(List<OABean> beans) {
|
|
|
- this.beans = getBeans(beans);
|
|
|
- if (ListUtils.isEmpty(beans)) mEmptyLayout.showEmpty();
|
|
|
- notifyDataSetChanged();
|
|
|
- }
|
|
|
+ class PagerAdapter extends FragmentPagerAdapter {
|
|
|
|
|
|
- @Override
|
|
|
- public int getCount() {
|
|
|
- return beans == null ? 0 : beans.size();
|
|
|
+ public PagerAdapter(FragmentManager fm) {
|
|
|
+ super(fm);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Object getItem(int i) {
|
|
|
- return beans.get(i);
|
|
|
+ public Fragment getItem(int position) {
|
|
|
+ return CalendarFragmet.getInstance(date[position]);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public long getItemId(int i) {
|
|
|
- return i;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public View getView(final int i, View view, ViewGroup viewGroup) {
|
|
|
- Viewholder viewholder = null;
|
|
|
- if (view == null) {
|
|
|
- viewholder = new Viewholder();
|
|
|
- view = LayoutInflater.from(activity).inflate(R.layout.oa_mylistview_item, null);
|
|
|
- viewholder.item_name_tv = (TextView) view.findViewById(R.id.item_name_tv);
|
|
|
- viewholder.item_addr_tv = (TextView) view.findViewById(R.id.item_addr_tv);
|
|
|
- viewholder.item_object_tv = (TextView) view.findViewById(R.id.item_object_tv);
|
|
|
- viewholder.item_remak = (TextView) view.findViewById(R.id.item_remak);
|
|
|
- viewholder.item_doit_tv = (ImageView) view.findViewById(R.id.item_doit_tv);
|
|
|
- viewholder.item_status_tv = (TextView) view.findViewById(R.id.item_status_tv);
|
|
|
- view.setTag(viewholder);
|
|
|
- } else {
|
|
|
- viewholder = (Viewholder) view.getTag();
|
|
|
- }
|
|
|
- viewholder.item_doit_tv.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View view) {
|
|
|
- Intent intent = null;
|
|
|
- chche = beans.get(i);
|
|
|
- if (chche.getType() == 3) {
|
|
|
- intent = new Intent(activity, VisitReportAddActivity.class);
|
|
|
- intent.putExtra("data", chche);
|
|
|
- startActivityForResult(intent, 0x20);
|
|
|
- } else if (chche.getType() == 1 || chche.getType() == 2) {
|
|
|
- intent = new Intent(ct, DetailTaskActivity.class);
|
|
|
- intent.putExtra("description", chche.getDescription());
|
|
|
- intent.putExtra("duration", chche.getDescription());
|
|
|
- intent.putExtra("status", chche.getStatus() + "");
|
|
|
- intent.putExtra("taskname", chche.getName());//名称
|
|
|
- intent.putExtra("taskemcode", chche.getRecorder());//发起人
|
|
|
- intent.putExtra("tasktime", chche.getStartdate());//发起时间
|
|
|
- intent.putExtra("performer", chche.getHandler());//处理人编号
|
|
|
- intent.putExtra("taskcode", chche.getTaskcode());//处理人编号
|
|
|
- intent.putExtra("ra_taskid", chche.getRa_taskid());//取回复内容id
|
|
|
- intent.putExtra("taskid", chche.getRa_id() + "");//编号
|
|
|
- intent.putExtra("endtime", chche.getEnddate());
|
|
|
- startActivityForResult(intent, 0x20);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- bindData(viewholder, i);
|
|
|
- return view;
|
|
|
+ public int getCount() {
|
|
|
+ return MAX_PAGER;
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- private OABean chche;//临时数据
|
|
|
-
|
|
|
- private void bindData(Viewholder viewholder, int i) {
|
|
|
- chche = beans.get(i);
|
|
|
- //处理 viewholder.item_doit_tv 去拜访、补拜访、去显示
|
|
|
- if (tag == 1) {
|
|
|
- if (!StringUtils.isEmpty(chche.getStatus()) && ("已拜访".equals(chche.getStatus()) || "已完成".equals(chche.getStatus()))) {
|
|
|
- viewholder.item_doit_tv.setVisibility(View.GONE);
|
|
|
- } else {
|
|
|
- viewholder.item_doit_tv.setVisibility(View.VISIBLE);
|
|
|
- }
|
|
|
- } else {
|
|
|
- viewholder.item_doit_tv.setVisibility(View.GONE);
|
|
|
- }
|
|
|
- viewholder.item_status_tv.setText(StringUtils.isEmpty(chche.getStatus()) ? "" : chche.getStatus());
|
|
|
- if (!StringUtils.isEmpty(chche.getName())) {//名字
|
|
|
- viewholder.item_name_tv.setText(chche.getName());
|
|
|
- viewholder.item_doit_tv.setImageResource(R.drawable.oa_next);
|
|
|
- } else if (!StringUtils.isEmpty(chche.getClient())) {
|
|
|
- viewholder.item_name_tv.setText(chche.getClient());
|
|
|
- if (!StringUtils.isEmpty(chche.getVisitdate()) && chche.getVisitdate().compareTo(TimeUtils.f_long_2_str(System.currentTimeMillis())) < 0) {
|
|
|
- viewholder.item_doit_tv.setImageResource(R.drawable.oa_doit_agen);
|
|
|
- } else {
|
|
|
- viewholder.item_doit_tv.setImageResource(R.drawable.oa_doit);
|
|
|
- }
|
|
|
- }
|
|
|
- if (chche.getDescription() != null) {//备注
|
|
|
- viewholder.item_remak.setText(chche.getDepartment());
|
|
|
- } else if (chche.getRemark() != null) {
|
|
|
- viewholder.item_remak.setText(chche.getRemark());
|
|
|
- viewholder.item_remak.setVisibility(View.GONE);
|
|
|
- } else {
|
|
|
- viewholder.item_remak.setText("");
|
|
|
- }
|
|
|
- if (chche.getAddress() != null) {//地址
|
|
|
- viewholder.item_addr_tv.setText(chche.getAddress());
|
|
|
- Drawable drawable = getResources().getDrawable(R.drawable.oa_signin);
|
|
|
- drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
|
|
|
- viewholder.item_addr_tv.setCompoundDrawables(drawable, null, null, null);
|
|
|
- } else if (chche.getStartdate() != null) {//开始时间
|
|
|
- viewholder.item_addr_tv.setText(chche.getStartdate() == null ? "未填写" : chche.getStartdate());
|
|
|
- viewholder.item_addr_tv.setCompoundDrawables(null, null, null, null);
|
|
|
- } else {
|
|
|
- viewholder.item_addr_tv.setText("");
|
|
|
- }
|
|
|
-
|
|
|
- if (chche.getHandler() != null) {//对象
|
|
|
- viewholder.item_object_tv.setText(chche.getHandler());
|
|
|
- } else if (chche.getDepartment() != null || chche.getRecordman() != null) {
|
|
|
- String str = chche.getDepartment() == null ? "" : chche.getDepartment() + " -> " + chche.getRecordman() == null ? "" : chche.getRecordman();
|
|
|
- viewholder.item_object_tv.setText(str);
|
|
|
- } else {
|
|
|
- viewholder.item_object_tv.setText("");
|
|
|
- }
|
|
|
+ /*当点击了指定日期(点击日期、滑动时候触发)*/
|
|
|
+ public void setClickDay(Date date) {
|
|
|
+ if (this.date != null && this.date.length > posItem) {
|
|
|
+ this.date[posItem] = date;
|
|
|
+ Calendar c = Calendar.getInstance();
|
|
|
+ c.setTime(this.date[posItem]);
|
|
|
|
|
|
}
|
|
|
+ curDate = date;
|
|
|
+ setDateTag(date);
|
|
|
+ setAdapterBeans();
|
|
|
+ }
|
|
|
|
|
|
- class Viewholder {
|
|
|
- TextView item_name_tv,//名字
|
|
|
- item_addr_tv,//地址
|
|
|
- item_object_tv,//对象
|
|
|
- item_status_tv,//状态
|
|
|
- item_remak;//备注
|
|
|
- ImageView item_doit_tv;//去拜访按钮
|
|
|
- }
|
|
|
+ /*判断*/
|
|
|
+ private boolean getIsDecorat(String text, String chche) {
|
|
|
+ Pattern p = Pattern.compile(chche);//遍历对象
|
|
|
+ Matcher m = p.matcher(text);//遍历源
|
|
|
+ return m.find();
|
|
|
}
|
|
|
|
|
|
+ private Map<String, OnTaskChangeListener> listenerMap;
|
|
|
+
|
|
|
+ public void setListener(String key, OnTaskChangeListener listener) {
|
|
|
+ listenerMap.put(key, listener);
|
|
|
+ }
|
|
|
|
|
|
+ public interface OnTaskChangeListener {
|
|
|
+ void onChange(Set<Integer> in);
|
|
|
+ }
|
|
|
}
|