infoPage.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. <template>
  2. <view class="equipmentInformationInfoPage">
  3. <view class="info-max-box">
  4. <img class="left-img" v-if="imageUrls[0]" :src="baseUrl+imageUrls[0]">
  5. <img class="left-img" v-if="!imageUrls[0]" src="">
  6. <view class="right-box">
  7. <view>设备分类:{{newData.categoryName}}</view>
  8. <view>设备名称:{{newData.deviceName}}</view>
  9. <view>设备编号:{{newData.deviceCode}}</view>
  10. <view>设备状态:{{newData.deviceStatusName}}</view>
  11. </view>
  12. </view>
  13. <view class="text-max-box">
  14. <img src="">
  15. <view>类型</view>
  16. <view>{{newData.deviceType}}</view>
  17. </view>
  18. <view class="text-max-box">
  19. <img src="">
  20. <view>品牌</view>
  21. <view>{{newData.brand}}</view>
  22. </view>
  23. <view class="text-max-box">
  24. <img src="">
  25. <view>设备原值(元)</view>
  26. <view>{{newData.price}}</view>
  27. </view>
  28. <view class="text-title-box">参数用途</view>
  29. <view class="text-max-box">
  30. <img src="">
  31. <view>设备用途</view>
  32. <view class="colorA" @click="lookText(1)">查看</view>
  33. </view>
  34. <view class="text-max-box">
  35. <img src="">
  36. <view>技术参数</view>
  37. <view class="colorA" @click="lookText(2)">查看</view>
  38. </view>
  39. <view class="text-max-box">
  40. <img src="">
  41. <view>备注</view>
  42. <view class="colorA" @click="lookText(3)">查看</view>
  43. </view>
  44. <view class="text-title-box">设备归属</view>
  45. <view class="text-max-box">
  46. <img src="">
  47. <view>设备管理员</view>
  48. <view>{{newData.adminDisplay}}</view>
  49. </view>
  50. <view class="text-max-box">
  51. <img src="">
  52. <view>管理部门</view>
  53. <view>{{newData.manageDeptName}}</view>
  54. </view>
  55. <view class="text-max-box">
  56. <img src="">
  57. <view>存放位置</view>
  58. <view>{{newData.location}}</view>
  59. </view>
  60. <view class="text-title-box">厂家产地</view>
  61. <view class="text-max-box">
  62. <img src="">
  63. <view>单位</view>
  64. <view>{{newData.unit}}</view>
  65. </view>
  66. <view class="text-max-box">
  67. <img src="">
  68. <view>生产厂家</view>
  69. <view>{{newData.manufacturer}}</view>
  70. </view>
  71. <view class="text-max-box">
  72. <img src="">
  73. <view>产地</view>
  74. <view>{{newData.originPlace}}</view>
  75. </view>
  76. <view class="bottom-button" @click="onShade()">登记使用信息</view>
  77. <view class="shade-max-big-box" v-if="shadeType == 1||shadeType == 2||shadeType == 3||shadeType == 4">
  78. <view class="shade-top-flex" @click="offShade()"></view>
  79. <view class="shade-big-box">
  80. <view class="shade-title-box" v-if="shadeType == 1||shadeType == 2||shadeType == 3">登记使用信息</view>
  81. <view class="shade-title-box" v-if="shadeType == 4">{{shadeDataD.data1}}</view>
  82. <!-- 登记 -->
  83. <view class="shade-box" v-if="shadeType == 1">
  84. <view class="shade-text-box">
  85. <view>使用人</view>
  86. <view>{{shadeDataA.data1}}</view>
  87. </view>
  88. <view class="shade-text-box">
  89. <view>使用类型</view>
  90. <!-- <view>{{shadeDataA.data2}}</view> -->
  91. <picker @change="pickerChange" :value="pickerIndex" :range="pickerList">
  92. <view style="width:400rpx;text-align:right;">{{pickerList[pickerIndex]}}</view>
  93. </picker>
  94. </view>
  95. <view class="shade-text-box">
  96. <view>开机时间</view>
  97. <view>{{timestampToStr(shadeDataA.data3)}}</view>
  98. </view>
  99. <view class="shade-text-box">
  100. <view>关机时间</view>
  101. <view>
  102. <uni-datetime-picker :start="timeApplication" @change="timePickerChange()" return-type="timestamp" v-model="shadeDataA.data4">{{timestampToStr(shadeDataA.data4)}}</uni-datetime-picker>
  103. </view>
  104. </view>
  105. <view class="shade-text-box">
  106. <view>使用总时长</view>
  107. <view>{{shadeDataA.data5}}</view>
  108. </view>
  109. <view class="shade-button" @click="submitButton(1)">确定</view>
  110. </view>
  111. <!-- 结束 -->
  112. <view class="shade-box" v-if="shadeType == 2">
  113. <view class="shade-text-box">
  114. <view>使用人</view>
  115. <view>{{shadeDataB.data1}}</view>
  116. </view>
  117. <view class="shade-text-box">
  118. <view>使用类型</view>
  119. <view>{{shadeDataB.data2}}</view>
  120. </view>
  121. <view class="shade-text-box">
  122. <view>开机时间</view>
  123. <view>{{shadeDataB.data3}}</view>
  124. </view>
  125. <view class="shade-text-box">
  126. <view>关机时间</view>
  127. <view>{{shadeDataB.data4}}</view>
  128. </view>
  129. <view class="shade-text-box">
  130. <view>使用总时长</view>
  131. <view>{{shadeDataB.data5}}</view>
  132. </view>
  133. <view class="shade-button">确定</view>
  134. </view>
  135. <!-- 查看 -->
  136. <view class="shade-box-c" v-if="shadeType == 3">
  137. <view class="shade-text-title">当前设备已被【{{shadeDataC.data1}}】登记使用,</view>
  138. <view class="shade-text-title">开机时间:{{shadeDataC.data2}}</view>
  139. <view class="shade-text-title">如有疑问请联系:{{shadeDataC.data3}}</view>
  140. </view>
  141. <view class="shade-box" v-if="shadeType == 4">
  142. <view class="text-box">
  143. {{shadeDataD.data2}}
  144. </view>
  145. </view>
  146. </view>
  147. </view>
  148. </view>
  149. </template>
  150. <script>
  151. import {
  152. mpDeviceDetail,
  153. } from '@/pages_equipmentUtilization/api/index.js'
  154. import { config } from '@/api/request/config.js'
  155. export default {
  156. props: {
  157. equipmentId: {},
  158. },
  159. data() {
  160. return {
  161. shadeType:0,
  162. baseUrl:config.base_url,
  163. userId: uni.getStorageSync('userId'),
  164. newData:{
  165. categoryName:'',
  166. deviceCode:'',
  167. deviceName:'',
  168. deviceStatusName:'',
  169. deviceType:'',
  170. brand:'',
  171. price:'',
  172. adminDisplay:'',
  173. manageDeptName:'',
  174. location:'',
  175. unit:'',
  176. manufacturer:'',
  177. originPlace:'',
  178. purpose:'',
  179. techParams:'',
  180. remark:'',
  181. },
  182. shadeDataA:{},
  183. shadeDataB:{
  184. data1:'张工',
  185. data2:'自用',
  186. data3:'2026-01-25 15:30',
  187. data4:'2026-01-25 15:30',
  188. data5:'3天2小时15分',
  189. },
  190. shadeDataC:{
  191. data1:'张工',
  192. data2:'2026-01-25 15:30',
  193. data3:'010-88888888',
  194. },
  195. shadeDataD:{
  196. data1:'张工',
  197. data2:'2026-01-25 15:30',
  198. },
  199. pickerList:['自用','对外服务'],
  200. pickerIndex:0,
  201. timeApplication:null,
  202. }
  203. },
  204. mounted() {
  205. this.mpDeviceDetail(this.equipmentId);
  206. },
  207. methods: {
  208. pickerChange(val){
  209. console.log('val',val.mp.detail.value);
  210. this.$set(this,'pickerIndex',val.mp.detail.value);
  211. },
  212. //获取设备信息
  213. async mpDeviceDetail(id) {
  214. let self = this;
  215. const {
  216. data
  217. } = await mpDeviceDetail({id:id});
  218. if (data.code == 200) {
  219. this.$set(this,'newData',data.data);
  220. }
  221. },
  222. lookText(type){
  223. if(type == 1){
  224. this.$set(this,'shadeDataD',{
  225. data1:'设备用途',
  226. data2:this.newData.purpose,
  227. });
  228. }else if(type == 2){
  229. this.$set(this,'shadeDataD',{
  230. data1:'技术参数',
  231. data2:this.newData.techParams,
  232. });
  233. }else if(type == 3){
  234. this.$set(this,'shadeDataD',{
  235. data1:'备注',
  236. data2:this.newData.remark,
  237. });
  238. }
  239. this.$set(this,'shadeType',4);
  240. },
  241. onShade(){
  242. //判断 登记时1 退订2 已占用3
  243. if(this.newData.runStatus == 0){
  244. //无人使用
  245. const now = new Date();
  246. now.setSeconds(0, 0); // 将秒和毫秒都设为0
  247. const timestamp = now.getTime()
  248. this.$set(this,'timeApplication',timestamp);
  249. this.$set(this,'pickerIndex',0);
  250. this.$set(this,'shadeDataA',{
  251. data1:uni.getStorageSync('user-name'),
  252. data2:null,
  253. data3:this.timeApplication,
  254. data4:this.timeApplication,
  255. data5:'0天0小时0分',
  256. });
  257. this.$set(this,'shadeType',1);
  258. }else if(this.newData.runStatus != 0 || this.newData.currentUserId != this.userId){
  259. //别人使用中
  260. this.$set(this,'shadeType',3);
  261. }else if(this.newData.runStatus != 0 || this.newData.currentUserId == this.userId){
  262. //自己使用中
  263. this.$set(this,'shadeType',2);
  264. }
  265. },
  266. offShade(){
  267. this.$set(this,'shadeType',0);
  268. },
  269. timestampToStr(timestamp) {
  270. const date = new Date(timestamp); // 传入毫秒级时间戳
  271. const year = date.getFullYear();
  272. const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始,需+1
  273. const day = String(date.getDate()).padStart(2, '0');
  274. const hours = String(date.getHours()).padStart(2, '0');
  275. const minutes = String(date.getMinutes()).padStart(2, '0');
  276. // 注意:这里没有拼接秒
  277. return `${year}-${month}-${day} ${hours}:${minutes}`;
  278. },
  279. formatTimeDiff(timestamp1, timestamp2) {
  280. // 计算绝对差值(毫秒)
  281. const diffMs = Math.abs(timestamp1 - timestamp2);
  282. // 转换为总分钟数(向下取整)
  283. const totalMinutes = Math.floor(diffMs / (1000 * 60));
  284. // 计算天、小时、分钟
  285. const days = Math.floor(totalMinutes / (60 * 24));
  286. const remainingMinutes = totalMinutes % (60 * 24);
  287. const hours = Math.floor(remainingMinutes / 60);
  288. const minutes = remainingMinutes % 60;
  289. // 构建输出字符串
  290. const parts = [];
  291. if (days > 0) parts.push(days + '天');
  292. if (hours > 0) parts.push(hours + '小时');
  293. if (minutes > 0 || parts.length === 0) parts.push(minutes + '分'); // 确保至少显示“0分”
  294. return parts.join('');
  295. },
  296. timePickerChange(){
  297. if(this.shadeDataA.data4>this.shadeDataA.data3){
  298. this.$set(this.shadeDataA,'data5',this.formatTimeDiff(this.shadeDataA.data3,this.shadeDataA.data4));
  299. }else{
  300. uni.showToast({
  301. title: '开机时间与关机时间不能相等',
  302. icon:"none",
  303. mask:true,
  304. duration: 2000
  305. });
  306. }
  307. },
  308. submitButton(type){
  309. console.log('shadeDataA',this.shadeDataA)
  310. },
  311. },
  312. }
  313. </script>
  314. <style lang="stylus" scoped>
  315. .equipmentInformationInfoPage {
  316. height: 100%;
  317. flex:1;
  318. display:flex;
  319. flex-direction:column;
  320. background-color: #fff;
  321. overflow: scroll;
  322. .info-max-box{
  323. display: flex;
  324. .left-img{
  325. width:200rpx;
  326. height:200rpx;
  327. display: inline-block;
  328. border:1rpx solid #dedede;
  329. margin:40rpx 20rpx 20rpx 20rpx;
  330. }
  331. .right-box{
  332. flex:1;
  333. margin:40rpx 20rpx 20rpx 0;
  334. view{
  335. width: 480rpx;
  336. display:block;
  337. overflow:hidden;
  338. text-overflow:ellipsis;
  339. white-space:nowrap;
  340. margin-bottom:14rpx;
  341. }
  342. }
  343. }
  344. .text-max-box{
  345. display: flex;
  346. border-bottom: 1rpx solid #f2f2f2;
  347. line-height:80rpx;
  348. padding: 0 40rpx;
  349. img{
  350. width:40rpx;
  351. height:40rpx;
  352. display: inline-block;
  353. }
  354. view:nth-child(2){
  355. flex:1;
  356. }
  357. view:nth-child(3){
  358. }
  359. .colorA{
  360. color:#0183FA;
  361. }
  362. }
  363. .text-title-box{
  364. line-height:80rpx;
  365. background-color: #f2f2f2;
  366. padding: 0 30rpx;
  367. }
  368. .bottom-button{
  369. width:300rpx;
  370. line-height:80rpx;
  371. text-align: center;
  372. margin:60rpx auto;
  373. color:#fff;
  374. background-color: #0183FA;
  375. border-radius:6rpx;
  376. }
  377. .shade-max-big-box{
  378. position: absolute;
  379. top:0;
  380. left:0;
  381. width:100%;
  382. height:100%;
  383. background-color: rgba(0,0,0,0.3)
  384. display: flex;
  385. flex-direction: column;
  386. .shade-top-flex{
  387. flex:1;
  388. }
  389. .shade-big-box{
  390. background-color: #fff;
  391. .shade-title-box{
  392. font-weight:900;
  393. padding-right:20rpx;
  394. width:300rpx;
  395. border-bottom-right-radius: 40rpx
  396. background-color: #0183FA;
  397. color:#fff;
  398. text-align: center;
  399. line-height:60rpx;
  400. }
  401. .shade-box{
  402. padding:20rpx 0 100rpx;
  403. .shade-text-box{
  404. display: flex;
  405. border-bottom:1rpx solid #f2f2f2;
  406. line-height:80rpx;
  407. padding:0 30rpx;
  408. view:nth-child(1){
  409. flex:1;
  410. }
  411. view:nth-child(1){
  412. flex:3;
  413. }
  414. }
  415. .shade-button{
  416. width:300rpx;
  417. line-height:80rpx;
  418. text-align: center;
  419. background-color: #0183FA;
  420. border-radius:8rpx;
  421. color:#fff;
  422. margin:40rpx auto 0;
  423. }
  424. .text-box{
  425. padding:60rpx 40rpx 200rpx;
  426. }
  427. }
  428. .shade-box-c{
  429. padding:120rpx 0 200rpx;
  430. .shade-text-title{
  431. text-align-last: center;
  432. line-height: 60rpx;
  433. }
  434. }
  435. }
  436. }
  437. }
  438. </style>