sparepartList.vue 11 KB

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