index.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <template>
  2. <!-- 结算中心页面 -->
  3. <view>
  4. <view class="top">
  5. <view class="content" v-for="(item,index) in datalist" :key="index">
  6. <view class="content-one">
  7. </view>
  8. <view style="display: flex;justify-content: space-between;">
  9. <text class="content-two">{{item.agentName}}</text>
  10. <text class="content-three" @click="button(index)">核销返利</text>
  11. </view>
  12. <view class="content-four">
  13. <text>品牌</text>
  14. <text>奖励</text>
  15. <text @click="checkedAll(index,item)" :key='index'>全选</text>
  16. </view>
  17. <checkbox-group @change="checkboxChange($event,index,item.storegentBrandList)">
  18. <view class="content-five" v-for="(item,brandIndex) in item.storegentBrandList" :key="brandIndex">
  19. <view class="content-five-img">
  20. <u-image width="100%" height="80%" scaleType="matrix" :src="item.logoUrl"></u-image>
  21. </view>
  22. <view class="content-five-view">
  23. {{item.usableMoney}}元
  24. </view>
  25. <view>
  26. <label>
  27. <checkbox v-model="JSON.stringify(item)" :value="JSON.stringify(item)" :checked="checkboxList[index]" :disabled="item.usableMoney==0"
  28. v-if="item.usableMoney!=0" color="#FFCC33" style="transform:scale(0.7)" />
  29. <checkbox @click="checkbox" disabled v-if="item.usableMoney==0" color="#FFCC33" style="transform:scale(0.7)" />
  30. </label>
  31. </view>
  32. </view>
  33. </checkbox-group>
  34. </view>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. import {
  40. mapMutations
  41. } from 'vuex'
  42. import {
  43. request
  44. } from '../../../common/request/request'
  45. require("promise.prototype.finally").shim()
  46. export default {
  47. data() {
  48. return {
  49. datalist: [],
  50. agentId: '',
  51. Arry: [],
  52. brandCodeCheckList: [],
  53. amount: '',
  54. choice: 0,
  55. kunnr: '',
  56. brandCode: '',
  57. agentOpDate: '',
  58. src: 'https://b2bcnfile.sailuntire.com/upload//sailun-allsteel-admin/2020110616154607343814..jpg',
  59. storegentBrandList: [],
  60. checked: true,
  61. list: [{}],
  62. checkboxList: [],
  63. idList: [],
  64. listaa: ['a', 'b', 'c'],
  65. checkedAllList: [],
  66. // isCheckedAll:false
  67. };
  68. },
  69. created() {
  70. this.getData()
  71. },
  72. computed: {
  73. ckeck() {
  74. return this.checkboxList
  75. }
  76. },
  77. methods: {
  78. ...mapMutations(["inStore"]),
  79. // 获取结算中心数据
  80. getData() {
  81. uni.showLoading({
  82. title: '加载中...'
  83. });
  84. request({
  85. url: '/myapp/storeSettlementCenter',
  86. method: 'post',
  87. data: {
  88. 'storeId': this.$store.state.storeInfo.storeId,
  89. 'userId': this.$store.state.storeInfo.userId
  90. }
  91. }).then(res => {
  92. if (res.data.code == 0) {
  93. this.datalist = res.data.data
  94. this.Arry.length = this.datalist.length
  95. // 每个新建数组长度为空,全选为false
  96. for (var i = 0; i < this.datalist.length; i++) {
  97. this.Arry[i] = []
  98. this.checkboxList[i] = false
  99. }
  100. this.inStore()
  101. } else {
  102. uni.showToast({
  103. title: res.data.msg,
  104. icon: "none",
  105. duration: _this.$store.state.showToastDuration
  106. });
  107. }
  108. }).catch(err => {
  109. })
  110. .finally(() => {
  111. setTimeout(() => {
  112. uni.hideLoading();
  113. this.loading = false;
  114. }, 1000)
  115. })
  116. },
  117. checkboxChange1() {
  118. },
  119. // 置灰选择框
  120. checkbox() {
  121. this.$u.toast('奖励金额不能为0!');
  122. },
  123. // 选中某个复选框时,由checkbox时触发
  124. // ,bollean,index
  125. checkboxChange(e, index, dataArr) {
  126. let newArr = []
  127. e.detail.value.forEach((item) => {
  128. var obj = {
  129. "storeId": this.$store.state.storeInfo.storeId,
  130. "amount": JSON.parse(item).usableMoney,
  131. "brandCode": JSON.parse(item).brandCode,
  132. "kunnr": JSON.parse(item).kunnr,
  133. 'userId': this.$store.state.storeInfo.userId
  134. }
  135. newArr.push(obj)
  136. })
  137. this.Arry[index] = newArr
  138. // 判断他是否全选
  139. if (this.Arry[index].length == dataArr.filter((item) => {
  140. return item.usableMoney != 0
  141. }).length) {
  142. this.$set(this.checkboxList, index, true);
  143. } else {
  144. this.$set(this.checkboxList, index, false);
  145. }
  146. },
  147. // 核销返利
  148. button(index) {
  149. request({
  150. url: '/myapp/storeCancel',
  151. method: 'post',
  152. data: this.Arry[index]
  153. }).then(res => {
  154. if (res.data.msg == "success") {
  155. uni.showToast({
  156. title: '核销成功',
  157. duration: 2000
  158. });
  159. this.getData()
  160. } else {
  161. uni.showToast({
  162. title: '请选择要核销的返利!',
  163. icon: 'none',
  164. duration: 2000
  165. });
  166. }
  167. }).catch(err => {
  168. })
  169. .finally(() => {
  170. setTimeout(() => {
  171. uni.hideLoading();
  172. this.loading = false;
  173. }, 1000)
  174. })
  175. },
  176. // 选中任一checkbox时,由checkbox-group触发
  177. checkboxGroupChange(e) {},
  178. // 全选
  179. checkedAll(index, e) {
  180. let newArr = []
  181. // 根据奖励金额是否为0判断全选取消全选
  182. if (this.Arry[index].length == e.storegentBrandList.filter((item) => {
  183. return item.usableMoney != 0
  184. }).length) {
  185. this.$set(this.checkboxList, index, false);
  186. this.Arry[index] = []
  187. } else {
  188. this.$set(this.checkboxList, index, true);
  189. for (var i = 0; i < e.storegentBrandList.length; i++) {
  190. if (e.storegentBrandList[i].usableMoney != 0) {
  191. var obj = {
  192. "storeId": this.$store.state.storeInfo.storeId,
  193. "amount": e.storegentBrandList[i].usableMoney,
  194. "brandCode": e.storegentBrandList[i].brandCode,
  195. "kunnr": e.storegentBrandList[i].agentId
  196. }
  197. newArr.push(obj)
  198. }
  199. }
  200. this.Arry[index] = newArr
  201. }
  202. }
  203. },
  204. }
  205. </script>
  206. <style>
  207. .top {
  208. width: 750rpx;
  209. height: 331rpx;
  210. background: url(../../../static/sailun/background.png) no-repeat;
  211. background-size: 750rpx 331rpx;
  212. }
  213. .content {
  214. width: 712rpx;
  215. /* height: 445rpx; */
  216. margin: 0 auto;
  217. margin-bottom: 30rpx;
  218. background: #FFFFFF;
  219. box-shadow: 0px 0px 24px 0px rgba(101, 176, 249, 0.41);
  220. border-radius: 18px;
  221. position: relative;
  222. top: 30rpx;
  223. margin-bottom: 50rpx;
  224. }
  225. .content2 {
  226. width: 712rpx;
  227. height: 351rpx;
  228. margin: 0 auto;
  229. background: #FFFFFF;
  230. box-shadow: 0px 0px 24px 0px rgba(101, 176, 249, 0.41);
  231. border-radius: 18px;
  232. position: relative;
  233. top: 170rpx;
  234. }
  235. .content-one {
  236. width: 6rpx;
  237. height: 30rpx;
  238. background-color: #0589F8;
  239. position: relative;
  240. top: 20rpx;
  241. left: 30rpx;
  242. }
  243. .content-two {
  244. font: 26rpx;
  245. font-weight: bolder;
  246. position: relative;
  247. top: -14rpx;
  248. left: 60rpx;
  249. }
  250. .content-three {
  251. width: 114rpx;
  252. height: 40rpx;
  253. display: inline-block;
  254. background-color: #3A9FF2;
  255. margin-top: -20rpx;
  256. margin-right: 15rpx;
  257. border-radius: 10rpx;
  258. font-size: 24rpx;
  259. color: #fff;
  260. text-align: center;
  261. line-height: 40rpx;
  262. }
  263. .content-four {
  264. display: flex;
  265. justify-content: space-between;
  266. font-weight: bolder;
  267. font-size: 26rpx;
  268. margin-top: 40rpx;
  269. margin-left: 70rpx;
  270. margin-right: 50rpx;
  271. }
  272. .content-five {
  273. display: flex;
  274. justify-content: space-between;
  275. font-size: 24rpx;
  276. margin-top: 40rpx;
  277. margin-left: 100rpx;
  278. font-weight: bolder;
  279. margin-right: 30rpx;
  280. padding-bottom: 20rpx;
  281. }
  282. .content-five-img {
  283. width: 164rpx;
  284. height: 50rpx;
  285. margin-left: -50rpx;
  286. }
  287. .content-five-view {
  288. margin-left: -100rpx;
  289. }
  290. </style>