2 Commits fc57d85949 ... 1850a8741f

Author SHA1 Message Date
  bai 1850a8741f @fun: cad 2 years ago
  bai 8b67e3a98d @fun: cad 2 years ago

+ 19 - 18
app/src/main/java/com/ys/bdtp/adm/mvvm/ui/compose/ExpandList.kt

@@ -67,25 +67,26 @@ fun ExpandList(items: List<BuildingWithFloors>, click: (FloorEntity) -> Unit) {
             }
 
             if (building.building.id == selectId && isExpand) {
-                building.floors.sortedByDescending {
-                    (Gson().fromJson(it.infos, FloorInfos::class.java)).floorSequenceID
-                }.forEach { floor ->
-                    Row(
-                        modifier = Modifier
-                            .height(60.dp)
-                            .fillMaxWidth()
-                            .clickable {
-                                click(floor)
-                            },
-                        verticalAlignment = Alignment.CenterVertically
-                    ) {
-                        Spacer(modifier = Modifier.width(48.dp))
-                        Text(
-                            text = floor.localName,
-                            color = textBlackColor,
-                        )
+                building.floors.filter { it.valid == 1 }
+                    .sortedByDescending {
+                        (Gson().fromJson(it.infos, FloorInfos::class.java)).floorSequenceID
+                    }.forEach { floor ->
+                        Row(
+                            modifier = Modifier
+                                .height(60.dp)
+                                .fillMaxWidth()
+                                .clickable {
+                                    click(floor)
+                                },
+                            verticalAlignment = Alignment.CenterVertically
+                        ) {
+                            Spacer(modifier = Modifier.width(48.dp))
+                            Text(
+                                text = floor.localName,
+                                color = textBlackColor,
+                            )
+                        }
                     }
-                }
             }
         }
     }

+ 96 - 25
app/src/main/java/com/ys/bdtp/adm/mvvm/ui/screen/cad/CadContent.kt

@@ -4,12 +4,17 @@ import androidx.compose.foundation.background
 import androidx.compose.foundation.layout.*
 import androidx.compose.foundation.lazy.LazyColumn
 import androidx.compose.foundation.lazy.items
+import androidx.compose.material.Tab
+import androidx.compose.material.TabRow
+import androidx.compose.material.TabRowDefaults
+import androidx.compose.material.TabRowDefaults.tabIndicatorOffset
 import androidx.compose.material.Text
-import androidx.compose.runtime.Composable
+import androidx.compose.runtime.*
 import androidx.compose.ui.Alignment
 import androidx.compose.ui.Modifier
 import androidx.compose.ui.unit.dp
 import androidx.compose.ui.unit.sp
+import com.ys.bdtp.adm.app.theme.*
 import com.ys.bdtp.adm.app.theme.textBlackColor
 import com.ys.bdtp.adm.app.theme.trDivColor
 import com.ys.bdtp.adm.app.theme.whiteColor
@@ -18,44 +23,110 @@ import com.ys.bdtp.adm.mvvm.model.db.relation.FloorWithCads
 import com.ys.bdtp.adm.mvvm.ui.compose.SelectState
 import com.ys.bdtp.adm.mvvm.ui.compose.Table
 
