审核活动质量汇报单

master
pan 4 years ago
parent 531c022328
commit f531b72442
  1. 3
      background/src/main/AndroidManifest.xml
  2. 51
      background/src/main/java/com/gyf/csams/main/model/CheckActViewModel.kt
  3. 62
      background/src/main/java/com/gyf/csams/main/model/CheckQualityReportViewModel.kt
  4. 15
      background/src/main/java/com/gyf/csams/main/model/MenuViewModel.kt
  5. 87
      background/src/main/java/com/gyf/csams/main/ui/CheckActActivity.kt
  6. 104
      background/src/main/java/com/gyf/csams/main/ui/CheckQualityReportActivity.kt
  7. 10
      background/src/main/java/com/gyf/csams/main/ui/MainActivity.kt
  8. 6
      background/src/main/java/com/gyf/csams/main/ui/ManagerActActivity.kt
  9. 102
      background/src/main/java/com/gyf/csams/main/ui/RenameActivity.kt
  10. 111
      background/src/main/java/com/gyf/csams/uikit/Table.kt
  11. 9
      background/src/main/res/drawable/ic_collection.xml
  12. 9
      background/src/main/res/drawable/ic_collection_fill.xml
  13. 5
      background/src/main/res/values-en/strings.xml
  14. 5
      background/src/main/res/values-zh/strings.xml
  15. 5
      background/src/main/res/values/strings.xml
  16. 11
      lib/src/main/java/com/gyf/ApplyViewModel.kt
  17. 1
      lib/src/main/res/values-en/strings.xml
  18. 1
      lib/src/main/res/values-zh/strings.xml
  19. 1
      lib/src/main/res/values/strings.xml

@ -29,6 +29,9 @@
<activity android:name=".main.ui.AssociationManagementActivity" />
<activity android:name=".main.ui.MenuActivity" />
<activity android:name=".main.ui.RenameActivity" />
<activity android:name=".main.ui.ManagerActActivity" />
<activity android:name=".main.ui.CheckActActivity" />
<activity android:name=".main.ui.CheckQualityReportActivity" />
</application>
</manifest>

@ -0,0 +1,51 @@
package com.gyf.csams.main.model
import android.app.Application
import androidx.lifecycle.viewModelScope
import com.gyf.ApplyViewModel
import com.gyf.lib.util.format
import com.gyf.lib.util.randomChinese
import com.gyf.lib.util.randomDateTime
import kotlinx.coroutines.launch
data class ApplyActVo(
val activityName: String, val activityTime: String,
val location: String, val desc: String,
val size: Int
)
/**
* 活动数据管理
*
*/
class CheckActViewModel(application: Application) : ApplyViewModel<ApplyActVo>(application) {
override val initSize: Int = 10
init {
load()
}
override fun load() {
viewModelScope.launch {
_data.value?.apply {
repeat(initSize) {
add(
ApplyActVo(
activityName = randomChinese(5),
activityTime = randomDateTime().format(),
location = randomChinese(10),
desc = randomChinese(10),
size = 10
)
)
}
}
}
}
override fun loadMore(callback: (message: String) -> Unit) {
TODO("Not yet implemented")
}
}

@ -0,0 +1,62 @@
package com.gyf.csams.main.model
import android.app.Application
import androidx.annotation.IntRange
import androidx.lifecycle.viewModelScope
import com.gyf.ApplyViewModel
import com.gyf.lib.util.randomChinese
import kotlinx.coroutines.launch
const val MAX_SCORE = 5L
/**
* 活动质量汇报单
*
* @property applyName 申请人
* @property activityName 活动名称
* @property merit 优点
* @property defect 缺点
* @property score 星级评价
*/
data class QualityReportVo(
val applyName: String,
val activityName: String,
val merit: String,
val defect: String,
@IntRange(from = 1L, to = MAX_SCORE) val score: Int
)
/**
* 活动质量汇报单评价
*
*/
class CheckQualityReportViewModel(application: Application) : ApplyViewModel<QualityReportVo>(
application
) {
override val initSize: Int = 10
init {
load()
}
override fun load() {
viewModelScope.launch {
_data.value?.apply {
repeat(initSize) {
add(
QualityReportVo(
applyName = randomChinese(3), activityName = randomChinese(10),
merit = randomChinese(10), defect = randomChinese(10),
score = (1..5).random()
)
)
}
}
}
}
override fun loadMore(callback: (message: String) -> Unit) {
TODO("Not yet implemented")
}
}

