sparepartList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. <template slot-scope="scope">
  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="assetName" placeholder="请输入物品名称" class="searchInput" />
  13. <view class="rx-sc">
  14. <image class="menu_icon" src="~@/static/pda/menu.svg" @click="handleSearch"></image>
  15. <u-button @click="search" type="success" size="small" class="u-reset-button" text="搜索"></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 tableData" :key="index"
  22. @change="e => selectVal(e, item, index)">
  23. <label class="listBox rx-bs">
  24. <view class="listBox-sel">
  25. <checkbox :value="item.categoryCode" color="#fff" :disabled="item.disabled"
  26. :checked="item.checked" />
  27. </view>
  28. <view class="listBox-con">
  29. <view class="listBox-top rx-bc">
  30. <view>{{ item.categoryName }}</view>
  31. </view>
  32. <view class="listBox-bottom rx">
  33. <view class="items">
  34. <text>编码</text>
  35. {{ item.categoryCode }}
  36. </view>
  37. <view class="items">
  38. <text>牌号</text>
  39. {{ item.brandNum }}
  40. </view>
  41. <view class="items">
  42. <text>型号</text>
  43. {{ item.categoryModel }}
  44. </view>
  45. <view class="items">
  46. <text>规格</text>
  47. {{ item.specification }}
  48. </view>
  49. <view class="items">
  50. <text>级别</text>
  51. {{ item.level }}
  52. </view>
  53. <!-- <view class="items" style="display: flex;">
  54. <text>出库数量</text>
  55. <input style="width: 80px;" v-model="item.outboundNum" type="number"
  56. @blur="handleInput(item,index)" placeholder="请输入出库数量" />
  57. </view> -->
  58. <view class="items">
  59. <text>计量数量</text>
  60. {{ item.measureQuantity }}
  61. </view>
  62. <view class="items">
  63. <text>计量单位</text>
  64. {{ item.measureUnit }}
  65. </view>
  66. </view>
  67. </view>
  68. </label>
  69. </checkbox-group>
  70. <view v-if="tableData.length == 0" style="margin-top: 20vh">
  71. <u-empty iconSize="150" textSize="32" text="暂无数据"></u-empty>
  72. </view>
  73. </u-list>
  74. </view>
  75. <view class="bottom-wrapper rx-bc">
  76. <view>
  77. <checkbox v-if="!seletedAll" color="#fff" :checked="seletedAll" @tap="_seletedAll">全选</checkbox>
  78. <checkbox class="select-all" color="#fff" v-else :checked="seletedAll" @tap="_seletedAll">取消全选
  79. </checkbox>
  80. </view>
  81. <view>
  82. <u-button type="success" size="small" class="u-reset-button" :disabled="!checkListLen" @click="config">
  83. <view>选择( {{ checkListLen }} )</view>
  84. </u-button>
  85. </view>
  86. </view>
  87. <ba-tree-picker ref="treePicker" key="verify" :multiple="false" @select-change="confirm" title="选择分类"
  88. :selectedData="selectedData" :localdata="classificationList" valueKey="id" textKey="name"
  89. childrenKey="children" />
  90. <SearchPopup mode="top" v-if="searchShow">
  91. <template v-slot:list>
  92. <view class="search_list">
  93. <u-form labelPosition="left" :model="formData" labelWidth="180" labelAlign="left" class="baseForm">
  94. <u-form-item label="维度:" class="required-form" borderBottom prop="warehouseId">
  95. <zxz-uni-data-select :localdata="dimensionList" v-model="dimension" dataValue="id"
  96. format="{name}" dataKey="name" filterable></zxz-uni-data-select>
  97. </u-form-item>
  98. </u-form>
  99. </view>
  100. </template>
  101. <template v-slot:operate>
  102. <view class="operate_box rx-bc">
  103. <u-button size="small" class="u-reset-button" @click="searchShow = false">取消</u-button>
  104. <u-button type="success" size="small" class="u-reset-button" @click="doSearch">确定</u-button>
  105. </view>
  106. </template>
  107. </SearchPopup>
  108. </view>
  109. </template>
  110. <script>
  111. import {
  112. treeByPid
  113. } from '@/api/pda/workOrder.js'
  114. import baTreePicker from '@/components/ba-tree-picker/ba-tree-picker.vue'
  115. import SearchPopup from '@/pages/pda/components/searchPopup.vue'
  116. import {
  117. getDetailById,
  118. getBatchDetails,
  119. applySpareParts,
  120. saveNew,
  121. getInventoryDetails,
  122. getMaterielDetails,
  123. getProductList,
  124. getHierarchyList,
  125. getHierarchyFifo
  126. } from '@/api/repair'
  127. export default {
  128. components: {
  129. baTreePicker,
  130. SearchPopup
  131. },
  132. data() {
  133. return {
  134. assetName: '',
  135. searchShow: false,
  136. formData: {},
  137. checkboxList: [],
  138. tableData: [],
  139. dimension: 1,
  140. show: false,
  141. categoryLevelId: 6,
  142. rootCategoryLevelId: '',
  143. classificationList: [],
  144. selectedData: ['6'],
  145. stateList: {
  146. 0: '未质检',
  147. 1: '已质检'
  148. },
  149. dimensionList: [{
  150. name: '物料维度',
  151. id: 4
  152. },
  153. {
  154. name: '包装维度',
  155. id: 3
  156. },
  157. {
  158. name: '批次维度',
  159. id: 2
  160. },
  161. {
  162. name: '物品维度',
  163. id: 1
  164. }
  165. ],
  166. searchForm: {
  167. assetName: ''
  168. },
  169. searchStyle: {
  170. background: '#F62F33',
  171. width: '105rpx',
  172. height: '50rpx',
  173. borderRadius: '30rpx',
  174. fontSize: '28rpx',
  175. color: '#FFFFFF',
  176. lineHeight: '50rpx',
  177. textAlign: 'center'
  178. },
  179. pageNum: 1,
  180. warehousingMaterialList: [],
  181. batchDetailsVOList: [],
  182. materialCodeReqList: [],
  183. selectionList: [],
  184. wlParams: {},
  185. materialObj: {},
  186. total: 0,
  187. seletedAll: false,
  188. codeS:[]
  189. }
  190. },
  191. onLoad(options) {
  192. this.id = options.id
  193. if(options.codeS){
  194. this.codeS=JSON.parse(options.codeS)
  195. }
  196. },
  197. onShow() {
  198. this.getTreeList()
  199. },
  200. //选择的列表长度
  201. computed: {
  202. checkListLen() {
  203. return this.checkboxList.length
  204. }
  205. },
  206. methods: {
  207. doSearch() {
  208. this.searchShow = false
  209. this.search()
  210. },
  211. handleSearch() {
  212. this.searchShow = true
  213. },
  214. getTreeList() {
  215. treeByPid({
  216. ids: [6]
  217. }).then(res => {
  218. this.classificationList = res
  219. this.confirm(res[0].id, res[0].name, res[0].rootCategoryLevelId)
  220. })
  221. },
  222. _seletedAll() {
  223. if (!this.seletedAll) {
  224. this.seletedAll = true
  225. this.tableData.map(item => {
  226. this.$set(item, 'checked', true)
  227. const idx = this.checkboxList.findIndex(itm => itm.id === item.id)
  228. if (idx === -1) {
  229. this.checkboxList.push(item)
  230. }
  231. })
  232. } else {
  233. this.seletedAll = false
  234. this.tableData.map(item => {
  235. this.$set(item, 'checked', false)
  236. const idx = this.checkboxList.findIndex(itm => itm.id === item.id)
  237. if (idx > -1) {
  238. this.checkboxList.splice(idx, 1)
  239. }
  240. })
  241. }
  242. },
  243. //勾选
  244. selectVal(e, val, index) {
  245. this.tableData[index].checked = !this.tableData[index].checked
  246. this.seletedAll = !this.tableData.some(item => !item.checked)
  247. const idx = this.checkboxList.findIndex(item => item.id === this.tableData[index].id)
  248. if (this.tableData[index].checked) {
  249. if (idx === -1) {
  250. this.checkboxList.push(this.tableData[index])
  251. }
  252. } else {
  253. if (idx > -1) {
  254. this.checkboxList.splice(idx, 1)
  255. }
  256. }
  257. },
  258. //回显
  259. selectValInit(codeS, list) {
  260. this.checkboxList = []
  261. list.forEach((item, index) => {
  262. if (codeS.includes(item.categoryCode)) {
  263. item['checked'] = true
  264. this.checkboxList.push(item)
  265. }
  266. })
  267. return list
  268. },
  269. openTreePicker() {
  270. this.$refs.treePicker._show()
  271. },
  272. search() {
  273. this.pageNum = 1
  274. this.tableData = []
  275. this.getList()
  276. },
  277. scrolltolower() {
  278. if (this.isEnd) return
  279. this.pageNum++
  280. this.getList()
  281. },
  282. getList() {
  283. uni.showLoading({
  284. title: '加载中'
  285. })
  286. return new Promise(async (resolve, reject) => {
  287. try {
  288. let params = {
  289. assetName: this.assetName,
  290. dimension: this.dimension,
  291. pageNum: this.pageNum,
  292. size: 30,
  293. categoryLevelId: this.categoryLevelId
  294. }
  295. const api = this.dimension == 1 ? getProductList : this.dimension == 2 ?
  296. getBatchDetails : this.dimension == 3 ? getInventoryDetails : getMaterielDetails
  297. let res = await api(params)
  298. this.total = res.count
  299. this.tableData = this.selectValInit(this.codeS, res.list)
  300. console.log(this.tableData, 'this.selectValInit(codeS, res.list)')
  301. this.isEnd = this.tableData.length >= this.total
  302. uni.hideLoading()
  303. resolve()
  304. } catch (error) {
  305. console.log(error)
  306. uni.hideLoading()
  307. reject()
  308. }
  309. })
  310. },
  311. confirm(id, name, rootCategoryLevelId) {
  312. this.rootCategoryLevelId = rootCategoryLevelId
  313. this.categoryLevelId = id
  314. this.tableData = []
  315. this.getList()
  316. },
  317. back() {
  318. uni.navigateBack({
  319. delta: 1
  320. })
  321. },
  322. async config() {
  323. this.checkboxList.forEach((item) => {
  324. if (item.warehouseList.length > 0) {
  325. item['warehouseId'] = item.warehouseList[0].warehouse_id
  326. item['warehouseName'] = item.warehouseList[0].warehouse_name
  327. }
  328. });
  329. uni.$emit('sparePartsApply', this.checkboxList)
  330. this.back()
  331. // console.log(this.checkboxList, 'data')
  332. },
  333. }
  334. }
  335. </script>
  336. <style lang="scss" scoped>
  337. .content-box {
  338. height: 100vh;
  339. overflow: hidden;
  340. display: flex;
  341. flex-direction: column;
  342. background-color: $page-bg;
  343. }
  344. .searchBox {
  345. background-color: #dedede;
  346. height: 90rpx;
  347. padding: 0 20rpx;
  348. .menu_icon {
  349. width: 60rpx;
  350. height: 60rpx;
  351. margin-right: 20rpx;
  352. }
  353. input {
  354. height: 70rpx;
  355. width: 480rpx;
  356. background: #f9f9f9 !important;
  357. padding-left: 10rpx;
  358. border-radius: 5rpx;
  359. }
  360. }
  361. .list_box {
  362. flex: 1;
  363. overflow: hidden;
  364. padding: 6rpx 0;
  365. .u-list {
  366. height: 100% !important;
  367. }
  368. }
  369. .bottom-wrapper {
  370. height: 80rpx;
  371. background: #fff;
  372. padding: 0 32rpx;
  373. /deep/ .uni-checkbox-input-checked {
  374. background-color: $theme-color !important;
  375. border-color: $theme-color !important;
  376. }
  377. }
  378. .listBox {
  379. margin-top: 8rpx;
  380. padding: 8rpx 24rpx;
  381. background: #fff;
  382. /deep/ .uni-checkbox-input-checked {
  383. background-color: $theme-color !important;
  384. border-color: $theme-color !important;
  385. }
  386. .listBox-con {
  387. width: 650rpx;
  388. font-weight: 400;
  389. }
  390. .listBox-top {
  391. margin-top: 6rpx;
  392. color: #090a0a;
  393. font-size: 28rpx;
  394. font-style: normal;
  395. font-weight: 800;
  396. }
  397. .listBox-bottom {
  398. color: #090a0a;
  399. font-size: 24rpx;
  400. font-style: normal;
  401. flex-wrap: wrap;
  402. .items {
  403. width: calc(50% - 1px);
  404. border-left: 1rpx solid #e3e5e5;
  405. border-right: 1rpx solid #e3e5e5;
  406. border-bottom: 1rpx solid #e3e5e5;
  407. box-sizing: border-box;
  408. word-break: break-all;
  409. text {
  410. display: inline-block;
  411. background: #f7f9fa;
  412. padding: 8rpx 10rpx;
  413. color: #157a2c;
  414. }
  415. &:nth-child(1),
  416. &:nth-child(2) {
  417. border-top: 1rpx solid #e3e5e5;
  418. margin-top: 8rpx;
  419. }
  420. }
  421. }
  422. }
  423. .search_list {
  424. min-height: 100rpx;
  425. /deep/ .baseForm {
  426. padding: 0 20rpx;
  427. }
  428. }
  429. </style>