equipmentRetrieval.vue 8.5 KB

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