Detail.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <view >
  3. <uni-nav-bar fixed="true" height="80px" dark color="#ffffff" backgroundColor="#1989fa" shadow left-icon="back"
  4. title="巡检详情" @clickLeft="GoBack()"/>
  5. <view class="uni-flex uni-column" style="display:flex;flex-direction:row;background-color: #1989fa;color:#fff;height: 100px;">
  6. <view class="flex-item flex-item-V" style="padding-left:15px;;">
  7. <view style="margin:20px 10px 10px 0;font-size:18px;font-weight:bold;">{{this.pointInfo.routename}}</view>
  8. <uni-icons type="person" size="18" color="#fff" style="margin-right:10px"></uni-icons>
  9. <text style="font-size:16px;">{{this.$store.state.data.userName}}</text>
  10. </view>
  11. <view class="flex-item flex-item-V" style="margin-left:30px;">
  12. <view style="margin-top:20px;font-size:16px;">{{this.pointInfo.pointname}}</view>
  13. <view style="margin-top:13px;font-size:16px;">{{this.pointInfo.realtime}}</view>
  14. </view>
  15. </view>
  16. <view style="margin:10px 10px;">
  17. <uni-forms-item label="备注说明" >
  18. <uni-easyinput type="textarea" v-model="remarkStr" placeholder="请输入备注" />
  19. </uni-forms-item>
  20. <uni-file-picker :value="filePathsList" :auto-upload="false" file-mediatype="image" mode="grid" title="上传图片"
  21. file-extname="png,jpg" :limit="3" @select="handleSelect" @delete="handleDelete"/>
  22. <button @click="SavePointData()" style="width:100%;height:40px;line-height:40px;border-radius:3px;background-color:#1989fa;color:#fff;border:#1989fa;margin-top:15px">确定</button>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. //在使用的文件引入 pathToBase64(将图片转为base64) base64ToPath(将base64转为图片)
  28. import { pathToBase64, base64ToPath } from 'image-tools'
  29. export default {
  30. data() {
  31. return {
  32. pkcode:'',
  33. remarkStr:'',
  34. imageValue: [],
  35. filePathsList:[],
  36. pointInfo:{},
  37. }
  38. },
  39. created(){
  40. this.pkcode =decodeURIComponent(this.getUrlParam('pkcode'))
  41. this.getDetail()
  42. },
  43. methods:{
  44. async handleSelect(res) { // 上传图片
  45. var filedata= res.tempFiles[0]
  46. var file={}
  47. file.name =filedata.name
  48. file.type = filedata.fileType
  49. file.size = filedata.size
  50. file.url = filedata.url
  51. await pathToBase64(filedata.url).then(base64=>{
  52. this.base64Data = base64
  53. file.content = base64
  54. })
  55. this.imageValue.push(file)
  56. },
  57. handleDelete(err) { // 删除图片
  58. var that=this;
  59. const num = that.imageValue.findIndex(v=>v.url==err.tempFilePath)
  60. that.imageValue.splice(num,1)
  61. },
  62. getDetail() {
  63. var data= {
  64. pkCode: this.pkcode
  65. }
  66. this.$api.GetPointDetail(data).then(res=>{
  67. if (res.isSuccess && res.data !=undefined) {
  68. this.pointInfo=res.data
  69. }else{
  70. uni.showToast({
  71. icon:'none',
  72. title:'未查询到记录'
  73. })
  74. }
  75. })
  76. },
  77. SavePointData(){
  78. if(this.remarkStr=='' && (this.imageValue!=undefined && this.imageValue.length==0)){
  79. uni.showToast({
  80. icon: 'none',
  81. title: '请填写备注或上传图片'
  82. });
  83. return
  84. }
  85. let files = []
  86. this.imageValue.filter(function (item, i) {
  87. let file = {}
  88. file.name = item.name
  89. file.type = item.type
  90. file.size = item.size
  91. file.content = item.content
  92. files.push(file)
  93. })
  94. var data ={
  95. autoid: this.pkcode,
  96. reamrk: this.remarkStr,
  97. fileList: files
  98. }
  99. this.$api.PlandetailUpdate(data).then(res=>{
  100. if(!res.isSuccess){
  101. uni.showToast({
  102. icon: 'none',
  103. title: res.errMsg
  104. });
  105. return
  106. };
  107. uni.showToast({
  108. icon: 'none',
  109. title: '提交成功'
  110. });
  111. uni.navigateTo({
  112. url:'/pages/inspection/Route?plancode='+encodeURIComponent(this.pointInfo.plancode)+'&plandate='+encodeURIComponent(this.pointInfo.planDate.slice(0,10))+'&plantime='+encodeURIComponent(this.pointInfo.plantime)
  113. })
  114. })
  115. },
  116. GoBack(){
  117. uni.navigateTo({
  118. url:'/pages/inspection/Route?plancode='+encodeURIComponent(this.pointInfo.plancode)+'&plandate='+encodeURIComponent(this.pointInfo.planDate.slice(0,10))+'&plantime='+encodeURIComponent(this.pointInfo.plantime)
  119. })
  120. },
  121. getUrlParam(_key){
  122. var pages = getCurrentPages() //获取加载的页面
  123. var currentPage = pages[pages.length - 1] //获取当前页面的对象
  124. var url = currentPage.route //当前页面url
  125. var options = currentPage.options //如果要获取url中所带的参数可以查看options
  126. return options[_key];
  127. }
  128. }
  129. }
  130. </script>
  131. <style>
  132. </style>