sqmoneydetail.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <template>
  2. <view class="mdetail">
  3. <uni-data-picker :map="map" :readonly='readonly' :localdata="assetTree" v-model="datainfo.assetId" >
  4. </uni-data-picker>
  5. <!-- <view class="mdtit">车辆资产 / {{datainfo.assetName}}</view> -->
  6. <view class="mdbox">
  7. <image :src="yy_code" class="code"></image>
  8. <view class="down flexcc" @click="getDown">
  9. <image :src="downico"></image>保存二维码至手机
  10. </view>
  11. <image :src="line" class="line mb20"></image>
  12. <view class="mdlist flex mb14"><view class="tit">资产名称:</view>{{datainfo.equipmentName}}</view>
  13. <view class="mdlist flex mb14"><view class="tit">资产编号:</view>{{datainfo.equipmentNumber}}</view>
  14. <view class="mdlist flex mb14"><view class="tit">资产型号:</view>{{datainfo.equipmentModel}}</view>
  15. <view class="mdlist flex mb14"><view class="tit">存放位置或使用位置:</view>{{datainfo.equipmentLocation}}</view>
  16. <view class="mdlist flex mb14"><view class="tit">购买价格:</view>{{datainfo.equipmentPrice}}
  17. <!-- <view class="coby">复制</view> -->
  18. </view>
  19. <view class="mdlist flex mb14"><view class="tit">购买时间:</view>{{datainfo.purchaseDate}}</view>
  20. <view class="mdlist flex mb14"><view class="tit">资产状态:</view>{{kaType(datainfo.equipmentStatus,sbztList)}}</view>
  21. <view class="mdlist flex mb14"><view class="tit">用途描述:</view>{{datainfo.equipmentPurpose}}</view>
  22. <view class="mdlist flex mb14"><view class="tit">车牌号:</view>{{datainfo.plateNumber}}</view>
  23. <view class="mdlist flex mb14"><view class="tit">备注信息:</view>{{datainfo.remark}}</view>
  24. <view class="mdlist flex mb14"><view class="tit">设备封面:</view>
  25. <view class="imgs">
  26. <block v-if="fmphofile&&fmphofile.length">
  27. <view class="img" v-for="(ite,idx) in fmphofile" :key="idx" @click="getPreview(idx,fmphofile)">
  28. <image :src="baseUrl+ite" class="pimg"></image>
  29. </view>
  30. </block>
  31. </view>
  32. </view>
  33. <view class="mdlist flex mb14"><view class="tit">设备图片:</view>
  34. <view class="imgs">
  35. <block v-if="phofile&&phofile.length">
  36. <view class="img" v-for="(ite,idx) in phofile" :key="idx" @click="getPreview(idx,phofile)">
  37. <image :src="baseUrl+ite" class="pimg"></image>
  38. </view>
  39. </block>
  40. </view>
  41. </view>
  42. <view class="flex1"></view>
  43. <view class="rhbtn mb12 mt30" v-if="pfrom=='list'&&checkPermi(['wuYe:assets:edit'])" @click="getput">修改</view>
  44. <view class="time">最近更新时间:2025-03-03 17:35:56</view>
  45. </view>
  46. <loading></loading>
  47. </view>
  48. </template>
  49. <script>
  50. import config from '@/config'
  51. const baseUrl = config.baseUrl;
  52. import {selectDictValue} from "@/utils/common.js"
  53. import {getDictionaryFn} from "@/api/system/user.js"
  54. import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
  55. import {assetsDet,assetTypeTree} from "@/api/work/manage.js"
  56. import QR from "@/utils/wxqrcode.js" // 二维码生成器
  57. export default{
  58. components:{},
  59. data(){
  60. return{
  61. downico:require('@/manage/static/community/downico.png'),
  62. line:require('@/manage/static/community/line.png'),
  63. id:'',
  64. datainfo:{},
  65. pfrom:"",
  66. sbztList:[],
  67. baseUrl:config.baseUrl,
  68. readonly:true,
  69. fmphofile:[],
  70. phofile:[],
  71. assetTree:[],
  72. map:{text:'label',value:'id'},
  73. yy_code:'',
  74. }
  75. },
  76. onLoad: function(e) {
  77. this.id=e.id;
  78. if(e.from){
  79. this.pfrom=e.from
  80. }
  81. this.init()
  82. this.getDetailFn()
  83. },
  84. methods:{
  85. checkPermi, checkRole,
  86. kaType(data, list) {
  87. return selectDictValue(list, data);
  88. },
  89. init(){
  90. assetTypeTree().then(res=>{
  91. if(res.code==200){
  92. this.assetTree=res.data;
  93. }
  94. })
  95. //设备状态
  96. getDictionaryFn('shebei_status').then(res=>{
  97. if(res.code==200){
  98. if(res.data){
  99. this.sbztList = res.data.map(v => {
  100. return {
  101. dictLabel: v.dictLabel,
  102. dictValue: v.dictValue
  103. }
  104. })
  105. }
  106. }
  107. })
  108. },
  109. getDown(urls){
  110. // var url=this.baseUrl+urls
  111. var imgbase64url=this.yy_code;
  112. // #ifdef H5
  113. var fileName = `/code${new Date().getTime()}.png`;
  114. var arr = imgbase64url.split(','),
  115. mime = arr[0].match(/:(.*?);/)[1],
  116. bstr = atob(arr[1]),
  117. n = bstr.length,
  118. u8arr = new Uint8Array(n);
  119. while (n--) {
  120. u8arr[n] = bstr.charCodeAt(n);
  121. }
  122. var blob = new Blob([u8arr], { type: mime });
  123. // 创建一个下载链接
  124. var a = document.createElement('a');
  125. a.download = fileName; // 设置下载文件名
  126. a.href = URL.createObjectURL(blob); // 将Blob对象转换为URL
  127. a.style.display = 'none'; // 隐藏下载链接
  128. document.body.appendChild(a); // 将下载链接添加到文档中
  129. // 模拟点击下载链接
  130. a.click();
  131. // 清理
  132. URL.revokeObjectURL(a.href); // 释放URL对象
  133. document.body.removeChild(a); // 移除下载链接
  134. // #endif
  135. // #ifdef MP-WEIXIN
  136. let base64 = imgbase64url.replace(/^data:image\/\w+;base64,/, ""); //图片替换
  137. let filePath = wx.env.USER_DATA_PATH + `/qrcode_id_${new Date().getTime()}.png`;
  138. uni.getFileSystemManager().writeFile({
  139. filePath: filePath, //创建一个临时文件名
  140. data: base64, //写入的文本或二进制数据
  141. encoding: 'base64', //写入当前文件的字符编码
  142. success: (res) => {
  143. uni.saveImageToPhotosAlbum({
  144. filePath: filePath,
  145. success: () => {
  146. uni.showToast({
  147. title: "图片保存成功,请到手机相册查看",
  148. icon: "none",
  149. duration: 5000
  150. })
  151. },
  152. fail: (err) => {
  153. console.log(err);
  154. uni.showToast({
  155. title: '图片保存失败',
  156. icon: "none",
  157. duration: 5000
  158. })
  159. }
  160. })
  161. },
  162. fail: (err) => {
  163. console.log(err)
  164. }
  165. })
  166. // #endif
  167. // #ifdef APP-PLUS
  168. const bitmap = new plus.nativeObj.Bitmap("test");
  169. bitmap.loadBase64Data(imgbase64url, function () {
  170. const url = `_doc/qrcode_id_${new Date().getTime()}.png`; // url为时间戳命名方式
  171. bitmap.save(url, {
  172. overwrite: true, // 是否覆盖
  173. // quality: 'quality' // 图片清晰度
  174. }, (i) => {
  175. uni.saveImageToPhotosAlbum({
  176. filePath: url,
  177. success: function () {
  178. uni.showToast({
  179. title: "图片保存成功,请到手机相册查看",
  180. position: "center",
  181. icon: "none",
  182. })
  183. bitmap.clear()
  184. }
  185. });
  186. }, (e) => {
  187. uni.showToast({
  188. title: '图片保存失败',
  189. icon: 'none'
  190. })
  191. bitmap.clear()
  192. });
  193. }, (e) => {
  194. bitmap.clear()
  195. });
  196. // #endif
  197. },
  198. getPreview(idx,arr) {
  199. var newArr=[];
  200. arr.forEach(ite=>{
  201. var ds=this.baseUrl+ite
  202. newArr.push(ds)
  203. })
  204. uni.previewImage({
  205. urls: newArr,
  206. current:idx,
  207. success: function(data) {},
  208. fail: function(err) {}
  209. });
  210. },
  211. getDetailFn(){
  212. var that=this;
  213. assetsDet(this.id).then(res=>{
  214. if(res.code==200){
  215. this.datainfo=res.data;
  216. var url=this.baseUrl+`/manage/pages/community/sqmoneydetail?id=${this.id}`
  217. this.yy_code = QR.createQrCodeImg(url, {
  218. size: parseInt(240),//二维码大小
  219. typeNumber:10
  220. })
  221. if(res.data.equipmentCoverPhoto){
  222. this.fmphofile=res.data.equipmentCoverPhoto.split(',')
  223. }
  224. if(res.data.equipmentPhotos){
  225. this.phofile=res.data.equipmentPhotos.split(',')
  226. }
  227. }
  228. })
  229. },
  230. getput(){
  231. this.$tab.navigateTo("/manage/pages/community/sqmoneyadd?id="+this.id)
  232. },
  233. }
  234. }
  235. </script>
  236. <style>
  237. page{background: #F3F3F0;}
  238. </style>
  239. <style lang="scss" scoped>
  240. .mdetail /deep/ .input-value-border{border: none !important;font-weight: bold;font-size: 34rpx;color: #161616;padding: 16rpx 6rpx;}
  241. .mdetail{background: linear-gradient(180deg, #CCDDFF 0%, #F3F3F0 100%) no-repeat;min-height: 100vh;background-position: top;background-size: 100% 578rpx;padding: 32rpx 30rpx 26rpx;position: relative;display: flex;flex-direction: column;}
  242. // .mdtit{font-weight: bold;font-size: 34rpx;color: #161616;padding: 16rpx 6rpx;}
  243. .mdbox{width: 100%;background: #FFFFFF;border-radius: 20rpx;flex: 1;padding: 84rpx 24rpx 80rpx;box-sizing: border-box;display: flex;flex-direction: column;
  244. .code{width: 222rpx;height: 222rpx;margin: 0 auto 20rpx;display: block;}
  245. .down{font-weight: 500;font-size: 24rpx;color: #161616;margin-bottom: 54rpx;
  246. image{width: 18rpx;height: 20rpx;margin-right: 10rpx;}
  247. }
  248. .line{width: 100%;height: 14rpx;}
  249. .mdlist{font-weight: bold;font-size: 26rpx;color: #272727;
  250. .tit{font-weight: 500;color: #AAAAAA;flex: 0 0 auto;}
  251. .coby{font-weight: 500;margin-left: 18rpx;flex: 0 0 auto;font-size: 24rpx;color: #0256FD;}
  252. }
  253. .time{font-weight: 500;font-size: 24rpx;color: #AAAAAA;text-align: center;}
  254. .imgs{display: flex;align-items: center;flex-wrap: wrap;
  255. .img{width: 142rpx;height:142rpx;border-radius: 20rpx;margin: 0 28rpx 20rpx 0;position: relative;
  256. &:nth-of-type(4n){margin-right: 0;}
  257. }
  258. .pimg{width: 100%;height: 100%;border-radius: 20rpx;}
  259. }
  260. }
  261. </style>