Forráskód Böngészése

1.添加测评module

王鹏鹏 2 éve
szülő
commit
ecd9cdbba2

+ 18 - 0
evaluation/src/main/java/com/yingyangfly/evaluation/adapter/EvaluationTypeAdapter.kt

@@ -0,0 +1,18 @@
+package com.yingyangfly.evaluation.adapter
+
+import com.yingyangfly.baselib.adapter.BaseDataBindingAdapter
+import com.yingyangfly.evaluation.R
+import com.yingyangfly.evaluation.databinding.ItemEvaluationTypeBinding
+import com.yingyangfly.evaluation.entity.EvaluationTypeBean
+
+/**
+ * 其他测评试题类型adapter
+ */
+class EvaluationTypeAdapter(override val layoutId: Int = R.layout.item_evaluation_type) :
+    BaseDataBindingAdapter<EvaluationTypeBean, ItemEvaluationTypeBinding>() {
+    override fun onBindViewHolder(
+        binding: ItemEvaluationTypeBinding, item: EvaluationTypeBean, position: Int
+    ) {
+        binding.data = item
+    }
+}

+ 20 - 0
evaluation/src/main/java/com/yingyangfly/evaluation/entity/EvaluationTypeBean.kt

@@ -0,0 +1,20 @@
+package com.yingyangfly.evaluation.entity
+
+/**
+ * 其他测评试题类型
+ */
+data class EvaluationTypeBean(
+    val createBy: String,
+    val createTime: String,
+    val dictLabel: String,
+    val dictType: String,
+    val dictValue: String,
+    val id: String,
+    val limit: Int,
+    val orderNum: String,
+    val orgCode: String,
+    val page: Int,
+    val status: String,
+    val updateBy: String,
+    val updateTime: String
+)

+ 35 - 1
evaluation/src/main/java/com/yingyangfly/evaluation/hospital/HospitalActivity.kt

@@ -63,7 +63,6 @@ class HospitalActivity : BaseTvMVVMActivity<ActivityHospitalBinding, HospitalVie
     }
 
     override fun initData() {
-
     }
 
     @SuppressLint("ClickableViewAccessibility")
@@ -147,10 +146,45 @@ class HospitalActivity : BaseTvMVVMActivity<ActivityHospitalBinding, HospitalVie
         bindingPhoneDialog.onDialogClickListener = {
             binding.imageLoginOut.show(true)
             binding.tvLoginOut.show(true)
+            getUserInfo()
         }
         bindingPhoneDialog.show(supportFragmentManager, "bindingPhoneDialog")
     }
 
+    /**
+     * 获取患者信息
+     */
+    private fun getUserInfo() {
+        viewModel.getUserInfo(fail = {
+            it.toast()
+        }, success = {
+            if (it != null) {
+                if (TextUtils.isEmpty(it.mobile).not()) {
+                    User.saveMobile(it.mobile)
+                }
+                if (TextUtils.isEmpty(it.idCard).not()) {
+                    User.saveIdCard(it.idCard)
+                }
+                //保存用户头像
+                if (TextUtils.isEmpty(it.avatar).not()) {
+                    User.saveAvatar(it.avatar)
+                }
+                //保存用户名
+                if (TextUtils.isEmpty(it.name).not()) {
+                    User.saveName(it.name)
+                }
+                if (TextUtils.isEmpty(it.orgCode).not()) {
+                    User.saveOrgCode(it.orgCode)
+                }
+                User.saveUserSex(it.getSex())
+                User.saveUserAge(it.getAgeInfo())
+                if (TextUtils.isEmpty(it.id).not()) {
+                    User.saveUserId(it.id)
+                }
+            }
+        })
+    }
+
     /**
      * 获取测评任务
      */

+ 13 - 0
evaluation/src/main/java/com/yingyangfly/evaluation/hospital/HospitalViewModel.kt

@@ -1,5 +1,6 @@
 package com.yingyangfly.evaluation.hospital
 
+import com.yingyangfly.baselib.bean.UserInfoBean
 import com.yingyangfly.baselib.db.QuestionsBean
 import com.yingyangfly.baselib.mvvm.BaseViewModel
 import com.yingyangfly.baselib.net.XUtils
@@ -15,6 +16,18 @@ import com.yingyangfly.evaluation.net.EVALUATION_API
  */
 class HospitalViewModel : BaseViewModel() {
 
+    /**
+     * 获取患者信息
+     */
+    fun getUserInfo(
+        fail: ((msg: String) -> Unit)? = null,
+        success: ((success: UserInfoBean?) -> Unit)? = null,
+    ) = launchFlow(true) {
+        EVALUATION_API.getUserInfo()
+    }.runUI(
+        success, fail
+    )
+
     /**
      * 获取mmse试题
      */

+ 15 - 0
evaluation/src/main/java/com/yingyangfly/evaluation/net/EvaluationApiService.kt

@@ -1,16 +1,25 @@
 package com.yingyangfly.evaluation.net
 
+import com.yingyangfly.baselib.bean.UserInfoBean
 import com.yingyangfly.baselib.db.QuestionsBean
 import com.yingyangfly.baselib.net.BaseResp
 import com.yingyangfly.evaluation.entity.EvaluationHistoryBean
+import com.yingyangfly.evaluation.entity.EvaluationTypeBean
 import com.yingyangfly.evaluation.entity.ReviewResultDetailBean
 import com.yingyangfly.evaluation.entity.ReviewTaskListBean
 import okhttp3.RequestBody
 import retrofit2.http.Body
 import retrofit2.http.POST
+import retrofit2.http.Query
 
 interface EvaluationApiService {
 
+    /**
+     * 获取个人中心信息接口
+     */
+    @POST("app/user/info")
+    suspend fun getUserInfo(): BaseResp<UserInfoBean>
+
     /**
      * 获取测评任务
      */
@@ -41,4 +50,10 @@ interface EvaluationApiService {
     @POST("app/review/findReviewResultDetail")
     suspend fun findReviewResultDetail(@Body requestBody: RequestBody): BaseResp<List<ReviewResultDetailBean>>
 
+    /**
+     * 获取推送消息类型
+     */
+    @POST("system/dict/data/selectByDictType")
+    suspend fun getSelectByDictType(@Query("dictType") dictType: String): BaseResp<List<EvaluationTypeBean>>
+
 }

+ 44 - 3
evaluation/src/main/java/com/yingyangfly/evaluation/otherevaluation/OtherEvaluationActivity.kt

@@ -1,18 +1,37 @@
 package com.yingyangfly.evaluation.otherevaluation
 
+import android.annotation.SuppressLint
+import androidx.recyclerview.widget.LinearLayoutManager
+import androidx.recyclerview.widget.RecyclerView
 import com.alibaba.android.arouter.facade.annotation.Route
-import com.yingyangfly.baselib.base.BaseTvActivity
+import com.yingyangfly.baselib.ext.toast
+import com.yingyangfly.baselib.mvvm.BaseMVVMActivity
 import com.yingyangfly.baselib.router.RouterUrlCommon
+import com.yingyangfly.evaluation.adapter.EvaluationTypeAdapter
 import com.yingyangfly.evaluation.databinding.ActivityOtherEvaluationBinding
+import com.yingyangfly.evaluation.entity.EvaluationTypeBean
 
 /**
  * 其他测评功能页面
  */
 @Route(path = RouterUrlCommon.otherEvaluation)
-class OtherEvaluationActivity : BaseTvActivity<ActivityOtherEvaluationBinding>() {
+class OtherEvaluationActivity :
+    BaseMVVMActivity<ActivityOtherEvaluationBinding, OtherEvaluationViewModel>() {
 
-    override fun initViews() {
+    /**
+     * 消息类型adapter
+     */
+    private var evaluationType = ""
+    private var evaluationTypeList = mutableListOf<EvaluationTypeBean>()
+    private val evaluationAdapter by lazy { EvaluationTypeAdapter() }
 
+    override fun initViews() {
+        binding {
+            val layoutManager =
+                LinearLayoutManager(this@OtherEvaluationActivity, RecyclerView.HORIZONTAL, false)
+            rvEvaluationType.layoutManager = layoutManager
+            rvEvaluationType.adapter = evaluationAdapter
+        }
     }
 
     override fun initListener() {
@@ -22,4 +41,26 @@ class OtherEvaluationActivity : BaseTvActivity<ActivityOtherEvaluationBinding>()
     override fun initData() {
 
     }
+
+    override fun onResume() {
+        super.onResume()
+        getEvaluationType()
+    }
+
+    /**
+     * 获取试题类型
+     */
+    @SuppressLint("NotifyDataSetChanged")
+    private fun getEvaluationType() {
+        evaluationTypeList.clear()
+        viewModel.getSelectByDictType(fail = {
+            it.toast()
+        }, success = {
+            evaluationTypeList.clear()
+            if (it.isNullOrEmpty().not()) {
+                evaluationTypeList.addAll(it!!)
+            }
+            evaluationAdapter.notifyDataSetChanged()
+        })
+    }
 }

+ 26 - 0
evaluation/src/main/java/com/yingyangfly/evaluation/otherevaluation/OtherEvaluationViewModel.kt

@@ -0,0 +1,26 @@
+package com.yingyangfly.evaluation.otherevaluation
+
+import com.yingyangfly.baselib.mvvm.BaseViewModel
+import com.yingyangfly.evaluation.entity.EvaluationTypeBean
+import com.yingyangfly.evaluation.entity.GetEvaluationTypeBean
+import com.yingyangfly.evaluation.net.EVALUATION_API
+
+/**
+ * @author 王鹏鹏
+ * @description 工作台页面ViewModel
+ */
+class OtherEvaluationViewModel : BaseViewModel() {
+
+    /**
+     * 获取推送消息类型
+     */
+    fun getSelectByDictType(
+        fail: ((msg: String) -> Unit)? = null,
+        success: ((success: List<EvaluationTypeBean>?) -> Unit)? = null,
+    ) = launchFlow(false) {
+        EVALUATION_API.getSelectByDictType("exam_type")
+    }.runUI(
+        success,
+        fail
+    )
+}

+ 85 - 2
evaluation/src/main/res/layout/activity_other_evaluation.xml

@@ -1,12 +1,95 @@
 <?xml version="1.0" encoding="utf-8"?>
 <layout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
     tools:ignore="ResourceName">
 
     <androidx.constraintlayout.widget.ConstraintLayout
-        android:layout_width="match_parent"
-        android:layout_height="match_parent">
+        style="@style/layout_properties_specify_width_geight"
+        android:background="@mipmap/icon_uniform_background">
 
+        <LinearLayout
+            android:id="@+id/layoutHead"
+            style="@style/back_layout"
+            tools:ignore="MissingConstraints">
+
+            <androidx.appcompat.widget.AppCompatImageView style="@style/back_image" />
+
+            <androidx.appcompat.widget.AppCompatTextView style="@style/back_text" />
+        </LinearLayout>
+
+        <androidx.appcompat.widget.AppCompatTextView
+            android:id="@+id/tvTitle"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="@dimen/divider_32px"
+            android:text="@string/evaluation"
+            android:textColor="@android:color/white"
+            android:textSize="@dimen/divider_34px"
+            android:textStyle="bold"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toTopOf="parent" />
+
+        <com.google.android.material.card.MaterialCardView
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_marginStart="@dimen/divider_22px"
+            android:layout_marginTop="@dimen/divider_29px"
+            android:layout_marginEnd="@dimen/divider_22px"
+            android:layout_marginBottom="@dimen/divider_18px"
+            android:theme="@style/Theme.MaterialComponents.NoActionBar"
+            app:cardBackgroundColor="@android:color/white"
+            app:cardCornerRadius="@dimen/divider_28px"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toBottomOf="@+id/tvTitle">
+
+            <androidx.constraintlayout.widget.ConstraintLayout
+                android:layout_width="match_parent"
+                android:layout_height="match_parent">
+
+                <com.google.android.material.card.MaterialCardView
+                    android:id="@+id/titleLayout"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:theme="@style/Theme.MaterialComponents.NoActionBar"
+                    app:cardBackgroundColor="@android:color/white"
+                    app:cardCornerRadius="@dimen/divider_12px"
+                    app:layout_constraintEnd_toEndOf="parent"
+                    app:layout_constraintStart_toStartOf="parent"
+                    app:layout_constraintTop_toTopOf="parent"
+                    app:strokeColor="@color/color_FF4A76FF"
+                    app:strokeWidth="@dimen/divider_2px">
+
+                    <androidx.recyclerview.widget.RecyclerView
+                        android:id="@+id/rvEvaluationType"
+                        android:layout_width="match_parent"
+                        android:layout_height="match_parent" />
+
+                </com.google.android.material.card.MaterialCardView>
+
+                <LinearLayout
+                    android:layout_width="match_parent"
+                    android:layout_height="0dp"
+                    android:layout_marginStart="@dimen/divider_34px"
+                    android:layout_marginEnd="@dimen/divider_37px"
+                    android:layout_marginBottom="@dimen/divider_36px"
+                    app:layout_constraintBottom_toBottomOf="parent"
+                    app:layout_constraintEnd_toEndOf="parent"
+                    app:layout_constraintStart_toStartOf="parent"
+                    app:layout_constraintTop_toBottomOf="@+id/titleLayout">
+
+                    <androidx.recyclerview.widget.RecyclerView
+                        android:id="@+id/rvResult"
+                        android:layout_width="match_parent"
+                        android:layout_height="match_parent"
+                        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
+                </LinearLayout>
+
+            </androidx.constraintlayout.widget.ConstraintLayout>
+        </com.google.android.material.card.MaterialCardView>
 
     </androidx.constraintlayout.widget.ConstraintLayout>
 

+ 37 - 0
evaluation/src/main/res/layout/item_evaluation_type.xml

@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    tools:ignore="ResourceName">
+
+    <data>
+
+        <variable
+            name="data"
+            type="com.yingyangfly.evaluation.entity.EvaluationTypeBean" />
+    </data>
+
+    <LinearLayout
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:orientation="horizontal">
+
+        <androidx.appcompat.widget.AppCompatTextView
+            android:id="@+id/tvTitle"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:paddingStart="@dimen/divider_26px"
+            android:paddingTop="@dimen/divider_8px"
+            android:paddingEnd="@dimen/divider_25px"
+            android:text="@{data.dictLabel}"
+            android:paddingBottom="@dimen/divider_7px"
+            android:textSize="@dimen/divider_24px" />
+
+        <View
+            android:layout_width="@dimen/divider_2px"
+            android:layout_height="match_parent"
+            android:background="@color/color_FF4A76FF" />
+
+
+    </LinearLayout>
+
+</layout>

BIN
evaluation/src/main/res/mipmap-xxhdpi/icon_back.png


+ 1 - 0
evaluation/src/main/res/values/strings.xml

@@ -68,4 +68,5 @@
     <string name="exit_binding" tools:ignore="ResourceName">退出绑定</string>
     <string name="report_query" tools:ignore="ResourceName">报告查询</string>
     <string name="other_evaluations" tools:ignore="ResourceName">其他测评</string>
+    <string name="evaluation" tools:ignore="ResourceName">测评</string>
 </resources>

+ 0 - 1
evaluation/src/main/res/values/styles.xml

@@ -47,7 +47,6 @@
         <item name="android:layout_height">wrap_content</item>
     </style>
 
-
     <!--自适应高度 居中-->
     <style name="layout_properties_self_adaption_center" parent="layout_properties_self_adaption" tools:ignore="ResourceName">
         <item name="layout_constraintStart_toStartOf">parent</item>