equipmentRetrieval.vue 8.4 KB

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