<!-- 资产借用 -->
|
<template>
|
<view>
|
<view class="">
|
<cu-custom bgColor="bg-gradual-blue" :isBack="true">
|
<block slot="backText">返回</block>
|
<block slot="content">资产借用</block>
|
</cu-custom>
|
</view>
|
<view class="">
|
<view class="cu-bar bg-white solid-bottom ">
|
<view class="action">
|
<text class="cuIcon-title text-orange"></text> 可借用资产列表
|
</view>
|
</view>
|
|
<view class="" v-if="listFlag">
|
<u-empty mode="list" icon="http://cdn.uviewui.com/uview/empty/list.png">
|
</u-empty>
|
</view>
|
|
<view class="cu-list menu-avatar">
|
<view class="cu-item" v-for="(item,index) in assetsList" :key="index">
|
<view class="cu-avatar radius lg bg-white" style="background-image:url(../../static/device.png)">
|
</view>
|
<view class="content">
|
<view>
|
<view class="text-cut text-bold text-xl">{{item.name}}</view>
|
<view class="cu-tag radius bg-orange sm">可借用:{{item.quantity}}</view>
|
<view class="numbox">
|
<u-number-box v-model="valueList[index]" :min="0" :max="item.quantity"
|
:showMinus="valueList[index] > 0">
|
<view slot="minus" class="minus">
|
<u-icon name="minus" size="12"></u-icon>
|
</view>
|
<input slot="input" style="width: 38px;text-align: center; " class="input"
|
:value="valueList[index]?valueList[index]:0"></input>
|
<view slot="plus" class="plus">
|
<u-icon name="plus" color="#FFFFFF" size="12"></u-icon>
|
</view>
|
</u-number-box>
|
</view>
|
</view>
|
<view class="text-gray text-sm flex">
|
<view class="text-cut">规格:{{item.model?item.model:'无'}} 编码:{{item.serialNumber}}</view>
|
</view>
|
</view>
|
<!-- <view class="action"> -->
|
<!-- <view class="text-grey text-xs">22:20</view> -->
|
<!-- <view class="cu-tag round bg-red sm">删除</view> -->
|
<!-- </view> -->
|
</view>
|
|
</view>
|
|
|
<!-- 申请理由 -->
|
<view class="margin-top">
|
<view class="margin-left border-title">
|
申请理由
|
</view>
|
<view class="flex justify-center align-center" style="margin-top: 10rpx;">
|
<view class="" style="width: 95%; ">
|
<u--textarea v-model="reason" placeholder="请输入内容" placeholderStyle="font-size: 15rpx;">
|
</u--textarea>
|
</view>
|
|
</view>
|
</view>
|
|
<view class="padding-left padding-top border-title " style="padding-bottom: 10rpx;">
|
<view class="action">
|
申请人信息
|
</view>
|
</view>
|
<view class="flex justify-center">
|
<view class="u-border radius" style="width: 95%; padding:20rpx 0 20rpx 20rpx;">
|
<view class="">
|
申请人: {{applicant}}
|
</view>
|
<view class="" style="margin-top: 5rpx;">
|
职务: {{jobTitle}}
|
</view>
|
<view class="" style="margin-top: 5rpx;">
|
申请单位: {{applicationUnit}}
|
</view>
|
<view class="" style="margin-top: 5rpx;">
|
申请时间: {{applicationTime}}
|
</view>
|
</view>
|
</view>
|
|
</view>
|
|
|
<view class="margin-top">
|
<u-button style="width: 40%;" type="primary" text="提交申请" @click="submit" :disabled="isDisabled"></u-button>
|
</view>
|
|
<u-toast ref="uToast"></u-toast>
|
</view>
|
</template>
|
|
<script>
|
export default {
|
data() {
|
return {
|
value: 0,
|
reason: '',
|
assetsList: [],
|
listFlag: false,
|
valueList: [],
|
applicant: "", //申请人
|
jobTitle: "", //职务
|
applicationUnit: '', //申请单位
|
applicationTime: '', //申请时间
|
templateId: '', //模板ID
|
isDisabled: false
|
}
|
},
|
onShow() {
|
console.log(this.$dayjs().format("YYYY-MM-DD"));
|
this.initUseListData();
|
this.initTemplateData();
|
},
|
methods: {
|
valChange(e) {
|
console.log('当前值为: ' + e.value)
|
},
|
//获取可领用设备
|
initUseListData() {
|
this.$http.get('/assets/approval/search', {
|
params: {
|
pageNum: "1",
|
pageSize: "3",
|
keyStr: '',
|
state: "2"
|
}
|
})
|
|
.then(res => {
|
// debugger;
|
if (res.data.code === 0) {
|
let data = res.data.rows;
|
this.assetsList = data;
|
// console.log(JSON.stringify(data.data))
|
// let tt = data.data;
|
console.log(data.length)
|
} else {
|
this.listFlag = true;
|
}
|
|
|
}).catch(err => {
|
this.listFlag = true;
|
console.log(err.data)
|
})
|
},
|
|
//获取领用的模板
|
initTemplateData() {
|
this.$http.get('/assets/approval/getTemplate')
|
.then(res => {
|
// debugger;
|
|
if (res.data.code === 0) {
|
let data = res.data.data;
|
|
console.log(data.length)
|
|
//获取借用的模板ID
|
for (let i = 0; i < data.length; i++) {
|
if (data[i].type === 2) {
|
this.templateId = data[i].templateId;
|
break;
|
}
|
}
|
}
|
|
|
|
}).catch(err => {
|
|
console.log(err.data)
|
})
|
},
|
|
submit() {
|
this.isDisabled = true;
|
if (this.reason.length <= 0) {
|
this.isDisabled = false;
|
this.$refs.uToast.show({
|
type: 'error',
|
message: "请填写申请理由"
|
});
|
return;
|
}
|
if (this.valueList.length <= 0) {
|
this.isDisabled = false;
|
this.$refs.uToast.show({
|
type: 'error',
|
message: "请选择一个或多个借用资产!"
|
});
|
|
return;
|
}
|
|
this.submitApply();
|
},
|
|
submitApply() {
|
let assets = [];
|
for (let i = 0; i < this.valueList.length; i++) {
|
if (this.valueList[i] > 0) {
|
let item = this.assetsList[i];
|
assets.push({
|
"id": item.id,
|
"name": item.name,
|
"serialNumber": item.serialNumber,
|
"quantity": this.valueList[i]
|
})
|
}
|
}
|
|
console.log(assets);
|
let data = {
|
"assets": assets,
|
"templateId": this.templateId,
|
"reason": this.reason
|
}
|
|
this.$http.post('/assets/approval/submit', data)
|
.then(res => {
|
debugger;
|
if (res.data.code === 0) {
|
console.log("成功了")
|
this.$refs.uToast.show({
|
type: 'success',
|
message: "提交成功"
|
});
|
} else {
|
this.$refs.uToast.show({
|
type: 'error',
|
message: res.data.msg
|
});
|
}
|
this.isDisabled = false;
|
|
}).catch(err => {
|
this.isDisabled = false;
|
console.log(err.data)
|
})
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss">
|
.numbox {
|
margin-left: 20rpx;
|
}
|
|
.minus {
|
|
width: 15px;
|
height: 15px;
|
border-width: 1px;
|
border-color: #E6E6E6;
|
border-top-left-radius: 50px;
|
border-top-right-radius: 50px;
|
border-bottom-left-radius: 50px;
|
border-bottom-right-radius: 50px;
|
@include flex;
|
justify-content: center;
|
align-items: center;
|
}
|
|
.input {
|
padding: 0 5px;
|
}
|
|
.plus {
|
width: 15px;
|
height: 15px;
|
background-color: #53C21D; //#FF0000;
|
border-radius: 50%;
|
/* #ifndef APP-NVUE */
|
display: flex;
|
/* #endif */
|
justify-content: center;
|
align-items: center;
|
}
|
</style>
|