equipmentRetrieval.vue 9.8 KB

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