+/**
+ * AC 空调
+ * FF 消防
+ * WS 给排水
+ */
 @Composable
 fun CadContent(selectState: SelectState, floor: FloorWithCads?, itemClick: (CadEntity) -> Unit) {
+    var state by remember { mutableStateOf(0) }
+    val title = if (selectState == SelectState.Left) "土建图纸核查" else "机电图纸核查"
+    val titles = listOf("空调", "消防", "给排水")
+    var code by remember { mutableStateOf("AC") }
+
     Column(
         modifier = Modifier
             .fillMaxSize()
             .background(whiteColor)
-            .padding(horizontal = 50.dp, vertical = 50.dp)
+            .padding(horizontal = 0.dp, vertical = 0.dp)
     ) {
-        val title = if (selectState == SelectState.Left) "土建图纸核查" else "机电图纸核查"
-        Table(
-            name = {
-                Text(text = title, color = textBlackColor, fontSize = 16.sp)
-            },
-            th = {
-                CadDrawingTitle()
-            },
-            tr = {
-                LazyColumn(modifier = Modifier.fillMaxSize()) {
-                    floor?.let {
-                        items(it.cads) { cad: CadEntity ->
-                            Box {
-                                CadDrawingItem(cad) {
-                                    itemClick(cad)
+        if (selectState == SelectState.Right) {
+            TabRow(
+                selectedTabIndex = state,
+                backgroundColor = whiteColor,
+                divider = {
+                    TabRowDefaults.Divider(color = divColor)
+                },
+                indicator = { tabPositions ->
+                    TabRowDefaults.Indicator(
+                        Modifier.tabIndicatorOffset(tabPositions[state]),
+                        color = textBlueColor
+                    )
+                }
+            ) {
+                titles.forEachIndexed { index, title ->
+                    Tab(
+                        modifier = Modifier.width(56.dp),
+                        text = { Text(title) },
+                        selected = state == index,
+                        onClick = {
+                            state = index
+                            when (index) {
+                                0 -> {
+                                    code = "AC"
+                                }
+                                1 -> {
+                                    code = "FF"
+                                }
+                                2 -> {
+                                    code = "WS"
+                                }
+                            }
+                        },
+                        selectedContentColor = textBlueColor,
+                        unselectedContentColor = textBlackColor
+                    )
+                }
+            }
+        }
+
+        Spacer(modifier = Modifier.height(40.dp))
+        Column(
+            modifier = Modifier
+                .fillMaxSize()
+                .padding(horizontal = 50.dp)
+        ) {
+            Table(
+                name = {
+                    Text(text = title, color = textBlackColor, fontSize = 16.sp)
+                },
+                th = {
+                    CadDrawingTitle()
+                },
+                tr = {
+                    LazyColumn(modifier = Modifier.fillMaxSize()) {
+                        floor?.let {
+                            val cads = when (selectState) {
+                                is SelectState.Left -> {
+                                    it.cads.filter { cad -> cad.majorCode == "CF" }
+                                }
+                                is SelectState.Right -> {
+                                    it.cads.filter { cad -> cad.majorCode == code }
+                                }
+                            }
+
+                            items(cads) { cad: CadEntity ->
+                                Box {
+                                    CadDrawingItem(cad) {
+                                        itemClick(cad)
+                                    }
+                                    Spacer(
+                                        modifier = Modifier
+                                            .align(Alignment.BottomCenter)
+                                            .fillMaxWidth().height(1.dp)
+                                            .background(trDivColor)
+                                    )
                                 }
-                                Spacer(
-                                    modifier = Modifier
-                                        .align(Alignment.BottomCenter)
-                                        .fillMaxWidth().height(1.dp)
-                                        .background(trDivColor)
-                                )
                             }
                         }
                     }
                 }
-            }
-        )
+            )
+        }
     }
 }
+
 /*
 
 @Preview(widthDp = 910, heightDp = 711)

+ 3 - 1
app/src/main/java/com/ys/bdtp/adm/mvvm/ui/screen/cad/CadDrawingItem.kt

@@ -14,6 +14,7 @@ import androidx.compose.ui.Alignment
 import androidx.compose.ui.Modifier
 import androidx.compose.ui.graphics.Color
 import androidx.compose.ui.text.style.TextAlign
+import androidx.compose.ui.text.style.TextOverflow
 import androidx.compose.ui.tooling.preview.Preview
 import androidx.compose.ui.unit.dp
 import androidx.compose.ui.unit.sp
@@ -40,7 +41,8 @@ fun CadDrawingItem(cad: CadEntity, block: () -> Unit) {
             color = textBlackColor,
             textAlign = TextAlign.Center,
             maxLines = 1,
-            modifier = Modifier.weight(4f)
+            modifier = Modifier.weight(4f),
+            overflow = TextOverflow.Ellipsis
         )
         Text(
             text = "10条",

+ 4 - 12
app/src/main/java/com/ys/bdtp/adm/mvvm/ui/screen/cad/CadScreen.kt

@@ -1,25 +1,16 @@
 package com.ys.bdtp.adm.mvvm.ui.screen.cad
 
 import android.content.Intent
+import android.widget.Toast
 import androidx.compose.foundation.background
-import androidx.compose.foundation.layout.*
-import androidx.compose.foundation.lazy.LazyColumn
-import androidx.compose.foundation.lazy.items
-import androidx.compose.material.Text
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.fillMaxSize
 import androidx.compose.runtime.*
-import androidx.compose.ui.Alignment
 import androidx.compose.ui.Modifier
 import androidx.compose.ui.graphics.Color
 import androidx.compose.ui.platform.LocalContext
 import androidx.compose.ui.tooling.preview.Preview
-import androidx.compose.ui.unit.dp
-import androidx.compose.ui.unit.sp
-import com.ys.bdtp.adm.app.theme.textBlackColor
-import com.ys.bdtp.adm.app.theme.trDivColor
-import com.ys.bdtp.adm.app.theme.underColor
-import com.ys.bdtp.adm.app.theme.whiteColor
 import com.ys.bdtp.adm.app.tools.file.getUri
-import com.ys.bdtp.adm.mvvm.model.db.entity.task.CadEntity
 import com.ys.bdtp.adm.mvvm.model.db.relation.FloorWithCads
 import com.ys.bdtp.adm.mvvm.model.db.relation.ProjectWithBuildingAndFloors
 import com.ys.bdtp.adm.mvvm.ui.compose.*
@@ -115,6 +106,7 @@ fun CadScreen(projectId: String) {
                             context.startActivity(intent)
                         } else {
                             // TODO
+                            Toast.makeText(context, "图纸不存在", Toast.LENGTH_SHORT).show()
                             println("not found")
                         }
                     })

+ 1 - 1
app/src/main/java/com/ys/bdtp/adm/mvvm/ui/screen/cad/CadSide.kt

@@ -32,7 +32,7 @@ fun CadSide(project: ProjectWithBuildingAndFloors?, floorClick: (FloorEntity) ->
         }
         if (project != null) {
             ExpandList(
-                items = project.buildings,
+                items = project.buildings.filter { it.building.valid == 1 },
                 click = {
                     floorClick(it)
                 })

+ 17 - 10
app/src/main/java/com/ys/bdtp/adm/mvvm/ui/screen/offline/OfflineSide.kt

@@ -157,11 +157,12 @@ fun OfflineSide(state: State<Data<ProjectWithBuildings>>) {
                 verticalAlignment = Alignment.CenterVertically
             ) {
                 Spacer(modifier = Modifier.width(16.dp))
-                Image(
+                Spacer(modifier = Modifier.width(8.dp))
+               /* Image(
                     painter = painterResource(R.drawable.red_circle),
                     contentDescription = "",
                     modifier = Modifier.size(8.dp)
-                )
+                )*/
                 Spacer(modifier = Modifier.width(12.dp))
                 Text(text = "项目任务")
             }
@@ -177,6 +178,7 @@ fun OfflineSide(state: State<Data<ProjectWithBuildings>>) {
                 verticalAlignment = Alignment.CenterVertically
             ) {
                 Spacer(modifier = Modifier.width(16.dp))
+                //Spacer(modifier = Modifier.width(8.dp))
                 Image(
                     painter = painterResource(R.drawable.red_circle),
                     contentDescription = "",
@@ -197,11 +199,12 @@ fun OfflineSide(state: State<Data<ProjectWithBuildings>>) {
                 verticalAlignment = Alignment.CenterVertically
             ) {
                 Spacer(modifier = Modifier.width(16.dp))
-                Image(
+                Spacer(modifier = Modifier.width(8.dp))
+                /*Image(
                     painter = painterResource(R.drawable.red_circle),
                     contentDescription = "",
                     modifier = Modifier.size(8.dp)
-                )
+                )*/
                 Spacer(modifier = Modifier.width(12.dp))
                 Text(text = "楼层模型")
             }
@@ -217,11 +220,12 @@ fun OfflineSide(state: State<Data<ProjectWithBuildings>>) {
                 verticalAlignment = Alignment.CenterVertically
             ) {
                 Spacer(modifier = Modifier.width(16.dp))
-                Image(
+                Spacer(modifier = Modifier.width(8.dp))
+              /*  Image(
                     painter = painterResource(R.drawable.red_circle),
                     contentDescription = "",
                     modifier = Modifier.size(8.dp)
-                )
+                )*/
                 Spacer(modifier = Modifier.width(12.dp))
                 Text(text = "参考图纸")
             }
@@ -237,11 +241,12 @@ fun OfflineSide(state: State<Data<ProjectWithBuildings>>) {
                 verticalAlignment = Alignment.CenterVertically
             ) {
                 Spacer(modifier = Modifier.width(16.dp))
-                Image(
+                Spacer(modifier = Modifier.width(8.dp))
+               /* Image(
                     painter = painterResource(R.drawable.red_circle),
                     contentDescription = "",
                     modifier = Modifier.size(8.dp)
-                )
+                )*/
                 Spacer(modifier = Modifier.width(12.dp))
                 Text(text = "交付范围")
             }
@@ -257,15 +262,17 @@ fun OfflineSide(state: State<Data<ProjectWithBuildings>>) {
                 verticalAlignment = Alignment.CenterVertically
             ) {
                 Spacer(modifier = Modifier.width(16.dp))
-                Image(
+                Spacer(modifier = Modifier.width(8.dp))
+              /*  Image(
                     painter = painterResource(R.drawable.red_circle),
                     contentDescription = "",
                     modifier = Modifier.size(8.dp)
-                )
+                )*/
                 Spacer(modifier = Modifier.width(12.dp))
                 Text(text = "交付规则")
             }
         }
+
     }
 }