@ -2,16 +2,21 @@ package com.gyf.csams.main.model
import android.app.Activity
import androidx.lifecycle.ViewModel
import com.gyf.csams.main.ui.AssociationManagementActivity
import com.gyf.csams.main.ui.RenameActivity
import com.gyf.csams.main.ui.*
enum class MenuType(val desc: String, val clazz: Map<String, Class<out Activity>>) {
//老师
//总部长
Association(
"社团管理", mapOf(
"社团管理",
mapOf(
"社团信息管理" to AssociationManagementActivity::class.java,
"审核换名申请表" to RenameActivity::class.java
),
),
Act(
"活动管理", mapOf(
"审核社团活动" to CheckActActivity::class.java,
"审核质量报告单" to CheckQualityReportActivity::class.java,
"查看社团活动" to ManagerActActivity::class.java
)
)
}

@ -0,0 +1,87 @@
package com.gyf.csams.main.ui
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.runtime.Composable
import androidx.compose.runtime.ExperimentalComposeApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import com.gyf.csams.R
import com.gyf.csams.main.model.ApplyActVo
import com.gyf.csams.main.model.CheckActViewModel
import com.gyf.csams.uikit.RowItem
import com.gyf.csams.uikit.TestTable
import com.gyf.lib.uikit.BaseTextField
import com.gyf.lib.uikit.ScaffoldModel
import com.gyf.lib.util.BottomButton
/**
* 审批社团活动
*
*/
class CheckActActivity : ComponentActivity() {
@ExperimentalComposeApi
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
TestTable(
clazz = CheckActViewModel::class.java,
title = R.string.activity_application
) {
ApplyActForm(vo = it)
}
}
}
@Composable
private fun ApplyActForm(
modifier: Modifier = Modifier, model: CheckActViewModel = viewModel(),
scaffoldModel: ScaffoldModel = viewModel(), vo: ApplyActVo
) {
Column(modifier = modifier) {
val baseHeight = 50.dp
RowItem(
modifier = Modifier.height(baseHeight),
key = R.string.activity_name,
value = vo.activityName
)
RowItem(
modifier = Modifier.height(baseHeight * 1.5F),
key = R.string.activity_address,
value = vo.location
)
RowItem(
modifier = Modifier.height(baseHeight * 3),
key = R.string.activity_desc,
value = vo.desc
)
RowItem(
modifier = Modifier.height(baseHeight),
key = R.string.activity_size,
value = "${vo.size}"
)
RowItem(
modifier = Modifier.height(baseHeight), key = R.string.approver, value = ""
/**TODO 获取审批人**/
)
RowItem(modifier = Modifier.height(baseHeight * 3), key = R.string.approver_origin) {
BaseTextField(modifier = Modifier.fillMaxSize(), form = model.approverOrigin)
}
val message = stringResource(id = R.string.not_impl_error)
BottomButton(
confirmDesc = R.string.reported_btn, backDesc = R.string.reject_btn,
modifier = Modifier.fillMaxWidth()
) {
scaffoldModel.update(message = message)
}
}
}
}

