assetsDetailFrame.vue 16 KB

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