assets.vue 17 KB

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