index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <template>
  2. <view class="refund">
  3. <view class="money-section">
  4. <view class="acea-row row-middle item">
  5. <view class="">预计退款</view>
  6. <input disabled="" v-model="refundMoney" class="input" type="text" />
  7. </view>
  8. <view class="acea-row row-middle item" >
  9. <view class="">退款类型</view>
  10. <view class="acea-row row-right radio-group">
  11. <view class="acea-row row-middle radio-item" :class="{ on: !isSplit}" @click="refundTypeChange(0)">
  12. <text class="iconfont" :class="isSplit?'icon-weixuanzhong':'icon-a-ic_CompleteSelect'"></text>整单退款
  13. </view>
  14. <view v-if="type!=2" class="acea-row row-middle radio-item" :class="{ on: isSplit}" @click="refundTypeChange(1)">
  15. <text class="iconfont" :class="isSplit?'icon-a-ic_CompleteSelect':'icon-weixuanzhong'"></text>分单退款
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. <splitOrder :type="1" v-if="isSplit" :splitGoods="splitGoods" :select_all="false" @getList="getList">
  21. </splitOrder>
  22. <view class="footer acea-row row-middle">
  23. <view class="all acea-row row-middle" v-if="isSplit" @click="allChange">
  24. <text class="iconfont" :class="isAll?'icon-a-ic_CompleteSelect':'icon-ic_unselect'"></text>
  25. 全选
  26. </view>
  27. <view class="btn-box">
  28. <view class="btn" :style="{ width: isSplit?'auto':'100%'}" @click="openRefund">
  29. 确认
  30. <text v-if="isSplit">({{ numTotal }})</text>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. import splitOrder from '../components/splitOrder/index.vue';
  38. import {
  39. employeeDirectRefund,
  40. sendDetailList
  41. } from '@/api/work.js'
  42. export default {
  43. components: {
  44. splitOrder,
  45. },
  46. data() {
  47. return {
  48. refundMoney: 0,
  49. isSplit: 0,
  50. isAll: false,
  51. splitGoods: [],
  52. goodsChecked: [],
  53. cart_ids: [],
  54. info: {},
  55. orderNo:'',
  56. type:''
  57. }
  58. },
  59. computed: {
  60. total() {
  61. return this.goodsChecked.reduce((total, item) => {
  62. return this.$util.$h.Add(total, this.$util.$h.Mul(this.$util.$h.Div(item.payPrice,item.payNum), item.surplus_num)).toFixed(2);
  63. }, 0);
  64. },
  65. numTotal() {
  66. return this.goodsChecked.reduce((total, {
  67. surplus_num,
  68. }) => {
  69. return this.$util.$h.Add(total, surplus_num);
  70. }, 0);
  71. },
  72. },
  73. watch: {
  74. total(newValue, oldValue) {
  75. this.refundMoney = newValue
  76. },
  77. },
  78. onLoad(options) {
  79. this.getInfo(options.orderNo)
  80. this.orderNo=options.orderNo
  81. this.type=options.type
  82. },
  83. methods: {
  84. getInfo(orderNo){
  85. sendDetailList(orderNo).then(res=>{
  86. this.info = res.data
  87. this.getIndex(res.data)
  88. })
  89. },
  90. allChange() {
  91. this.isAll = !this.isAll;
  92. this.cart_ids = [];
  93. this.goodsChecked = [];
  94. for (let i = 0; i < this.splitGoods.length; i++) {
  95. this.splitGoods[i].checked = this.isAll;
  96. if (this.splitGoods[i].checked) {
  97. this.goodsChecked.push(this.splitGoods[i]);
  98. this.cart_ids.push(this.splitGoods[i].id);
  99. }
  100. }
  101. },
  102. refundTypeChange(value) {
  103. this.isSplit = value;
  104. if (value) {
  105. this.goodsChecked = []
  106. this.splitGoods.forEach(item => {
  107. item.checked = false
  108. })
  109. this.isAll = false
  110. } else {
  111. this.splitGoods.forEach(item => {
  112. item.surplus_num=item.payNum - item.refundNum
  113. })
  114. this.goodsChecked = this.splitGoods
  115. }
  116. },
  117. getIndex(info) {
  118. let that = this;
  119. let obj = '';
  120. const cartInfo = info
  121. let list = cartInfo.map(item => {
  122. return {
  123. id: item.id,
  124. checked: false,
  125. numShow: item.payNum - item.refundNum,
  126. surplus_num: item.payNum - item.refundNum,
  127. ...item,
  128. refundPrice: this.$util.$h.Div(item.refundPrice, item.payNum),
  129. };
  130. });
  131. this.splitGoods = list;
  132. this.goodsChecked = list;
  133. },
  134. getList(val) {
  135. let that = this;
  136. that.splitGoods = JSON.parse(JSON.stringify(val));
  137. let goodsChecked = [];
  138. let cart_ids = [];
  139. for (let i = 0; i < val.length; i++) {
  140. if (val[i].checked) {
  141. goodsChecked.push(val[i]);
  142. cart_ids.push(val[i].id);
  143. }
  144. }
  145. this.goodsChecked = goodsChecked;
  146. this.cart_ids = cart_ids;
  147. this.isAll = this.goodsChecked.length == this.splitGoods.length;
  148. },
  149. openRefund() {
  150. let cart_ids = [];
  151. let data = {
  152. refund_price: this.refundMoney,
  153. type: 1,
  154. is_split_order: this.isSplit,
  155. };
  156. cart_ids = this.goodsChecked.map(({
  157. id,
  158. surplus_num
  159. }) => {
  160. return {
  161. orderDetailId: id,
  162. num: surplus_num
  163. }
  164. });
  165. let refundObj = {
  166. orderNo: this.orderNo,
  167. returnType: this.isSplit == 0 ? 1 : 2,
  168. detailList: cart_ids
  169. }
  170. employeeDirectRefund(refundObj).then(res => {
  171. if (res.code == 200) {
  172. this.$util.Tips({
  173. title: '操作成功'
  174. })
  175. setTimeout(()=>{
  176. uni.navigateTo({
  177. url:'/pages/admin/order/index?type=complete'
  178. })
  179. },500)
  180. }
  181. }).catch(err=>{
  182. this.$util.Tips({
  183. title: err
  184. })
  185. })
  186. },
  187. },
  188. }
  189. </script>
  190. <style lang="scss" scoped>
  191. /deep/checkbox .uni-checkbox-input.uni-checkbox-input-checked {
  192. border: 1px solid #2A7EFB !important;
  193. background-color: #2A7EFB !important;
  194. color: #fff !important;
  195. }
  196. /deep/checkbox .wx-checkbox-input.wx-checkbox-input-checked {
  197. border: 1px solid #2A7EFB !important;
  198. background-color: #2A7EFB !important;
  199. color: #fff !important;
  200. }
  201. .refund {
  202. padding: 22rpx 20rpx;
  203. }
  204. .money-section {
  205. padding: 12rpx 0;
  206. border-radius: 24rpx;
  207. background: #FFFFFF;
  208. .item {
  209. height: 80rpx;
  210. padding: 0 24rpx;
  211. font-size: 28rpx;
  212. color: #333333;
  213. }
  214. .input {
  215. flex: 1;
  216. height: 80rpx;
  217. text-align: right;
  218. font-family: Regular;
  219. font-size: 36rpx;
  220. color: #FF7E00;
  221. }
  222. .icon-ic_edit {
  223. margin-left: 8rpx;
  224. font-size: 32rpx;
  225. color: #999999;
  226. }
  227. .radio-group {
  228. flex: 1;
  229. }
  230. .radio-item {
  231. font-size: 28rpx;
  232. color: #999999;
  233. +.radio-item {
  234. margin-left: 48rpx;
  235. }
  236. .iconfont {
  237. margin-right: 12rpx;
  238. font-size: 32rpx;
  239. }
  240. &.on {
  241. color: #333333;
  242. .iconfont {
  243. color: #2A7EFB;
  244. }
  245. }
  246. }
  247. }
  248. .footer {
  249. position: fixed;
  250. bottom: 0;
  251. left: 0;
  252. width: 100%;
  253. padding: 16rpx 20rpx 16rpx 32rpx;
  254. padding-bottom: calc(16rpx + constant(safe-area-inset-bottom));
  255. padding-bottom: calc(16rpx + env(safe-area-inset-bottom));
  256. background: #FFFFFF;
  257. .btn {
  258. display: inline-block;
  259. height: 64rpx;
  260. padding: 0 40rpx;
  261. border-radius: 32rpx;
  262. background: #2A7EFB;
  263. font-weight: 500;
  264. font-size: 26rpx;
  265. line-height: 64rpx;
  266. color: #FFFFFF;
  267. }
  268. .all {
  269. font-size: 26rpx;
  270. color: #333333;
  271. .iconfont {
  272. margin-right: 12rpx;
  273. font-size: 40rpx;
  274. color: #CCCCCC;
  275. &.icon-a-ic_CompleteSelect {
  276. color: #2A7EFB;
  277. }
  278. }
  279. }
  280. .btn-box {
  281. flex: 1;
  282. text-align: right;
  283. .btn {
  284. text-align: center;
  285. }
  286. }
  287. }
  288. </style>