工作报告

This commit is contained in:
adam 2022-05-10 15:15:49 +08:00
parent a032069deb
commit 29d2eb5252
18 changed files with 2193 additions and 7 deletions

View File

@ -235,4 +235,9 @@ public class PathConfig {
public static final String PATH_MODULE_PAD_OA_FRAGMENT_ROUTINE_WORK_DETAIL = "/oamodule/fragment/routineWorkDetail";//日常工作详情
public static final String PATH_MODULE_PAD_OA_FRAGMENT_ROUTINE_WORK_TRANSACT = "/oamodule/fragment/routineWorkTransact";//完成日常工作
public static final String PATH_MODULE_PAD_OA_FRAGMENT_WORK_REPORT_ADD = "/oamodule/fragment/workReportAdd";//添加工作报告
public static final String PATH_MODULE_PAD_OA_FRAGMENT_WORK_REPORT_EDIT = "/oamodule/fragment/workReportEdit";//编辑工作报告
public static final String PATH_MODULE_PAD_OA_FRAGMENT_WORK_REPORT_DETAIL = "/oamodule/fragment/workReportDetail";//工作报告详情
public static final String PATH_MODULE_PAD_OA_FRAGMENT_WORK_REPORT = "/oamodule/fragment/workReport";//工作报告
}

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="300"
android:interpolator="@android:anim/decelerate_interpolator">
<translate
android:fromXDelta="-100%p"
android:toXDelta="0%p" />
<alpha
android:fromAlpha="0.5"
android:toAlpha="1.0" />
</set>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="300"
android:interpolator="@android:anim/decelerate_interpolator">
<translate
android:fromXDelta="0%p"
android:toXDelta="-100%p" />
<alpha
android:fromAlpha="1.0"
android:toAlpha="0.5" />
</set>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="300"
android:interpolator="@android:anim/decelerate_interpolator">
<translate
android:fromXDelta="100%p"
android:toXDelta="0%p" />
<alpha
android:fromAlpha="0.5"
android:toAlpha="1.0" />
</set>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="300"
android:interpolator="@android:anim/decelerate_interpolator">
<translate
android:fromXDelta="0%p"
android:toXDelta="100%p" />
<alpha
android:fromAlpha="1.0"
android:toAlpha="0.5" />
</set>

Binary file not shown.

After

