equipmentRetrieval.vue 8.0 KB

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