removeList.vue 9.7 KB

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