equipmentRetrieval.vue 8.8 KB

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