list2.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  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="searchFn"/>
  10. </view>
  11. <view style="padding:0 0upx 0 20upx;" >
  12. <button class="admin-button-com middle blue" @click="downloadTable()">价格表</button>
  13. </view>
  14. </view>
  15. <view class="scroll-middle_bx">
  16. <scroll-view scroll-y scroll-with-animation class="tab-view">
  17. <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)">
  18. <text style="text-align: center;">{{ item.name || "" }}</text>
  19. </div>
  20. </scroll-view>
  21. <scroll-view scroll-y class="right-box"
  22. :scroll-top="globalScrollTopPlace"
  23. @scroll="globalGetScroll"
  24. :scroll-into-view="scroll_into_view"
  25. scroll-with-animation="true"
  26. lower-threshold="100"
  27. @scrolltolower="globalScrollBottom">
  28. <block v-if="!$util.isEmpty(globalItemData)">
  29. <view class="item_list_bx selectAll">
  30. <view class="item_list_title"></view>
  31. <view v-if="!$util.isEmpty(globalItemData)">
  32. <template v-for="(productItem, productIndex) in globalItemData">
  33. <view style="height:230upx" :key="productIndex">
  34. <ItemComponent :isPrice="false" :info="productItem" @hideChangeFn="hideChangeFn" :ref="`productRef${productItem.id}`"
  35. @savePrice="savePrice" @cancelDiscountFn="cancelDiscountFn" @cancelFullOff="cancelFullOff" @cancelPreSellFn="cancelPreSellFn"></ItemComponent>
  36. </view>
  37. </template>
  38. </view>
  39. <view v-else>
  40. <view style="height:260upx;text-align:center;color:#CCCCCC;position: relative;">
  41. <view style="position: absolute;margin:auto;top:130upx;left:0;right:0;bottom:0;">暂无花材</view>
  42. </view>
  43. </view>
  44. </view>
  45. </block>
  46. <block v-else>
  47. <view style="width: 100%">
  48. <app-wrapper-empty title="加载中" :is-empty="$util.isEmpty(globalItemData)"/>
  49. </view>
  50. </block>
  51. </scroll-view>
  52. </view>
  53. <div class="app-footer">
  54. <button class="admin-button-com big default" @click="goBatchChange">批量修改</button>
  55. <button class="admin-button-com big blue" style="width:40vw;" @click="commitPrice">保存修改</button>
  56. </div>
  57. <uni-popup ref="globalClassImgRef" background-color="#fff" type="center" :animation="false" class="class-popup-style">
  58. <view style="display:flex;padding:20upx;height:auto;justify-content: space-between;align-items:center;flex-wrap:wrap;max-height:100vh;overflow:auto;">
  59. <view v-for="(item, index) in globalClassData" :key="index" @tap.stop="globalChangeClass(index,item)" style="margin-bottom:20upx;margin-left:3upx;">
  60. <image :src="item.cover" style="width:120upx;height:120upx;border-radius:10upx;"></image>
  61. <view style="margin-top:5upx;overflow: hidden;white-space: nowrap;width:120upx;text-align:center;">{{item.name}}</view>
  62. </view>
  63. </view>
  64. </uni-popup>
  65. <image v-if="showClassRemind" @click="hideClassRemind" style="position:absolute;width:610upx;height:699upx;top:225upx;left:80upx;z-index:9999;" :src="`${constant.imgUrl}/class_remind.png`"></image>
  66. </view>
  67. </view>
  68. </template>
  69. <script>
  70. import AppSearchModule from "@/components/module/app-search";
  71. import AppWrapperEmpty from "@/components/app-wrapper-empty";
  72. import ItemComponent from "./components/Item2";
  73. import productMins from "@/mixins/product2";
  74. import { mapGetters } from "vuex";
  75. import { batchChangePrice,generatePriceTable,cancelDiscountPrice,cancelFullOffFn,cancelPreSell } from '@/api/product'
  76. import { changeFrontHide } from '@/api/item'
  77. export default {
  78. name: "item_list",
  79. components: {
  80. AppSearchModule,
  81. AppWrapperEmpty,
  82. ItemComponent
  83. },
  84. mixins: [productMins],
  85. data() {
  86. return {
  87. autoLoad: false,
  88. selectJobType: "stock",
  89. tabIndex: 0,
  90. priceList:[],
  91. showClassRemind:false
  92. };
  93. },
  94. computed:{
  95. ...mapGetters(["getMyShopInfo","getLoginInfo"]),
  96. },
  97. onLoad() {
  98. this.initProduct()
  99. },
  100. methods: {
  101. goBatchChange(){
  102. this.$util.pageTo({url: '/admin/changePrice/batchChange'})
  103. },
  104. hideChangeFn(item,status){
  105. let that = this
  106. changeFrontHide({id:item.id,status:status}).then(res=>{
  107. if(res.code == 1){
  108. that.$refs[`productRef${item.id}`][0].frontHide = status
  109. }
  110. })
  111. },
  112. selectFlowerNumFn(){
  113. this.$refs.globalClassImgRef.open('top')
  114. },
  115. hideClassRemind(){
  116. },
  117. cancelPreSellFn(item){
  118. let that = this
  119. this.$util.confirmModal({content:'确认取消预售?'},() => {
  120. cancelPreSell({id:item.id}).then(res=>{
  121. if(res.code == 1){
  122. that.$msg(res.msg)
  123. }
  124. })
  125. })
  126. },
  127. cancelFullOff(item){
  128. let that = this
  129. this.$util.confirmModal({content:'确认取消满减?'},() => {
  130. cancelFullOffFn({id:item.id}).then(res=>{
  131. if(res.code == 1){
  132. that.$msg(res.msg)
  133. }
  134. })
  135. })
  136. },
  137. cancelDiscountFn(item){
  138. let that = this
  139. this.$util.confirmModal({content:'确认取消特价?'},() => {
  140. cancelDiscountPrice({id:item.id}).then(res=>{
  141. if(res.code == 1){
  142. that.$msg(res.msg)
  143. }
  144. })
  145. })
  146. },
  147. downloadTable(){
  148. let level = 0
  149. let levelList = ['零售价', '批发价']
  150. uni.showActionSheet({
  151. itemList: levelList,
  152. success: function (respond) {
  153. level = respond.tapIndex
  154. uni.showLoading({title:'下载中',mask:true})
  155. generatePriceTable({level:level}).then(res => {
  156. if(res.code == 1){
  157. uni.hideLoading()
  158. let file = res.data.file
  159. let shortFile = res.data.shortFile
  160. uni.downloadFile({
  161. url: file,
  162. header: {"Content-Type": 'application/vnd.ms-excel'},
  163. filePath: `${wx.env.USER_DATA_PATH}/${shortFile}`,
  164. success: (res) => {
  165. if (res.statusCode === 200) {
  166. wx.saveFileToDisk({
  167. filePath: res.filePath,
  168. success: function(res) {
  169. console.log(res)
  170. },
  171. fail:function(res) {
  172. console.log(res)
  173. }
  174. })
  175. }
  176. },
  177. fail:()=>{
  178. uni.showToast({title:'请用电脑打开小程序下载',mask:true,icon:'none'})
  179. }
  180. });
  181. }
  182. })
  183. }
  184. })
  185. },
  186. initProduct(){
  187. this.globalRequestType = 'changePrice'
  188. this.initData()
  189. },
  190. commitPrice(){
  191. let that = this
  192. if(this.priceList.length == 0){
  193. this.$msg('没有修改')
  194. return;
  195. }
  196. this.$util.confirmModal({content:'确认修改?'},() => {
  197. that.commitChange()
  198. })
  199. },
  200. commitChange(){
  201. let data = JSON.stringify(this.priceList);
  202. batchChangePrice({data:data,appVersion:1}).then(res => {
  203. if(res.code == 1){
  204. this.priceList = [];
  205. this.initProduct()
  206. }
  207. uni.showToast({ title: '修改成功', icon: 'success', })
  208. })
  209. },
  210. savePrice(price,skPrice,hjPrice,id,status){
  211. if(this.priceList.length > 0){
  212. this.priceList.forEach(function(value,index,array){
  213. if(value.id == id){
  214. array.splice(index,1)
  215. }
  216. });
  217. }
  218. if(status == 1){
  219. this.priceList.push({id:id,price:price,skPrice:skPrice,hjPrice:hjPrice})
  220. }
  221. },
  222. affirm(val) {
  223. if (val.index === 0) {
  224. this.modalCancel();
  225. }
  226. }
  227. }
  228. };
  229. </script>
  230. <style lang="scss" scoped>
  231. .billing_box_bg {
  232. height: 100%;
  233. background: white;
  234. display: flex;
  235. background:white;
  236. flex-direction: column;
  237. .input-wrap {
  238. display: flex;
  239. padding: 22upx 20upx 22upx 13upx;
  240. .search-bar {
  241. flex: 1;
  242. }
  243. .city-select {
  244. display: flex;
  245. flex-shrink: 0;
  246. align-items: center;
  247. margin-right: 15upx;
  248. margin-left: 45upx;
  249. background-color: #ffff;
  250. .iconfont {
  251. margin-left: 20upx;
  252. font-size: 30upx;
  253. }
  254. }
  255. }
  256. .scroll-middle_bx {
  257. flex: 1;
  258. display: flex;
  259. width: 100%;
  260. height: 100%;
  261. overflow: hidden;
  262. }
  263. .tab-view {
  264. padding-bottom:100upx;
  265. height: calc(100vh - 140upx);
  266. width: 170upx;
  267. flex-shrink: 0;
  268. background-color: #f0f2f6;
  269. .tab-bar-item {
  270. position: relative;
  271. width: 170upx;
  272. height: 90upx;
  273. box-sizing: border-box;
  274. display: flex;
  275. align-items: center;
  276. justify-content: center;
  277. font-size: 26upx;
  278. color: #444;
  279. font-weight: 400;
  280. .tag {
  281. display: flex;
  282. padding: 0 20upx;
  283. align-items: center;
  284. position: absolute;
  285. right: 0;
  286. top: 0;
  287. height: 32upx;
  288. background: #ff2842;
  289. border-radius: 16upx;
  290. color: #fff;
  291. font-size: 20upx;
  292. }
  293. &:last-child{
  294. margin-bottom: 110upx;
  295. }
  296. }
  297. .active {
  298. position: relative;
  299. color: $mainColor;
  300. font-size: 26upx;
  301. background: #fff;
  302. }
  303. .active::before {
  304. content: "";
  305. position: absolute;
  306. border-left: 8upx solid $mainColor;
  307. height: 100%;
  308. left: 0;
  309. }
  310. }
  311. .right-box {
  312. height: calc(100vh - 200upx);
  313. flex: 1;
  314. box-sizing: border-box;
  315. }
  316. .item_list_bx {
  317. padding: 40upx 16upx;
  318. }
  319. .item_list_title {
  320. margin-bottom: 20upx;
  321. font-size: 24upx;
  322. font-weight: 600;
  323. color: #666666;
  324. }
  325. .select-cmd_bx {
  326. & .kc {
  327. color: #999999;
  328. font-size: 28upx;
  329. font-weight: 400;
  330. margin-bottom: 60upx;
  331. text-align: center;
  332. margin-top: 10upx;
  333. }
  334. & .num_bx {
  335. display: flex;
  336. align-items: center;
  337. margin-bottom: 80upx;
  338. & > input {
  339. width: 212upx;
  340. height: 80upx;
  341. border: 1upx solid #dddddd;
  342. border-radius: 4upx;
  343. text-align: center;
  344. margin-right: 24upx;
  345. }
  346. }
  347. }
  348. .app-footer {
  349. justify-content: space-evenly;
  350. z-index: 9999;
  351. }
  352. }
  353. .class-popup-style{
  354. z-index:999999;
  355. }
  356. </style>