From 2cb293efd7bbc353445de3d4cde91364d31f8266 Mon Sep 17 00:00:00 2001 From: denghy Date: Fri, 20 Sep 2019 10:35:57 +0800 Subject: [PATCH] pre --- frontend/src/views/virtual/cards/index.vue | 4 +- frontend/src/views/virtual/cards/js/index.js | 252 ++++++++++--------- 2 files changed, 135 insertions(+), 121 deletions(-) diff --git a/frontend/src/views/virtual/cards/index.vue b/frontend/src/views/virtual/cards/index.vue index a0f81557..874e1990 100644 --- a/frontend/src/views/virtual/cards/index.vue +++ b/frontend/src/views/virtual/cards/index.vue @@ -21,7 +21,7 @@ -
+
@@ -94,7 +94,7 @@
  • - +
  • diff --git a/frontend/src/views/virtual/cards/js/index.js b/frontend/src/views/virtual/cards/js/index.js index 1642b0d8..20cb3283 100644 --- a/frontend/src/views/virtual/cards/js/index.js +++ b/frontend/src/views/virtual/cards/js/index.js @@ -1,19 +1,19 @@ -import * as API from 'api/virtual/cards'; +import * as API from "api/virtual/cards"; export default { - name: 'Cards', + name: "Cards", components: { - UiDetail: resolve => require(['views/virtual/cards/detail'], resolve) + UiDetail: resolve => require(["views/virtual/cards/detail"], resolve) }, data() { return { params: { - id: '', - sim: '', - company_name: '', - package_name: '', - carrier_operator: '', - card_status: '', + id: "", + sim: "", + company_name: "", + package_name: "", + carrier_operator: "", + card_status: "", time: [], activated_time: [] }, @@ -25,89 +25,88 @@ export default { search: { show: false }, - table_titles: [{ - title: '客户编号', - key: 'id', - width: 150 - }, - { - title: 'SIM', - key: 'sim', - width: 150 - }, - { - title: '运营商', - key: 'carrier_operator', - width: 90 - }, - { - title: '企业名称', - key: 'company_name', - minWidth: 300 - }, - { - title: '套餐名称', - key: 'package_name', - minWidth: 110 - }, - { - title: '状态', - key: 'status_name', - width: 110 - }, - { - title: '服务时间', - key: '', - width: 170, - render: (h, { - row, - column, - index - }) => { - return h('span', row.service_start_at + ' - ' + row.service_end_at); - } - }, - { - title: '创建时间', - key: 'created_at', - width: 170 - }, - { - title: '操作', - key: 'action', - width: 110, - render: (h, { - row, - column, - index - }) => { - let html = []; - - if (this.haveJurisdiction('show')) { - html.push(h('Button', { - props: { - type: 'dashed', - size: 'small', - disabled: false, - icon: 'md-eye' - }, - class: ['btn'], - on: { - click: (event) => { - this.detailObj = { - show: true, - data: row - }; - } - } - }, '查看')); + table_titles: [ + { + title: "客户编号", + key: "id", + width: 150 + }, + { + title: "SIM", + key: "sim", + width: 150 + }, + { + title: "运营商", + key: "carrier_operator", + width: 90 + }, + { + title: "企业名称", + key: "company_name", + minWidth: 300 + }, + { + title: "套餐名称", + key: "package_name", + minWidth: 110 + }, + { + title: "状态", + key: "status_name", + width: 110 + }, + { + title: "服务时间", + key: "", + width: 170, + render: (h, { row, column, index }) => { + return h("span", row.service_start_at + " - " + row.service_end_at); } + }, + { + title: "创建时间", + key: "created_at", + width: 170 + }, + { + title: "操作", + key: "action", + width: 110, + render: (h, { row, column, index }) => { + let html = []; - if (html.length) { - return h('div', html); + if (this.haveJurisdiction("show")) { + html.push( + h( + "Button", + { + props: { + type: "dashed", + size: "small", + disabled: false, + icon: "md-eye" + }, + class: ["btn"], + on: { + click: event => { + this.detailObj = { + show: true, + data: row + }; + } + } + }, + "查看" + ) + ); + } + + if (html.length) { + return h("div", html); + } } } - } ] }; }, @@ -123,50 +122,61 @@ export default { index(page = 1) { let params = this.getParams({ page }); this.isShowLoading(true); - API.index(params).then(res => { - this.isShowLoading(false); - if (res.code == 0) { - this.list_data = res.data; - } - }).catch(() => { - this.isShowLoading(false); - }); + API.index(params) + .then(res => { + this.isShowLoading(false); + if (res.code == 0) { + this.list_data = res.data; + } + }) + .catch(() => { + this.isShowLoading(false); + }); }, - exportExcel() { let params = this.getParams({ limit: 0 }); this.isShowLoading(true); - API.exportExcel(params).then(res => { - this.isShowLoading(false); + API.exportExcel(params) + .then(res => { + this.isShowLoading(false); - if (res.code === 0) { - if (res.data) { - this.downloadFile(res.data); - } else { - this.$Modal.success({ - title: '提示', - content: '当前导出数据量大,已进入后台队列导出模式,请稍后至导出列表查看下载。' - }); + if (res.code === 0) { + if (res.data) { + this.downloadFile(res.data); + } else { + this.$Modal.success({ + title: "提示", + content: + "当前导出数据量大,已进入后台队列导出模式,请稍后至导出列表查看下载。" + }); + } } - } - }).catch(() => { - this.isShowLoading(false); - }); + }) + .catch(() => { + this.isShowLoading(false); + }); }, getParams({ page, limit }) { - let params = Object.assign({ - orderBy: 'created_at', - sortedBy: 'desc' - }, this.params); + let params = Object.assign( + { + orderBy: "created_at", + sortedBy: "desc" + }, + this.params + ); if (this.params.sim) { params.sim = this.params.sim.split(/[\s|,|;]+/); } - if (this.params.activated_time.length && this.params.activated_time[0] && this.params.activated_time[1]) { + if ( + this.params.activated_time.length && + this.params.activated_time[0] && + this.params.activated_time[1] + ) { let activated_time = this.parseTime(this.params.activated_time); params.activated_starttime = activated_time.starttime; params.activated_endtime = activated_time.endtime; @@ -188,7 +198,11 @@ export default { let page = result.current_page; if (result && result.data.length == 1) { - page = this.returnPage(result.total, result.current_page, result.per_page); + page = this.returnPage( + result.total, + result.current_page, + result.per_page + ); } this.index(page); @@ -196,10 +210,10 @@ export default { resetSearch() { for (let k in this.params) { - if (k === 'time' || k === 'activated_time') { + if (k === "time" || k === "activated_time") { this.params[k] = []; } else { - this.params[k] = ''; + this.params[k] = ""; } } this.index(1);