You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
172 lines
6.5 KiB
172 lines
6.5 KiB
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.ExperimentalFoundationApi
|
|
import androidx.compose.foundation.border
|
|
import androidx.compose.foundation.clickable
|
|
import androidx.compose.foundation.layout.*
|
|
import androidx.compose.foundation.lazy.LazyRow
|
|
import androidx.compose.material.DropdownMenu
|
|
import androidx.compose.material.DropdownMenuItem
|
|
import androidx.compose.material.MaterialTheme
|
|
import androidx.compose.material.Text
|
|
import androidx.compose.runtime.*
|
|
import androidx.compose.runtime.livedata.observeAsState
|
|
import androidx.compose.ui.Alignment
|
|
import androidx.compose.ui.Modifier
|
|
import androidx.compose.ui.platform.LocalContext
|
|
import androidx.compose.ui.unit.dp
|
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
|
import com.gyf.csams.R
|
|
import com.gyf.csams.main.model.Duty
|
|
import com.gyf.csams.main.model.ManagementOfficerModel
|
|
import com.gyf.csams.main.model.MinisterVo
|
|
import com.gyf.csams.main.model.OfficerVo
|
|
import com.gyf.lib.uikit.*
|
|
import com.orhanobut.logger.Logger
|
|
|
|
/**
|
|
* 部门干事管理
|
|
*
|
|
*/
|
|
class ManagementOfficerActivity : ComponentActivity() {
|
|
@ExperimentalFoundationApi
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
super.onCreate(savedInstanceState)
|
|
setContent {
|
|
Body { scaffoldState ->
|
|
MainColumnFrame(background = { /*TODO*/ }) {
|
|
val weight = 1 / 3F
|
|
val model: ManagementOfficerModel = viewModel()
|
|
val data by model.data.observeAsState()
|
|
Logger.i("$data")
|
|
data?.apply {
|
|
Table(
|
|
modifier = Modifier
|
|
.weight(weight = weight),
|
|
id = R.string.secretariat,
|
|
officerVoList = secretariat
|
|
)
|
|
Table(
|
|
modifier = Modifier
|
|
.weight(weight = weight),
|
|
id = R.string.propaganda_department,
|
|
officerVoList = propaganda
|
|
)
|
|
Table(
|
|
modifier = Modifier
|
|
.weight(weight = weight),
|
|
id = R.string.public_relations_department,
|
|
officerVoList = publicRelationsDepartment
|
|
)
|
|
}
|
|
|
|
ShowSnackbar(scaffoldState = scaffoldState)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@Composable
|
|
private fun BoxItem(content: @Composable () -> Unit) {
|
|
Box(
|
|
Modifier
|
|
.width(150.dp)
|
|
.height(40.dp)
|
|
.border(
|
|
width = 1.dp,
|
|
color = MaterialTheme.colors.onBackground
|
|
)
|
|
.padding(vertical = 10.dp),
|
|
contentAlignment = Alignment.Center
|
|
) {
|
|
content()
|
|
}
|
|
}
|
|
|
|
/**
|
|
*
|
|
* 表格
|
|
*/
|
|
@ExperimentalFoundationApi
|
|
@Composable
|
|
private fun Table(
|
|
modifier: Modifier = Modifier,
|
|
model: ManagementOfficerModel = viewModel(),
|
|
scaffoldModel: ScaffoldModel = viewModel(),
|
|
@StringRes id: Int,
|
|
officerVoList: MutableList<OfficerVo>,
|
|
) {
|
|
Column(
|
|
modifier = modifier
|
|
.padding(horizontal = 10.dp)
|
|
.border(width = 1.dp, color = MaterialTheme.colors.onBackground),
|
|
verticalArrangement = Arrangement.SpaceEvenly
|
|
) {
|
|
val context = LocalContext.current
|
|
|
|
Spacer(modifier = Modifier.weight(0.05F))
|
|
Text(text = context.getString(id), modifier = Modifier.weight(0.1F))
|
|
Spacer(modifier = Modifier.weight(0.05F))
|
|
val columnSize = 4
|
|
|
|
LazyRow(modifier = Modifier.weight(0.6F)) {
|
|
officerVoList.withIndex().forEach {
|
|
item {
|
|
var expanded by remember {
|
|
mutableStateOf(false)
|
|
}
|
|
Profile(
|
|
modifier = Modifier
|
|
.width(200.dp)
|
|
.fillMaxHeight()
|
|
.border(width = 1.dp, color = MaterialTheme.colors.onBackground),
|
|
personInfoVo =
|
|
MinisterVo(
|
|
name = it.value.name,
|
|
duty = it.value.duty.desc,
|
|
headImg = "",
|
|
desc = it.value.mobile
|
|
)
|
|
) {
|
|
|
|
Text(
|
|
text = it.value.duty.desc,
|
|
modifier = Modifier.clickable(onClick = {
|
|
if (it.value.duty.desc != Duty.Minister.desc) expanded =
|
|
true else scaffoldModel
|
|
.update(message = context.getString(R.string.update_duty_error))
|
|
})
|
|
)
|
|
// Text(
|
|
// text = it.duty.desc,
|
|
// modifier = Modifier.clickable(onClick = {
|
|
// if (duty.desc != Duty.Minister.desc) expanded =
|
|
// true else scaffoldModel
|
|
// .update(message = context.getString(R.string.update_duty_error))
|
|
// })
|
|
// )
|
|
DropdownMenu(
|
|
expanded = expanded,
|
|
onDismissRequest = { /*TODO*/ }) {
|
|
DropdownMenuItem(onClick = {
|
|
model.updateDuty(list = officerVoList, index = it.index)
|
|
expanded = false
|
|
}) {
|
|
Text(text = Duty.Minister.desc)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Spacer(modifier = Modifier.weight(0.05F))
|
|
|
|
}
|
|
}
|
|
|
|
} |