From 693590fcab6cfad9ade638ad5c769d6a740c01bb Mon Sep 17 00:00:00 2001 From: adam Date: Mon, 9 May 2022 17:18:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B9=B3=E6=9D=BF=E7=9D=A3=E5=8A=9E=E4=BA=8B?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../baselib/constant/PathConfig.java | 4 + .../pad/activitys/home/PadMainActivity.java | 4 +- .../home/schedule/ScheduleFragment.java | 4 - .../home/supervise/SuperviseAddFragment.java | 337 ++++++++++++++ .../supervise/SuperviseDetailFragment.java | 192 ++++++++ .../home/supervise/SuperviseFragment.java | 423 ++++++++++++++++++ .../supervise/SuperviseTransactFragment.java | 223 +++++++++ .../main/res/layout/fragment_supervise.xml | 191 ++++++++ .../res/layout/fragment_supervise_add.xml | 265 +++++++++++ .../res/layout/fragment_supervise_detail.xml | 337 ++++++++++++++ .../layout/fragment_supervise_transact.xml | 290 ++++++++++++ 11 files changed, 2264 insertions(+), 6 deletions(-) create mode 100644 oamodule/src/main/java/com/tenlionsoft/oamodule/pad/fragments/home/supervise/SuperviseAddFragment.java create mode 100644 oamodule/src/main/java/com/tenlionsoft/oamodule/pad/fragments/home/supervise/SuperviseDetailFragment.java create mode 100644 oamodule/src/main/java/com/tenlionsoft/oamodule/pad/fragments/home/supervise/SuperviseFragment.java create mode 100644 oamodule/src/main/java/com/tenlionsoft/oamodule/pad/fragments/home/supervise/SuperviseTransactFragment.java create mode 100644 oamodule/src/main/res/layout/fragment_supervise.xml create mode 100644 oamodule/src/main/res/layout/fragment_supervise_add.xml create mode 100644 oamodule/src/main/res/layout/fragment_supervise_detail.xml create mode 100644 oamodule/src/main/res/layout/fragment_supervise_transact.xml diff --git a/baselib/src/main/java/com/tenlionsoft/baselib/constant/PathConfig.java b/baselib/src/main/java/com/tenlionsoft/baselib/constant/PathConfig.java index cc79f03..397ed69 100755 --- a/baselib/src/main/java/com/tenlionsoft/baselib/constant/PathConfig.java +++ b/baselib/src/main/java/com/tenlionsoft/baselib/constant/PathConfig.java @@ -222,4 +222,8 @@ public class PathConfig { public static final String PATH_MODULE_PAD_OA_FRAGMENT_MEETING_EDIT = "/oamodule/fragment/meetingEdit";//发起会议 public static final String PATH_MODULE_PAD_OA_FRAGMENT_MEETING_DETAIL = "/oamodule/fragment/meetingDetail";//发起会议 + public static final String PATH_MODULE_PAD_OA_FRAGMENT_SUPERVISE = "/oamodule/fragment/supervise";//督办事项 + public static final String PATH_MODULE_PAD_OA_FRAGMENT_SUPERVISE_ADD = "/oamodule/fragment/superviseAdd";//发起督办事项 + public static final String PATH_MODULE_PAD_OA_FRAGMENT_SUPERVISE_DETAIL = "/oamodule/fragment/superviseDetail";//督办详情 + public static final String PATH_MODULE_PAD_OA_FRAGMENT_SUPERVISE_TRANSACT = "/oamodule/fragment/superviseTransact";//督办回复 } diff --git a/oamodule/src/main/java/com/tenlionsoft/oamodule/pad/activitys/home/PadMainActivity.java b/oamodule/src/main/java/com/tenlionsoft/oamodule/pad/activitys/home/PadMainActivity.java index 184299c..8e8f5d5 100644 --- a/oamodule/src/main/java/com/tenlionsoft/oamodule/pad/activitys/home/PadMainActivity.java +++ b/oamodule/src/main/java/com/tenlionsoft/oamodule/pad/activitys/home/PadMainActivity.java @@ -319,7 +319,7 @@ public class PadMainActivity extends BaseActivity { * 切换fragment */ private void switchFragment(BaseFragment fragment, String tag) { - FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction(); + FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); if (mCurrentFragment != null) { fragmentTransaction.hide(mCurrentFragment) .setCustomAnimations(R.anim.anim_fade_in, R.anim.anim_fade_out); @@ -419,7 +419,7 @@ public class PadMainActivity extends BaseActivity { List list = mFragments.get(mCurrentItem); list.remove(fragment); getSupportFragmentManager().beginTransaction() - .hide(fragment) + .remove(fragment) .show(list.get(list.size() - 1)) .commit(); } diff --git a/oamodule/src/main/java/com/tenlionsoft/oamodule/pad/fragments/home/schedule/ScheduleFragment.java b/oamodule/src/main/java/com/tenlionsoft/oamodule/pad/fragments/home/schedule/ScheduleFragment.java index d1decce..fe21712 100644 --- a/oamodule/src/main/java/com/tenlionsoft/oamodule/pad/fragments/home/schedule/ScheduleFragment.java +++ b/oamodule/src/main/java/com/tenlionsoft/oamodule/pad/fragments/home/schedule/ScheduleFragment.java @@ -330,7 +330,6 @@ public class ScheduleFragment extends BaseFragment implements @Override public void onCalendarSelect(Calendar calendar, boolean isClick) { - LogUtils.e("日历选择"); mCurrentDay = calendar.getDay(); mCurrentYear = calendar.getYear(); mCurrentMonth = calendar.getMonth(); @@ -359,7 +358,6 @@ public class ScheduleFragment extends BaseFragment implements @Override public void onMonthChange(int year, int month) { - LogUtils.e("月份切换"); mCurrentYear = year; mCurrentMonth = month; mTvYear.setText(mCurrentYear + "年"); @@ -369,14 +367,12 @@ public class ScheduleFragment extends BaseFragment implements @Override public void onYearChange(int year) { - LogUtils.e("年份切换"); mCurrentYear = year; mTvYear.setText(year + "年"); } @Override public void onViewChange(boolean isMonthView) { - LogUtils.e("视图切换"); if (isMonthView) { mCalendarView.setBackgroundColor(Color.WHITE); } else { diff --git a/oamodule/src/main/java/com/tenlionsoft/oamodule/pad/fragments/home/supervise/SuperviseAddFragment.java b/oamodule/src/main/java/com/tenlionsoft/oamodule/pad/fragments/home/supervise/SuperviseAddFragment.java new file mode 100644 index 0000000..69d1ac4 --- /dev/null +++ b/oamodule/src/main/java/com/tenlionsoft/oamodule/pad/fragments/home/supervise/SuperviseAddFragment.java @@ -0,0 +1,337 @@ +package com.tenlionsoft.oamodule.pad.fragments.home.supervise; + +import android.app.ProgressDialog; +import android.content.Context; +import android.content.Intent; +import android.graphics.Color; +import android.text.TextUtils; +import android.view.View; +import android.widget.Button; +import android.widget.CheckBox; +import android.widget.EditText; +import android.widget.TextView; + +import com.alibaba.android.arouter.facade.annotation.Route; +import com.bigkoo.pickerview.builder.OptionsPickerBuilder; +import com.bigkoo.pickerview.builder.TimePickerBuilder; +import com.bigkoo.pickerview.view.OptionsPickerView; +import com.bigkoo.pickerview.view.TimePickerView; +import com.google.gson.Gson; +import com.hjq.toast.ToastUtils; +import com.tenlionsoft.baselib.constant.PathConfig; +import com.tenlionsoft.baselib.core.beans.BaseSuccessBean; +import com.tenlionsoft.baselib.core.retrofit_net.RetrofitManager; +import com.tenlionsoft.baselib.core.retrofit_net.conver.RxTransformer; +import com.tenlionsoft.baselib.core.widget.base.BaseFragment; +import com.tenlionsoft.baselib.utils.ExceptionHandler; +import com.tenlionsoft.baselib.utils.TimeUtils; +import com.tenlionsoft.baselib.utils.UIUtil; +import com.tenlionsoft.oamodule.R; +import com.tenlionsoft.oamodule.R2; +import com.tenlionsoft.oamodule.activity.car.ChooseUserActivity; +import com.tenlionsoft.oamodule.activity.supervise.SelRelevanceOptionActivity; +import com.tenlionsoft.oamodule.beans.SaveSuperviseBean; +import com.tenlionsoft.oamodule.beans.SuperviseRelevanceOptionsListBean; +import com.tenlionsoft.oamodule.beans.SuperviseTypeBean; +import com.tenlionsoft.oamodule.net.OAApi; +import com.tenlionsoft.oamodule.pad.activitys.home.PadMainActivity; + +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +import androidx.activity.result.ActivityResultLauncher; +import androidx.activity.result.contract.ActivityResultContracts; +import butterknife.BindView; +import butterknife.ButterKnife; +import io.reactivex.rxjava3.annotations.NonNull; +import io.reactivex.rxjava3.core.Observer; +import io.reactivex.rxjava3.disposables.Disposable; +import okhttp3.MediaType; +import okhttp3.RequestBody; + +/** + * 作者: adam + * 日期: 2022/5/9 - 15:58 + * 邮箱: itgaojian@163.com + * 描述: 发起督办 + */ +@Route(path = PathConfig.PATH_MODULE_PAD_OA_FRAGMENT_SUPERVISE_ADD) +public class SuperviseAddFragment extends BaseFragment { + + @BindView(R2.id.et_name) + EditText mEtName; + @BindView(R2.id.tv_type) + TextView mTvType; + @BindView(R2.id.tv_end_time) + TextView mTvEndTime; + @BindView(R2.id.tv_relevance) + TextView mTvRelevance; + @BindView(R2.id.tv_users) + TextView mTvUsers; + @BindView(R2.id.et_request) + EditText mEtRequest; + @BindView(R2.id.tv_request_num) + TextView mTvRequestNum; + @BindView(R2.id.cb_notice_msg) + CheckBox mCbNoticeMsg; + @BindView(R2.id.cb_notice_email) + CheckBox mCbNoticeEmail; + @BindView(R2.id.btn_confirm) + Button mBtnConfirm; + + private OptionsPickerView mTypePicker; + private List mTypes; + private SuperviseTypeBean mSelType; + private String mIds; + private String mUserNames; + private SuperviseRelevanceOptionsListBean.RowsBean mSelRelevance; + private PadMainActivity mMainActivity; + private ActivityResultLauncher mOptionsLauncher; + private ActivityResultLauncher mPersonLauncher; + + @Override + protected int getContentViewId() { + return R.layout.fragment_supervise_add; + } + + @Override + protected void setDataToView(View dataView) { + ButterKnife.bind(this, dataView); + setStateView(STATE_SUCCESS); + mSrlView.setEnableLoadMore(false); + mSrlView.setEnableRefresh(false); + setTitleView(true); + mTvFragmentTitle.setText("发起督办"); + mIvFragmentBack.setOnClickListener(v -> mMainActivity.backFragment(1, this)); + initViews(); + } + + + /** + * 初始化页面 + */ + private void initViews() { + mTvType.setOnClickListener(v -> onShowType()); + mTvEndTime.setOnClickListener(v -> onShowDate()); + mTvRelevance.setOnClickListener(v -> { + if (mSelType == null) { + ToastUtils.show("请先选择督办类型"); + } else { + Intent intent = new Intent(mActivity, SelRelevanceOptionActivity.class); + intent.putExtra("isSingle", true); + intent.putExtra("id", mSelType.getTypeCode()); + mOptionsLauncher.launch(intent); + } + }); + mTvUsers.setOnClickListener(v -> { + Intent intent = new Intent(mActivity, ChooseUserActivity.class); + intent.putExtra("isSingle", false); + mPersonLauncher.launch(intent); + }); + mBtnConfirm.setOnClickListener(v -> doConfirm()); + } + + @Override + public void onAttach(@androidx.annotation.NonNull @NotNull Context context) { + super.onAttach(context); + mMainActivity = (PadMainActivity) getActivity(); + mOptionsLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> { + Intent data = result.getData(); + if (data == null) return; + //关联事项 + mSelRelevance = (SuperviseRelevanceOptionsListBean.RowsBean) data.getSerializableExtra("bean"); + mTvRelevance.setText(mSelRelevance.getDataTitle()); + });//关联事项 + mPersonLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> { + Intent data = result.getData(); + if (data == null) return; + //督办人员 + mIds = data.getStringExtra("id"); + mUserNames = data.getStringExtra("name"); + mTvUsers.setText(mUserNames); + });//督办人员 + + } + + /** + * 督办类型 + */ + private void onShowType() { + mActivity.hideSoftKeyboard(); + if (mTypes != null && mTypes.size() > 0) { + if (mTypePicker == null) { + mTypePicker = new OptionsPickerBuilder(mActivity, (o1, o2, o3, v) -> { + mSelType = mTypes.get(o1); + mTvType.setText(mSelType.getTypeName()); + + }) + .setTitleText("请选择") + .setCancelColor(Color.parseColor("#1189FF")) + .setSubmitColor(Color.parseColor("#1189FF")) + .setTitleColor(Color.parseColor("#1189FF")) + .build(); + mTypePicker.setPicker(mTypes); + } + mTypePicker.show(); + } else { + getSuperviseTypeList(); + } + } + + private void getSuperviseTypeList() { + ProgressDialog dialog = UIUtil.initDialog(mActivity, "加载中..."); + dialog.show(); + RetrofitManager.getInstance() + .create(OAApi.class) + .getSuperviseTypeList() + .compose(RxTransformer.getTransformer()) + .subscribe(new Observer>() { + @Override + public void onSubscribe(@NonNull Disposable d) { + + } + + @Override + public void onNext(@NonNull List superviseTypeBeans) { + if (dialog.isShowing()) dialog.dismiss(); + if (superviseTypeBeans.size() > 0) { + mTypes = superviseTypeBeans; + onShowType(); + } else { + ToastUtils.show("暂无数据"); + } + } + + @Override + public void onError(@NonNull Throwable e) { + if (dialog.isShowing()) dialog.dismiss(); + ExceptionHandler.handleException(e); + } + + @Override + public void onComplete() { + + } + }); + } + + private void onShowDate() { + TimePickerView mTimePickerView = new TimePickerBuilder(mActivity, (date, v) -> { + //判断时间大小 + mTvEndTime.setText(TimeUtils.date2String(date)); + }) + .setTitleText("请选时间") + .setCancelColor(Color.parseColor("#1189FF")) + .setSubmitColor(Color.parseColor("#1189FF")) + .isDialog(false) + .setType(new boolean[]{true, true, true, true, true, true}) + .setTitleColor(Color.parseColor("#1189FF")) + .build(); + mTimePickerView.show(); + } + + + private void doConfirm() { + if (checkParams()) { + ProgressDialog dialog = UIUtil.initDialog(mActivity, "提交中..."); + dialog.show(); + RequestBody body = buildParams(); + RetrofitManager.getInstance() + .create(OAApi.class) + .doSaveSupervise(body) + .compose(RxTransformer.getTransformer()) + .subscribe(new Observer() { + @Override + public void onSubscribe(@NonNull Disposable d) { + + } + + @Override + public void onNext(@NonNull BaseSuccessBean baseSuccessBean) { + if (dialog.isShowing()) dialog.dismiss(); + ToastUtils.show("保存成功"); + BaseFragment preFragment = mMainActivity.getPreFragment(); + if (null != preFragment) { + preFragment.mIsRefresh = true; + } + mMainActivity.backFragment(1, SuperviseAddFragment.this); + } + + @Override + public void onError(@NonNull Throwable e) { + if (dialog.isShowing()) dialog.dismiss(); + ExceptionHandler.handleException(e); + } + + @Override + public void onComplete() { + + } + }); + } + } + + private boolean checkParams() { + String name = mEtName.getText().toString().trim(); + if (TextUtils.isEmpty(name)) { + ToastUtils.show("请输入督办名称"); + return false; + } + String endTime = mTvEndTime.getText().toString().trim(); + if (TextUtils.isEmpty(endTime)) { + ToastUtils.show("请选择完成时限"); + return false; + } + if (TextUtils.isEmpty(mIds)) { + ToastUtils.show("请选择督办人员"); + return false; + } + String request = mEtRequest.getText().toString().trim(); + if (TextUtils.isEmpty(request)) { + ToastUtils.show("请输入督办内容"); + return false; + } + return true; + } + + private RequestBody buildParams() { + SaveSuperviseBean bean = new SaveSuperviseBean(); + String name = mEtName.getText().toString().trim(); + bean.setOverseeTitle(name); + if (mSelType != null) { + bean.setOverseeType(mSelType.getOverseeTypeId()); + } + String endTime = mTvEndTime.getText().toString().trim(); + bean.setOverseeCompleteTime(endTime); + if (mSelRelevance != null) { + bean.setOverseeItemId(mSelRelevance.getDataId()); + bean.setOverseeItemName(mSelRelevance.getDataTitle()); + } + bean.setOverseeUserIds(mIds.replace(",", "_")); + bean.setOverseeUserNames(mUserNames); + String reqeust = mEtRequest.getText().toString().trim(); + bean.setOverseeContent(reqeust); + StringBuilder notice = new StringBuilder(); + if (mCbNoticeMsg.isChecked()) { + notice.append("1").append(","); + } + if (mCbNoticeEmail.isChecked()) { + notice.append("2"); + } + if (!TextUtils.isEmpty(notice.toString().trim())) { + bean.setOverseeNoticeType(notice.toString().trim()); + } + return RequestBody.create(new Gson().toJson(bean), MediaType.parse("application/json; charset=utf-8")); + } + + @Override + protected void refreshView() { + + } + + @Override + protected void loadMoreData() { + + } +} diff --git a/oamodule/src/main/java/com/tenlionsoft/oamodule/pad/fragments/home/supervise/SuperviseDetailFragment.java b/oamodule/src/main/java/com/tenlionsoft/oamodule/pad/fragments/home/supervise/SuperviseDetailFragment.java new file mode 100644 index 0000000..d9c1b86 --- /dev/null +++ b/oamodule/src/main/java/com/tenlionsoft/oamodule/pad/fragments/home/supervise/SuperviseDetailFragment.java @@ -0,0 +1,192 @@ +package com.tenlionsoft.oamodule.pad.fragments.home.supervise; + +import android.content.Context; +import android.os.Bundle; +import android.text.TextUtils; +import android.view.View; +import android.widget.CheckBox; +import android.widget.LinearLayout; +import android.widget.TextView; + +import com.alibaba.android.arouter.facade.annotation.Route; +import com.tenlionsoft.baselib.constant.PathConfig; +import com.tenlionsoft.baselib.core.retrofit_net.RetrofitManager; +import com.tenlionsoft.baselib.core.retrofit_net.conver.RxTransformer; +import com.tenlionsoft.baselib.core.widget.base.BaseFragment; +import com.tenlionsoft.baselib.utils.ExceptionHandler; +import com.tenlionsoft.oamodule.R; +import com.tenlionsoft.oamodule.R2; +import com.tenlionsoft.oamodule.beans.SuperviseBean; +import com.tenlionsoft.oamodule.beans.SuperviseRepectBean; +import com.tenlionsoft.oamodule.net.OAApi; +import com.tenlionsoft.oamodule.pad.activitys.home.PadMainActivity; + +import org.jetbrains.annotations.NotNull; + +import butterknife.BindView; +import butterknife.ButterKnife; +import io.reactivex.rxjava3.annotations.NonNull; +import io.reactivex.rxjava3.core.Observer; +import io.reactivex.rxjava3.disposables.Disposable; + +/** + * 作者: adam + * 日期: 2022/5/9 - 16:27 + * 邮箱: itgaojian@163.com + * 描述: 督办详情 + */ +@Route(path = PathConfig.PATH_MODULE_PAD_OA_FRAGMENT_SUPERVISE_DETAIL) +public class SuperviseDetailFragment extends BaseFragment { + @BindView(R2.id.tv_name) + TextView mTvName; + @BindView(R2.id.tv_type) + TextView mTvType; + @BindView(R2.id.tv_end_time) + TextView mTvEndTime; + @BindView(R2.id.tv_relevance) + TextView mTvRelevance; + @BindView(R2.id.tv_users) + TextView mTvUsers; + @BindView(R2.id.tv_request) + TextView mTvRequest; + @BindView(R2.id.cb_notice_msg) + CheckBox mCbNoticeMsg; + @BindView(R2.id.cb_notice_email) + CheckBox mCbNoticeEmail; + @BindView(R2.id.tv_repect_content) + TextView mTvRepectContent; + @BindView(R2.id.ll_repect) + LinearLayout mLlRepect; + private String mId; + private String mUserId; + private PadMainActivity mMainActivity; + + @Override + protected int getContentViewId() { + return R.layout.fragment_supervise_detail; + } + + @Override + protected void setDataToView(View dataView) { + ButterKnife.bind(this, dataView); + setTitleView(true); + mTvFragmentTitle.setText("督办详情"); + mIvFragmentBack.setOnClickListener(v -> mMainActivity.backFragment(1, this)); + Bundle bundle = getArguments(); + if (bundle != null) { + mId = bundle.getString("id"); + mUserId = bundle.getString("userId"); + } + if (!TextUtils.isEmpty(mUserId)) { + getDetailByUserId(); + } else { + getDetailById(); + } + } + + @Override + public void onAttach(@androidx.annotation.NonNull @NotNull Context context) { + super.onAttach(context); + mMainActivity = (PadMainActivity) getActivity(); + } + + private void getDetailById() { + RetrofitManager.getInstance() + .create(OAApi.class) + .getSuperviseDetail(mId) + .compose(RxTransformer.getTransformer()) + .subscribe(new Observer() { + @Override + public void onSubscribe(@NonNull Disposable d) { + + } + + @Override + public void onNext(@NonNull SuperviseBean superviseBean) { + setDataToView(superviseBean); + } + + @Override + public void onError(@NonNull Throwable e) { + setStateView(STATE_ERROR); + ExceptionHandler.handleException(e); + } + + @Override + public void onComplete() { + + } + }); + } + + + private void getDetailByUserId() { + RetrofitManager.getInstance() + .create(OAApi.class) + .getSuperviseRepectDetail(mUserId) + .compose(RxTransformer.getTransformer()) + .subscribe(new Observer() { + @Override + public void onSubscribe(@NonNull Disposable d) { + + } + + @Override + public void onNext(@NonNull SuperviseRepectBean superviseBean) { + setRepectDataToView(superviseBean); + } + + @Override + public void onError(@NonNull Throwable e) { + setStateView(STATE_ERROR); + ExceptionHandler.handleException(e); + } + + @Override + public void onComplete() { + + } + }); + } + + private void setRepectDataToView(SuperviseRepectBean bean) { + setStateView(STATE_SUCCESS); + mSrlView.setEnableRefresh(false); + mSrlView.setEnableLoadMore(false); + mTvName.setText(bean.getOverseeDTO().getOverseeTitle()); + mTvType.setText(bean.getOverseeDTO().getOverseeTypeName()); + mTvEndTime.setText(bean.getOverseeDTO().getOverseeCompleteTime()); + mTvRelevance.setText(bean.getOverseeDTO().getOverseeItemName()); + mTvUsers.setText(bean.getOverseeDTO().getOverseeUserNames()); + mTvRequest.setText(bean.getOverseeDTO().getOverseeContent()); + mCbNoticeMsg.setChecked(bean.getOverseeDTO().getOverseeNoticeType().contains("1")); + mCbNoticeEmail.setChecked(bean.getOverseeDTO().getOverseeNoticeType().contains("2")); + mLlRepect.setVisibility(View.VISIBLE); + mTvRepectContent.setText(bean.getContent()); + } + + private void setDataToView(SuperviseBean bean) { + setStateView(STATE_SUCCESS); + mSrlView.setEnableRefresh(false); + mSrlView.setEnableLoadMore(false); + mTvName.setText(bean.getOverseeTitle()); + mTvType.setText(bean.getOverseeTypeName()); + mTvEndTime.setText(bean.getOverseeCompleteTime()); + mTvRelevance.setText(bean.getOverseeItemName()); + mTvUsers.setText(bean.getOverseeUserNames()); + mTvRequest.setText(bean.getOverseeContent()); + mCbNoticeMsg.setChecked(bean.getOverseeNoticeType().contains("1")); + mCbNoticeEmail.setChecked(bean.getOverseeNoticeType().contains("2")); + mLlRepect.setVisibility(View.GONE); + } + + @Override + protected void refreshView() { + + } + + @Override + protected void loadMoreData() { + + } +} diff --git a/oamodule/src/main/java/com/tenlionsoft/oamodule/pad/fragments/home/supervise/SuperviseFragment.java b/oamodule/src/main/java/com/tenlionsoft/oamodule/pad/fragments/home/supervise/SuperviseFragment.java new file mode 100644 index 0000000..287d471 --- /dev/null +++ b/oamodule/src/main/java/com/tenlionsoft/oamodule/pad/fragments/home/supervise/SuperviseFragment.java @@ -0,0 +1,423 @@ +package com.tenlionsoft.oamodule.pad.fragments.home.supervise; + +import android.content.Context; +import android.graphics.Color; +import android.text.TextUtils; +import android.view.View; +import android.view.inputmethod.EditorInfo; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.RadioButton; +import android.widget.RadioGroup; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import com.alibaba.android.arouter.facade.annotation.Route; +import com.bigkoo.pickerview.builder.TimePickerBuilder; +import com.bigkoo.pickerview.view.TimePickerView; +import com.hjq.toast.ToastUtils; +import com.scwang.smart.refresh.layout.SmartRefreshLayout; +import com.tenlionsoft.baselib.constant.PathConfig; +import com.tenlionsoft.baselib.core.retrofit_net.RetrofitManager; +import com.tenlionsoft.baselib.core.retrofit_net.conver.RxTransformer; +import com.tenlionsoft.baselib.core.widget.base.BaseFragment; +import com.tenlionsoft.baselib.core.widget.base.FragmentUtils; +import com.tenlionsoft.baselib.core.widget.views.CustomStateView; +import com.tenlionsoft.baselib.utils.ExceptionHandler; +import com.tenlionsoft.baselib.utils.LogUtils; +import com.tenlionsoft.baselib.utils.TimeUtils; +import com.tenlionsoft.oamodule.R; +import com.tenlionsoft.oamodule.R2; +import com.tenlionsoft.oamodule.adapter.SuperviseAdapter; +import com.tenlionsoft.oamodule.beans.BySuperviseListBean; +import com.tenlionsoft.oamodule.beans.SuperviseBean; +import com.tenlionsoft.oamodule.beans.SuperviseListBean; +import com.tenlionsoft.oamodule.net.OAApi; +import com.tenlionsoft.oamodule.pad.activitys.home.PadMainActivity; + +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.List; + +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import butterknife.BindView; +import butterknife.ButterKnife; +import io.reactivex.rxjava3.annotations.NonNull; +import io.reactivex.rxjava3.core.Observer; +import io.reactivex.rxjava3.disposables.Disposable; + +/** + * 作者: adam + * 日期: 2022/5/9 - 15:38 + * 邮箱: itgaojian@163.com + * 描述: 督办事项 + */ +@Route(path = PathConfig.PATH_MODULE_PAD_OA_FRAGMENT_SUPERVISE) +public class SuperviseFragment extends BaseFragment { + @BindView(R2.id.iv_back) + ImageView mIvBack; + @BindView(R2.id.rb_apply) + RadioButton mRbApply; + @BindView(R2.id.rb_mine) + RadioButton mRbMine; + @BindView(R2.id.rg_type) + RadioGroup mRgType; + @BindView(R2.id.iv_control) + TextView mIvControl; + @BindView(R2.id.rl_content_title) + RelativeLayout mRlContentTitle; + @BindView(R2.id.et_base_search_cancel) + EditText mEtBaseSearchCancel; + @BindView(R2.id.tv_base_search_cancel) + TextView mTvBaseSearchCancel; + @BindView(R2.id.ll_base_search_cancel) + LinearLayout mLlBaseSearchCancel; + @BindView(R2.id.tv_start_date) + TextView mTvStartDate; + @BindView(R2.id.tv_end_date) + TextView mTvEndDate; + @BindView(R2.id.rlv_content) + RecyclerView mRlvContent; + @BindView(R2.id.srl_content) + SmartRefreshLayout mSrlContent; + @BindView(R2.id.csv_state) + CustomStateView mCsvState; + + + private List mDatas; + private int mType = 1;//1我发起的督办 2被督办 + private SuperviseAdapter mAdapter; + private int mCurrentPage = 1; + private String mKeywords = ""; + private PadMainActivity mMainActivity; + + @Override + protected int getContentViewId() { + return R.layout.fragment_supervise; + } + + @Override + protected void setDataToView(View dataView) { + ButterKnife.bind(this, dataView); + setStateView(STATE_SUCCESS); + mSrlView.setEnableRefresh(false); + mSrlView.setEnableLoadMore(false); + + mIvControl.setOnClickListener(v -> { + BaseFragment fragment = FragmentUtils.getFragment(PathConfig.PATH_MODULE_PAD_OA_FRAGMENT_SUPERVISE_ADD); + mMainActivity.addFragment(1, fragment); + }); + mCsvState.setState(CustomStateView.STATE_LOAD); + initViews(); + } + + /** + * 初始化页面 + */ + private void initViews() { + mIvBack.setOnClickListener(v -> mMainActivity.backFragment(1, this)); + mTvStartDate.setOnClickListener(v -> onShowDate(1)); + mTvEndDate.setOnClickListener(v -> onShowDate(2)); + mDatas = new ArrayList<>(); + mAdapter = new SuperviseAdapter(mActivity, mDatas); + mRlvContent.setLayoutManager(new LinearLayoutManager(mActivity)); + mRlvContent.setAdapter(mAdapter); + mRgType.setOnCheckedChangeListener((group, checkedId) -> { + if (checkedId == R.id.rb_apply) { + //我发起的 + mType = 1; + } else if (checkedId == R.id.rb_mine) { + //我接受的 + mType = 2; + } + //重置搜索条件 + resetCondition(); + }); + mSrlContent.setOnRefreshListener(v -> doRefresh()); + mSrlContent.setOnLoadMoreListener(v -> doLoadMore()); + + mAdapter.addOnItemClickListener(o -> { + if (o instanceof SuperviseBean) { + //我发起的督办 + BaseFragment fragmentOne = FragmentUtils.getFragmentOne(PathConfig.PATH_MODULE_PAD_OA_FRAGMENT_SUPERVISE_DETAIL, "id", ((SuperviseBean) o).getOverseeId()); + mMainActivity.addFragment(1, fragmentOne); + } else if (o instanceof BySuperviseListBean.RowsBean) { + //被督办 + if ("nto".equals(((BySuperviseListBean.RowsBean) o).getStatus())) { + //未办结 + BaseFragment fragmentOne = FragmentUtils.getFragmentTwo( + PathConfig.PATH_MODULE_PAD_OA_FRAGMENT_SUPERVISE_TRANSACT, + "id", + ((BySuperviseListBean.RowsBean) o).getOverseeId(), + "userId", + ((BySuperviseListBean.RowsBean) o).getOverseeUserId()); + mMainActivity.addFragment(1, fragmentOne); + } else { + //已办结 + BaseFragment fragmentOne = FragmentUtils.getFragmentTwo( + PathConfig.PATH_MODULE_PAD_OA_FRAGMENT_SUPERVISE_DETAIL, + "id", + ((SuperviseBean) o).getOverseeId(), "userId", ((BySuperviseListBean.RowsBean) o).getOverseeUserId()); + mMainActivity.addFragment(1, fragmentOne); + } + } + }); + doRefresh(); + + mEtBaseSearchCancel.setOnEditorActionListener((v, actionId, event) -> { + LogUtils.e("搜索==" + actionId); + if (actionId == EditorInfo.IME_ACTION_SEARCH) { + mActivity.hideSoftKeyboard(); + mEtBaseSearchCancel.clearFocus(); + mKeywords = v.getText().toString(); + doRefresh(); + return true; + } else { + return false; + } + }); + mTvBaseSearchCancel.setOnClickListener(v -> { + mEtBaseSearchCancel.setText(""); + mEtBaseSearchCancel.clearFocus(); + mTvStartDate.setText(""); + mTvEndDate.setText(""); + mKeywords = ""; + doRefresh(); + }); + } + + @Override + public void onAttach(@androidx.annotation.NonNull @NotNull Context context) { + super.onAttach(context); + mMainActivity = (PadMainActivity) getActivity(); + } + + private void resetCondition() { + mEtBaseSearchCancel.setText(""); + mTvStartDate.setText(""); + mTvEndDate.setText(""); + mCsvState.setState(CustomStateView.STATE_LOAD); + doRefresh(); + } + + /** + * 时间选择 + */ + private void onShowDate(int i) { + TimePickerView mTimePickerView = new TimePickerBuilder(mActivity, (date, v) -> { + switch (i) { + case 1: + mTvStartDate.setText(TimeUtils.dateToString(date)); + break; + case 2: + //判断时间大小 + String start = mTvStartDate.getText().toString().trim(); + int span = TimeUtils.compareDate(date, TimeUtils.stringToDate(start)); + if (span >= 0) { + mTvEndDate.setText(TimeUtils.dateToString(date)); + mCsvState.setState(CustomStateView.STATE_LOAD); + doRefresh(); + } else { + ToastUtils.show("结束时间须大于开始时间"); + } + break; + } + }) + .setTitleText("请选时间") + .setCancelColor(Color.parseColor("#1189FF")) + .setSubmitColor(Color.parseColor("#1189FF")) + .isDialog(false) + .setType(new boolean[]{true, true, true, false, false, false}) + .setTitleColor(Color.parseColor("#1189FF")) + .build(); + mTimePickerView.show(); + } + + /** + * 加载更多 + */ + private void doLoadMore() { + if (mType == 1) { + getMineApplyList(mCurrentPage); + } else { + getBySuperviseList(mCurrentPage); + } + } + + + /** + * 刷新 + */ + private void doRefresh() { + mDatas.clear(); + mAdapter.setData(mDatas); + mCsvState.setState(CustomStateView.STATE_LOAD); + if (mType == 1) { + getMineApplyList(1); + } else { + getBySuperviseList(1); + } + } + + + private void getMineApplyList(int currentPage) { + mCurrentPage = currentPage; + String start = mTvStartDate.getText().toString().trim(); + String end = mTvEndDate.getText().toString().trim(); + RetrofitManager.getInstance() + .create(OAApi.class) + .getMineApplySuperviseList(start, end, mKeywords, mCurrentPage + "") + .compose(RxTransformer.getTransformer()) + .subscribe(new Observer() { + @Override + public void onSubscribe(@NonNull Disposable d) { + + } + + @Override + public void onNext(@NonNull SuperviseListBean listBean) { + if (listBean.getRows() != null && listBean.getRows().size() > 0) { + ++mCurrentPage; + if (currentPage == 1) { + mDatas.clear(); + mDatas.addAll(listBean.getRows()); + } else { + mDatas.addAll(listBean.getRows()); + } + mCsvState.setState(CustomStateView.STATE_SUCCESS); + mAdapter.notifyDataSetChanged(); + mSrlContent.finishRefresh(); + if (mDatas.size() >= listBean.getTotal()) { + mSrlContent.finishLoadMore(); + mSrlContent.setNoMoreData(true); + } else { + mSrlContent.finishLoadMore(); + mSrlContent.setNoMoreData(false); + } + } else { + mSrlContent.finishRefresh(); + mSrlContent.finishLoadMore(); + if (currentPage > 1) { + mSrlContent.setNoMoreData(true); + } else { + if (TextUtils.isEmpty(mKeywords)) { + //无数据 + mCsvState.setState(CustomStateView.STATE_EMPTY); + } else { + mCsvState.setState(CustomStateView.STATE_EMPTY); + ToastUtils.show("未查询到相关内容"); + } + } + } + } + + @Override + public void onError(@NonNull Throwable e) { + mSrlContent.finishLoadMore(); + mSrlContent.finishRefresh(); + ExceptionHandler.handleException(e); + mCsvState.setState(CustomStateView.STATE_ERROR); + } + + @Override + public void onComplete() { + + } + }); + } + + + /** + * 获取被督办的列表 + */ + private void getBySuperviseList(int currentPage) { + mCurrentPage = currentPage; + String start = mTvStartDate.getText().toString().trim(); + String end = mTvEndDate.getText().toString().trim(); + RetrofitManager.getInstance() + .create(OAApi.class) + .getBySuperviseList(start, end, mKeywords, mCurrentPage + "") + .compose(RxTransformer.getTransformer()) + .subscribe(new Observer() { + @Override + public void onSubscribe(@NonNull Disposable d) { + + } + + @Override + public void onNext(@NonNull BySuperviseListBean listBean) { + if (listBean.getRows() != null && listBean.getRows().size() > 0) { + ++mCurrentPage; + if (currentPage == 1) { + mDatas.clear(); + mDatas.addAll(listBean.getRows()); + } else { + mDatas.addAll(listBean.getRows()); + } + mCsvState.setState(CustomStateView.STATE_SUCCESS); + mAdapter.notifyDataSetChanged(); + mSrlContent.finishRefresh(); + if (mDatas.size() >= listBean.getTotal()) { + mSrlContent.finishLoadMore(); + mSrlContent.setNoMoreData(true); + } else { + mSrlContent.finishLoadMore(); + mSrlContent.setNoMoreData(false); + } + } else { + mSrlContent.finishRefresh(); + mSrlContent.finishLoadMore(); + if (currentPage > 1) { + mSrlContent.setNoMoreData(true); + } else { + if (TextUtils.isEmpty(mKeywords)) { + //无数据 + mCsvState.setState(CustomStateView.STATE_EMPTY); + } else { + mCsvState.setState(CustomStateView.STATE_EMPTY); + ToastUtils.show("未查询到相关内容"); + } + } + } + } + + @Override + public void onError(@NonNull Throwable e) { + mSrlContent.finishLoadMore(); + mSrlContent.finishRefresh(); + ExceptionHandler.handleException(e); + mCsvState.setState(CustomStateView.STATE_ERROR); + } + + @Override + public void onComplete() { + + } + }); + } + + + @Override + public void onHiddenChanged(boolean hidden) { + if (!hidden) { + if (mIsRefresh) { + mIsRefresh = false; + doRefresh(); + } + } + super.onHiddenChanged(hidden); + } + + @Override + protected void refreshView() { + + } + + @Override + protected void loadMoreData() { + + } +} diff --git a/oamodule/src/main/java/com/tenlionsoft/oamodule/pad/fragments/home/supervise/SuperviseTransactFragment.java b/oamodule/src/main/java/com/tenlionsoft/oamodule/pad/fragments/home/supervise/SuperviseTransactFragment.java new file mode 100644 index 0000000..3c506b4 --- /dev/null +++ b/oamodule/src/main/java/com/tenlionsoft/oamodule/pad/fragments/home/supervise/SuperviseTransactFragment.java @@ -0,0 +1,223 @@ +package com.tenlionsoft.oamodule.pad.fragments.home.supervise; + +import android.app.ProgressDialog; +import android.content.Context; +import android.os.Bundle; +import android.text.TextUtils; +import android.view.View; +import android.widget.Button; +import android.widget.CheckBox; +import android.widget.EditText; +import android.widget.TextView; + +import com.alibaba.android.arouter.facade.annotation.Route; +import com.google.gson.Gson; +import com.hjq.toast.ToastUtils; +import com.tenlionsoft.baselib.constant.PathConfig; +import com.tenlionsoft.baselib.core.beans.BaseSuccessBean; +import com.tenlionsoft.baselib.core.retrofit_net.RetrofitManager; +import com.tenlionsoft.baselib.core.retrofit_net.conver.RxTransformer; +import com.tenlionsoft.baselib.core.widget.base.BaseFragment; +import com.tenlionsoft.baselib.utils.ExceptionHandler; +import com.tenlionsoft.baselib.utils.LogUtils; +import com.tenlionsoft.baselib.utils.UIUtil; +import com.tenlionsoft.baselib.utils.UserLgUtils; +import com.tenlionsoft.oamodule.R; +import com.tenlionsoft.oamodule.R2; +import com.tenlionsoft.oamodule.beans.SaveRepectSuperviseBean; +import com.tenlionsoft.oamodule.beans.SuperviseBean; +import com.tenlionsoft.oamodule.net.OAApi; +import com.tenlionsoft.oamodule.pad.activitys.home.PadMainActivity; + +import org.jetbrains.annotations.NotNull; + +import androidx.annotation.NonNull; +import butterknife.BindView; +import butterknife.ButterKnife; +import io.reactivex.rxjava3.core.Observer; +import io.reactivex.rxjava3.disposables.Disposable; +import okhttp3.MediaType; +import okhttp3.RequestBody; + +/** + * 作者: adam + * 日期: 2022/5/9 - 16:37 + * 邮箱: itgaojian@163.com + * 描述: 督办回复 + */ +@Route(path = PathConfig.PATH_MODULE_PAD_OA_FRAGMENT_SUPERVISE_TRANSACT) +public class SuperviseTransactFragment extends BaseFragment { + + @BindView(R2.id.tv_name) + TextView mTvName; + @BindView(R2.id.tv_type) + TextView mTvType; + @BindView(R2.id.tv_end_time) + TextView mTvEndTime; + @BindView(R2.id.tv_relevance) + TextView mTvRelevance; + @BindView(R2.id.tv_users) + TextView mTvUsers; + @BindView(R2.id.tv_request) + TextView mTvRequest; + @BindView(R2.id.cb_notice_msg) + CheckBox mCbNoticeMsg; + @BindView(R2.id.cb_notice_email) + CheckBox mCbNoticeEmail; + @BindView(R2.id.et_repect_content) + EditText mEtRepectContent; + @BindView(R2.id.btn_confirm) + Button mBtnConfirm; + private PadMainActivity mMainActivity; + private String mId; + private String mUserId; + + @Override + protected int getContentViewId() { + return R.layout.fragment_supervise_transact; + } + + @Override + protected void setDataToView(View dataView) { + ButterKnife.bind(this, dataView); + setTitleView(true); + mTvFragmentTitle.setText("督办回复"); + mIvFragmentBack.setOnClickListener(v -> mMainActivity.backFragment(1, this)); + Bundle bundle = getArguments(); + if (bundle != null) { + mId = bundle.getString("id"); + mUserId = bundle.getString("userId"); + } + if (TextUtils.isEmpty(mId)) { + ToastUtils.show("数据有误"); + mMainActivity.backFragment(1, this); + } else { + getDetailData(); + } + initViews(); + } + + @Override + public void onAttach(@NonNull @NotNull Context context) { + super.onAttach(context); + mMainActivity = (PadMainActivity) getActivity(); + } + + private void initViews() { + mBtnConfirm.setOnClickListener(v -> doConfirm()); + } + + private void doConfirm() { + if (checkParams()) { + ProgressDialog dialog = UIUtil.initDialog(mActivity, "提交中..."); + dialog.show(); + RequestBody body = buildParams(); + RetrofitManager.getInstance() + .create(OAApi.class) + .doSaveRepectSupervise(mUserId, body) + .compose(RxTransformer.getTransformer()) + .subscribe(new Observer() { + @Override + public void onSubscribe(@io.reactivex.rxjava3.annotations.NonNull Disposable d) { + + } + + @Override + public void onNext(@io.reactivex.rxjava3.annotations.NonNull BaseSuccessBean baseSuccessBean) { + if (dialog.isShowing()) dialog.dismiss(); + ToastUtils.show("回复成功"); + BaseFragment preFragment = mMainActivity.getPreFragment(); + if (preFragment != null) { + preFragment.mIsRefresh = true; + } + mMainActivity.backFragment(1, SuperviseTransactFragment.this); + } + + @Override + public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) { + if (dialog.isShowing()) dialog.dismiss(); + ExceptionHandler.handleException(e); + } + + @Override + public void onComplete() { + + } + }); + + } + } + + private boolean checkParams() { + String content = mEtRepectContent.getText().toString().trim(); + if (TextUtils.isEmpty(content)) { + ToastUtils.show("请输入回复内容"); + return false; + } + return true; + } + + private RequestBody buildParams() { + SaveRepectSuperviseBean bean = new SaveRepectSuperviseBean(); + String content = mEtRepectContent.getText().toString().trim(); + bean.setContent(content); + bean.setOverseeId(mId); + bean.setUserId(UserLgUtils.getUserId()); + bean.setUserName(UserLgUtils.getName()); + return RequestBody.create(new Gson().toJson(bean), MediaType.parse("application/json; charset=utf-8")); + } + + private void getDetailData() { + RetrofitManager.getInstance() + .create(OAApi.class) + .getSuperviseDetail(mId) + .compose(RxTransformer.getTransformer()) + .subscribe(new Observer() { + @Override + public void onSubscribe(@io.reactivex.rxjava3.annotations.NonNull Disposable d) { + + } + + @Override + public void onNext(@io.reactivex.rxjava3.annotations.NonNull SuperviseBean superviseBean) { + setDataToView(superviseBean); + } + + @Override + public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) { + setStateView(STATE_ERROR); + ExceptionHandler.handleException(e); + } + + @Override + public void onComplete() { + + } + }); + } + + private void setDataToView(SuperviseBean bean) { + setStateView(STATE_SUCCESS); + mSrlView.setEnableLoadMore(false); + mSrlView.setEnableRefresh(false); + mTvName.setText(bean.getOverseeTitle()); + mTvType.setText(bean.getOverseeTypeName()); + mTvEndTime.setText(bean.getOverseeCompleteTime()); + mTvRelevance.setText(bean.getOverseeItemName()); + mTvUsers.setText(bean.getOverseeUserNames()); + mTvRequest.setText(bean.getOverseeContent()); + mCbNoticeMsg.setChecked(bean.getOverseeNoticeType().contains("1")); + mCbNoticeEmail.setChecked(bean.getOverseeNoticeType().contains("2")); + + } + + @Override + protected void refreshView() { + + } + + @Override + protected void loadMoreData() { + + } +} diff --git a/oamodule/src/main/res/layout/fragment_supervise.xml b/oamodule/src/main/res/layout/fragment_supervise.xml new file mode 100644 index 0000000..8ef3a0d --- /dev/null +++ b/oamodule/src/main/res/layout/fragment_supervise.xml @@ -0,0 +1,191 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/oamodule/src/main/res/layout/fragment_supervise_add.xml b/oamodule/src/main/res/layout/fragment_supervise_add.xml new file mode 100644 index 0000000..926b9c5 --- /dev/null +++ b/oamodule/src/main/res/layout/fragment_supervise_add.xml @@ -0,0 +1,265 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +