Browse Source

refactor(更新)
- 区域管理模块新增修改区域功能
- 重置密码模块修改密码规则的输入提示
- 重置密码模块UI调整

周文健 3 months ago
parent
commit
bf42f2d6be

+ 53 - 0
app/src/main/java/com/grkj/iscs/features/main/dialog/data_manage/UpdateWorkstationDialog.kt

@@ -0,0 +1,53 @@
+package com.grkj.iscs.features.main.dialog.data_manage
+
+import android.view.View
+import com.grkj.iscs.R
+import com.grkj.iscs.databinding.DialogAddWorkstationBinding
+import com.grkj.ui_base.utils.CommonUtils
+import com.grkj.ui_base.utils.extension.tip
+import com.kongzue.dialogx.dialogs.CustomDialog
+import com.kongzue.dialogx.dialogs.PopTip
+import com.kongzue.dialogx.interfaces.OnBindView
+import com.sik.sikcore.extension.setDebouncedClickListener
+
+/**
+ * 修改区域对话框,基于 DialogX
+ * 使用:
+ * UpdateWorkstationDialog.show { name -> /* handle */ }
+ */
+class UpdateWorkstationDialog(
+    val workstationName: String, private val onConfirm: (String, CustomDialog) -> Unit
+) : OnBindView<CustomDialog>(R.layout.dialog_add_workstation) {
+
+    private lateinit var binding: DialogAddWorkstationBinding
+
+    override fun onBind(dialog: CustomDialog, v: View) {
+        binding = DialogAddWorkstationBinding.bind(v)
+        dialog?.isCancelable = false
+        dialog?.setMaskColor(CommonUtils.getColor(com.grkj.ui_base.R.color.scrim))
+        binding.workstationNameEt.setText(workstationName)
+        binding.cancel.setDebouncedClickListener { dialog?.dismiss() }
+        binding.closeIv.setDebouncedClickListener { dialog?.dismiss() }
+        binding.confirm.setDebouncedClickListener {
+            val name = binding.workstationNameEt.text.trim().toString()
+            if (name.isEmpty()) {
+                PopTip.build().tip(R.string.please_input_workstation_name)
+            } else {
+                onConfirm(name, dialog)
+            }
+        }
+    }
+
+    companion object {
+        /**
+         * 显示新增区域对话框
+         */
+        @JvmStatic
+        fun show(workstationName: String, onConfirm: (String, CustomDialog) -> Unit) {
+            CustomDialog.show(
+                UpdateWorkstationDialog(workstationName, onConfirm),
+                CustomDialog.ALIGN.CENTER
+            )
+        }
+    }
+}

+ 43 - 0
app/src/main/java/com/grkj/iscs/features/main/fragment/data_manage/WorkstationManageFragment.kt

@@ -14,6 +14,7 @@ import com.grkj.iscs.R
 import com.grkj.iscs.databinding.FragmentWorkstationManageBinding
 import com.grkj.iscs.databinding.ItemWorkstationBinding
 import com.grkj.iscs.features.main.dialog.data_manage.AddWorkstationDialog
+import com.grkj.iscs.features.main.dialog.data_manage.UpdateWorkstationDialog
 import com.grkj.iscs.features.main.viewmodel.data_manage.WorkstationManageViewModel
 import com.grkj.ui_base.base.BaseFragment
 import com.grkj.ui_base.dialog.TipDialog
@@ -40,6 +41,48 @@ class WorkstationManageFragment : BaseFragment<FragmentWorkstationManageBinding>
         binding.back.setDebouncedClickListener {
             navController.popBackStack()
         }
