This commit is contained in:
邓皓元 2019-09-20 10:35:57 +08:00
parent 5a535390e3
commit 2cb293efd7
2 changed files with 135 additions and 121 deletions

View File

@ -21,7 +21,7 @@
<Button @click="index(1)" icon="md-refresh">刷新</Button> <Button @click="index(1)" icon="md-refresh">刷新</Button>
</div> </div>
<div class="handle-item"> <div class="handle-item" v-has="'output'">
<Button @click="exportExcel" icon="md-download">导出</Button> <Button @click="exportExcel" icon="md-download">导出</Button>
</div> </div>
</li> </li>
@ -94,7 +94,7 @@
</li> </li>
<li class="handle-item w-250"> <li class="handle-item w-250">
<Input placeholder="SIM" type="textarea" v-model="params.sim"/> <Input placeholder="SIM" type="textarea" v-model="params.sim" />
</li> </li>
<li class="handle-item w-250"> <li class="handle-item w-250">

View File

@ -1,19 +1,19 @@
import * as API from 'api/virtual/cards'; import * as API from "api/virtual/cards";
export default { export default {
name: 'Cards', name: "Cards",
components: { components: {
UiDetail: resolve => require(['views/virtual/cards/detail'], resolve) UiDetail: resolve => require(["views/virtual/cards/detail"], resolve)
}, },
data() { data() {
return { return {
params: { params: {
id: '', id: "",
sim: '', sim: "",
company_name: '', company_name: "",
package_name: '', package_name: "",
carrier_operator: '', carrier_operator: "",
card_status: '', card_status: "",
time: [], time: [],
activated_time: [] activated_time: []
}, },
@ -25,89 +25,88 @@ export default {
search: { search: {
show: false show: false
}, },
table_titles: [{ table_titles: [
title: '客户编号', {
key: 'id', title: "客户编号",
width: 150 key: "id",
}, width: 150
{ },
title: 'SIM', {
key: 'sim', title: "SIM",
width: 150 key: "sim",
}, width: 150
{ },
title: '运营商', {
key: 'carrier_operator', title: "运营商",
width: 90 key: "carrier_operator",
}, width: 90
{ },
title: '企业名称', {
key: 'company_name', title: "企业名称",
minWidth: 300 key: "company_name",
}, minWidth: 300
{ },
title: '套餐名称', {
key: 'package_name', title: "套餐名称",
minWidth: 110 key: "package_name",
}, minWidth: 110
{ },
title: '状态', {
key: 'status_name', title: "状态",
width: 110 key: "status_name",
}, width: 110
{ },
title: '服务时间', {
key: '', title: "服务时间",
width: 170, key: "",
render: (h, { width: 170,
row, render: (h, { row, column, index }) => {
column, return h("span", row.service_start_at + " - " + row.service_end_at);
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
};
}
}
}, '查看'));
} }
},
{
title: "创建时间",
key: "created_at",
width: 170
},
{
title: "操作",
key: "action",
width: 110,
render: (h, { row, column, index }) => {
let html = [];
if (html.length) { if (this.haveJurisdiction("show")) {
return h('div', html); 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) { index(page = 1) {
let params = this.getParams({ page }); let params = this.getParams({ page });
this.isShowLoading(true); this.isShowLoading(true);
API.index(params).then(res => { API.index(params)
this.isShowLoading(false); .then(res => {
if (res.code == 0) { this.isShowLoading(false);
this.list_data = res.data; if (res.code == 0) {
} this.list_data = res.data;
}).catch(() => { }
this.isShowLoading(false); })
}); .catch(() => {
this.isShowLoading(false);
});
}, },
exportExcel() { exportExcel() {
let params = this.getParams({ limit: 0 }); let params = this.getParams({ limit: 0 });
this.isShowLoading(true); this.isShowLoading(true);
API.exportExcel(params).then(res => { API.exportExcel(params)
this.isShowLoading(false); .then(res => {
this.isShowLoading(false);
if (res.code === 0) { if (res.code === 0) {
if (res.data) { if (res.data) {
this.downloadFile(res.data); this.downloadFile(res.data);
} else { } else {
this.$Modal.success({ this.$Modal.success({
title: '提示', title: "提示",
content: '当前导出数据量大,已进入后台队列导出模式,请稍后至导出列表查看下载。' content:
}); "当前导出数据量大,已进入后台队列导出模式,请稍后至导出列表查看下载。"
});
}
} }
} })
}).catch(() => { .catch(() => {
this.isShowLoading(false); this.isShowLoading(false);
}); });
}, },
getParams({ page, limit }) { getParams({ page, limit }) {
let params = Object.assign({ let params = Object.assign(
orderBy: 'created_at', {
sortedBy: 'desc' orderBy: "created_at",
}, this.params); sortedBy: "desc"
},
this.params
);
if (this.params.sim) { if (this.params.sim) {
params.sim = this.params.sim.split(/[\s|,|;]+/); 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); let activated_time = this.parseTime(this.params.activated_time);
params.activated_starttime = activated_time.starttime; params.activated_starttime = activated_time.starttime;
params.activated_endtime = activated_time.endtime; params.activated_endtime = activated_time.endtime;
@ -188,7 +198,11 @@ export default {
let page = result.current_page; let page = result.current_page;
if (result && result.data.length == 1) { 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); this.index(page);
@ -196,10 +210,10 @@ export default {
resetSearch() { resetSearch() {
for (let k in this.params) { for (let k in this.params) {
if (k === 'time' || k === 'activated_time') { if (k === "time" || k === "activated_time") {
this.params[k] = []; this.params[k] = [];
} else { } else {
this.params[k] = ''; this.params[k] = "";
} }
} }
this.index(1); this.index(1);