123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- <template>
- <view class="home">
- <view class="device-info">
- <i class="iconfont icon-shebei"></i>设备信息
- </view>
- <view class="info-area">
- <u--form
- labelPosition="left"
- :model="model1"
- ref="form1"
- :labelWidth="100"
- labelAlign="center"
- >
- <u-form-item
- label="设备名称"
- prop="deviceName"
- borderBottom
- ref="item1"
- >
- {{model1.deviceName}}
- </u-form-item>
- <u-form-item
- label="设备编码"
- prop="deviceNumber"
- borderBottom
- ref="item2"
- >
- {{model1.deviceNumber}}
- </u-form-item>
- </u--form>
- </view>
- <view class="type-head">
- <i class="iconfont icon-dingwei"></i>请填写故障现象
- </view>
- <view class="type-area">
- <u--textarea
- border="none"
- v-model="fault"
- placeholder="请输入故障现象"
- height='80'
- maxlength="-1"></u--textarea>
- </view>
- <view class="btn-area">
- <u-button color="#67C23A" size="small" @click="toReportFault">上报</u-button>
- </view>
- <u-toast ref="uToast"></u-toast>
- </view>
- </template>
- <script>
- import { searchAsset,reportFault } from "@/api/asset.js"
- import cache from '@/utils/storage.js'
- export default {
- data() {
- return {
- model1: {
- deviceName: '',
- deviceNumber: '',
- },
- fault:"",
- id:""
- };
- },
- methods:{
- initAssets(data,str){
- uni.showLoading({
- title:str,
- mask:true,
- icon:'none'
- })
- searchAsset({barCode: data}).then(res=>{
- if(res.barCode===null){
- this.model1.deviceName = ""
- this.model1.deviceNumber = this.id
- this.$refs.uToast.show({
- type: 'error',
- icon: false,
- message: "该设备不存在,即将返回上一页",
- duration:1500
- })
- setTimeout(()=>{
- uni.navigateBack({
- delta:1
- })
- },1000)
- }else if(res.status==="0" || res.status==="2"){
- this.$refs.uToast.show({
- type: 'error',
- icon: false,
- message: "该设备已经上报故障,即将返回上一页",
- duration:1500
- })
- setTimeout(()=>{
- uni.navigateBack({
- delta:1
- })
- },1000)
- }else{
- this.model1.deviceName = res.name
- this.model1.deviceNumber = res.barCode
- }
- uni.hideLoading()
- })
- },
- toReportFault(){
- uni.showLoading({
- title: "正在上报中",
- mask: true,
- icon:'none'
- });
- let data = {
- "assetBarCode": this.model1.deviceNumber,
- "faultPhenomenon": this.fault,
- "tel": cache.session.getJSON('phone')
- }
- reportFault(data).then(res=>{
- uni.hideLoading()
- if(res.faultPhenomenon!==""){
- uni.showModal({
- title: '系统提示',
- content: '故障上报成功,是否返回上一页',
- showCancel:false,
- success: function (resp) {
- if (resp.confirm) {
- uni.navigateBack({
- delta:1
- })
- } else if (resp.cancel) {
- return;
- }
- }
- });
- }
-
- })
- }
- },
- onLoad(option) {
- this.id = option.id
- this.initAssets(option.id,'正在加载中')
- }
- }
- </script>
- <style lang="scss">
- page{
- background-color: #f5f6fa;
- }
- .home{
- // padding: 20rpx 0;
- }
- .device-info,.type-head{
- display: flex;
- align-items: center;
- padding:20rpx;
- .iconfont{
- font-size: 40rpx;
- margin-right: 10rpx;
- }
- }
- .info-area,.type-area{
- background-color: #fff;
- }
- .type-area{
- padding: 0 20rpx;
- }
- .btn-area{
- // padding: 20rpx 20rpx 20rpx 500rpx;
- margin-top: 120rpx;
- padding: 0 250rpx;
- }
- </style>
|