chooseProduct.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. <template>
  2. <view class="content flex flex_column">
  3. <view class="searchBar">
  4. <view class="p-title flex align_center">
  5. <text></text>
  6. <view class="shelfName">
  7. <view>{{nowData.shelfName}}</view>
  8. </view>
  9. <view class="screeningBox" @click="chooseShow = true">
  10. <text>滞销天数</text>
  11. <u-icon color="#0485F6" size="30" name="shaixuan" custom-prefix="iscm-icon"></u-icon>
  12. </view>
  13. </view>
  14. <!-- @input="$u.debounce(changeSearch, 800)" -->
  15. <view class="search flex align_center">
  16. <view class="input">
  17. <u-search
  18. v-model="keyword"
  19. @change="$u.debounce(getSearchCon, 800)"
  20. @search="getSearchCon"
  21. @custom="getSearchCon"
  22. @clear="clearSearch"
  23. bg-color="#fff"
  24. :show-action="false"
  25. placeholder="请输入产品编码或名称搜索"></u-search>
  26. </view>
  27. <view class="icon" @click="handleScanCode">
  28. <u-icon name="scan"></u-icon>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="check-list">
  33. <productList ref="productList" noDataText="暂无产品" @updateNums="updateNums" @allChecked="allCheckedCallback"></productList>
  34. </view>
  35. <!-- 底部栏 -->
  36. <view class="footer-bar flex align_center" v-if="partList.length">
  37. <view class="f-left">
  38. <u-checkbox size="40" @change="allCheckeChange" v-model="allChecked" shape="circle">{{allChecked?'取消全选':'全选'}}</u-checkbox>
  39. </view>
  40. <view class="f-mid">
  41. <view v-if="totalCategory">
  42. 已选<text>{{totalCategory}}</text>款产品
  43. </view>
  44. </view>
  45. <view class="f-btns">
  46. <u-button size="medium" @click="submitOrder" :custom-style="customBtnStyle" shape="circle" type="primary" hover-class="none" >确定选择</u-button>
  47. </view>
  48. </view>
  49. <!-- 滞销天数弹窗 -->
  50. <u-popup v-model="chooseShow" mode="right" width="60%">
  51. <view class="choosePopup">
  52. <view class="chooseTit">滞销天数</view>
  53. <view class="chooseDay u-flex">
  54. <u-input v-model="queryParam.unsalableDaysBegin" input-align="center" placeholder="起始天数" type="number" />
  55. <text>至</text>
  56. <u-input v-model="queryParam.unsalableDaysEnd" input-align="center" placeholder="截止天数" type="number" />
  57. </view>
  58. <view class="butBox u-flex">
  59. <u-button hover-class="none" shape="circle" size="medium" @click="reset">重置</u-button>
  60. <u-button hover-class="none" :custom-style="customBtnStyle" size="medium" shape="circle" @click="handelFilter">查询</u-button>
  61. </view>
  62. </view>
  63. </u-popup>
  64. </view>
  65. </template>
  66. <script>
  67. import { reportPage } from '@/api/vinLog';
  68. import productList from './productList.vue'
  69. import { controlQueryList,insert } from '@/api/shelf';
  70. export default {
  71. components: {
  72. productList
  73. },
  74. data() {
  75. return {
  76. nowData:null,
  77. keyword:'',
  78. noDataText: '暂无产品',
  79. partList: [],
  80. allChecked: false,
  81. customBtnStyle: { // 自定义按钮样式
  82. borderColor: this.$config('primaryColor'),
  83. backgroundColor: this.$config('primaryColor'),
  84. color: '#fff'
  85. },
  86. chooseList: [],
  87. chooseShow:false,
  88. queryParam: { // 查询条件
  89. shelfSn:undefined,
  90. productCode: undefined,
  91. productName: undefined,
  92. unsalableDaysBegin: undefined,
  93. unsalableDaysEnd: undefined,
  94. queryWord:undefined
  95. },
  96. againChooseList:[]
  97. }
  98. },
  99. onBackPress(e) {
  100. if(this.chooseShow) {
  101. this.chooseShow = false;
  102. return true;
  103. }
  104. },
  105. onLoad(opts) {
  106. this.nowData = JSON.parse(decodeURIComponent(opts.data));
  107. let ajaxData = {
  108. shelfSn: this.nowData.shelfSn
  109. };
  110. this.loadData(ajaxData);
  111. },
  112. computed: {
  113. totalCategory () {
  114. return this.chooseList.length
  115. },
  116. },
  117. methods: {
  118. // 全选
  119. allCheckeChange(e){
  120. this.$refs.productList.allSelect(e.value)
  121. this.chooseList = this.$refs.productList.getAllChecked()
  122. },
  123. allCheckedCallback(val){
  124. this.allChecked = val
  125. this.chooseList = this.$refs.productList.getAllChecked()
  126. },
  127. // 清空已选数据
  128. clearChoose(){
  129. this.chooseList = []
  130. this.allChecked = false
  131. if(this.$refs.productList){
  132. this.$refs.productList.allSelect(false)
  133. }
  134. },
  135. updateNums(){
  136. this.chooseList = this.$refs.productList.getAllChecked()
  137. },
  138. clearSearch(){
  139. // 重置
  140. this.keyword = ''
  141. this.changeSearch()
  142. },
  143. changeSearch(){
  144. let ajaxData = {
  145. shelfSn:this.nowData.shelfSn,
  146. productCode: undefined,
  147. productName: undefined,
  148. unsalableDaysBegin: undefined,
  149. unsalableDaysEnd: undefined,
  150. queryWord:undefined
  151. };
  152. this.queryParam = ajaxData;
  153. this.partList = []
  154. this.loadData(ajaxData)
  155. },
  156. // 重置
  157. reset() {
  158. let ajaxData = {
  159. shelfSn:this.nowData.shelfSn,
  160. productCode: undefined,
  161. productName: undefined,
  162. unsalableDaysBegin: undefined,
  163. unsalableDaysEnd: undefined,
  164. queryWord:undefined
  165. };
  166. this.queryParam = ajaxData;
  167. this.loadData(ajaxData);
  168. },
  169. handelFilter(){
  170. if(this.checkValueRange()){
  171. this.queryParam.shelfSn = this.nowData.shelfSn;
  172. this.chooseShow =false;
  173. this.loadData(this.queryParam);
  174. }
  175. },
  176. // 获取数字货架列表
  177. loadData(params) {
  178. const _this = this;
  179. _this.clearChoose()
  180. _this.partList = []
  181. _this.$refs.productList && _this.$refs.productList.setData(_this.partList)
  182. uni.showLoading({
  183. mask:true,
  184. title:"正在加载..."
  185. })
  186. controlQueryList(params).then(res => {
  187. if (res.status == 200) {
  188. res.data.forEach(item=>{
  189. item.isChecked= false
  190. item.confirmQty = item.qty - item.recallBillQty>0 ?item.qty - item.recallBillQty>0: 0;
  191. })
  192. _this.partList=res.data;
  193. }else{
  194. _this.partList =[]
  195. }
  196. // 赋值
  197. // 赋值
  198. if(_this.nowData.chooseKey.length){
  199. _this.partList = _this.partList.filter(item => {
  200. const row = _this.nowData.chooseKey.findIndex(k => k == item.id)
  201. return !(row>=0)
  202. })
  203. }
  204. // 已选
  205. _this.partList.map(item => {
  206. const row = _this.chooseList.find(k => k.id == item.id)
  207. item.checked = !!row
  208. })
  209. this.$refs.productList.setData(_this.partList)
  210. setTimeout(()=>{
  211. uni.hideLoading()
  212. },_this.partList.length*40)
  213. });
  214. },
  215. // 提交
  216. submitOrder(){
  217. if(this.totalCategory){
  218. uni.$emit("chooseBackProduct",this.chooseList)
  219. uni.navigateBack()
  220. }else{
  221. uni.showToast({
  222. icon: 'none',
  223. title: '请选择产品'
  224. })
  225. }
  226. },
  227. // 扫描
  228. handleScanCode(){
  229. this.mpaasScanModule = uni.requireNativePlugin("wss-scan")
  230. this.mpaasScanModule.scan(
  231. {
  232. "scanMode":"Customized",
  233. "scanStyle":{
  234. "scanFrameSizePlus":{"width":250,"height":250},
  235. "scanFrameSize":200,
  236. "scanLight":"visible",
  237. "scanText":"对准条形码/二维码进行识别",
  238. "scanTitle":"扫码搜索货位产品",
  239. }
  240. },
  241. (result) => {
  242. if(result.scanStatus == 1){
  243. this.scanResult(result)
  244. }
  245. })
  246. },
  247. // 扫描结果
  248. scanResult(data){
  249. // 二维码
  250. if(data.scanType == 'QRCODE'){
  251. const ret = data.scanValue.split("&")
  252. this.queryParam.queryWord = ret[1] // 产品编码
  253. this.keyword= ret[1]
  254. }else{
  255. this.queryParam.queryWord = data.scanValue;
  256. this.keyword= data.scanValue
  257. }
  258. this.queryParam.shelfSn = this.nowData.shelfSn
  259. this.loadData(this.queryParam);
  260. },
  261. // 搜索
  262. getSearchCon() {
  263. var reg = new RegExp('[\\u4E00-\\u9FFF]+', 'g');
  264. if(!this.queryParam.queryWord){
  265. if (reg.test(this.keyword)) {
  266. //包含汉字
  267. this.queryParam.productName = this.keyword.trim()
  268. } else {
  269. this.queryParam.productCode=this.keyword.trim()
  270. }
  271. }
  272. this.queryParam.shelfSn = this.nowData.shelfSn
  273. this.loadData(this.queryParam);
  274. },
  275. // 校验滞销天数数值范围
  276. checkValueRange () {
  277. const isONull = this.queryParam.unsalableDaysBegin === null || this.queryParam.unsalableDaysBegin === undefined
  278. const isOEmpty = this.queryParam.unsalableDaysBegin === ''
  279. const isOZero = this.queryParam.unsalableDaysBegin === 0
  280. const isTNull = this.queryParam.unsalableDaysEnd === null || this.queryParam.unsalableDaysEnd === undefined
  281. const isTEmpty = this.queryParam.unsalableDaysEnd === ''
  282. const isTZero = this.queryParam.unsalableDaysEnd === 0
  283. // 第一个为空(可为null可为空字符)第二个不为空
  284. // 第一个不为空第二个为空(可为null可为空字符)
  285. // 第一个大于第二个
  286. if ((isONull || isOEmpty) && (this.queryParam.unsalableDaysEnd || isTZero)) {
  287. uni.showToast({
  288. title:'请输入正确的滞销天数查询范围!',
  289. icon:'none'
  290. })
  291. return false
  292. }
  293. if ((this.queryParam.unsalableDaysBegin || isOZero) && (isTNull || isTEmpty)) {
  294. uni.showToast({
  295. title:'请输入正确的滞销天数查询范围!',
  296. icon:'none'
  297. })
  298. return false
  299. }
  300. if (this.queryParam.unsalableDaysBegin*1 > this.queryParam.unsalableDaysEnd *1) {
  301. uni.showToast({
  302. title:'请输入正确的滞销天数查询范围!',
  303. icon:'none'
  304. })
  305. return false
  306. }
  307. this.queryParam.unsalableDaysBegin = this.queryParam.unsalableDaysBegin > 999999999 ? 999999999 : this.queryParam.unsalableDaysBegin
  308. this.queryParam.unsalableDaysEnd = this.queryParam.unsalableDaysEnd > 999999999 ? 999999999 : this.queryParam.unsalableDaysEnd
  309. return true
  310. }
  311. }
  312. }
  313. </script>
  314. <style lang="less">
  315. .content{
  316. height: 100vh;
  317. width: 100%;
  318. background: #fff;
  319. .searchBar{
  320. padding: 0 0.8rem 0.3rem;
  321. .p-title{
  322. padding: 0 15rpx;
  323. display: flex;
  324. align-items: center;
  325. color: #222;
  326. font-size: 30rpx;
  327. > text{
  328. display: block;
  329. height: 30rpx;
  330. width: 6rpx;
  331. background: #0485F6;
  332. margin-right: 10rpx;
  333. border-radius: 10rpx;
  334. }
  335. .shelfName{
  336. flex-grow: 1;
  337. font-weight: bold;
  338. width: 74%;
  339. > view{
  340. overflow: hidden;
  341. white-space: nowrap;
  342. text-overflow: ellipsis;
  343. }
  344. }
  345. .screeningBox {
  346. font-size: 26rpx;
  347. width: 150rpx;
  348. text-align: right;
  349. color: #0485F6;
  350. text {
  351. vertical-align: top;
  352. }
  353. }
  354. .btns{
  355. width:100rpx;
  356. text-align: right;
  357. font-size: 28rpx;
  358. color: #0485F6;
  359. }
  360. }
  361. .search{
  362. margin-top: 15upx;
  363. padding: 0.1rem;
  364. border-radius: 50rpx;
  365. border:1rpx solid #eee;
  366. .input{
  367. flex-grow: 1;
  368. padding: 4rpx;
  369. }
  370. .icon{
  371. width: 13%;
  372. text-align: center;
  373. font-size: 46rpx;
  374. color: #999;
  375. }
  376. }
  377. }
  378. .check-list{
  379. padding: 0 0.8rem;
  380. flex-grow: 1;
  381. overflow: auto;
  382. }
  383. .footer-bar{
  384. background-color: #f8f8f8;
  385. padding: 20upx;
  386. .f-left{
  387. color: #fff;
  388. }
  389. .active{
  390. background-color: #0485F6;
  391. }
  392. .f-mid{
  393. flex-grow: 1;
  394. color: #666;
  395. > view{
  396. padding: 0 5upx;
  397. &:first-child{
  398. text{
  399. color: red;
  400. }
  401. }
  402. &:last-child{
  403. font-size: 0.8rem;
  404. }
  405. }
  406. }
  407. .f-btns{
  408. button{
  409. width: 200upx;
  410. }
  411. }
  412. }
  413. // 筛选
  414. .tabBox{
  415. height: 100vh;
  416. .tabs{
  417. overflow: auto;
  418. padding: 20rpx;
  419. > view{
  420. flex-wrap: wrap;
  421. justify-content: space-between;
  422. > view{
  423. width: 98%;
  424. border: 1rpx solid #eee;
  425. padding: 15rpx;
  426. border-radius: 50rpx;
  427. text-align: center;
  428. margin-bottom: 15rpx;
  429. /deep/ .u-checkbox__label{
  430. flex-grow: 1;
  431. }
  432. }
  433. &:first-child{
  434. > view{
  435. width: 100%;
  436. }
  437. }
  438. }
  439. }
  440. .btns{
  441. display: flex;
  442. padding: 40upx 20upx 20upx;
  443. justify-content: space-between;
  444. .handle-btn {
  445. font-size: 28upx;
  446. }
  447. }
  448. }
  449. // 弹窗样式
  450. .choosePopup {
  451. padding: 30rpx 20rpx;
  452. box-sizing: border-box;
  453. .chooseTit {
  454. text-align: center;
  455. }
  456. .chooseDay {
  457. margin: 60rpx 0;
  458. .u-input {
  459. border-bottom: 1rpx solid #e0e0e0;
  460. }
  461. }
  462. .butBox {
  463. margin-top: 100rpx;
  464. .u-size-medium {
  465. padding: 0 60rpx !important;
  466. }
  467. }
  468. }
  469. }
  470. </style>