batchChange.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  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 style="text-align: center;">{{ 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" @checkItem="checkItemEvent" :info="productItem"></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="changeSelectItem()">修改所选花材价格</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. <modal-module :show="showClassModel" @cancel="cancelModifyModel" @click="confirmModifyClass" title=" " color="#333" :size="32" padding="30rpx 30rpx" >
  63. <template slot="customContent">
  64. <view style="padding:30upx 0">
  65. <view class="module-com input-line-wrap">
  66. <tui-list-cell class="line-cell" :arrow="false" :hover="false">
  67. <view class="tui-title">大客价</view>
  68. <input type="digit" placeholder="请填写大客价" v-model="form.hjPrice" @focus="form.hjPrice=''" placeholder-class="tui-placeholder"/>
  69. </tui-list-cell>
  70. <tui-list-cell class="line-cell" :arrow="false" :hover="false">
  71. <view class="tui-title" style="color:#3385FF;font-weight:bold;">批发价</view>
  72. <input type="digit" placeholder="请填写批发价" v-model="form.price" @focus="form.price=''" placeholder-class="tui-placeholder"/>
  73. </tui-list-cell>
  74. <tui-list-cell class="line-cell" :arrow="false" :hover="false">
  75. <view class="tui-title">零售价</view>
  76. <input type="digit" placeholder="请填写零售价" v-model="form.skPrice" @focus="form.skPrice=''" placeholder-class="tui-placeholder"/>
  77. </tui-list-cell>
  78. </view>
  79. </view>
  80. </template>
  81. </modal-module>
  82. </view>
  83. </view>
  84. </template>
  85. <script>
  86. import AppSearchModule from "@/components/module/app-search";
  87. import AppWrapperEmpty from "@/components/app-wrapper-empty";
  88. import ItemComponent from "./components/changeClassItem";
  89. import productMins from "@/mixins/product";
  90. import { manyItemChangeOnePrice } from "@/api/product";
  91. import { mapGetters } from "vuex";
  92. import ModalModule from "@/components/plugin/modal";
  93. import TuiListCell from "@/components/plugin/list-cell";
  94. export default {
  95. name: "batchChangePrice",
  96. components: {
  97. AppSearchModule,
  98. AppWrapperEmpty,
  99. ItemComponent,
  100. ModalModule,
  101. TuiListCell
  102. },
  103. mixins: [productMins],
  104. data() {
  105. return {
  106. autoLoad: false,
  107. selectJobType: "batchChangePrice",
  108. tabIndex: 0,
  109. priceArr:[],
  110. showClassRemind:false,
  111. currentList:[],
  112. showClassModel:false,
  113. form:{price:'',hjPrice:'',skPrice:''}
  114. };
  115. },
  116. computed:{
  117. ...mapGetters(["getMyShopInfo","getLoginInfo"]),
  118. },
  119. onLoad() {
  120. this.initProduct()
  121. },
  122. methods: {
  123. getCurrentAll(index){
  124. let that = this
  125. let child = this.globalClassItemList[index] && this.globalClassItemList[index].child ? this.globalClassItemList[index].child : []
  126. if(!this.$util.isEmpty(child)){
  127. child.forEach((item) => {
  128. let id = item.id
  129. let current = 'item_'+id
  130. that.$refs[current][0].checkEvent()
  131. })
  132. }
  133. },
  134. changeSelectItem(){
  135. let that = this
  136. if(this.$util.isEmpty(this.currentList)){
  137. this.$msg('请选择花材')
  138. return false
  139. }
  140. this.showClassModel = true
  141. },
  142. confirmModifyClass(val){
  143. if (val.index === 0) {
  144. this.cancelModifyModel();
  145. return false
  146. }
  147. let that = this
  148. if(this.$util.isEmpty(this.currentList)){
  149. this.$msg('请选择花材')
  150. return false
  151. }
  152. if(Number(this.form.price)<=0){
  153. this.$msg('请填写批发价')
  154. return false;
  155. }
  156. if(Number(this.form.hjPrice)<=0){
  157. this.$msg('请填写大客价')
  158. return false;
  159. }
  160. if(Number(this.form.skPrice)<=0){
  161. this.$msg('请填写零售价')
  162. return false;
  163. }
  164. if(Number(this.form.hjPrice) > Number(this.form.price)){
  165. this.$msg('大客价不能大于批发价')
  166. return false
  167. }
  168. if(Number(this.form.price) > Number(this.form.skPrice)){
  169. this.$msg('批发价不能大于零售价')
  170. return false
  171. }
  172. this.$util.confirmModal({content:'确认修改?'},() => {
  173. manyItemChangeOnePrice({ids:JSON.stringify(that.currentList),...that.form}).then(res=>{
  174. if(res.code == 1){
  175. that.cancelModifyModel()
  176. that.$msg(res.msg)
  177. that.form.price=''
  178. that.form.skPrice=''
  179. that.form.hjPrice=''
  180. that.initProduct()
  181. }
  182. })
  183. })
  184. },
  185. cancelModifyModel() {
  186. this.showClassModel = false;
  187. },
  188. checkItemEvent(item,check) {
  189. let id = item.id
  190. if(check == true){
  191. const index = this.currentList.indexOf(id);
  192. if (index == -1) {
  193. this.currentList.push(id)
  194. }
  195. }else{
  196. const index = this.currentList.indexOf(id);
  197. if (index > -1) {
  198. this.currentList.splice(index, 1)
  199. }
  200. }
  201. },
  202. changeClass(index){
  203. this.$refs.selectFlowerNumRef.close()
  204. this.swichClass(index)
  205. },
  206. selectFlowerNumFn(){
  207. this.$refs.selectFlowerNumRef.open('top')
  208. },
  209. initProduct(){
  210. this.initData({ requestType:'itemList',status:0,delStatus:0})
  211. }
  212. }
  213. };
  214. </script>
  215. <style lang="scss" scoped>
  216. .billing_box_bg {
  217. height: 100%;
  218. background: white;
  219. display: flex;
  220. background:white;
  221. flex-direction: column;
  222. .input-wrap {
  223. display: flex;
  224. padding: 22upx 20upx 22upx 13upx;
  225. .search-bar {
  226. flex: 1;
  227. }
  228. .city-select {
  229. display: flex;
  230. flex-shrink: 0;
  231. align-items: center;
  232. margin-right: 15upx;
  233. margin-left: 45upx;
  234. background-color: #ffff;
  235. .iconfont {
  236. margin-left: 20upx;
  237. font-size: 30upx;
  238. }
  239. }
  240. }
  241. .scroll-middle_bx {
  242. flex: 1;
  243. display: flex;
  244. width: 100%;
  245. height: 100%;
  246. overflow: hidden;
  247. }
  248. .tab-view {
  249. height: calc(100vh - 140upx);
  250. width: 170upx;
  251. flex-shrink: 0;
  252. background-color: #f0f2f6;
  253. .tab-bar-item {
  254. position: relative;
  255. width: 170upx;
  256. height: 90upx;
  257. box-sizing: border-box;
  258. display: flex;
  259. align-items: center;
  260. justify-content: center;
  261. font-size: 26upx;
  262. color: #444;
  263. font-weight: 400;
  264. .tag {
  265. display: flex;
  266. padding: 0 20upx;
  267. align-items: center;
  268. position: absolute;
  269. right: 0;
  270. top: 0;
  271. height: 32upx;
  272. background: #ff2842;
  273. border-radius: 16upx;
  274. color: #fff;
  275. font-size: 20upx;
  276. }
  277. &:last-child{
  278. margin-bottom: 110upx;
  279. }
  280. }
  281. .active {
  282. position: relative;
  283. color: $mainColor;
  284. font-size: 26upx;
  285. background: #fff;
  286. }
  287. .active::before {
  288. content: "";
  289. position: absolute;
  290. border-left: 8upx solid $mainColor;
  291. height: 100%;
  292. left: 0;
  293. }
  294. }
  295. .right-box {
  296. height: calc(100vh - 230upx);
  297. flex: 1;
  298. box-sizing: border-box;
  299. }
  300. .item_list_bx {
  301. padding: 40upx 16upx;
  302. }
  303. .item_list_title {
  304. margin-bottom: 20upx;
  305. font-size: 30upx;
  306. font-weight: 600;
  307. color: #3385FF;
  308. }
  309. .select-cmd_bx {
  310. & .kc {
  311. color: #999999;
  312. font-size: 28upx;
  313. font-weight: 400;
  314. margin-bottom: 60upx;
  315. text-align: center;
  316. margin-top: 10upx;
  317. }
  318. & .num_bx {
  319. display: flex;
  320. align-items: center;
  321. margin-bottom: 80upx;
  322. & > input {
  323. width: 212upx;
  324. height: 80upx;
  325. border: 1upx solid #dddddd;
  326. border-radius: 4upx;
  327. text-align: center;
  328. margin-right: 24upx;
  329. }
  330. }
  331. }
  332. .app-footer {
  333. justify-content: space-evenly;
  334. z-index: 9999;
  335. .admin-button-com {
  336. width: 60%;
  337. }
  338. button{
  339. width:600upx;
  340. }
  341. }
  342. }
  343. .class-popup-style{
  344. z-index:999999;
  345. }
  346. </style>