CredentialPopup

This commit is contained in:
2026-04-03 10:44:35 +08:00
parent 8e1c9979a7
commit b9282a61e6
6 changed files with 227 additions and 27 deletions

View File

@@ -0,0 +1,155 @@
<template>
<view class="popup-mask" v-if="visible" @click.self="close('cancel')">
<view class="popup-container">
<!-- <view class="popup-title">请输入账号和密码</view>
<input class="filter_input" v-model="username" placeholder="账号" />
<input class="filter_input" v-model="password" type="password" placeholder="密码" /> -->
<view class="setup-item">
<view class="filter_label">账号</view>
<input type="text" class="setup-input" v-model="username">
</view>
<view class="setup-item">
<view class="filter_label">密码</view>
<input type="password" class="setup-input" v-model="password">
</view>
<view class="dialog-buttons">
<!-- <button @click="close('cancel')">取消</button>
<button @click="confirm">确定</button> -->
<button class="cancel-btn" @click="close('cancel')">取消</button>
<button class="confirm-btn" type="primary" @click="confirm">复核确认</button>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
visible: false,
username: '',
password: '',
resolvePromise: null,
rejectPromise: null
};
},
methods: {
// 显示弹窗,返回 Promise
show() {
this.visible = true;
this.username = '';
this.password = '';
return new Promise((resolve, reject) => {
this.resolvePromise = resolve;
this.rejectPromise = reject;
});
},
confirm() {
if (this.username && this.password) {
this.resolvePromise({ username: this.username, password: this.password });
this.close();
} else {
uni.showToast({ title: '请输入账号和密码', icon: 'none' });
}
},
close(type) {
this.visible = false;
if (type === 'cancel') {
this.rejectPromise(new Error('用户取消'));
}
this.resolvePromise = null;
this.rejectPromise = null;
}
}
};
</script>
<style lang="stylus" scoped>
@import '../common/style/mixin.styl';
.setup-item
width 100%
margin-bottom 18rpx
.setup-label
_font(24rpx,40rpx,#000)
.setup-input
_wh(100%, 80rpx)
background #fff
_font(28rpx,80rpx,#323232)
padding 0 28rpx
border 2px solid #e9ecf3
border-radius 12rpx
.popup-mask {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
z-index: 999;
}
.popup-container {
width: 80%;
background-color: #fff;
border-radius: 10px;
padding: 10px 20px 0px 20px;
}
.popup-title {
text-align: center;
font-size: 18px;
margin-bottom: 20px;
}
.popup-input {
border: 1px solid #ccc;
border-radius: 5px;
padding: 10px;
margin-bottom: 15px;
}
.popup-buttons {
display: flex;
justify-content: space-between;
}
/* 按钮区域 */
.dialog-buttons {
display: flex;
border-top: 1px solid #f0f0f0;
}
.dialog-buttons button {
flex: 1;
border-radius: 0;
height: 48px;
line-height: 48px;
font-size: 16px;
background: transparent;
border: none;
margin: 0;
}
.cancel-btn {
color: #666;
border-right: 1px solid #f0f0f0;
}
.cancel-btn::after {
border: none;
}
.confirm-btn {
color: #007aff;
font-weight: 500;
}
.confirm-btn::after {
border: none;
}
/* 分隔线样式 */
.button-divider {
width: 1px;
height: 24px;
background-color: #e5e5e5;
flex-shrink: 0;
}
</style>

View File

@@ -31,6 +31,10 @@ Vue.prototype.$getStatusText = function(statusMap, status) {
import store from '@/vuex/store.js'
// 全局注册账号密码输入框
import CredentialPopup from '@/components/CredentialPopup.vue';
Vue.component('CredentialPopup', CredentialPopup);
const app = new Vue({
...App,
store

View File

@@ -63,13 +63,16 @@
</view>
<view class="zd-row submit-bar">
<button class="zd-col-5 button-default" @tap="toEmpty">清空</button>
<button class="zd-col-18 button-primary" :class="{'button-info': !val1 || !dataList.length}" :disabled="disabled" @tap="_leftoverMaterialBack" v-if="!flag">回库</button>
<button class="zd-col-18 button-primary" :class="{'button-info': !val1 || !dataList.length}" :disabled="disabled" @tap="handleSubmit" v-if="!flag">回库</button>
<button class="zd-col-18 button-primary" :class="{'button-info': !val1}" :disabled="disabled" @tap="_leftoverMaterialBack" v-if="flag">空盘退回</button>
</view>
<!-- 放置弹窗组件 -->
<CredentialPopup ref="credentialPopup" />
</view>
</template>
<script>
import { RSAencrypt } from '@/utils/jsencrypt.js'
import NavBar from '@/components/NavBar.vue'
import SearchBox from '@/components/SearchBox.vue'
import {getGroupInfo, leftoverMaterialBack} from '@/utils/getData3.js'
@@ -92,6 +95,21 @@
this.title = options.title
},
methods: {
async handleSubmit() {
if (!this.val1 || !this.dataList.length) {
this.disabled = false
return
}
try {
// 显示弹窗,等待用户输入
const { username, password } = await this.$refs.credentialPopup.show();
// 调用原接口,传入账号密码
this._leftoverMaterialBack(username, password);
} catch (error) {
// 用户取消,不做处理
console.log('用户取消输入');
}
},
toEmpty () {
this.val1 = ''
this.num = null
@@ -123,14 +141,10 @@
this.dataList = []
}
},
async _leftoverMaterialBack () {
async _leftoverMaterialBack (username, password) {
this.disabled = true
if (!this.val1 || !this.dataList.length) {
this.disabled = false
return
}
try {
let res = await leftoverMaterialBack(this.val1, this.dataList)
let res = await leftoverMaterialBack(username, RSAencrypt(password), this.val1, this.dataList)
if (res) {
uni.showToast({
title: res.message,

View File

@@ -61,8 +61,10 @@
</view>
<view class="zd-row submit-bar">
<button class="zd-col-5 button-default" @tap="toEmpty">清空</button>
<button class="zd-col-18 button-primary" :class="{'button-info': !val1 || !index || !dataList.length}" :disabled="disabled" @tap="_packInConfirm">送入</button>
<button class="zd-col-18 button-primary" :class="{'button-info': !val1 || !index || !dataList.length}" :disabled="disabled" @tap="handleSubmit">送入</button>
</view>
<!-- 放置弹窗组件 -->
<CredentialPopup ref="credentialPopup" />
</view>
</template>
@@ -92,6 +94,21 @@
this._queryPointInDownload()
},
methods: {
async handleSubmit() {
if (!this.val1 || !this.index || !this.dataList.length) {
this.disabled = false
return
}
try {
// 显示弹窗,等待用户输入
const { username, password } = await this.$refs.credentialPopup.show();
// 调用原接口,传入账号密码
this._packInConfirm(username, password);
} catch (error) {
// 用户取消,不做处理
console.log('用户取消输入');
}
},
toEmpty () {
this.val1 = ''
this.num = null
@@ -133,15 +150,11 @@
this.dataList = []
}
},
async _packInConfirm () {
async _packInConfirm (username, password) {
this.disabled = true
if (!this.val1 || !this.index || !this.dataList.length) {
this.disabled = false
return
}
this.num = this.dataList.reduce((sum, item) => sum + Number(item.qty), 0)
try {
let res = await packInConfirm(this.val1, this.index, this.num, this.dataList)
let res = await packInConfirm(username, password, this.val1, this.index, this.num, this.dataList)
if (res) {
uni.showToast({
title: res.message,

View File

@@ -73,8 +73,10 @@
</view>
<view class="zd-row submit-bar">
<button class="zd-col-5 button-default" @tap="toEmpty">清空</button>
<button class="zd-col-18 button-primary" :class="{'button-info': !val1 || JSON.stringify(materialData) === '{}'}" :disabled="disabled" @tap="_packConfirmReturn">确认还回</button>
<button class="zd-col-18 button-primary" :class="{'button-info': !val1 || JSON.stringify(materialData) === '{}'}" :disabled="disabled" @tap="handleSubmit">确认还回</button>
</view>
<!-- 放置弹窗组件 -->
<CredentialPopup ref="credentialPopup" />
</view>
</template>
@@ -109,6 +111,21 @@
}
},
methods: {
async handleSubmit() {
if (!this.val1 || JSON.stringify(this.materialData) === '{}') {
this.disabled = false
return
}
try {
// 显示弹窗,等待用户输入
const { username, password } = await this.$refs.credentialPopup.show();
// 调用原接口,传入账号密码
this._packConfirmReturn(username, password);
} catch (error) {
// 用户取消,不做处理
console.log('用户取消输入');
}
},
toJump (name) {
uni.navigateTo({
url: `/pages/hdyy/wbc/${name}`
@@ -124,14 +141,10 @@
this.mark = ''
this.disabled = false
},
async _packConfirmReturn () {
async _packConfirmReturn (username, password) {
this.disabled = true
if (!this.val1 || JSON.stringify(this.materialData) === '{}') {
this.disabled = false
return
}
try {
let res = await packConfirmReturn(this.val1, this.materialData.material_id, this.materialData.material_code, this.materialData.material_name, this.pcsn, this.num, this.mark)
let res = await packConfirmReturn(username, password, this.val1, this.materialData.material_id, this.materialData.material_code, this.materialData.material_name, this.pcsn, this.num, this.mark)
if (res) {
uni.showToast({
title: res.message,

View File

@@ -1,4 +1,5 @@
import request from './request.js'
import { RSAencrypt } from '@/utils/jsencrypt.js'
// 项目hdyy
@@ -73,9 +74,9 @@ export const queryPointInDownload = () => request({
})
// 送入
export const packInConfirm = (pcode, icode, qty, rows) => request({
export const packInConfirm = (username, password, pcode, icode, qty, rows) => request({
url:'api/pda/packaging/packInConfirm',
data: {point_code: pcode, in_point_code: icode, total_qty: qty, rows: rows}
data: {username: username, password: RSAencrypt(password), point_code: pcode, in_point_code: icode, total_qty: qty, rows: rows}
})
/**
@@ -97,9 +98,9 @@ export const queryDrawConfirm = (pcode, qty, rows) => request({
* 外包材还回(外包材管理)
*/
// 确认还回
export const packConfirmReturn = (pcode, mid, mcode, mname, pcsn, qty, remark) => request({
export const packConfirmReturn = (username, password, pcode, mid, mcode, mname, pcsn, qty, remark) => request({
url:'api/pda/packaging/packConfirmReturn',
data: {point_code: pcode, material_id: mid, material_code: mcode, material_name: mname, pcsn: pcsn, qty: qty, remark: remark}
data: {username: username, password: RSAencrypt(password), point_code: pcode, material_id: mid, material_code: mcode, material_name: mname, pcsn: pcsn, qty: qty, remark: remark}
})
/**
@@ -301,9 +302,9 @@ export const getGroupInfo = (search) => request({
data: {search: search}
})
// 剩料回库
export const leftoverMaterialBack = (search, rows) => request({
export const leftoverMaterialBack = (username, password, search, rows) => request({
url:'api/pdaProduction/leftoverMaterialBack',
data: {search: search, rows: rows}
data: {username: username, password: password, search: search, rows: rows}
})
// 托盘叫料