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.
138 lines
5.1 KiB
138 lines
5.1 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.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.ManagementOfficerModel
|
|
import com.gyf.lib.uikit.Body
|
|
import com.gyf.lib.uikit.MainColumnFrame
|
|
import com.gyf.lib.uikit.Profile
|
|
import com.gyf.lib.uikit.ScaffoldModel
|
|
import com.gyf.lib.util.ManagerInfoVo
|
|
import com.orhanobut.logger.Logger
|
|
|
|
/**
|
|
* 部门干事管理
|
|
*
|
|
*/
|
|
class ManagementOfficerActivity : ComponentActivity() {
|
|
@ExperimentalFoundationApi
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
super.onCreate(savedInstanceState)
|
|
setContent {
|
|
Body {
|
|
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
|
|
)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
*
|
|
* 表格
|
|
*/
|
|
@ExperimentalFoundationApi
|
|
@Composable
|
|
private fun Table(
|
|
modifier: Modifier = Modifier,
|
|
model: ManagementOfficerModel = viewModel(),
|
|
scaffoldModel: ScaffoldModel = viewModel(),
|
|
@StringRes id: Int,
|
|
officerVoList: MutableList<ManagerInfoVo>,
|
|
) {
|
|
Column(
|
|
modifier = modifier
|
|
.padding(horizontal = 10.dp)
|
|
.border(width = 1.dp, color = MaterialTheme.colors.onBackground),
|
|
verticalArrangement = Arrangement.SpaceEvenly
|
|
) {
|
|
|
|
Spacer(modifier = Modifier.weight(0.05F))
|
|
Text(text = stringResource(id = id), modifier = Modifier.weight(0.1F))
|
|
Spacer(modifier = Modifier.weight(0.05F))
|
|
|
|
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 = it.value
|
|
) {
|
|
Logger.i("expanded=$expanded")
|
|
Text(
|
|
text = it.value.duty.desc,
|
|
modifier = Modifier.clickable(onClick = {
|
|
if (it.value.duty.isOfficer()) expanded =
|
|
true else scaffoldModel
|
|
.update(message = getString(R.string.update_duty_error))
|
|
})
|
|
)
|
|
|
|
DropdownMenu(
|
|
expanded = expanded,
|
|
onDismissRequest = { /*TODO*/ }) {
|
|
DropdownMenuItem(onClick = {
|
|
model.updateDuty(list = officerVoList, index = it.index)
|
|
expanded = false
|
|
}) {
|
|
Text(text = it.value.duty.desc)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Spacer(modifier = Modifier.weight(0.05F))
|
|
|
|
}
|
|
}
|
|
|
|
} |