selectList.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. <template>
  2. <view class="app-content" style="background:white;">
  3. <view class="billing_box_bg">
  4. <view class="input-wrap">
  5. <view style="padding:0upx 0upx 0upx 0upx;margin-right:10upx;" >
  6. <button class="admin-button-com middle blue" @click="selectFlowerNumFn()">图片分类</button>
  7. </view>
  8. <view class="search-bar">
  9. <app-search-module v-model="globalPy" ref="globalSearchRef" placeholder="这里搜索" @input="globalSearch"/>
  10. </view>
  11. </view>
  12. <view class="scroll-middle_bx">
  13. <scroll-view scroll-y scroll-with-animation class="tab-view">
  14. <div v-for="(item, index) in globalClassData" :key="index" class="tab-bar-item" :class="[globalClassIndex == index ? 'active' : '']" :data-current="index" @tap.stop="globalSwitchClass(index,item)">
  15. <text style="text-align: center;">{{ item.name || "" }}</text>
  16. </div>
  17. </scroll-view>
  18. <scroll-view scroll-y class="right-box" :scroll-top="globalScrollTopPlace" @scroll="globalGetScroll" :scroll-into-view="scroll_into_view" scroll-with-animation="true"
  19. lower-threshold="120" @scrolltolower="globalScrollBottom">
  20. <block v-if="!$util.isEmpty(globalItemData)">
  21. <view class="item_list_bx selectAll">
  22. <view v-if="!$util.isEmpty(globalItemData)">
  23. <template v-for="(productItem, productIndex) in globalItemData">
  24. <view class="item_list_title" v-if="productItem.className && productItem.className!=''">{{ productItem.className }}</view>
  25. <view style="height:190upx">
  26. <ItemStock :info="productItem" :ref="`productRef${productItem.id}`">
  27. </ItemStock>
  28. </view>
  29. </template>
  30. </view>
  31. <view v-else>
  32. <view style="height:260upx;text-align:center;color:#CCCCCC;position: relative;">
  33. <view style="position: absolute;margin:auto;top:130upx;left:0;right:0;bottom:0;">暂无花材</view>
  34. </view>
  35. </view>
  36. </view>
  37. </block>
  38. <block v-else>
  39. <view style="width:100%">
  40. <app-wrapper-empty title="加载中" :is-empty="$util.isEmpty(globalItemData)" />
  41. </view>
  42. </block>
  43. </scroll-view>
  44. </view>
  45. </view>
  46. <modal-module :show="printLabelShow" @click="dialogInputConfirm" :maskClosable="true" title="数量" padding="30rpx 30rpx" >
  47. <template v-slot:content>
  48. <div class="app-modal-input-wrap">
  49. <div class="inp-list-line">
  50. <div class="line-input">
  51. <input type="number" ref="input" style="width:61.8%;text-align:center;" @blur="printBlur" :focus="printFocus" v-model="printNum" :adjust-position="false" class="inp-input" />
  52. </div>
  53. </div>
  54. </div>
  55. </template>
  56. </modal-module>
  57. <modal-module :show="breakShow" @click="breakConfirm" :maskClosable="true" title="拆散数量" padding="30rpx 30rpx" >
  58. <template v-slot:content>
  59. <div class="app-modal-input-wrap">
  60. <div class="inp-list-line">
  61. <div class="line-input">
  62. <input type="number" ref="input" style="width:61.8%;text-align:center;" :focus="breakFocus" v-model="breakNum" :adjust-position="false" class="inp-input" />
  63. </div>
  64. </div>
  65. </div>
  66. </template>
  67. </modal-module>
  68. <uni-popup ref="globalClassImgRef" background-color="#fff" type="center" :animation="false" class="class-popup-style">
  69. <view style="display:flex;padding:20upx;height:auto;justify-content: space-between;align-items:center;flex-wrap:wrap;max-height:100vh;overflow:auto;">
  70. <view v-for="(item, index) in globalClassData" :key="index" @tap.stop="globalChangeClass(index,item)" style="margin-bottom:20upx;margin-left:3upx;">
  71. <image :src="item.cover" style="width:120upx;height:120upx;border-radius:10upx;"></image>
  72. <view style="margin-top:5upx;overflow: hidden;white-space: nowrap;width:120upx;text-align:center;">{{item.name}}</view>
  73. </view>
  74. </view>
  75. </uni-popup>
  76. <uni-popup ref="posterShow" background-color="#fff" type="center" :animation="true" class="class-popup-style">
  77. <view style="display:flex;width:100vw;padding:20upx 20upx 40upx 20upx;height:auto;justify-content: space-between;align-items:center;flex-wrap:wrap;max-height:100vh;overflow:auto;">
  78. <text style="position:absolute;right:50upx;top:10upx;font-size:70upx;" @click="closePoster()">×</text>
  79. <view style="width:100%;text-align:center;margin-top:75upx;">
  80. <image style="width:70%;margin:0 auto;border:1upx solid #CCCCCC;" :src="posterUrl" mode="widthFix"></image>
  81. </view>
  82. <view style="width:100%;margin-top:65upx;text-align:center;">
  83. <button class="admin-button-com big blue" style="width:300upx;" @click="downloadImg">保存图片</button>
  84. </view>
  85. </view>
  86. </uni-popup>
  87. </view>
  88. </template>
  89. <script>
  90. import AppSearchModule from "@/components/module/app-search";
  91. import AppWrapperEmpty from "@/components/app-wrapper-empty";
  92. import ItemStock from "./components/selectItem";
  93. import productMins from "@/mixins/product2";
  94. import { mapGetters } from "vuex";
  95. import { getWeixinId } from "@/api/invite";
  96. import { print,cancelDiscountPrice,cancelPreSell,delStatusUpdate,cancelFullOffFn } from '@/api/product';
  97. import { getHdPoster,getSkPoster,breakItem,changeFrontHide,applyAuth } from '@/api/item'
  98. import uniPopup from '@/uni_modules/uni-popup/components/uni-popup/uni-popup.vue';
  99. import ModalModule from "@/components/plugin/modal"
  100. export default {
  101. name: "list",
  102. components: {
  103. AppSearchModule,
  104. AppWrapperEmpty,
  105. ItemStock,
  106. uniPopup,
  107. ModalModule
  108. },
  109. mixins: [productMins],
  110. data() {
  111. return {
  112. autoLoad: false,
  113. selectJobType: "stock",
  114. tabIndex: 0,
  115. getAppIdList:{},
  116. status:0,
  117. delStatus:0,
  118. printItemId:0,
  119. printType:0,
  120. printLabelShow:false,
  121. printNum:'',
  122. printFocus:false,
  123. warning:0,
  124. currentInfo:{},
  125. posterUrl:'',
  126. breakNum:'',
  127. breakFocus:false,
  128. breakShow:false
  129. };
  130. },
  131. computed:{
  132. ...mapGetters(["getMyShopInfo","getLoginInfo"]),
  133. ...mapGetters({ loginInfo: "getLoginInfo",dictInfo:"getDictionariesInfo" })
  134. },
  135. onLoad() {
  136. this.initItem()
  137. let that = this
  138. getWeixinId().then(res => {
  139. that.getAppIdList = res.data
  140. })
  141. },
  142. methods: {
  143. goSearchFn(){
  144. this.searchFn()
  145. },
  146. initItem(){
  147. this.globalRequestType = 'itemList'
  148. this.initData()
  149. uni.hideLoading()
  150. },
  151. refreshItem(){
  152. uni.showLoading({mask:true})
  153. this.globalPy = ''
  154. this.initItem()
  155. },
  156. hideChangeFn(item,status){
  157. let that = this
  158. changeFrontHide({id:item.id,status:status}).then(res=>{
  159. if(res.code == 1){
  160. that.$refs[`productRef${item.id}`][0].frontHide = status
  161. }
  162. })
  163. },
  164. breakSingleItem(item){
  165. let that = this
  166. this.breakNum = 1
  167. that.$util.confirmModal({content:'确定拆1扎?'},() => {
  168. that.breakAction()
  169. })
  170. },
  171. breakMore(){
  172. this.closeRightShow()
  173. this.breakShow = true
  174. this.breakNum = null
  175. setTimeout(x => {
  176. this.$nextTick(() => this.setBreakFocus())
  177. }, 200)
  178. },
  179. breakAction(){
  180. let that = this
  181. breakItem({breakNum:that.breakNum,id:that.currentInfo.id}).then(res=>{
  182. if(res.code == 1){
  183. that.breakShow = false
  184. that.breakFocus = false
  185. that.$msg(res.msg)
  186. }
  187. })
  188. },
  189. breakConfirm(val){
  190. let that=this;
  191. if (val.index == 0) {
  192. that.breakShow = false
  193. that.breakFocus = false
  194. return false
  195. }
  196. if (this.breakNum == null) {
  197. that.$msg('请填写数量')
  198. that.breakFocus = true
  199. return false
  200. }
  201. if (Number(this.breakNum) <= 0) {
  202. that.$msg('数量不能小于1')
  203. that.breakFocus = true
  204. return false
  205. }
  206. that.$util.confirmModal({content:'确认拆'+that.breakNum+'份?'},() => {
  207. that.breakAction()
  208. })
  209. },
  210. setBreakFocus(){
  211. this.breakFocus = true
  212. },
  213. cancelPreSellFn(item){
  214. let that = this
  215. this.$util.confirmModal({content:'确认取消预售?'},() => {
  216. cancelPreSell({id:item.id}).then(res=>{
  217. if(res.code == 1){
  218. that.$msg(res.msg)
  219. }
  220. })
  221. })
  222. },
  223. cancelDiscountFn(item){
  224. let that = this
  225. this.$util.confirmModal({content:'确认取消特价?'},() => {
  226. cancelDiscountPrice({id:item.id}).then(res=>{
  227. if(res.code == 1){
  228. that.$msg(res.msg)
  229. }
  230. })
  231. })
  232. },
  233. cancelFullOff(item){
  234. let that = this
  235. this.$util.confirmModal({content:'确认取消满减?'},() => {
  236. cancelFullOffFn({id:item.id}).then(res=>{
  237. if(res.code == 1){
  238. that.$msg(res.msg)
  239. }
  240. })
  241. })
  242. },
  243. closePoster(){
  244. this.$refs.posterShow.close()
  245. },
  246. getHdPosterFn(){
  247. this.closeRightShow()
  248. let that = this
  249. uni.showLoading({mask:true})
  250. getHdPoster({id:this.currentInfo.id}).then(res=>{
  251. uni.hideLoading()
  252. if(res.code == 1){
  253. that.posterUrl = res.data.imgUrl
  254. that.$refs.posterShow.open('top')
  255. }
  256. })
  257. },
  258. getSkPosterFn(){
  259. this.closeRightShow()
  260. let that = this
  261. uni.showLoading({mask:true})
  262. getSkPoster({id:this.currentInfo.id}).then(res=>{
  263. uni.hideLoading()
  264. if(res.code == 1){
  265. that.posterUrl = res.data.imgUrl
  266. that.$refs.posterShow.open('top')
  267. }
  268. })
  269. },
  270. sendStock(){
  271. this.pageTo({url: '/admin/item/sendStock?id='+this.currentInfo.id+'&price='+this.currentInfo.price+'&stock='+this.currentInfo.stock+'&name='+this.currentInfo.name,type:2})
  272. },
  273. downloadImg(){
  274. let that = this
  275. uni.downloadFile({
  276. url: this.posterUrl,
  277. success: (res) => {
  278. if (res.statusCode === 200) {
  279. uni.saveImageToPhotosAlbum({
  280. filePath: res.tempFilePath,
  281. success: function (data) {
  282. that.$refs.posterShow.close()
  283. uni.showToast({title:'保存成功'})
  284. }
  285. });
  286. }
  287. }
  288. });
  289. },
  290. selectFlowerNumFn(){
  291. this.$refs.globalClassImgRef.open('top')
  292. },
  293. printBlur() {
  294. this.printFocus = false
  295. },
  296. doPrintLabel(id,type){
  297. this.printItemId = id
  298. this.printType = type
  299. this.printLabelShow = true
  300. this.printNum = null
  301. setTimeout(x => {
  302. this.$nextTick(() => this.setFocus())
  303. }, 200)
  304. },
  305. setFocus() {
  306. this.printFocus = true
  307. },
  308. dialogInputConfirm(val) {
  309. let that=this;
  310. if (val.index == 0) {
  311. that.printLabelShow = false
  312. that.printFocus = false
  313. return
  314. }
  315. let currentNum = this.printNum
  316. let itemId = this.printItemId
  317. if (currentNum == null) {
  318. that.$msg('请填写数量')
  319. that.printFocus = true
  320. return
  321. }
  322. if (currentNum <= 0) {
  323. that.$msg('数量不能小于1')
  324. that.printFocus = true
  325. return
  326. }
  327. if (itemId == 0) {
  328. that.$msg('打印的花材id出错')
  329. that.printLabelShow = false
  330. that.printFocus = false
  331. return
  332. }
  333. print({id:itemId,num:currentNum,type:this.printType}).then(res=>{
  334. if(res.code == 1){
  335. that.printLabelShow = false
  336. that.printFocus = false
  337. uni.showToast({ title: '操作成功', duration: 1500 })
  338. } else if(res.code == 0){
  339. that.printLabelShow = false
  340. that.printFocus = false
  341. that.$msg(res.msg)
  342. }
  343. })
  344. },
  345. closeRightShow(){
  346. this.$refs.rightShowMore.close()
  347. },
  348. costChange(){
  349. this.closeRightShow()
  350. this.pageTo({url: '/admin/changePrice/costChangeList?id='+this.currentInfo.id})
  351. },
  352. ptAuth(){
  353. let that = this
  354. that.$util.confirmModal({content:'确认申请?'},() => {
  355. applyAuth({id:this.currentInfo.id}).then(res=>{
  356. if(res.code == 1){
  357. that.closeRightShow()
  358. that.$msg('已提交申请')
  359. }
  360. })
  361. })
  362. },
  363. delItem(){
  364. let that = this
  365. that.$util.confirmModal({content:'确认删除?'},() => {
  366. delStatusUpdate({id:this.currentInfo.id,delStatus:1}).then(res=>{
  367. if(res.code == 1){
  368. that.closeRightShow()
  369. that.$msg('删除成功')
  370. }
  371. })
  372. })
  373. },
  374. onStockChange(){
  375. this.closeRightShow()
  376. this.pageTo({url: '/pagesStorehouse/stockWarn/onStockChange?id='+this.currentInfo.id+'&name='+this.currentInfo.name})
  377. },
  378. priceChange(){
  379. this.closeRightShow()
  380. this.pageTo({url: '/admin/changePrice/changeList?id='+this.currentInfo.id})
  381. },
  382. varietyManage(){
  383. this.closeRightShow()
  384. this.pageTo({url: "/admin/item/xjSelect?itemId="+this.currentInfo.id})
  385. },
  386. copyCreate(){
  387. this.closeRightShow()
  388. this.pageTo({url: '/admin/item/copy?id='+this.currentInfo.id})
  389. },
  390. orderRecord(){
  391. this.closeRightShow()
  392. this.pageTo({url: "/admin/order/itemOrder?productId="+this.currentInfo.id})
  393. },
  394. preSell(){
  395. this.closeRightShow()
  396. this.pageTo({url: "/admin/item/presell?id="+this.currentInfo.id})
  397. },
  398. moreAction(item){
  399. this.currentInfo = item
  400. this.$refs.rightShowMore.open('top')
  401. },
  402. shareItem() {
  403. let that = this
  404. let id = this.currentInfo.id
  405. this.closeRightShow()
  406. // #ifdef MP-WEIXIN
  407. console.log('admin/ghsProduct/detail?shopId='+ that.loginInfo.shopId+'&id=0&ghsShopAdminId='+that.loginInfo.shopAdminId+'&id='+id)
  408. uni.navigateToMiniProgram({
  409. //姜枫-2021.04.13
  410. appId: that.getAppIdList.hd.miniAppId,
  411. path: 'admin/ghsProduct/detail?shopId='+ that.loginInfo.shopId+'&ghsShopAdminId='+that.loginInfo.shopAdminId+'&id='+id,
  412. //develop 开发版 trial 体验版 release 正式版
  413. envVersion: process.env.NODE_ENV === 'development' ? 'develop' : 'release',
  414. extraData: {
  415. 'shopId': that.loginInfo.shopId,
  416. 'id': 0,
  417. 'name':'',
  418. },
  419. success (res) {
  420. }
  421. })
  422. // #endif
  423. // #ifdef APP-PLUS
  424. if(plus.runtime.isApplicationExist({pname:'com.tencent.mm',action:'weixin://'})){
  425. var sweixin
  426. plus.share.getServices(function(s){
  427. for (var i = 0; i < s.length; i++) {
  428. var t = s[i];
  429. if (t.id == 'weixin') {
  430. sweixin = t;
  431. }
  432. }
  433. let miniOriginalId = that.dictInfo.miniOriginalId && that.dictInfo.miniOriginalId.current && that.dictInfo.miniOriginalId.current.hd ? that.dictInfo.miniOriginalId.current.hd : ''
  434. if (sweixin) { //&& sweixin.nativeClient
  435. sweixin.launchMiniProgram({
  436. id: miniOriginalId,
  437. path: 'admin/ghsProduct/detail?shopId='+ that.loginInfo.shopId+'&ghsShopAdminId='+that.loginInfo.shopAdminId+'&id='+id,
  438. type: 0
  439. });
  440. } else {
  441. that.$msg('没有找到微信服务');
  442. return false;
  443. }
  444. }, function(e){
  445. that.$msg("没有找到微信服务哦")
  446. //that.$msg("获取微信失败:" + e.message)
  447. //console.log(JSON.stringify(e));
  448. });
  449. }else{
  450. this.$msg("请安装微信,再打开小程序")
  451. return false
  452. }
  453. // #endif
  454. },
  455. affirm(val) {
  456. if (val.index === 0) {
  457. this.modalCancel();
  458. } else {
  459. }
  460. }
  461. }
  462. };
  463. </script>
  464. <style lang="scss" scoped>
  465. .billing_box_bg {
  466. height: 100%;
  467. display: flex;
  468. background:white;
  469. flex-direction: column;
  470. .input-wrap {
  471. display: flex;
  472. padding: 22upx 20upx 22upx 13upx;
  473. .search-bar {
  474. flex: 1;
  475. }
  476. .city-select {
  477. display: flex;
  478. flex-shrink: 0;
  479. align-items: center;
  480. margin-right: 15upx;
  481. margin-left: 45upx;
  482. background-color: #ffff;
  483. .iconfont {
  484. margin-left: 20upx;
  485. font-size: 30upx;
  486. }
  487. }
  488. }
  489. .scroll-middle_bx {
  490. flex: 1;
  491. display: flex;
  492. width: 100%;
  493. height: 100%;
  494. overflow: hidden;
  495. }
  496. .tab-view {
  497. height: calc(100vh - 140upx);
  498. width: 170upx;
  499. flex-shrink: 0;
  500. background-color: #f0f2f6;
  501. .tab-bar-item {
  502. position: relative;
  503. width: 170upx;
  504. height: 90upx;
  505. box-sizing: border-box;
  506. display: flex;
  507. align-items: center;
  508. justify-content: center;
  509. font-size: 26upx;
  510. color: #444;
  511. font-weight: 400;
  512. .tag {
  513. display: flex;
  514. padding: 0 20upx;
  515. align-items: center;
  516. position: absolute;
  517. right: 0;
  518. top: 0;
  519. height: 32upx;
  520. background: #ff2842;
  521. border-radius: 16upx;
  522. color: #fff;
  523. font-size: 20upx;
  524. }
  525. &:last-child{
  526. margin-bottom: 110upx;
  527. }
  528. }
  529. .active {
  530. position: relative;
  531. color: $mainColor;
  532. font-size: 26upx;
  533. background: #fff;
  534. }
  535. .active::before {
  536. content: "";
  537. position: absolute;
  538. border-left: 8upx solid $mainColor;
  539. height: 100%;
  540. left: 0;
  541. }
  542. }
  543. .right-box {
  544. height: calc(100vh - 140upx);
  545. flex: 1;
  546. box-sizing: border-box;
  547. }
  548. .item_list_bx {
  549. padding: 40upx 16upx;
  550. }
  551. .item_list_title {
  552. margin-bottom: 20upx;
  553. font-size: 30upx;
  554. font-weight: 600;
  555. color: #3385FF;
  556. }
  557. .select-cmd_bx {
  558. & .kc {
  559. color: #999999;
  560. font-size: 28upx;
  561. font-weight: 400;
  562. margin-bottom: 60upx;
  563. text-align: center;
  564. margin-top: 10upx;
  565. }
  566. & .num_bx {
  567. display: flex;
  568. align-items: center;
  569. margin-bottom: 80upx;
  570. & > input {
  571. width: 212upx;
  572. height: 80upx;
  573. border: 1upx solid #dddddd;
  574. border-radius: 4upx;
  575. text-align: center;
  576. margin-right: 24upx;
  577. }
  578. }
  579. }
  580. }
  581. .class-popup-style{
  582. z-index:999999;
  583. }
  584. </style>