Width:  |  Height:  |  Size: 551 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -128,7 +128,7 @@ public class EditWorkReportActivity extends BaseActivity {
@Override
public void onError(@NonNull Throwable e) {
refreshView(STATE_LOAD_EMPTY);
refreshView(STATE_LOAD_ERROR);
ExceptionHandler.handleException(e);
}

View File

@ -27,7 +27,6 @@ import com.tenlionsoft.baselib.core.widget.base.BaseActivity;
import com.tenlionsoft.baselib.core.widget.base.BaseFragment;
import com.tenlionsoft.baselib.core.widget.base.FragmentUtils;
import com.tenlionsoft.baselib.utils.KeyBoardListener;
import com.tenlionsoft.baselib.utils.LogUtils;
import com.tenlionsoft.baselib.utils.UserLgUtils;
import com.tenlionsoft.oamodule.R;
import com.tenlionsoft.oamodule.R2;
@ -325,16 +324,24 @@ public class PadMainActivity extends BaseActivity {
//隐藏上一个fragment
if (mPreFragment != null) {
fragmentTransaction.hide(mPreFragment)
.setCustomAnimations(R.anim.anim_fade_in, R.anim.anim_fade_out);
LogUtils.e("上一个fragment=========" + mPreFragment);
.setCustomAnimations(R.anim.slide_right_in,
R.anim.slide_left_out,
R.anim.slide_left_in,
R.anim.slide_right_out);
}
if (fragment.isAdded()) {
fragmentTransaction.show(fragment)
.setCustomAnimations(R.anim.anim_fade_in, R.anim.anim_fade_out)
.setCustomAnimations(R.anim.slide_right_in,
R.anim.slide_left_out,
R.anim.slide_left_in,
R.anim.slide_right_out)
.commit();
} else {
fragmentTransaction.add(R.id.fl_content, fragment, tag)
.setCustomAnimations(R.anim.anim_fade_in, R.anim.anim_fade_out)
.setCustomAnimations(R.anim.slide_right_in,
R.anim.slide_left_out,
R.anim.slide_left_in,
R.anim.slide_right_out)
.commit();
}
mPreFragment = fragment;

View File

@ -0,0 +1,389 @@
package com.tenlionsoft.oamodule.pad.fragments.home.workreports;
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.EditText;
import android.widget.TextView;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
import com.bigkoo.pickerview.view.OptionsPickerView;
import com.google.gson.Gson;
import com.hjq.toast.ToastUtils;
import com.leon.lfilepickerlibrary.LFilePicker;
import com.leon.lfilepickerlibrary.utils.Constant;
import com.tenlionsoft.baselib.constant.LionActions;
import com.tenlionsoft.baselib.constant.PathConfig;
import com.tenlionsoft.baselib.core.beans.AddFileBean;
import com.tenlionsoft.baselib.core.beans.BaseSuccessBean;
import com.tenlionsoft.baselib.core.beans.DicBean;
import com.tenlionsoft.baselib.core.retrofit_net.BaseUrlApi;
import com.tenlionsoft.baselib.core.retrofit_net.RetrofitManager;
import com.tenlionsoft.baselib.core.retrofit_net.api.BaseApiService;
import com.tenlionsoft.baselib.core.retrofit_net.conver.RxTransformer;
import com.tenlionsoft.baselib.core.widget.base.AddFileAdapter;
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.oamodule.R;
import com.tenlionsoft.oamodule.R2;
import com.tenlionsoft.oamodule.beans.SaveWorkReportBean;
import com.tenlionsoft.oamodule.net.OAApi;
import com.tenlionsoft.oamodule.pad.activitys.home.PadMainActivity;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
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.Observable;
import io.reactivex.rxjava3.core.Observer;
import io.reactivex.rxjava3.disposables.Disposable;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
/**
* 作者: adam
* 日期: 2022/5/10 - 14:13
* 邮箱: itgaojian@163.com
* 描述: 工作报告
*/
@Route(path = PathConfig.PATH_MODULE_PAD_OA_FRAGMENT_WORK_REPORT_ADD)
public class WorkReportAddFragment extends BaseFragment {
@BindView(R2.id.et_name)
EditText mEtName;
@BindView(R2.id.tv_type)
TextView mTvType;
@BindView(R2.id.et_out)
EditText mEtOut;
@BindView(R2.id.et_content)
EditText mEtContent;
@BindView(R2.id.rlv_files)
RecyclerView mRlvFiles;
@BindView(R2.id.btn_confirm)
Button mBtnConfirm;
private List<AddFileBean> mFileBeans = new ArrayList<>();
private AddFileAdapter mAddFileAdapter;
private String[] fileFilter = new String[]{".doc", ".docx", ".xls", ".xlsx", ".pptx", ".ppt", ".txt", ".pdf"};
private int mFileMax = 9;
private OptionsPickerView<DicBean> mTypePicker;
private List<DicBean> mTyps;
private DicBean mSelType;
private PadMainActivity mMainActivity;
private ActivityResultLauncher<Intent> mFileLauncher;
@Override
protected int getContentViewId() {
return R.layout.fragment_work_report_add;
}
@Override
protected void setDataToView(View dataView) {
ButterKnife.bind(this, dataView);
setTitleView(true);
mTvFragmentTitle.setText("工作报告新增");
mIvFragmentBack.setOnClickListener(v->mMainActivity.backFragment(1,this));
setStateView(STATE_SUCCESS);
mSrlView.setEnableLoadMore(false);
mSrlView.setEnableRefresh(false);
initViews();
}
private void initViews() {
mTyps = new ArrayList<>();
// 工作日报 1
// 工作月报 2
// 工作年报 3
DicBean type1 = new DicBean();
type1.setDataId("1");
type1.setDataName("工作日报");
DicBean type2 = new DicBean();
type2.setDataId("2");
type2.setDataName("工作月报");
DicBean type3 = new DicBean();
type3.setDataId("3");
type3.setDataName("工作年报");
mTyps.add(type1);
mTyps.add(type2);
mTyps.add(type3);
mTvType.setOnClickListener(v -> onShowType());
mFileBeans.add(new AddFileBean());
mAddFileAdapter = new AddFileAdapter(mActivity, mFileBeans);
mAddFileAdapter.addOnItemClickListener(addFileBean -> {
LogUtils.e("添加文件");
if (TextUtils.isEmpty(addFileBean.getId())) {
checkManagePermission();
} else {
//TODO 预览
}
});
//删除上传的文件
mAddFileAdapter.addOnDeleteListener((bean, i) -> {
//删除list中的某个数据
mFileBeans.remove(i);
mAddFileAdapter.notifyDataSetChanged();
++mFileMax;
});
mRlvFiles.setLayoutManager(new LinearLayoutManager(mActivity));
mRlvFiles.setAdapter(mAddFileAdapter);
mBtnConfirm.setOnClickListener(v -> doConfirm());
}
@Override
public void onAttach(@androidx.annotation.NonNull @NotNull Context context) {
super.onAttach(context);
mMainActivity = (PadMainActivity) getActivity();
mFileLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
Intent data = result.getData();
//文件
if (data != null) {
ArrayList<String> paths = data.getStringArrayListExtra(Constant.RESULT_INFO);
if (paths != null && paths.size() > 0) {
doUploadFiles(paths);
} else {
ToastUtils.show("未选择文件");
}
} else {
ToastUtils.show("路径有误,请稍后重试");
}
});
}
@Override
protected void hasManageFileManage() {
if (mFileMax == 0) {
ToastUtils.show("超过最大上传数量限制");
} else {
new LFilePicker()
.withFragment(this)
.withFragmentLauncher(mFileLauncher)
.withRequestCode(LionActions.REQUEST_CODE_AC)
.withTitle("文件选择")
.withMaxNum(mFileMax)
.withFileFilter(fileFilter)
.start();
}
}
/**
* 显示类型
*/
private void onShowType() {
mActivity.hideSoftKeyboard();
if (mTyps != null && mTyps.size() > 0) {
if (mTypePicker == null) {
mTypePicker = new OptionsPickerBuilder(mActivity, (o1, o2, o3, v) -> {
mSelType = mTyps.get(o1);
mTvType.setText(mSelType.getDataName());
})
.setTitleText("请选择")
.setCancelColor(Color.parseColor("#1189FF"))
.setSubmitColor(Color.parseColor("#1189FF"))
.setTitleColor(Color.parseColor("#1189FF"))
.build();
mTypePicker.setPicker(mTyps);
}
mTypePicker.show();
} else {
ToastUtils.show("数据有误,请重新打开页面");
}
}
/**
* 上传文件
*
* @param paths
*/
private int mUploadCount = 0;
private void doUploadFiles(ArrayList<String> paths) {
LogUtils.e(paths);
ProgressDialog progressDialog = UIUtil.initDialog(mActivity, "上传中...");
progressDialog.show();
List<Observable> requests = new ArrayList<>();
List<String> fileNames = new ArrayList<>();
for (int i = 0; i < paths.size(); i++) {
File file = new File(paths.get(i));
Observable observable = createObservable(file);
fileNames.add(file.getName());
if (observable == null) return;
requests.add(observable);
}
Observable<BaseSuccessBean>[] observables1 = requests.toArray(new Observable[requests.size()]);
Observable.mergeArrayDelayError(observables1)
.compose(RxTransformer.getTransformer())
.subscribe(new Observer() {
@Override
public void onSubscribe(@NonNull Disposable d) {
}
@Override
public void onNext(@NotNull Object o) {
++mUploadCount;
if (o instanceof BaseSuccessBean) {
--mFileMax;
//刷新文件
BaseSuccessBean bean = (BaseSuccessBean) o;
AddFileBean fileBean = new AddFileBean();
fileBean.setId(bean.getData());
fileBean.setPath(BaseUrlApi.BASE_IMG_URL + bean.getData());
fileBean.setFileType(1);
fileBean.setFileName(fileNames.get(mUploadCount - 1));
mFileBeans.add(0, fileBean);
}
mAddFileAdapter.notifyDataSetChanged();
if (mUploadCount == paths.size()) {
mUploadCount = 0;
if (progressDialog.isShowing()) {
progressDialog.dismiss();
}
}
}
@Override
public void onError(@NonNull Throwable e) {
e.printStackTrace();
mUploadCount = 0;
if (progressDialog.isShowing()) {
progressDialog.dismiss();
}
ToastUtils.show("上传失败,请稍后重试.");
}
@Override
public void onComplete() {
}
});
}
private Observable createObservable(File file) {
LogUtils.e(file.exists());
RequestBody requestFile = RequestBody.create(file, MediaType.parse("multipart/form-data"));
MultipartBody.Part body;
body = MultipartBody.Part.createFormData("file", file.getName(), requestFile);
return RetrofitManager.getInstance()
.create(BaseApiService.class)
.uploadFile(body)
.compose(RxTransformer.getTransformer());
}
private RequestBody buildParams() {
SaveWorkReportBean bean = new SaveWorkReportBean();
String name = mEtName.getText().toString().trim();
bean.setReportTitle(name);
String out = mEtOut.getText().toString().trim();
if (!TextUtils.isEmpty(out)) {
bean.setReportEgress(out);
}
String content = mEtContent.getText().toString().trim();
bean.setReportContent(content);
bean.setReportType(mSelType.getDataId());
if (mFileBeans.size() >= 2) {
StringBuilder fileId = new StringBuilder();
for (AddFileBean fileBean : mFileBeans) {
if (!TextUtils.isEmpty(fileBean.getId())) {
fileId.append(fileBean.getId()).append(",");
}
}
if (fileId.toString().endsWith(",")) {
fileId = new StringBuilder(fileId.substring(0, fileId.length() - 1));
}
bean.setReportFiles(fileId.toString().trim());
}
return RequestBody.create(new Gson().toJson(bean), MediaType.parse("application/json; charset=utf-8"));
}
private boolean checkParams() {
String name = mEtName.getText().toString().trim();
if (TextUtils.isEmpty(name)) {
ToastUtils.show("请输入上报标题");
return false;
}
if (mSelType == null) {
ToastUtils.show("请选择上报类型");
return false;
}
String content = mEtContent.getText().toString().trim();
if (TextUtils.isEmpty(content)) {
ToastUtils.show("请输入工作内容");
return false;
}
return true;
}
private void doConfirm() {
if (checkParams()) {
ProgressDialog dialog = UIUtil.initDialog(mActivity, "保存中...");
dialog.show();
RequestBody body = buildParams();
RetrofitManager.getInstance()
.create(OAApi.class)
.doSaveWorkReport(body)
.compose(RxTransformer.getTransformer())
.subscribe(new Observer<BaseSuccessBean>() {
@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 (preFragment != null) {
preFragment.mIsRefresh = true;
}
mMainActivity.backFragment(1, WorkReportAddFragment.this);
}
@Override
public void onError(@NonNull Throwable e) {
if (dialog.isShowing()) dialog.dismiss();
ExceptionHandler.handleException(e);
}
@Override
public void onComplete() {
}
});
}
}
@Override
protected void refreshView() {
}
@Override
protected void loadMoreData() {
}
}

