chooseProduct.vue 11 KB

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