equipmentRetrieval.vue 12 KB

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