index.vue 7.5 KB

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