refundOrderOperationBase.blade.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. <script>
  2. Vue.component('refundOrderOperationBase', {
  3. template: `
  4. <div>
  5. <!--//驳回售后申请-->
  6. <el-dialog :visible.sync="refund_reject_show" width="750px" title="驳回售后申请">
  7. <div style="height:300px;overflow:auto" id="refund-reject">
  8. <div style="color:#000;font-weight:500">驳回原因</div>
  9. <el-input v-model="refund_reject_reason" :rows="10" type="textarea"></el-input>
  10. </div>
  11. <span slot="footer" class="dialog-footer">
  12. <el-button @click="refund_reject_show = false">取 消</el-button>
  13. <el-button type="primary" @click="confirmRefundReject()">确 认</el-button>
  14. </span>
  15. </el-dialog>
  16. <!-- //通过申请 -->
  17. <el-dialog :visible.sync="refund_pass_show" width="650px" title="通过申请">
  18. <el-form ref="refund_pass_form" :model="refund_pass_form">
  19. <el-form-item label="">
  20. 退货地址:
  21. <el-select v-model="refund_pass_form.refund_address" clearable placeholder="请选择退货地址" style="width:150px">
  22. <el-option v-for="(vr, kr) in refund_pass_address" :label="vr.address_name" :key="kr" :value="vr.id">
  23. <span v-if="vr.is_default">[[vr.address_name]](默认地址)</span>
  24. </el-option>
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item label="">
  28. 留言:
  29. <el-input v-model="refund_pass_form.message" :rows="8" type="textarea"></el-input>
  30. </el-form-item>
  31. </el-form>
  32. <span slot="footer" class="dialog-footer">
  33. <el-button @click="refund_pass_show = false">取 消</el-button>
  34. <el-button type="primary" @click="confirmRefundPass()">确 认</el-button>
  35. </span>
  36. </el-dialog>
  37. <!-- //换货确认发货 -->
  38. <el-dialog :visible.sync="refund_resend_show" width="650px" title="确认发货">
  39. <div style="height:350px;overflow:auto" id="refund-resend">
  40. <el-form ref="refund_resend" :model="refund_resend" label-width="15%">
  41. <el-form-item label="快递公司">
  42. <el-select v-model="refund_resend.express_code" clearable filterable placeholder="快递公司" style="width:70%;">
  43. <el-option label="其他快递" value="其他快递"></el-option>
  44. <el-option v-for="(vr1,kr1) in expressCompanies" :key="kr1" :label="vr1.name" :value="vr1.value"></el-option>
  45. </el-select>
  46. </el-form-item>
  47. <el-form-item label="快递单号" prop="">
  48. <el-input v-model="refund_resend.express_sn" style="width:70%;"></el-input>
  49. </el-form-item>
  50. </el-form>
  51. </div>
  52. <span slot="footer" class="dialog-footer">
  53. <el-button @click="refund_resend_show = false">取 消</el-button>
  54. <el-button type="primary" @click="confirmRefundResend()">确认发货 </el-button>
  55. </span>
  56. </el-dialog>
  57. <!-- //换货分批发货 -->
  58. <el-dialog :visible.sync="refund_batch_resend_show" width="750px" title="分批发货">
  59. <div style="" id="refund-batch-resend">
  60. <el-form ref="refund_resend" :model="refund_resend" label-width="15%">
  61. <el-form-item label="快递公司">
  62. <el-select v-model="refund_resend.express_code" clearable filterable placeholder="快递公司" style="width:70%;">
  63. <el-option label="其他快递" value="其他快递"></el-option>
  64. <el-option v-for="(vr1,kr1) in expressCompanies" :key="kr1" :label="vr1.name" :value="vr1.value"></el-option>
  65. </el-select>
  66. </el-form-item>
  67. <el-form-item label="快递单号" prop="">
  68. <el-input v-model="refund_resend.express_sn" style="width:70%;"></el-input>
  69. </el-form-item>
  70. </el-form>
  71. <el-table ref="multipleTable" :data="refund_order_goods" tooltip-effect="dark" height="250" style="width: 100%" @selection-change="batchResendChange">
  72. <el-table-column type="selection" width="55"></el-table-column>
  73. <el-table-column width="550">
  74. <template slot-scope="scope">
  75. <div style="display:flex;">
  76. <div style="display:flex;width: 100%;">
  77. <div style="width:50px;height:50px">
  78. <img :src="scope.row.goods_thumb" alt="" style="width:50px;height:50px">
  79. </div>
  80. <div style="margin-left:20px;display: flex;flex-direction: column;justify-content: space-between;">
  81. <div style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">[[scope.row.goods_title]]</div>
  82. <div style="color:#999">[[scope.row.goods_id]]</div>
  83. </div>
  84. </div>
  85. <div style="margin-right:20px">
  86. <el-input-number size="small" v-model="scope.row.num" :min="1" :max="scope.row.send_num" label="数量"></el-input-number>
  87. <div style="color:#999">最大数量 [[scope.row.send_num]]</div>
  88. </div>
  89. </div>
  90. </template>
  91. </el-table-column>
  92. <el-table-column>
  93. <template slot-scope="scope">
  94. <div style="color:#999">[[scope.row.goods_option_title]]</div>
  95. </template>
  96. </el-table-column>
  97. </el-table>
  98. </div>
  99. <span slot="footer" class="dialog-footer">
  100. <el-button @click="refund_batch_resend_show = false">取 消</el-button>
  101. <el-button type="primary" @click="confirmBatchResend()">确认发货 </el-button>
  102. </span>
  103. </el-dialog>
  104. </div>
  105. `,
  106. props: {
  107. refundOperationType: {
  108. type: Number | String,
  109. default: '',
  110. },
  111. operationRefund: {
  112. type: Object | String,
  113. default: {},
  114. },
  115. refundOrder: {
  116. type: Object | String,
  117. default: {},
  118. },
  119. refund_dialog_show: {
  120. type: Number,
  121. default: 0,
  122. },
  123. },
  124. delimiters: ['[[', ']]'],
  125. data() {
  126. return {
  127. refund_order_goods:[],
  128. //退款申请拒绝
  129. refund_reject_show: false,
  130. refund_reject_reason:'',
  131. //通过退款申请
  132. refund_pass_show: false,
  133. refund_pass_address: [],
  134. refund_pass_form:{},
  135. //换货确认发货
  136. expressCompanies:[],
  137. refund_resend_show:false, //全部发货
  138. refund_batch_resend_show:false,//分批发货
  139. refund_resend:{
  140. express_code:"",
  141. express_sn:"",
  142. pack_goods:[],
  143. },
  144. web_url: "{!! yzWebUrl('') !!}", //地址
  145. }
  146. },
  147. watch: {
  148. refund_dialog_show(val) {
  149. console.log(this.refundOperationType);
  150. if (this.refundOperationType == -1) {
  151. return this.refundReject();
  152. } else if (this.refundOperationType == 1) {
  153. return this.refundPay();
  154. } else if (this.refundOperationType == 2) {
  155. return this.refundConsensus()
  156. } else if (this.refundOperationType == 3) {
  157. return this.refundPass()
  158. } else if (this.refundOperationType == 5) {
  159. return this.refundResend()
  160. } else if (this.refundOperationType == 'batch_resend') {
  161. return this.batchResend()
  162. } else if (this.refundOperationType == 10) {
  163. return this.refundClose()
  164. }
  165. },
  166. },
  167. mounted: function () {
  168. },
  169. methods: {
  170. //同意退款
  171. refundPay() {
  172. let obj = this.operationRefund.backend_button_models.find(item => {
  173. return item.value == 1
  174. });
  175. this.$confirm('是否同意此订单退款?', '提示', {confirmButtonText: '同意',cancelButtonText: '取消',type: 'warning'}).then(() => {
  176. let url = this.web_url+obj.api;
  177. url += '&refund_id=' + this.operationRefund.id;
  178. window.location.href = url;
  179. }).catch(() => {
  180. this.$message({type: 'info',message: '已取消操作'});
  181. });
  182. },
  183. //手动退款
  184. refundConsensus() {
  185. let obj = this.operationRefund.backend_button_models.find(item => {
  186. return item.value == 2
  187. });
  188. this.$confirm('确认此订单手动退款完成吗?', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
  189. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  190. this.$http.post(this.web_url+obj.api,{refund_id:this.operationRefund.id}).then(function (response) {
  191. if (response.data.result) {
  192. this.$message({type: 'success',message: '操作成功'});
  193. location.reload(); //重新获取数据刷新页面
  194. } else {
  195. this.$message({type: 'error',message: response.data.msg});
  196. }
  197. loading.close();
  198. },function (response) {
  199. this.$message({type: 'error',message: response.data.msg});
  200. loading.close();
  201. }
  202. );
  203. }).catch(() => {
  204. this.$message({type: 'info',message: '已取消操作'});
  205. });
  206. },
  207. //驳回退款申请
  208. refundReject() {
  209. this.refund_reject_show = true;
  210. this.refund_reject_reason = "";
  211. },
  212. //驳回退款申请
  213. confirmRefundReject() {
  214. let json = {
  215. 'refund_id':this.operationRefund.id,
  216. 'reject_reason':this.refund_reject_reason,
  217. };
  218. let obj = this.operationRefund.backend_button_models.find(item => {
  219. return item.value == -1
  220. });
  221. let loading = this.$loading({target:document.querySelector("#refund-reject"),background: 'rgba(0, 0, 0, 0)'});
  222. this.$http.post(this.web_url+obj.api,json).then(function (response) {
  223. if (response.data.result) {
  224. this.$message({type: 'success',message: '操作成功!'});
  225. location.reload(); //重新获取数据刷新页面
  226. } else{
  227. this.$message({type: 'error',message: response.data.msg});
  228. }
  229. loading.close();
  230. this.refund_reject_show = false;
  231. },function (response) {
  232. this.$message({type: 'error',message: response.data.msg});
  233. loading.close();
  234. this.refund_reject_show = false;
  235. });
  236. },
  237. //通过申请
  238. refundPass() {
  239. this.refund_pass_show = true;
  240. this.getRefundAddress();
  241. },
  242. //通过申请
  243. confirmRefundPass() {
  244. if(!this.refund_pass_form.refund_address) {
  245. this.$message.error("请选择退货地址!");
  246. return false;
  247. }
  248. let json = {
  249. 'refund_id':this.operationRefund.id,
  250. 'message':this.refund_pass_form.message,
  251. 'refund_address': this.refund_pass_form.refund_address,
  252. };
  253. let obj = this.operationRefund.backend_button_models.find(item => {
  254. return item.value == 3
  255. });
  256. let loading = this.$loading({target:document.querySelector("#refund-pass"),background: 'rgba(0, 0, 0, 0)'});
  257. this.$http.post(this.web_url+obj.api,json).then(function (response) {
  258. if (response.data.result) {
  259. this.$message({type: 'success',message: '操作成功!'});
  260. location.reload(); //重新获取数据刷新页面
  261. } else{
  262. this.$message({type: 'error',message: response.data.msg});
  263. }
  264. loading.close();
  265. this.refund_pass_show = false;
  266. },function (response) {
  267. this.$message({type: 'error',message: response.data.msg});
  268. loading.close();
  269. this.refund_pass_show = false;
  270. });
  271. },
  272. //获取退款地址
  273. getRefundAddress() {
  274. let json = {};
  275. this.$http.post('{!! yzWebFullUrl('goods.return-address.ajax-all-address') !!}', json).then(function (response) {
  276. if (response.data.result) {
  277. this.refund_pass_address = response.data.data;
  278. console.log(this.refund_pass_address);
  279. } else{
  280. this.$message({type: 'error',message: response.data.msg});
  281. }
  282. },function (response) {
  283. this.$message({type: 'error',message: response.data.msg});
  284. });
  285. },
  286. //换货分批发货
  287. batchResend() {
  288. if (this.expressCompanies.length <= 0) {
  289. this.getExpressCompanies();
  290. }
  291. if (this.refund_order_goods.length <= 0) {
  292. this.setResendOrderGoods();
  293. }
  294. this.refund_batch_resend_show = true;
  295. },
  296. setResendOrderGoods() {
  297. let goodsArr = [];
  298. this.operationRefund.refund_order_goods.forEach((item,index) => {
  299. if (item.send_num > 0) {
  300. item.num = item.send_num;
  301. goodsArr.push(item);
  302. }
  303. });
  304. this.refund_order_goods = JSON.parse(JSON.stringify(goodsArr));
  305. console.log(this.refund_order_goods);
  306. },
  307. // 多包裹确认发货 选择商品
  308. batchResendChange(selection) {
  309. let arr = [];
  310. for (let value of selection){
  311. arr.push(value.order_goods_id);
  312. }
  313. this.refund_resend.pack_goods = arr;
  314. },
  315. //换货分批发货
  316. confirmBatchResend() {
  317. if (this.refund_resend.pack_goods == undefined || this.refund_resend.pack_goods.length <= 0) {
  318. this.$message({type: 'error',message: '未勾选商品!'});
  319. return false;
  320. }
  321. if(this.refund_resend.express_sn == "") {
  322. this.$message({type: 'error',message: '快递单号不能为空!'});
  323. return false;
  324. }
  325. let pack_goods = [];
  326. for (let value of this.refund_resend.pack_goods) {
  327. for (let item of this.refund_order_goods) {
  328. if (item.order_goods_id == value) {
  329. pack_goods.push({
  330. id: item.order_goods_id,
  331. num: item.num,
  332. });
  333. }
  334. }
  335. }
  336. let json = {
  337. refund_id:this.operationRefund.id,
  338. express_code:this.refund_resend.express_code,
  339. express_sn:this.refund_resend.express_sn,
  340. pack_goods:pack_goods,
  341. };
  342. let obj = this.operationRefund.backend_button_models.find(item => {
  343. return item.value == 'batch_resend'
  344. });
  345. let loading = this.$loading({target:document.querySelector("#refund-pass"),background: 'rgba(0, 0, 0, 0)'});
  346. this.$http.post(this.web_url+obj.api,json).then(function (response) {
  347. if (response.data.result) {
  348. this.$message({type: 'success',message: '操作成功!'});
  349. location.reload(); //重新获取数据刷新页面
  350. } else{
  351. this.$message({type: 'error',message: response.data.msg});
  352. }
  353. loading.close();
  354. this.refund_resend_show = false;
  355. },function (response) {
  356. this.$message({type: 'error',message: response.data.msg});
  357. loading.close();
  358. this.refund_resend_show = false;
  359. });
  360. },
  361. //获取快递信息
  362. getExpressCompanies() {
  363. this.$http.post('{!! yzWebFullUrl('address.get-ajax-express') !!}').then(function (response) {
  364. if (response.data.result) {
  365. this.expressCompanies = response.data.data;
  366. } else{
  367. this.$message({type: 'error',message: response.data.msg});
  368. }
  369. },function (response) {
  370. this.$message({type: 'error',message: response.data.msg});
  371. });
  372. },
  373. //换货确认发货
  374. refundResend() {
  375. if (this.expressCompanies.length <= 0) {
  376. this.getExpressCompanies();
  377. }
  378. this.refund_resend_show = true;
  379. },
  380. //换货确认发货
  381. confirmRefundResend() {
  382. let json = {
  383. refund_id:this.operationRefund.id,
  384. express_code:this.refund_resend.express_code,
  385. express_sn:this.refund_resend.express_sn,
  386. };
  387. let obj = this.operationRefund.backend_button_models.find(item => {
  388. return item.value == 5
  389. });
  390. let loading = this.$loading({target:document.querySelector("#refund-pass"),background: 'rgba(0, 0, 0, 0)'});
  391. this.$http.post(this.web_url+obj.api,json).then(function (response) {
  392. if (response.data.result) {
  393. this.$message({type: 'success',message: '操作成功!'});
  394. location.reload(); //重新获取数据刷新页面
  395. } else{
  396. this.$message({type: 'error',message: response.data.msg});
  397. }
  398. loading.close();
  399. this.refund_resend_show = false;
  400. },function (response) {
  401. this.$message({type: 'error',message: response.data.msg});
  402. loading.close();
  403. this.refund_resend_show = false;
  404. });
  405. },
  406. //换货完成关闭申请
  407. refundClose() {
  408. let obj = this.operationRefund.backend_button_models.find(item => {
  409. return item.value == 10
  410. });
  411. this.$confirm('确认此订单换货完成吗?', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
  412. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  413. this.$http.post(this.web_url+obj.api,{refund_id:this.operationRefund.id}).then(function (response) {
  414. if (response.data.result) {
  415. this.$message({type: 'success',message: '操作成功'});
  416. location.reload(); //重新获取数据刷新页面
  417. } else{
  418. this.$message({type: 'error',message: response.data.msg});
  419. }
  420. loading.close();
  421. },function (response) {
  422. this.$message({type: 'error',message: response.data.msg});
  423. loading.close();
  424. }
  425. );
  426. }).catch(() => {
  427. this.$message({type: 'info',message: '已取消操作'});
  428. });
  429. },
  430. },
  431. });
  432. </script>