index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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. uni.showLoading({
  80. title: '加载中...'
  81. });
  82. request({
  83. url: '/myapp/storeSettlementCenter',
  84. method: 'post',
  85. data: {
  86. 'storeId': this.$store.state.storeInfo.storeId,
  87. 'userId': this.$store.state.storeInfo.userId
  88. }
  89. }).then(res => {
  90. if (res.data.code == 0) {
  91. console.log(res.data)
  92. this.datalist = res.data.data
  93. this.Arry.length = this.datalist.length
  94. // 每个新建数组长度为空,全选为false
  95. for (var i = 0; i < this.datalist.length; i++) {
  96. this.Arry[i] = []
  97. this.checkboxList[i] = false
  98. }
  99. this.inStore()
  100. }else {
  101. console.log(res)
  102. uni.showToast({
  103. title: res.data.msg,
  104. icon: "none",
  105. duration: _this.$store.state.showToastDuration
  106. });
  107. }
  108. }).catch(err => {
  109. console.log(err + "")
  110. })
  111. .finally(() => {
  112. setTimeout(() => {
  113. uni.hideLoading();
  114. this.loading = false;
  115. }, 1000)
  116. })
  117. },
  118. checkboxChange1() {
  119. },
  120. // 置灰选择框
  121. checkbox() {
  122. this.$u.toast('奖励金额不能为0!');
  123. },
  124. // 选中某个复选框时,由checkbox时触发
  125. // ,bollean,index
  126. checkboxChange(e, index, dataArr) {
  127. console.log(index)
  128. console.log(e)
  129. let newArr = []
  130. console.log(this.Arry)
  131. e.detail.value.forEach((item) => {
  132. var obj = {
  133. "storeId": this.$store.state.storeInfo.storeId,
  134. "amount": JSON.parse(item).usableMoney,
  135. "brandCode": JSON.parse(item).brandCode,
  136. "kunnr": JSON.parse(item).kunnr,
  137. 'userId': this.$store.state.storeInfo.userId
  138. }
  139. console.log(obj)
  140. newArr.push(obj)
  141. })
  142. this.Arry[index] = newArr
  143. console.log(newArr)
  144. // 判断他是否全选
  145. if (this.Arry[index].length == dataArr.filter((item) => {
  146. return item.usableMoney != 0
  147. }).length) {
  148. this.$set(this.checkboxList, index, true);
  149. } else {
  150. this.$set(this.checkboxList, index, false);
  151. }
  152. },
  153. // 核销返利
  154. button(index) {
  155. console.log(index)
  156. console.log(this.Arry[index])
  157. request({
  158. url: '/myapp/storeCancel',
  159. method: 'post',
  160. data: this.Arry[index]
  161. }).then(res => {
  162. console.log(res)
  163. if (res.data.msg == "success") {
  164. uni.showToast({
  165. title: '核销返利成功!',
  166. duration: 2000
  167. });
  168. this.getData()
  169. } else {
  170. uni.showToast({
  171. title: '核销返利失败!',
  172. icon: 'none',
  173. duration: 2000
  174. });
  175. }
  176. }).catch(err => {
  177. console.log(err)
  178. })
  179. .finally(() => {
  180. setTimeout(() => {
  181. uni.hideLoading();
  182. this.loading = false;
  183. }, 1000)
  184. })
  185. },
  186. // 选中任一checkbox时,由checkbox-group触发
  187. checkboxGroupChange(e) {},
  188. // 全选
  189. checkedAll(index, e) {
  190. console.log(index, e)
  191. let newArr = []
  192. // 根据奖励金额是否为0判断全选取消全选
  193. if (this.Arry[index].length == e.storegentBrandList.filter((item) => {
  194. return item.usableMoney != 0
  195. }).length) {
  196. this.$set(this.checkboxList, index, false);
  197. this.Arry[index] = []
  198. } else {
  199. this.$set(this.checkboxList, index, true);
  200. for (var i = 0; i < e.storegentBrandList.length; i++) {
  201. if (e.storegentBrandList[i].usableMoney != 0) {
  202. var obj = {
  203. "storeId": this.$store.state.storeInfo.storeId,
  204. "amount": e.storegentBrandList[i].usableMoney,
  205. "brandCode": e.storegentBrandList[i].brandCode,
  206. "kunnr": e.storegentBrandList[i].agentId
  207. }
  208. newArr.push(obj)
  209. }
  210. }
  211. this.Arry[index] = newArr
  212. }
  213. console.log(this.Arry, this.checkboxList)
  214. }
  215. },
  216. }
  217. </script>
  218. <style>
  219. .top {
  220. width: 750rpx;
  221. height: 331rpx;
  222. background: url(../../../static/sailun/background.png) no-repeat;
  223. background-size: 750rpx 331rpx;
  224. }
  225. .content {
  226. width: 712rpx;
  227. /* height: 445rpx; */
  228. margin: 0 auto;
  229. margin-bottom: 30rpx;
  230. background: #FFFFFF;
  231. box-shadow: 0px 0px 24px 0px rgba(101, 176, 249, 0.41);
  232. border-radius: 18px;
  233. position: relative;
  234. top: 30rpx;
  235. margin-bottom: 50rpx;
  236. }
  237. .content2 {
  238. width: 712rpx;
  239. height: 351rpx;
  240. margin: 0 auto;
  241. background: #FFFFFF;
  242. box-shadow: 0px 0px 24px 0px rgba(101, 176, 249, 0.41);
  243. border-radius: 18px;
  244. position: relative;
  245. top: 170rpx;
  246. }
  247. .content-one {
  248. width: 6rpx;
  249. height: 30rpx;
  250. background-color: #0589F8;
  251. position: relative;
  252. top: 20rpx;
  253. left: 30rpx;
  254. }
  255. .content-two {
  256. font: 26rpx;
  257. font-weight: bolder;
  258. position: relative;
  259. top: -14rpx;
  260. left: 60rpx;
  261. }
  262. .content-three {
  263. width: 114rpx;
  264. height: 40rpx;
  265. display: inline-block;
  266. background-color: #3A9FF2;
  267. margin-top: -20rpx;
  268. margin-right: 15rpx;
  269. border-radius: 10rpx;
  270. font-size: 24rpx;
  271. color: #fff;
  272. text-align: center;
  273. line-height: 40rpx;
  274. }
  275. .content-four {
  276. display: flex;
  277. justify-content: space-between;
  278. font-weight: bolder;
  279. font-size: 26rpx;
  280. margin-top: 40rpx;
  281. margin-left: 70rpx;
  282. margin-right: 50rpx;
  283. }
  284. .content-five {
  285. display: flex;
  286. justify-content: space-between;
  287. font-size: 24rpx;
  288. margin-top: 40rpx;
  289. margin-left: 100rpx;
  290. font-weight: bolder;
  291. margin-right: 30rpx;
  292. padding-bottom: 20rpx;
  293. }
  294. .content-five-img {
  295. width: 164rpx;
  296. height: 50rpx;
  297. margin-left: -50rpx;
  298. }
  299. .content-five-view {
  300. margin-left: -100rpx;
  301. }
  302. </style>