@ -0,0 +1,104 @@
package com.gyf.csams.main.ui
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.ExperimentalComposeApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import com.gyf.csams.R
import com.gyf.csams.main.model.CheckQualityReportViewModel
import com.gyf.csams.main.model.MAX_SCORE
import com.gyf.csams.main.model.QualityReportVo
import com.gyf.csams.uikit.RowItem
import com.gyf.csams.uikit.TestTable
import com.gyf.lib.uikit.BaseTextField
import com.gyf.lib.uikit.ScaffoldModel
import com.gyf.lib.util.BottomButton
/**
* 审批质量报告单
*
*/
class CheckQualityReportActivity : ComponentActivity() {
@ExperimentalComposeApi
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
TestTable(
clazz = CheckQualityReportViewModel::class.java,
title = R.string.quality_report_title
) {
CheckQualityReportForm(vo = it)
}
}
}
@Composable
private fun CheckQualityReportForm(
modifier: Modifier = Modifier, model: CheckQualityReportViewModel = viewModel(),
scaffoldModel: ScaffoldModel = viewModel(), vo: QualityReportVo
) {
Column(modifier = modifier) {
val baseHeight = 50.dp
RowItem(
modifier = Modifier.height(baseHeight),
key = R.string.petitioner,
value = vo.applyName
)
RowItem(
modifier = Modifier.height(baseHeight),
key = R.string.activity_name,
value = vo.activityName
)
RowItem(
modifier = Modifier.height(baseHeight * 3),
key = R.string.activity_merit,
value = vo.merit
)
RowItem(
modifier = Modifier.height(baseHeight * 3),
key = R.string.activitiy_defect,
value = vo.defect
)
RowItem(
modifier = Modifier.height(baseHeight),
key = R.string.activity_evaluate
) {
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.Center
) {
repeat(MAX_SCORE.toInt()) {
Image(
modifier = Modifier.weight(1F / MAX_SCORE),
painter = painterResource(id = if (it < vo.score) R.drawable.ic_collection_fill else R.drawable.ic_collection),
contentDescription = null
)
}
}
}
RowItem(
modifier = Modifier.height(baseHeight), key = R.string.approver, value = ""
/**TODO 获取审批人**/
)
RowItem(modifier = Modifier.height(baseHeight * 3), key = R.string.approver_origin) {
BaseTextField(modifier = Modifier.fillMaxSize(), form = model.approverOrigin)
}
val message = stringResource(id = R.string.not_impl_error)
BottomButton(
confirmDesc = R.string.reported_btn, backDesc = R.string.reject_btn,
modifier = Modifier.fillMaxWidth()
) {
scaffoldModel.update(message = message)
}
}
}
}

@ -56,7 +56,15 @@ class MainActivity : ComponentActivity() {
}, modifier = Modifier.fillMaxWidth()) {
Text(text = stringResource(id = R.string.association_management))
}
OutlinedButton(onClick = { /*TODO*/ }, modifier = Modifier.fillMaxWidth()) {
OutlinedButton(onClick = {
startActivity(
Intent(
this@MainActivity,
MenuActivity::class.java
).apply {
putExtra(MenuType::name.name, MenuType.Act)
})
}, modifier = Modifier.fillMaxWidth()) {
Text(text = stringResource(id = R.string.activity_management))
}
}

@ -0,0 +1,6 @@
package com.gyf.csams.main.ui
import androidx.activity.ComponentActivity
class ManagerActActivity : ComponentActivity() {
}

