From 84d489ad3c7663f3591a4d62c822547e5eb888b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=9C=E8=B4=A4=E9=87=91?= <1960116313@qq.com> Date: Wed, 20 Apr 2022 22:02:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=BC=80=E5=8F=91=E5=9F=BA=E7=A1=80?= =?UTF-8?q?=E5=8D=A1=E5=AF=BC=E5=87=BA=20=20=E5=AF=BC=E5=85=A5=20=E5=88=86?= =?UTF-8?q?=E6=8B=A8=20=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/communication/basiccard.js | 33 + .../basiccard/basiccard.vue | 361 +++- .../communicationmanage/device/device.vue | 27 + src/views/system/user.vue | 1808 +++++++++-------- 4 files changed, 1362 insertions(+), 867 deletions(-) diff --git a/src/api/communication/basiccard.js b/src/api/communication/basiccard.js index 51429ac..b41fa42 100644 --- a/src/api/communication/basiccard.js +++ b/src/api/communication/basiccard.js @@ -47,3 +47,36 @@ export const update = (row) => { data: row }) } + +//分拨类型下拉 +export const allocate = () => { + return request({ + url: '/api/iot-system/dict/dictionary?code=allocate', + method: 'get', + }) +} +//租户下拉 +export const tenant = () => { + return request({ + url:'/api/iot-system/tenant/fillData', + method: 'get', + }) +} +//分拨操作 +export const simdeliver = (params) => { + return request({ + url:'/api/iot-sim/simcard/simdeliver', + method: 'post', + params: { + ...params, + } + }) +} +//通道 +export const channelfillData = () => { + return request({ + url:'/api/iot-sim/channel/fillData', + method: 'get', + + }) +} diff --git a/src/views/communicationmanage/basiccard/basiccard.vue b/src/views/communicationmanage/basiccard/basiccard.vue index 6a264f6..b759760 100644 --- a/src/views/communicationmanage/basiccard/basiccard.vue +++ b/src/views/communicationmanage/basiccard/basiccard.vue @@ -12,6 +12,7 @@ @row-update="rowUpdate" @row-save="rowSave" @row-del="rowDel" + @selection-change="selectionChange" @search-change="searchChange" @search-reset="searchReset" @current-change="currentChange" @@ -19,7 +20,117 @@ @refresh-change="refreshChange" @on-load="onLoad" > + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + 保 存 + 取 消 + + @@ -30,15 +141,115 @@ import { getDetail, remove, update, + allocate, + tenant, + simdeliver, + channelfillData, } from "@/api/communication/basiccard"; import { mapGetters } from "vuex"; - +import website from "@/config/website"; +import { getToken } from "@/util/auth"; export default { data() { + var start = (rule, value, callback) => { + if (value == null) { + callback(new Error("开始号码不能为空")); + } else if (value < 0) { + callback(new Error("开始号码不能为负数")); + } else { + callback(); + } + }; + var end = (rule, value, callback) => { + if (value == null) { + callback(new Error("结束号码不能为空")); + } else if (value < 0) { + callback(new Error("结束号码不能为负数")); + } else if (Number(value) < Number(this.distribution.numStart)) { + callback(new Error("结束号码必须大于开始号码")); + } else { + callback(); + } + }; return { form: {}, + excelForm: { + tenantId: "", + isCovered: 0, + }, + excelOption: { + column: [ + { + label: "通道名称", + prop: "tenantId", + type: "select", + span: 24, + dicUrl: "/api/iot-sim/channel/fillData", + props: { + label: "name", + value: "id", + }, + rules: [ + { + required: true, + message: "请选择通道名称", + trigger: "change", + }, + ], + }, + { + label: "模板上传", + prop: "excelFile", + type: "upload", + drag: true, + loadText: "模板上传中,请稍等", + span: 24, + propsHttp: { + res: "data", + }, + tip: "请上传 .xls,.xlsx 标准格式文件", + action: "/api/iot-sim/simcard/import-simCard", + rules: [ + { + required: true, + message: "请选择文件", + trigger: "change", + }, + ], + }, + { + label: "模板下载", + prop: "excelTemplate", + formslot: true, + span: 24, + }, + ], + }, + distribution: { + tenantId: "", //租户id + deliverType: null, //分拨类型 + numStart: null, //开始号码 + numEnd: null, //结束号码 + }, //分拨 + distributionlist: [], //分拨类型下拉 + tenantlist: [], //租户下拉 + distrules: { + tenantId: [ + { required: true, message: "请选择分拨租户", trigger: "change" }, + ], + deliverType: [ + { required: true, message: "请选择分拨类型", trigger: "change" }, + ], + numStart: [{ validator: start, trigger: "blur" }], + numEnd: [{ validator: end, trigger: "blur" }], + }, + channellist: [], //通道下拉 + ruleForm: {}, //导入 + dialogVisible: false, //分拨弹窗布尔 query: {}, + selectionList: [], loading: false, + excelBox: false, page: { pageSize: 10, currentPage: 1, @@ -53,6 +264,7 @@ export default { addBtn: true, viewBtn: true, delBtn: true, + excelBtn: false, //导出 columnBtn: false, selection: false, dialogClickModal: false, @@ -66,7 +278,7 @@ export default { span: 12, labelWidth: 130, search: true, - dicUrl: "/api/iot-sim/simcard/getChannel", + dicUrl: "/api/iot-sim/channel/fillData", props: { label: "name", value: "id", @@ -224,9 +436,34 @@ export default { // delBtn: this.vaildData(this.permission.sourceApi_delete, false), }; }, + ids() { + let ids = []; + this.selectionList.forEach((ele) => { + ids.push(ele.id); + }); + return ids.join(","); + }, + }, + created() { + this.allocatelist(); //分拨列表 + this.tenantlists(); //租户下拉 + // this.channellists(); //通道下拉 + }, + watch: { + "excelForm.tenantId"() { + if (this.excelForm.tenantId != "") { + if (process.env.NODE_ENV === "production") { + const column = this.findObject(this.excelOption.column, "excelFile"); + column.action = `http://223.99.228.240:18081/api/iot-sim/simcard/import-simCard?channelId=${this.excelForm.tenantId}`; + } else { + const column = this.findObject(this.excelOption.column, "excelFile"); + column.action = `/api/iot-sim/simcard/import-simCard?channelId=${this.excelForm.tenantId}`; + } + } + }, }, - methods: { + //详情 beforeOpen(done, type) { if (["edit", "view"].includes(type)) { getDetail(this.form.id).then((res) => { @@ -235,10 +472,12 @@ export default { } done(); }, + //重置搜索 searchReset() { this.query = {}; this.onLoad(this.page); }, + //搜索 searchChange(params, done) { this.query = params; this.page.currentPage = 1; @@ -297,15 +536,130 @@ export default { }); }); }, + //多选框 + selectionChange(list) { + this.selectionList = list; + }, + //多选框清除 + selectionClear() { + this.selectionList = []; + this.$refs.crud.toggleSelection(); + }, + + //分页 currentChange(currentPage) { this.page.currentPage = currentPage; }, + //页码规格 sizeChange(pageSize) { this.page.pageSize = pageSize; }, + //刷新 refreshChange() { this.onLoad(this.page, this.query); }, + //批量出库 + delivery() { + if (this.selectionList.length === 0) { + this.$message.warning("请选择至少一条数据"); + return; + } else { + this.$message.error(this.ids); + console.log(this.ids, typeof this.ids); + } + }, + //导出 + handleExport() { + if (process.env.NODE_ENV === "production") { + window.open( + `http://223.99.228.240:18081/bd-core/tenant/dailybill/export-excel?${ + this.website.tokenHeader + }=${getToken()}` + ); + } else { + window.open( + `/api/iot-sim/simcard/export-simCard?${ + this.website.tokenHeader + }=${getToken()}` + ); + } + }, + //导入弹窗开启 + handleImport() { + this.excelBox = true; + }, + //导入后 + uploadAfter(res, done, loading, column) { + this.excelBox = false; + this.refreshChange(); + done(); + }, + submit(res, done, loading, column) { + this.excelBox = false; + this.refreshChange(); + done(); + }, + //下载模板 + handleTemplate() { + window.open( + `/api/iot-system/user/export-template?${ + this.website.tokenHeader + }=${getToken()}` + ); + }, + //分拨下拉框 + allocatelist() { + allocate().then((res) => { + if (res.data.code == 200) { + this.distributionlist = res.data.data; + } + }); + }, + //租户下拉框 + tenantlists() { + tenant().then((res) => { + if (res.data.code == 200) { + this.tenantlist = res.data.data; + } + }); + }, + //分拨弹窗开启 + handleAllocate() { + this.dialogVisible = true; + }, + //分拨弹窗关闭 + handleClose() { + this.dialogVisible = false; + this.$refs.distribution.resetFields(); + }, + //提交分拨 + handleSubmit() { + this.$refs.distribution.validate((valid) => { + if (valid) { + simdeliver(this.distribution).then((res) => { + if (res.data.data == "") { + this.$message.success("操作成功"); + this.$refs.distribution.resetFields(); + this.dialogVisible = false; + } else { + const h = this.$createElement; + this.$notify.error({ + title: "错误号码", + message: h( + "i", + { style: "color: teal; word-break: break-all;" }, + res.data.data + ), + duration: 0, + }); + this.$refs.distribution.resetFields(); + this.dialogVisible = false; + } + }); + } else { + } + }); + }, onLoad(page, params = {}) { this.loading = true; getList( @@ -317,6 +671,7 @@ export default { this.page.total = data.total; this.data = data.records; this.loading = false; + this.selectionClear(); }); }, }, diff --git a/src/views/communicationmanage/device/device.vue b/src/views/communicationmanage/device/device.vue index 67afea5..3e779ba 100644 --- a/src/views/communicationmanage/device/device.vue +++ b/src/views/communicationmanage/device/device.vue @@ -19,6 +19,15 @@ @refresh-change="refreshChange" @on-load="onLoad" > + @@ -279,6 +288,24 @@ export default { refreshChange() { this.onLoad(this.page, this.query); }, + //导出 + handleExport() { + if (process.env.NODE_ENV === "production") { + window.open( + `http://223.99.228.240:18081/bd-core/tenant/dailybill/export-excel?${ + this.website.tokenHeader + }=${getToken()}&tenantId=${this.exp.tenantId}&yyyyMMdd=${ + this.exp.yyyyMMdd + }` + ); + } else { + window.open( + `/api/iot-sim/simcard/export-simCard?${ + this.website.tokenHeader + }=${getToken()}` + ); + } + }, onLoad(page, params = {}) { this.loading = true; getList( diff --git a/src/views/system/user.vue b/src/views/system/user.vue index cae5a52..aa97d7f 100644 --- a/src/views/system/user.vue +++ b/src/views/system/user.vue @@ -4,119 +4,141 @@
- +
- + -