item.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <view>
  3. <MeScroll :up="up" :down="down" @up="upFn" :fixed="false" @down="downFn" @init="initMeScroll">
  4. <card @handleRepair="handleRepair" :list="list"></card>
  5. <!-- 详情 -->
  6. <u-popup v-model="popupShow" mode="center" width="650" :closeable="true" border-radius="10">
  7. <view style="padding: 60rpx 40rpx 10rpx;">
  8. <u-form label-width="150" :model="form" label-position="top">
  9. <u-form-item label="照片上传" >
  10. <view class="cu-form-group">
  11. <view class="grid col-4 grid-square flex-sub">
  12. <view class="bg-img" v-for="(item,index) in imgList" :key="index" @tap="ViewImage" :data-url="imgList[index]">
  13. <image :src="imgList[index]" mode="aspectFill"></image>
  14. <view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="index">
  15. <text class='cuIcon-close'></text>
  16. </view>
  17. </view>
  18. <view class="solids" @tap="ChooseImage" v-if="imgList.length<4">
  19. <text class='cuIcon-cameraadd'></text>
  20. </view>
  21. </view>
  22. </view>
  23. </u-form-item>
  24. <u-form-item label="处理情况" required=true><u-input v-model="detail"/></u-form-item>
  25. </u-form>
  26. <view @click="submit()" class="flex cu-btn bg-blue" style="margin: 60rpx 0 10rpx;padding: 40rpx;">
  27. 确定
  28. </view>
  29. </view>
  30. </u-popup>
  31. </MeScroll>
  32. </view>
  33. </template>
  34. <script>
  35. import MeScroll from '@/components/mescroll-body/mescroll-uni.vue'
  36. import card from '@/components/repair/repair'
  37. var app=getApp()
  38. var _this = this;
  39. export default {
  40. components:{
  41. MeScroll,card
  42. },
  43. props: {
  44. refresh:Boolean,
  45. type: Number,
  46. i: Number,
  47. item:Object
  48. },
  49. data() {
  50. return {
  51. //照片上传及处理情况
  52. imgList: [],
  53. imgMaxNum: 4,
  54. detail:'',
  55. detailTemp:{},
  56. //弹出
  57. popupShow:false,
  58. isInit: false, // 是否初始化
  59. list: [], // 列表数据
  60. mescroll: null, // mescroll 对象
  61. // 上拉配置参数
  62. up: {
  63. noMoreSize: 5,
  64. auto: true,
  65. page: {
  66. page: 0,
  67. size: 10
  68. }
  69. },
  70. // 下拉配置参数
  71. down: {
  72. use: true,
  73. auto: false
  74. }
  75. }
  76. },
  77. watch:{
  78. refresh() {
  79. console.log("我要刷新了");
  80. this.mescroll.resetUpScroll()
  81. },
  82. type(val) {
  83. if(!this.isInit && val === this.i) {
  84. this.mescroll.resetUpScroll()
  85. }
  86. }
  87. },
  88. mounted() {
  89. if(!this.isInit && this.i === 0) {
  90. this.mescroll.resetUpScroll()
  91. }
  92. },
  93. methods: {
  94. /**
  95. * @param {Object} item
  96. * 点击处理工单
  97. */
  98. handleRepair(item){
  99. console.log("进入时item:", item)
  100. this.detailTemp = item,
  101. this.popupShow=true,
  102. this.imgList = [],
  103. this.detail = ''
  104. },
  105. /**
  106. * 确认提交工单情况s
  107. */
  108. submit(){
  109. this.detailTemp.picArr = this.imgList.join(",")
  110. console.log("临时item",this.detailTemp)
  111. // this.detailTemp.
  112. this.$showModel('确定把该工单置为已处理状态?').then(res=>{
  113. if(this.detail == ''){
  114. this.$u.toast('请填写处理情况')
  115. return
  116. }else{
  117. this.detailTemp.handleStatus=1,
  118. this.detailTemp.estimateStatus=0
  119. this.$api.estateRepair.submit(this.detailTemp).then(res=>{
  120. this.$u.toast('操作成功')
  121. this.mescroll.resetUpScroll()
  122. this.popupShow=false
  123. })
  124. }
  125. })
  126. },
  127. /**
  128. * @param {Object} index
  129. * 拍照或者从图库选择照片上传照片
  130. */
  131. ChooseImage() {
  132. _this = this;
  133. uni.chooseImage({
  134. count: 4, //默认9
  135. sizeType: ['original'], //可以指定是原图还是压缩图,默认二者都有
  136. sourceType: ['camera','album'], //从相机、相册选择
  137. success: (res) => {
  138. var tempFilePaths = res.tempFilePaths;
  139. if (_this.imgList.length+tempFilePaths.length > _this.imgMaxNum) {
  140. uni.showToast({
  141. title: '超过上传图片的最大数量',
  142. icon: 'none'
  143. })
  144. } else {
  145. if (_this.imgList.length != 0) {
  146. _this.imgList = _this.imgList.concat(res.tempFilePaths);
  147. } else {
  148. _this.imgList = res.tempFilePaths;
  149. }
  150. for (var i = 0; i < tempFilePaths.length; i++) {
  151. uni.uploadFile({
  152. url: "https://www.example.com/upload",
  153. filePath: tempFilePaths[i],
  154. name: "file", // 一定要与后台@RequestParam("file") MultipartFile变量名一致
  155. success(res) {
  156. console.log(res);
  157. }
  158. });
  159. }
  160. }
  161. }
  162. });
  163. },
  164. ViewImage(e) {
  165. uni.previewImage({
  166. urls: this.imgList,
  167. current: e.currentTarget.dataset.url
  168. });
  169. },
  170. DelImg(e) {
  171. this.imgList.splice(e.currentTarget.dataset.index, 1)
  172. },
  173. /**
  174. * @param {Object} mescroll 初始化组件
  175. */
  176. initMeScroll(mescroll) {
  177. this.mescroll = mescroll
  178. },
  179. /**
  180. * @param {Object} mescroll 上拉回调
  181. */
  182. upFn(mescroll) {
  183. let that=this
  184. let data={
  185. current:mescroll.num,
  186. size:mescroll.size,
  187. handleStatus:this.item.value
  188. }
  189. // if (this.item.value==2) {
  190. // data.handleStatus=1
  191. // data.estimateStatus=0
  192. // }
  193. try{
  194. this.$api.estateRepair.page(data).then(res=>{
  195. let data=res.data.records
  196. console.log(data);
  197. let length=data.length
  198. mescroll.endBySize(length, res.data.total);
  199. if(mescroll.num == 1) that.list = [];
  200. that.list=that.list.concat(data);
  201. })
  202. }catch(e){
  203. mescroll.endErr();
  204. }
  205. },
  206. /**
  207. * 下拉回调
  208. * */
  209. downFn(mescroll) {
  210. setTimeout(()=>{
  211. this.list=[]
  212. this.mescroll.resetUpScroll()
  213. },1500)
  214. },
  215. }
  216. }
  217. </script>
  218. <style lang="scss" scoped>
  219. view{
  220. box-sizing: border-box;
  221. }
  222. </style>