View File

@ -0,0 +1,328 @@
package com.tenlionsoft.oamodule.pad.fragments.home.workreports;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.Bundle;
import android.text.Html;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.hjq.toast.ToastUtils;
import com.tenlionsoft.baselib.constant.PathConfig;
import com.tenlionsoft.baselib.core.beans.AddFileBean;
import com.tenlionsoft.baselib.core.beans.BaseSuccessBean;
import com.tenlionsoft.baselib.core.retrofit_net.BaseUrlApi;
import com.tenlionsoft.baselib.core.retrofit_net.RetrofitManager;
import com.tenlionsoft.baselib.core.retrofit_net.api.BaseApiService;
import com.tenlionsoft.baselib.core.retrofit_net.bean.FileInfoBean;
import com.tenlionsoft.baselib.core.retrofit_net.conver.RxTransformer;
import com.tenlionsoft.baselib.core.widget.base.AddFileAdapter;
import com.tenlionsoft.baselib.core.widget.base.BaseFragment;
import com.tenlionsoft.baselib.core.widget.base.FragmentUtils;
import com.tenlionsoft.baselib.utils.ExceptionHandler;
import com.tenlionsoft.baselib.utils.FileUtils;
import com.tenlionsoft.baselib.utils.UIUtil;
import com.tenlionsoft.oamodule.R;
import com.tenlionsoft.oamodule.R2;
import com.tenlionsoft.oamodule.beans.WorkReportDetailBean;
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.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;
import io.reactivex.rxjava3.core.Observer;
import io.reactivex.rxjava3.disposables.Disposable;
import static com.tenlionsoft.baselib.core.widget.PhotoActivity.TAG_IMGURL;
/**
* 作者: adam
* 日期: 2022/5/10 - 14:16
* 邮箱: itgaojian@163.com
* 描述:
*/
@Route(path = PathConfig.PATH_MODULE_PAD_OA_FRAGMENT_WORK_REPORT_DETAIL)
public class WorkReportDetailFragment extends BaseFragment {
@BindView(R2.id.tv_name)
TextView mTvName;
@BindView(R2.id.tv_type)
TextView mTvType;
@BindView(R2.id.et_out)
TextView mEtOut;
@BindView(R2.id.tv_content)
TextView mTvContent;
@BindView(R2.id.rlv_files)
RecyclerView mRlvFiles;
@BindView(R2.id.tv_file_hint)
TextView mTvFileHint;
@BindView(R2.id.btn_del)
Button mBtnDel;
private PadMainActivity mMainActivity;
private String mId;
@Override
protected int getContentViewId() {
return R.layout.fragment_work_report_detail;
}
@Override
protected void setDataToView(View dataView) {
ButterKnife.bind(this, dataView);
setTitleView(true);
mTvFragmentTitle.setText("报告详情");
mTvFragmentOption.setText("编辑");
mIvFragmentBack.setOnClickListener(v -> mMainActivity.backFragment(1, this));
mTvFragmentOption.setOnClickListener(v -> {
BaseFragment fragment = FragmentUtils.getFragmentOne(PathConfig.PATH_MODULE_PAD_OA_FRAGMENT_WORK_REPORT_EDIT, "id", mId);
mMainActivity.addFragment(1, fragment);
});
Bundle bundle = getArguments();
if (bundle != null) {
mId = bundle.getString("id");
}
if (TextUtils.isEmpty(mId)) {
ToastUtils.show("数据有误");
mMainActivity.backFragment(1, this);
} else {
getDetailById();
}
mBtnDel.setOnClickListener(v -> showDelConfirm());
}
private void showDelConfirm() {
new AlertDialog.Builder(mActivity)
.setTitle("提示")
.setMessage("确定要删除该报告吗?")
.setPositiveButton("确定", (dialog, which) -> {
dialog.dismiss();
doDel();
})
.setNegativeButton("取消", (dialog, which) -> dialog.dismiss())
.create()
.show();
}
private void doDel() {
ProgressDialog dialog = UIUtil.initDialog(mActivity, "删除中...");
dialog.show();
RetrofitManager.getInstance()
.create(OAApi.class)
.doDelWorkReport(mId)
.compose(RxTransformer.getTransformer())
.subscribe(new Observer<BaseSuccessBean>() {
@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, WorkReportDetailFragment.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 void getDetailById() {
RetrofitManager.getInstance()
.create(OAApi.class)
.getWorkReportDetail(mId)
.compose(RxTransformer.getTransformer())
.subscribe(new Observer<WorkReportDetailBean>() {
@Override
public void onSubscribe(@io.reactivex.rxjava3.annotations.NonNull Disposable d) {
}
@Override
public void onNext(@io.reactivex.rxjava3.annotations.NonNull WorkReportDetailBean workReportDetailBean) {
setDataToView(workReportDetailBean);
}
@Override
public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) {
setStateView(STATE_ERROR);
ExceptionHandler.handleException(e);
}
@Override
public void onComplete() {
}
});
}
private void setDataToView(WorkReportDetailBean bean) {
setStateView(STATE_SUCCESS);
mSrlView.setEnableRefresh(false);
mSrlView.setEnableLoadMore(false);
mTvName.setText(bean.getReportTitle());
switch (bean.getReportType()) {
case "1":
mTvType.setText("工作日报");
break;
case "2":
mTvType.setText("工作周报");
break;
case "3":
mTvType.setText("工作月报");
break;
}
mEtOut.setText(Html.fromHtml(bean.getReportEgress()));
mTvContent.setText(Html.fromHtml(bean.getReportContent()));
//文件
if (!TextUtils.isEmpty(bean.getReportFiles())) {
mRlvFiles.setVisibility(View.VISIBLE);
mTvFileHint.setVisibility(View.GONE);
doGetFileInfo(bean.getReportFiles());
} else {
mRlvFiles.setVisibility(View.GONE);
mTvFileHint.setVisibility(View.VISIBLE);
}
}
/**
* 获取文件名称等信息
*/
private void doGetFileInfo(String fileId) {
ProgressDialog dialog = UIUtil.initDialog(mActivity, "获取中...");
dialog.show();
RetrofitManager.getInstance()
.create(BaseApiService.class)
.getFileInfoList(fileId)
.compose(RxTransformer.getTransformer())
.subscribe(new Observer<List<FileInfoBean>>() {
@Override
public void onSubscribe(@io.reactivex.rxjava3.annotations.NonNull Disposable d) {
}
@Override
public void onNext(@io.reactivex.rxjava3.annotations.NonNull List<FileInfoBean> fileInfoBeans) {
if (dialog.isShowing()) dialog.dismiss();
if (fileInfoBeans.size() > 0) {
List<AddFileBean> mFiles = new ArrayList<>();
for (int i = 0; i < fileInfoBeans.size(); i++) {
FileInfoBean infoBean = fileInfoBeans.get(i);
AddFileBean bean = new AddFileBean();
bean.setId(infoBean.getFileId());
bean.setPath(BaseUrlApi.BASE_IMG_URL + infoBean.getFileId());
bean.setFileType(FileUtils.getFileType(infoBean.getFileName()));
bean.setFileName(infoBean.getFileName());
mFiles.add(bean);
}
AddFileAdapter adapter = new AddFileAdapter(mActivity, mFiles);
mRlvFiles.setLayoutManager(new LinearLayoutManager(mActivity));
mRlvFiles.setAdapter(adapter);
adapter.addOnItemClickListener(addFileBean -> previewFile(addFileBean, mFiles));
} else {
ToastUtils.show("未找到文档信息");
}
}
@Override
public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) {
if (dialog.isShowing()) dialog.dismiss();
ExceptionHandler.handleException(e);
}
@Override
public void onComplete() {
}
});
}
/**
* 预览文件
*/
private void previewFile(AddFileBean addFileBean, List<AddFileBean> mFiles) {
if (addFileBean.getFileType() == 1) {
//文档
ARouter.getInstance()
.build(PathConfig.PATH_MODULE_BASELIB_ACTIVITY_PREVIEW_FILE)
.withString("fileName", addFileBean.getFileName())
.withString("fileId", addFileBean.getId())
.navigation();
} else if (2 == addFileBean.getFileType()) {
//图片预览
//遍历文件获取所有图片文件
ArrayList<String> imgUrls = new ArrayList<>();
for (int i = 0; i < mFiles.size(); i++) {
if (mFiles.get(i).getFileType() == 2) {
AddFileBean fileBean = mFiles.get(i);
String url = BaseUrlApi.BASE_IMG_URL + fileBean.getId();
imgUrls.add(url);
}
}
ARouter.getInstance()
.build(PathConfig.PATH_MODULE_BASELIB_SHOW_IMG)
.withStringArrayList(TAG_IMGURL, imgUrls)
.navigation();
} else if (3 == addFileBean.getFileType() || 4 == addFileBean.getFileType()) {
//TODO 视频或音频预览
}
}
@Override
public void onHiddenChanged(boolean hidden) {
super.onHiddenChanged(hidden);
if (!hidden) {
if (mIsRefresh) {
mIsRefresh = false;
setStateView(STATE_LOAD);
getDetailById();
}
}
}
@Override
public void onAttach(@NonNull @NotNull Context context) {
super.onAttach(context);
mMainActivity = (PadMainActivity) getActivity();
}
@Override
protected void refreshView() {
setStateView(STATE_LOAD);
getDetailById();
}
@Override
protected void loadMoreData() {
}
}

View File

@ -0,0 +1,503 @@
package com.tenlionsoft.oamodule.pad.fragments.home.workreports;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.text.Html;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
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.view.OptionsPickerView;
import com.google.gson.Gson;
import com.hjq.toast.ToastUtils;
import com.leon.lfilepickerlibrary.LFilePicker;
import com.leon.lfilepickerlibrary.utils.Constant;
import com.tenlionsoft.baselib.constant.LionActions;
import com.tenlionsoft.baselib.constant.PathConfig;
import com.tenlionsoft.baselib.core.beans.AddFileBean;
import com.tenlionsoft.baselib.core.beans.BaseSuccessBean;
import com.tenlionsoft.baselib.core.beans.DicBean;
import com.tenlionsoft.baselib.core.retrofit_net.BaseUrlApi;
import com.tenlionsoft.baselib.core.retrofit_net.RetrofitManager;
import com.tenlionsoft.baselib.core.retrofit_net.api.BaseApiService;
import com.tenlionsoft.baselib.core.retrofit_net.bean.FileInfoBean;
import com.tenlionsoft.baselib.core.retrofit_net.conver.RxTransformer;
import com.tenlionsoft.baselib.core.widget.base.AddFileAdapter;
import com.tenlionsoft.baselib.core.widget.base.BaseFragment;
import com.tenlionsoft.baselib.utils.ExceptionHandler;
import com.tenlionsoft.baselib.utils.FileUtils;
import com.tenlionsoft.baselib.utils.LogUtils;
import com.tenlionsoft.baselib.utils.UIUtil;
import com.tenlionsoft.oamodule.R;
import com.tenlionsoft.oamodule.R2;
import com.tenlionsoft.oamodule.beans.SaveWorkReportBean;
import com.tenlionsoft.oamodule.beans.WorkReportDetailBean;
import com.tenlionsoft.oamodule.net.OAApi;
import com.tenlionsoft.oamodule.pad.activitys.home.PadMainActivity;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.core.Observer;
import io.reactivex.rxjava3.disposables.Disposable;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
/**
* 作者: adam
* 日期: 2022/5/10 - 14:16
* 邮箱: itgaojian@163.com
* 描述:
*/
@Route(path = PathConfig.PATH_MODULE_PAD_OA_FRAGMENT_WORK_REPORT_EDIT)
public class WorkReportEditFragment extends BaseFragment {
@BindView(R2.id.et_name)
EditText mEtName;
@BindView(R2.id.tv_type)
TextView mTvType;
@BindView(R2.id.et_out)
EditText mEtOut;
@BindView(R2.id.et_content)
EditText mEtContent;
@BindView(R2.id.rlv_files)
RecyclerView mRlvFiles;
@BindView(R2.id.btn_confirm)
Button mBtnConfirm;
private PadMainActivity mMainActivity;
private List<AddFileBean> mFileBeans = new ArrayList<>();
private AddFileAdapter mAddFileAdapter;
private String[] fileFilter = new String[]{".doc", ".docx", ".xls", ".xlsx", ".pptx", ".ppt", ".txt", ".pdf"};
private int mFileMax = 9;
private OptionsPickerView<DicBean> mTypePicker;
private List<DicBean> mTyps;
private DicBean mSelType;
private String mId;
private ActivityResultLauncher<Intent> mFileLauncher;
@Override
protected int getContentViewId() {
return R.layout.fragment_work_report_edit;
}
@Override
protected void setDataToView(View dataView) {
ButterKnife.bind(this, dataView);
setTitleView(true);
mTvFragmentTitle.setText("报告编辑");
mIvFragmentBack.setOnClickListener(v -> mMainActivity.backFragment(1, this));
initViews();
Bundle arguments = getArguments();
if (arguments != null) {
mId = arguments.getString("id");
}
if (TextUtils.isEmpty(mId)) {
ToastUtils.show("数据有误");
mMainActivity.backFragment(1, this);
} else {
getDetailById();
}
}
@Override
public void onAttach(@NonNull @NotNull Context context) {
super.onAttach(context);
mMainActivity = (PadMainActivity) getActivity();
mFileLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
Intent data = result.getData();
//文件
if (data != null) {
ArrayList<String> paths = data.getStringArrayListExtra(Constant.RESULT_INFO);
if (paths != null && paths.size() > 0) {
doUploadFiles(paths);
} else {
ToastUtils.show("未选择文件");
}
} else {
ToastUtils.show("路径有误,请稍后重试");
}
});
}
private void getDetailById() {
RetrofitManager.getInstance()
.create(OAApi.class)
.getWorkReportDetail(mId)
.compose(RxTransformer.getTransformer())
.subscribe(new Observer<WorkReportDetailBean>() {
@Override
public void onSubscribe(@io.reactivex.rxjava3.annotations.NonNull Disposable d) {
}
@Override
public void onNext(@io.reactivex.rxjava3.annotations.NonNull WorkReportDetailBean workReportDetailBean) {
setDataToView(workReportDetailBean);
}
@Override
public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) {
setStateView(STATE_ERROR);
ExceptionHandler.handleException(e);
}
@Override
public void onComplete() {
}
});
}
private void setDataToView(WorkReportDetailBean bean) {
setStateView(STATE_SUCCESS);
mSrlView.setEnableLoadMore(false);
mSrlView.setEnableRefresh(false);
mEtName.setText(bean.getReportTitle());
for (DicBean typ : mTyps) {
if (typ.getDataId().equals(bean.getReportType())) {
mSelType = typ;
break;
}
}
mTvType.setText(mSelType.getDataName());
mEtOut.setText(Html.fromHtml(bean.getReportEgress()));
mEtContent.setText(Html.fromHtml(bean.getReportContent()));
if (!TextUtils.isEmpty(bean.getReportFiles())) {
mFileBeans.clear();
doGetFileInfo(bean.getReportFiles());
}
}
/**
* 获取文件名称等信息
*/
private void doGetFileInfo(String fileId) {
ProgressDialog dialog = UIUtil.initDialog(mActivity, "获取中...");
dialog.show();
RetrofitManager.getInstance()
.create(BaseApiService.class)
.getFileInfoList(fileId)
.compose(RxTransformer.getTransformer())
.subscribe(new Observer<List<FileInfoBean>>() {
@Override
public void onSubscribe(@io.reactivex.rxjava3.annotations.NonNull Disposable d) {
}
@Override
public void onNext(@io.reactivex.rxjava3.annotations.NonNull List<FileInfoBean> fileInfoBeans) {
if (dialog.isShowing()) dialog.dismiss();
if (fileInfoBeans.size() > 0) {
for (int i = 0; i < fileInfoBeans.size(); i++) {
FileInfoBean infoBean = fileInfoBeans.get(i);
AddFileBean bean = new AddFileBean();
bean.setId(infoBean.getFileId());
bean.setPath(BaseUrlApi.BASE_IMG_URL + infoBean.getFileId());
bean.setFileType(FileUtils.getFileType(infoBean.getFileName()));
bean.setFileName(infoBean.getFileName());
mFileBeans.add(0, bean);
--mFileMax;
}
mAddFileAdapter.setData(mFileBeans);
} else {
ToastUtils.show("未找到文档信息");
}
}
@Override
public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) {
if (dialog.isShowing()) dialog.dismiss();
ExceptionHandler.handleException(e);
}
@Override
public void onComplete() {
}
});
}
private void initViews() {
mTyps = new ArrayList<>();
DicBean type1 = new DicBean();
type1.setDataId("1");
type1.setDataName("工作日报");
DicBean type2 = new DicBean();
type2.setDataId("2");
type2.setDataName("工作月报");
DicBean type3 = new DicBean();
type3.setDataId("3");
type3.setDataName("工作年报");
mTyps.add(type1);
mTyps.add(type2);
mTyps.add(type3);
mTvType.setOnClickListener(v -> onShowType());
mFileBeans.add(new AddFileBean());
mAddFileAdapter = new AddFileAdapter(mActivity, mFileBeans);
mAddFileAdapter.addOnItemClickListener(addFileBean -> {
LogUtils.e("添加文件");
if (TextUtils.isEmpty(addFileBean.getId())) {
checkManagePermission();
} else {
//TODO 预览
}
});
//删除上传的文件
mAddFileAdapter.addOnDeleteListener((bean, i) -> {
//删除list中的某个数据
mFileBeans.remove(i);
mAddFileAdapter.notifyDataSetChanged();
++mFileMax;
});
mRlvFiles.setLayoutManager(new LinearLayoutManager(mActivity));
mRlvFiles.setAdapter(mAddFileAdapter);
mBtnConfirm.setOnClickListener(v -> doConfirm());
}
@Override
protected void hasManageFileManage() {
if (mFileMax == 0) {
ToastUtils.show("超过最大上传数量限制");
} else {
new LFilePicker()
.withFragment(this)
.withFragmentLauncher(mFileLauncher)
.withRequestCode(LionActions.REQUEST_CODE_AC)
.withTitle("文件选择")
.withMaxNum(mFileMax)
.withFileFilter(fileFilter)
.start();
}
}
/**
* 显示类型
*/
private void onShowType() {
mActivity.hideSoftKeyboard();
if (mTyps != null && mTyps.size() > 0) {
if (mTypePicker == null) {
mTypePicker = new OptionsPickerBuilder(mActivity, (o1, o2, o3, v) -> {
mSelType = mTyps.get(o1);
mTvType.setText(mSelType.getDataName());
})
.setTitleText("请选择")
.setCancelColor(Color.parseColor("#1189FF"))
.setSubmitColor(Color.parseColor("#1189FF"))
.setTitleColor(Color.parseColor("#1189FF"))
.build();
mTypePicker.setPicker(mTyps);
}
mTypePicker.show();
} else {
ToastUtils.show("数据有误,请重新打开页面");
}
}
/**
* 上传文件
*
* @param paths
*/
private int mUploadCount = 0;
private void doUploadFiles(ArrayList<String> paths) {
ProgressDialog progressDialog = UIUtil.initDialog(mActivity, "上传中...");
progressDialog.show();
List<Observable<BaseSuccessBean>> requests = new ArrayList<>();
List<String> fileNames = new ArrayList<>();
for (int i = 0; i < paths.size(); i++) {
File file = new File(paths.get(i));
Observable<BaseSuccessBean> observable = createObservable(file);
fileNames.add(file.getName());
if (observable == null) return;
requests.add(observable);
}
Observable<BaseSuccessBean>[] observables1 = requests.toArray(new Observable[requests.size()]);
Observable.mergeArrayDelayError(observables1)
.compose(RxTransformer.getTransformer())
.subscribe(new Observer() {
@Override
public void onSubscribe(@io.reactivex.rxjava3.annotations.NonNull Disposable d) {
}
@Override
public void onNext(@NotNull Object o) {
++mUploadCount;
if (o instanceof BaseSuccessBean) {
--mFileMax;
//刷新文件
BaseSuccessBean bean = (BaseSuccessBean) o;
AddFileBean fileBean = new AddFileBean();
fileBean.setId(bean.getData());
fileBean.setPath(BaseUrlApi.BASE_IMG_URL + bean.getData());
fileBean.setFileType(1);
fileBean.setFileName(fileNames.get(mUploadCount - 1));
mFileBeans.add(0, fileBean);
}
mAddFileAdapter.notifyDataSetChanged();
if (mUploadCount == paths.size()) {
mUploadCount = 0;
if (progressDialog.isShowing()) {
progressDialog.dismiss();
}
}
}
@Override
public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) {
e.printStackTrace();
mUploadCount = 0;
if (progressDialog.isShowing()) {
progressDialog.dismiss();
}
ToastUtils.show("上传失败,请稍后重试.");
}
@Override
public void onComplete() {
}
});
}
private Observable<BaseSuccessBean> createObservable(File file) {
LogUtils.e(file.exists());
RequestBody requestFile = RequestBody.create(file, MediaType.parse("multipart/form-data"));
MultipartBody.Part body;
body = MultipartBody.Part.createFormData("file", file.getName(), requestFile);
return RetrofitManager.getInstance()
.create(BaseApiService.class)
.uploadFile(body)
.compose(RxTransformer.getTransformer());
}
private RequestBody buildParams() {
SaveWorkReportBean bean = new SaveWorkReportBean();
String name = mEtName.getText().toString().trim();
bean.setReportTitle(name);
String out = mEtOut.getText().toString().trim();
bean.setReportEgress(out);
String content = mEtContent.getText().toString().trim();
bean.setReportContent(content);
bean.setReportType(mSelType.getDataId());
if (mFileBeans.size() >= 2) {
StringBuilder fileId = new StringBuilder();
for (AddFileBean fileBean : mFileBeans) {
if (!TextUtils.isEmpty(fileBean.getId())) {
fileId.append(fileBean.getId()).append(",");
}
}
if (fileId.toString().endsWith(",")) {
fileId = new StringBuilder(fileId.substring(0, fileId.length() - 1));
}
bean.setReportFiles(fileId.toString().trim());
} else {
bean.setReportFiles("");
}
return RequestBody.create(new Gson().toJson(bean), MediaType.parse("application/json; charset=utf-8"));
}
private boolean checkParams() {
String name = mEtName.getText().toString().trim();
if (TextUtils.isEmpty(name)) {
ToastUtils.show("请输入上报标题");
return false;
}
if (mSelType == null) {
ToastUtils.show("请选择上报类型");
return false;
}
String content = mEtContent.getText().toString().trim();
if (TextUtils.isEmpty(content)) {
ToastUtils.show("请输入工作内容");
return false;
}
return true;
}
private void doConfirm() {
if (checkParams()) {
ProgressDialog dialog = UIUtil.initDialog(mActivity, "保存中...");
dialog.show();
RequestBody body = buildParams();
RetrofitManager.getInstance()
.create(OAApi.class)
.doEditWorkReport(mId, body)
.compose(RxTransformer.getTransformer())
.subscribe(new Observer<BaseSuccessBean>() {
@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, WorkReportEditFragment.this);
}
@Override
public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) {
if (dialog.isShowing()) dialog.dismiss();
ExceptionHandler.handleException(e);
}
@Override
public void onComplete() {
}
});
}
}
@Override
protected void refreshView() {
setStateView(STATE_LOAD);
getDetailById();
}
@Override
protected void loadMoreData() {
mSrlView.finishRefresh();
mSrlView.setNoMoreData(false);
}
}

