equipmentRetrieval.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  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. departmentId:{
  112. default: ""
  113. },
  114. queryStatus:{
  115. default: 0
  116. },
  117. iscomponents:{
  118. default: ""
  119. },
  120. isreturn:{
  121. default: ""
  122. },
  123. list:{
  124. default: () => [],
  125. },
  126. scanList:{
  127. default: () => [],
  128. },
  129. },
  130. data() {
  131. return {
  132. customStyle:{
  133. height: "60rpx",
  134. lineHeight: "60rpx",
  135. marginTop: "3px"
  136. },
  137. styleheight:"",
  138. queryContent:"",
  139. queryContentBl:false,
  140. checkindex: 0,
  141. indexList:[],
  142. form:{
  143. pageIndex:1,
  144. pageSize:20,
  145. list:[]
  146. },
  147. menuList: [
  148. ]
  149. }
  150. },
  151. computed:{
  152. listcurrentlist(){
  153. if(this.menuList.length==0){
  154. return []
  155. }
  156. var list=this.menuList[this.checkindex].list
  157. if(list){
  158. return list
  159. }else{
  160. return []
  161. }
  162. }
  163. },
  164. mounted() {
  165. if(this.isreturn){
  166. if(this.isreturn){
  167. var sz=[
  168. {
  169. typeId:"-$jp%-0",
  170. name:"未归还设备",
  171. list:[],
  172. pageIndex:1,
  173. pageSize:10,
  174. recordsTotal:0
  175. },
  176. // {
  177. // typeId:"-$jp%-1",
  178. // name:"借出历史",
  179. // list:[],
  180. // pageIndex:1,
  181. // pageSize:10,
  182. // recordsTotal:0
  183. // },
  184. ]
  185. this.menuList = [
  186. ...sz,
  187. ]
  188. uni.hideLoading();
  189. if(this.menuList.length>0){
  190. this.getList()
  191. }
  192. //this.getList()
  193. }
  194. }else{
  195. this.getDeviceTypeList();
  196. }
  197. },
  198. onReady() {
  199. //this.getList()
  200. },
  201. onReachBottom() {
  202. console.log(1)
  203. this.myLoadmoreonReachBottom()
  204. },
  205. methods: {
  206. init(){
  207. this.menuList[this.checkindex].pageIndex=1
  208. this.indexList=[]
  209. this.getList()
  210. },
  211. myLoadmoreonReachBottom(){
  212. var obj=this.menuList[this.checkindex]
  213. if(this.queryContentBl){
  214. obj=this.form;
  215. }
  216. console.log(obj)
  217. if (this.indexList.length < obj.recordsTotal) {
  218. this.myLoadmore();
  219. }
  220. },
  221. getMenuListName(id){
  222. var obj =this.menuList.filter(item=>{
  223. return id==item.typeId;
  224. })
  225. if(obj.length){
  226. return obj[0].name
  227. }
  228. },
  229. getDeviceTypeList(){
  230. uni.showLoading({
  231. title: "加载中",
  232. mask: true,
  233. })
  234. API.deviceTypeList({}).then((res) => {
  235. var menuList = res.data.deviceTypeList.map(item=>{
  236. return {
  237. typeId:item.id,
  238. name:item.name,
  239. list:[],
  240. pageIndex:1,
  241. pageSize:10,
  242. recordsTotal:0
  243. }
  244. });
  245. var sz=[]
  246. //
  247. this.menuList = [
  248. ...sz,
  249. ...menuList
  250. ]
  251. uni.hideLoading();
  252. if(this.menuList.length>0){
  253. this.getList()
  254. }
  255. }).catch(error => {
  256. uni.showToast({
  257. title: error
  258. })
  259. })
  260. },
  261. viewItem(item){
  262. if(this.iscomponents==1){
  263. }else{
  264. uni.navigateTo({
  265. url:"./equipmentDetail?name="+item.title+"&model="+item.model+"&specifications="+item.specifications
  266. })
  267. }
  268. },
  269. viewInfo(item){
  270. if(item.code){
  271. uni.navigateTo({
  272. url:"/pages/otherFunctions/equipmentRetrieval/equipmentInfo?id="+item.id
  273. })
  274. }else{
  275. uni.navigateTo({
  276. url:"/pages/otherFunctions/equipmentRetrieval/equipmentDetail?name="+item.title+"&model="+item.model+"&specifications="+item.specifications
  277. })
  278. }
  279. },
  280. deterItem(item){
  281. var c=""
  282. if(item.code){
  283. c=this.scanList.find(it=>{
  284. return it.id==item.id
  285. })
  286. }else{
  287. c=this.list.find(it=>{
  288. return it.obj.id==item.id
  289. })
  290. }
  291. if(c){
  292. return true
  293. }else{
  294. return false
  295. }
  296. },
  297. ckItem(item){
  298. console.log(this.scanList)
  299. this.$emit('ckItem',item)
  300. },
  301. myLoadmore(){
  302. if(this.queryContentBl){
  303. this.form.pageIndex += 1;
  304. }else{
  305. this.menuList[this.checkindex].pageIndex += 1;
  306. }
  307. this.getList();
  308. },
  309. getList(){
  310. uni.showLoading({
  311. title: "加载中",
  312. mask: true,
  313. })
  314. this.datainit()
  315. var list=this.indexList
  316. var data = this.menuList[this.checkindex];
  317. if(this.queryContent){
  318. //this.queryContentBl=true
  319. // 删除类型 delete data.list;
  320. data=this.form
  321. data.queryContent=this.queryContent;
  322. }else{
  323. //this.queryContentBl=false
  324. }
  325. delete data.list;
  326. if(["-$jp%-0","-$jp%-1"].indexOf(data.typeId)!=-1){
  327. if(this.queryContent){
  328. }else{
  329. this.queryContentBl=false
  330. }
  331. if(data.typeId=="-$jp%-0"){
  332. data.departmentId=this.departmentId;
  333. data.queryStatus=!this.queryStatus?1:0
  334. API.outDeviceByUser(data).then((res) => {
  335. if(data.pageIndex==1){
  336. list = res.data.outDeviceList.data;
  337. }else{
  338. list = [
  339. ...list,
  340. ...res.data.outDeviceList.data
  341. ];
  342. }
  343. this.menuList[this.checkindex].list=list
  344. this.menuList[this.checkindex].recordsTotal = res.data.outDeviceList.recordsTotal;
  345. this.form.recordsTotal = res.data.outDeviceList.recordsTotal;
  346. this.indexList=list;
  347. uni.hideLoading();
  348. }).catch(error => {
  349. uni.showToast({
  350. title: error
  351. })
  352. })
  353. }
  354. if(data.typeId=="-$jp%-1"){
  355. //废弃
  356. }
  357. }else{
  358. if(this.isreturn){
  359. data.queryAll=1
  360. }
  361. API.deviceList(data).then((res) => {
  362. if(data.pageIndex==1){
  363. list = res.data.data;
  364. }else{
  365. list = [
  366. ...list,
  367. ...res.data.data
  368. ];
  369. }
  370. if(this.queryContent){
  371. this.queryContentBl=true
  372. }else{
  373. this.queryContentBl=false
  374. this.menuList[this.checkindex].list=list
  375. this.menuList[this.checkindex].recordsTotal = res.data.recordsTotal;
  376. }
  377. this.form.recordsTotal = res.data.recordsTotal;
  378. this.indexList=list;
  379. //console.log(this.form.recordsTotal ,list.length)
  380. uni.hideLoading();
  381. }).catch(error => {
  382. uni.showToast({
  383. title: error
  384. })
  385. })
  386. }
  387. },
  388. datainit(){
  389. // var data = this.menuList[this.checkindex];
  390. // if(!data.pageIndex){
  391. // this.menuList[this.checkindex].pageIndex=1;
  392. // this.menuList[this.checkindex].pageSize=10
  393. // this.menuList[this.checkindex].recordsTotal=0;
  394. // this.menuList[this.checkindex].list=[]
  395. // }
  396. },
  397. toggle(index) {
  398. this.checkindex = index
  399. this.datainit()
  400. var list=this.menuList[this.checkindex].list
  401. this.indexList=list;
  402. if(list.length==0){
  403. this.getList()
  404. }
  405. },
  406. back(){
  407. this.$refs.navbar.goBack()
  408. }
  409. },
  410. }
  411. </script>
  412. <style scoped lang="scss">
  413. page {
  414. background-color: #fff;
  415. }
  416. .iscomponents ::v-deep .u-search{
  417. width: 630rpx !important;
  418. }
  419. // 搜索
  420. .search {
  421. padding: 12rpx 24rpx;
  422. border-radius: 8px;
  423. overflow: hidden;
  424. .search-box {
  425. border-radius: 8px;
  426. overflow: hidden;
  427. }
  428. .u-search {
  429. margin: auto !important;
  430. position: relative;
  431. flex: 0;
  432. margin: 0 !important;
  433. height: 64rpx !important;
  434. }
  435. ::v-deep .u-content {
  436. border-radius: 0px !important;
  437. height: 64rpx !important;
  438. }
  439. ::v-deep .u-icon--right {
  440. margin-right: 16rpx;
  441. }
  442. .search-btn {
  443. width: 100rpx;
  444. height: 64rpx;
  445. background-color: #f2f2f2;
  446. .text {
  447. height: 40rpx;
  448. margin: 12rpx 0;
  449. border-left: 1px solid #999999;
  450. font-family: Microsoft Yahei;
  451. text-align: center;
  452. color: rgba(16, 98, 213, 1);
  453. font-size: 28rpx;
  454. }
  455. }
  456. }
  457. .calc10080{
  458. //height: calc(95vh - 90px);
  459. }
  460. .calc10081{
  461. //height: calc(95vh - 90px);
  462. height:800rpx
  463. }
  464. .calc10082{
  465. height: calc(95vh - 90px);
  466. //height:750rpx
  467. }
  468. .main {
  469. display: flex;
  470. // 分类
  471. .classify {
  472. width: 170rpx;
  473. background-color: #F0F0F0;
  474. overflow-y: scroll;
  475. font-size: 28rpx;
  476. .item {
  477. height: 120rpx;
  478. line-height: 120rpx;
  479. text-align: center;
  480. }
  481. .checked {
  482. background-color: #fff;
  483. color: #1062D5
  484. }
  485. }
  486. // 类型
  487. .typeAll{
  488. width: 750rpx !important;
  489. }
  490. .type{
  491. width: 580rpx;
  492. padding: 24rpx 24rpx;
  493. overflow-y: scroll;
  494. .type-item{
  495. //margin-bottom: 80rpx;
  496. }
  497. .title{
  498. color: rgba(51, 51, 51, 1);
  499. font-size: 32rpx;
  500. margin-bottom: 24rpx;
  501. }
  502. .content{
  503. .item{
  504. display: flex;
  505. margin-bottom: 28rpx;
  506. border-bottom: 1px dashed;
  507. .option{
  508. padding-left: 20rpx;
  509. }
  510. .picture{
  511. width: 120rpx;
  512. height: 120rpx;
  513. border-radius: 8rpx;
  514. overflow: hidden;
  515. img{
  516. width: 100rpx;
  517. height: 100%;
  518. }
  519. }
  520. .infosQuery{
  521. width:400rpx !important;
  522. }
  523. .infos{
  524. width:200rpx ;
  525. margin-left: 16rpx;
  526. .name{
  527. color: rgba(51, 51, 51, 1);
  528. font-size: 32rpx;
  529. margin-bottom: 8rpx;
  530. }
  531. .model{
  532. color: rgba(153, 153, 153, 1);
  533. font-size: 24rpx;
  534. display: flex;
  535. //margin-bottom: 8rpx;
  536. }
  537. .inventory{
  538. color: rgba(153, 153, 153, 1);
  539. font-size: 24rpx;
  540. display: flex;
  541. margin-bottom: 8rpx;
  542. }
  543. .infos-title{
  544. width: 88rpx;
  545. min-width: 88rpx;
  546. }
  547. }
  548. }
  549. }
  550. }
  551. }
  552. </style>