This commit is contained in:
Aiden 2024-10-15 16:45:54 +08:00
parent 59e59bd37e
commit bea133759f
2 changed files with 51 additions and 54 deletions

View File

@ -5,42 +5,25 @@
<span style="font-weight: bold"> 已扫画筒号{{ state.pid }} </span> <span style="font-weight: bold"> 已扫画筒号{{ state.pid }} </span>
<span style="margin-top: 40rpx"> 请放入 </span> <span style="margin-top: 40rpx"> 请放入 </span>
<view class="painting-box"> <view class="painting-box">
<span style="font-weight: bold; text-align: center" <span style="font-weight: bold; text-align: center">{{ state.containerName }}货架</span>
>{{ state.containerName }}货架</span
>
<up-line style="margin-top: 20rpx"></up-line> <up-line style="margin-top: 20rpx"></up-line>
<span <span style="
style="
color: #cf3050; color: #cf3050;
font-size: 24px; font-size: 24px;
text-align: center; text-align: center;
margin-top: 20rpx; margin-top: 20rpx;
" ">
> {{ state.boxName }}
{{state.boxName}}
</span> </span>
<span style="text-align: center; margin-top: 20rpx"> {{state.column}}{{state.row}} </span> <span style="text-align: center; margin-top: 20rpx"> {{ state.column }}{{ state.row }} </span>
</view> </view>
</view> </view>
</view> </view>
<view class="button-container"> <view class="button-container">
<up-button <up-button style="width: 336rpx; margin: auto; height: 80rpx" color="#BABABA" throttleTime="5"
style="width: 336rpx; margin: auto; height: 80rpx" disabled="isButtonDisabled" @click="closeFn" v-if="runTimeEnv()">取消</up-button>
color="#BABABA" <up-button style="width: 336rpx; margin: auto; height: 80rpx" color="#EFC54E" throttleTime="5" @click="doneSet"
throttleTime="5" disabled="closeButton" :loading="loading">{{ buttonText }}</up-button>
disabled="isButtonDisabled"
@click="closeFn"
>取消</up-button
>
<up-button
style="width: 336rpx; margin: auto; height: 80rpx"
color="#EFC54E"
throttleTime="5"
@click="doneSet"
disabled="closeButton"
:loading="loading"
>{{ buttonText }}</up-button
>
</view> </view>
</template> </template>
@ -48,7 +31,8 @@
import { ref, reactive, onBeforeMount } from "vue"; import { ref, reactive, onBeforeMount } from "vue";
import useToast from "@/hooks/toast/useToast.js"; import useToast from "@/hooks/toast/useToast.js";
import { onLoad } from "@dcloudio/uni-app"; import { onLoad } from "@dcloudio/uni-app";
import { freebox,bind,check_freebox,cancel} from "@/api/login.js"; import { freebox, bind, check_freebox, cancel } from "@/api/login.js";
import { closeWebview, runTimeEnv } from "@/utils/index.js"
const { showMessage } = useToast(); const { showMessage } = useToast();
const loading = ref(false); const loading = ref(false);
const isButtonDisabled = ref(false); const isButtonDisabled = ref(false);
@ -58,9 +42,9 @@ const state = reactive({
id: "", id: "",
pid: "", pid: "",
containerName: "", containerName: "",
boxName:"", boxName: "",
boxUid:"", boxUid: "",
containerUid:'', containerUid: '',
}); });
onLoad((options) => { onLoad((options) => {
@ -75,8 +59,8 @@ const bindShelfHole = async () => {
if (res.status === 0) { if (res.status === 0) {
state.containerName = res.data.containerName; state.containerName = res.data.containerName;
state.boxName = res.data.boxName; state.boxName = res.data.boxName;
state.containerUid=res.data.containerUid; state.containerUid = res.data.containerUid;
state.boxUid=res.data.boxUid; state.boxUid = res.data.boxUid;
check() check()
if (state.boxName) { if (state.boxName) {
const parts = state.boxName.split(/(\d+)/); const parts = state.boxName.split(/(\d+)/);
@ -93,41 +77,45 @@ const doneSet = async () => {
const res = await bind({ const res = await bind({
paintingBucketId: state.id, paintingBucketId: state.id,
paintingBucketUid: state.pid, paintingBucketUid: state.pid,
boxUid:state.boxUid, boxUid: state.boxUid,
containerUid:state.containerUid, containerUid: state.containerUid,
containerName:state.containerName, containerName: state.containerName,
boxName:state.boxName, boxName: state.boxName,
}); });
if (res.status === 0) { if (res.status === 0) {
showMessage({ type: "sucess", message: "入库成功" }); showMessage({ type: "sucess", message: "入库成功" });
isButtonDisabled.value = true; isButtonDisabled.value = true;
buttonText.value = "已入库"; buttonText.value = "已入库";
}else{ } else {
showMessage({ type: "error", message: res.msg }); showMessage({ type: "error", message: res.msg });
} }
loading.value = false; loading.value = false;
}; };
// //
const closeFn = async () => { const closeFn = async () => {
const res = await cancel({ const res = await cancel({
boxUid : state.boxUid boxUid: state.boxUid
}); });
if(res.status === 0){ if (res.status === 0) {
}else{ // console.log(123123123, runTimeEnv())
showMessage({ type: "error", message: res.msg }); // if (runTimeEnv()) {
isButtonDisabled.value = true; // closeWebview()
closeButton.value = true; // }
} } else {
showMessage({ type: "error", message: res.msg });
isButtonDisabled.value = true;
closeButton.value = true;
}
} }
// //
const check = async () => { const check = async () => {
const res = await check_freebox({ const res = await check_freebox({
boxUid : state.boxUid boxUid: state.boxUid
}); });
if(res.status === 0){ if (res.status === 0) {
}else{ } else {
showMessage({ type: "error", message: res.msg }); showMessage({ type: "error", message: res.msg });
} }
} }
</script> </script>
@ -169,6 +157,7 @@ page {
box-shadow: 0 0 6px rgba(219, 218, 218, 0.5); box-shadow: 0 0 6px rgba(219, 218, 218, 0.5);
} }
} }
.button-container { .button-container {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;

8
utils/index.js Normal file
View File

@ -0,0 +1,8 @@
const currentWebView = plus.webview.getWebviewById("wv");
export const runTimeEnv = () => {
return currentWebView.RunTime === "app";
};
export const closeWebview = () => {
currentWebView.close();
};