selectCurSarepart.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar
  4. fixed="true"
  5. statusBar="true"
  6. left-icon="back"
  7. :title="`选择备件`"
  8. @clickLeft="backAdd"
  9. >
  10. </uni-nav-bar>
  11. <view class="wrapper">
  12. <!-- <view class="searchBox">
  13. <input
  14. v-model="searchVal"
  15. placeholder="请输入关键字搜索"
  16. class="searchInput"
  17. />
  18. <u-button
  19. type="icon-shixiangxinzeng"
  20. size="30"
  21. @click="doSearch"
  22. data-icon="Search"
  23. class="searchBtn"
  24. >
  25. <view class="iconfont icon-sousuo"> </view>
  26. <view class="text"> 搜索 </view>
  27. </u-button>
  28. </view> -->
  29. <view class="listContent">
  30. <checkbox-group
  31. v-for="(item, index) in listData"
  32. :key="index"
  33. @change="e => selectVal(e, item, index)"
  34. >
  35. <label>
  36. <view class="listBox">
  37. <view class="listBox-sel">
  38. <checkbox
  39. :value="item.code"
  40. color="#fff"
  41. :disabled="item.disabled"
  42. :checked="item.checked"
  43. />
  44. </view>
  45. <view class="listBox-con">
  46. <view class="listBox-top">
  47. <view class="listBox-name">
  48. {{ item.assetName }}
  49. </view>
  50. <view class="listBox-code">
  51. {{ item.assetCode }}
  52. </view>
  53. </view>
  54. <view class="listBox-bottom">
  55. <view
  56. v-for="(itm, index) in tableHeader"
  57. :key="index"
  58. class="items"
  59. >
  60. {{ itm.label }}:{{ item[itm.prop] }}
  61. </view>
  62. <view class="items">
  63. 可用库存:{{ item.realInventoryNum || 0 }}
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. </label>
  69. </checkbox-group>
  70. <u-empty style="margin-top: 20vh" v-if="!listData.length"> </u-empty>
  71. </view>
  72. </view>
  73. <view class="footer">
  74. <view class="bottom">
  75. <checkbox
  76. v-if="!seletedAll"
  77. color="#fff"
  78. :checked="seletedAll"
  79. @tap="_seletedAll"
  80. >全选</checkbox
  81. >
  82. <checkbox
  83. class="select-all"
  84. color="#fff"
  85. v-else
  86. :checked="seletedAll"
  87. @tap="_seletedAll"
  88. >取消全选
  89. </checkbox>
  90. </view>
  91. <u-button
  92. type="success"
  93. size="small"
  94. class="u-reset-button"
  95. :disabled="!checkListLen"
  96. @click="jumpAdd"
  97. >
  98. <view class="selBtn"> 选择( {{ checkListLen }} ) </view>
  99. </u-button>
  100. </view>
  101. </view>
  102. </template>
  103. <script>
  104. import { post, postJ, get } from '@/utils/api.js'
  105. let [page, size, isEnd] = [1, 20, true]
  106. export default {
  107. components: {
  108. },
  109. data () {
  110. return {
  111. searchVal: '',
  112. pickTabIndex: 1,
  113. popupShow: false, //右侧搜索窗
  114. typeIndex: 1,
  115. listData: [], //列表数据
  116. classificationList: [], //分类数据
  117. seletedAll: false, //全选状态
  118. warehousingName: '',
  119. warehousingType: '',
  120. curId: '',
  121. workOrderCode: '',
  122. memoList: [],
  123. tableHeader: [
  124. { label: '规格', prop: 'specification' },
  125. { label: '型号', prop: 'modelType' }
  126. ]
  127. }
  128. },
  129. //选择的列表长度
  130. computed: {
  131. checkListLen () {
  132. return this.memoList.length
  133. },
  134. },
  135. onLoad ({ workOrderCode, storageKey, }) {
  136. this.workOrderCode = workOrderCode
  137. this.memoList = (storageKey && uni.getStorageSync(storageKey)) || []
  138. this.getList()
  139. },
  140. mounted () {
  141. },
  142. methods: {
  143. //列表数据
  144. async getList () {
  145. isEnd = false
  146. const res = await postJ(
  147. this.apiUrl + `/warehouseGoodsshelves/select/listMaterialsOfRepairWorkOrder/${this.workOrderCode}`,
  148. )
  149. uni.hideLoading()
  150. if (res?.success) {
  151. if (page == 1) {
  152. this.listData = []
  153. }
  154. this.listData.push(
  155. ...res.data.map(i => {
  156. const curId = i.informationCode
  157. const checked =
  158. this.memoList.findIndex(itm => itm.curId === curId) > -1
  159. return {
  160. checked,
  161. curId,
  162. ...i,
  163. assetCode: i.informationCode,
  164. assetName: i.informationName,
  165. }
  166. })
  167. )
  168. if (curId === this.curId) {
  169. isEnd = this.listData.length >= res.data.total
  170. }
  171. }
  172. },
  173. //勾选
  174. selectVal (e, val, index) {
  175. // console.log(this.listData);
  176. this.listData[index].checked = !this.listData[index].checked
  177. this.seletedAll = !this.listData.some(item => !item.checked)
  178. const idx = this.memoList.findIndex(
  179. item => item.curId === this.listData[index].curId
  180. )
  181. if (this.listData[index].checked) {
  182. if (idx === -1) {
  183. this.memoList.push(this.listData[index])
  184. }
  185. } else {
  186. if (idx > -1) {
  187. this.memoList.splice(idx, 1)
  188. }
  189. }
  190. },
  191. //全选按钮
  192. _seletedAll () {
  193. if (!this.seletedAll) {
  194. this.seletedAll = true
  195. this.listData.map(item => {
  196. this.$set(item, 'checked', true)
  197. const idx = this.memoList.findIndex(itm => itm.curId === item.curId)
  198. console.log(idx, item.curId)
  199. if (idx === -1) {
  200. this.memoList.push(item)
  201. }
  202. })
  203. } else {
  204. this.seletedAll = false
  205. //this.checkListLen = 0;
  206. this.listData.map(item => {
  207. this.$set(item, 'checked', false)
  208. console.log(this.memoList, 'this.memoList')
  209. const idx = this.memoList.findIndex(itm => itm.curId === item.curId)
  210. console.log(idx, item.curId)
  211. if (idx > -1) {
  212. this.memoList.splice(idx, 1)
  213. }
  214. })
  215. }
  216. },
  217. //跳转回添加页面
  218. jumpAdd () {
  219. uni.$emit('setSelectList', this.memoList)
  220. uni.navigateBack()
  221. },
  222. //返回添加页
  223. backAdd () {
  224. uni.navigateBack()
  225. }
  226. }
  227. }
  228. </script>
  229. <style lang="scss" scoped>
  230. .mainBox {
  231. .wrapper {
  232. /* padding-top: 50px; */
  233. position: relative;
  234. }
  235. .searchBox {
  236. position: absolute;
  237. top: 0;
  238. z-index: 99;
  239. background-color: #dedede;
  240. height: 50px;
  241. width: 100%;
  242. line-height: 50px;
  243. display: flex;
  244. justify-content: space-around;
  245. align-items: center;
  246. input {
  247. height: 40px;
  248. width: 65%;
  249. background: #f9f9f9 !important;
  250. margin-left: 20rpx;
  251. padding-left: 10rpx;
  252. border-radius: 5rpx;
  253. }
  254. .searchBtn {
  255. height: 40px;
  256. background: #f9f9f9 !important;
  257. color: #676767;
  258. font-size: 28rpx;
  259. width: 260rpx;
  260. padding: 0 42rpx;
  261. outline: none;
  262. border: none;
  263. .icon-sousuo {
  264. font-size: 22px;
  265. }
  266. .text {
  267. font-size: 16px;
  268. margin-left: 10px;
  269. }
  270. }
  271. }
  272. .tab-title {
  273. position: fixed;
  274. top: 190rpx;
  275. z-index: 99;
  276. width: 100%;
  277. display: flex;
  278. justify-content: space-between;
  279. align-items: center;
  280. height: $tab-height;
  281. line-height: $tab-height;
  282. background-color: #ffffff;
  283. border-bottom: 2rpx solid #f2f2f2;
  284. box-sizing: border-box;
  285. .tab-item {
  286. width: 25%;
  287. text-align: center;
  288. font-size: 32rpx;
  289. color: $uni-text-color-grey;
  290. }
  291. .tab-item.active {
  292. color: $j-primary-border-green;
  293. border-bottom: 1px solid $j-primary-border-green;
  294. font-weight: bold;
  295. }
  296. .tab-item.filter {
  297. flex: 1;
  298. padding: 0px 30rpx;
  299. .uni-icons {
  300. display: flex;
  301. padding-top: 5px;
  302. }
  303. }
  304. .screenIcon {
  305. display: flex;
  306. width: 80px;
  307. justify-content: center;
  308. .screenText {
  309. font-size: 32rpx;
  310. color: $uni-text-color-grey;
  311. }
  312. }
  313. }
  314. .listContent {
  315. // margin-top: 100rpx;
  316. padding-bottom: 100rpx;
  317. .listBox {
  318. display: flex;
  319. // height: 180rpx;
  320. padding: 20rpx 0;
  321. border-bottom: 2rpx solid #e5e5e5;
  322. .listBox-sel {
  323. height: 90rpx;
  324. width: 80rpx;
  325. line-height: 90rpx;
  326. text-align: center;
  327. checkbox {
  328. transform: scale(1.2);
  329. }
  330. }
  331. .listBox-con {
  332. width: 100%;
  333. // display: flex;
  334. // flex-wrap: wrap;
  335. // justify-content: space-between;
  336. align-items: center;
  337. padding: 0 18rpx 0 0;
  338. .listBox-top {
  339. width: 100%;
  340. display: flex;
  341. justify-content: space-between;
  342. padding-bottom: 10rpx;
  343. .listBox-name,
  344. .listBox-code {
  345. display: inline-block;
  346. font-size: $uni-font-size-sm;
  347. font-weight: bold;
  348. }
  349. .listBox-code {
  350. }
  351. }
  352. .listBox-bottom {
  353. width: 100%;
  354. display: flex;
  355. justify-content: space-between;
  356. flex-wrap: wrap;
  357. font-size: $uni-font-size-sm;
  358. .items {
  359. width: 50%;
  360. margin-bottom: 10rpx;
  361. }
  362. .bot-left,
  363. .bot-right {
  364. display: inline-block;
  365. color: $uni-text-color-grey;
  366. }
  367. .bot-right {
  368. }
  369. }
  370. }
  371. }
  372. }
  373. //底部按钮
  374. .footer {
  375. position: fixed;
  376. display: flex;
  377. justify-content: space-between;
  378. align-items: center;
  379. bottom: 0;
  380. width: 100%;
  381. height: 100rpx;
  382. border-top: 1rpx solid #eeecec;
  383. background-color: #ffffff;
  384. z-index: 999;
  385. .bottom {
  386. margin-left: 10rpx;
  387. }
  388. .u-reset-button {
  389. position: absolute;
  390. right: 10rpx;
  391. top: 20rpx;
  392. width: 150rpx;
  393. }
  394. }
  395. }
  396. </style>