order.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  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. </template>
  23. <template slot="orderStateDesc" slot-scope="scope" >
  24. <el-tag v-if="scope.row.orderState === 1">{{scope.row.orderStateDesc}}</el-tag>
  25. <el-tag v-else-if="scope.row.orderState === 2" type="warning">{{scope.row.orderStateDesc}}</el-tag>
  26. <el-tag v-else-if="scope.row.orderState === 4"type="success">{{scope.row.orderStateDesc}}</el-tag>
  27. <el-tag v-else-if="scope.row.orderState === 5"type="danger">{{scope.row.orderStateDesc}}</el-tag>
  28. </template>
  29. </avue-crud>
  30. </basic-container>
  31. </template>
  32. <script>
  33. import {getList, getDetail, add, update, remove} from "@/api/finance/order";
  34. import {mapGetters} from "vuex";
  35. export default {
  36. data() {
  37. return {
  38. form: {},
  39. query: {},
  40. loading: true,
  41. page: {
  42. pageSize: 10,
  43. currentPage: 1,
  44. total: 0
  45. },
  46. selectionList: [],
  47. option: {
  48. height:'auto',
  49. calcHeight: 30,
  50. tip: false,
  51. searchShow: true,
  52. searchMenuSpan: 6,
  53. searchIcon: true,
  54. searchIndex: 3,
  55. menuWidth: 100,
  56. border: true,
  57. viewBtn: true,
  58. editBtn: false,
  59. delBtn: false,
  60. selection: true,
  61. dialogClickModal: false,
  62. column: [
  63. {
  64. label: "订单号",
  65. prop: "orderNo",
  66. search: true,
  67. width: 170,
  68. },
  69. {
  70. label: "订单来源",
  71. width: 100,
  72. prop: "source",
  73. type: "select",
  74. search: true,
  75. dicUrl: "/api/blade-system/dict-biz/getEnumDict?enumName=OrderSourceEnum",
  76. props: {
  77. label: "name",
  78. value: "value"
  79. },
  80. dataType: "number",
  81. },
  82. {
  83. label: "订单类型",
  84. prop: "orderType",
  85. type: "select",
  86. search: true,
  87. dicUrl: "/api/blade-system/dict-biz/dictionary?code=order_type",
  88. props: {
  89. label: "dictValue",
  90. value: "dictKey"
  91. },
  92. dataType: "number",
  93. },
  94. {
  95. label: "买家昵称",
  96. prop: "nickname",
  97. search: true,
  98. },
  99. {
  100. label: "订单状态",
  101. prop: "orderState",
  102. type: "select",
  103. search: true,
  104. hide: true,
  105. dicUrl: "/api/blade-system/dict-biz/dictionary?code=order_state",
  106. props: {
  107. label: "dictValue",
  108. value: "dictKey"
  109. },
  110. dataType: "number",
  111. },
  112. {
  113. label: "总金额",
  114. prop: "totalAmount",
  115. hide: true,
  116. rules: [{
  117. required: true,
  118. message: "请输入总金额",
  119. trigger: "blur"
  120. }]
  121. },
  122. {
  123. label: "订单金额",
  124. prop: "paymentAmount",
  125. formatter:(val,value,label)=>{
  126. return "¥" + value;
  127. },
  128. },
  129. {
  130. label: "支付方式",
  131. prop: "paymentMode",
  132. hide: true,
  133. rules: [{
  134. required: true,
  135. message: "请输入支付方式",
  136. trigger: "blur"
  137. }]
  138. },
  139. {
  140. label: "订单状态",
  141. prop: "orderStateDesc",
  142. slot:true,
  143. width: 80
  144. },
  145. {
  146. label: "支付时间",
  147. prop: "paymentTime",
  148. hide: true,
  149. rules: [{
  150. required: true,
  151. message: "请输入支付时间",
  152. trigger: "blur"
  153. }]
  154. },
  155. {
  156. label: "支付状态",
  157. prop: "paymentState",
  158. hide: true
  159. },
  160. {
  161. label: "优惠金额",
  162. prop: "discountAmount",
  163. hide: true,
  164. rules: [{
  165. required: true,
  166. message: "请输入优惠金额",
  167. trigger: "blur"
  168. }]
  169. },
  170. {
  171. label: "是否售后",
  172. prop: "isAftersales",
  173. hide: true,
  174. type: "select",
  175. dicUrl: "/api/blade-system/dict/dictionary?code=yes_no",
  176. props: {
  177. label: "dictValue",
  178. value: "dictKey"
  179. },
  180. // dataType: "number",
  181. },
  182. {
  183. label: "发货时间",
  184. prop: "sendTime",
  185. hide: true,
  186. },
  187. {
  188. label: "收货时间",
  189. prop: "recordTime",
  190. hide: true,
  191. },
  192. {
  193. label: "下单时间",
  194. prop: "createTime"
  195. },
  196. {
  197. label: "下单时间",
  198. prop: "orderTimeRange",
  199. width: 150,
  200. display: false,
  201. hide: true,
  202. search: true,
  203. type: 'datetimerange',
  204. searchRange:true,
  205. defaultTime:['00:00:00', '23:59:59'],
  206. format:'yyyy-MM-dd HH:mm:ss',
  207. valueFormat:'yyyy-MM-dd HH:mm:ss',
  208. startPlaceholder: '开始时间',
  209. endPlaceholder: '结束时间',
  210. },
  211. ]
  212. },
  213. data: []
  214. };
  215. },
  216. computed: {
  217. ...mapGetters(["permission"]),
  218. permissionList() {
  219. return {
  220. addBtn: this.vaildData(this.permission.order_add, false),
  221. viewBtn: this.vaildData(this.permission.order_view, false),
  222. delBtn: this.vaildData(this.permission.order_delete, false),
  223. editBtn: this.vaildData(this.permission.order_edit, false)
  224. };
  225. },
  226. ids() {
  227. let ids = [];
  228. this.selectionList.forEach(ele => {
  229. ids.push(ele.id);
  230. });
  231. return ids.join(",");
  232. }
  233. },
  234. methods: {
  235. rowSave(row, done, loading) {
  236. add(row).then(() => {
  237. this.onLoad(this.page);
  238. this.$message({
  239. type: "success",
  240. message: "操作成功!"
  241. });
  242. done();
  243. }, error => {
  244. loading();
  245. window.console.log(error);
  246. });
  247. },
  248. rowUpdate(row, index, done, loading) {
  249. update(row).then(() => {
  250. this.onLoad(this.page);
  251. this.$message({
  252. type: "success",
  253. message: "操作成功!"
  254. });
  255. done();
  256. }, error => {
  257. loading();
  258. console.log(error);
  259. });
  260. },
  261. rowDel(row) {
  262. this.$confirm("确定将选择数据删除?", {
  263. confirmButtonText: "确定",
  264. cancelButtonText: "取消",
  265. type: "warning"
  266. })
  267. .then(() => {
  268. return remove(row.id);
  269. })
  270. .then(() => {
  271. this.onLoad(this.page);
  272. this.$message({
  273. type: "success",
  274. message: "操作成功!"
  275. });
  276. });
  277. },
  278. handleDelete() {
  279. if (this.selectionList.length === 0) {
  280. this.$message.warning("请选择至少一条数据");
  281. return;
  282. }
  283. this.$confirm("确定将选择数据删除?", {
  284. confirmButtonText: "确定",
  285. cancelButtonText: "取消",
  286. type: "warning"
  287. })
  288. .then(() => {
  289. return remove(this.ids);
  290. })
  291. .then(() => {
  292. this.onLoad(this.page);
  293. this.$message({
  294. type: "success",
  295. message: "操作成功!"
  296. });
  297. this.$refs.crud.toggleSelection();
  298. });
  299. },
  300. beforeOpen(done, type) {
  301. if (["edit", "view"].includes(type)) {
  302. getDetail(this.form.id).then(res => {
  303. this.form = res.data.data;
  304. });
  305. }
  306. done();
  307. },
  308. searchReset() {
  309. this.query = {};
  310. this.onLoad(this.page);
  311. },
  312. searchChange(params, done) {
  313. this.query = params;
  314. this.page.currentPage = 1;
  315. this.onLoad(this.page, params);
  316. done();
  317. },
  318. selectionChange(list) {
  319. this.selectionList = list;
  320. },
  321. selectionClear() {
  322. this.selectionList = [];
  323. this.$refs.crud.toggleSelection();
  324. },
  325. currentChange(currentPage){
  326. this.page.currentPage = currentPage;
  327. },
  328. sizeChange(pageSize){
  329. this.page.pageSize = pageSize;
  330. },
  331. refreshChange() {
  332. this.onLoad(this.page, this.query);
  333. },
  334. onLoad(page, params = {}) {
  335. const orderTimeRange = this.query.orderTimeRange;
  336. if (orderTimeRange) {
  337. this.query.startTime = orderTimeRange[0];
  338. this.query.endTime = orderTimeRange[1];
  339. }
  340. this.loading = true;
  341. getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  342. const data = res.data.data;
  343. this.page.total = data.total;
  344. this.data = data.records;
  345. this.loading = false;
  346. this.selectionClear();
  347. });
  348. }
  349. }
  350. };
  351. </script>
  352. <style>
  353. </style>