index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. <template>
  2. <view class="content-box">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="搜索" @clickLeft="back">
  4. <!--右菜单-->
  5. <template slot="right">
  6. <u-button type="success" size="small" class="u-reset-button" @click="openTreePicker"
  7. text="选择分类"></u-button>
  8. </template>
  9. </uni-nav-bar>
  10. <view class="top-wrapper">
  11. <view class="searchBox rx-bc">
  12. <input v-model="keyWord" placeholder="请输入关键字搜索" class="searchInput" />
  13. <view>
  14. <u-button @click="doSearch" type="success" size="small" class="u-reset-button" text="搜索">
  15. </u-button>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="list_box">
  20. <u-list @scrolltolower="scrolltolower">
  21. <checkbox-group v-for="(item, index) in list" :key="index" @change="e => selectVal(e, item, index)">
  22. <label class="listBox rx-bs">
  23. <view class="listBox-sel" >
  24. <checkbox v-if='item.rootCategoryLevelId != 11 || (item.rootCategoryLevelId == 11 && item.status != 1)':value="item.code" color="#fff" :disabled="item.disabled"
  25. :checked="item.checked" />
  26. </view>
  27. <view class="listBox-con">
  28. <view class="listBox-top rx-bc">
  29. <view> {{ item.name }}</view>
  30. <view class="code">{{ item.code}}</view>
  31. </view>
  32. <view class="listBox-bottom rx">
  33. <view v-for="(itm, index) in tableH(item.rootCategoryLevelId)" :key="index"
  34. class="items">
  35. {{ itm.label }}:{{ item[itm.prop] }}
  36. </view>
  37. <view class="items" v-if='item.rootCategoryLevelId != 11'>
  38. 可用库存:{{ item.availableCountBase }} {{item.unit}}
  39. </view>
  40. <view class="items" v-if='item.rootCategoryLevelId == 11'>
  41. <text :style="{ color: item.status == 0 ? '#157A2C' :'#FFA929' }" >状态:{{ item.status == 0 ? '空闲' : item.status == 1 ? '占用' : ''}}</text>
  42. </view>
  43. <view class="items" v-if='item.rootCategoryLevelId == 11'>
  44. 位置:{{ item.region }}
  45. </view>
  46. </view>
  47. </view>
  48. </label>
  49. </checkbox-group>
  50. <view v-if='list.length == 0' style='margin-top: 20vh;'>
  51. <u-empty iconSize='150' textSize='32' text='暂无数据'>
  52. </u-empty>
  53. </view>
  54. </u-list>
  55. </view>
  56. <view class="bottom-wrapper rx-bc">
  57. <view>
  58. <checkbox v-if="!seletedAll" color="#fff" :checked="seletedAll" @tap="_seletedAll">全选</checkbox>
  59. <checkbox class="select-all" color="#fff" v-else :checked="seletedAll" @tap="_seletedAll">取消全选
  60. </checkbox>
  61. </view>
  62. <view>
  63. <u-button type="success" size="small" class="u-reset-button" :disabled="!checkListLen" @click="jumpAdd">
  64. <view> 选择( {{ checkListLen }} ) </view>
  65. </u-button>
  66. </view>
  67. </view>
  68. <ba-tree-picker ref="treePicker" key="verify" :multiple="false" @select-change="confirm" title="选择分类"
  69. :localdata="classificationList" valueKey="id" textKey="name" childrenKey="children" />
  70. </view>
  71. </template>
  72. <script>
  73. import baTreePicker from '@/components/ba-tree-picker/ba-tree-picker.vue'
  74. import {
  75. tableHeader
  76. } from '../../common.js'
  77. import {
  78. treeByPid,
  79. pageeLedgerMain,
  80. assetPage
  81. } from '@/api/pda/workOrder.js'
  82. let [isEnd] = [false]
  83. export default {
  84. components: {
  85. baTreePicker,
  86. },
  87. data() {
  88. return {
  89. keyWord: null,
  90. rootCategoryLevelId: null,
  91. categoryLevelId: null,
  92. classificationList: [],
  93. treePickerShow: false,
  94. list: [],
  95. page: 1,
  96. seletedAll: false, //全选状态
  97. memoList: [],
  98. isType: null,
  99. pid: null, // 上个页面id
  100. storageKey: null,
  101. }
  102. },
  103. //选择的列表长度
  104. computed: {
  105. checkListLen() {
  106. return this.memoList.length
  107. }
  108. },
  109. onLoad(option) {
  110. this.pid = option.id
  111. this.isType = option.isType
  112. if (option.storageKey) {
  113. this.storageKey = option.storageKey
  114. this.memoList = []
  115. if (this.isType == 'feed') {
  116. let _arr = (this.storageKey && uni.getStorageSync(this.storageKey)) || []
  117. this.memoList = [..._arr[0].modelList, ..._arr[0].equipmentList, ..._arr[0].instanceList, ..._arr[0].aridRegionList, ..._arr[0].turnover]
  118. } else if (this.isType == 'pick') {
  119. this.memoList = (this.storageKey && uni.getStorageSync(this.storageKey)) || []
  120. } else if (this.isType == 'job') {
  121. let _obj = (this.storageKey && uni.getStorageSync(this.storageKey)) || {}
  122. this.memoList = [..._obj.turnover]
  123. }
  124. }
  125. this.getTreeList()
  126. },
  127. onUnload() {
  128. if (this.storageKey) {
  129. uni.removeStorage(this.storageKey)
  130. }
  131. },
  132. methods: {
  133. _seletedAll() {
  134. if (!this.seletedAll) {
  135. this.seletedAll = true
  136. this.list.map(item => {
  137. this.$set(item, 'checked', true)
  138. const idx = this.memoList.findIndex(itm => itm.id === item.id)
  139. if (idx === -1) {
  140. this.memoList.push(item)
  141. }
  142. })
  143. } else {
  144. this.seletedAll = false
  145. this.list.map(item => {
  146. this.$set(item, 'checked', false)
  147. const idx = this.memoList.findIndex(itm => itm.id === item.id)
  148. if (idx > -1) {
  149. this.memoList.splice(idx, 1)
  150. }
  151. })
  152. }
  153. },
  154. openTreePicker() {
  155. this.$refs.treePicker._show()
  156. },
  157. tableH(type) {
  158. return tableHeader(type)
  159. },
  160. getTreeList() {
  161. let params = {}
  162. if (this.isType == 'feed') {
  163. params.ids = [1, 5, 8, 10, 11, 14]
  164. } else if (this.isType == 'pick') {
  165. params.ids = [1, 5, 7, 8, 10, 14]
  166. } else if (this.isType == 'job') {
  167. params['ids'] = [ 7 ]
  168. }
  169. treeByPid(params).then(res => {
  170. this.classificationList = res
  171. this.confirm([res[0].id], res[0].name, res[0].rootCategoryLevelId)
  172. })
  173. },
  174. confirm(id, name, rootCategoryLevelId) {
  175. this.rootCategoryLevelId = rootCategoryLevelId
  176. this.categoryLevelId = id
  177. this.list = []
  178. this.getList()
  179. },
  180. doSearch() {
  181. this.list = []
  182. this.getList()
  183. },
  184. scrolltolower() {
  185. if (isEnd) return
  186. this.page++
  187. this.getList()
  188. },
  189. getList() {
  190. let param = {
  191. categoryLevelId: this.categoryLevelId,
  192. keyWord: this.keyWord,
  193. pageNum: this.page,
  194. size: 100,
  195. }
  196. if (this.rootCategoryLevelId == '11') { // 干燥区特殊处理
  197. param.size = 5
  198. }
  199. isEnd = false
  200. let URL = null
  201. if (this.isType == 'pick') { // 领料
  202. param.dimension = 1
  203. URL = pageeLedgerMain
  204. } else if (this.isType == 'feed') { // 投料
  205. URL = assetPage
  206. } else if (this.isType == 'job') { // 报工
  207. URL = assetPage
  208. }
  209. URL(param).then(res => {
  210. if (this.rootCategoryLevelId == '11') {
  211. res.list.forEach(e => {
  212. if (e.aridRegionList && e.aridRegionList.length != 0) {
  213. e.aridRegionList.map(i => {
  214. const checked =
  215. this.memoList.findIndex(itm => itm.id === i.id) > -1
  216. let obj = {
  217. checked,
  218. name: e.name,
  219. region: e.extInfo.region,
  220. rootCategoryLevelId: e.rootCategoryLevelId,
  221. ...i,
  222. instanceId: i.id,
  223. }
  224. this.list.push(obj)
  225. })
  226. }
  227. })
  228. } else {
  229. this.list.push(
  230. ...res.list.map(i => {
  231. const checked =
  232. this.memoList.findIndex(itm => itm.id === i.id) > -1
  233. const warehouseId = i.pathIds && i.pathIds.split(',')[0]
  234. return {
  235. checked,
  236. warehouseId,
  237. ...i,
  238. instanceId: i.id,
  239. }
  240. })
  241. )
  242. }
  243. isEnd = this.list.length >= res.count
  244. })
  245. },
  246. //勾选
  247. selectVal(e, val, index) {
  248. console.log(val)
  249. if(val.rootCategoryLevelId == 11 && val.status == 1) {
  250. return false
  251. }
  252. this.list[index].checked = !this.list[index].checked
  253. this.seletedAll = !this.list.some(item => !item.checked)
  254. const idx = this.memoList.findIndex(
  255. item => item.id === this.list[index].id
  256. )
  257. if (this.list[index].checked) {
  258. if (idx === -1) {
  259. this.memoList.push(this.list[index])
  260. }
  261. } else {
  262. if (idx > -1) {
  263. this.memoList.splice(idx, 1)
  264. }
  265. }
  266. },
  267. //跳转回添加页面
  268. jumpAdd() {
  269. if (this.isType == 'pick' || this.isType == 'feed' || this.isType == 'job') {
  270. uni.$emit('setSelectList', this.memoList, this.pid)
  271. uni.navigateBack()
  272. }
  273. },
  274. }
  275. }
  276. </script>
  277. <style lang="scss" scoped>
  278. .content-box {
  279. height: 100vh;
  280. overflow: hidden;
  281. display: flex;
  282. flex-direction: column;
  283. background-color: $page-bg;
  284. }
  285. .searchBox {
  286. background-color: #dedede;
  287. height: 90rpx;
  288. padding: 0 20rpx;
  289. input {
  290. height: 70rpx;
  291. width: 540rpx;
  292. background: #f9f9f9 !important;
  293. padding-left: 10rpx;
  294. border-radius: 5rpx;
  295. }
  296. }
  297. .list_box {
  298. flex: 1;
  299. overflow: hidden;
  300. padding: 6rpx 0;
  301. .u-list {
  302. height: 100% !important;
  303. }
  304. }
  305. .bottom-wrapper {
  306. height: 80rpx;
  307. background: #fff;
  308. padding: 0 32rpx;
  309. /deep/ .uni-checkbox-input-checked {
  310. background-color: $theme-color !important;
  311. border-color: $theme-color !important;
  312. }
  313. }
  314. .listBox {
  315. margin-top: 8rpx;
  316. padding: 8rpx 24rpx;
  317. background: #fff;
  318. /deep/ .uni-checkbox-input-checked {
  319. background-color: $theme-color !important;
  320. border-color: $theme-color !important;
  321. }
  322. .listBox-con {
  323. width: 650rpx;
  324. font-weight: 400;
  325. }
  326. .listBox-top {
  327. margin-top: 6rpx;
  328. color: #090A0A;
  329. font-size: 28rpx;
  330. font-style: normal;
  331. }
  332. .listBox-bottom {
  333. color: #090A0A;
  334. font-size: 24rpx;
  335. font-style: normal;
  336. flex-wrap: wrap;
  337. .items {
  338. width: 50%;
  339. margin-top: 8rpx;
  340. }
  341. }
  342. }
  343. </style>