unusualDeal.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <view class="content">
  3. <view class="topbar" v-show="isIphone">
  4. </view>
  5. <view class="status_bar">
  6. <view class="left" @click="goBack"><u-icon name="arrow-left"></u-icon>返回</view>
  7. <span style="font-size: 36rpx;">异常处理</span>
  8. <view class="right"></view>
  9. </view>
  10. <view class="mainCont">
  11. <view class="title">
  12. {{ info.packCode }}
  13. <span style="float: right; color: #bcbcbc" v-show="info.packState == '4'">已完成</span>
  14. <span style="float: right; color: #2D8CF0" v-show="info.packState == '3'">待验收</span>
  15. </view>
  16. <u-cell-group style="margin-bottom: 10px">
  17. <u-cell-item :arrow="false" :value-style="{textAlign: 'left',paddingLeft: '10px'}">
  18. <view slot="title"><span class="red"></span>科&emsp;&emsp;室:</view>
  19. {{ info.positionName }}
  20. </u-cell-item>
  21. </u-cell-group>
  22. <u-cell-group style="margin-bottom: 10px">
  23. <u-cell-item :arrow="false" :value-style="{textAlign: 'left',paddingLeft: '10px'}">
  24. <view slot="title"><span class="red"></span>分&emsp;&emsp;类:</view>
  25. {{ info.rubbishCategoryStr }}
  26. </u-cell-item>
  27. <u-cell-item :arrow="false" :value-style="{textAlign: 'left',paddingLeft: '10px'}">
  28. <view slot="title"><span class="red"></span>重&emsp;&emsp;量:</view>
  29. {{ info.packWeight }}kg
  30. </u-cell-item>
  31. <u-cell-item :arrow="false" :value-style="{textAlign: 'left',paddingLeft: '10px'}">
  32. <view slot="title"><span class="red"></span>打&ensp;包&ensp;人:</view>
  33. {{ info.createUserName }}
  34. </u-cell-item>
  35. <u-cell-item :arrow="false" :value-style="{textAlign: 'left',paddingLeft: '10px'}">
  36. <view slot="title"><span class="red"></span>打包时间:</view>
  37. {{ info.createTime }}
  38. </u-cell-item>
  39. <u-cell-item :arrow="false" :value-style="{textAlign: 'left',paddingLeft: '10px'}">
  40. <view slot="title"><span class="red"></span>暂&ensp;存&ensp;点:</view>
  41. {{ info.provisionalName }}
  42. </u-cell-item>
  43. </u-cell-group>
  44. <view class="imgupload">
  45. <view>{{ info.packRemake }}</view>
  46. <view class="imgbox">
  47. <img v-for="(item,index) in fileList" :src="item.filePath" alt="">
  48. </view>
  49. </view>
  50. <u-cell-group style="margin-bottom: 10px">
  51. <u-cell-item :arrow="false" :value-style="{textAlign: 'left',paddingLeft: '10px'}">
  52. <view slot="title"><span class="red"></span>收&ensp;集&ensp;人:</view>
  53. 顾一野
  54. </u-cell-item>
  55. <u-cell-item :arrow="false" :value-style="{textAlign: 'left',paddingLeft: '10px'}">
  56. <view slot="title"><span class="red"></span>收集时间:</view>
  57. 2021-05-18 12:23:09
  58. </u-cell-item>
  59. </u-cell-group>
  60. <view class="imgupload">
  61. <u-input v-model="remark" placeholder="请描述异常内容" auto-height type="textarea" />
  62. <u-upload :show-progress="false" ref="upload" @on-remove="uploadRemove" @on-success="uploadSuccess"
  63. :header="uploadHeader" max-count="3" width="80px" height="80px" :custom-btn="true" :action="action"
  64. :file-list="filesList">
  65. <view slot="addBtn" class="slot-btn">
  66. <image style="width: 80px;height: 80px" src="/static/tjzp.png" alt="">
  67. </view>
  68. </u-upload>
  69. </view>
  70. </view>
  71. <view class="bottomButton" @click="unusualDo">
  72. <view>提交</view>
  73. </view>
  74. <u-toast ref="uToast" />
  75. </view>
  76. </template>
  77. <script>
  78. const NET = require('@/utils/request')
  79. const API = require('@/config/api')
  80. export default {
  81. data() {
  82. return {
  83. id: "",
  84. remark: "",
  85. action: API.uploadFile,
  86. info: {},
  87. fileList: [],
  88. filesList: [],
  89. isIphone: false,
  90. imgList: [],
  91. uploadHeader: {
  92. Authorization: 'Bearer ' + uni.getStorageSync('token')
  93. },
  94. }
  95. },
  96. onLoad(options) {
  97. uni.getSystemInfo({
  98. success: (res) => {
  99. console.log(res)
  100. if (res.model == 'iPhone') {
  101. this.isIphone = true;
  102. }
  103. },
  104. fail: (err) => {
  105. console.log(err)
  106. }
  107. })
  108. this.id = options.id
  109. NET.request(API.getPackageInfo + '/' + options.id, {}).then(res => {
  110. this.info = res.data
  111. this.fileList = res.data.packFiles
  112. }).catch(error => {
  113. this.$refs.uToast.show({
  114. title: error.msg,
  115. type: 'warning',
  116. })
  117. })
  118. },
  119. onReady() {
  120. if (this.isIphone) {
  121. document.getElementsByClassName('mainCont')[0].style.height = document.getElementsByClassName('mainCont')[
  122. 0].clientHeight - 25 + 'px'
  123. }
  124. },
  125. methods: {
  126. uploadSuccess(data, index) {
  127. console.log(data, index)
  128. if (data.code == 200) {
  129. data.data[0].fileType = 2
  130. data.data[0].fileCategory = 3
  131. data.data[0].packageId = this.id
  132. this.imgList.push(data.data[0])
  133. this.$refs.uToast.show({
  134. title: '上传成功',
  135. type: 'success',
  136. })
  137. } else {
  138. this.$refs.upload.remove(index)
  139. this.$refs.uToast.show({
  140. title: data.msg,
  141. type: 'warning',
  142. })
  143. }
  144. },
  145. uploadRemove(index) {
  146. console.log(index);
  147. this.imgList.splice(index, 1)
  148. },
  149. unusualDo() {
  150. if (!this.remark) {
  151. this.$refs.uToast.show({
  152. title: '请填写异常描述内容',
  153. type: 'warning',
  154. })
  155. return false
  156. }
  157. if (!this.imgList.length) {
  158. this.$refs.uToast.show({
  159. title: '请上传异常照片',
  160. type: 'warning',
  161. })
  162. return false
  163. }
  164. let postData = {
  165. abnormalRemake: this.remark,
  166. files: this.imgList,
  167. id: this.id
  168. }
  169. NET.request(API.handleError4Pack, postData, 'POST').then(res => {
  170. this.$refs.uToast.show({
  171. title: res.msg,
  172. type: 'success',
  173. })
  174. uni.navigateBack({
  175. delta: 1
  176. });
  177. }).catch(error => {
  178. this.$refs.uToast.show({
  179. title: error.msg,
  180. type: 'warning',
  181. })
  182. })
  183. },
  184. goBack() {
  185. uni.navigateBack({
  186. delta: 1
  187. });
  188. },
  189. }
  190. }
  191. </script>
  192. <style lang="scss">
  193. .mainCont {
  194. height: calc(100% - 80rpx);
  195. padding-bottom: 60px;
  196. overflow-y: scroll;
  197. }
  198. .title {
  199. height: 40px;
  200. line-height: 20px;
  201. padding: 10px;
  202. }
  203. .red {
  204. display: inline-block;
  205. width: 10px;
  206. height: 10px;
  207. color: red;
  208. }
  209. .imgupload {
  210. margin-bottom: 10px;
  211. padding: 10px 25px;
  212. background: #fff;
  213. .imgbox {
  214. img {
  215. width: 80px;
  216. height: 80px;
  217. margin: 10px 10px 10px 0;
  218. }
  219. }
  220. }
  221. /deep/ .u-cell__value {
  222. color: #1c1c1c;
  223. }
  224. </style>