View File

@ -0,0 +1,220 @@
package com.tenlionsoft.oamodule.pad.fragments.home.workreports;
import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.alibaba.android.arouter.facade.annotation.Route;
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.oamodule.R;
import com.tenlionsoft.oamodule.R2;
import com.tenlionsoft.oamodule.adapter.WorkReportAdapter;
import com.tenlionsoft.oamodule.beans.WorkReportDetailBean;
import com.tenlionsoft.oamodule.beans.WorkReportListBean;
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/10 - 14:15
* 邮箱: itgaojian@163.com
* 描述: 工作报告
*/
@Route(path = PathConfig.PATH_MODULE_PAD_OA_FRAGMENT_WORK_REPORT)
public class WorkReportFragment extends BaseFragment {
@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.rlv_content)
RecyclerView mRlvContent;
@BindView(R2.id.srl_content)
SmartRefreshLayout mSrlContent;
@BindView(R2.id.csv_state)
CustomStateView mCsvState;
private List<WorkReportDetailBean> mDatas;
private WorkReportAdapter mAdapter;
private int mCurrentPage = 1;
private String mKeywords = "";
private PadMainActivity mMainActivity;
@Override
protected int getContentViewId() {
return R.layout.fragment_work_report;
}
@Override
protected void setDataToView(View dataView) {
ButterKnife.bind(this, dataView);
setStateView(STATE_SUCCESS);
mSrlView.setEnableRefresh(false);
mSrlView.setEnableLoadMore(false);
setTitleView(true);
mTvFragmentTitle.setText("我的报告");
mTvFragmentOption.setText("新增报告");
mIvFragmentBack.setOnClickListener(v->mMainActivity.backFragment(1,this));
mTvFragmentOption.setOnClickListener(v -> {
BaseFragment fragment = FragmentUtils.getFragment(PathConfig.PATH_MODULE_PAD_OA_FRAGMENT_WORK_REPORT_ADD);
mMainActivity.addFragment(1, fragment);
});
mSrlContent.setOnRefreshListener(v -> doRefresh());
mSrlContent.setOnLoadMoreListener(v -> doLoadMore());
mDatas = new ArrayList<>();
mAdapter = new WorkReportAdapter(mActivity, mDatas);
mRlvContent.setLayoutManager(new LinearLayoutManager(mActivity));
mRlvContent.setAdapter(mAdapter);
mAdapter.addOnItemClickListener(workReportDetailBean -> {
BaseFragment id = FragmentUtils.getFragmentOne(PathConfig.PATH_MODULE_PAD_OA_FRAGMENT_WORK_REPORT_DETAIL, "id", workReportDetailBean.getWorkReportId());
mMainActivity.addFragment(1, id);
});
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();
mKeywords = "";
doRefresh();
});
}
@Override
public void onAttach(@androidx.annotation.NonNull @NotNull Context context) {
super.onAttach(context);
mMainActivity = (PadMainActivity) getActivity();
}
private void doLoadMore() {
getWorkReportList(mCurrentPage);
}
private void doRefresh() {
mDatas.clear();
mAdapter.setData(mDatas);
getWorkReportList(1);
}
@Override
public void onHiddenChanged(boolean hidden) {
super.onHiddenChanged(hidden);
if (!hidden) {
if (mIsRefresh) {
mIsRefresh = false;
doRefresh();
}
}
}
private void getWorkReportList(int currentPage) {
mCurrentPage = currentPage;
RetrofitManager.getInstance()
.create(OAApi.class)
.getWorkReportList(mKeywords, mCurrentPage + "")
.compose(RxTransformer.getTransformer())
.subscribe(new Observer<WorkReportListBean>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
}
@Override
public void onNext(@NonNull WorkReportListBean 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
protected void refreshView() {
}
@Override
protected void loadMoreData() {
}
}

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/gray_f0"
android:orientation="vertical"
android:paddingTop="10dp">
<include layout="@layout/layout_base_search_cancel" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:background="@color/white">
<com.scwang.smart.refresh.layout.SmartRefreshLayout
android:id="@+id/srl_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rlv_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
tools:listitem="@layout/item_work_report" />
</com.scwang.smart.refresh.layout.SmartRefreshLayout>
<com.tenlionsoft.baselib.core.widget.views.CustomStateView
android:id="@+id/csv_state"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
</LinearLayout>

View File

@ -0,0 +1,213 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/gray_f0"
android:orientation="vertical">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="70dp"
android:background="@color/white"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="vertical"
android:paddingTop="10dp"
android:paddingBottom="10dp">
<LinearLayout style="@style/item_hor_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="上报标题"
android:textColor="@color/black"
android:textSize="14sp" />
<EditText
android:id="@+id/et_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="@null"
android:gravity="right"
android:hint="请输入上报标题"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout style="@style/item_hor_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="上报类型"
android:textColor="@color/black"
android:textSize="14sp" />
<TextView
android:id="@+id/tv_type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:clickable="true"
android:drawableRight="@drawable/ic_arrow_right"
android:focusable="true"
android:gravity="right"
android:hint="请选择上报类型"
android:textColor="@color/black"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="@color/white"
android:orientation="vertical"
android:paddingTop="5dp"
android:paddingBottom="10dp">
<LinearLayout style="@style/item_ver">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="外出情况"
android:textColor="@color/black"
android:textSize="14sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="@drawable/shp_rectangle_gray"
android:orientation="vertical">
<EditText
android:id="@+id/et_out"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="@null"
android:gravity="left"
android:hint="请输入外出情况"
android:minLines="3"
android:padding="5dp"
android:textColor="@color/black"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="@color/white"
android:orientation="vertical"
android:paddingTop="5dp"
android:paddingBottom="10dp">
<LinearLayout style="@style/item_ver">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="工作内容"
android:textColor="@color/black"
android:textSize="14sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="@drawable/shp_rectangle_gray"
android:orientation="vertical">
<EditText
android:id="@+id/et_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="@null"
android:gravity="left"
android:hint="请输入工作内容"
android:minLines="3"
android:padding="5dp"
android:textColor="@color/black"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="@color/white"
android:orientation="vertical"
android:paddingTop="5dp"
android:paddingBottom="10dp">
<LinearLayout style="@style/item_ver">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="上报附件"
android:textColor="@color/black"
android:textSize="14sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="@drawable/shp_rectangle_gray"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rlv_files"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:itemCount="3" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<Button
android:id="@+id/btn_confirm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="10dp"
android:background="@drawable/sel_btn_submit_no_size"
android:text="保存"
android:textColor="@color/col_white_gray_press" />
</RelativeLayout>

View File

@ -0,0 +1,226 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/gray_f0"
android:orientation="vertical">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="70dp"
android:background="@color/white"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="10dp"
android:paddingBottom="10dp">
<LinearLayout style="@style/item_hor_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="上报标题"
android:textColor="@color/black"
android:textSize="14sp" />
<TextView
android:id="@+id/tv_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="@null"
android:gravity="right"
android:hint="未录入"
android:textColor="@color/black"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout style="@style/item_hor_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="上报类型"
android:textColor="@color/black"
android:textSize="14sp" />
<TextView
android:id="@+id/tv_type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:clickable="true"
android:focusable="true"
android:gravity="right"
android:hint="未录入"
android:textColor="@color/black"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="vertical"
android:paddingTop="5dp"
android:paddingBottom="10dp">
<LinearLayout style="@style/item_ver">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="外出情况"
android:textColor="@color/black"
android:textSize="14sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="@drawable/shp_rectangle_gray"
android:orientation="vertical">
<TextView
android:id="@+id/et_out"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="@null"
android:gravity="left"
android:hint="无"
android:minLines="3"
android:padding="5dp"
android:textColor="@color/black"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="vertical"
android:paddingTop="5dp"
android:paddingBottom="10dp">
<LinearLayout style="@style/item_ver">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="工作内容"
android:textColor="@color/black"
android:textSize="14sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="@drawable/shp_rectangle_gray"
android:orientation="vertical">
<TextView
android:id="@+id/tv_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="@null"
android:gravity="left"
android:hint="未录入"
android:minLines="3"
android:padding="5dp"
android:textColor="@color/black"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="vertical"
android:paddingTop="5dp"
android:paddingBottom="10dp">
<LinearLayout style="@style/item_ver">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="上报附件"
android:textColor="@color/black"
android:textSize="14sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="@drawable/shp_rectangle_gray"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rlv_files"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:itemCount="3" />
<TextView
android:id="@+id/tv_file_hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="20dp"
android:text="未上传" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="10dp"
android:orientation="horizontal">
<Button
android:id="@+id/btn_del"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/sel_btn_gray_white_round"
android:text="删除"
android:textColor="@color/col_white_gray_press" />
</LinearLayout>
</RelativeLayout>

View File

@ -0,0 +1,213 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/gray_f0"
android:orientation="vertical">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="70dp"
android:background="@color/white"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="vertical"
android:paddingTop="10dp"
android:paddingBottom="10dp">
<LinearLayout style="@style/item_hor_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="上报标题"
android:textColor="@color/black"
android:textSize="14sp" />
<EditText
android:id="@+id/et_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="@null"
android:gravity="right"
android:hint="请输入上报标题"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout style="@style/item_hor_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="上报类型"
android:textColor="@color/black"
android:textSize="14sp" />
<TextView
android:id="@+id/tv_type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:clickable="true"
android:drawableRight="@drawable/ic_arrow_right"
android:focusable="true"
android:gravity="right"
android:hint="请选择上报类型"
android:textColor="@color/black"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="@color/white"
android:orientation="vertical"
android:paddingTop="5dp"
android:paddingBottom="10dp">
<LinearLayout style="@style/item_ver">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="外出情况"
android:textColor="@color/black"
android:textSize="14sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="@drawable/shp_rectangle_gray"
android:orientation="vertical">
<EditText
android:id="@+id/et_out"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="@null"
android:gravity="left"
android:hint="请输入外出情况"
android:minLines="3"
android:padding="5dp"
android:textColor="@color/black"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="@color/white"
android:orientation="vertical"
android:paddingTop="5dp"
android:paddingBottom="10dp">
<LinearLayout style="@style/item_ver">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="工作内容"
android:textColor="@color/black"
android:textSize="14sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="@drawable/shp_rectangle_gray"
android:orientation="vertical">
<EditText
android:id="@+id/et_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="@null"
android:gravity="left"
android:hint="请输入工作内容"
android:minLines="3"
android:padding="5dp"
android:textColor="@color/black"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="@color/white"
android:orientation="vertical"
android:paddingTop="5dp"
android:paddingBottom="10dp">
<LinearLayout style="@style/item_ver">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="上报附件"
android:textColor="@color/black"
android:textSize="14sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="@drawable/shp_rectangle_gray"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rlv_files"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:itemCount="3" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<Button
android:id="@+id/btn_confirm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="10dp"
android:background="@drawable/sel_btn_submit_no_size"
android:text="保存"
android:textColor="@color/col_white_gray_press" />
</RelativeLayout>

View File

@ -8,7 +8,7 @@
<ImageView
android:id="@+id/iv_step"
android:layout_width="17dp"
android:layout_width="25dp"
android:layout_height="match_parent"
android:scaleType="fitXY"
tools:src="@drawable/ic_step_start" />