sparepartList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  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. name: '物料维度',
  150. id: 4
  151. },
  152. {
  153. name: '包装维度',
  154. id: 3
  155. },
  156. {
  157. name: '批次维度',
  158. id: 2
  159. },
  160. {
  161. name: '物品维度',
  162. id: 1
  163. }
  164. ],
  165. searchForm: {
  166. assetName: ''
  167. },
  168. searchStyle: {
  169. background: '#F62F33',
  170. width: '105rpx',
  171. height: '50rpx',
  172. borderRadius: '30rpx',
  173. fontSize: '28rpx',
  174. color: '#FFFFFF',
  175. lineHeight: '50rpx',
  176. textAlign: 'center'
  177. },
  178. pageNum: 1,
  179. warehousingMaterialList: [],
  180. batchDetailsVOList: [],
  181. materialCodeReqList: [],
  182. selectionList: [],
  183. wlParams: {},
  184. materialObj: {},
  185. total: 0,
  186. seletedAll: false,
  187. codeS:[]
  188. }
  189. },
  190. onLoad(options) {
  191. this.id = options.id
  192. if(options.codeS){
  193. this.codeS=JSON.parse(options.codeS)
  194. }
  195. },
  196. onShow() {
  197. this.getTreeList()
  198. },
  199. //选择的列表长度
  200. computed: {
  201. checkListLen() {
  202. return this.checkboxList.length
  203. }
  204. },
  205. methods: {
  206. doSearch() {
  207. this.searchShow = false
  208. this.search()
  209. },
  210. handleSearch() {
  211. this.searchShow = true
  212. },
  213. getTreeList() {
  214. treeByPid({
  215. ids: [6]
  216. }).then(res => {
  217. this.classificationList = res
  218. this.confirm(res[0].id, res[0].name, res[0].rootCategoryLevelId)
  219. })
  220. },
  221. _seletedAll() {
  222. if (!this.seletedAll) {
  223. this.seletedAll = true
  224. this.tableData.map(item => {
  225. this.$set(item, 'checked', true)
  226. const idx = this.checkboxList.findIndex(itm => itm.id === item.id)
  227. if (idx === -1) {
  228. this.checkboxList.push(item)
  229. }
  230. })
  231. } else {
  232. this.seletedAll = false
  233. this.tableData.map(item => {
  234. this.$set(item, 'checked', false)
  235. const idx = this.checkboxList.findIndex(itm => itm.id === item.id)
  236. if (idx > -1) {
  237. this.checkboxList.splice(idx, 1)
  238. }
  239. })
  240. }
  241. },
  242. //勾选
  243. selectVal(e, val, index) {
  244. this.tableData[index].checked = !this.tableData[index].checked
  245. this.seletedAll = !this.tableData.some(item => !item.checked)
  246. const idx = this.checkboxList.findIndex(item => item.id === this.tableData[index].id)
  247. if (this.tableData[index].checked) {
  248. if (idx === -1) {
  249. this.checkboxList.push(this.tableData[index])
  250. }
  251. } else {
  252. if (idx > -1) {
  253. this.checkboxList.splice(idx, 1)
  254. }
  255. }
  256. },
  257. //回显
  258. selectValInit(codeS, list) {
  259. this.checkboxList = []
  260. list.forEach((item, index) => {
  261. if (codeS.includes(item.categoryCode)) {
  262. item['checked'] = true
  263. this.checkboxList.push(item)
  264. }
  265. })
  266. return list
  267. },
  268. openTreePicker() {
  269. this.$refs.treePicker._show()
  270. },
  271. search() {
  272. this.pageNum = 1
  273. this.tableData = []
  274. this.getList()
  275. },
  276. scrolltolower() {
  277. if (this.isEnd) return
  278. this.pageNum++
  279. this.getList()
  280. },
  281. getList() {
  282. uni.showLoading({
  283. title: '加载中'
  284. })
  285. return new Promise(async (resolve, reject) => {
  286. try {
  287. let params = {
  288. assetName: this.assetName,
  289. dimension: this.dimension,
  290. pageNum: this.pageNum,
  291. size: 30,
  292. categoryLevelId: this.categoryLevelId
  293. }
  294. const api = this.dimension == 1 ? getProductList : this.dimension == 2 ?
  295. getBatchDetails : this.dimension == 3 ? getInventoryDetails : getMaterielDetails
  296. let res = await api(params)
  297. this.total = res.count
  298. this.tableData = this.selectValInit(this.codeS, res.list)
  299. console.log(this.tableData, 'this.selectValInit(codeS, res.list)')
  300. this.isEnd = this.tableData.length >= this.total
  301. uni.hideLoading()
  302. resolve()
  303. } catch (error) {
  304. console.log(error)
  305. uni.hideLoading()
  306. reject()
  307. }
  308. })
  309. },
  310. confirm(id, name, rootCategoryLevelId) {
  311. this.rootCategoryLevelId = rootCategoryLevelId
  312. this.categoryLevelId = id
  313. this.tableData = []
  314. this.getList()
  315. },
  316. back() {
  317. uni.navigateBack({
  318. delta: 1
  319. })
  320. },
  321. async config() {
  322. this.checkboxList.forEach((item) => {
  323. if (item.warehouseList.length > 0) {
  324. item['warehouseId'] = item.warehouseList[0].warehouse_id
  325. item['warehouseName'] = item.warehouseList[0].warehouse_name
  326. }
  327. });
  328. uni.$emit('sparePartsApply', this.checkboxList)
  329. this.back()
  330. // console.log(this.checkboxList, 'data')
  331. },
  332. }
  333. }
  334. </script>
  335. <style lang="scss" scoped>
  336. .top-wrapper {
  337. background-color: #fff;
  338. display: flex;
  339. width: 750rpx;
  340. height: 88rpx;
  341. padding: 16rpx 32rpx;
  342. align-items: center;
  343. gap: 16rpx;
  344. /deep/.uni-section {
  345. margin-top: 0px;
  346. }
  347. /deep/.uni-section-header {
  348. padding: 0px;
  349. }
  350. .search_btn {
  351. width: 120rpx;
  352. height: 70rpx;
  353. line-height: 70rpx;
  354. padding: 0 24rpx;
  355. background: $theme-color;
  356. font-size: 32rpx;
  357. color: #fff;
  358. margin: 0;
  359. margin-left: 26rpx;
  360. }
  361. .menu_icon {
  362. width: 44rpx;
  363. height: 44rpx;
  364. margin-left: 14rpx;
  365. }
  366. }
  367. .content-box {
  368. height: 100vh;
  369. overflow: hidden;
  370. display: flex;
  371. flex-direction: column;
  372. background-color: $page-bg;
  373. }
  374. .searchBox {
  375. background-color: #dedede;
  376. height: 90rpx;
  377. padding: 0 20rpx;
  378. .menu_icon {
  379. width: 60rpx;
  380. height: 60rpx;
  381. margin-right: 20rpx;
  382. }
  383. input {
  384. height: 70rpx;
  385. width: 480rpx;
  386. background: #f9f9f9 !important;
  387. padding-left: 10rpx;
  388. border-radius: 5rpx;
  389. }
  390. }
  391. .list_box {
  392. flex: 1;
  393. overflow: hidden;
  394. padding: 6rpx 0;
  395. .u-list {
  396. height: 100% !important;
  397. }
  398. }
  399. .bottom-wrapper {
  400. height: 80rpx;
  401. background: #fff;
  402. padding: 0 32rpx;
  403. /deep/ .uni-checkbox-input-checked {
  404. background-color: $theme-color !important;
  405. border-color: $theme-color !important;
  406. }
  407. }
  408. .listBox {
  409. margin-top: 8rpx;
  410. padding: 8rpx 24rpx;
  411. background: #fff;
  412. /deep/ .uni-checkbox-input-checked {
  413. background-color: $theme-color !important;
  414. border-color: $theme-color !important;
  415. }
  416. .listBox-con {
  417. width: 650rpx;
  418. font-weight: 400;
  419. }
  420. .listBox-top {
  421. margin-top: 6rpx;
  422. color: #090a0a;
  423. font-size: 28rpx;
  424. font-style: normal;
  425. font-weight: 800;
  426. }
  427. .listBox-bottom {
  428. color: #090a0a;
  429. font-size: 24rpx;
  430. font-style: normal;
  431. flex-wrap: wrap;
  432. .items {
  433. width: calc(50% - 1px);
  434. border-left: 1rpx solid #e3e5e5;
  435. border-right: 1rpx solid #e3e5e5;
  436. border-bottom: 1rpx solid #e3e5e5;
  437. box-sizing: border-box;
  438. word-break: break-all;
  439. text {
  440. display: inline-block;
  441. background: #f7f9fa;
  442. padding: 8rpx 10rpx;
  443. color: #157a2c;
  444. }
  445. &:nth-child(1),
  446. &:nth-child(2) {
  447. border-top: 1rpx solid #e3e5e5;
  448. margin-top: 8rpx;
  449. }
  450. }
  451. }
  452. }
  453. .search_list {
  454. min-height: 100rpx;
  455. /deep/ .baseForm {
  456. padding: 0 20rpx;
  457. }
  458. }
  459. </style>