@ -28,8 +28,8 @@
< view class = "multi-select" >
< view class = "multi-select" >
< view class = "selected-items" v-if ="selectedMaterials.length > 0" >
< view class = "selected-items" v-if ="selectedMaterials.length > 0" >
< view class = "selected-item" v-for ="(item, index) in selectedMaterials" :key="item.cargoId" >
< view class = "selected-item" v-for ="(item, index) in selectedMaterials" :key="item.cargoId" >
< text > { { item . cargoName } } ( { { item . cargoSpec } } ) < / text >
< text > { { item . cargoName } } ( { { item . cargoSpec } } ) x { { item . quantity } } < / text >
< text class = "remove-btn" @click ="removeMaterial(index)" > × < / text >
< text class = "remove-btn" @click ="removeMaterial(index)" > x < / text >
< / view >
< / view >
< / view >
< / view >
< view class = "select-btn" @click ="showMaterialSelector" >
< view class = "select-btn" @click ="showMaterialSelector" >
@ -82,18 +82,30 @@
class = "material-item"
class = "material-item"
v - for = "material in filteredMaterials"
v - for = "material in filteredMaterials"
: key = "material.cargoId"
: key = "material.cargoId"
@ click = "toggleMaterial(material)"
>
>
< view class = "material-info" >
< view class = "material-info" >
< text class = "material-name" > { { material . cargoName } } < / text >
< text class = "material-name" > { { material . cargoName } } < / text >
< text class = "material-spec" > { { material . cargoSpec } } < / text >
< text class = "material-spec" > { { material . cargoSpec } } < / text >
< / view >
< / view >
< view class = "checkbox" : class = "{ checked: isMaterialSelected(material.cargoId) }" >
< view class = "item-actions" >
< view v-if ="isMaterialSelected(material.cargoId)" class="quantity-input" >
< text class = "quantity-btn" @click ="decreaseQuantity(material.cargoId)" > - < / text >
< input
type = "number"
: value = "getMaterialQuantity(material.cargoId)"
class = "quantity-input-box"
min = "1"
@ input = "updateQuantity(material.cargoId, $event)"
/ >
< text class = "quantity-btn" @click ="increaseQuantity(material.cargoId)" > + < / text >
< / view >
< view class = "checkbox" : class = "{ checked: isMaterialSelected(material.cargoId) }" @click ="toggleMaterial(material)" >
< text v-if ="isMaterialSelected(material.cargoId)" > ✓ < / text >
< text v-if ="isMaterialSelected(material.cargoId)" > ✓ < / text >
< / view >
< / view >
< / view >
< / view >
< / view >
< / view >
< / view >
< / view >
< / view >
< view class = "popup-footer" >
< view class = "popup-footer" >
< view class = "footer-btn cancel" @click ="closeMaterialSelector" > 取 消 < / view >
< view class = "footer-btn cancel" @click ="closeMaterialSelector" > 取 消 < / view >
< view class = "footer-btn confirm" @click ="confirmMaterialSelection" > 确 定 < / view >
< view class = "footer-btn confirm" @click ="confirmMaterialSelection" > 确 定 < / view >
@ -113,7 +125,13 @@
< text class = "type" > 领用单 < / text >
< text class = "type" > 领用单 < / text >
< text
< text
class = "status"
class = "status"
: class = "getStatusClass(item)"
: class = " {
'status-pending' : getStatusText ( item ) === '待审批' ,
'status-approved' : getStatusText ( item ) === '已审批' ,
'status-rejected' : getStatusText ( item ) === '已拒绝' ,
'status-canceled' : getStatusText ( item ) === '已取消' ,
'status-verified' : getStatusText ( item ) === '已核销'
} "
>
>
{ { getStatusText ( item ) } }
{ { getStatusText ( item ) } }
< / text >
< / text >
@ -145,7 +163,7 @@
< text class = "label" > 领用物资 < / text >
< text class = "label" > 领用物资 < / text >
< text class = "value" >
< text class = "value" >
< text v-for ="(cargo, index) in item.ckBillCargos" :key="cargo.id" >
< text v-for ="(cargo, index) in item.ckBillCargos" :key="cargo.id" >
{ { cargo . cargoName } } ({ { cargo . cargo Spec } } ) { { index < item . ckBillCargos . length - 1 ? '、' : '' } }
{ { cargo . cargoName } } { { cargo .cargoSpec ? ` (${ cargo . cargoSpec } ) ` : '' } } { { cargo . cargo Wt ? ` x ${ parseFloat ( cargo . cargoWt ) . toFixed ( 2 ) . replace ( /\.?0+$/ , '' ) } ` : '' } } { { index < item . ckBillCargos . length - 1 ? '、' : '' } }
< / text >
< / text >
< / text >
< / text >
< / view >
< / view >
@ -153,8 +171,8 @@
< view class = "card-footer" >
< view class = "card-footer" >
< view class = "action-buttons" >
< view class = "action-buttons" >
< view class = "action-btn cancel-btn" v-if ="item.cancelStatus === '0' " @click="cancelBill(item.id)"> 取 消 单 据 < / view >
< view class = "action-btn cancel-btn" v-if ="item.cancelStatus === '0' && item.billStatus === '0' " @click="cancelBill(item.id)"> 取 消 单 据 < / view >
< view class = "action-btn voucher-btn" @click ="viewVoucher(item)"> 查 看 凭 证 < / view >
< view class = "action-btn voucher-btn" v-if="item.auditStatus === '1' && item.billStatus === '0'" @click="viewVoucher(item)"> 查 看 凭 证 < / view >
< / view >
< / view >
< / view >
< / view >
< / view >
< / view >
@ -173,7 +191,7 @@
< text class = "voucher-value" > { { currentVoucher ? currentVoucher . billNumber : '' } } < / text >
< text class = "voucher-value" > { { currentVoucher ? currentVoucher . billNumber : '' } } < / text >
< / view >
< / view >
< view class = "qrcode-container" >
< view class = "qrcode-container" >
< canvas canvas -id = " qrcode " : style = "{width: `${qrcodeSize}px`, height: `${qrcodeSize}px`}" style = "opacity: 0;" / >
< canvas canvas -id = " qrcode " : style = "{width: `${qrcodeSize}px`, height: `${qrcodeSize}px`}" / >
< / view >
< / view >
< / view >
< / view >
< view class = "voucher-footer" >
< view class = "voucher-footer" >
@ -201,6 +219,7 @@ export default {
'已审批' : 'status-approved' ,
'已审批' : 'status-approved' ,
'已拒绝' : 'status-rejected' ,
'已拒绝' : 'status-rejected' ,
'已取消' : 'status-canceled' ,
'已取消' : 'status-canceled' ,
'已核销' : 'status-verified' ,
'__default__' : 'status-pending'
'__default__' : 'status-pending'
} ,
} ,
materials : [ ] ,
materials : [ ] ,
@ -273,6 +292,33 @@ export default {
isMaterialSelected ( cargoId ) {
isMaterialSelected ( cargoId ) {
return this . tempSelectedMaterials . some ( item => item . cargoId === cargoId ) ;
return this . tempSelectedMaterials . some ( item => item . cargoId === cargoId ) ;
} ,
} ,
/ / 获 取 物 资 数 量
getMaterialQuantity ( cargoId ) {
const item = this . tempSelectedMaterials . find ( item => item . cargoId === cargoId ) ;
return item ? item . quantity : 1 ;
} ,
/ / 增 加 数 量
increaseQuantity ( cargoId ) {
const item = this . tempSelectedMaterials . find ( item => item . cargoId === cargoId ) ;
if ( item ) {
item . quantity += 1 ;
}
} ,
/ / 减 少 数 量
decreaseQuantity ( cargoId ) {
const item = this . tempSelectedMaterials . find ( item => item . cargoId === cargoId ) ;
if ( item && item . quantity > 1 ) {
item . quantity -= 1 ;
}
} ,
/ / 更 新 数 量
updateQuantity ( cargoId , event ) {
const item = this . tempSelectedMaterials . find ( item => item . cargoId === cargoId ) ;
if ( item ) {
const value = parseInt ( event . target . value ) || 1 ;
item . quantity = Math . max ( 1 , value ) ;
}
} ,
/ / 确 认 物 资 选 择
/ / 确 认 物 资 选 择
confirmMaterialSelection ( ) {
confirmMaterialSelection ( ) {
this . selectedMaterials = [ ... this . tempSelectedMaterials ] ;
this . selectedMaterials = [ ... this . tempSelectedMaterials ] ;
@ -283,7 +329,7 @@ export default {
this . selectedMaterials . splice ( index , 1 ) ;
this . selectedMaterials . splice ( index , 1 ) ;
} ,
} ,
submitReceipt ( ) {
submitReceipt ( ) {
if ( this . selectedMaterials . length === 0 || ! this . receiptForm . purpose || ! this . receiptForm . applicant ) {
if ( this . selectedMaterials . length === 0 || ! this . receiptForm . purpose ) {
uni . showToast ( {
uni . showToast ( {
title : '请填写完整信息' ,
title : '请填写完整信息' ,
icon : 'none'
icon : 'none'
@ -294,16 +340,24 @@ export default {
/ / 准 备 提 交 数 据
/ / 准 备 提 交 数 据
const items = this . selectedMaterials . map ( item => ( {
const items = this . selectedMaterials . map ( item => ( {
cargoId : item . cargoId ,
cargoId : item . cargoId ,
quantity : item . quantity
quantity : item . quantity ,
billNumber : item . billNumber ,
stockId : item . stockId ,
stockCode : item . stockCode ,
ckCargoStockId : item . id ,
} ) ) ;
} ) ) ;
const submitData = {
const submitData = {
purpose : this . receiptForm . purpose ,
purpose : this . receiptForm . purpose ,
items : items
items : items
} ;
} ;
uni . showLoading ( {
title : '提交中...'
} ) ;
/ / 调 用 接 口 提 交 领 用 申 请
/ / 调 用 接 口 提 交 领 用 申 请
quickOutBill ( submitData ) . then ( res => {
quickOutBill ( submitData ) . then ( res => {
uni . hideLoading ( ) ;
if ( res . code === 200 ) {
if ( res . code === 200 ) {
uni . showToast ( {
uni . showToast ( {
title : '领用申请提交成功' ,
title : '领用申请提交成功' ,
@ -330,10 +384,15 @@ export default {
icon : 'none'
icon : 'none'
} ) ;
} ) ;
}
}
} ) . catch ( ( ) => {
uni . hideLoading ( ) ;
} ) ;
} ) ;
} ,
} ,
/ / 获 取 状 态 文 本
/ / 获 取 状 态 文 本
getStatusText ( item ) {
getStatusText ( item ) {
if ( item . billStatus === '1' ) {
return '已核销' ;
}
if ( item . cancelStatus === '1' ) {
if ( item . cancelStatus === '1' ) {
return '已取消' ;
return '已取消' ;
}
}
@ -395,16 +454,23 @@ export default {
} ,
} ,
/ / 生 成 二 维 码
/ / 生 成 二 维 码
generateQRCode ( billNumber ) {
generateQRCode ( billNumber ) {
console . log ( '开始生成二维码' ) ;
uQRCode . make ( {
uQRCode . make ( {
canvasId : 'qrcode' ,
canvasId : 'qrcode' ,
text : billNumber ,
text : billNumber ,
size : this . qrcodeSize ,
size : this . qrcodeSize ,
margin : 10 ,
margin : 10 ,
success : res => {
success : res => {
console . log ( res ) ;
} ,
} ,
complete : ( ) => {
complete : ( ) => {
} ,
} ,
fail : res => {
fail : res => {
console . log ( res ) ;
uni . showToast ( {
title : '二维码生成失败' ,
icon : 'none'
} ) ;
}
}
} ) ;
} ) ;
} ,
} ,
@ -418,6 +484,8 @@ export default {
} else {
} else {
this . $refs . paging . complete ( [ ] ) ;
this . $refs . paging . complete ( [ ] ) ;
}
}
} ) . catch ( e => {
this . $refs . paging . complete ( false ) ;
} ) ;
} ) ;
} ,
} ,
refreshList ( ) {
refreshList ( ) {
@ -625,6 +693,11 @@ export default {
background - color : # F5F5F5 ;
background - color : # F5F5F5 ;
color : # 999 ;
color : # 999 ;
}
}
. status - verified {
background - color : # E8F5E8 ;
color : # 4 CAF50 ;
}
}
}
. header - right {
. header - right {
@ -750,7 +823,6 @@ export default {
justify - content : space - between ;
justify - content : space - between ;
padding : 24 rpx 30 rpx ;
padding : 24 rpx 30 rpx ;
border - bottom : 1 rpx solid # f0f0f0 ;
border - bottom : 1 rpx solid # f0f0f0 ;
cursor : pointer ;
. material - info {
. material - info {
flex : 1 ;
flex : 1 ;
@ -768,6 +840,38 @@ export default {
}
}
}
}
. item - actions {
display : flex ;
align - items : center ;
gap : 20 rpx ;
. quantity - input {
display : flex ;
align - items : center ;
border : 1 rpx solid # e5e5e5 ;
border - radius : 8 rpx ;
. quantity - btn {
width : 40 rpx ;
height : 40 rpx ;
display : flex ;
align - items : center ;
justify - content : center ;
font - size : 24 rpx ;
color : # 666 ;
background - color : # f5f5f5 ;
}
. quantity - input - box {
width : 80 rpx ;
height : 40 rpx ;
border : none ;
text - align : center ;
font - size : 22 rpx ;
color : # 333 ;
}
}
. checkbox {
. checkbox {
width : 36 rpx ;
width : 36 rpx ;
height : 36 rpx ;
height : 36 rpx ;
@ -778,6 +882,7 @@ export default {
justify - content : center ;
justify - content : center ;
font - size : 24 rpx ;
font - size : 24 rpx ;
color : # fff ;
color : # fff ;
cursor : pointer ;
& . checked {
& . checked {
background - color : # 409 EFF ;
background - color : # 409 EFF ;
@ -787,6 +892,7 @@ export default {
}
}
}
}
}
}
}
. popup - footer {
. popup - footer {
display : flex ;
display : flex ;
@ -819,7 +925,7 @@ export default {
/* 凭证弹窗样式 */
/* 凭证弹窗样式 */
. voucher - popup {
. voucher - popup {
width : 80% ;
width : 680rpx ;
background - color : # fff ;
background - color : # fff ;
border - radius : 20 rpx ;
border - radius : 20 rpx ;
overflow : hidden ;
overflow : hidden ;