|
@@ -3,12 +3,9 @@ package com.iscs.bozzys.ui.pages.edit.step
|
|
|
import android.content.Context
|
|
import android.content.Context
|
|
|
import android.content.Intent
|
|
import android.content.Intent
|
|
|
import android.view.WindowManager
|
|
import android.view.WindowManager
|
|
|
-import androidx.compose.animation.AnimatedVisibility
|
|
|
|
|
import androidx.compose.animation.core.Animatable
|
|
import androidx.compose.animation.core.Animatable
|
|
|
import androidx.compose.animation.core.spring
|
|
import androidx.compose.animation.core.spring
|
|
|
import androidx.compose.animation.core.tween
|
|
import androidx.compose.animation.core.tween
|
|
|
-import androidx.compose.animation.slideInVertically
|
|
|
|
|
-import androidx.compose.animation.slideOutVertically
|
|
|
|
|
import androidx.compose.foundation.background
|
|
import androidx.compose.foundation.background
|
|
|
import androidx.compose.foundation.clickable
|
|
import androidx.compose.foundation.clickable
|
|
|
import androidx.compose.foundation.interaction.MutableInteractionSource
|
|
import androidx.compose.foundation.interaction.MutableInteractionSource
|
|
@@ -17,13 +14,18 @@ import androidx.compose.foundation.layout.Column
|
|
|
import androidx.compose.foundation.layout.PaddingValues
|
|
import androidx.compose.foundation.layout.PaddingValues
|
|
|
import androidx.compose.foundation.layout.Row
|
|
import androidx.compose.foundation.layout.Row
|
|
|
import androidx.compose.foundation.layout.Spacer
|
|
import androidx.compose.foundation.layout.Spacer
|
|
|
|
|
+import androidx.compose.foundation.layout.WindowInsets
|
|
|
import androidx.compose.foundation.layout.fillMaxHeight
|
|
import androidx.compose.foundation.layout.fillMaxHeight
|
|
|
import androidx.compose.foundation.layout.fillMaxSize
|
|
import androidx.compose.foundation.layout.fillMaxSize
|
|
|
import androidx.compose.foundation.layout.fillMaxWidth
|
|
import androidx.compose.foundation.layout.fillMaxWidth
|
|
|
import androidx.compose.foundation.layout.height
|
|
import androidx.compose.foundation.layout.height
|
|
|
|
|
+import androidx.compose.foundation.layout.ime
|
|
|
|
|
+import androidx.compose.foundation.layout.imePadding
|
|
|
import androidx.compose.foundation.layout.offset
|
|
import androidx.compose.foundation.layout.offset
|
|
|
import androidx.compose.foundation.layout.padding
|
|
import androidx.compose.foundation.layout.padding
|
|
|
import androidx.compose.foundation.layout.size
|
|
import androidx.compose.foundation.layout.size
|
|
|
|
|
+import androidx.compose.foundation.lazy.LazyColumn
|
|
|
|
|
+import androidx.compose.foundation.lazy.items
|
|
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
import androidx.compose.material3.Button
|
|
import androidx.compose.material3.Button
|
|
|
import androidx.compose.material3.Icon
|
|
import androidx.compose.material3.Icon
|
|
@@ -33,6 +35,7 @@ import androidx.compose.runtime.Composable
|
|
|
import androidx.compose.runtime.LaunchedEffect
|
|
import androidx.compose.runtime.LaunchedEffect
|
|
|
import androidx.compose.runtime.SideEffect
|
|
import androidx.compose.runtime.SideEffect
|
|
|
import androidx.compose.runtime.getValue
|
|
import androidx.compose.runtime.getValue
|
|
|
|
|
+import androidx.compose.runtime.mutableStateListOf
|
|
|
import androidx.compose.runtime.mutableStateMapOf
|
|
import androidx.compose.runtime.mutableStateMapOf
|
|
|
import androidx.compose.runtime.mutableStateOf
|
|
import androidx.compose.runtime.mutableStateOf
|
|
|
import androidx.compose.runtime.remember
|
|
import androidx.compose.runtime.remember
|
|
@@ -45,6 +48,7 @@ import androidx.compose.ui.geometry.Offset
|
|
|
import androidx.compose.ui.graphics.Color
|
|
import androidx.compose.ui.graphics.Color
|
|
|
import androidx.compose.ui.graphics.graphicsLayer
|
|
import androidx.compose.ui.graphics.graphicsLayer
|
|
|
import androidx.compose.ui.platform.LocalContext
|
|
import androidx.compose.ui.platform.LocalContext
|
|
|
|
|
+import androidx.compose.ui.platform.LocalDensity
|
|
|
import androidx.compose.ui.res.painterResource
|
|
import androidx.compose.ui.res.painterResource
|
|
|
import androidx.compose.ui.text.font.FontWeight
|
|
import androidx.compose.ui.text.font.FontWeight
|
|
|
import androidx.compose.ui.text.style.TextAlign
|
|
import androidx.compose.ui.text.style.TextAlign
|
|
@@ -55,11 +59,16 @@ import androidx.compose.ui.window.DialogProperties
|
|
|
import androidx.compose.ui.zIndex
|
|
import androidx.compose.ui.zIndex
|
|
|
import androidx.lifecycle.lifecycleScope
|
|
import androidx.lifecycle.lifecycleScope
|
|
|
import com.iscs.bozzys.R
|
|
import com.iscs.bozzys.R
|
|
|
|
|
+import com.iscs.bozzys.api.FormField
|
|
|
import com.iscs.bozzys.ui.base.PageBase
|
|
import com.iscs.bozzys.ui.base.PageBase
|
|
|
import com.iscs.bozzys.ui.base.Title
|
|
import com.iscs.bozzys.ui.base.Title
|
|
|
import com.iscs.bozzys.ui.pages.compose.CardContainer
|
|
import com.iscs.bozzys.ui.pages.compose.CardContainer
|
|
|
|
|
+import com.iscs.bozzys.ui.pages.compose.FormDateSelect
|
|
|
import com.iscs.bozzys.ui.pages.compose.FormInput
|
|
import com.iscs.bozzys.ui.pages.compose.FormInput
|
|
|
|
|
+import com.iscs.bozzys.ui.pages.compose.FormRadio
|
|
|
import com.iscs.bozzys.ui.pages.compose.FormSelect
|
|
import com.iscs.bozzys.ui.pages.compose.FormSelect
|
|
|
|
|
+import com.iscs.bozzys.ui.pages.compose.FormTextarea
|
|
|
|
|
+import com.iscs.bozzys.ui.pages.compose.getFormList
|
|
|
import com.iscs.bozzys.ui.pages.edit.step.compose.Anchor
|
|
import com.iscs.bozzys.ui.pages.edit.step.compose.Anchor
|
|
|
import com.iscs.bozzys.ui.pages.edit.step.compose.Connection
|
|
import com.iscs.bozzys.ui.pages.edit.step.compose.Connection
|
|
|
import com.iscs.bozzys.ui.pages.edit.step.compose.Node
|
|
import com.iscs.bozzys.ui.pages.edit.step.compose.Node
|
|
@@ -82,22 +91,27 @@ class PageEditStep : PageBase() {
|
|
|
val nodes = remember { mutableStateMapOf<String, Node>() }
|
|
val nodes = remember { mutableStateMapOf<String, Node>() }
|
|
|
val selectNode = remember { mutableStateOf(Node("-1", Offset(0f, 0f))) }
|
|
val selectNode = remember { mutableStateOf(Node("-1", Offset(0f, 0f))) }
|
|
|
val lines = listOf(
|
|
val lines = listOf(
|
|
|
- Connection("A", "B"),
|
|
|
|
|
- Connection("A", "D", fromAnchor = Anchor.RIGHT, toAnchor = Anchor.LEFT),
|
|
|
|
|
- Connection("B", "C")
|
|
|
|
|
|
|
+ Connection("A", "B", fromAnchor = Anchor.BOTTOM, toAnchor = Anchor.TOP),
|
|
|
|
|
+ Connection("A", "D", fromAnchor = Anchor.BOTTOM, toAnchor = Anchor.TOP),
|
|
|
|
|
+ Connection("B", "C", fromAnchor = Anchor.BOTTOM, toAnchor = Anchor.TOP)
|
|
|
)
|
|
)
|
|
|
var showFormDialog by remember { mutableStateOf(false) }
|
|
var showFormDialog by remember { mutableStateOf(false) }
|
|
|
|
|
+ // 处理显示的表单
|
|
|
|
|
+ val json =
|
|
|
|
|
+ "[{\"id\":\"field_1766037799194\",\"type\":\"card\",\"label\":\"卡片容器\",\"name\":\"field1766037799194\",\"required\":false,\"placeholder\":\"\",\"options\":[],\"cardTitle\":\"卡片容器\",\"children\":[{\"id\":\"field_1766037802805\",\"type\":\"grid\",\"label\":\"双栏布局\",\"name\":\"field1766037802805\",\"required\":false,\"placeholder\":\"\",\"options\":[],\"gridColumns\":2,\"children\":[{\"id\":\"field_1766037804595\",\"type\":\"textarea\",\"label\":\"字段2\",\"name\":\"field1766037804595\",\"required\":false,\"placeholder\":\"请输入内容\",\"options\":[]},{\"id\":\"field_1766037807731\",\"type\":\"input\",\"label\":\"字段2\",\"name\":\"field1766037807731\",\"required\":false,\"placeholder\":\"请输入\",\"options\":[]}]}]},{\"id\":\"field_1766038059114\",\"type\":\"select\",\"label\":\"字段2\",\"name\":\"field1766038059114\",\"required\":false,\"placeholder\":\"请选择\",\"options\":[{\"label\":\"选项1\",\"value\":\"option1\"},{\"label\":\"选项2\",\"value\":\"option2\"}]},{\"id\":\"field_1766038062137\",\"type\":\"date\",\"label\":\"字段3\",\"name\":\"field1766038062137\",\"required\":false,\"placeholder\":\"请选择日期\",\"options\":[]},{\"id\":\"field_1766473806339\",\"type\":\"radio\",\"label\":\"字段4\",\"name\":\"field1766473806339\",\"required\":false,\"options\":[{\"label\":\"选项1\",\"value\":\"option1\"},{\"label\":\"选项2\",\"value\":\"option2\"}]}]"
|
|
|
|
|
+ val fields = remember { mutableStateListOf<FormField>() }
|
|
|
|
|
+ fields.addAll(json.getFormList())
|
|
|
LaunchedEffect(Unit) {
|
|
LaunchedEffect(Unit) {
|
|
|
- nodes["A"] = Node("A", Offset(50f, 0f))
|
|
|
|
|
- nodes["B"] = Node("B", Offset(250f, 0f))
|
|
|
|
|
- nodes["D"] = Node("D", Offset(250f, 100f))
|
|
|
|
|
- nodes["C"] = Node("C", Offset(450f, 0f))
|
|
|
|
|
|
|
+ nodes["A"] = Node("A", Offset(125f, -100f))
|
|
|
|
|
+ nodes["B"] = Node("B", Offset(50f, 0f))
|
|
|
|
|
+ nodes["D"] = Node("D", Offset(200f, 0f))
|
|
|
|
|
+ nodes["C"] = Node("C", Offset(50f, 100f))
|
|
|
// 默认选中第一个节点
|
|
// 默认选中第一个节点
|
|
|
nodes["A"]?.let { selectNode.value = it }
|
|
nodes["A"]?.let { selectNode.value = it }
|
|
|
}
|
|
}
|
|
|
Column(Modifier.fillMaxSize()) {
|
|
Column(Modifier.fillMaxSize()) {
|
|
|
Title(pv, "作业流程管理")
|
|
Title(pv, "作业流程管理")
|
|
|
- ZoomPanContainer(nodes, lines, modifier = Modifier.fillMaxSize()) { scale, toTopCenter, toCenter ->
|
|
|
|
|
|
|
+ ZoomPanContainer(nodes, lines, modifier = Modifier.fillMaxSize()) { scale, toTopCenter, toCenter, toLast ->
|
|
|
// 控件显示
|
|
// 控件显示
|
|
|
Box(
|
|
Box(
|
|
|
modifier = Modifier
|
|
modifier = Modifier
|
|
@@ -121,49 +135,65 @@ class PageEditStep : PageBase() {
|
|
|
}
|
|
}
|
|
|
// 底部弹出式的Dialog
|
|
// 底部弹出式的Dialog
|
|
|
FormDialog(showFormDialog, {
|
|
FormDialog(showFormDialog, {
|
|
|
- // 回到中心位置,默认不添加 等反馈
|
|
|
|
|
- // toCenter(selectNode.value)
|
|
|
|
|
|
|
+ // 回到移动中心位置前的位置,默认不添加 等反馈
|
|
|
|
|
+ toLast()
|
|
|
showFormDialog = false
|
|
showFormDialog = false
|
|
|
}, pv) {
|
|
}, pv) {
|
|
|
|
|
+
|
|
|
|
|
+ // 监听键盘弹出事件
|
|
|
|
|
+
|
|
|
|
|
+ val density = LocalDensity.current
|
|
|
|
|
+ val imeInsets = WindowInsets.ime
|
|
|
|
|
+ val imeBottom = imeInsets.getBottom(density)
|
|
|
|
|
+
|
|
|
Column(
|
|
Column(
|
|
|
Modifier
|
|
Modifier
|
|
|
- .fillMaxWidth()
|
|
|
|
|
- .fillMaxHeight(5 / 7f)
|
|
|
|
|
|
|
+ .fillMaxHeight(4 / 7f)
|
|
|
.padding(horizontal = 16.dp)
|
|
.padding(horizontal = 16.dp)
|
|
|
) {
|
|
) {
|
|
|
- Column(
|
|
|
|
|
|
|
+ Box(
|
|
|
Modifier
|
|
Modifier
|
|
|
- .fillMaxWidth()
|
|
|
|
|
|
|
+ .fillMaxSize()
|
|
|
.weight(1f)
|
|
.weight(1f)
|
|
|
) {
|
|
) {
|
|
|
- FormInput("节点名称", "", {})
|
|
|
|
|
- FormSelect("负责人", "张三" to "zhangsan", listOf("张三" to "zhangsan"), {})
|
|
|
|
|
- FormSelect(
|
|
|
|
|
- "关联表单",
|
|
|
|
|
- "通用作业申请单" to "normal2",
|
|
|
|
|
- listOf(
|
|
|
|
|
- "通用作业申请单" to "normal2",
|
|
|
|
|
- "通用作业申请单" to "normal3",
|
|
|
|
|
- "通用作业申请单" to "normal4",
|
|
|
|
|
- "通用作业申请单" to "normal5",
|
|
|
|
|
- "通用作业申请单" to "normal6",
|
|
|
|
|
- "通用作业申请单" to "normal7",
|
|
|
|
|
- "通用作业申请单" to "normal8",
|
|
|
|
|
- "通用作业申请单" to "normal",
|
|
|
|
|
- "通用作业申请单" to "normal9"
|
|
|
|
|
- ),
|
|
|
|
|
- {})
|
|
|
|
|
|
|
+ LazyColumn(
|
|
|
|
|
+ Modifier
|
|
|
|
|
+ .imePadding()
|
|
|
|
|
+ .padding(vertical = 5.dp)
|
|
|
|
|
+ ) {
|
|
|
|
|
+ items(fields) {
|
|
|
|
|
+ when (it.type) {
|
|
|
|
|
+ "textarea" -> FormTextarea(it.label, it.value, { sel -> it.value = sel }, it.placeholder)
|
|
|
|
|
+ "input" -> FormInput(it.label, it.value, { sel -> it.value = sel }, it.placeholder)
|
|
|
|
|
+ "select" -> FormSelect(
|
|
|
|
|
+ it.label,
|
|
|
|
|
+ it.value.ifEmpty { it.options[0].value },
|
|
|
|
|
+ it.options,
|
|
|
|
|
+ { sel -> it.value = sel.value })
|
|
|
|
|
+
|
|
|
|
|
+ "date" -> FormDateSelect(it.label, it.value.ifEmpty { "0" }.toLong(), { sel -> it.value = sel.toString() })
|
|
|
|
|
+ "radio" -> FormRadio(
|
|
|
|
|
+ it.label,
|
|
|
|
|
+ it.value.ifEmpty { it.options[0].value },
|
|
|
|
|
+ it.options,
|
|
|
|
|
+ { sel -> it.value = sel.value })
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- Button(
|
|
|
|
|
- {},
|
|
|
|
|
- modifier = Modifier
|
|
|
|
|
- .fillMaxWidth()
|
|
|
|
|
- .height(50.dp)
|
|
|
|
|
- .clip(RoundedCornerShape(12.dp))
|
|
|
|
|
- .background(MaterialTheme.colorScheme.primary),
|
|
|
|
|
- shape = RoundedCornerShape(12.dp)
|
|
|
|
|
- ) {
|
|
|
|
|
- Text("保存", fontSize = 16.sp, fontWeight = FontWeight.Bold)
|
|
|
|
|
|
|
+ if (imeBottom <= 0) {
|
|
|
|
|
+ Spacer(Modifier.height(10.dp))
|
|
|
|
|
+ Button(
|
|
|
|
|
+ {},
|
|
|
|
|
+ modifier = Modifier
|
|
|
|
|
+ .fillMaxWidth()
|
|
|
|
|
+ .height(50.dp)
|
|
|
|
|
+ .clip(RoundedCornerShape(12.dp))
|
|
|
|
|
+ .background(MaterialTheme.colorScheme.primary),
|
|
|
|
|
+ shape = RoundedCornerShape(12.dp)
|
|
|
|
|
+ ) {
|
|
|
|
|
+ Text("保存", fontSize = 16.sp, fontWeight = FontWeight.Bold)
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -174,34 +204,6 @@ class PageEditStep : PageBase() {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/**
|
|
|
|
|
- * 底部弹出式的表单录入弹窗,嵌入页面式
|
|
|
|
|
- */
|
|
|
|
|
-@Composable
|
|
|
|
|
-fun FormInPage(show: Boolean, onDismiss: () -> Unit, content: @Composable () -> Unit) {
|
|
|
|
|
- AnimatedVisibility(
|
|
|
|
|
- visible = show,
|
|
|
|
|
- enter = slideInVertically { it },
|
|
|
|
|
- exit = slideOutVertically { it }
|
|
|
|
|
- ) {
|
|
|
|
|
- Box(Modifier.fillMaxSize()) {
|
|
|
|
|
- Box(
|
|
|
|
|
- modifier = Modifier
|
|
|
|
|
- .align(Alignment.BottomCenter)
|
|
|
|
|
- .fillMaxWidth()
|
|
|
|
|
- .background(Color.White)
|
|
|
|
|
- ) {
|
|
|
|
|
- Column(modifier = Modifier.fillMaxWidth()) {
|
|
|
|
|
- Row() {
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- content()
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
@Composable
|
|
@Composable
|
|
|
fun FormDialog(
|
|
fun FormDialog(
|
|
|
show: Boolean,
|
|
show: Boolean,
|
|
@@ -242,7 +244,7 @@ fun FormDialog(
|
|
|
Box(
|
|
Box(
|
|
|
modifier = Modifier
|
|
modifier = Modifier
|
|
|
.fillMaxSize()
|
|
.fillMaxSize()
|
|
|
- .background(Color.Black.copy(alpha = 0.6f))
|
|
|
|
|
|
|
+ .background(Color.Black.copy(alpha = 0.4f))
|
|
|
.clickable(
|
|
.clickable(
|
|
|
indication = null,
|
|
indication = null,
|
|
|
interactionSource = remember { MutableInteractionSource() }) {
|
|
interactionSource = remember { MutableInteractionSource() }) {
|
|
@@ -300,6 +302,12 @@ fun FormDialog(
|
|
|
.padding(10.dp)
|
|
.padding(10.dp)
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
|
|
+ Spacer(
|
|
|
|
|
+ Modifier
|
|
|
|
|
+ .fillMaxWidth()
|
|
|
|
|
+ .height(0.5.dp)
|
|
|
|
|
+ .background(Color.Black.copy(alpha = 0.05f))
|
|
|
|
|
+ )
|
|
|
content()
|
|
content()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|