fault-report.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <view class="home">
  3. <view class="device-info">
  4. <i class="iconfont icon-shebei"></i>设备信息
  5. </view>
  6. <view class="info-area">
  7. <u--form
  8. labelPosition="left"
  9. :model="model1"
  10. ref="form1"
  11. :labelWidth="100"
  12. labelAlign="center"
  13. >
  14. <u-form-item
  15. label="设备名称"
  16. prop="deviceName"
  17. borderBottom
  18. ref="item1"
  19. >
  20. {{model1.deviceName}}
  21. </u-form-item>
  22. <u-form-item
  23. label="设备编码"
  24. prop="deviceNumber"
  25. borderBottom
  26. ref="item2"
  27. >
  28. {{model1.deviceNumber}}
  29. </u-form-item>
  30. </u--form>
  31. </view>
  32. <view class="type-head">
  33. <i class="iconfont icon-dingwei"></i>请填写故障现象
  34. </view>
  35. <view class="type-area">
  36. <u--textarea
  37. border="none"
  38. v-model="fault"
  39. placeholder="请输入故障现象"
  40. height='80'
  41. maxlength="-1"></u--textarea>
  42. </view>
  43. <view class="btn-area">
  44. <u-button color="#67C23A" size="small" @click="toReportFault">上报</u-button>
  45. </view>
  46. <u-toast ref="uToast"></u-toast>
  47. </view>
  48. </template>
  49. <script>
  50. import { searchAsset,reportFault } from "@/api/asset.js"
  51. import cache from '@/utils/storage.js'
  52. export default {
  53. data() {
  54. return {
  55. model1: {
  56. deviceName: '',
  57. deviceNumber: '',
  58. },
  59. fault:"",
  60. id:""
  61. };
  62. },
  63. methods:{
  64. initAssets(data,str){
  65. uni.showLoading({
  66. title:str,
  67. mask:true,
  68. icon:'none'
  69. })
  70. searchAsset({barCode: data}).then(res=>{
  71. if(res.barCode===null){
  72. this.model1.deviceName = ""
  73. this.model1.deviceNumber = this.id
  74. this.$refs.uToast.show({
  75. type: 'error',
  76. icon: false,
  77. message: "该设备不存在,即将返回上一页",
  78. duration:1500
  79. })
  80. setTimeout(()=>{
  81. uni.navigateBack({
  82. delta:1
  83. })
  84. },1000)
  85. }else if(res.status==="0" || res.status==="2"){
  86. this.$refs.uToast.show({
  87. type: 'error',
  88. icon: false,
  89. message: "该设备已经上报故障,即将返回上一页",
  90. duration:1500
  91. })
  92. setTimeout(()=>{
  93. uni.navigateBack({
  94. delta:1
  95. })
  96. },1000)
  97. }else{
  98. this.model1.deviceName = res.name
  99. this.model1.deviceNumber = res.barCode
  100. }
  101. uni.hideLoading()
  102. })
  103. },
  104. toReportFault(){
  105. uni.showLoading({
  106. title: "正在上报中",
  107. mask: true,
  108. icon:'none'
  109. });
  110. let data = {
  111. "assetBarCode": this.model1.deviceNumber,
  112. "faultPhenomenon": this.fault,
  113. "tel": cache.session.getJSON('phone')
  114. }
  115. reportFault(data).then(res=>{
  116. uni.hideLoading()
  117. if(res.faultPhenomenon!==""){
  118. uni.showModal({
  119. title: '系统提示',
  120. content: '故障上报成功,是否返回上一页',
  121. showCancel:false,
  122. success: function (resp) {
  123. if (resp.confirm) {
  124. uni.navigateBack({
  125. delta:1
  126. })
  127. } else if (resp.cancel) {
  128. return;
  129. }
  130. }
  131. });
  132. }
  133. })
  134. }
  135. },
  136. onLoad(option) {
  137. this.id = option.id
  138. this.initAssets(option.id,'正在加载中')
  139. }
  140. }
  141. </script>
  142. <style lang="scss">
  143. page{
  144. background-color: #f5f6fa;
  145. }
  146. .home{
  147. // padding: 20rpx 0;
  148. }
  149. .device-info,.type-head{
  150. display: flex;
  151. align-items: center;
  152. padding:20rpx;
  153. .iconfont{
  154. font-size: 40rpx;
  155. margin-right: 10rpx;
  156. }
  157. }
  158. .info-area,.type-area{
  159. background-color: #fff;
  160. }
  161. .type-area{
  162. padding: 0 20rpx;
  163. }
  164. .btn-area{
  165. // padding: 20rpx 20rpx 20rpx 500rpx;
  166. margin-top: 120rpx;
  167. padding: 0 250rpx;
  168. }
  169. </style>