assets.vue 17 KB

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