changeClass.vue 9.2 KB

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