assets.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. <template>
  2. <div id="allocation">
  3. <div class="head">
  4. <div class="searchbox">
  5. <img src="../../assets/image/search.png" class="searchbox_img">
  6. <input type="text" v-model="keyWord" class="searchbox_text" />
  7. <button v-on:click="searchKeyword()" class="searchbox_button">搜索</button>
  8. </div>
  9. <div class="btn_body">
  10. <img v-on:click.stop="showList()" class="btn_img" src="../../assets/image/add.png">
  11. <div class="btn_list" v-show="popupVisible">
  12. <!-- <div v-on:click="toTest()">扫描二维码</div> -->
  13. <!-- <img src="../../assets/image/export.png"> -->
  14. <div v-if="power.indexOf('registered_assets') > -1" v-on:click="register()">登记资产</div>
  15. <!-- <img src="../../assets/image/register.png"> -->
  16. <div v-on:click="exportExcel()">导出报表</div>
  17. <!-- <img src="../../assets/image/export.png"> -->
  18. </div>
  19. </div>
  20. <div class="searchkey">
  21. <div class="searchkey_word">
  22. <a v-for="(item,index) in labels" :id="'tag' + item.id" v-bind:class="{'active':item.id==tagId}" v-on:click="chooseTag(item.id,1)">{{item.name}}</a>
  23. </div>
  24. <div class="searchkey_btn">
  25. <img v-on:click="showFilter()" src="../../assets/image/pull_down.png">
  26. </div>
  27. </div>
  28. </div>
  29. <section class="_sorting-address">
  30. <ul class="address_first">
  31. <li v-for="(item,index) in labels" :id="'btn'+item.id" v-bind:class="{'active':item.id==tagId}" v-on:click="chooseTag(item.id,0)">{{item.name}}</li>
  32. </ul>
  33. </section>
  34. <div class="body">
  35. <div class="noList" v-if="list.length==0">
  36. <img src="../../assets/image/noList.png">
  37. </div>
  38. <ul v-else v-infinite-scroll="loadMore" infinite-scroll-disabled="loading" infinite-scroll-distance="10">
  39. <li v-for="item in list" v-on:click="jumpTo(item.id)">
  40. <div class="item_img">
  41. <img v-if="item.pic != null" v-lazy="item.pic">
  42. <img v-else src="../../assets/image/noPic.png">
  43. </div>
  44. <div class="text item_name">{{item.name}}</div>
  45. <div class="text item_int">{{item.modelNumber}}</div>
  46. <div class="text item_num">{{item.goodsNosVO.length}}{{item.unit}}</div>
  47. </li>
  48. <div class="order" v-if="haveMore">
  49. <span class="line"></span>
  50. <span class="txt">没有更多了</span>
  51. <span class="line"></span>
  52. </div>
  53. </ul>
  54. </div>
  55. </div>
  56. </template>
  57. <script>
  58. import util from '../../common/js/util'
  59. export default {
  60. data() {
  61. return {
  62. keyWord: "",
  63. power: sessionStorage.getItem("power"),
  64. list: [],
  65. labels: [],
  66. pageNum: 1,
  67. pages: 1,
  68. tagId: sessionStorage.assetsTab==null?-1:sessionStorage.assetsTab,
  69. popupVisible: false,
  70. loading: false,
  71. haveMore: false,
  72. }
  73. },
  74. methods: {
  75. // 资产列表
  76. getList() {
  77. this.$indicator.open();
  78. var from = {
  79. 'keyName': this.keyWord,
  80. 'pageNum': 1
  81. }
  82. if(this.tagId != -1) {
  83. from.tagId = this.tagId
  84. }
  85. this.http.post(this.port.assets.list, from,
  86. res => {
  87. this.$indicator.close();
  88. if (res.code == "ok") {
  89. this.list = res.data.list;
  90. this.pages = res.data.pages==0?1:res.data.pages;
  91. document.querySelector("#tag"+this.tagId).scrollIntoView(true);
  92. } else {
  93. this.$toast({
  94. message: res.msg,
  95. duration: 2000
  96. });
  97. }
  98. }, error => {
  99. this.$indicator.close();
  100. this.$toast({
  101. message: error,
  102. duration: 2000
  103. });
  104. })
  105. },
  106. loadMore() {
  107. if(this.pageNum == this.pages) {
  108. this.haveMore = true;
  109. } else if(this.pageNum < this.pages) {
  110. this.$indicator.open();
  111. this.http.post(this.port.assets.list, {
  112. 'keyName': this.keyWord,
  113. 'tagId': this.tagId==-1?"":this.tagId,
  114. 'pageNum': ++this.pageNum
  115. } ,
  116. res => {
  117. this.$indicator.close();
  118. if (res.code == "ok") {
  119. this.pages = res.data.pages==0?1:res.data.pages;
  120. if(res.data.list.length != 0) {
  121. for(var i in res.data.list) {
  122. this.list.push(res.data.list[i]);
  123. }
  124. }
  125. } else {
  126. this.$toast({
  127. message: res.msg,
  128. duration: 2000
  129. });
  130. }
  131. }, error => {
  132. this.$indicator.close();
  133. this.$toast({
  134. message: error,
  135. duration: 2000
  136. });
  137. })
  138. }
  139. },
  140. // 标签列表
  141. getLabels() {
  142. this.http.post(this.port.label.list, {} ,
  143. res => {
  144. if (res.code == "ok") {
  145. this.pageNum = 1;
  146. this.getList();
  147. var array = [{"id":-1 , "name": "全部"}];
  148. for(var i in res.data) {
  149. array.push(res.data[i]);
  150. }
  151. this.labels = array;
  152. } else {
  153. this.$toast({
  154. message: res.msg,
  155. duration: 2000
  156. });
  157. }
  158. }, error => {
  159. this.$toast({
  160. message: error,
  161. duration: 2000
  162. });
  163. })
  164. },
  165. // 关键词搜索
  166. searchKeyword() {
  167. this.pageNum = 1;
  168. this.getList();
  169. },
  170. // 右上角按钮
  171. showList() {
  172. this.popupVisible = !this.popupVisible;
  173. },
  174. // 标签筛选
  175. showFilter() {
  176. $("._sorting-medical").removeClass("fixed-top");
  177. if($("._sorting-address").hasClass("fixed-top")){
  178. $(".searchkey_btn img").removeClass("rotate")
  179. $(".searchkey_btn img").addClass("rotate1")
  180. $(this).removeClass("current");
  181. $("._sorting-address").removeClass("fixed-top");
  182. $('._navbar').attr('style','position: fixed;top:0;');
  183. }else{
  184. $(".searchkey_btn img").removeClass("rotate1")
  185. $(".searchkey_btn img").addClass("rotate")
  186. $("._sorting-address").addClass("fixed-top");
  187. $(this).addClass("current");
  188. $("._current-medical").removeClass("current");
  189. $('._navbar').attr('style','position: fixed;top:0;');
  190. }
  191. },
  192. // 标签选择
  193. chooseTag(id,type) {
  194. $("#"+id).addClass("active").siblings("a").removeClass("active");
  195. $("#btn"+id).addClass("active").siblings().removeClass("active");
  196. // location.href = "#" + id;
  197. document.querySelector("#tag"+id).scrollIntoView(true);
  198. sessionStorage.assetsTab = id;
  199. $("._sorting-medical").removeClass("fixed-top");
  200. $(".searchkey_btn img").removeClass("rotate")
  201. $(".searchkey_btn img").addClass("rotate1")
  202. $(this).removeClass("current");
  203. $("._sorting-address").removeClass("fixed-top");
  204. $('._navbar').attr('style','position: fixed;top:0;');
  205. this.pageNum = 1;
  206. this.pages = 1;
  207. this.tagId = id;
  208. this.getList();
  209. },
  210. jumpTo(id) {
  211. this.$router.push("/detail/" + id);
  212. },
  213. register() {
  214. this.$router.push("/assetsRegister");
  215. },
  216. toTest() {
  217. this.$router.push("/test");
  218. },
  219. exportExcel() {
  220. this.$indicator.open();
  221. this.http.downloadFile(this.port.assets.listExcel, {
  222. 'keyName': this.keyWord,
  223. 'tagId': this.tagId==-1?"":this.tagId,
  224. } ,
  225. res => {
  226. this.$indicator.close();
  227. let url = window.URL.createObjectURL(new Blob([res]))
  228. let link = document.createElement('a')
  229. link.style.display = 'none'
  230. link.href = url
  231. link.setAttribute('download', '资产报表.xls')
  232. document.body.appendChild(link)
  233. link.click()
  234. }, error => {
  235. this.$indicator.close();
  236. this.$toast({
  237. message: error,
  238. duration: 2000
  239. });
  240. })
  241. },
  242. globalClick(callback) {
  243. var _this = this;
  244. document.getElementById('allocation').onclick = function () {
  245. _this.popupVisible = false;
  246. }
  247. }
  248. },
  249. created() {
  250. this.getLabels();
  251. },
  252. mounted() {
  253. this.globalClick();
  254. }
  255. }
  256. </script>
  257. <style scoped>
  258. /* 头部搜索框、筛选栏 START */
  259. .head {
  260. position: fixed;
  261. width: 100%;
  262. box-sizing:border-box;
  263. padding: 0.07rem 0.15rem 0 0.15rem;
  264. background: #ffffff;
  265. border-bottom: 1px solid #dfdfdf;
  266. z-index: 105;
  267. }
  268. .searchbox {
  269. display: inline-block;
  270. /* width: 75%; */
  271. width: 88%;
  272. position: relative;
  273. vertical-align: middle;
  274. }
  275. .searchbox img.searchbox_img {
  276. width:0.18rem;
  277. height: 0.18rem;
  278. position: absolute;
  279. left: 0.04rem;
  280. top: 0.05rem;
  281. }
  282. .searchbox input.searchbox_text {
  283. font-size: 0.16rem;
  284. height: 0.28rem;
  285. border-style:none;
  286. border: 1px solid #2680EB;
  287. border-radius: 50px;
  288. box-sizing:border-box;
  289. width: 100%;
  290. padding: 0 0.45rem 0 0.33rem;
  291. }
  292. input.searchbox_text:focus{
  293. outline: none;
  294. }
  295. .searchbox button.searchbox_button {
  296. border: 0;
  297. background-color: transparent;
  298. outline: none;
  299. height: 0.28rem;
  300. font-size: 0.13rem;
  301. background: #2680EB;
  302. color: #fff;
  303. border-radius: 50px;
  304. padding: 0 0.12rem;
  305. position: absolute;
  306. right: -0.01rem;
  307. top: 0;
  308. }
  309. .btn_body {
  310. display: inline-block;
  311. float: right;
  312. position: relative;
  313. margin-top: 0.03rem;
  314. }
  315. .btn_img {
  316. float: right;
  317. width: 0.25rem;
  318. vertical-align: middle;
  319. }
  320. .btn_list {
  321. position: absolute;
  322. right: 0;
  323. top: 0.37rem;
  324. border:#aaa;
  325. background: #fcfcfc;
  326. box-shadow: 5px 5px 10px #ccc;
  327. z-index: 105;
  328. }
  329. .btn_list:before {
  330. display: inline-block;
  331. width: 0;
  332. height: 0;
  333. border: solid transparent;
  334. border-width: 10px;
  335. border-bottom-color: #fcfcfc;
  336. content: "";
  337. position: absolute;
  338. top: -20px;
  339. right: 0.06rem;
  340. }
  341. .btn_list > div {
  342. width: 0.8rem;
  343. font-size: 0.13rem;
  344. padding: 0.1rem 0.15rem;
  345. border-bottom: 1px solid #efefef;
  346. text-align: center;
  347. }
  348. .btn_list > div img {
  349. width: 0.14rem;
  350. height: 0.14rem;
  351. vertical-align: middle;
  352. margin-right: 0.05rem;
  353. }
  354. .btn_list > div span {
  355. height: 0.15rem;
  356. line-height: 0.15rem;
  357. vertical-align: middle;
  358. }
  359. .searchkey {
  360. height: 0.35rem;
  361. line-height: 0.35rem;
  362. margin-top: 0.08rem;
  363. }
  364. .searchkey .searchkey_word {
  365. width: 93%;
  366. display: inline-block;
  367. overflow-x: auto;
  368. white-space: nowrap;
  369. vertical-align: middle;
  370. }
  371. .searchkey .searchkey_word::-webkit-scrollbar {
  372. display:none
  373. }
  374. .searchkey .searchkey_word a {
  375. font-size: 0.13rem;
  376. padding: 0 0.05rem;
  377. color: #333;
  378. text-decoration:none;
  379. }
  380. .searchkey .searchkey_word a.active {
  381. color: #2680EB;
  382. }
  383. .searchkey .searchkey_btn {
  384. display: inline-block;
  385. width: 7%;
  386. height: 100%;
  387. float: right;
  388. }
  389. .searchkey .searchkey_btn img {
  390. width: 0.25rem;
  391. /* height: 0.3rem; */
  392. vertical-align: middle;
  393. }
  394. .address_first .current{
  395. background:#eee;
  396. color: #6f83ff;
  397. border-left: 2px solid #6f83ff;
  398. }
  399. ._sorting-address {
  400. position:fixed;
  401. top: -50%;
  402. width: 100%;
  403. height: 50%;
  404. z-index: 1;
  405. -webkit-transition-duration: 0.4s;
  406. background: #fff;
  407. }
  408. ._sorting-address>ul {
  409. margin: 0;
  410. padding: 0;
  411. overflow: auto;
  412. height: 100%;
  413. width: 100%;
  414. -webkit-transition-duration: 0.4s;
  415. box-sizing:border-box;
  416. padding: 0.08rem 0.1rem;
  417. }
  418. ._sorting-address>ul>li {
  419. display: inline-block;
  420. height: 0.2rem;
  421. line-height: 0.2rem;
  422. font-size: 0.14rem;
  423. color: #ccc;
  424. margin: 0.02rem 0.03rem 0.08rem;
  425. border: 1px solid #ccc;
  426. border-radius: 50px;
  427. width: 0.76rem;
  428. text-align: center;
  429. overflow: hidden;
  430. text-overflow: ellipsis;
  431. }
  432. ._sorting-address>ul>li.active {
  433. border: 1px solid #2680EB;
  434. color: #2680EB;
  435. }
  436. ._sorting-address>ul.address_first {
  437. background: #fff;
  438. position: absolute;
  439. z-index: 1;
  440. border: 1px solid #ddd;
  441. box-shadow: 5px 5px 10px #ddd;
  442. }
  443. .fixed-top{
  444. top: 0.77rem;
  445. }
  446. .fixed-top::after{
  447. content: "";
  448. width: 100%;
  449. height: 100%;
  450. display: block;
  451. background:rgba(0,0,0,0.2);
  452. }
  453. .rotate {
  454. transform-origin: center center;
  455. transform: rotate(180deg);
  456. -webkit-transform: rotate(180deg);
  457. -moz-transform: rotate(180deg);
  458. -ms-transform: rotate(180deg);
  459. -o-transform: rotate(180deg);
  460. transition: transform 0.2s;
  461. -moz-transition: -moz-transform 0.2s;
  462. -moz-transition: -moz-transform 0.2s;
  463. -o-transition: -o-transform 0.2s;
  464. -ms-transition: -ms-transform 0.2s;
  465. }
  466. .rotate1 {
  467. transform-origin: center center;
  468. transform: rotate(0deg);
  469. -webkit-transform: rotate(0deg);
  470. -moz-transform: rotate(0deg);
  471. -ms-transform: rotate(0deg);
  472. -o-transform: rotate(0deg);
  473. transition: transform 0.2s;
  474. -moz-transition: -moz-transform 0.2s;
  475. -moz-transition: -moz-transform 0.2s;
  476. -o-transition: -o-transform 0.2s;
  477. -ms-transition: -ms-transform 0.2s;
  478. }
  479. /* 头部搜索框、筛选栏 END */
  480. /* 列表页 START */
  481. .body {
  482. -webkit-box-flex: 1;
  483. -webkit-flex: 1;
  484. -ms-flex: 1;
  485. flex: 1;
  486. width: 100%;
  487. padding: 0.81rem 0 0 0;
  488. /* height: calc(100% - 0.4rem); */
  489. height: calc(100% - 0.8rem);
  490. overflow-y: auto;
  491. background: #EFEFEF;
  492. }
  493. .body > ul {
  494. padding: 0 0.12rem;
  495. margin-top: 0;
  496. }
  497. .body > ul li {
  498. display: inline-block;
  499. width: 1.5rem;
  500. padding: 0.08rem 0.05rem;
  501. background: #fff;
  502. margin: 0.06rem 0.04rem;
  503. border-radius: 10px;
  504. }
  505. .body > ul li .item_img img {
  506. width: 1.5rem;
  507. height: 1.5rem;
  508. }
  509. .body > ul li .text {
  510. height: 0.23rem;
  511. line-height: 0.23rem;
  512. margin: 0.02rem 0 0 0;
  513. white-space: nowrap;
  514. overflow: hidden;
  515. text-overflow: ellipsis;
  516. }
  517. .body > ul li .item_int {
  518. color: #B5B5B5;
  519. font-size: 0.12rem;
  520. }
  521. .body > ul li .item_num {
  522. color: #448DE4;
  523. font-weight: 600;
  524. }
  525. .noList {
  526. text-align: center;
  527. padding: 1.5rem 0;
  528. }
  529. .noList img {
  530. width: 1.2rem;
  531. height: 1.2rem;
  532. }
  533. .order {
  534. height: 0.6rem;
  535. line-height: 0.6rem;
  536. text-align: center;
  537. }
  538. .order .line {
  539. display: inline-block;
  540. width: 1.2rem;
  541. border-top: 1px solid #ccc ;
  542. vertical-align: middle;
  543. }
  544. .order .txt {
  545. color: #ccc;
  546. font-size: 0.13rem;
  547. vertical-align: middle;
  548. }
  549. /* 列表页 END */
  550. </style>