list.vue 17 KB

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