index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <template>
  2. <basic-container>
  3. <avue-crud :option="option"
  4. :table-loading="loading"
  5. :data="data"
  6. :page.sync="page"
  7. :permission="permissionList"
  8. :before-open="beforeOpen"
  9. v-model="form"
  10. ref="crud"
  11. @row-update="rowUpdate"
  12. @row-save="rowSave"
  13. @row-del="rowDel"
  14. @search-change="searchChange"
  15. @search-reset="searchReset"
  16. @selection-change="selectionChange"
  17. @current-change="currentChange"
  18. @size-change="sizeChange"
  19. @refresh-change="refreshChange"
  20. @on-load="onLoad">
  21. <!-- <template slot="menuLeft">-->
  22. <!-- <el-button type="danger"-->
  23. <!-- size="small"-->
  24. <!-- icon="el-icon-delete"-->
  25. <!-- plain-->
  26. <!-- v-if="permission.aftersales_delete"-->
  27. <!-- @click="handleDelete">删 除-->
  28. <!-- </el-button>-->
  29. <!-- </template>-->
  30. <template slot-scope="scope" slot="menu">
  31. <el-button
  32. type="text"
  33. size="small"
  34. @click="refund(scope.row)"
  35. >确认收货
  36. </el-button>
  37. <el-button
  38. type="text"
  39. size="small"
  40. @click="viewRefundGoods(scope.row)"
  41. >查看售后商品
  42. </el-button>
  43. </template>
  44. </avue-crud>
  45. <el-dialog title="查看售后商品" @close="refreshChange"
  46. append-to-body
  47. :visible.sync="viewRefundGoodsBox"
  48. width="80%">
  49. <avue-crud :data="refundGoodsList" :option="goodsOption" ></avue-crud>
  50. </el-dialog>
  51. </basic-container>
  52. </template>
  53. <script>
  54. import {getList, getDetail, confirm, update, remove, refund} from "@/api/finance/aftersales";
  55. import {mapGetters} from "vuex";
  56. export default {
  57. data() {
  58. return {
  59. viewRefundGoodsBox: false,
  60. refundGoodsList: [],
  61. goodsOption:{
  62. height:300,
  63. viewBtn: true,
  64. addBtn: false,
  65. editBtn: false,
  66. delBtn: false,
  67. selection: false,
  68. menu: false,
  69. refreshBtn: false,
  70. columnBtn: false,
  71. column:[
  72. {
  73. label:'商品图片',
  74. prop:'goodsImage',
  75. type: 'img',
  76. }, {
  77. label:'商品名称',
  78. prop:'goodsName'
  79. }, {
  80. label:'商品规格',
  81. prop:'goodsSpec'
  82. }, {
  83. label:'商品金额',
  84. prop:'goodsPrice'
  85. }, {
  86. label:'退货数量',
  87. prop:'goodsNum'
  88. }
  89. ]
  90. },
  91. form: {},
  92. query: {},
  93. loading: true,
  94. page: {
  95. pageSize: 10,
  96. currentPage: 1,
  97. total: 0
  98. },
  99. selectionList: [],
  100. option: {
  101. height:'auto',
  102. calcHeight: 30,
  103. tip: false,
  104. searchShow: true,
  105. searchMenuSpan: 6,
  106. border: true,
  107. index: true,
  108. viewBtn: true,
  109. addBtn: false,
  110. editBtn: false,
  111. delBtn: false,
  112. selection: false,
  113. dialogClickModal: false,
  114. column: [
  115. {
  116. label: "售后编号",
  117. prop: "afterSalesNo",
  118. rules: [{
  119. required: true,
  120. message: "请输入售后编号",
  121. trigger: "blur"
  122. }]
  123. },
  124. {
  125. label: "售后类型",
  126. prop: "type",
  127. type: "select",
  128. search: true,
  129. dicUrl: "/api/blade-system/dict-biz/getEnumDict?enumName=AfterSalesTypeEnum",
  130. props: {
  131. label: "name",
  132. value: "value"
  133. },
  134. dataType: "number",
  135. },
  136. {
  137. label: "售后原因",
  138. prop: "reason",
  139. rules: [{
  140. required: true,
  141. message: "请输入售后原因",
  142. trigger: "blur"
  143. }]
  144. },
  145. {
  146. label: "售后状态",
  147. prop: "status",
  148. type: "select",
  149. search: true,
  150. dicUrl: "/api/blade-system/dict-biz/getEnumDict?enumName=AfterSalesStatusEnum",
  151. props: {
  152. label: "name",
  153. value: "value"
  154. },
  155. dataType: "number",
  156. },
  157. {
  158. label: "退货物流编号",
  159. prop: "logisticsNo",
  160. },
  161. ]
  162. },
  163. data: []
  164. };
  165. },
  166. computed: {
  167. ...mapGetters(["permission"]),
  168. permissionList() {
  169. return {
  170. addBtn: this.vaildData(this.permission.aftersales_add, false),
  171. viewBtn: this.vaildData(this.permission.aftersales_view, false),
  172. delBtn: this.vaildData(this.permission.aftersales_delete, false),
  173. editBtn: this.vaildData(this.permission.aftersales_edit, false)
  174. };
  175. },
  176. ids() {
  177. let ids = [];
  178. this.selectionList.forEach(ele => {
  179. ids.push(ele.id);
  180. });
  181. return ids.join(",");
  182. }
  183. },
  184. methods: {
  185. rowSave(row, done, loading) {
  186. add(row).then(() => {
  187. this.onLoad(this.page);
  188. this.$message({
  189. type: "success",
  190. message: "操作成功!"
  191. });
  192. done();
  193. }, error => {
  194. loading();
  195. window.console.log(error);
  196. });
  197. },
  198. rowUpdate(row, index, done, loading) {
  199. update(row).then(() => {
  200. this.onLoad(this.page);
  201. this.$message({
  202. type: "success",
  203. message: "操作成功!"
  204. });
  205. done();
  206. }, error => {
  207. loading();
  208. console.log(error);
  209. });
  210. },
  211. rowDel(row) {
  212. this.$confirm("确定将选择数据删除?", {
  213. confirmButtonText: "确定",
  214. cancelButtonText: "取消",
  215. type: "warning"
  216. })
  217. .then(() => {
  218. return remove(row.id);
  219. })
  220. .then(() => {
  221. this.onLoad(this.page);
  222. this.$message({
  223. type: "success",
  224. message: "操作成功!"
  225. });
  226. });
  227. },
  228. handleDelete() {
  229. if (this.selectionList.length === 0) {
  230. this.$message.warning("请选择至少一条数据");
  231. return;
  232. }
  233. this.$confirm("确定将选择数据删除?", {
  234. confirmButtonText: "确定",
  235. cancelButtonText: "取消",
  236. type: "warning"
  237. })
  238. .then(() => {
  239. return remove(this.ids);
  240. })
  241. .then(() => {
  242. this.onLoad(this.page);
  243. this.$message({
  244. type: "success",
  245. message: "操作成功!"
  246. });
  247. this.$refs.crud.toggleSelection();
  248. });
  249. },
  250. beforeOpen(done, type) {
  251. if (["edit", "view"].includes(type)) {
  252. getDetail(this.form.id).then(res => {
  253. this.form = res.data.data;
  254. });
  255. }
  256. done();
  257. },
  258. searchReset() {
  259. this.query = {};
  260. this.onLoad(this.page);
  261. },
  262. searchChange(params, done) {
  263. this.query = params;
  264. this.page.currentPage = 1;
  265. this.onLoad(this.page, params);
  266. done();
  267. },
  268. selectionChange(list) {
  269. this.selectionList = list;
  270. },
  271. selectionClear() {
  272. this.selectionList = [];
  273. this.$refs.crud.toggleSelection();
  274. },
  275. currentChange(currentPage){
  276. this.page.currentPage = currentPage;
  277. },
  278. sizeChange(pageSize){
  279. this.page.pageSize = pageSize;
  280. },
  281. refreshChange() {
  282. this.onLoad(this.page, this.query);
  283. },
  284. onLoad(page, params = {}) {
  285. this.loading = true;
  286. getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  287. const data = res.data.data;
  288. this.page.total = data.total;
  289. this.data = data.records;
  290. this.loading = false;
  291. this.selectionClear();
  292. });
  293. },
  294. refund(row) {
  295. this.$confirm("是否确认收货?", {
  296. confirmButtonText: "确定",
  297. cancelButtonText: "取消",
  298. type: "warning"
  299. }).then(() => {
  300. const loading = this.$loading({
  301. lock: true,
  302. text: '退款中...',
  303. spinner: 'el-icon-loading',
  304. background: 'rgba(0, 0, 0, 0.7)'
  305. });
  306. confirm(row.orderId, row.id).then(res => {
  307. loading.close();
  308. this.$message({
  309. type: "success",
  310. message: "退款成功!"
  311. });
  312. this.refreshChange();
  313. }).catch(() => {
  314. loading.close();
  315. });
  316. });
  317. },
  318. /**
  319. * 查看退货商品
  320. * @param row
  321. */
  322. viewRefundGoods(row) {
  323. this.viewRefundGoodsBox = true;
  324. getDetail(row.id).then(res => {
  325. console.log(res)
  326. this.refundGoodsList = res.data.data.goodsList;
  327. })
  328. }
  329. }
  330. };
  331. </script>
  332. <style>
  333. </style>