list.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. <template>
  2. <view class="billing_box_bg">
  3. <view class="input-wrap">
  4. <view class="search-bar">
  5. <app-search-module v-model="py" placeholder="找小菊请输xj" @input="searchFn"/>
  6. </view>
  7. <view style="padding:0 0upx 0 20upx;" >
  8. <button class="admin-button-com middle blue" style="margin-right:8upx;" @click="downPriceTable()">价格表</button>
  9. <button class="admin-button-com middle blue" style="margin-right:8upx;" @click="pageTo({ url: '/admin/ptItem/itemList' })">导花材</button>
  10. <button class="admin-button-com middle blue" @click="downBarcodeTable()">条码</button>
  11. </view>
  12. </view>
  13. <view class="scroll-middle_bx">
  14. <scroll-view scroll-y scroll-with-animation class="tab-view" :scroll-top="scrollTop">
  15. <div v-for="(item, index) in globalClassItemList" :key="index" class="tab-bar-item" :class="[classIndex == index ? 'active' : '']" :data-current="index" @tap.stop="swichClass(index)">
  16. <text>{{ item.className || "" }}</text>
  17. </div>
  18. </scroll-view>
  19. <scroll-view scroll-y class="right-box" :scroll-into-view="scroll_into_view" scroll-with-animation="true"
  20. @scroll="scroll_detail"
  21. lower-threshold="100"
  22. @scrolltolower="scroll_bottom">
  23. <!--内容部分-->
  24. <block v-if="!$util.isEmpty(globalClassItemList)">
  25. <view class="item_list_bx selectAll" v-for="(classItem, classIndex) in globalClassItemList" :key="classIndex" :id="`class_${classIndex}`">
  26. <view class="item_list_title" v-if="!$util.isEmpty(classItem.child)"> {{ classItem.className }}</view>
  27. <template v-for="(productItem, productIndex) in classItem.child">
  28. <view style="height:240upx" :id="`class_${classIndex}`" :key="productIndex">
  29. <ItemStock v-if="classItem.isActive" :isPrice="false" :info="productItem" @goToProduct="goToProduct" ></ItemStock>
  30. </view>
  31. </template>
  32. </view>
  33. </block>
  34. <block v-else>
  35. <view style="width: 100%">
  36. <app-wrapper-empty title="暂无数据" :is-empty="$util.isEmpty(globalClassItemList)"/>
  37. </view>
  38. </block>
  39. </scroll-view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. import AppSearchModule from "@/components/module/app-search";
  45. import AppWrapperEmpty from "@/components/app-wrapper-empty";
  46. import ItemStock from "./components/ItemStock";
  47. import { STOCK_TYPE } from "@/utils/declare";
  48. import productMins from "@/mixins/product";
  49. import productContraposeMins from "@/mixins/productContrapose";
  50. import { selectShop } from "@/mixins";
  51. import { mapGetters } from "vuex";
  52. import DorpdownSelect from "@/components/module/shopSelect";
  53. import { getWeixinId } from "@/api/invite/index";
  54. import { generatePriceTable,generateBarcodeTable } from '@/api/product/index'
  55. export default {
  56. name: "item_list",
  57. components: {
  58. AppSearchModule,
  59. AppWrapperEmpty,
  60. ItemStock,
  61. DorpdownSelect
  62. },
  63. mixins: [productMins, selectShop,productContraposeMins],
  64. data() {
  65. return {
  66. STOCK_TYPE,
  67. autoLoad: false,
  68. pageType: "stock",
  69. tabIndex: 0,
  70. getAppIdList:{}
  71. };
  72. },
  73. computed:{
  74. ...mapGetters(["getMyShopInfo","getLoginInfo"]),
  75. },
  76. onShow(){
  77. },
  78. onLoad() {
  79. this.shopId = this.getMyShopInfo.id;
  80. let type = '';
  81. this.initData({ type, shopId: this.shopId,status:0});
  82. let that = this
  83. getWeixinId().then(res => {
  84. that.getAppIdList = res.data
  85. });
  86. },
  87. methods: {
  88. downPriceTable(){
  89. let level = 0
  90. let levelList = ['散客价', '普店价', '银店价','金店价']
  91. uni.showActionSheet({
  92. itemList: levelList,
  93. success: function (respond) {
  94. level = respond.tapIndex
  95. uni.showLoading({title:'下载中',mask:true})
  96. generatePriceTable({level:level}).then(res => {
  97. if(res.code == 1){
  98. uni.hideLoading()
  99. let file = res.data.file
  100. let shortFile = res.data.shortFile
  101. uni.downloadFile({
  102. url: file,
  103. header: {"Content-Type": 'application/vnd.ms-excel'},
  104. filePath: `${wx.env.USER_DATA_PATH}/${shortFile}`,
  105. success: (res) => {
  106. if (res.statusCode === 200) {
  107. wx.saveFileToDisk({
  108. filePath: res.filePath,
  109. success: function(res) {
  110. console.log(res)
  111. },
  112. fail:function(res) {
  113. console.log(res)
  114. }
  115. })
  116. }
  117. },
  118. fail:()=>{
  119. uni.showToast({title:'请用电脑打开小程序下载',mask:true,icon:'none'})
  120. }
  121. });
  122. }
  123. })
  124. }
  125. })
  126. },
  127. downBarcodeTable(){
  128. uni.showLoading({title:'下载中',mask:true})
  129. generateBarcodeTable().then(res => {
  130. if(res.code == 1){
  131. uni.hideLoading()
  132. let file = res.data.file
  133. let shortFile = res.data.shortFile
  134. uni.downloadFile({
  135. url: file,
  136. header: {"Content-Type": 'application/vnd.ms-excel'},
  137. filePath: `${wx.env.USER_DATA_PATH}/${shortFile}`,
  138. success: (res) => {
  139. if (res.statusCode === 200) {
  140. wx.saveFileToDisk({
  141. filePath: res.filePath,
  142. success: function(res) {
  143. console.log(res)
  144. },
  145. fail:function(res) {
  146. console.log(res)
  147. }
  148. })
  149. }
  150. },
  151. fail:()=>{
  152. uni.showToast({title:'请用电脑打开小程序下载',mask:true,icon:'none'})
  153. }
  154. });
  155. }
  156. })
  157. },
  158. goToProduct (id) {
  159. let that = this
  160. console.log('admin/ghsProduct/detail?shopId='+ that.loginInfo.shopId+'&id=0&ghsShopAdminId='+that.loginInfo.shopAdminId+'&id='+id)
  161. uni.navigateToMiniProgram({
  162. //姜枫-2021.04.13
  163. appId: that.getAppIdList.hd.miniAppId,
  164. path: 'admin/ghsProduct/detail?shopId='+ that.loginInfo.shopId+'&ghsShopAdminId='+that.loginInfo.shopAdminId+'&id='+id,
  165. //develop 开发版 trial 体验版 release 正式版
  166. envVersion: process.env.NODE_ENV === 'development' ? 'develop' : 'release',
  167. extraData: {
  168. 'shopId': that.loginInfo.shopId,
  169. 'id': 0,
  170. 'name':'',
  171. },
  172. success (res) {
  173. }
  174. })
  175. },
  176. affirm(val) {
  177. if (val.index === 0) {
  178. this.modalCancel();
  179. } else {
  180. }
  181. },
  182. change(e) {
  183. if (this.tabIndex == e.index) {
  184. return false;
  185. } else {
  186. uni.showLoading({
  187. title: "加载中"
  188. });
  189. this.tabIndex = e.index;
  190. let type = "";
  191. this.initData({ type, shopId: this.shopId });
  192. }
  193. },
  194. scrollTop() {},
  195. initProductInfo() {
  196. this.globalClassItemListContrapose = [];
  197. this.page = 1;
  198. this.isMore = true;
  199. },
  200. selectSussess(val) {
  201. uni.showLoading({ title: "加载中" })
  202. this.initProductInfo();
  203. let type = "";
  204. this.shopId = val.selectItem.id;
  205. this.initData({ type, shopId: this.shopId });
  206. }
  207. }
  208. };
  209. </script>
  210. <style lang="scss" scoped>
  211. .billing_box_bg {
  212. height: 100%;
  213. display: flex;
  214. flex-direction: column;
  215. .input-wrap {
  216. display: flex;
  217. padding: 22upx 20upx 22upx 30upx;
  218. .search-bar {
  219. flex: 1;
  220. }
  221. .city-select {
  222. display: flex;
  223. flex-shrink: 0;
  224. align-items: center;
  225. margin-right: 15upx;
  226. margin-left: 45upx;
  227. background-color: #ffff;
  228. .iconfont {
  229. margin-left: 20upx;
  230. font-size: 30upx;
  231. }
  232. }
  233. }
  234. .scroll-middle_bx {
  235. flex: 1;
  236. display: flex;
  237. width: 100%;
  238. height: 100%;
  239. overflow: hidden;
  240. }
  241. .tab-view {
  242. height: calc(100vh - 140upx);
  243. width: 170upx;
  244. flex-shrink: 0;
  245. background-color: #f0f2f6;
  246. .tab-bar-item {
  247. position: relative;
  248. width: 170upx;
  249. height: 90upx;
  250. box-sizing: border-box;
  251. display: flex;
  252. align-items: center;
  253. justify-content: center;
  254. font-size: 26upx;
  255. color: #444;
  256. font-weight: 400;
  257. .tag {
  258. display: flex;
  259. padding: 0 20upx;
  260. align-items: center;
  261. position: absolute;
  262. right: 0;
  263. top: 0;
  264. height: 32upx;
  265. background: #ff2842;
  266. border-radius: 16upx;
  267. color: #fff;
  268. font-size: 20upx;
  269. }
  270. &:last-child{
  271. margin-bottom: 110upx;
  272. }
  273. }
  274. .active {
  275. position: relative;
  276. color: $mainColor;
  277. font-size: 26upx;
  278. background: #fff;
  279. }
  280. .active::before {
  281. content: "";
  282. position: absolute;
  283. border-left: 8upx solid $mainColor;
  284. height: 100%;
  285. left: 0;
  286. }
  287. }
  288. .right-box {
  289. height: calc(100vh - 140upx);
  290. flex: 1;
  291. box-sizing: border-box;
  292. }
  293. .item_list_bx {
  294. padding: 40upx 16upx;
  295. }
  296. .item_list_title {
  297. margin-bottom: 20upx;
  298. font-size: 24upx;
  299. font-weight: 600;
  300. color: #666666;
  301. }
  302. .select-cmd_bx {
  303. & .kc {
  304. color: #999999;
  305. font-size: 28upx;
  306. font-weight: 400;
  307. margin-bottom: 60upx;
  308. text-align: center;
  309. margin-top: 10upx;
  310. }
  311. & .num_bx {
  312. display: flex;
  313. align-items: center;
  314. margin-bottom: 80upx;
  315. & > input {
  316. width: 212upx;
  317. height: 80upx;
  318. border: 1upx solid #dddddd;
  319. border-radius: 4upx;
  320. text-align: center;
  321. margin-right: 24upx;
  322. }
  323. }
  324. }
  325. }
  326. </style>