index.vue 7.5 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"
  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. console.log(res.data)
  94. this.datalist = res.data.data
  95. this.Arry.length = this.datalist.length
  96. // 每个新建数组长度为空,全选为false
  97. for (var i = 0; i < this.datalist.length; i++) {
  98. this.Arry[i] = []
  99. this.checkboxList[i] = false
  100. }
  101. this.inStore()
  102. } else {
  103. console.log(res)
  104. uni.showToast({
  105. title: res.data.msg,
  106. icon: "none",
  107. duration: _this.$store.state.showToastDuration
  108. });
  109. }
  110. }).catch(err => {
  111. console.log(err + "")
  112. })
  113. .finally(() => {
  114. setTimeout(() => {
  115. uni.hideLoading();
  116. this.loading = false;
  117. }, 1000)
  118. })
  119. },
  120. checkboxChange1() {
  121. },
  122. // 置灰选择框
  123. checkbox() {
  124. this.$u.toast('奖励金额不能为0!');
  125. },
  126. // 选中某个复选框时,由checkbox时触发
  127. // ,bollean,index
  128. checkboxChange(e, index, dataArr) {
  129. console.log(index)
  130. console.log(e)
  131. let newArr = []
  132. console.log(this.Arry)
  133. e.detail.value.forEach((item) => {
  134. var obj = {
  135. "storeId": this.$store.state.storeInfo.storeId,
  136. "amount": JSON.parse(item).usableMoney,
  137. "brandCode": JSON.parse(item).brandCode,
  138. "kunnr": JSON.parse(item).kunnr,
  139. 'userId': this.$store.state.storeInfo.userId
  140. }
  141. console.log(obj)
  142. newArr.push(obj)
  143. })
  144. this.Arry[index] = newArr
  145. console.log(newArr)
  146. // 判断他是否全选
  147. if (this.Arry[index].length == dataArr.filter((item) => {
  148. return item.usableMoney != 0
  149. }).length) {
  150. this.$set(this.checkboxList, index, true);
  151. } else {
  152. this.$set(this.checkboxList, index, false);
  153. }
  154. },
  155. // 核销返利
  156. button(index) {
  157. console.log(index)
  158. console.log(this.Arry[index])
  159. request({
  160. url: '/myapp/storeCancel',
  161. method: 'post',
  162. data: this.Arry[index]
  163. }).then(res => {
  164. console.log(res)
  165. if (res.data.msg == "success") {
  166. uni.showToast({
  167. title: '核销返利成功!',
  168. duration: 2000
  169. });
  170. this.getData()
  171. } else {
  172. uni.showToast({
  173. title: '请选择要核销的返利!',
  174. icon: 'none',
  175. duration: 2000
  176. });
  177. }
  178. }).catch(err => {
  179. console.log(err)
  180. })
  181. .finally(() => {
  182. setTimeout(() => {
  183. uni.hideLoading();
  184. this.loading = false;
  185. }, 1000)
  186. })
  187. },
  188. // 选中任一checkbox时,由checkbox-group触发
  189. checkboxGroupChange(e) {},
  190. // 全选
  191. checkedAll(index, e) {
  192. console.log(index, e)
  193. let newArr = []
  194. // 根据奖励金额是否为0判断全选取消全选
  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: 15rpx;
  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: 70rpx;
  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: -100rpx;
  303. }
  304. </style>