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