giftApply.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. <template>
  2. <view class="content">
  3. <view class="filter-box">
  4. <u-search placeholder="请输入关键字" v-model="filterText" @search="setFilterText" @custom="setFilterText"></u-search>
  5. </view>
  6. <u-tabs-swiper ref="uTabs" :active-color="mainColor" :list="tabList" :current="current" @change="tabsChange"
  7. :is-scroll="false"></u-tabs-swiper>
  8. <swiper :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish" class="swiper-box">
  9. <swiper-item class="swiper-item" v-for="(item, index1) in tabList" :key="index1">
  10. <scroll-view scroll-y class="scroll-box" @scrolltolower="handleLoadMore" :refresher-enabled="true"
  11. :refresher-triggered="triggered" :refresher-threshold="100" refresher-background="white" @refresherrefresh="onRefresh"
  12. @refresherrestore="onRestore">
  13. <u-card :show-head="false" :foot-border-top="false" margin="10px 15px" borderRadius="40" :foot-style="{padding: '0 10px 5px 0'}" v-for="(site, index2) in item.tableList"
  14. :key="index2" class="card-box">
  15. <view slot="body" class="card-content">
  16. <view class="student-info">
  17. <view style="width: 100%;">
  18. <text class="info-name" style="margin-right: 10px;">{{ site.studentName }}</text>
  19. <text class="info-name">{{ site.venueName }}</text>
  20. </view>
  21. <view class="info-phone">{{ site.className }}</view>
  22. <template v-if="site.giftList.length">
  23. <view class="info-phone" v-for="(iten, index3) in site.giftList" :key="index3">{{ iten.name }}</view>
  24. </template>
  25. <view class="info-phone">{{ getStatus(site.approvalStatus) }}</view>
  26. </view>
  27. </view>
  28. <view slot="foot" style="text-align: right;" v-if="site.giftType == 0 && site.approvalStatus == 3" >
  29. <u-button type="warning" :ripple="true" shape="circle" :custom-style="{...handleCustomStyle, marginRight: '5px'}" size="mini" @click="handleGiveClick(site.id,site.venueId)">赠送</u-button>
  30. <u-button type="warning" :ripple="true" shape="circle" :custom-style="handleCustomStyle" size="mini" @click="handleNoGiveClick(site.id)">不送</u-button>
  31. </view>
  32. </u-card>
  33. <u-divider v-if="item.isOver" bg-color="transparent" :style="{paddingTop : item.tableList.length == 0 ? '10px' : ''}">没有更多了</u-divider>
  34. </scroll-view>
  35. </swiper-item>
  36. </swiper>
  37. <!-- 礼物数据 -->
  38. <u-popup v-model="giftShow" mode="center" border-radius="30" width="600rpx" height="500px" >
  39. <view class="common-title">礼物</view>
  40. <view class="menber-box" style="overflow-y: auto;height:390px;">
  41. <u-form :model="form" ref="giftForm" label-width="80">
  42. <view style="display:flex;justify-content: space-between;" v-for="(item,index) in formInfo" :key="index">
  43. <u-form-item label="商品" :prop="item.signOne" required right-icon="arrow-right" style="width:44%;" @click.native="handleShowProductClick(index)">
  44. <text>{{ item.signOne }}</text>
  45. </u-form-item>
  46. <u-form-item label="规格" :prop="item.two" required right-icon="arrow-right" style="width:44%;" @click.native="handleShowSpecClick(index)">
  47. <text>{{ item.signTwo }}</text>
  48. </u-form-item>
  49. <u-icon v-if="formInfo.length != 1" name="minus-circle" size="34" @click="handleGiftDelClick(index)"></u-icon>
  50. </view>
  51. <view style="width:100;display:flex;justify-content: flex-end;">
  52. <u-button type="warning" :ripple="true" size="mini" :custom-style="{ backgroundColor: mainColor }" @click="handleGiftAddClick">添加</u-button>
  53. </view>
  54. </u-form>
  55. </view>
  56. <view class="button-box">
  57. <u-button type="warning" shape="circle" :ripple="true" :custom-style="customStyle" @click="handleSubmitClick">确定</u-button>
  58. </view>
  59. </u-popup>
  60. <!-- 商品 -->
  61. <u-picker mode="selector" v-model="productShow" :range="productList" @confirm="handleSetProductClick" title="礼物" range-key="text"></u-picker>
  62. <!-- 规格 -->
  63. <u-picker mode="selector" v-model="specShow" :range="specList" @confirm="handleSetSpecClick" title="规格" range-key="text"></u-picker>
  64. <u-top-tips ref="uTips" z-index="12000"></u-top-tips>
  65. </view>
  66. </template>
  67. <script>
  68. import {
  69. mapGetters
  70. } from 'vuex'
  71. const NET = require('@/utils/request')
  72. const API = require('@/config/api')
  73. export default {
  74. data() {
  75. return {
  76. listId: 0,
  77. venueId: 0,
  78. // filterText: '',
  79. triggered: false,
  80. formInfo: [
  81. {
  82. signOneId: '',
  83. signOne: '',
  84. signTwoId: '',
  85. signTwo: ''
  86. }
  87. ],
  88. tabList: [
  89. {
  90. name: '未赠送',
  91. isOver: false,
  92. pageIndex: 1,
  93. filterText: '',
  94. tableList: [],
  95. }, {
  96. name: '已赠送',
  97. isOver: false,
  98. pageIndex: 1,
  99. filterText: '',
  100. tableList: [],
  101. }, {
  102. name: '不赠送',
  103. isOver: false,
  104. pageIndex: 1,
  105. filterText: '',
  106. tableList: [],
  107. }],
  108. current: 0,
  109. swiperCurrent: 0,
  110. giftIndex: 0,
  111. giftShow: false,
  112. productShow: false,
  113. productList: [],
  114. specShow: false,
  115. specList: [],
  116. }
  117. },
  118. onShow() {
  119. this.getData()
  120. },
  121. computed: {
  122. ...mapGetters([
  123. 'mainColor',
  124. 'customStyle',
  125. 'handleCustomStyle',
  126. 'handleDefaultCustomStyle',
  127. ]),
  128. getStatus() {
  129. return function(index) {
  130. switch (index) {
  131. case 0:
  132. return '待审批'
  133. case 1:
  134. return '审批通过'
  135. case 2:
  136. return '驳回'
  137. case 3:
  138. return '提交'
  139. }
  140. }
  141. }
  142. },
  143. methods: {
  144. getData() {
  145. this.tabList = Object.assign([], this.$options.data().tabList)
  146. this.getTableList(0)
  147. this.getTableList(1)
  148. this.getTableList(2)
  149. },
  150. handleGiveClick(id,venueId) {
  151. this.giftShow = true
  152. this.listId = id
  153. this.venueId = venueId
  154. },
  155. handleShowProductClick(index) {
  156. this.giftIndex = index
  157. NET.request(API.findVenueGiftOneList, {
  158. id: this.venueId
  159. }, 'POST').then(res => {
  160. this.productList = res.data
  161. this.productShow = true
  162. })
  163. },
  164. handleSetProductClick(index) {
  165. this.formInfo[this.giftIndex].signOneId = this.productList[index].id
  166. this.formInfo[this.giftIndex].signOne = this.productList[index].text
  167. },
  168. handleShowSpecClick(index) {
  169. this.giftIndex = index
  170. if(!this.formInfo[this.giftIndex].signOneId) {
  171. this.$refs.uTips.show({
  172. title: '请先选择商品',
  173. type: 'warning',
  174. })
  175. return
  176. }
  177. const giftId = this.formInfo[this.giftIndex].signOneId
  178. const venueId = this.venueId
  179. NET.request(API.findVenueGiftTwoList, {
  180. giftId, venueId
  181. }, 'POST').then(res => {
  182. this.specList = res.data
  183. this.specShow = true
  184. })
  185. },
  186. handleSetSpecClick(index) {
  187. this.formInfo[this.giftIndex].signTwoId = this.specList[index].id
  188. this.formInfo[this.giftIndex].signTwo = this.specList[index].text
  189. },
  190. handleGiftAddClick() {
  191. this.formInfo.push({
  192. signOneId: '',
  193. signOne: '',
  194. signTwoId: '',
  195. signTwo: ''
  196. })
  197. },
  198. handleGiftDelClick(index) {
  199. this.formInfo.splice(index,1)
  200. },
  201. handleSubmitClick() {
  202. let flag = true
  203. this.formInfo.forEach( item => {
  204. if(!item.signOneId) {
  205. this.$refs.uTips.show({
  206. title: '请选择要赠送的礼物',
  207. type: 'warning',
  208. })
  209. flag = false
  210. return
  211. }
  212. if(item.signOneId && !item.signTwoId) {
  213. this.$refs.uTips.show({
  214. title: `请选择商品${item.signOne}的规格`,
  215. type: 'warning',
  216. })
  217. flag = false
  218. return
  219. }
  220. })
  221. if(flag) {
  222. const id = this.listId
  223. const venueId = this.venueId
  224. const giftIds = this.formInfo.filter(item => item.signTwoId != '').map( item => {
  225. return item.signTwoId
  226. })
  227. NET.request(API.giveGiftStudent, {
  228. id, venueId, giftIds
  229. }, 'POST').then(res => {
  230. if(res.status == 10000) {
  231. this.$refs.uTips.show({
  232. title: res.message,
  233. type: 'success',
  234. })
  235. } else {
  236. this.$refs.uTips.show({
  237. title: res.message,
  238. type: 'warning',
  239. })
  240. }
  241. this.getData()
  242. this.giftShow = false
  243. }).catch(error => {
  244. this.$refs.uTips.show({
  245. title: error.message,
  246. type: 'warning',
  247. })
  248. })
  249. }
  250. },
  251. // 不送
  252. handleNoGiveClick(id) {
  253. NET.request(API.giveGiftRefuse, {
  254. id
  255. }, 'POST').then(res => {
  256. if(res.status == 10000) {
  257. this.$refs.uTips.show({
  258. title: res.message,
  259. type: 'success',
  260. })
  261. } else {
  262. this.$refs.uTips.show({
  263. title: res.message,
  264. type: 'warning',
  265. })
  266. }
  267. this.getData()
  268. })
  269. },
  270. // 获取列表数据
  271. getTableList(index) {
  272. NET.request(API.giftStudentPage, {
  273. giftType: index,
  274. name: this.tabList[index].filterText,
  275. page: this.tabList[index].pageIndex,
  276. size: 10,
  277. }, 'POST').then(res => {
  278. this.triggered = false
  279. this.tabList[index].tableList = this.tabList[index].tableList.concat(res.data.row)
  280. this.tabList[index].isOver = res.data.row.length != 10
  281. }).catch(error => {
  282. this.triggered = false
  283. this.$refs.uTips.show({
  284. title: error.msg,
  285. type: 'warning',
  286. })
  287. })
  288. },
  289. // 设置过滤字段
  290. setFilterText(value) {
  291. this.tabList[this.current].filterText = value
  292. this.onRefresh()
  293. },
  294. // tab页面切换
  295. tabsChange(index) {
  296. this.swiperCurrent = index;
  297. },
  298. // swiper-item左右移动,通知tabs的滑块跟随移动
  299. transition(e) {
  300. let dx = e.detail.dx;
  301. this.$refs.uTabs.setDx(dx);
  302. },
  303. // swiper滑动结束,分别设置tabs和swiper的状态
  304. animationfinish(e) {
  305. let current = e.detail.current;
  306. this.$refs.uTabs.setFinishCurrent(current);
  307. this.swiperCurrent = current;
  308. this.current = current;
  309. },
  310. // 下拉刷新
  311. onRefresh() {
  312. if (!this.triggered) {
  313. this.triggered = true
  314. this.tabList[this.current].isOver = false
  315. this.tabList[this.current].pageIndex = 1
  316. this.tabList[this.current].tableList = []
  317. this.getTableList(this.current)
  318. }
  319. },
  320. // 重置下拉刷新状态
  321. onRestore() {
  322. this.triggered = 'restore'
  323. this.triggered = false
  324. },
  325. // 懒加载
  326. handleLoadMore() {
  327. if (!this.tabList[this.current].isOver) {
  328. this.tabList[this.current].pageIndex++
  329. this.getTableList(this.current)
  330. }
  331. }
  332. },
  333. }
  334. </script>
  335. <style>
  336. page {
  337. width: 100%;
  338. height: 100%;
  339. background-color: #f7f7f7;
  340. }
  341. </style>
  342. <style lang="scss" scoped>
  343. @import "@/static/css/themes.scss";
  344. .content {
  345. width: 100%;
  346. float: left;
  347. .filter-box {
  348. height: 48px;
  349. padding: 10px 15px;
  350. background-color: #FFFFFF;
  351. }
  352. .swiper-box {
  353. height: calc(100vh - 82px);
  354. .swiper-item {
  355. height: calc(100vh - 82px);
  356. .scroll-box {
  357. width: 100%;
  358. height: calc(100vh - 82px);
  359. .card-box {
  360. .card-content {
  361. display: flex;
  362. align-items: center;
  363. .student-info {
  364. flex: 1;
  365. .info-name {
  366. // width: 64px;
  367. // float: left;
  368. line-height: 28px;
  369. font-size: 14px;
  370. font-weight: bold;
  371. }
  372. .info-type {
  373. padding: 0 10px;
  374. margin-top: 3px;
  375. border-radius: 20px;
  376. float: left;
  377. line-height: 20px;
  378. font-size: 10px;
  379. color: #FFFFFF;
  380. background-color: #999999;
  381. }
  382. .info-type-active {
  383. background-color: $mainColor;
  384. }
  385. .info-phone {
  386. // float: left;
  387. line-height: 28px;
  388. font-size: 12px;
  389. color: #999999;
  390. }
  391. }
  392. }
  393. }
  394. }
  395. }
  396. }
  397. }
  398. .menber-box {
  399. width: 100%;
  400. // float: left;
  401. padding: 10px 15px;
  402. margin-bottom: 10px;
  403. .menber-col {
  404. width: 100%;
  405. padding: 15px;
  406. margin-bottom: 10px;
  407. display: inline-block;
  408. background-color: #FFFFFF;
  409. border-radius: 15px;
  410. box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.2);
  411. position: relative;
  412. overflow: hidden;
  413. box-sizing: border-box;
  414. .menber-label {
  415. width: 100%;
  416. margin-bottom: 5px;
  417. float: left;
  418. font-size: 14px;
  419. // line-height: 20px;
  420. }
  421. .menber-num {
  422. width: 100%;
  423. float: left;
  424. font-size: 26px;
  425. line-height: 28px;
  426. color: $mainColor;
  427. }
  428. .menber-icon {
  429. font-size: 100px;
  430. color: $mainColor;
  431. position: absolute;
  432. right: -5px;
  433. bottom: -30px;
  434. opacity: 0.5;
  435. }
  436. }
  437. }
  438. .common-title {
  439. width:100%;
  440. text-align: center;
  441. font-size: 20px;
  442. margin: 10px 0;
  443. }
  444. .fix-add-icon {
  445. position: fixed;
  446. bottom: 15px;
  447. right: 15px;
  448. }
  449. .button-box {
  450. // width: 100%;
  451. padding: 10px 15px;
  452. box-sizing: border-box;
  453. }
  454. </style>