diff --git a/.idea/misc.xml b/.idea/misc.xml index 189a21d..6a960de 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -12,6 +12,7 @@ + @@ -20,11 +21,12 @@ - + + - - + + diff --git a/app/build.gradle b/app/build.gradle index 1336f07..6fe19b3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -16,8 +16,8 @@ android { // minSdkVersion 26 minSdkVersion 21 targetSdkVersion 25 - versionCode 8 - versionName "2.0.6" + versionCode 9 + versionName "2.0.7" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" // ndk { @@ -84,8 +84,8 @@ android { // buildConfigField "String", "BASE_URL", '"http://192.168.69.99:9009"' // buildConfigField "String", "M_URL", '"http://192.168.69.112:8098"' // buildConfigField "String", "BASE_URL", '"https://oa.qbjjyyun.net/api"' -// buildConfigField "String", "OA_URL", '"https://oa.live.educlouddata.com"' - buildConfigField "String", "OA_URL", '"http://192.168.69.114:3000"' + buildConfigField "String", "OA_URL", '"https://oa.live.educlouddata.com"' +// buildConfigField "String", "OA_URL", '"http://192.168.69.114:3000"' buildConfigField "String", "M_URL", '"https://m.live.educlouddata.com/"' buildConfigField "String", "BASE_URL", '"https://oa.live.educlouddata.com/api"' buildConfigField "String", "APP_NAME", '"家校互通(开发)"' @@ -186,4 +186,5 @@ dependencies { implementation 'com.qmuiteam:qmui:2.0.0-alpha10' api 'com.tencent.tbs:tbssdk:44181' + implementation 'com.github.HuanTanSheng:EasyPhotos:3.1.5' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1d24b34..47a0d3e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -17,9 +17,10 @@ + + + android:launchMode="singleInstance" + android:screenOrientation="landscape" + android:windowSoftInputMode="adjustPan|stateHidden"> - - + + - - - - - - + android:screenOrientation="landscape" /> + + + + + - + android:process=":dexopt"> + - + diff --git a/app/src/main/java/com/yzx/escreen/activity/CameraActivity.kt b/app/src/main/java/com/yzx/escreen/activity/CameraActivity.kt new file mode 100644 index 0000000..4590640 --- /dev/null +++ b/app/src/main/java/com/yzx/escreen/activity/CameraActivity.kt @@ -0,0 +1,24 @@ +package com.yzx.escreen.activity + +import android.os.Bundle +import com.yzx.escreen.R +import com.yzx.escreen.activity.base.BaseActivity +import com.yzx.escreen.presenter.base.BasePresenter + +class CameraActivity : BaseActivity>() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_camera) + } + + override val inflateId: Int + get() = R.layout.activity_camera + + override fun initView() { + } + + override fun initData() { + } + + override fun initPresenter(): BasePresenter<*>? = null +} \ No newline at end of file diff --git a/app/src/main/java/com/yzx/escreen/adapter/HomeDialogStepAdapter.kt b/app/src/main/java/com/yzx/escreen/adapter/HomeDialogStepAdapter.kt index 33fd785..0ab8fa4 100644 --- a/app/src/main/java/com/yzx/escreen/adapter/HomeDialogStepAdapter.kt +++ b/app/src/main/java/com/yzx/escreen/adapter/HomeDialogStepAdapter.kt @@ -1,6 +1,7 @@ package com.yzx.escreen.adapter import android.annotation.SuppressLint +import android.graphics.Color import android.view.View import com.chad.library.adapter.base.BaseQuickAdapter import com.chad.library.adapter.base.viewholder.BaseViewHolder @@ -10,24 +11,47 @@ import com.yzx.escreen.utils.setSrc import com.yzx.escreen.utils.toTime import kotlinx.android.synthetic.main.layout_leave_step.view.* import org.jetbrains.anko.dip +import org.jetbrains.anko.textColor class HomeDialogStepAdapter(list: MutableList) : BaseQuickAdapter(R.layout.layout_leave_step, list) { @SuppressLint("SetTextI18n") override fun convert(holder: BaseViewHolder, item: LeaveActivity) { - if (item.is_approve == 0) { - holder.itemView.addUserName.visibility = View.VISIBLE - holder.itemView.addUserName.text = item.add_user_name - holder.itemView.approvalComments.visibility = View.GONE - } else { - holder.itemView.addUserName.visibility = View.GONE - holder.itemView.approvalComments.visibility = View.VISIBLE - var str = "审批人:${item.add_user_name}" - if (item.approval_comments != null && item.approval_comments.isNotEmpty()) { - str += "。${item.approval_comments}" + holder.itemView.inImg.visibility = View.GONE + when (item.is_approve) { + 0 -> { + holder.itemView.addUserName.visibility = View.VISIBLE + holder.itemView.addUserName.text = item.add_user_name + holder.itemView.approvalComments.visibility = View.GONE + } + 2 -> { + holder.itemView.addUserName.visibility = View.GONE + holder.itemView.approvalComments.visibility = View.VISIBLE + holder.itemView.approvalComments.text = item.approval_comments + holder.itemView.approvalComments.textColor = if (item.color.isNotEmpty()) { + Color.parseColor(item.color) + } else { + Color.parseColor("#333333") + } + + val inItem = item.getInImg() + if (inItem != null) { + holder.itemView.inImg.visibility = View.VISIBLE + holder.itemView.inImg.setSrc(inItem.identity, inItem.attachment_id) + } else { + holder.itemView.inImg.visibility = View.GONE + } + } + else -> { + holder.itemView.addUserName.visibility = View.GONE + holder.itemView.approvalComments.visibility = View.VISIBLE + var str = "审批人:${item.add_user_name}" + if (item.approval_comments != null && item.approval_comments.isNotEmpty()) { + str += "。${item.approval_comments}" + } + holder.itemView.approvalComments.text = str } - holder.itemView.approvalComments.text = str } if (item.add_user_type_name.isNullOrBlank()) { holder.itemView.addUserTypeName.visibility = View.GONE diff --git a/app/src/main/java/com/yzx/escreen/adapter/HomeListAdapter.kt b/app/src/main/java/com/yzx/escreen/adapter/HomeListAdapter.kt index f206d5b..752898f 100644 --- a/app/src/main/java/com/yzx/escreen/adapter/HomeListAdapter.kt +++ b/app/src/main/java/com/yzx/escreen/adapter/HomeListAdapter.kt @@ -16,6 +16,10 @@ import org.jetbrains.anko.textColor class HomeListAdapter(list: MutableList) : BaseQuickAdapter(R.layout.layout_leave_table, list) { + init { + addChildClickViewIds(R.id.cancelBtn) + } + @SuppressLint("SetTextI18n") override fun convert(holder: BaseViewHolder, item: StuLeave) { holder.itemView.studentName.text = item.leave_student_name @@ -36,12 +40,16 @@ class HomeListAdapter(list: MutableList) : 1 -> "待处理" 2 -> "已确认" 3 -> "已拒绝" + 4 -> "正常销假" + 5 -> "超时销假" else -> "--" } holder.itemView.statusName.textColor = when (item.status) { 1 -> Color.parseColor("#333333") 2 -> Color.parseColor("#3c7ef6") 3 -> Color.parseColor("#ff4040") + 4 -> Color.parseColor("#3c7ef6") + 5 -> Color.parseColor("#ff4040") else -> Color.parseColor("#333333") } holder.itemView.applyTime.text = item.add_time.toTime() @@ -51,5 +59,14 @@ class HomeListAdapter(list: MutableList) : } else { View.VISIBLE } + + + holder.itemView.cancelBtn.visibility = if(item.is_cancel_leave ==1 ){ + holder.itemView.placeHolder.visibility = View.GONE + View.VISIBLE + }else{ + holder.itemView.placeHolder.visibility = View.VISIBLE + View.GONE + } } } \ No newline at end of file diff --git a/app/src/main/java/com/yzx/escreen/config/YzxInterface.kt b/app/src/main/java/com/yzx/escreen/config/YzxInterface.kt index 2e2f203..0c22c9c 100644 --- a/app/src/main/java/com/yzx/escreen/config/YzxInterface.kt +++ b/app/src/main/java/com/yzx/escreen/config/YzxInterface.kt @@ -47,5 +47,6 @@ object YzxInterface { const val INTERFACE_GET_STU_LEAVE_INFO_DETAIL= "/edu/attendance/getStudentLeaveRequestDetail" //获取学生的请假信息详情 const val INTERFACE_GET_TEACHER_INFO= "/rights/teacherWork/getTeacherByUserId"//获取人员信息 const val INTERFACE_STUDENT_GET_SHOW_BOX_LIST= "/edu/attendance/student/getStudentLeaveIds" //获取需要弹出的数据 + const val INTERFACE_STUDENT_POST_LEAVE_VACATION= "/edu/attendance/student/studentLeaveVacation"//人工销假操作 } \ No newline at end of file diff --git a/app/src/main/java/com/yzx/escreen/fragment/HomeFragment.kt b/app/src/main/java/com/yzx/escreen/fragment/HomeFragment.kt index f128264..e90811a 100644 --- a/app/src/main/java/com/yzx/escreen/fragment/HomeFragment.kt +++ b/app/src/main/java/com/yzx/escreen/fragment/HomeFragment.kt @@ -1,6 +1,9 @@ package com.yzx.escreen.fragment +import android.Manifest import android.annotation.SuppressLint +import android.app.Activity +import android.content.Intent import android.content.res.ColorStateList import android.graphics.Color import android.os.Handler @@ -9,27 +12,25 @@ import android.text.Editable import android.text.TextWatcher import android.view.KeyEvent import android.view.View +import android.widget.EditText import android.widget.ImageView import android.widget.TextView import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView -import com.blankj.utilcode.util.KeyboardUtils -import com.blankj.utilcode.util.NetworkUtils -import com.blankj.utilcode.util.SPUtils +import com.blankj.utilcode.util.* +import com.huantansheng.easyphotos.EasyPhotos +import com.huantansheng.easyphotos.models.album.entity.Photo +import com.qmuiteam.qmui.widget.dialog.QMUIDialog +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton import com.yzx.escreen.R import com.yzx.escreen.adapter.HomeDialogStepAdapter import com.yzx.escreen.adapter.HomeListAdapter import com.yzx.escreen.fragment.base.BaseFragment -import com.yzx.escreen.model.LeaveID -import com.yzx.escreen.model.Pager -import com.yzx.escreen.model.StuLeave +import com.yzx.escreen.model.* import com.yzx.escreen.presenter.HomePresenter import com.yzx.escreen.presenter.HomeView -import com.yzx.escreen.utils.durationStr -import com.yzx.escreen.utils.hideNavigationBar -import com.yzx.escreen.utils.setSrc -import com.yzx.escreen.utils.toTime +import com.yzx.escreen.utils.* import com.yzx.escreen.widget.BaseDialog import kotlinx.android.synthetic.main.fragment_home.* import kotlinx.android.synthetic.main.layout_loading.view.* @@ -38,11 +39,14 @@ import org.jetbrains.anko.support.v4.act import org.jetbrains.anko.support.v4.ctx import org.jetbrains.anko.textColor + class HomeFragment : BaseFragment(), HomeView, - NetworkUtils.OnNetworkStatusChangedListener { + NetworkUtils.OnNetworkStatusChangedListener, FileUploadCallBack { companion object { + val CAMER_REQUEST_CODE = 0x01 + @JvmStatic fun getNewInstance() = HomeFragment() @@ -61,7 +65,11 @@ class HomeFragment : BaseFragment(), HomeView, private var isLoading = false private val mShowList = mutableListOf() private val mShowDialogList = mutableListOf() - + private var mCancelItem: StuLeave? = null + private var mCancelFaceImg: ImageView? = null + private var mDialogVacation: BaseDialog? = null + private val mVacation = Vacation() + private val mVacationAttachment = Attachment("","","") private val mHandler = Handler(Looper.getMainLooper()) private val runnable = object : Runnable { @@ -89,16 +97,20 @@ class HomeFragment : BaseFragment(), HomeView, status1Btn.setOnClickListener { changeStatus(1) } status2Btn.setOnClickListener { changeStatus(2) } status3Btn.setOnClickListener { changeStatus(3) } + status4Btn.setOnClickListener { changeStatus(4) } + status5Btn.setOnClickListener { changeStatus(5) } statusBtnList.add(allBtn) statusBtnList.add(status1Btn) statusBtnList.add(status2Btn) statusBtnList.add(status3Btn) + statusBtnList.add(status4Btn) + statusBtnList.add(status5Btn) keywordInput.setOnKeyListener { _, keyCode, _ -> if (!isLoading) { if (keyCode == KeyEvent.KEYCODE_ENTER) { keyword = keywordInput.text.toString() initData() - KeyboardUtils.hideSoftInput( keywordInput) + KeyboardUtils.hideSoftInput(keywordInput) } } false @@ -114,6 +126,16 @@ class HomeFragment : BaseFragment(), HomeView, mPresenter?.getDetail(mAdapter.getItem(position).id) } + mAdapter.setOnItemChildClickListener { adapter, view, position -> + LogUtils.d("setOnItemChildClickListener", position) + when (view.id) { + R.id.cancelBtn -> { + mCancelItem = mAdapter.getItem(position) + showCancelDialog() + } + } + } + switchBtn.setOnCheckedChangeListener { buttonView, isChecked -> SPUtils.getInstance().put("auto_show_leave", isChecked) @@ -152,10 +174,84 @@ class HomeFragment : BaseFragment(), HomeView, }) filterLayout.setOnClickListener { - KeyboardUtils.hideSoftInput( keywordInput) + KeyboardUtils.hideSoftInput(keywordInput) } } + @SuppressLint("SetTextI18n") + private fun showCancelDialog() { + val dialogVacation = BaseDialog(act, R.style.BaseDialog, R.layout.dialog_vacation) + mCancelItem?.apply { + mVacation.id = id + mVacation.vacation_type = 2 + mVacation.vacation_attachment = "" + mVacation.vacation_remark = "电子屏人工销假" + mVacationAttachment.clear() + dialogVacation.find(R.id.leave_student_name).text = leave_student_name + dialogVacation.find(R.id.class_name).text = "${grade_name}${class_name}" + dialogVacation.find(R.id.add_time).text = + "${start_time.toTime()} - ${end_time.toTime()}" + val nowTime = (TimeUtils.getNowMills() / 1000).toInt() + dialogVacation.find(R.id.vacation_time).text = nowTime.toTime() + mVacation.vacation_time = nowTime.toLong() + dialogVacation.find(R.id.vacation_remark).setText(mVacation.vacation_remark) + dialogVacation.find(R.id.cameraBtn).setOnClickListener { onCameraBtnClick() } + mCancelFaceImg = dialogVacation.find(R.id.face_img) + dialogVacation.find(R.id.submitBtn).setOnClickListener { + postVacation() + } + dialogVacation.find(R.id.closeBtn).setOnClickListener { + dialogVacation.dismiss() + } + } + //处理弹窗显示 + dialogVacation.show() + dialogVacation.hideNavigationBar() + mDialogVacation = dialogVacation + } + + private fun postVacation(){ + if(mVacationAttachment.id.isNotEmpty()){ + mVacation.vacation_attachment = GsonUtils.toJson(mutableListOf(mVacationAttachment)) + } + showLoading("销假中") + mPresenter?.postVacation(mVacation) + } + + private fun onCameraBtnClick() { + val isGranted = PermissionUtils.isGranted(Manifest.permission.CAMERA) + if (!isGranted) { + PermissionUtils.permission(Manifest.permission.CAMERA) + .callback { isAllGranted, granted, deniedForever, denied -> + if (!isAllGranted) { + val tipDialog = QMUIDialog.MessageDialogBuilder(activity) + .setTitle("温馨提示") + .setMessage("拍照权限被拒绝,请开启权限后重试") + .addAction("取消") { dialog, index -> + dialog.dismiss() + } + .addAction("确定") { dialog, index -> + dialog.dismiss() + PermissionUtils.launchAppDetailsSettings() + } + .create() + tipDialog.show() + tipDialog.hideNavigationBar() + } + } + .request() + } else { + openCamera() + } + } + + private fun openCamera() { + EasyPhotos.createCamera(this, true) + .setFileProviderAuthority("${activity?.packageName}.fileProvider") + .start(CAMER_REQUEST_CODE)//也可以选择链式调用写法 + } + + private fun changeSwitchBtnTxt(isChecked: Boolean) { if (isChecked) { switchBtnTxt.setTextColor(ctx.resources.getColor(R.color.green2)) @@ -181,7 +277,8 @@ class HomeFragment : BaseFragment(), HomeView, } dialog.find(R.id.class_name).text = "${detail.grade_name}${detail.class_name}" dialog.find(R.id.leave_request_type_name).text = detail.leave_request_type_name - dialog.find(R.id.leave_duration_str).text = (detail.end_time - detail.start_time).durationStr() + dialog.find(R.id.leave_duration_str).text = + (detail.end_time - detail.start_time).durationStr() dialog.find(R.id.add_time).text = "${detail.start_time.toTime()} - ${detail.end_time.toTime()}" dialog.find(R.id.leave_request_reason).text = detail.leave_request_reason @@ -190,6 +287,8 @@ class HomeFragment : BaseFragment(), HomeView, 1 -> "https://oa-edu-1259243469.cos.ap-chengdu.myqcloud.com/public/mini/stutakeleave_wait.png" 2 -> "https://oa-edu-1259243469.cos.ap-chengdu.myqcloud.com/public/mini/stutakeleave_pass.png" 3 -> "https://oa-edu-1259243469.cos.ap-chengdu.myqcloud.com/public/mini/stutakeleave_nopass.png" + 4 -> "https://oa-edu-1259243469.cos.ap-chengdu.myqcloud.com/public/mini/cancellation.png" + 5 -> "https://oa-edu-1259243469.cos.ap-chengdu.myqcloud.com/public/mini/cancellation_overtime.png" else -> "" } ) @@ -233,7 +332,7 @@ class HomeFragment : BaseFragment(), HomeView, } private fun changeStatus(status: Int) { - KeyboardUtils.hideSoftInput( keywordInput) + KeyboardUtils.hideSoftInput(keywordInput) if (isLoading) { return } @@ -295,7 +394,7 @@ class HomeFragment : BaseFragment(), HomeView, } private fun pre() { - KeyboardUtils.hideSoftInput( keywordInput) + KeyboardUtils.hideSoftInput(keywordInput) if (isLoading) { return } @@ -307,7 +406,7 @@ class HomeFragment : BaseFragment(), HomeView, } private fun next() { - KeyboardUtils.hideSoftInput( keywordInput) + KeyboardUtils.hideSoftInput(keywordInput) if (isLoading) { return } @@ -391,6 +490,20 @@ class HomeFragment : BaseFragment(), HomeView, } } + override fun postVacationSuccess(msg: String) { + showDialogToast(msg,2000L) + hideLoading() + mDialogVacation?.apply { + dismiss() + refreshData() + } + } + + override fun postVacationError(msg: String) { + hideLoading() + showDialogToast(msg,2000L,QMUITipDialog.Builder.ICON_TYPE_FAIL) + } + override fun onDisconnected() { } @@ -398,4 +511,34 @@ class HomeFragment : BaseFragment(), HomeView, override fun onConnected(networkType: NetworkUtils.NetworkType?) { refreshData() } -} \ No newline at end of file + + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { + if (resultCode == Activity.RESULT_OK) { + if (requestCode == CAMER_REQUEST_CODE) { + val photos = data?.getParcelableArrayListExtra(EasyPhotos.RESULT_PHOTOS) + LogUtils.d("photos", photos) + photos?.apply { + if (this.size > 0) { + mVacationAttachment.name = this[0].name + FileUpload.upload(this[0].path, this@HomeFragment) + } + } + + } + + } + super.onActivityResult(requestCode, resultCode, data) + } + + override fun onSuccess(identity: String, key: String) { + LogUtils.d(identity, key) + mCancelFaceImg?.setSrc(identity, key) + mVacationAttachment.identity = identity + mVacationAttachment.id = key + } + + override fun onError(msg: String) { + LogUtils.d(msg) + } +} + diff --git a/app/src/main/java/com/yzx/escreen/fragment/MyFragment.kt b/app/src/main/java/com/yzx/escreen/fragment/MyFragment.kt index 043495e..65945a1 100644 --- a/app/src/main/java/com/yzx/escreen/fragment/MyFragment.kt +++ b/app/src/main/java/com/yzx/escreen/fragment/MyFragment.kt @@ -1,14 +1,12 @@ package com.yzx.escreen.fragment import android.text.InputType +import com.blankj.utilcode.util.ActivityUtils import com.blankj.utilcode.util.KeyboardUtils import com.blankj.utilcode.util.LogUtils import com.blankj.utilcode.util.ScreenUtils -import com.blankj.utilcode.util.ToastUtils import com.qmuiteam.qmui.widget.dialog.QMUIDialog -import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction import com.qmuiteam.qmui.widget.dialog.QMUITipDialog -import com.yzx.escreen.MainActivity import com.yzx.escreen.R import com.yzx.escreen.activity.WebActivity import com.yzx.escreen.config.Config @@ -18,9 +16,7 @@ import com.yzx.escreen.model.User import com.yzx.escreen.presenter.MyPresenter import com.yzx.escreen.presenter.MyView import com.yzx.escreen.utils.hideNavigationBar -import kotlinx.android.synthetic.main.activity_home.* import kotlinx.android.synthetic.main.fragment_my.* -import org.jetbrains.anko.startActivity import kotlin.system.exitProcess class MyFragment : BaseFragment(), MyView { @@ -71,7 +67,7 @@ class MyFragment : BaseFragment(), MyView { LogUtils.d("112233".equals(text)) if ("112233" == text.toString()) { activity?.finish() -// exitProcess(0) + exitProcess(0) } else { // ToastUtils.showShort("密码不正确") showPwdErrorTip() diff --git a/app/src/main/java/com/yzx/escreen/fragment/base/BaseFragment.kt b/app/src/main/java/com/yzx/escreen/fragment/base/BaseFragment.kt index 1a16a5e..4a91ade 100644 --- a/app/src/main/java/com/yzx/escreen/fragment/base/BaseFragment.kt +++ b/app/src/main/java/com/yzx/escreen/fragment/base/BaseFragment.kt @@ -6,7 +6,9 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog import com.yzx.escreen.presenter.base.BasePresenter +import com.yzx.escreen.utils.hideNavigationBar /** * fragment 基类 @@ -18,6 +20,8 @@ abstract class BaseFragment> : Fragment() { */ abstract val inflateId: Int + private var mLoadingDialog: QMUITipDialog? = null + /** * 初始化视图操作在这里执行,执行时机为onCreate之后 */ @@ -35,7 +39,6 @@ abstract class BaseFragment> : Fragment() { abstract fun initPresenter(): P? - override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, @@ -52,8 +55,41 @@ abstract class BaseFragment> : Fragment() { } - override fun onDestroy() { super.onDestroy() } + + fun showDialogToast( + msg: String, + duration: Long = 1500, + @QMUITipDialog.Builder.IconType icon: Int = QMUITipDialog.Builder.ICON_TYPE_SUCCESS + ) { + val tipDialog = QMUITipDialog.Builder(activity) + .setIconType(icon) + .setTipWord(msg) + .create() + tipDialog.show() + tipDialog.hideNavigationBar() + view?.postDelayed({ + tipDialog.dismiss() + }, duration) + } + + fun showLoading(msg: String = "加载中") { + mLoadingDialog = QMUITipDialog.Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(msg) + .create() + mLoadingDialog?.apply { + show() + } + } + + fun hideLoading() { + mLoadingDialog?.apply { + if (isShowing) { + dismiss() + } + } + } } \ No newline at end of file diff --git a/app/src/main/java/com/yzx/escreen/model/StuLeave.kt b/app/src/main/java/com/yzx/escreen/model/StuLeave.kt index 95623db..adb35b0 100644 --- a/app/src/main/java/com/yzx/escreen/model/StuLeave.kt +++ b/app/src/main/java/com/yzx/escreen/model/StuLeave.kt @@ -2,6 +2,7 @@ package com.yzx.escreen.model import android.app.Dialog import com.blankj.utilcode.util.LogUtils +import com.yzx.escreen.utils.durationStr data class StuLeave( val activities: MutableList = mutableListOf(), @@ -24,6 +25,7 @@ data class StuLeave( val grade_name: String = "", val headteacher_id: Int = 0, val id: Int = 0, + val is_cancel_leave: Int = 0, val leave_request_reason: String = "", val leave_request_type: Int = 0, val leave_request_type_name: String = "", @@ -37,54 +39,54 @@ data class StuLeave( val status: Int = 0, val todo_list_id: Int = 0, val todo_status: Int = 0 -){ +) { fun getStep(): MutableList { val logList = mutableListOf() for (item in activities) { - if(item.child.isNotEmpty()){ + if (item.child.isNotEmpty()) { for (it in item.child) { - it.activity_name = when(it.approve_user_type){ - 0->"领导审批" - 1->"自选" - 2->if (it.role_type==3){ + it.activity_name = when (it.approve_user_type) { + 0 -> "领导审批" + 1 -> "自选" + 2 -> if (it.role_type == 3) { "班主任审批" - }else{ + } else { "任课老师审批" } - 3->"专业部领导审批" - 4->"值班领导审批" - else->"领导审批" + 3 -> "专业部领导审批" + 4 -> "值班领导审批" + else -> "领导审批" } } val approvedList = item.child.filter { - return@filter it.approval_status>1 + return@filter it.approval_status > 1 } - if(approvedList.isNotEmpty()){ - if(item.approve_way==2){ + if (approvedList.isNotEmpty()) { + if (item.approve_way == 2) { logList.addAll(approvedList) - }else{ + } else { logList.addAll(item.child) } - }else{ - item.activity_name = when(item.approve_user_type){ - 0->"领导审批" - 1->"自选" - 2->if (item.role_type==3){ + } else { + item.activity_name = when (item.approve_user_type) { + 0 -> "领导审批" + 1 -> "自选" + 2 -> if (item.role_type == 3) { "班主任审批" - }else{ + } else { "任课老师审批" } - 3->"专业部领导审批" - 4->"值班领导审批" - else->"领导审批" + 3 -> "专业部领导审批" + 4 -> "值班领导审批" + else -> "领导审批" } - if(item.child.size>1){ - item.activity_name += when(item.approve_way){ - 0-> "(依次审批)" - 1-> "(会签)" - 2-> "(或签)" - else->"" + if (item.child.size > 1) { + item.activity_name += when (item.approve_way) { + 0 -> "(依次审批)" + 1 -> "(会签)" + 2 -> "(或签)" + else -> "" } } item.add_user_name = item.child.map { @@ -95,14 +97,37 @@ data class StuLeave( item.is_approve = 1 logList.add(item) } - }else{ //提交人 - item.activity_name = "提交申请" - if(item.add_user_type == 0){ + } else if (item.is_approve == 0) { //提交人 + if (item.activity_name.contains("并直接通过") || item.is_auto_pass == 1) { + item.activity_name = "提交申请(直接通过)" + } else { + item.activity_name = "提交申请" + } + if (item.add_user_type == 0) { item.add_user_type_name = "老师" - }else if (item.add_user_type == 1){ + } else if (item.add_user_type == 1) { item.add_user_type_name = "学生家长" } logList.add(item) + } else if (item.is_approve == 2) { //学生返校销假 + if (item.vacation_type == 2) { //销假/返校类型(1自动销假 2老师操作销假) + val remark = item.approval_comments + item.approval_comments = "人工销假,销假操作人:${item.add_user_name}。" + if (item.add_time > end_time) { //超时 + item.approval_comments += "超出请假时长:${(item.add_time - end_time).durationStr()}。" + item.color = "#ff4040" + } + if (remark.isNotEmpty()) { + item.approval_comments += "备注:${remark}" + } + } else if (item.vacation_type == 1) { + item.approval_comments = "刷脸进校,自动销假。" + if (item.add_time > end_time) { //超时 + item.approval_comments += "超出请假时长:${(item.add_time - end_time).durationStr()}。" + item.color = "#ff4040" + } + } + logList.add(item) } } @@ -141,7 +166,33 @@ data class LeaveActivity( var type: Int = 0, var unit_id: Int = 0, var unit_name: String = "", - var add_user_type_name: String="" + var add_user_type_name: String = "", + var is_auto_pass: Int = 0, + var vacation_type: Int = 0, + var color: String = "", + val face_infos: MutableList = mutableListOf() ) { + fun getInImg(): FaceInfo? { + val imgList = face_infos.filter { it.isImg() } + if (imgList.isNotEmpty()) { + return imgList[0] + } + return null + } } +data class FaceInfo( + var attachment_name: String = "", + var attachment_id: String = "", + var identity: String = "" +) { + fun isImg(): Boolean { + if (attachment_name.isNullOrBlank()) { + return false + } + if (attachment_name.endsWith(".jpg", true) || attachment_name.endsWith(".png", true)) { + return true + } + return false + } +} diff --git a/app/src/main/java/com/yzx/escreen/model/Vacation.kt b/app/src/main/java/com/yzx/escreen/model/Vacation.kt new file mode 100644 index 0000000..bcc93cb --- /dev/null +++ b/app/src/main/java/com/yzx/escreen/model/Vacation.kt @@ -0,0 +1,21 @@ +package com.yzx.escreen.model + +data class Vacation( + var vacation_time: Long = 0, + var vacation_type: Int = 2, + var vacation_remark: String = "", + var vacation_attachment: String = "", + var id: Int = 0 +) + +data class Attachment( + var name: String, + var id: String, + var identity: String +){ + fun clear(){ + name ="" + id ="" + identity ="" + } +} \ No newline at end of file diff --git a/app/src/main/java/com/yzx/escreen/presenter/HomePresenter.kt b/app/src/main/java/com/yzx/escreen/presenter/HomePresenter.kt index 19fc834..1857494 100644 --- a/app/src/main/java/com/yzx/escreen/presenter/HomePresenter.kt +++ b/app/src/main/java/com/yzx/escreen/presenter/HomePresenter.kt @@ -4,15 +4,9 @@ import com.blankj.utilcode.util.LogUtils import com.lzy.okgo.OkGo import com.lzy.okgo.model.Response import com.yzx.escreen.config.Config -import com.yzx.escreen.model.LeaveID -import com.yzx.escreen.model.Pager -import com.yzx.escreen.model.StuLeave -import com.yzx.escreen.model.User +import com.yzx.escreen.model.* +import com.yzx.escreen.presenter.base.* import com.yzx.webebook.config.YzxInterface -import com.yzx.escreen.presenter.base.BasePresenter -import com.yzx.escreen.presenter.base.IView -import com.yzx.escreen.presenter.base.JsonCallBack -import com.yzx.escreen.presenter.base.YzxResponse class HomePresenter(view: HomeView) : BasePresenter(view) { @@ -94,6 +88,35 @@ class HomePresenter(view: HomeView) : BasePresenter(view) { }) } + fun postVacation(data:Vacation){ + if(!User.isLogin()){ + return + } + val url = "${Config.BASE_URL}${YzxInterface.INTERFACE_STUDENT_POST_LEAVE_VACATION}" + OkGo.post(url) + .tag(this) + .params("id", data.id) + .params("vacation_type", data.vacation_type) + .params("vacation_time", data.vacation_time) + .params("vacation_remark", data.vacation_remark) + .params("vacation_attachment", data.vacation_attachment) + .execute(object : JsonCallBack() { + + + override fun onSuccess(response: Response?) { + LogUtils.d(response) + if (response?.isSuccessful == true) { + mView?.postVacationSuccess("销假成功!") + } + } + + override fun onError(response: Response?) { + super.onError(response) + LogUtils.d(response) + mView?.postVacationError(response?.body()?.msg ?: "销假失败,请重试!") + } + }) + } } @@ -103,4 +126,6 @@ interface HomeView : IView { fun onLeaveDetailSuccess(detail: StuLeave) fun onLeaveDetailError(error: String) fun onLeaveIDsSuccess(list: MutableList) + fun postVacationSuccess(msg: String) + fun postVacationError(msg: String) } \ No newline at end of file diff --git a/app/src/main/java/com/yzx/escreen/utils/FileUpload.kt b/app/src/main/java/com/yzx/escreen/utils/FileUpload.kt new file mode 100644 index 0000000..f43e010 --- /dev/null +++ b/app/src/main/java/com/yzx/escreen/utils/FileUpload.kt @@ -0,0 +1,49 @@ +package com.yzx.escreen.utils + +import com.lzy.okgo.OkGo +import com.lzy.okgo.callback.StringCallback +import com.lzy.okgo.model.Response +import com.yzx.escreen.model.User +import com.yzx.webebook.config.YzxInterface +import org.json.JSONObject +import java.io.File + +object FileUpload { + + fun upload(path: String, callBack: FileUploadCallBack) { + val user = User.getUser() + OkGo.post(YzxInterface.FILE_UPLOAD_URL) + .tag(this) + .params("token", user.token) + .params("user", user.user_id) + .params("file", File(path)) + .execute(object : StringCallback() { + override fun onSuccess(response: Response) { + try { + val noteJson = response.body() + val noteJsonObject = JSONObject(noteJson) + val noteContent = noteJsonObject.optString("content") + val noteContentObject = JSONObject(noteContent) + val noteKey = noteContentObject.optString("key") + val noteIdentity = noteContentObject.optString("identity") + callBack.onSuccess(noteIdentity, noteKey) + } catch (e: Exception) { + } + } + + override fun onError(response: Response) { + super.onError(response) + callBack.onError("上传失败") + } + + override fun onFinish() { + super.onFinish() + } + }) + } +} + +interface FileUploadCallBack { + fun onSuccess(identity: String, key: String) + fun onError(msg: String) +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_camera.xml b/app/src/main/res/layout/activity_camera.xml new file mode 100644 index 0000000..97d6aa3 --- /dev/null +++ b/app/src/main/res/layout/activity_camera.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_vacation.xml b/app/src/main/res/layout/dialog_vacation.xml new file mode 100644 index 0000000..6865512 --- /dev/null +++ b/app/src/main/res/layout/dialog_vacation.xml @@ -0,0 +1,206 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index 0490d11..26af7be 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -129,6 +129,22 @@ app:qmui_backgroundColor="#fff" app:qmui_borderColor="#dcdee0" /> + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/layout_leave_step.xml b/app/src/main/res/layout/layout_leave_step.xml index dc44d43..9204b85 100644 --- a/app/src/main/res/layout/layout_leave_step.xml +++ b/app/src/main/res/layout/layout_leave_step.xml @@ -1,6 +1,6 @@ - + android:gravity="center_horizontal" + android:orientation="vertical"> + + + app:qmui_radius="@dimen/d_3" /> + android:textStyle="bold" + tools:text="王大仙" /> + android:textStyle="bold" + tools:text="(学生家长)" /> + android:textStyle="bold" + tools:text="提交申请" /> + android:textStyle="bold" + tools:text="提交申请" /> + tools:text="审批人:颜小华。允许出校,请放行" /> + android:orientation="horizontal"> + android:layout_marginEnd="@dimen/dp_10" + android:background="@color/white" /> + tools:text="2022-4-21 15:50:42" /> + + \ No newline at end of file diff --git a/app/src/main/res/layout/layout_leave_table.xml b/app/src/main/res/layout/layout_leave_table.xml index 8c28cd8..a7b9f17 100644 --- a/app/src/main/res/layout/layout_leave_table.xml +++ b/app/src/main/res/layout/layout_leave_table.xml @@ -17,8 +17,8 @@ android:id="@+id/studentName" style="@style/table_cell" android:layout_weight="1.5" - android:text="请假学生" - android:paddingStart="@dimen/dp_40"/> + android:paddingStart="@dimen/dp_40" + android:text="请假学生" /> + app:qmui_border_color="@color/white" + app:qmui_corner_radius="@dimen/d_5" /> + + + + + + + + + \ No newline at end of file