+        binding.edit.setDebouncedClickListener {
+            if (viewModel.workstationManageData.none { it.isSelected }) {
+                PopTip.build().tip(R.string.please_select_workstation)
+                return@setDebouncedClickListener
+            }
+            UpdateWorkstationDialog.show(viewModel.workstationManageData.first { it.isSelected }.workstationName) { data, dialog ->
+                viewModel.validateWorkstationData(data).observe(this) {
+                    val updateWorkstation = viewModel.workstationManageData.first { it.isSelected }
+                    updateWorkstation.workstationName = data
+                    viewModel.updateWorkstation(updateWorkstation).observe(this) {
+                        dialog.dismiss()
+                        if (it) {
+                            TipDialog.show(
+                                title = CommonUtils.getStr(com.grkj.ui_base.R.string.action_succeed)
+                                    .toString(),
+                                dialogType = TipDialog.DialogType.SUCCESS,
+                                msg = CommonUtils.getStr(R.string.update_workstation_succeed)
+                                    .toString(),
+                                countDownTime = 10,
+                                showConfirm = false,
+                                onCancelClick = {
+                                    getWorkstationManageData()
+                                }
+                            )
+                        } else {
+                            TipDialog.show(
+                                title = CommonUtils.getStr(com.grkj.ui_base.R.string.action_failed)
+                                    .toString(),
+                                dialogType = TipDialog.DialogType.ERROR,
+                                msg = CommonUtils.getStr(R.string.update_workstation_failed)
+                                    .toString(),
+                                countDownTime = 10,
+                                showConfirm = false,
+                                onCancelClick = {
+                                    getWorkstationManageData()
+                                }
+                            )
+                        }
+                    }
+                }
+            }
+        }
         binding.addWorkstation.setDebouncedClickListener {
             AddWorkstationDialog.show { data, dialog ->
                 viewModel.validateWorkstationData(data).observe(this) {

+ 15 - 1
app/src/main/java/com/grkj/iscs/features/main/fragment/user_info/ResetPasswordFragment.kt

@@ -1,6 +1,7 @@
 package com.grkj.iscs.features.main.fragment.user_info
 
 import androidx.fragment.app.viewModels
+import com.grkj.data.data.CommonConstants
 import com.grkj.data.data.MainDomainData
 import com.grkj.iscs.R
 import com.grkj.iscs.databinding.FragmentResetPasswordBinding
@@ -12,6 +13,7 @@ import com.grkj.ui_base.utils.CommonUtils
 import com.grkj.ui_base.utils.event.LogoutEvent
 import com.kongzue.dialogx.dialogs.PopTip
 import com.sik.sikcore.extension.setDebouncedClickListener
+import com.sik.sikcore.string.RegexUtils
 import dagger.hilt.android.AndroidEntryPoint
 
 /**
@@ -56,7 +58,11 @@ class ResetPasswordFragment : BaseFragment<FragmentResetPasswordBinding>() {
     }
 
     private fun checkData(): Boolean {
-        if (!BCryptUtils.matchPassword(binding.oldPasswordEt.text.toString(), MainDomainData.userInfo?.password?:"")){
+        if (!BCryptUtils.matchPassword(
+                binding.oldPasswordEt.text.toString(),
+                MainDomainData.userInfo?.password ?: ""
+            )
+        ) {
             PopTip.tip(R.string.old_password_error)
             return false
         }
@@ -68,6 +74,14 @@ class ResetPasswordFragment : BaseFragment<FragmentResetPasswordBinding>() {
             PopTip.tip(R.string.please_input_new_password)
             return false
         }
+        if (!RegexUtils.isMatch(
+                binding.newPasswordEt.text.toString(),
+                CommonConstants.REGEX_PASSWORD
+            )
+        ) {
+            showToast(getString(R.string.password_regex_tip))
+            return false
+        }
         if (binding.repeatNewPasswordEt.text.toString().isEmpty()) {
             PopTip.tip(R.string.please_input_repeat_new_password)
             return false

+ 10 - 0
app/src/main/java/com/grkj/iscs/features/main/viewmodel/data_manage/WorkstationManageViewModel.kt

@@ -161,4 +161,14 @@ class WorkstationManageViewModel @Inject constructor(val workstationRepository:
             }
         }
     }
+
+    /**
+     * 更新区域信息
+     */
+    fun updateWorkstation(updateWorkstation: WorkstationManageVo): LiveData<Boolean> {
+        return liveData(Dispatchers.IO){
+            workstationRepository.updateWorkstation(updateWorkstation.workstationId,updateWorkstation.workstationName)
+            emit(true)
+        }
+    }
 }

+ 118 - 0
app/src/main/res/layout/dialog_update_workstation.xml

@@ -0,0 +1,118 @@
+<?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">
+
+    <LinearLayout
+        android:layout_width="@dimen/dialog_common_root_width"
+        android:layout_height="@dimen/dialog_common_root_height_small"
+        android:background="@drawable/common_card_bg"
+        android:orientation="vertical">
+
+        <LinearLayout
+            android:id="@+id/title_layout"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:gravity="center_vertical"
+            android:orientation="horizontal"
+            android:paddingHorizontal="@dimen/common_spacing"
+            android:paddingVertical="@dimen/common_spacing_small">
+
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:text="@string/workstation_manage_update_workstation"
+                android:textColor="@color/black"
+                android:textSize="@dimen/common_btn_text_size" />
+
+            <ImageView
+                android:id="@+id/close_iv"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:paddingHorizontal="@dimen/common_spacing"
+                android:src="@drawable/icon_close" />
+        </LinearLayout>
+
+        <View
+            android:layout_width="match_parent"
+            android:layout_height="@dimen/divider_line_space"
+            android:background="@color/black" />
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_weight="1"
+            android:orientation="vertical">
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="@dimen/common_spacing_2x"
+                android:gravity="center_vertical"
+                android:orientation="horizontal"
+                android:paddingHorizontal="@dimen/dialog_content_normal_padding_horizontal">
+
+                <com.grkj.ui_base.widget.RequiredTextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/workstation_manage_workstation_name"
+                    android:textColor="@color/black"
+                    android:textSize="@dimen/common_text_size"
+                    app:markPosition="end"
+                    app:required="true" />
+
+                <EditText
+                    android:id="@+id/workstation_name_et"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_marginLeft="@dimen/common_spacing"
+                    android:background="@drawable/bg_common_input"
+                    android:hint="@string/please_input_workstation_name"
+                    android:maxLines="1"
+                    android:paddingHorizontal="@dimen/common_spacing"
+                    android:paddingVertical="2dp"
+                    android:singleLine="true"
+                    android:textColor="@color/black"
+                    android:textSize="@dimen/common_text_size" />
+            </LinearLayout>
+        </LinearLayout>
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:gravity="right"
+            android:orientation="horizontal"
+            android:padding="@dimen/common_spacing">
+
+            <TextView
+                android:id="@+id/confirm"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginLeft="@dimen/common_spacing"
+                android:background="@drawable/common_btn_confirm"
+                android:drawableLeft="@mipmap/icon_confirm"
+                android:drawablePadding="@dimen/common_spacing"
+                android:gravity="center"
+                android:minHeight="@dimen/common_btn_height"
+                android:paddingHorizontal="@dimen/common_spacing_2x"
+                android:text="@string/confirm"
+                android:textColor="@color/white"
+                android:textSize="@dimen/common_btn_text_size" />
+
+            <TextView
+                android:id="@+id/cancel"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginLeft="@dimen/common_spacing"
+                android:background="@drawable/common_btn_cancel"
+                android:drawableLeft="@mipmap/icon_cancel"
+                android:drawablePadding="@dimen/common_spacing"
+                android:gravity="center"
+                android:minHeight="@dimen/common_btn_height"
+                android:paddingHorizontal="@dimen/common_spacing_2x"
+                android:text="@string/cancel"
+                android:textColor="@color/white"
+                android:textSize="@dimen/common_btn_text_size" />
+        </LinearLayout>
+    </LinearLayout>
+</layout>

+ 12 - 19
app/src/main/res/layout/fragment_reset_password.xml

@@ -77,7 +77,7 @@
                 android:id="@+id/old_password_et"
                 android:layout_width="0dp"
                 android:layout_height="wrap_content"
-                android:layout_marginLeft="@dimen/common_spacing"
+                android:layout_marginTop="@dimen/common_spacing"
                 android:background="@drawable/bg_common_input"
                 android:hint="@string/please_input_old_password"
                 android:inputType="textPassword"
@@ -88,8 +88,8 @@
                 android:textColor="@color/black"
                 android:textSize="@dimen/common_text_size"
                 app:layout_constraintEnd_toEndOf="parent"
-                app:layout_constraintStart_toEndOf="@+id/end_line"
-                app:layout_constraintTop_toTopOf="@+id/old_password_tv" />
+                app:layout_constraintStart_toStartOf="@+id/old_password_tv"
+                app:layout_constraintTop_toBottomOf="@+id/old_password_tv" />
 
             <TextView
                 android:id="@+id/new_password_tv"
@@ -100,13 +100,13 @@
                 android:textColor="@color/black"
                 android:textSize="@dimen/common_text_size"
                 app:layout_constraintEnd_toEndOf="@+id/end_line"
-                app:layout_constraintTop_toBottomOf="@+id/old_password_tv" />
+                app:layout_constraintTop_toBottomOf="@+id/old_password_et" />
 
             <EditText
                 android:id="@+id/new_password_et"
                 android:layout_width="0dp"
                 android:layout_height="wrap_content"
-                android:layout_marginLeft="@dimen/common_spacing"
+                android:layout_marginTop="@dimen/common_spacing"
                 android:background="@drawable/bg_common_input"
                 android:hint="@string/please_input_new_password"
                 android:inputType="textPassword"
@@ -117,8 +117,8 @@
                 android:textColor="@color/black"
                 android:textSize="@dimen/common_text_size"
                 app:layout_constraintEnd_toEndOf="parent"
-                app:layout_constraintStart_toEndOf="@+id/end_line"
-                app:layout_constraintTop_toTopOf="@+id/new_password_tv" />
+                app:layout_constraintStart_toStartOf="@+id/new_password_tv"
+                app:layout_constraintTop_toBottomOf="@+id/new_password_tv" />
 
 
             <TextView
@@ -129,15 +129,15 @@
                 android:text="@string/repeat_new_password"
                 android:textColor="@color/black"
                 android:textSize="@dimen/common_text_size"
-                app:layout_constraintStart_toStartOf="parent"
                 app:layout_constraintEnd_toEndOf="@+id/end_line"
-                app:layout_constraintTop_toBottomOf="@+id/new_password_tv" />
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintTop_toBottomOf="@+id/new_password_et" />
 
             <EditText
                 android:id="@+id/repeat_new_password_et"
                 android:layout_width="0dp"
                 android:layout_height="wrap_content"
-                android:layout_marginLeft="@dimen/common_spacing"
+                android:layout_marginTop="@dimen/common_spacing"
                 android:background="@drawable/bg_common_input"
                 android:hint="@string/please_input_repeat_new_password"
                 android:inputType="textPassword"
@@ -148,15 +148,8 @@
                 android:textColor="@color/black"
                 android:textSize="@dimen/common_text_size"
                 app:layout_constraintEnd_toEndOf="parent"
-                app:layout_constraintStart_toEndOf="@+id/end_line"
-                app:layout_constraintTop_toTopOf="@+id/repeat_new_password_tv" />
-
-            <androidx.constraintlayout.widget.Barrier
-                android:id="@+id/end_line"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                app:barrierDirection="end"
-                app:constraint_referenced_ids="repeat_new_password_tv,new_password_tv,old_password_tv" />
+                app:layout_constraintStart_toStartOf="@+id/repeat_new_password_tv"
+                app:layout_constraintTop_toBottomOf="@+id/repeat_new_password_tv" />
 
         </androidx.constraintlayout.widget.ConstraintLayout>
 

+ 10 - 0
app/src/main/res/layout/fragment_workstation_manage.xml

@@ -72,6 +72,16 @@
                 android:textColor="@color/black"
                 android:textSize="@dimen/common_btn_text_size" />
 
+            <TextView
+                android:id="@+id/edit"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginLeft="@dimen/common_spacing"
+                android:background="@drawable/common_btn"
+                android:paddingHorizontal="@dimen/common_spacing_2x"
+                android:text="@string/edit"
+                android:textColor="@color/black"
+                android:textSize="@dimen/common_btn_text_size" />
 
             <TextView
                 android:id="@+id/delete_workstation"

+ 5 - 2
app/src/main/res/values-en/strings.xml

@@ -177,10 +177,10 @@
     <string name="reset_password_title">Reset password</string>
     <string name="old_password">Old password</string>
     <string name="please_input_old_password">please input old password</string>
-    <string name="new_password">New password</string>
+    <string name="new_password">New password(numbers, letters, 6-20 digits)</string>
     <string name="please_input_new_password">please input new password</string>
     <string name="please_input_repeat_new_password">please input repeat new password</string>
-    <string name="repeat_new_password">Repeat new password</string>
+    <string name="repeat_new_password">Repeat new password(numbers, letters, 6-20 digits)</string>
     <string name="new_password_and_repeat_new_password_not_same">The new password does not match the repeated new password</string>
     <string name="new_password_cannot_be_the_same_as_the_old_password">The new password cannot be the same as the old password</string>
     <string name="reset_user_password_succeed">reset user password succeed</string>
@@ -554,5 +554,8 @@
     <string name="key_in_use">Key in use</string>
     <string name="password_regex_tip">The password does not meet the requirements</string>
     <string name="username_regex_tip">Account number does not meet the requirements</string>
+    <string name="workstation_manage_update_workstation">Edit workstation</string>
+    <string name="update_workstation_succeed">Update workstation success</string>
+    <string name="update_workstation_failed">Update workstation failed</string>
 
 </resources>

+ 5 - 2
app/src/main/res/values-zh/strings.xml

@@ -177,10 +177,10 @@
     <string name="reset_password_title">重置密码</string>
     <string name="old_password">旧密码</string>
     <string name="please_input_old_password">请输入旧密码</string>
-    <string name="new_password">新密码</string>
+    <string name="new_password">新密码(数字、字母、特殊符号、6-20位)</string>
     <string name="please_input_new_password">请输入新密码</string>
     <string name="please_input_repeat_new_password">请重复新密码</string>
-    <string name="repeat_new_password">重复新密码</string>
+    <string name="repeat_new_password">重复新密码(数字、字母、特殊符号、6-20位)</string>
     <string name="new_password_and_repeat_new_password_not_same">新密码与重复新密码不一致</string>
     <string name="new_password_cannot_be_the_same_as_the_old_password">新密码与旧密码不能相同</string>
     <string name="reset_user_password_succeed">用户密码重置成功</string>
@@ -554,5 +554,8 @@
     <string name="key_in_use">钥匙正在使用</string>
     <string name="password_regex_tip">密码不符合要求</string>
     <string name="username_regex_tip">账号不符合要求</string>
+    <string name="workstation_manage_update_workstation">修改区域</string>
+    <string name="update_workstation_succeed">更新区域成功</string>
+    <string name="update_workstation_failed">更新区域失败</string>
 
 </resources>

+ 5 - 2
app/src/main/res/values/strings.xml

@@ -176,10 +176,10 @@
     <string name="reset_password_title">重置密码</string>
     <string name="old_password">旧密码</string>
     <string name="please_input_old_password">请输入旧密码</string>
-    <string name="new_password">新密码</string>
+    <string name="new_password">新密码(数字、字母、特殊符号、6-20位)</string>
     <string name="please_input_new_password">请输入新密码</string>
     <string name="please_input_repeat_new_password">请重复新密码</string>
-    <string name="repeat_new_password">重复新密码</string>
+    <string name="repeat_new_password">重复新密码(数字、字母、特殊符号、6-20位)</string>
     <string name="new_password_and_repeat_new_password_not_same">新密码与重复新密码不一致</string>
     <string name="new_password_cannot_be_the_same_as_the_old_password">新密码与旧密码不能相同</string>
     <string name="reset_user_password_succeed">用户密码重置成功</string>
@@ -557,5 +557,8 @@
     <string name="key_in_use">钥匙正在使用</string>
     <string name="password_regex_tip">密码不符合要求</string>
     <string name="username_regex_tip">账号不符合要求</string>
+    <string name="workstation_manage_update_workstation">修改区域</string>
+    <string name="update_workstation_succeed">更新区域成功</string>
+    <string name="update_workstation_failed">更新区域失败</string>
 
 </resources>

+ 6 - 0
data/src/main/java/com/grkj/data/dao/WorkstationDao.kt

@@ -61,4 +61,10 @@ interface WorkstationDao {
         parentId: Long,
         workstationName: String
     ): IsWorkstation?
+
+    /**
+     * 更新区域名称
+     */
+    @Query("update is_workstation set workstation_name = :workstationName where workstation_id = :workstationId")
+    fun updateWorkstationNameByWorkstationId(workstationId: Long, workstationName: String)
 }

+ 5 - 0
data/src/main/java/com/grkj/data/logic/IWorkstationLogic.kt

@@ -46,4 +46,9 @@ interface IWorkstationLogic {
      * 根据父id和区域名称获取区域数据
      */
     fun getWorkstationDataByParentIdAndWorkstationName(parentId: Long, workstationName: String): IsWorkstation?
+
+    /**
+     * 更新区域设定
+     */
+    fun updateWorkstation(workstationId: Long, workstationName: String)
 }

+ 4 - 0
data/src/main/java/com/grkj/data/logic/impl/network/NetworkWorkstationLogic.kt

@@ -43,6 +43,10 @@ class NetworkWorkstationLogic @Inject constructor()  : BaseLogic(), IWorkstation
         TODO("Not yet implemented")
     }
 
+    override fun updateWorkstation(workstationId: Long, workstationName: String) {
+        TODO("Not yet implemented")
+    }
+
     override fun deleteWorkstationByWorkstationId(workstationId: Long) {
         TODO("Not yet implemented")
     }

+ 4 - 0
data/src/main/java/com/grkj/data/logic/impl/standard/WorkstationLogic.kt

@@ -31,6 +31,10 @@ class WorkstationLogic @Inject constructor(val workstationDao: WorkstationDao) :
         workstationDao.deleteUserWorkstationByUserIds(userIds)
     }
 
+    override fun updateWorkstation(workstationId: Long, workstationName: String) {
+        workstationDao.updateWorkstationNameByWorkstationId(workstationId, workstationName)
+    }
+
     override fun getWorkstationManageData(): List<WorkstationManageVo> {
         return buildTree(workstationDao.getWorkstationData())
     }