@ -3,71 +3,43 @@ package com.gyf.csams.main.ui
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.annotation.StringRes
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.ui.Alignment
import androidx.compose.runtime.ExperimentalComposeApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import com.gyf.csams.R
import com.gyf.csams.main.model.RenameViewModel
import com.gyf.csams.main.model.RenameVo
import com.gyf.csams.uikit.RowItem
import com.gyf.csams.uikit.TestTable
import com.gyf.lib.uikit.BaseTextField
import com.gyf.lib.uikit.BodyS
import com.gyf.lib.uikit.MainColumnFrame
import com.gyf.lib.uikit.ScaffoldModel
import com.gyf.lib.util.BottomButton
class RenameActivity : ComponentActivity() {
@ExperimentalComposeApi
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
BodyS {
MainColumnFrame(background = { /*TODO*/ }) {
val listState = rememberLazyListState()
val model: RenameViewModel = viewModel()
val data by model.data.observeAsState()
Row(
horizontalArrangement = Arrangement.Center,
modifier = Modifier
.fillMaxWidth()
.padding(10.dp)
) {
Text(
text = stringResource(id = R.string.rename_form),
style = MaterialTheme.typography.h4
)
}
LazyColumn(state = listState) {
data?.forEach {
item {
RenameForm(renameVo = it)
Spacer(modifier = Modifier.height(10.dp))
}
}
}
}
TestTable(clazz = RenameViewModel::class.java, title = R.string.rename_form) {
RenameForm(renameVo = it)
}
}
}
@Composable
private fun RenameForm(modifier: Modifier = Modifier, renameVo: RenameVo) {
val model: RenameViewModel = viewModel()
val scaffoldModel: ScaffoldModel = viewModel()
private fun RenameForm(
modifier: Modifier = Modifier, model: RenameViewModel = viewModel(),
scaffoldModel: ScaffoldModel = viewModel(), renameVo: RenameVo
) {
Column(modifier = modifier) {
val baseHeight = 50.dp
RowItem(
@ -86,7 +58,7 @@ class RenameActivity : ComponentActivity() {
value = renameVo.newName
)
RowItem(
modifier = Modifier.height(baseHeight),
modifier = Modifier.height(baseHeight * 3),
key = R.string.reason_for_application,
value = renameVo.reason
)
@ -98,49 +70,13 @@ class RenameActivity : ComponentActivity() {
BaseTextField(modifier = Modifier.fillMaxSize(), form = model.approverOrigin)
}
val message = stringResource(id = R.string.not_impl_error)
BottomButton(modifier = Modifier.fillMaxWidth()) {
BottomButton(
confirmDesc = R.string.reported_btn, backDesc = R.string.reject_btn,
modifier = Modifier.fillMaxWidth()
) {
scaffoldModel.update(message = message)
}
}
}
@Composable
private fun RowItem(
modifier: Modifier = Modifier,
@StringRes key: Int,
value: String? = null,
content: (@Composable () -> Unit)? = null
) {
Row(
modifier = modifier
.fillMaxWidth()
.border(width = 1.dp, color = Color.Black)
) {
Cell(
modifier = Modifier.weight(0.5F),
value = stringResource(id = key)
)
Cell(modifier = Modifier.weight(0.5F), value = value, content = content)
}
}
@Composable
private fun Cell(
modifier: Modifier = Modifier,
value: String? = null,
content: (@Composable () -> Unit)? = null
) {
Box(
modifier = modifier
.fillMaxSize()
.border(width = 1.dp, color = MaterialTheme.colors.onBackground),
contentAlignment = Alignment.Center
) {
if (content != null) content() else Text(
text = value ?: throw IllegalArgumentException(
"参数错误"
)
)
}
}
}

@ -0,0 +1,111 @@
package com.gyf.csams.uikit
import androidx.annotation.StringRes
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.ExperimentalComposeApi
import androidx.compose.runtime.getValue
import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import com.gyf.lib.ScrollListW
import com.gyf.lib.uikit.BodyS
import com.gyf.lib.uikit.MainColumnFrame
/**
* 表格
*
* @param callback
*/
@ExperimentalComposeApi
@Composable
fun <A> TestTable(
clazz: Class<out ScrollListW<A>>,
@StringRes title: Int,
callback: @Composable (vo: A) -> Unit
) {
BodyS {
MainColumnFrame(background = { /*TODO*/ }) {
val listState = rememberLazyListState()
val model = viewModel(modelClass = clazz)
val data by model.data.observeAsState()
Row(
horizontalArrangement = Arrangement.Center,
modifier = Modifier
.fillMaxWidth()
.padding(10.dp)
) {
Text(
text = stringResource(id = title),
style = MaterialTheme.typography.h4
)
}
LazyColumn(state = listState) {
data?.forEach {
item {
callback(vo = it)
Spacer(modifier = Modifier.height(10.dp))
}
}
}
}
}
}
/**
* 表格行
*
* @param modifier
* @param key
* @param value
* @param content
*/
@Composable
fun RowItem(
modifier: Modifier = Modifier,
@StringRes key: Int,
value: String? = null,
content: (@Composable () -> Unit)? = null
) {
Row(
modifier = modifier
.fillMaxWidth()
.border(width = 1.dp, color = Color.Black)
) {
Cell(
modifier = Modifier.weight(0.5F),
value = stringResource(id = key)
)
Cell(modifier = Modifier.weight(0.5F), value = value, content = content)
}
}
@Composable
private fun Cell(
modifier: Modifier = Modifier,
value: String? = null,
content: (@Composable () -> Unit)? = null
) {
Box(
modifier = modifier
.fillMaxSize()
.border(width = 1.dp, color = MaterialTheme.colors.onBackground),
contentAlignment = Alignment.Center
) {
if (content != null) content() else Text(
text = value ?: throw IllegalArgumentException(
"参数错误"
)
)
}
}

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="64dp"
android:height="64dp"
android:viewportWidth="1024"
android:viewportHeight="1024">
<path
android:fillColor="#FF000000"
android:pathData="M490.26,173.44a49.07,49.07 0,0 1,64.06 19.18l1.66,3.09 87.85,177.81 196.35,28.5a49.07,49.07 0,0 1,29.72 81.07l-2.54,2.65L725.33,624l33.54,195.35a49.07,49.07 0,0 1,-68.01 53.27l-3.16,-1.51L512,778.86l-175.7,92.27a49.07,49.07 0,0 1,-71.64 -48.43l0.47,-3.33L298.67,624.02 156.63,485.76a49.07,49.07 0,0 1,23.89 -83.11l3.29,-0.6 196.35,-28.5 87.85,-177.81a49.07,49.07 0,0 1,22.25 -22.27zM422.63,432.02l-199.66,28.99 144.47,140.65 -34.13,198.74L512,706.56l178.69,93.85 -34.13,-198.74 144.47,-140.65 -199.66,-28.99L512,251.16l-89.39,180.86z" />
</vector>

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="64dp"
android:height="64dp"
android:viewportWidth="1024"
android:viewportHeight="1024">
<path
android:pathData="M490.26,173.44a49.07,49.07 0,0 1,64.06 19.18l1.66,3.09 87.85,177.81 196.35,28.5a49.07,49.07 0,0 1,29.72 81.07l-2.54,2.65L725.33,624l33.54,195.35a49.07,49.07 0,0 1,-68.01 53.27l-3.16,-1.51L512,778.86l-175.7,92.27a49.07,49.07 0,0 1,-71.64 -48.43l0.47,-3.33L298.67,624.02 156.63,485.76a49.07,49.07 0,0 1,23.89 -83.11l3.29,-0.6 196.35,-28.5 87.85,-177.81a49.07,49.07 0,0 1,22.25 -22.27z"
android:fillColor="#f4ea2a" />
</vector>

@ -18,4 +18,9 @@
<string name="counselor">导员</string>
<string name="update_duty_error">只能调整干事职务!</string>
<string name="management_officer">部门干事管理</string>
<string name="reported_btn">上报</string>
<string name="reject_btn">驳回</string>
<string name="activity_merit">优点</string>
<string name="activitiy_defect">缺点</string>
<string name="activity_evaluate">评价</string>
</resources>

@ -18,4 +18,9 @@
<string name="counselor">导员</string>
<string name="update_duty_error">只能调整干事职务!</string>
<string name="management_officer">部门干事管理</string>
<string name="reported_btn">上报</string>
<string name="reject_btn">驳回</string>
<string name="activity_merit">优点</string>
<string name="activitiy_defect">缺点</string>
<string name="activity_evaluate">评价</string>
</resources>

@ -18,4 +18,9 @@
<string name="counselor">导员</string>
<string name="update_duty_error">只能调整干事职务!</string>
<string name="management_officer">部门干事管理</string>
<string name="reported_btn">上报</string>
<string name="reject_btn">驳回</string>
<string name="activity_merit">优点</string>
<string name="activitiy_defect">缺点</string>
<string name="activity_evaluate">评价</string>
</resources>

@ -0,0 +1,11 @@
package com.gyf
import android.app.Application
import com.gyf.lib.R
import com.gyf.lib.ScrollListW
import com.gyf.lib.uikit.StringForm
abstract class ApplyViewModel<T>(application: Application) : ScrollListW<T>(application) {
val approverOrigin =
StringForm(formDesc = application.getString(R.string.approver_origin), textLength = 30)
}

@ -20,4 +20,5 @@
<string name="approver">审批人</string>
<string name="approver_origin">审核理由</string>
<string name="not_impl_error">抱歉此功能尚未开放</string>
<string name="quality_report_title">活动质量汇报单</string>
</resources>

@ -20,4 +20,5 @@
<string name="approver">审批人</string>
<string name="approver_origin">审核理由</string>
<string name="not_impl_error">抱歉此功能尚未开放</string>
<string name="quality_report_title">活动质量汇报单</string>
</resources>

@ -20,4 +20,5 @@
<string name="approver">审批人</string>
<string name="approver_origin">审核理由</string>
<string name="not_impl_error">抱歉此功能尚未开放</string>
<string name="quality_report_title">活动质量汇报单</string>
</resources>
Loading…
Cancel
Save