实现了部分收货UI。替换为张欢测试服务

This commit is contained in:
zxj
2025-07-18 08:49:06 +08:00
parent 5874e4ed9a
commit 4c6fa31787
22 changed files with 282 additions and 137 deletions
@@ -47,4 +47,5 @@ object GlobalData {
object GlobalKey {
const val KEY_TOKEN = "tokenKey"
const val KEY_USER_INFO = "userInfoKey"
const val KEY_USER_NAME = "userNameKey"
}
@@ -20,9 +20,8 @@ import javax.inject.Singleton
object NetworkModule {
// private const val BASE_URL = "https://127.0.0.1"
private const val BASE_URL = "https://vip.shuziweidao.com"
// private const val BASE_URL = "http://192.168.1.8:9092"
// private const val BASE_URL = "https://vip.shuziweidao.com"
private const val BASE_URL = "http://192.168.1.237:9002"
private const val TIME_OUT = 30L // 超时时间(秒)
@Provides
@@ -3,8 +3,9 @@ package com.sw.inbound.model.response
data class ApiResponse<T>(
val code: Int,
val success: Boolean? = false,
val msg: String? = "",
val data: T? = null
val message: String? = "",
val result: T? = null,
val timestamp: Long? = 0
) {
fun isSuccess(): Boolean = code == 200
}
@@ -105,6 +105,13 @@ data class GoodsInfo(
return receivedNum?.toFormattedString() ?: ""
}
val receivedNumListStr: String
get() {
if (receivedNum == null)
return "-"
return receivedNum?.toFormattedString() ?: "-"
}
val recUnitPriceTaxInStr: String
get() {
if (recUnitPriceTaxIn == 0f) return ""
@@ -38,8 +38,11 @@ data class SupplierInfo(
val pageNum: String? = "",
@SerializedName("pageSize")
val pageSize: String? = "",
/**
* 采购单位
*/
@SerializedName("purCode")
val purCode: String? = "",
val purCode: String? = "-",
@SerializedName("purDateStart")
val purDateStart: String? = "",
@SerializedName("purDateStop")
@@ -102,7 +105,7 @@ data class SupplierInfo(
* 供应商
*/
@SerializedName("supplierName")
val supplierName: String = "",
val supplierName: String? = "",
@SerializedName("taxRateAll")
val taxRateAll: Double? = 0.0,
@SerializedName("updateTime")
@@ -25,13 +25,13 @@ interface ApiService {
/**
* 登录
*/
@POST("/shuwei-user/swuserbase/loginPad")
@POST("/sys/loginPad")
suspend fun login(@Body body: LoginParam): ApiResponse<User>
/**
* 采购单入库-列表
*/
@GET("/shuwei-zhct/pad/receivePage")
@GET("/pad/receivePage")
suspend fun getReceiveList(
@Query("pageNo") pageNo: Int,
@Query("pageSize") pageSize: Int
@@ -40,44 +40,44 @@ interface ApiService {
/**
* 采购单入库-详情
*/
@GET("/shuwei-zhct/pad/receiveDetail")
@GET("/pad/receiveDetail")
suspend fun getReceiveDetail(@Query("id") id: Int): ApiResponse<PurchaseInfo>
/**
* 部分收货
*/
@POST("/shuwei-zhct/pad/partialReceiptGoods")
@POST("/pad/partialReceiptGoods")
suspend fun partialReceipt(@Body uploadInfo: UploadInfo): ApiResponse<Boolean>
/**
* 确认收货
*/
@POST("/shuwei-zhct/pad/saveAndReceiveAndGoWare")
@POST("/pad/saveAndReceiveAndGoWare")
suspend fun confirmReceipt(@Body uploadInfo: UploadInfo): ApiResponse<Boolean>
/**
* 存储方式
*/
@GET("/shuwei-zhct/swsysdictitem/getDictItemByF")
@GET("/sys/dict/getDictItemByF")
suspend fun getGoodsStorageType(@Query("dictCode") dictCode: String = "goods_storage_type"): ApiResponse<List<StorageType>>
/**
* 物品类型
*/
@GET("/shuwei-zhct/swkcglgoodstype/notLimitList")
@GET("/pad/notLimitList")
suspend fun getGoodsType(): ApiResponse<GoodsType>
/**
* 获取字典数据
*/
@GET("/shuwei-zhct/pad/dataList")
@GET("/pad/dataList")
suspend fun getDictType(@Query("type") type: String): ApiResponse<List<DictType>>
/**
* 上传图片
*/
@Multipart
@POST("/shuwei-zhct/fileUpload/fileUpload/")
@POST("/fileUpload/fileUpload/")
suspend fun uploadImage(
@Part("code") code: RequestBody,
@Part file: MultipartBody.Part
@@ -86,7 +86,7 @@ interface ApiService {
/**
* 搜索物品列表
*/
@GET("/shuwei-zhct/pad/goodsInfoList")
@GET("/pad/goodsInfoList")
suspend fun searchGoodsInfoList(
@Query("goodsName") goodsName: String,
@Query("pageNo") pageNo: Int,
@@ -96,13 +96,13 @@ interface ApiService {
/**
* 自采添加商品
*/
@POST("/shuwei-zhct/pad/goodsAdd")
@POST("/pad/goodsAdd")
suspend fun selfPurchaseGoodsAdd(@Body goodsAddParam: GoodsAddParam): ApiResponse<SearchGoodsInfo>
/**
* 自采入库
*/
@POST("/shuwei-zhct/pad/SelfPurchasedGoods")
@POST("/pad/SelfPurchasedGoods")
suspend fun selfPurchaseWarehousing(@Body list: List<PurchaseWarehouseParam>): ApiResponse<Boolean>
}
@@ -16,7 +16,7 @@ class RequestInterceptor : Interceptor {
.header("Content-Type", "application/json")
.header("Accept", "application/json")
// .header("Authorization", "Bearer ${getToken()}")
.header("Authorization", getToken())
.header("x-access-token", getToken())
val newRequest = requestBuilder.build()
@@ -19,37 +19,37 @@ abstract class BaseRepository {
when (e) {
is HttpException -> {
// 对于HTTP异常,尝试从响应体中获取错误信息
val errorBody = e.response()?.errorBody()?.string()
val errorMsg = if (!errorBody.isNullOrEmpty()) {
errorBody
} else {
"HTTP Error: ${e.code()} - ${e.message()}"
}
ApiResponse(code = e.code(), msg = errorMsg)
// val errorBody = e.response()?.errorBody()?.string()
// val errorMsg = if (!errorBody.isNullOrEmpty()) {
// errorBody
// } else {
// "HTTP Error: ${e.code()} - ${e.message()}"
// }
ApiResponse(code = e.code(), message = e.message())
}
is SocketTimeoutException -> {
ApiResponse(code = -2, msg = "请求超时: ${e.message}")
ApiResponse(code = -2, message = "请求超时: ${e.message}")
}
is ConnectException -> {
ApiResponse(code = -3, msg = "连接失败: ${e.message}")
ApiResponse(code = -3, message = "连接失败: ${e.message}")
}
is SSLHandshakeException -> {
ApiResponse(code = -4, msg = "SSL握手失败: ${e.message}")
ApiResponse(code = -4, message = "SSL握手失败: ${e.message}")
}
is JsonParseException -> {
ApiResponse(code = -5, msg = "JSON解析错误: ${e.message}")
ApiResponse(code = -5, message = "JSON解析错误: ${e.message}")
}
is IOException -> {
ApiResponse(code = -6, msg = "网络IO错误: ${e.message}")
ApiResponse(code = -6, message = "网络IO错误: ${e.message}")
}
else -> {
ApiResponse(code = -1, msg = "未知错误: ${e.message ?: "无错误信息"}")
ApiResponse(code = -1, message = "未知错误: ${e.message ?: "无错误信息"}")
}
}
}
@@ -91,7 +91,7 @@ class RemoteRepository @Inject constructor(
val part =
FileUtils.genRequestPart(context = ContextUtils.getAppContext(), imageUri = uri)
if (part == null) {
ApiResponse(code = -1, msg = "解析图片失败", data = "")
ApiResponse(code = -1, message = "解析图片失败", result = "")
} else {
apiService.uploadImage(code = codeRequestBody, file = part)
}
@@ -34,6 +34,7 @@ import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavController
import androidx.navigation.compose.rememberNavController
import com.sw.inbound.GlobalData
import com.sw.inbound.GlobalKey
import com.sw.inbound.R
import com.sw.inbound.ext.bold
import com.sw.inbound.ext.textAlign
@@ -41,6 +42,7 @@ import com.sw.inbound.ext.withSize
import com.sw.inbound.ui.Screen
import com.sw.inbound.ui.theme.AppTypography
import com.sw.inbound.ui.weight.CustomButton
import com.sw.inbound.utils.SPUtil
import com.sw.inbound.utils.ToastUtils
import com.sw.inbound.viewmodel.UserViewModel
import timber.log.Timber
@@ -51,13 +53,14 @@ fun LoginScreen(
controller: NavController = rememberNavController(),
viewModel: UserViewModel = hiltViewModel<UserViewModel>()
) {
var username by remember { mutableStateOf<String>("padAdmin") }
var password by remember { mutableStateOf<String>("123123") }
var username by remember { mutableStateOf<String>("") }
var password by remember { mutableStateOf<String>("") }
// val user by viewModel.user.collectAsState()
LaunchedEffect(Unit) {
Timber.d(" user =")
username = SPUtil.getInstance().get(GlobalKey.KEY_USER_NAME, "").toString()
viewModel.user.collect {
Timber.d(" user collect = ${it}")
if (it != null) {
@@ -233,7 +233,7 @@ fun PurchaseOrderItem(product: SupplierInfo, onItemClick: (SupplierInfo) -> Unit
verticalArrangement = Arrangement.spacedBy(0.dp)
) {
Text(
text = product.supplierName,
text = product.supplierName ?: "-",
modifier = Modifier.padding(top = 25.dp),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
@@ -245,7 +245,7 @@ fun PurchaseOrderItem(product: SupplierInfo, onItemClick: (SupplierInfo) -> Unit
)
Spacer(modifier = Modifier.height(itemSpace))
Text(
text = "单号 ${product.receiveCode}",
text = "单号 ${product.purCode ?: "-"}",
maxLines = 1,
style = grayTextStyle
)
@@ -2,6 +2,7 @@ package com.sw.inbound.ui.page
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
@@ -14,9 +15,10 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.Tab
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
@@ -32,6 +34,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
@@ -44,6 +47,7 @@ import com.sw.inbound.GlobalData
import com.sw.inbound.R
import com.sw.inbound.ext.bold
import com.sw.inbound.ext.toSafeFloat
import com.sw.inbound.ext.withColor
import com.sw.inbound.ext.withSize
import com.sw.inbound.model.request.UploadInfo
import com.sw.inbound.model.response.DictType
@@ -52,6 +56,8 @@ import com.sw.inbound.sdk.SensorScaleUtils
import com.sw.inbound.ui.theme.AppTypography
import com.sw.inbound.ui.theme.AppTypography.black141428TextStyle
import com.sw.inbound.ui.theme.AppTypography.gray96a0aaTextStyle
import com.sw.inbound.ui.theme.Black_141428
import com.sw.inbound.ui.theme.Red_FF3232
import com.sw.inbound.ui.weight.BottomActionBar
import com.sw.inbound.ui.weight.CustomDropdownTextField
import com.sw.inbound.ui.weight.CustomSpinner
@@ -129,10 +135,14 @@ fun ReceiptProductScreen(
}
if (showDialog) {
ReceiptTipDialog(isWarn = viewModel.hasWrongCount(), onCancelClick = {
ReceiptTipDialog(
isWarn = viewModel.hasWrongCount(),
goodsList = orders.filter { it.receivedNum != it.receiveCount },
onCancelClick = {
Timber.d("返回")
viewModel.updateReceiptDialog(false)
}, onConfirmClick = { isFull ->
},
onConfirmClick = { isFull ->
Timber.d(if (isFull) "确认收货" else "部分收货")
viewModel.updateReceiptDialog(false)
val uploadInfo = UploadInfo(id = id)
@@ -144,7 +154,6 @@ fun ReceiptProductScreen(
uploadInfo.supplierId = supplierId
viewModel.partialReceipt(uploadInfo)
}
})
}
}
@@ -284,7 +293,7 @@ fun UnadjustedView(purchaseOrderList: List<GoodsInfo>, viewModel: ReceiptViewMod
modifier = Modifier.padding(horizontal = 30.dp),
productList = purchaseOrderList,
checkedItem = checkedItem,
onItemCheckedClick = {
onItemCheckedClick = { index, it ->
viewModel.updateSelectedItemWithSwitch(it)
})
}
@@ -294,11 +303,14 @@ fun AdjustedView(viewModel: ReceiptViewModel) {
// 已调整view
val purchaseAdjustList by viewModel.adjustedOrders.collectAsState()
LazyColumn(
verticalArrangement = Arrangement.spacedBy(0.dp)
) {
items(items = purchaseAdjustList, key = { it.goodId!! }) {
// ReceiptItem(it)
itemsIndexed(
items = purchaseAdjustList,
key = { index, it -> it.goodId!! + index }) { index, it ->
AdjustedViewItem(it, viewModel)
}
}
@@ -306,9 +318,19 @@ fun AdjustedView(viewModel: ReceiptViewModel) {
@Composable
private fun AdjustedViewItem(purchaseOrder: GoodsInfo, viewModel: ReceiptViewModel) {
val warehouseTypeList = GlobalData.warehouseTypeList // viewModel.getStoreList()
val warehouseTypeList = GlobalData.warehouseTypeList
val isWarnItem = purchaseOrder.receivedNum != purchaseOrder.receiveCount
var modifier: Modifier // = Modifier.padding(horizontal = 30.dp)
if (isWarnItem) {
modifier = Modifier
.padding(horizontal = 30.dp)
.background(Color(0xffFAF1F9))
.border(width = 1.dp, color = Color.Red)
} else {
modifier = Modifier.padding(horizontal = 30.dp)
}
Column(modifier = Modifier.padding(horizontal = 30.dp)) {
Column(modifier = modifier) {
Spacer(modifier = Modifier.height(30.dp))
Row(
modifier = Modifier
@@ -316,7 +338,10 @@ private fun AdjustedViewItem(purchaseOrder: GoodsInfo, viewModel: ReceiptViewMod
.padding(horizontal = 30.dp),
horizontalArrangement = Arrangement.SpaceBetween
) {
Text(purchaseOrder.goodNameStr, style = AppTypography.blackTextStyle)
Text(
purchaseOrder.goodNameStr,
style = if (isWarnItem) AppTypography.blackTextStyle.withColor(Color.Red) else AppTypography.blackTextStyle
)
Row {
Text("采购量:", style = gray96a0aaTextStyle)
Text(
@@ -348,7 +373,8 @@ private fun AdjustedViewItem(purchaseOrder: GoodsInfo, viewModel: ReceiptViewMod
Text(text = "x", style = AppTypography.black141428TextStyle.bold())
Spacer(modifier = Modifier.width(50.dp))
AdjustedRowInputLayout(
label = "实收", value = purchaseOrder.receivedNumTemp,
label = "实收",
value = purchaseOrder.receivedNumTemp,
onValueChange = {
viewModel.updatePurchaseItem(
purchaseOrder = purchaseOrder.copy(
@@ -356,7 +382,9 @@ private fun AdjustedViewItem(purchaseOrder: GoodsInfo, viewModel: ReceiptViewMod
receivedNum = it.toSafeFloat()
)
)
}, inputType = InputType.Decimal
},
inputType = InputType.Decimal,
inputTextColor = if (isWarnItem) Red_FF3232 else Black_141428
)
Spacer(modifier = Modifier.width(12.dp))
Text(text = purchaseOrder.unitNameStr, style = AppTypography.gray96a0aaTextStyle)
@@ -407,7 +435,8 @@ private fun AdjustedRowInputLayout(
textAlign: TextAlign = TextAlign.Center,
spinnerTextAlign: TextAlign = TextAlign.Start,
trailingLabel: String? = null,
inputType: InputType = InputType.Text
inputType: InputType = InputType.Text,
inputTextColor: Color = Black_141428
) {
Row(
modifier = Modifier
@@ -426,7 +455,13 @@ private fun AdjustedRowInputLayout(
value = value,
onValueChange = onValueChange,
textAlign = textAlign,
trailingLabel = trailingLabel, inputType = inputType
trailingLabel = trailingLabel, inputType = inputType,
textStyle = LocalTextStyle.current.copy(
color = inputTextColor,
fontSize = 24.sp,
fontWeight = FontWeight.Bold,
textAlign = textAlign
)
)
} else {
CustomDropdownTextField(
@@ -434,7 +469,7 @@ private fun AdjustedRowInputLayout(
value = value,
dropdownItems = dropdownItems,
onValueChange = onValueChange,
textAlign = spinnerTextAlign
textAlign = spinnerTextAlign,
)
}
}
@@ -696,7 +696,7 @@ private fun SelfProductEditView(
)
}
},
trailingLabel = selectedItem!!.unitName,
trailingLabel = selectedItem!!.unitName ?: "-",
)
RowInputLayout(
@@ -16,6 +16,13 @@ object AppTypography {
color = Color(0xFF96A0AA)
)
val gray999999TextStyle: TextStyle
@Composable get() = TextStyle(
fontSize = 24.sp,
fontWeight = FontWeight.Medium,
color = Color(0xFF999999)
)
val black141428TextStyle: TextStyle
@Composable get() = TextStyle(
fontSize = 24.sp,
@@ -38,6 +45,14 @@ object AppTypography {
fontWeight = FontWeight.Bold
)
val blackMediumTextStyle: TextStyle
@Composable
get() = TextStyle(
color = colorResource(R.color.black),
fontSize = 24.sp,
fontWeight = FontWeight.Medium
)
val BlueTextStyle: TextStyle
@Composable
get() = TextStyle(
@@ -18,4 +18,5 @@ val GrayDivider = Color(0XFFDCDCF0)
val Green_009632 = Color(0xFF009632)
val Blue_0032C8 = Color(0xFF0032C8)
val Red_FF3232 = Color(0xFFFF3232)
@@ -12,9 +12,13 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.material3.HorizontalDivider
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
@@ -36,10 +40,12 @@ fun ReceiptUnadjustedListView(
modifier: Modifier = Modifier,
productList: List<GoodsInfo>,
checkedItem: GoodsInfo? = null,
onItemCheckedClick: (GoodsInfo) -> Unit = {},
onItemCheckedClick: (Int, GoodsInfo) -> Unit = { _, _ -> },
showClose: Boolean = false,
onCloseClick: (GoodsInfo) -> Unit = {},
) {
var selectIndex by remember { mutableIntStateOf(-1) }
Column(
modifier = modifier
// .padding(horizontal = 30.dp)
@@ -85,17 +91,20 @@ fun ReceiptUnadjustedListView(
// Spacer(modifier = Modifier.height(31.dp))
// 左侧列表
LazyColumn() {
items(items = productList, key = { it.goodId!! }) { it ->
itemsIndexed(
items = productList,
key = { index, it -> it.goodId!! + index }) { index, it ->
val checkedBg =
if (it.goodId == checkedItem?.goodId) Gray_DCDCF0 else Color.Transparent
if (selectIndex == index) Gray_DCDCF0 else Color.Transparent
Row(
modifier = Modifier
.background(color = checkedBg)
.height(80.dp)
.padding(horizontal = 60.dp)
.clickable {
onItemCheckedClick(it)
selectIndex = index
onItemCheckedClick(index, it)
}, verticalAlignment = Alignment.CenterVertically
) {
CustomSingleRightText(
@@ -1,6 +1,7 @@
package com.sw.inbound.ui.weight.dialog
import androidx.compose.foundation.Image
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
@@ -11,6 +12,8 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Surface
@@ -21,6 +24,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.window.Dialog
@@ -29,9 +33,12 @@ import com.sw.inbound.R
import com.sw.inbound.ext.bold
import com.sw.inbound.ext.withColor
import com.sw.inbound.ext.withSize
import com.sw.inbound.model.response.GoodsInfo
import com.sw.inbound.ui.theme.AppTypography
import com.sw.inbound.ui.theme.GrayDivider
import com.sw.inbound.ui.weight.CustomButton
import com.sw.inbound.ui.weight.CustomOutlinedButton
import com.sw.inbound.ui.weight.CustomSingleRightText
/**
* 收货确认弹窗
@@ -40,6 +47,7 @@ import com.sw.inbound.ui.weight.CustomOutlinedButton
fun ReceiptTipDialog(
modifier: Modifier = Modifier,
isWarn: Boolean = false,
goodsList: List<GoodsInfo>,
onCancelClick: () -> Unit,
onConfirmClick: (Boolean) -> Unit,
onDismiss: () -> Unit = {},
@@ -79,10 +87,83 @@ fun ReceiptTipDialog(
)
Spacer(modifier = Modifier.height(60.dp))
Text(
text = if (isWarn) "收货数量与采购量不一致" else "核对无误,确认收货",
text = if (isWarn) "收货数量与采购量存在差异" else "核对无误,确认收货",
style = AppTypography.black141428TextStyle.bold().withSize(48.sp)
)
if (isWarn) {
Spacer(modifier = Modifier.height(60.dp))
Column(
modifier = Modifier
.height(257.dp)
.width(810.dp)
.border(width = 1.dp, color = GrayDivider)
) {
Row(
modifier = Modifier
.padding(start = 80.dp, top = 20.dp, end = 80.dp)
.height(50.dp),
horizontalArrangement = Arrangement.SpaceEvenly,
verticalAlignment = Alignment.CenterVertically
) {
CustomSingleRightText(
modifier = Modifier.weight(1f),
text = "名称",
style = AppTypography.gray999999TextStyle,
textAlign = TextAlign.Center
)
Spacer(modifier = Modifier.width(10.dp))
CustomSingleRightText(
modifier = Modifier.weight(1f),
text = "采购量",
style = AppTypography.gray999999TextStyle,
textAlign = TextAlign.Center
)
Spacer(modifier = Modifier.width(10.dp))
CustomSingleRightText(
modifier = Modifier.weight(1f),
text = "实收",
style = AppTypography.gray999999TextStyle,
textAlign = TextAlign.Center
)
}
LazyColumn {
itemsIndexed(items = goodsList) { index, goods ->
Row(
modifier = Modifier
.padding(horizontal = 80.dp)
.height(50.dp),
horizontalArrangement = Arrangement.SpaceEvenly,
verticalAlignment = Alignment.CenterVertically
) {
CustomSingleRightText(
modifier = Modifier.weight(1f),
text = goods.goodNameStr,
style = AppTypography.blackMediumTextStyle,
textAlign = TextAlign.Center
)
Spacer(modifier = Modifier.width(10.dp))
CustomSingleRightText(
modifier = Modifier.weight(1f),
text = "${goods.receivedNumListStr}${goods.unitNameStr}",
style = AppTypography.blackMediumTextStyle.withColor(
color = Color(0xFF0032C8)
),
textAlign = TextAlign.Center
)
Spacer(modifier = Modifier.width(10.dp))
CustomSingleRightText(
modifier = Modifier.weight(1f),
text = "${goods.receiveCountListStr}${goods.unitNameStr}",
style = AppTypography.blackMediumTextStyle.withColor(
Color.Red
),
textAlign = TextAlign.Center
)
}
}
}
}
Spacer(modifier = Modifier.height(29.dp))
Text(
text = "请确认实际收货数量,或选择部分收货处理",
@@ -52,8 +52,8 @@ abstract class BaseViewModel(
if (response.isSuccess()) {
return true
}
Timber.d("msg = ${response.msg}, code = ${response.code}")
ToastUtils.showToast("${response.msg}(${response.code})")
Timber.d("msg = ${response.message}, code = ${response.code}")
ToastUtils.showToast("${response.message}(${response.code})")
return false
}
@@ -71,60 +71,60 @@ abstract class BaseViewModel(
Timber.d("获取所有字典列表")
launchWithLoading {
val response = repository.getGoodsStorageType()
if (response.isSuccess()) {
Timber.d("getGoodsStorageType data = ${response.data}")
response.data?.let {
if (parseResponse(response)) {
Timber.d("getGoodsStorageType data = ${response.result}")
response.result?.let {
// val dictType = DictType(response.data)
val list = mutableListOf<DictType>()
for (type in response.data) {
for (type in response.result) {
list.add(DictType(type.itemValue!!.toInt(), type.itemText!!))
}
GlobalData.storageTypeList = list
}
} else {
Timber.e("getGoodsStorageType msg = ${response.msg}, code = ${response.code}")
Timber.e("getGoodsStorageType msg = ${response.message}, code = ${response.code}")
}
val response1 = repository.getGoodsType()
if (response1.isSuccess()) {
Timber.d("getGoodsType data = ${response1.data?.allType}")
response1.data?.let {
if (response1.data.allType != null) {
if (parseResponse(response1)) {
Timber.d("getGoodsType data = ${response1.result?.allType}")
response1.result?.let {
if (response1.result.allType != null) {
val list = mutableListOf<DictType>()
for (type in response1.data.allType) {
for (type in response1.result.allType) {
list.add(DictType(type!!.id!!, type.typeName!!))
}
GlobalData.goodsTypeList = list
}
}
} else {
Timber.e("getGoodsType msg = ${response1.msg}, code = ${response1.code}")
Timber.e("getGoodsType msg = ${response1.message}, code = ${response1.code}")
}
val response2 = repository.getDictType(RemoteRepository.TypeEnum.WAREHOUSE)
if (response2.isSuccess()) {
Timber.d("getDictType WAREHOUSE data = ${response2.data}")
response2.data?.let {
GlobalData.warehouseTypeList = response2.data
if (parseResponse(response2)) {
Timber.d("getDictType WAREHOUSE data = ${response2.result}")
response2.result?.let {
GlobalData.warehouseTypeList = response2.result
}
} else {
Timber.e("getDictType WAREHOUSE msg = ${response2.msg}, code = ${response2.code}")
Timber.e("getDictType WAREHOUSE msg = ${response2.message}, code = ${response2.code}")
}
val response3 = repository.getDictType(RemoteRepository.TypeEnum.SUPPLIER)
if (response3.isSuccess()) {
Timber.d("getDictType SUPPLIER data = ${response3.data}")
response3.data?.let {
GlobalData.supplierTypeList = response3.data
if (parseResponse(response3)) {
Timber.d("getDictType SUPPLIER data = ${response3.result}")
response3.result?.let {
GlobalData.supplierTypeList = response3.result
}
} else {
Timber.e("getDictType SUPPLIER msg = ${response3.msg}, code = ${response3.code}")
Timber.e("getDictType SUPPLIER msg = ${response3.message}, code = ${response3.code}")
}
val response4 = repository.getDictType(RemoteRepository.TypeEnum.UNIT)
if (response4.isSuccess()) {
Timber.d("getDictType UNIT data = ${response4.data}")
response4.data?.let {
GlobalData.unitTypeList = response4.data
if (parseResponse(response4)) {
Timber.d("getDictType UNIT data = ${response4.result}")
response4.result?.let {
GlobalData.unitTypeList = response4.result
}
} else {
Timber.e("getDictType UNIT msg = ${response4.msg}, code = ${response4.code}")
Timber.e("getDictType UNIT msg = ${response4.message}, code = ${response4.code}")
}
}
}
@@ -43,8 +43,8 @@ class PurchaseOrderViewModel @Inject constructor(
_isMoreLoading.value = true
val response = repository.getReceiveList(pageNum, pageSize)
_isMoreLoading.value = false
if (response.isSuccess()) {
response.data?.records?.let {
if (parseResponse(response)) {
response.result?.records?.let {
_canLoadMore.value = it.size >= pageSize
_supplierList.value = _supplierList.value + it
}
@@ -53,8 +53,8 @@ class PurchaseOrderViewModel @Inject constructor(
} else {
launchWithLoading {
val response = repository.getReceiveList(pageNum, pageSize)
if (response.isSuccess()) {
response.data?.records?.let {
if (parseResponse(response)) {
response.result?.records?.let {
_supplierList.value = it
}
}
@@ -146,8 +146,8 @@ class ReceiptViewModel @Inject constructor(
fun getReceiveDetail(id: Int) {
launchWithLoading {
val response = repository.getReceiveDetail(id)
if (response.isSuccess()) {
_currentPurchaseInfo.value = response.data
if (parseResponse(response)) {
_currentPurchaseInfo.value = response.result
initOrders()
}
}
@@ -305,15 +305,9 @@ class ReceiptViewModel @Inject constructor(
fun partialReceipt(uploadInfo: UploadInfo) {
launchWithLoading {
val response = repository.partialReceipt(uploadInfo)
if (!response.isSuccess()) {
parseResponse(response)
return@launchWithLoading
}
if (response.success == true) {
if (parseResponse(response)) {
ToastUtils.showToast("部分收货成功")
_receiptResult.value = true
} else {
ToastUtils.showToast("部分收货失败")
}
}
}
@@ -321,15 +315,9 @@ class ReceiptViewModel @Inject constructor(
fun confirmReceipt(uploadInfo: UploadInfo) {
launchWithLoading {
val response = repository.confirmReceipt(uploadInfo)
if (!response.isSuccess()) {
parseResponse(response)
return@launchWithLoading
}
if (response.success == true) {
if (parseResponse(response)) {
ToastUtils.showToast("收货成功")
_receiptResult.value = true
} else {
ToastUtils.showToast("收货失败")
}
}
}
@@ -107,16 +107,17 @@ class SelfProcurementViewModel @Inject constructor(
val currentItem = _selectedItem.value
currentItem?.let { info ->
val selectUnitType = currentItem.selectUnitType
// 用户输入数量后不再通过重量反算
if (_countUserInput.value) {
if (_countUserInput.value || selectUnitType == null) {
_selectedItem.value = info.copy(
goodsWeight = weight.toSafeBigDecimal(),
)
return@startScale
}
val selectUnitType = currentItem.selectUnitType
if (selectUnitType == null) return@startScale
// val selectUnitType = currentItem.selectUnitType
// if (selectUnitType == null) return@startScale
val consumeValue = selectUnitType.consumeValue?.toDouble() ?: 1.0
val purchaseValue = selectUnitType.purchaseValue?.toDouble() ?: 1.0
@@ -265,8 +266,8 @@ class SelfProcurementViewModel @Inject constructor(
}
val response = repository.searchGoodsInfoList(goodsName, pageNo, pageSize)
_isMoreLoading.value = false
if (response.isSuccess()) {
val data = response.data
if (parseResponse(response)) {
val data = response.result
data?.records?.let {
_canLoadMore.value = data.records.size >= pageSize
if (pageNo > 1) {
@@ -334,22 +335,20 @@ class SelfProcurementViewModel @Inject constructor(
launchWithLoading {
val uploadResponse = repository.uploadImage(imageUri)
if (!uploadResponse.isSuccess()) {
parseResponse(uploadResponse)
if (!parseResponse(uploadResponse)) {
return@launchWithLoading
}
// ToastUtils.showToast("图片上传成功,${uploadResponse.data}")
GlobalData.imageUri = null
_goodsAddParam.value.relativeUrl = uploadResponse.data
_goodsAddParam.value.relativeUrl = uploadResponse.result
val response = repository.selfPurchaseGoodsAdd(_goodsAddParam.value)
if (!response.isSuccess()) {
parseResponse(response)
if (!parseResponse(response)) {
return@launchWithLoading
}
FileUtils.deleteFileWithUri(context = ContextUtils.getAppContext(), uri = imageUri)
_showAddProductDialog.value = false
_goodsAddParam.value = GoodsAddParam()
val searchFirst = response.data!!.records?.get(0)
val searchFirst = response.result!!.records?.get(0)
searchFirst?.let {
updateSelectedItemWithSearch(searchFirst)
}
@@ -369,6 +368,8 @@ class SelfProcurementViewModel @Inject constructor(
val response = repository.selfPurchaseWarehousing(_purchaseList.value)
if (parseResponse(response)) {
_addToWarehouseResult.value = true
} else {
_addToWarehouseResult.value = false
}
}
}
@@ -38,10 +38,11 @@ class UserViewModel @Inject constructor(
fun login(userName: String, password: String) = launchWithLoading {
val loginParam = LoginParam(userName = userName, password = password)
val response = repo.login(loginParam)
if (response.isSuccess()) {
_user.value = response.data
saveToken(response.data)
response.data?.token
if (parseResponse(response)) {
SPUtil.getInstance().put(GlobalKey.KEY_USER_NAME, userName)
_user.value = response.result
saveToken(response.result)
response.result?.token
}
}