giftApply.vue 13 KB

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