添加识别逻辑
This commit is contained in:
@@ -20,8 +20,8 @@ import javax.inject.Singleton
|
||||
object NetworkModule {
|
||||
|
||||
// private const val BASE_URL = "https://127.0.0.1"
|
||||
// private const val BASE_URL = "https://yyjk.shuziweidao.com/gateway/"
|
||||
private const val BASE_URL = "http://192.168.1.237:9002/"
|
||||
private const val BASE_URL = "https://yyjk.shuziweidao.com/gateway/"
|
||||
// private const val BASE_URL = "http://192.168.1.237:9002/"
|
||||
|
||||
// private const val BASE_URL = "https://vip.shuziweidao.com/gateway/"
|
||||
private const val TIME_OUT = 30L // 超时时间(秒)
|
||||
|
||||
@@ -66,6 +66,7 @@ import com.sw.inbound.ui.weight.CustomSpinner
|
||||
import com.sw.inbound.ui.weight.CustomTextField
|
||||
import com.sw.inbound.ui.weight.IdentityView
|
||||
import com.sw.inbound.ui.weight.InputType
|
||||
import com.sw.inbound.ui.weight.PageType
|
||||
import com.sw.inbound.ui.weight.ReceiptUnadjustedListView
|
||||
import com.sw.inbound.ui.weight.RowInputLayout
|
||||
import com.sw.inbound.ui.weight.TopTitleBar
|
||||
@@ -523,7 +524,8 @@ fun ReceiptRightView(modifier: Modifier = Modifier, viewModel: ReceiptViewModel)
|
||||
IdentityView(
|
||||
showSearchView = false,
|
||||
onOptionSelected = {},
|
||||
baseViewModel = viewModel
|
||||
baseViewModel = viewModel,
|
||||
pageType = PageType.RECEIPT_PRODUCT
|
||||
)
|
||||
} else {
|
||||
ReceiptProductEditView(viewModel)
|
||||
|
||||
@@ -66,6 +66,7 @@ import com.sw.inbound.ui.weight.CustomSpinner
|
||||
import com.sw.inbound.ui.weight.CustomTextField
|
||||
import com.sw.inbound.ui.weight.IdentityView
|
||||
import com.sw.inbound.ui.weight.InputType
|
||||
import com.sw.inbound.ui.weight.PageType
|
||||
import com.sw.inbound.ui.weight.RowInputLayout
|
||||
import com.sw.inbound.ui.weight.SelfProcurementListItem
|
||||
import com.sw.inbound.ui.weight.TopTitleBar
|
||||
@@ -179,9 +180,9 @@ private fun ContentView(
|
||||
private fun ContentLeftView(
|
||||
viewModel: SelfProcurementViewModel
|
||||
) {
|
||||
val warehouseList = GlobalData.warehouseTypeList // productViewModel.getStoreList()
|
||||
val warehouseList = GlobalData.warehouseTypeList
|
||||
val productList by viewModel.purchaseList.collectAsState()
|
||||
val globalWarehouseName by viewModel.globalWarehouse.collectAsState() // remember { mutableStateOf<String>("选择仓库") }
|
||||
val globalWarehouseName by viewModel.globalWarehouse.collectAsState()
|
||||
|
||||
Column(
|
||||
modifier = Modifier
|
||||
@@ -267,7 +268,11 @@ fun ProductIdentification(viewModel: SelfProcurementViewModel) {
|
||||
// 菜品识别
|
||||
IdentityView(showSearchView = true, onOptionSelected = {
|
||||
viewModel.updateSelectedItemWithSearch(it)
|
||||
}, checkedItem = selectedItem, baseViewModel = viewModel)
|
||||
},
|
||||
checkedItem = selectedItem,
|
||||
baseViewModel = viewModel,
|
||||
pageType = PageType.SELF_PROCUREMENT
|
||||
)
|
||||
}
|
||||
Spacer(modifier = Modifier.height(10.dp))
|
||||
Row(
|
||||
@@ -878,6 +883,8 @@ private fun SelfProductEditView(
|
||||
// ToastUtils.showToast("数量和金额不符,请检查后再试")
|
||||
// return@CustomButton
|
||||
// }
|
||||
viewModel.updateLastPhotoUri(null)
|
||||
viewModel.updateIdentityList(emptyList())
|
||||
viewModel.addPurchaseItem(selectedItem!!)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -32,6 +32,18 @@ import com.sw.inbound.utils.rememberPhotoCapture
|
||||
import com.sw.inbound.viewmodel.BaseViewModel
|
||||
import timber.log.Timber
|
||||
|
||||
enum class PageType {
|
||||
/**
|
||||
* 自采
|
||||
*/
|
||||
SELF_PROCUREMENT,
|
||||
|
||||
/**
|
||||
* 收货
|
||||
*/
|
||||
RECEIPT_PRODUCT
|
||||
}
|
||||
|
||||
/**
|
||||
* 菜品识别组件
|
||||
*/
|
||||
@@ -41,11 +53,13 @@ fun IdentityView(
|
||||
onOptionSelected: (SearchGoodsInfo.Record) -> Unit = {},
|
||||
checkedItem: PurchaseWarehouseParam? = null,
|
||||
baseViewModel: BaseViewModel,
|
||||
pageType: PageType
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val lifecycleOwner = LocalLifecycleOwner.current
|
||||
val weightInfo by baseViewModel.weightInfo.collectAsState()
|
||||
val identityList by baseViewModel.identityListItems.collectAsState()
|
||||
val receiptList by baseViewModel.receiptList.collectAsState()
|
||||
val searchList by baseViewModel.searchListItems.collectAsState()
|
||||
// var lastWeight by remember { mutableStateOf<Double?>(null) }
|
||||
var lastWeight by remember { mutableDoubleStateOf(0.0) }
|
||||
@@ -97,10 +111,12 @@ fun IdentityView(
|
||||
|
||||
LaunchedEffect(weightInfo) {
|
||||
Timber.d("LaunchedEffect weightInfo1 = $weightInfo, lastWeight = $lastWeight")
|
||||
if (weightInfo - lastWeight > 1) {
|
||||
Timber.d("weightInfo2 = $weightInfo")
|
||||
debouncer.debounce {
|
||||
takePhoto()
|
||||
if (weightInfo - lastWeight > 1.0) {
|
||||
Timber.d("LaunchedEffect pageType = $pageType, receiptList = ${receiptList.size}")
|
||||
if (pageType == PageType.RECEIPT_PRODUCT && receiptList.isNotEmpty() || pageType == PageType.SELF_PROCUREMENT) {
|
||||
debouncer.debounce {
|
||||
takePhoto()
|
||||
}
|
||||
}
|
||||
}
|
||||
lastWeight = weightInfo
|
||||
|
||||
@@ -40,6 +40,7 @@ abstract class BaseViewModel(
|
||||
|
||||
// 待收货的列表 用于识别时从中获取
|
||||
private val _receiptList = MutableStateFlow<List<SearchGoodsInfo.Record>>(emptyList())
|
||||
val receiptList: StateFlow<List<SearchGoodsInfo.Record>> = _receiptList
|
||||
|
||||
// 拍照uri
|
||||
private val _lastPhotoUri = MutableStateFlow<Uri?>(null)
|
||||
|
||||
Reference in New Issue
Block a user