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. console.log(res)
  155. if (res.data.msg == "success") {
  156. uni.showToast({
  157. title: '核销成功',
  158. duration: 2000
  159. });
  160. this.getData()
  161. } else {
  162. uni.showToast({
  163. title: '请选择要核销的返利!',
  164. icon: 'none',
  165. duration: 2000
  166. });
  167. }
  168. }).catch(err => {
  169. console.log(err)
  170. })
  171. .finally(() => {
  172. setTimeout(() => {
  173. uni.hideLoading();
  174. this.loading = false;
  175. }, 1000)
  176. })
  177. },
  178. // 选中任一checkbox时,由checkbox-group触发
  179. checkboxGroupChange(e) {},
  180. // 全选
  181. checkedAll(index, e) {
  182. let newArr = []
  183. // 根据奖励金额是否为0判断全选取消全选
  184. if (this.Arry[index].length == e.storegentBrandList.filter((item) => {
  185. return item.usableMoney != 0
  186. }).length) {
  187. this.$set(this.checkboxList, index, false);
  188. this.Arry[index] = []
  189. } else {
  190. this.$set(this.checkboxList, index, true);
  191. for (var i = 0; i < e.storegentBrandList.length; i++) {
  192. if (e.storegentBrandList[i].usableMoney != 0) {
  193. var obj = {
  194. "storeId": this.$store.state.storeInfo.storeId,
  195. "amount": e.storegentBrandList[i].usableMoney,
  196. "brandCode": e.storegentBrandList[i].brandCode,
  197. "kunnr": e.storegentBrandList[i].agentId
  198. }
  199. newArr.push(obj)
  200. }
  201. }
  202. this.Arry[index] = newArr
  203. }
  204. }
  205. },
  206. }
  207. </script>
  208. <style>
  209. .top {
  210. width: 750rpx;
  211. height: 331rpx;
  212. background: url(../../../static/sailun/background.png) no-repeat;
  213. background-size: 750rpx 331rpx;
  214. }
  215. .content {
  216. width: 712rpx;
  217. /* height: 445rpx; */
  218. margin: 0 auto;
  219. margin-bottom: 30rpx;
  220. background: #FFFFFF;
  221. box-shadow: 0px 0px 24px 0px rgba(101, 176, 249, 0.41);
  222. border-radius: 18px;
  223. position: relative;
  224. top: 30rpx;
  225. margin-bottom: 50rpx;
  226. }
  227. .content2 {
  228. width: 712rpx;
  229. height: 351rpx;
  230. margin: 0 auto;
  231. background: #FFFFFF;
  232. box-shadow: 0px 0px 24px 0px rgba(101, 176, 249, 0.41);
  233. border-radius: 18px;
  234. position: relative;
  235. top: 170rpx;
  236. }
  237. .content-one {
  238. width: 6rpx;
  239. height: 30rpx;
  240. background-color: #0589F8;
  241. position: relative;
  242. top: 20rpx;
  243. left: 30rpx;
  244. }
  245. .content-two {
  246. font: 26rpx;
  247. font-weight: bolder;
  248. position: relative;
  249. top: -14rpx;
  250. left: 60rpx;
  251. }
  252. .content-three {
  253. width: 114rpx;
  254. height: 40rpx;
  255. display: inline-block;
  256. background-color: #3A9FF2;
  257. margin-top: -20rpx;
  258. margin-right: 15rpx;
  259. border-radius: 10rpx;
  260. font-size: 24rpx;
  261. color: #fff;
  262. text-align: center;
  263. line-height: 40rpx;
  264. }
  265. .content-four {
  266. display: flex;
  267. justify-content: space-between;
  268. font-weight: bolder;
  269. font-size: 26rpx;
  270. margin-top: 40rpx;
  271. margin-left: 70rpx;
  272. margin-right: 50rpx;
  273. }
  274. .content-five {
  275. display: flex;
  276. justify-content: space-between;
  277. font-size: 24rpx;
  278. margin-top: 40rpx;
  279. margin-left: 100rpx;
  280. font-weight: bolder;
  281. margin-right: 30rpx;
  282. padding-bottom: 20rpx;
  283. }
  284. .content-five-img {
  285. width: 164rpx;
  286. height: 50rpx;
  287. margin-left: -50rpx;
  288. }
  289. .content-five-view {
  290. margin-left: -100rpx;
  291. }
  292. </style>