index.vue 7.7 KB

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