assetsDetailFrame.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. <template>
  2. <div class="detail">
  3. <mt-header class="detail_head" fixed title="资产详情">
  4. <router-link to="/assets" slot="left">
  5. <mt-button icon="back"></mt-button>
  6. </router-link>
  7. </mt-header>
  8. <div class="detail_body">
  9. <div class="detailBox userInfo">
  10. <div class="frame_title">
  11. <span>{{detail.rack.name}}</span>
  12. <span>
  13. <mt-button v-if="detail.rack.doorStatus==0" size="small" type="primary" v-on:click.native.stop="openDoor(1)">开门</mt-button>
  14. <span v-else style="color:red">已开门</span>
  15. </span>
  16. </div>
  17. <div class="frame_number">{{detail.modelNumber}}</div>
  18. <div class="frame_label">
  19. <span><span>机架ID:</span>{{detail.rack.rackIp}}</span>
  20. <span><span>温度:</span>{{detail.rack.temp}}</span>
  21. <span><span>湿度:</span>{{detail.rack.hum}}</span>
  22. </div>
  23. </div>
  24. <div class="detailBox">
  25. <div class="assDel assDel_Head">
  26. 机柜设备列表
  27. <!-- <img v-if="power.indexOf('update_assets')>-1" v-on:click="addNo()" src="../../assets/image/add.png"> -->
  28. </div>
  29. <div class="assDel_List">
  30. <div v-if="delList.length == 0" style="padding: 0.3rem;text-align:center;color:#ccc;">
  31. 暂无机柜设备
  32. </div>
  33. <div v-else class="one_assDel isFrame" v-for="item in delList">
  34. <mt-cell-swipe title="" :right="[
  35. { content: '下架', style: { background: 'red', color: '#fff' }, handler: () => handle(item.id) },
  36. ]">
  37. <div>
  38. <div class="new_title">
  39. <span>{{item.name}}</span>
  40. <span>{{item.modelNumber}}</span>
  41. <span>{{item.currentState==0?'禁止':'运行'}}</span>
  42. </div>
  43. <div class="new_label">
  44. <span><span>标签ID:</span>{{item.goodsNosVO[0].labelId}}</span>
  45. <span><span>模块ID:</span>{{item.goodsNosVO[0].modelId}}</span>
  46. <span><span>U位号:</span>{{item.goodsNosVO[0].ubitNum}}</span>
  47. </div>
  48. </div>
  49. </mt-cell-swipe>
  50. </div>
  51. </div>
  52. </div>
  53. </div>
  54. </div>
  55. </template>
  56. <script>
  57. import { MessageBox } from 'mint-ui';
  58. export default {
  59. data() {
  60. return {
  61. id: this.$route.params.id,
  62. power: sessionStorage.getItem("power"),
  63. detail: "",
  64. delList: [],
  65. }
  66. },
  67. methods: {
  68. getDetail() {
  69. this.$indicator.open();
  70. this.http.post(this.port.assets.detail, {
  71. 'id': this.id
  72. } ,
  73. res => {
  74. this.$indicator.close();
  75. if (res.code == "ok") {
  76. this.detail = res.data;
  77. this.delList = res.data.equipments==null?[]:res.data.equipments;
  78. } else {
  79. this.$toast({
  80. message: res.msg,
  81. duration: 2000
  82. });
  83. }
  84. }, error => {
  85. this.$indicator.close();
  86. this.$toast({
  87. message: error,
  88. duration: 2000
  89. });
  90. })
  91. },
  92. // 添加资产编号
  93. addNo() {
  94. MessageBox({
  95. $type:'prompt',
  96. title:'',
  97. message:'添加资产数量',
  98. closeOnClickModal:false,
  99. showCancelButton:true,
  100. inputValidator:function(v){
  101. if (v === null) {
  102.    return true;
  103. }
  104. var str = /^[0-9]*[1-9][0-9]*$/;
  105. if(str.test(v) && v != "") {
  106. return true
  107. } else {
  108. return false
  109. }
  110. },
  111. inputErrorMessage:'请输入资产编号数量',
  112. showInput:true
  113. }).then(({ value, action }) => {
  114. if(value == null) {
  115. this.$toast({
  116. message: '创建失败',
  117. duration: 2000
  118. });
  119. return false;
  120. } else {
  121. this.$indicator.open();
  122. this.http.post(this.port.assets.addNo, {
  123. 'goodsId': this.id,
  124. 'count': value
  125. } ,
  126. res => {
  127. this.$indicator.close();
  128. if (res.code == "ok") {
  129. this.$toast({
  130. message: '创建成功',
  131. duration: 2000
  132. });
  133. this.getDetail();
  134. } else {
  135. this.$toast({
  136. message: res.msg,
  137. duration: 2000
  138. });
  139. }
  140. }, error => {
  141. this.$indicator.close();
  142. this.$toast({
  143. message: error,
  144. duration: 2000
  145. });
  146. })
  147. }
  148. }).catch(() => {
  149. });
  150. },
  151. // 删除资产编号
  152. deleteNos(id) {
  153. MessageBox.confirm('', { 
  154. message: '是否删除该资产?', 
  155. title: '', 
  156. confirmButtonText: '确定', 
  157. cancelButtonText: '取消' 
  158.  }).then(action => { 
  159. if (action == 'confirm') {     //确认的回调
  160. this.http.post(this.port.assets.delNo, {
  161. 'id': id
  162. } ,
  163. res => {
  164. if (res.code == "ok") {
  165. this.$toast({
  166. message: "删除成功",
  167. duration: 2000
  168. });
  169. for(var i in this.delList) {
  170. if(this.delList[i].id == id) {
  171. this.delList.splice(i, 1);
  172. }
  173. }
  174. var list = this.delList,
  175. useList = [],
  176. serList = [],
  177. scrList = [],
  178. unuList = [];
  179. for(var i in list) {
  180. if(list[i].state == 0) {
  181. unuList.push(list[i])
  182. } else if(list[i].state == 1) {
  183. useList.push(list[i])
  184. serList.push(list[i])
  185. } else if(list[i].state == 3) {
  186. scrList.push(list[i])
  187. }
  188. }
  189. this.useList = useList;
  190. this.serList = serList;
  191. this.scrList = scrList;
  192. this.unuList = unuList;
  193. } else {
  194. this.$toast({
  195. message: res.msg,
  196. duration: 2000
  197. });
  198. }
  199. }, error => {
  200. this.$toast({
  201. message: error,
  202. duration: 2000
  203. });
  204. })
  205. }
  206.  }).catch(err => { 
  207.  });
  208. },
  209. // 跳转
  210. jumpBack() {
  211. this.$router.push("/assets");
  212. },
  213. // 开门
  214. openDoor() {
  215. MessageBox.confirm('', { 
  216. message: '是否打开机柜?', 
  217. title: '', 
  218. confirmButtonText: '确定', 
  219. cancelButtonText: '取消' 
  220.  }).then(action => { 
  221. if (action == 'confirm') {     //确认的回调
  222. this.http.post(this.port.assets.openDoor, {
  223. 'goodsId': this.id,
  224. 'doorStatus': 1
  225. } ,
  226. res => {
  227. if (res.code == "ok") {
  228. this.$toast({
  229. message: "开门成功",
  230. duration: 2000
  231. });
  232. this.getDetail();
  233. } else {
  234. this.$toast({
  235. message: res.msg,
  236. duration: 2000
  237. });
  238. }
  239. }, error => {
  240. this.$toast({
  241. message: error,
  242. duration: 2000
  243. });
  244. })
  245. }
  246.  }).catch(err => { 
  247.  });
  248. },
  249. // 下架设备
  250. handle(id) {
  251. MessageBox.confirm('', { 
  252. message: '是否下架该设备?', 
  253. title: '', 
  254. confirmButtonText: '确定', 
  255. cancelButtonText: '取消' 
  256.  }).then(action => { 
  257. if (action == 'confirm') {     //确认的回调
  258. this.http.post(this.port.assets.upMold, {
  259. 'id': id
  260. } ,
  261. res => {
  262. if (res.code == "ok") {
  263. this.$toast({
  264. message: "下架成功",
  265. duration: 2000
  266. });
  267. this.getDetail();
  268. } else {
  269. this.$toast({
  270. message: res.msg,
  271. duration: 2000
  272. });
  273. }
  274. }, error => {
  275. this.$toast({
  276. message: error,
  277. duration: 2000
  278. });
  279. })
  280. }
  281.  }).catch(err => { 
  282.  });
  283. }
  284. },
  285. created() {
  286. this.getDetail();
  287. },
  288. mounted() {
  289. }
  290. }
  291. </script>
  292. <style scoped>
  293. .detail_head {
  294. background: #fff;
  295. color: #333;
  296. height: 0.4rem;
  297. }
  298. .detail_body {
  299. margin-top: 0.4rem;
  300. }
  301. .detail {
  302. background: #EFEFEF;
  303. }
  304. .detailBox {
  305. background: #fff;
  306. margin-bottom: 0.11rem;
  307. }
  308. .userInfo {
  309. padding: 0 0.1rem 0.12rem;
  310. }
  311. .frame_title > span {
  312. padding: 0.12rem 0 0 0;
  313. display: inline-block;
  314. vertical-align: bottom;
  315. }
  316. .frame_title > span:nth-child(1) {
  317. display: inline-block;
  318. width: 70%;
  319. overflow: hidden;
  320. white-space: nowrap;
  321. text-overflow: ellipsis;
  322. color: #333;
  323. font-size: 0.15rem;
  324. }
  325. .frame_title > span:nth-child(2) {
  326. float: right;
  327. color: #2680EB;
  328. padding: 0.1rem 0 0 0;
  329. }
  330. .frame_number {
  331. padding: 0.05rem 0;
  332. color: #999;
  333. }
  334. .frame_label {
  335. padding: 0 0 0.05rem 0;
  336. }
  337. .frame_label > span {
  338. display: inline-block;
  339. overflow: hidden;
  340. white-space: nowrap;
  341. text-overflow: ellipsis;
  342. color: #888;
  343. }
  344. .frame_label > span:nth-child(1) {
  345. width: 40%;
  346. float: left;
  347. }
  348. .frame_label > span:nth-child(2) {
  349. width: 30%;
  350. float: left;
  351. text-align: right;
  352. }
  353. .frame_label > span:nth-child(3) {
  354. width: 30%;
  355. text-align: right;
  356. }
  357. .frame_label > span > span {
  358. color: #555;
  359. font-size: 0.13rem;
  360. }
  361. .frame_detail {
  362. text-align: right;
  363. padding: 0 0.01rem 0.05rem;
  364. color: #2680EB;
  365. font-size: 0.13rem;
  366. }
  367. .assDel {
  368. padding: 0.12rem 0.1rem;
  369. }
  370. .assDel_List {
  371. padding-top: 0;
  372. }
  373. .assDel_Status span {
  374. display: inline-block;
  375. text-align: center;
  376. width: 24%;
  377. color: #aaa;
  378. font-size: 0.15rem;
  379. }
  380. .assDel_Status span.active {
  381. color: #26a2ff;
  382. }
  383. .assDel_Head img {
  384. float: right;
  385. width: 0.2rem;
  386. height: 0.2rem;
  387. }
  388. .one_assDel {
  389. /* padding: 0 0.1rem; */
  390. margin: 0 0 0.15rem 0;
  391. }
  392. .mint-cell-wrapper {
  393. padding: 0;
  394. }
  395. .one_assDel_head {
  396. width: 100%;
  397. }
  398. .one_assDel_body {
  399. width: 100%;
  400. }
  401. .one_assDel_head > span {
  402. display:inline-block;
  403. vertical-align: middle;
  404. color: #666;
  405. line-height: 0.4rem;
  406. }
  407. .one_assDel_head > span:nth-child(1){
  408. width: 85%;
  409. font-size: 0.15rem;
  410. overflow: hidden;
  411. white-space: nowrap;
  412. text-overflow: ellipsis;
  413. }
  414. .one_assDel_head > span:nth-child(2){
  415. float: right;
  416. }
  417. .one_assDel_body span {
  418. /* display:inline-block; */
  419. color: #aaa;
  420. vertical-align: middle;
  421. }
  422. .one_assDel_body img {
  423. float: right;
  424. width: 0.25rem;
  425. height: 0.25rem;
  426. vertical-align: middle;
  427. }
  428. .new_title {
  429. width: 100%;
  430. }
  431. .new_label {
  432. width: 100%;
  433. }
  434. .new_title > span {
  435. padding: 0.12rem 0;
  436. display: inline-block;
  437. vertical-align: bottom;
  438. }
  439. .new_title > span:nth-child(1) {
  440. max-width: 40%;
  441. overflow: hidden;
  442. white-space: nowrap;
  443. text-overflow: ellipsis;
  444. color: #333;
  445. font-size: 0.15rem;
  446. }
  447. .new_title > span:nth-child(2) {
  448. max-width: 40%;
  449. overflow: hidden;
  450. white-space: nowrap;
  451. text-overflow: ellipsis;
  452. }
  453. .new_title > span:nth-child(3) {
  454. float: right;
  455. color: #2680EB;
  456. }
  457. .new_label > span {
  458. display: inline-block;
  459. padding: 0 0 0.05rem 0;
  460. width: 49%;
  461. overflow: hidden;
  462. white-space: nowrap;
  463. text-overflow: ellipsis;
  464. }
  465. .new_label > span > span {
  466. color: #555;
  467. font-size: 0.13rem;
  468. }
  469. </style>
  470. <style>
  471. .detail_head .mint-header-title {
  472. font-weight: 600;
  473. font-size: 0.15rem;
  474. }
  475. .detail_head .mint-button-text {
  476. color: #26a2ff;
  477. }
  478. .detailBox .mint-cell {
  479. padding: 0 0 0 0.02rem;
  480. }
  481. .one_assDel .mint-cell-value {
  482. display: block;
  483. width: 100%;
  484. }
  485. .one_assDel .mint-cell:last-child {
  486. background-image: none;
  487. }
  488. .one_assDel .mint-cell-wrapper {
  489. background-image: none;
  490. }
  491. .one_assDel .mint-cell-swipe-button {
  492. line-height: 0.55rem;
  493. }
  494. .one_assDel .noName .mint-cell-swipe-button {
  495. line-height: 48px;
  496. }
  497. .isFrame .mint-cell-swipe-button {
  498. line-height: 0.83rem;
  499. }
  500. </style>