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