addRemarkPopup.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <view>
  3. <uni-popup ref="addRemarkPopup" type="center">
  4. <view class="addRemarkPopup flex-col">
  5. <view class="content">
  6. <view class="flex-row justify-between item">
  7. <text class="label">备注:</text>
  8. <textarea class="textarea" v-model="expandUser.remake" placeholder-style="color:#999999" placeholder="请输入备注"/>
  9. </view>
  10. <view class="flex-row justify-between item">
  11. <view class="flex-col justify-center">
  12. <text class="label">备注地址:</text>
  13. </view>
  14. <input class="input" v-model="expandUser.remarkAddress" placeholder="请输入备注地址" />
  15. </view>
  16. <view class="flex-row justify-between item">
  17. <text class="label">现场照片:</text>
  18. <view class="imageList">
  19. <view class="addImage leftFloat" v-for="(item,index) in scenePhotoArr" :key="index">
  20. <image :src="item.url"></image>
  21. </view>
  22. <view class="addImage leftFloat flex-col justify-center" @click="updateAvatar">
  23. <uni-icons type="plusempty" size="30"></uni-icons>
  24. <text>现场照片</text>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="flex-row">
  30. <button class="button" type="primary" @click="addRemark">确定</button>
  31. <button class="button" @click="closePopup">取消</button>
  32. </view>
  33. </view>
  34. </uni-popup>
  35. </view>
  36. </template>
  37. <script>
  38. import Button from "../../uni_modules/uv-ui-tools/libs/mixin/button";
  39. export default {
  40. name:"addRemarkPopup",
  41. components: {Button},
  42. data() {
  43. return {
  44. ilist:3,
  45. expandUser:{},
  46. scenePhotoArr:[],
  47. param:{
  48. id:'',
  49. remake:'',
  50. remarkAddress:'',
  51. scenePhoto:''
  52. }
  53. };
  54. },
  55. methods:{
  56. updateAvatar(){
  57. let that = this
  58. uni.chooseImage({
  59. count: 1, //默认9
  60. sizeType: ['original'], //可以指定是原图还是压缩图,默认二者都有
  61. sourceType: ['album'], //从相册选择
  62. success: function (res) {
  63. let tempUrl = res.tempFiles[0].path
  64. uni.uploadFile({
  65. url: that.$baseUrl + '/resource/oss/upload', //仅为示例,非真实的接口地址
  66. filePath:tempUrl,
  67. name: 'file',
  68. header: {
  69. // "Content-Type": "multipart/form-data",
  70. // 'X-Access-Token': uni.getStorageSync('token'),
  71. 'Authorization': 'Bearer ' + uni.getStorageSync('accessToken'),
  72. },
  73. success: (uploadFileRes) => {
  74. let res = JSON.parse(uploadFileRes.data)
  75. console.log('+++++++++++++++++chooseavatar+++++++++++++++++++++++',uploadFileRes.data)
  76. console.log('+++++++++++++++++res.data+++++++++++++++++++++++',res.data)
  77. res.data.url = res.data.url.replace(/^http:/, "https:")
  78. that.scenePhotoArr.push(res.data)
  79. }
  80. });
  81. }
  82. })
  83. },
  84. addRemark(){
  85. let scenePhotoStr =''
  86. this.scenePhotoArr.forEach(i=>{
  87. if (scenePhotoStr === ''){
  88. scenePhotoStr += i.ossId
  89. }else {
  90. scenePhotoStr += ',' + i.ossId
  91. }
  92. })
  93. this.$api.service.addRemark({
  94. id:this.expandUser.id,
  95. remake:this.expandUser.remake,
  96. remarkAddress:this.expandUser.remarkAddress,
  97. scenePhoto:scenePhotoStr
  98. }).then(res=>{
  99. uni.$u.toast('添加成功')
  100. this.closePopup()
  101. })
  102. console.log(this.expandUser)
  103. },
  104. closePopup(){
  105. this.$refs.addRemarkPopup.close()
  106. },
  107. openPopup(id){
  108. this.param.id = id
  109. this.expandUser = {}
  110. this.scenePhotoArr = []
  111. this.expandUserDetail(id)
  112. this.$refs.addRemarkPopup.open()
  113. },
  114. expandUserDetail(id){
  115. console.log('++++++++++++++++++++++++++++')
  116. this.$api.service.expandUserDetail({
  117. expandUserId:id
  118. }).then(async res=>{
  119. this.expandUser = res.data.data
  120. if (this.expandUser.scenePhoto){
  121. let arr = this.expandUser.scenePhoto.split(',')
  122. for (const imgId of arr) {
  123. let oss = await this.$commonUtils.getImgUrlByOssId(imgId)
  124. this.scenePhotoArr.push(oss[0])
  125. this.$set(this.scenePhotoArr)
  126. }
  127. }
  128. this.$set(this.expandUser)
  129. console.log('人员详情',this.expandUser)
  130. console.log('现场图片',this.scenePhotoArr)
  131. })
  132. },
  133. }
  134. }
  135. </script>
  136. <style scoped lang="less">
  137. .addRemarkPopup{
  138. width: 750rpx;
  139. height: 900rpx;
  140. background: #FFFFFF;
  141. }
  142. .content{
  143. padding: 0 32rpx;
  144. height: 730rpx;
  145. overflow: auto;
  146. }
  147. .textarea{
  148. width: 500rpx;
  149. height: 250rpx;
  150. border: 2rpx solid #f7f7f7;
  151. font-size: 26rpx;
  152. }
  153. .input{
  154. width: 500rpx;
  155. height: 70rpx;
  156. border: 2rpx solid #f7f7f7;
  157. font-size: 26rpx;
  158. }
  159. .item{
  160. margin-top: 20rpx;
  161. }
  162. .label{
  163. font-size: 28rpx;
  164. }
  165. .button{
  166. width: 200rpx;
  167. height: 70rpx;
  168. line-height: 70rpx;
  169. font-size: 30rpx;
  170. margin-top: 50rpx;
  171. }
  172. .imageList{
  173. width: 530rpx;
  174. min-height: 240rpx;
  175. }
  176. .addImage{
  177. width: 200rpx;
  178. height: 240rpx;
  179. border: 2rpx solid #f7f7f7;
  180. align-items: center;
  181. font-size: 28rpx;
  182. line-height: 80rpx;
  183. margin-left: 30rpx;
  184. margin-top: 10rpx;
  185. image{
  186. width: 200rpx;
  187. height: 240rpx;
  188. }
  189. }
  190. .leftFloat{
  191. float: left;
  192. }
  193. </style>