equipmentRetrieval.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. <template>
  2. <view style="background-color: #fff;" :class="{
  3. iscomponents:iscomponents==1
  4. }">
  5. <u-navbar title="设备检索" ref="navbar" v-if="iscomponents!=1" ></u-navbar>
  6. <!-- 搜索 -->
  7. <view class="search" v-if="iscomponents!=1" >
  8. <!-- <u-icon name="arrow-left" @click="back()" size="36"></u-icon> -->
  9. <view class="search-box">
  10. <u-search :show-action="true" class="u-search" @custom="form.pageIndex=1,getList()"
  11. v-model="queryContent" @search="form.pageIndex=1,getList()"
  12. placeholder="搜索设备名称或型号"
  13. action-text="搜索" :animation="true"></u-search>
  14. <!-- <u-search class="u-search" placeholder="搜索设备名称或型号" v-model="queryContent" :show-action="false">
  15. </u-search>
  16. -->
  17. </view>
  18. </view>
  19. <view class="main">
  20. <!-- 分类 -->
  21. <view class="classify calc10080 " v-if="!queryContentBl&&!isreturn">
  22. <scroll-view scroll-y="true" :class="iscomponents!=1?'calc10082':'calc10081'" >
  23. <view class="item " v-for="(item,index) in menuList" :key="index" @click="toggle(index)"
  24. :class="{'checked':index ==checkindex }">
  25. {{item.name}}<br/>
  26. </view>
  27. </scroll-view>
  28. </view>
  29. <!-- 类型 -->
  30. <view class="type calc10080" :class="queryContentBl||isreturn?'typeAll':''" >
  31. <view class="type-item">
  32. <!-- <view class="title" v-for="item in 4">
  33. 设备类型一
  34. </view> -->
  35. <scroll-view scroll-y="true" :class="iscomponents!=1?'calc10082':'calc10081'" @scrolltolower="myLoadmoreonReachBottom()">
  36. <view class="content" >
  37. <view class="item" v-for="(item,i) in indexList" @click="viewItem(item)" :key="i">
  38. <view class="picture">
  39. <img :src="item.imgUrl" alt="">
  40. </view>
  41. <view class="infos" :class="{
  42. infosQuery:queryContentBl||isreturn
  43. }" >
  44. <view class="name">
  45. {{item.title}}
  46. </view>
  47. <view class="model" >
  48. <view class="infos-title">
  49. 型号:
  50. </view>
  51. <view class="value">
  52. {{item.model}}
  53. </view>
  54. </view>
  55. <view class="model" v-if="item.specifications">
  56. <view class="infos-title">
  57. 规格:
  58. </view>
  59. <view class="value">
  60. {{item.specifications}}
  61. </view>
  62. </view>
  63. <view class="inventory" v-if="!item.code">
  64. <view class="infos-title">
  65. 库存:
  66. </view>
  67. <view class="value">
  68. {{item.count}}
  69. </view>
  70. </view>
  71. <view class="inventory" v-if="item.code" >
  72. <view class="value">
  73. {{showCode(item)}}
  74. </view>
  75. </view>
  76. <view class="inventory" v-if="queryContentBl">
  77. <view class="infos-title">
  78. 分类:
  79. </view>
  80. <view class="value">
  81. {{getMenuListName(item.typeId)}}
  82. </view>
  83. </view>
  84. </view>
  85. <view class="option" v-if="iscomponents==1" >
  86. <u-button v-if="deterItem(item)" @click="ckItem(item)"
  87. style="height: 48rpx;" :custom-style="customStyle"
  88. type="error" ><u-icon name="trash-fill"></u-icon>删除</u-button>
  89. <u-button v-else @click="ckItem(item)"
  90. style="height: 48rpx;" :custom-style="customStyle"
  91. type="primary" ><u-icon name="plus-circle"></u-icon>添加</u-button>
  92. <u-button @click="viewInfo(item)"
  93. style="height: 48rpx;margin-top: 6px;" :custom-style="customStyle"
  94. type="success" ><u-icon name="file-text"></u-icon>详情</u-button>
  95. </view>
  96. </view>
  97. </view>
  98. <u-divider v-if="form.recordsTotal==indexList.length"
  99. :isnone="form.recordsTotal==0" nonetext="没有找到相关内容"
  100. border-color="#CFD2D5" bg-color="#fff">已经到底了</u-divider>
  101. </scroll-view>
  102. </view>
  103. </view>
  104. </view>
  105. </view>
  106. </template>
  107. <script>
  108. import * as API from '@/apis/pagejs/index.js'
  109. export default {
  110. props:{
  111. iscomponents:{
  112. default: ""
  113. },
  114. isreturn:{
  115. default: ""
  116. },
  117. list:{
  118. default: () => [],
  119. },
  120. scanList:{
  121. default: () => [],
  122. },
  123. },
  124. data() {
  125. return {
  126. customStyle:{
  127. height: "60rpx",
  128. lineHeight: "60rpx",
  129. marginTop: "3px"
  130. },
  131. styleheight:"",
  132. queryContent:"",
  133. queryContentBl:false,
  134. checkindex: 0,
  135. indexList:[],
  136. form:{
  137. pageIndex:1,
  138. pageSize:20,
  139. list:[]
  140. },
  141. menuList: [
  142. ]
  143. }
  144. },
  145. computed:{
  146. listcurrentlist(){
  147. if(this.menuList.length==0){
  148. return []
  149. }
  150. var list=this.menuList[this.checkindex].list
  151. if(list){
  152. return list
  153. }else{
  154. return []
  155. }
  156. }
  157. },
  158. mounted() {
  159. this.getDeviceTypeList();
  160. },
  161. onReady() {
  162. //this.getList()
  163. },
  164. onReachBottom() {
  165. console.log(1)
  166. this.myLoadmoreonReachBottom()
  167. },
  168. methods: {
  169. myLoadmoreonReachBottom(){
  170. var obj=this.menuList[this.checkindex]
  171. if(this.queryContentBl){
  172. obj=this.form;
  173. }
  174. console.log(obj)
  175. if (this.indexList.length < obj.recordsTotal) {
  176. this.myLoadmore();
  177. }
  178. },
  179. getMenuListName(id){
  180. var obj =this.menuList.filter(item=>{
  181. return id==item.typeId;
  182. })
  183. if(obj.length){
  184. return obj[0].name
  185. }
  186. },
  187. getDeviceTypeList(){
  188. uni.showLoading({
  189. title: "加载中",
  190. mask: true,
  191. })
  192. API.deviceTypeList({}).then((res) => {
  193. var menuList = res.data.deviceTypeList.map(item=>{
  194. return {
  195. typeId:item.id,
  196. name:item.name,
  197. list:[],
  198. pageIndex:1,
  199. pageSize:10,
  200. recordsTotal:0
  201. }
  202. });
  203. var sz=[]
  204. if(this.isreturn){
  205. sz=[
  206. {
  207. typeId:"-$jp%-0",
  208. name:"未归还设备",
  209. list:[],
  210. pageIndex:1,
  211. pageSize:10,
  212. recordsTotal:0
  213. },
  214. // {
  215. // typeId:"-$jp%-1",
  216. // name:"借出历史",
  217. // list:[],
  218. // pageIndex:1,
  219. // pageSize:10,
  220. // recordsTotal:0
  221. // },
  222. ]
  223. }
  224. this.menuList = [
  225. ...sz,
  226. ...menuList
  227. ]
  228. uni.hideLoading();
  229. if(this.menuList.length>0){
  230. this.getList()
  231. }
  232. }).catch(error => {
  233. uni.showToast({
  234. title: error
  235. })
  236. })
  237. },
  238. viewItem(item){
  239. if(this.iscomponents==1){
  240. }else{
  241. uni.navigateTo({
  242. url:"./equipmentDetail?name="+item.title+"&model="+item.model+"&specifications="+item.specifications
  243. })
  244. }
  245. },
  246. viewInfo(item){
  247. if(item.code){
  248. uni.navigateTo({
  249. url:"/pages/otherFunctions/equipmentRetrieval/equipmentInfo?id="+item.id
  250. })
  251. }else{
  252. uni.navigateTo({
  253. url:"/pages/otherFunctions/equipmentRetrieval/equipmentDetail?name="+item.title+"&model="+item.model+"&specifications="+item.specifications
  254. })
  255. }
  256. },
  257. deterItem(item){
  258. var c=""
  259. if(item.code){
  260. c=this.scanList.find(it=>{
  261. return it.id==item.id
  262. })
  263. }else{
  264. c=this.list.find(it=>{
  265. return it.obj.id==item.id
  266. })
  267. }
  268. if(c){
  269. return true
  270. }else{
  271. return false
  272. }
  273. },
  274. ckItem(item){
  275. console.log(this.scanList)
  276. this.$emit('ckItem',item)
  277. },
  278. myLoadmore(){
  279. if(this.queryContentBl){
  280. this.form.pageIndex += 1;
  281. }else{
  282. this.menuList[this.checkindex].pageIndex += 1;
  283. }
  284. this.getList();
  285. },
  286. getList(){
  287. uni.showLoading({
  288. title: "加载中",
  289. mask: true,
  290. })
  291. this.datainit()
  292. var list=this.indexList
  293. var data = this.menuList[this.checkindex];
  294. if(this.queryContent){
  295. //this.queryContentBl=true
  296. // 删除类型 delete data.list;
  297. data=this.form
  298. data.queryContent=this.queryContent;
  299. }else{
  300. //this.queryContentBl=false
  301. }
  302. delete data.list;
  303. if(["-$jp%-0","-$jp%-1"].indexOf(data.typeId)!=-1){
  304. if(this.queryContent){
  305. }else{
  306. this.queryContentBl=false
  307. }
  308. if(data.typeId=="-$jp%-0"){
  309. API.outDeviceByUser(data).then((res) => {
  310. if(data.pageIndex==1){
  311. list = res.data.outDeviceList.data;
  312. }else{
  313. list = [
  314. ...list,
  315. ...res.data.outDeviceList.data
  316. ];
  317. }
  318. this.menuList[this.checkindex].list=list
  319. this.menuList[this.checkindex].recordsTotal = res.data.outDeviceList.recordsTotal;
  320. this.form.recordsTotal = res.data.outDeviceList.recordsTotal;
  321. this.indexList=list;
  322. uni.hideLoading();
  323. }).catch(error => {
  324. uni.showToast({
  325. title: error
  326. })
  327. })
  328. }
  329. if(data.typeId=="-$jp%-1"){
  330. //废弃
  331. }
  332. }else{
  333. if(this.isreturn){
  334. data.queryAll=1
  335. }
  336. API.deviceList(data).then((res) => {
  337. if(data.pageIndex==1){
  338. list = res.data.data;
  339. }else{
  340. list = [
  341. ...list,
  342. ...res.data.data
  343. ];
  344. }
  345. if(this.queryContent){
  346. this.queryContentBl=true
  347. }else{
  348. this.queryContentBl=false
  349. this.menuList[this.checkindex].list=list
  350. this.menuList[this.checkindex].recordsTotal = res.data.recordsTotal;
  351. }
  352. this.form.recordsTotal = res.data.recordsTotal;
  353. this.indexList=list;
  354. //console.log(this.form.recordsTotal ,list.length)
  355. uni.hideLoading();
  356. }).catch(error => {
  357. uni.showToast({
  358. title: error
  359. })
  360. })
  361. }
  362. },
  363. datainit(){
  364. // var data = this.menuList[this.checkindex];
  365. // if(!data.pageIndex){
  366. // this.menuList[this.checkindex].pageIndex=1;
  367. // this.menuList[this.checkindex].pageSize=10
  368. // this.menuList[this.checkindex].recordsTotal=0;
  369. // this.menuList[this.checkindex].list=[]
  370. // }
  371. },
  372. toggle(index) {
  373. this.checkindex = index
  374. this.datainit()
  375. var list=this.menuList[this.checkindex].list
  376. this.indexList=list;
  377. if(list.length==0){
  378. this.getList()
  379. }
  380. },
  381. back(){
  382. this.$refs.navbar.goBack()
  383. }
  384. },
  385. }
  386. </script>
  387. <style scoped lang="scss">
  388. page {
  389. background-color: #fff;
  390. }
  391. .iscomponents /deep/.u-search{
  392. width: 630rpx !important;
  393. }
  394. // 搜索
  395. .search {
  396. padding: 12rpx 24rpx;
  397. border-radius: 8px;
  398. overflow: hidden;
  399. .search-box {
  400. border-radius: 8px;
  401. overflow: hidden;
  402. }
  403. .u-search {
  404. margin: auto !important;
  405. position: relative;
  406. flex: 0;
  407. margin: 0 !important;
  408. height: 64rpx !important;
  409. }
  410. /deep/.u-content {
  411. border-radius: 0px !important;
  412. height: 64rpx !important;
  413. }
  414. /deep/.u-icon--right {
  415. margin-right: 16rpx;
  416. }
  417. .search-btn {
  418. width: 100rpx;
  419. height: 64rpx;
  420. background-color: #f2f2f2;
  421. .text {
  422. height: 40rpx;
  423. margin: 12rpx 0;
  424. border-left: 1px solid #999999;
  425. font-family: Microsoft Yahei;
  426. text-align: center;
  427. color: rgba(16, 98, 213, 1);
  428. font-size: 28rpx;
  429. }
  430. }
  431. }
  432. .calc10080{
  433. //height: calc(95vh - 90px);
  434. }
  435. .calc10081{
  436. //height: calc(95vh - 90px);
  437. height:700rpx
  438. }
  439. .calc10082{
  440. height: calc(95vh - 90px);
  441. //height:750rpx
  442. }
  443. .main {
  444. display: flex;
  445. // 分类
  446. .classify {
  447. width: 170rpx;
  448. background-color: #F0F0F0;
  449. overflow-y: scroll;
  450. font-size: 28rpx;
  451. .item {
  452. height: 120rpx;
  453. line-height: 120rpx;
  454. text-align: center;
  455. }
  456. .checked {
  457. background-color: #fff;
  458. color: #1062D5
  459. }
  460. }
  461. // 类型
  462. .typeAll{
  463. width: 750rpx !important;
  464. }
  465. .type{
  466. width: 580rpx;
  467. padding: 24rpx 24rpx;
  468. overflow-y: scroll;
  469. .type-item{
  470. //margin-bottom: 80rpx;
  471. }
  472. .title{
  473. color: rgba(51, 51, 51, 1);
  474. font-size: 32rpx;
  475. margin-bottom: 24rpx;
  476. }
  477. .content{
  478. .item{
  479. display: flex;
  480. margin-bottom: 28rpx;
  481. border-bottom: 1px dashed;
  482. .option{
  483. padding-left: 20rpx;
  484. }
  485. .picture{
  486. width: 120rpx;
  487. height: 120rpx;
  488. border-radius: 8rpx;
  489. overflow: hidden;
  490. img{
  491. width: 100rpx;
  492. height: 100%;
  493. }
  494. }
  495. .infosQuery{
  496. width:400rpx !important;
  497. }
  498. .infos{
  499. width:200rpx ;
  500. margin-left: 16rpx;
  501. .name{
  502. color: rgba(51, 51, 51, 1);
  503. font-size: 32rpx;
  504. margin-bottom: 8rpx;
  505. }
  506. .model{
  507. color: rgba(153, 153, 153, 1);
  508. font-size: 24rpx;
  509. display: flex;
  510. //margin-bottom: 8rpx;
  511. }
  512. .inventory{
  513. color: rgba(153, 153, 153, 1);
  514. font-size: 24rpx;
  515. display: flex;
  516. margin-bottom: 8rpx;
  517. }
  518. .infos-title{
  519. width: 88rpx;
  520. min-width: 88rpx;
  521. }
  522. }
  523. }
  524. }
  525. }
  526. }
  527. </style>