index.vue 9.8 KB

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