changeHide.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. <template>
  2. <view class="app-content">
  3. <!-- 顶部筛选标签 -->
  4. <view class="modern-tabs-container">
  5. <view class="modern-tabs">
  6. <view class="modern-tab" :class="{ 'active': globalLookStock === 0 }" @click="changeHasStock(0)">
  7. <view class="tab-content">
  8. <text class="tab-text">全部</text>
  9. </view>
  10. </view>
  11. <view class="modern-tab" :class="{ 'active': globalLookStock === 1 }" @click="changeHasStock(1)">
  12. <view class="tab-content">
  13. <text class="tab-text">有库存</text>
  14. </view>
  15. </view>
  16. <view class="modern-tab" :class="{ 'active': globalLookStock === 2 }" @click="changeHasStock(2)">
  17. <view class="tab-content">
  18. <text class="tab-text">没库存</text>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. <!-- 主容器 -->
  24. <view class="billing_box_bg">
  25. <!-- 搜索栏 -->
  26. <view class="input-wrap">
  27. <view style="padding:0upx 0upx 0upx 0upx;margin-right:10upx;">
  28. <button class="admin-button-com middle blue" @click="selectFlowerNumFn()">图片分类</button>
  29. </view>
  30. <view class="search-bar">
  31. <app-search-module ref="globalSearchRef" v-model="globalPy" placeholder="这里搜索" @input="globalSearch" />
  32. </view>
  33. </view>
  34. <!-- 主内容区 -->
  35. <view class="scroll-middle_bx">
  36. <scroll-view scroll-y scroll-with-animation class="tab-view">
  37. <div v-for="(item, index) in globalClassData" :key="index" class="tab-bar-item" :class="[globalClassIndex == index ? 'active' : '']" @tap.stop="currentSwitchClass(index,item)">
  38. <text>{{ item.name || "" }}</text>
  39. </div>
  40. </scroll-view>
  41. <scroll-view scroll-y class="right-box"
  42. :scroll-top="globalScrollTopPlace"
  43. @scroll="globalGetScroll"
  44. :scroll-into-view="scroll_into_view"
  45. scroll-with-animation="true"
  46. lower-threshold="100"
  47. @scrolltolower="globalScrollBottom">
  48. <!-- 内容列表 -->
  49. <block v-if="!$util.isEmpty(globalItemData)">
  50. <view class="item_list_bx">
  51. <!-- 按分类分组显示 -->
  52. <view v-for="(groupData, groupIndex) in itemGroups" :key="groupIndex">
  53. <!-- 分类标题 + 全选按钮 -->
  54. <view class="item_list_title" v-if="groupData.className">
  55. <view class="title-row">
  56. <text class="class-name">{{ groupData.className }}</text>
  57. <text class="select-all-btn" @click.stop="toggleGroupSelection(groupIndex)">
  58. {{ isGroupAllSelected(groupIndex) ? '全不选' : '全选' }}
  59. </text>
  60. </view>
  61. </view>
  62. <!-- 分类下的商品 -->
  63. <view v-for="(productItem, itemIndex) in groupData.items" :key="productItem.id" style="height:190upx">
  64. <ItemComponent
  65. :isPrice="false"
  66. :info="productItem"
  67. :isChecked="isItemChecked(productItem.id)"
  68. @checkChange="handleItemCheck(productItem, $event)"
  69. @cancelPreSellFn="cancelPreSellFn">
  70. </ItemComponent>
  71. </view>
  72. </view>
  73. </view>
  74. </block>
  75. <!-- 空状态 -->
  76. <block v-else>
  77. <view style="width: 100%">
  78. <app-wrapper-empty title="暂无数据" :is-empty="$util.isEmpty(globalItemData)"/>
  79. </view>
  80. </block>
  81. </scroll-view>
  82. </view>
  83. <!-- 底部按钮 -->
  84. <div class="app-footer">
  85. <button class="admin-button-com big blue footer-btn-left" @click="commitShow">批量显示</button>
  86. <button class="admin-button-com big blue footer-btn-right" @click="commitHide">批量隐藏</button>
  87. </div>
  88. <!-- 分类选择弹窗 -->
  89. <uni-popup ref="globalClassImgRef" background-color="#fff" type="center" :animation="false" class="class-popup-style">
  90. <view style="display:flex;padding:20upx;height:auto;justify-content: space-between;align-items:center;flex-wrap:wrap;max-height:100vh;overflow:auto;">
  91. <view v-for="(item, index) in globalClassData" :key="index" @tap.stop="currentChangeClass(index,item)" style="margin-bottom:20upx;margin-left:3upx;">
  92. <image :src="item.cover" style="width:120upx;height:120upx;border-radius:10upx;"></image>
  93. <view style="margin-top:5upx;overflow: hidden;white-space: nowrap;width:120upx;text-align:center;">{{item.name}}</view>
  94. </view>
  95. </view>
  96. </uni-popup>
  97. </view>
  98. </view>
  99. </template>
  100. <script>
  101. import AppSearchModule from "@/components/module/app-search";
  102. import AppWrapperEmpty from "@/components/app-wrapper-empty";
  103. import ItemComponent from "./components/changeHide";
  104. import productMins from "@/mixins/product2";
  105. import { mapGetters } from "vuex";
  106. import { batchChangeFrontHide } from "@/api/item";
  107. import { cancelPreSell } from '@/api/product'
  108. export default {
  109. name: "changeHide",
  110. components: {
  111. AppSearchModule,
  112. AppWrapperEmpty,
  113. ItemComponent
  114. },
  115. mixins: [productMins],
  116. data() {
  117. return {
  118. autoLoad: false,
  119. selectJobType: "stock",
  120. selectedIdsSet: new Set()
  121. };
  122. },
  123. computed: {
  124. ...mapGetters(["getMyShopInfo","getLoginInfo"]),
  125. selectedCount() {
  126. return this.selectedIdsSet.size;
  127. },
  128. itemGroups() {
  129. if (this.$util.isEmpty(this.globalItemData)) {
  130. return [];
  131. }
  132. const groups = [];
  133. let currentGroup = null;
  134. this.globalItemData.forEach((item) => {
  135. if (item.className && item.className !== '') {
  136. currentGroup = {
  137. className: item.className,
  138. items: [item]
  139. };
  140. groups.push(currentGroup);
  141. } else if (currentGroup) {
  142. currentGroup.items.push(item);
  143. }
  144. });
  145. return groups;
  146. }
  147. },
  148. onLoad() {
  149. this.initProduct()
  150. },
  151. methods: {
  152. isItemChecked(itemId) {
  153. return this.selectedIdsSet.has(itemId);
  154. },
  155. handleItemCheck(productItem, isChecked) {
  156. const id = productItem.id;
  157. if (isChecked) {
  158. this.selectedIdsSet.add(id);
  159. } else {
  160. this.selectedIdsSet.delete(id);
  161. }
  162. this.$forceUpdate();
  163. },
  164. isGroupAllSelected(groupIndex) {
  165. const group = this.itemGroups[groupIndex];
  166. if (!group || group.items.length === 0) return false;
  167. return group.items.every(item => this.selectedIdsSet.has(item.id));
  168. },
  169. toggleGroupSelection(groupIndex) {
  170. const group = this.itemGroups[groupIndex];
  171. if (!group) return;
  172. const isAllSelected = this.isGroupAllSelected(groupIndex);
  173. group.items.forEach(item => {
  174. if (isAllSelected) {
  175. this.selectedIdsSet.delete(item.id);
  176. } else {
  177. this.selectedIdsSet.add(item.id);
  178. }
  179. });
  180. this.$forceUpdate();
  181. },
  182. selectFlowerNumFn(){
  183. this.$refs.globalClassImgRef.open('top')
  184. },
  185. changeHasStock(check){
  186. this.globalLookStock = check
  187. this.reGetGlobalProductList()
  188. },
  189. cancelPreSellFn(item){
  190. this.$util.confirmModal({content:'确认取消预售?'},() => {
  191. cancelPreSell({id:item.id}).then(res=>{
  192. if(res.code == 1){
  193. this.$msg(res.msg)
  194. }
  195. })
  196. })
  197. },
  198. initProduct(){
  199. this.globalRequestType = 'itemList'
  200. this.initData()
  201. uni.hideLoading()
  202. },
  203. commitHide(){
  204. if(this.selectedIdsSet.size === 0){
  205. this.$msg('请选择花材')
  206. return;
  207. }
  208. this.$util.confirmModal({content:'确认隐藏 ' + this.selectedIdsSet.size + ' 个花材?'},() => {
  209. this.commitChange(1)
  210. })
  211. },
  212. commitShow(){
  213. if(this.selectedIdsSet.size === 0){
  214. this.$msg('请选择花材')
  215. return;
  216. }
  217. this.$util.confirmModal({content:'确认显示 ' + this.selectedIdsSet.size + ' 个花材?'},() => {
  218. this.commitChange(0)
  219. })
  220. },
  221. commitChange(hideStatus){
  222. const ids = Array.from(this.selectedIdsSet);
  223. batchChangeFrontHide({ids:JSON.stringify(ids), frontHide: hideStatus}).then(res=>{
  224. if(res.code == 1){
  225. this.$msg(res.msg)
  226. this.initData()
  227. }
  228. })
  229. },
  230. currentSwitchClass(index,item){
  231. this.globalSwitchClass(index,item)
  232. },
  233. currentChangeClass(index,item){
  234. this.$refs.globalClassImgRef.close()
  235. this.globalSwitchClass(index,item)
  236. }
  237. }
  238. };
  239. </script>
  240. <style lang="scss" scoped>
  241. .app-content {
  242. display: flex;
  243. flex-direction: column;
  244. height: 100vh;
  245. overflow: hidden;
  246. background: white;
  247. }
  248. .modern-tabs-container {
  249. flex-shrink: 0;
  250. padding: 0;
  251. background-color: #f8f9fa;
  252. width: 100%;
  253. }
  254. .modern-tabs {
  255. display: flex;
  256. background-color: #ffffff;
  257. padding: 6upx;
  258. box-shadow: 0 2upx 12upx rgba(0, 0, 0, 0.06);
  259. border: 2upx solid #f0f2f5;
  260. position: relative;
  261. z-index: 5;
  262. width: 100%;
  263. }
  264. .modern-tab {
  265. flex: 1;
  266. text-align: center;
  267. padding: 30upx 0;
  268. position: relative;
  269. transition: all 0.35s cubic-bezier(0.25, 1, 0.5, 1);
  270. border-radius: 12upx;
  271. margin: 0 2upx;
  272. background-color: #e2dfdf;
  273. border: 2upx solid #f2f4f7;
  274. box-shadow: none;
  275. .tab-content {
  276. display: flex;
  277. flex-direction: column;
  278. align-items: center;
  279. justify-content: center;
  280. }
  281. .tab-text {
  282. font-size: 30upx;
  283. color: #666;
  284. font-weight: 700;
  285. }
  286. &.active {
  287. background: #3385FF;
  288. .tab-text {
  289. color: #ffffff;
  290. font-weight: 700;
  291. font-size: 30upx;
  292. }
  293. }
  294. &:not(.active):hover {
  295. background-color: #f6f7f9;
  296. border-color: #e9ecef;
  297. }
  298. }
  299. .billing_box_bg {
  300. flex: 1;
  301. background: white;
  302. display: flex;
  303. flex-direction: column;
  304. overflow: hidden;
  305. .input-wrap {
  306. display: flex;
  307. padding: 22upx 20upx 22upx 13upx;
  308. flex-shrink: 0;
  309. .search-bar {
  310. flex: 1;
  311. }
  312. }
  313. .scroll-middle_bx {
  314. flex: 1;
  315. display: flex;
  316. width: 100%;
  317. overflow: hidden;
  318. }
  319. .tab-view {
  320. width: 170upx;
  321. flex-shrink: 0;
  322. background-color: #f0f2f6;
  323. padding-bottom: 100upx;
  324. .tab-bar-item {
  325. position: relative;
  326. width: 170upx;
  327. height: 90upx;
  328. box-sizing: border-box;
  329. display: flex;
  330. align-items: center;
  331. justify-content: center;
  332. font-size: 26upx;
  333. color: #444;
  334. font-weight: 400;
  335. &:last-child {
  336. margin-bottom: 110upx;
  337. }
  338. &.active {
  339. position: relative;
  340. color: $mainColor;
  341. font-size: 26upx;
  342. background: #fff;
  343. &::before {
  344. content: "";
  345. position: absolute;
  346. border-left: 8upx solid $mainColor;
  347. height: 100%;
  348. left: 0;
  349. }
  350. }
  351. }
  352. }
  353. .right-box {
  354. flex: 1;
  355. box-sizing: border-box;
  356. }
  357. .item_list_bx {
  358. padding: 40upx 16upx;
  359. .item_list_title {
  360. margin-bottom: 20upx;
  361. font-size: 34upx;
  362. font-weight: 600;
  363. color: #3385FF;
  364. .title-row {
  365. width: 100%;
  366. display: flex;
  367. justify-content: space-between;
  368. align-items: center;
  369. }
  370. .class-name {
  371. flex: 1;
  372. }
  373. .select-all-btn {
  374. color: #3385FF;
  375. font-size: 34upx;
  376. font-weight: bold;
  377. padding: 8upx 16upx;
  378. white-space: nowrap;
  379. background: #E8F2FF;
  380. border-radius: 8upx;
  381. }
  382. }
  383. }
  384. .app-footer {
  385. display: flex;
  386. justify-content: center;
  387. align-items: center;
  388. z-index: 9999;
  389. flex-shrink: 0;
  390. padding: 20upx;
  391. background: white;
  392. box-shadow: 0 -2upx 8upx rgba(0, 0, 0, 0.1);
  393. .footer-btn-left {
  394. width: 280upx;
  395. margin-right: 40upx;
  396. }
  397. .footer-btn-right {
  398. width: 280upx;
  399. }
  400. }
  401. }
  402. .class-popup-style {
  403. z-index: 999999;
  404. }
  405. </style>