<template>
|
<div class="authorityManagement_box">
|
<My-bread :list="[
|
`${$t('dataManage.dataManage')}`,
|
`${$t('dataManage.templateManage')}`,
|
]"></My-bread>
|
<el-divider />
|
<div class="searchComp subpage_Div" ref="container">
|
<el-form ref="ruleForm" :model="ruleForm" :inline="true">
|
<div class="flex_box">
|
<div style="margin-right: auto">
|
<el-form-item :label="$t('userManage.authorityM.name')">
|
<el-input style="width:200px" size="small" v-model="ruleForm.name"
|
:placeholder="$t('userManage.authorityM.nameHolder')">
|
<i slot="suffix" class="el-icon-search" @click="setRefreshTable"></i>
|
</el-input>
|
</el-form-item>
|
</div>
|
<div>
|
|
<!-- <el-form-item>-->
|
<!-- <el-button-->
|
<!-- icon="el-icon-search"-->
|
<!-- @click="setRefreshTable"-->
|
<!-- type="primary"-->
|
<!-- size="small"-->
|
<!-- >{{ $t('common.iquery') }}</el-button>-->
|
<!-- </el-form-item>-->
|
<el-form-item>
|
<el-button v-if="btnStatus.insert" @click="setTableInsert" icon="el-icon-edit" type="success"
|
size="small">{{ $t('common.append') }}</el-button>
|
</el-form-item>
|
<el-form-item>
|
<el-button v-if="btnStatus.delete" icon="el-icon-delete" @click="delTableData" type="danger"
|
size="small">{{
|
$t('common.delete') }}</el-button>
|
</el-form-item>
|
<el-form-item>
|
<el-button icon="el-icon-refresh" @click="restRefreshTable" type="info" size="small">{{ $t('common.empty')
|
}}</el-button>
|
</el-form-item>
|
</div>
|
</div>
|
|
</el-form>
|
</div>
|
<div class="dividing-line"></div>
|
<div class="table_box" :style="styleVar">
|
<el-table :data="tableData" style="width: 100%" border @selection-change="handleSelectionChange"
|
height="calc(100% - 45px)">
|
<el-table-column type="selection" width="55" />
|
<el-table-column align="center" type="index" :label="$t('dataManage.styleObj.index')" width="70px" />
|
<el-table-column align="center" prop="name" :label="$t('dataManage.styleObj.name')" />
|
<el-table-column align="center" prop="type" :label="$t('common.fileType')">
|
<template slot-scope="scope">
|
<span v-if="scope.row.type == 1">World模板 </span>
|
<span v-else-if="scope.row.type == 2">Excel模板</span>
|
<span v-else-if="scope.row.type == 3">Zip模板</span>
|
</template>
|
</el-table-column>
|
<el-table-column align="center" prop="code" :label="$t('common.templateType')" :formatter="codeData" />
|
<!-- <el-table-column
|
align="center"
|
prop="fname"
|
:label="$t('common.filePath')"
|
/> -->
|
<!-- <el-table-column
|
align="center"
|
prop="bak"
|
:label="$t('common.bak')"
|
/> -->
|
<el-table-column align="center" prop="createName" :label="$t('dataManage.vmobj.createonuser')" />
|
<el-table-column align="center" prop="createTime" :label="$t('dataManage.vmobj.createontime')"
|
:formatter="formatData" />
|
<el-table-column min-width="100" :label="$t('dataManage.dictionaryManageObj.operation')">
|
|
<template slot-scope="scope">
|
<el-button v-if="btnStatus.select" @click="showDetail(scope.$index, scope.row)" type="primary" plain
|
size="small">{{ $t('dataManage.dictionaryManageObj.lookOver') }}</el-button>
|
<el-button v-if="btnStatus.update" @click="handleEdit(scope.$index, scope.row)" type="warning" plain
|
size="small">{{ $t('dataManage.dictionaryManageObj.revamp') }}</el-button>
|
<el-button v-if="btnStatus.download" plain @click="handleDownload(scope.$index, scope.row)" type="info"
|
size="small">{{ $t('common.download') }}</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
<div style="margin-top:10px">
|
<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
|
:current-page="listData.pageIndex" :page-sizes="[10, 20, 50, 100]" :page-size="listData.pageSize"
|
layout="total, sizes, prev, pager, next, jumper" :total="listData.count">
|
</el-pagination>
|
</div>
|
</div>
|
<!-- 新增 -->
|
<el-dialog :title="behavior == '新增'
|
? `${$t('common.append')}`
|
: `${$t('common.update')}`
|
" :visible.sync="dialogVisible" :before-close="handleClose">
|
<div style="height: 500px; overflow: auto">
|
<el-form ref="form" :model="editForm" label-width="100px" label-position="top">
|
<el-form-item :label="$t('dataManage.styleObj.name')">
|
<el-input style="width:85%" v-model="editForm.name"
|
:placeholder="$t('shuJuGuanLi.shuJuJianSuo.valuetwo') + $t('dataManage.styleObj.name')"></el-input>
|
</el-form-item>
|
<el-form-item :label="$t('common.templateType')">
|
<!-- <el-input
|
style="width:100%"
|
v-model=" editForm.code"
|
></el-input> -->
|
<el-select :popper-append-to-body="false" style="width:85%" @change="selFileCodeChange"
|
v-model="editForm.code"
|
:placeholder="$t('shuJuGuanLi.shuJuJianSuo.valuetree') + $t('dataManage.common.templateType')">
|
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item :label="$t('common.fileType')">
|
<el-select :popper-append-to-body="false" v-model="editForm.type" @change="selFileTypeChange"
|
:placeholder="$t('shuJuGuanLi.shuJuJianSuo.valuetree') + $t('common.fileType')" style="width:85%">
|
<el-option v-for="item in typeOption" :key="item.value" :label="item.label" :value="item.value">
|
</el-option>
|
<!-- <el-option
|
label="World模板"
|
value="1"
|
></el-option>
|
<el-option
|
label="Excel模板"
|
value="2"
|
></el-option>
|
<el-option
|
label="Zip模板"
|
value="3"
|
></el-option> -->
|
</el-select>
|
</el-form-item>
|
|
<el-form-item :label="$t('common.filePath')">
|
<div class="BoxFlex">
|
<div class="BoxFlexinput">
|
<el-input v-model="editForm.fname" disabled autocomplete="off" style="width:100%"></el-input>
|
</div>
|
<div class="BoxFlexbutton">
|
<input name="file1" type="file" id="editFile" multiple="multiple" :accept="selectFileType"
|
style="display: none" @change="geteditFile(1)" />
|
<el-button style="margin-left: 6px;" type="primary" size="small" :underline="false"
|
@click="geteditFile(0)">选择</el-button>
|
<el-button type="primary" size="small" :underline="false" @click="geteditFile(2)">上传</el-button>
|
</div>
|
</div>
|
</el-form-item>
|
<el-form-item :label="$t('common.bak')">
|
<el-input style="width:85%" v-model="editForm.bak"
|
:placeholder="$t('shuJuGuanLi.shuJuJianSuo.valuetwo') + $t('common.bak')"></el-input>
|
</el-form-item>
|
</el-form>
|
</div>
|
<div v-if="behavior == '新增'" slot="footer" class="dialog-footer">
|
<el-button size="small" @click="closeInsertData">取 消</el-button>
|
<el-button type="primary" size="small" @click="addInsertData">确 定</el-button>
|
</div>
|
<div v-if="behavior != '新增'" slot="footer" class="dialog-footer">
|
<el-button size="small" @click="closeEditData">取 消</el-button>
|
<el-button type="primary" size="small" @click="addEditData">确 定</el-button>
|
</div>
|
</el-dialog>
|
<div class="infoBox_box" v-show="showinfoBox">
|
<div class="infoBox subpage_Div box_div">
|
|
<div slot="header" class="clearfix">
|
<span>{{ $t('dataManage.styleObj.deInformation') }}</span>
|
<div style="float: right; cursor: pointer" @click="closeDetial">
|
<i class="el-icon-close"></i>
|
</div>
|
</div>
|
<el-divider></el-divider>
|
<div class="contentBox">
|
<p>
|
<label> {{ $t('dataManage.styleObj.name') }}:</label>
|
<label class="boxlabel">{{ itemdetail.name }}</label>
|
</p>
|
<el-divider></el-divider>
|
<p>
|
<p>
|
<label> {{ $t('common.fileType') }}:</label>
|
<label class="boxlabel">{{ itemdetail.fileType }}</label>
|
</p>
|
</p>
|
<el-divider></el-divider>
|
<p>
|
<label> {{ $t('common.templateType') }}:</label>
|
<label class="boxlabel">{{ itemdetail.code }}</label>
|
</p>
|
<el-divider></el-divider>
|
<p>
|
<label> {{ $t('common.filePath') }}:</label>
|
<label class="boxlabel">{{ itemdetail.fname }}</label>
|
</p>
|
<el-divider></el-divider>
|
<p>
|
<label> {{ $t('common.bak') }}:</label>
|
<label class="boxlabel">{{ itemdetail.bak }}</label>
|
</p>
|
<el-divider></el-divider>
|
<p>
|
<label> {{ $t('dataManage.vmobj.createonuser') }}:</label>
|
<label class="boxlabel">{{ itemdetail.createName }}</label>
|
</p>
|
<el-divider></el-divider>
|
<p>
|
<label> {{ $t('dataManage.vmobj.createontime') }}:</label>
|
<label class="boxlabel">{{ itemdetail.cTime }}</label>
|
</p>
|
<el-divider></el-divider>
|
<p>
|
<label> {{ $t('dataManage.vmobj.updateonuser') }}:</label>
|
<label class="boxlabel">{{ itemdetail.updateName }}</label>
|
</p>
|
<el-divider></el-divider>
|
<p>
|
<label> {{ $t('dataManage.vmobj.updateontime') }}:</label>
|
<label class="boxlabel">{{ itemdetail.uTime }}</label>
|
</p>
|
<el-divider></el-divider>
|
</div>
|
|
</div>
|
</div>
|
<iframe id="downFrame" src="" style="display: none; border: 0; padding: 0; height: 0; width: 0"></iframe>
|
</div>
|
</template>
|
|
<script>
|
import MyBread from "../../components/MyBread.vue";
|
import {
|
report_selectByPageAndCount,
|
report_upload,
|
report_insert,
|
report_deletes,
|
report_update,
|
} from "../../api/api.js";
|
import dataStatistics from '../../components/js/dataStatistics.js'
|
import { getToken } from "@/utils/auth";
|
export default {
|
name: "templateManage",
|
components: { MyBread },
|
data() {
|
return {
|
options: [],
|
itemdetail: {},
|
showinfoBox: false,
|
behavior: "新增",
|
selectFileType: "*.*",
|
editForm: {
|
fname: "",
|
guid: "",
|
name: "",
|
code: "",
|
type: "",
|
bak: "",
|
},
|
multipleSelection: [],
|
dialogVisible: false,
|
tableData: [],
|
ruleForm: {
|
name: "",
|
},
|
listData: {
|
pageIndex: 1,
|
pageSize: 10,
|
name: "",
|
count: 0,
|
},
|
btnStatus: {
|
select: false,
|
delete: false,
|
upload: false,
|
download: false,
|
insert: false,
|
update: false,
|
},
|
tableHeight: 0,
|
timer: 0,
|
styleVar: {
|
height: "calc(100% - 109px)",
|
},
|
typeOption: [],
|
rowGuid: null,
|
};
|
},
|
created() {
|
this.showPermsBtn();
|
this.showTableData();
|
},
|
beforeDestroy() {
|
this.timer && clearTimeout(this.timer);
|
window.removeEventListener("resize", this.onResize);
|
},
|
mounted() {
|
|
var obj = dataStatistics.statistics.filter(res => {
|
if (res.isMenu != false)
|
return res;
|
})
|
this.options = obj
|
window.addEventListener("resize", this.onResize);
|
this.calHeight();
|
},
|
methods: {
|
onResize() {
|
this.timer && clearTimeout(this.timer);
|
this.timer = setTimeout(() => {
|
this.calHeight();
|
}, 500);
|
},
|
calHeight() {
|
this.$nextTick(() => {
|
const rect = this.$refs.container.getBoundingClientRect();
|
this.tableHeight = `${rect.height + 97}px`;
|
this.styleVar["height"] = `calc(100% - ${rect.height + 30}px)`;
|
// this.styleVar["height"] = `calc(100% - ${rect.height + 97}px)`;
|
});
|
},
|
//修改取消
|
closeEditData() {
|
this.closeInsertData();
|
},
|
handleClose() {
|
var blackTheme;
|
if (this.$store.state.themeflag == true) {
|
blackTheme = {
|
customClass: "Black_theme",
|
};
|
}
|
|
this.$confirm("关闭后无法保存,是否关闭?", blackTheme)
|
.then((_) => {
|
this.closeInsertData();
|
})
|
.catch((_) => { });
|
},
|
codeData(row, column) {
|
|
var code = row.code;
|
let val = this.options.filter(res => {
|
if (res.value == code) {
|
return res
|
}
|
})
|
if (val.length > 0) {
|
return val[0].label
|
} else {
|
return code
|
}
|
|
},
|
//查看
|
showDetail(index, row) {
|
this.itemdetail = row;
|
|
if (parseInt(row.type) == 1) {
|
this.itemdetail.fileType = "World模板";
|
} else if (parseInt(row.type) == 2) {
|
this.itemdetail.fileType = "Excel模板";
|
} else if (parseInt(row.type) == 3) {
|
this.itemdetail.fileType = "Zip模板";
|
}
|
var val = this.options.filter(res => {
|
if (res.value == row.code) {
|
return res
|
}
|
})
|
if (val.length > 0 && val[0].label) {
|
this.itemdetail.code = val[0].label;
|
}
|
|
// if (row.code.indexOf("countSizes") != -1) {
|
// this.itemdetail.code = "数据量统计";
|
// } else if (row.code.indexOf("countServices") != -1) {
|
// this.itemdetail.code = "服务调用量统计";
|
// } else if (row.code.indexOf("countOperates") != -1) {
|
// this.itemdetail.code = "用户流量统计";
|
// } else if (row.code.indexOf("countOperates") != -1) {
|
// this.itemdetail.code = "用户流量统计";
|
// } else if (row.code.indexOf("countOperates") != -1) {
|
// this.itemdetail.code = "用户流量统计";
|
// }
|
|
this.itemdetail.cTime = this.format(row.createTime);
|
if (row.updateTime) {
|
|
this.itemdetail.uTime = this.format(row.updateTime);
|
}
|
// this.itemdetail.uTime = this.format(row.updateTime);
|
this.showinfoBox = true;
|
},
|
//关闭查看
|
closeDetial() {
|
this.showinfoBox = false;
|
},
|
//下载
|
handleDownload(index, row) {
|
var token = getToken();
|
var url =
|
BASE_URL + "/report/download?token=" + token + "&guid=" + row.guid;
|
$("#downFrame").attr("src", url).click();
|
},
|
//修改提交
|
async addEditData() {
|
this.editForm.guid = this.rowGuid;
|
debugger
|
const data = await report_update(this.editForm);
|
if (data.code != 200) {
|
return this.$message.error("修改失败");
|
}
|
this.$message({
|
message: "修改成功",
|
type: "success",
|
});
|
this.closeInsertData();
|
},
|
//文件类型切换
|
selFileTypeChange(val) {
|
if (parseInt(val) == 1) {
|
this.selectFileType = ".docx";
|
} else if (parseInt(val) == 2) {
|
this.selectFileType = ".xlsx";
|
} else if (parseInt(val) == 3) {
|
this.selectFileType = ".zip";
|
}
|
},
|
selFileCodeChange(res) {
|
var name;
|
for (var i in this.options) {
|
if (this.options[i].value == res) {
|
name = this.options[i].label
|
break;
|
}
|
}
|
console.log(name)
|
if (name.indexOf('统计') > -1) {
|
this.typeOption = [{
|
label: "World模板",
|
value: "1"
|
}, {
|
label: "Excel模板",
|
value: "2"
|
}]
|
|
} else {
|
this.typeOption = [{
|
label: "World模板",
|
value: "1"
|
}, {
|
label: "Excel模板",
|
value: "2"
|
}, {
|
label: "Zip模板",
|
value: "3"
|
}]
|
}
|
this.editForm.type = this.typeOption[0].value
|
},
|
|
|
|
|
//修改
|
handleEdit(index, row) {
|
this.behavior = "修改";
|
this.editForm = row;
|
|
if (row.name.indexOf('统计') > -1) {
|
this.typeOption = [{
|
label: "World模板",
|
value: "1"
|
}, {
|
label: "Excel模板",
|
value: "2"
|
}]
|
|
} else {
|
this.typeOption = [{
|
label: "World模板",
|
value: "1"
|
}, {
|
label: "Excel模板",
|
value: "2"
|
}, {
|
label: "Zip模板",
|
value: "3"
|
}]
|
}
|
if (parseInt(row.type) == 1) {
|
this.selectFileType = ".docx";
|
} else if (parseInt(row.type) == 2) {
|
this.selectFileType = ".xlsx";
|
}
|
this.rowGuid = row.guid;
|
|
|
|
|
this.dialogVisible = true;
|
},
|
//删除
|
async delTableData() {
|
if (this.multipleSelection.length == 0) {
|
return this.$message("请选择要删除的数据");
|
}
|
var std = [];
|
for (var i in this.multipleSelection) {
|
std.push(this.multipleSelection[i].id);
|
}
|
this.$confirm("此操作将永久删除该模块, 是否继续?", "提示", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning",
|
})
|
.then(async () => {
|
const data = await report_deletes({ ids: std.toString() });
|
if (data.code == 200) {
|
this.InsertFormdialog = false;
|
this.$message({
|
message: "删除成功!",
|
type: "success",
|
});
|
this.setRefreshTable();
|
} else {
|
this.$message({
|
message: "删除失败!",
|
type: "warning",
|
});
|
}
|
})
|
.catch(() => {
|
this.$message({
|
type: "info",
|
message: "已取消删除",
|
});
|
});
|
// const data = await report_deletes({ ids: std.toString() })
|
// if (data.code != 200) {
|
// return this.$message.error("删除失败");
|
// }
|
// this.$message({
|
// message: '删除成功',
|
// type: 'success'
|
// });
|
// this.setRefreshTable();
|
},
|
|
//重置查询
|
restRefreshTable() {
|
this.ruleForm.name = "";
|
this.setRefreshTable();
|
},
|
//重置刷新Table
|
setRefreshTable() {
|
this.listData.pageIndex = 1;
|
this.listData.pageSize = 10;
|
this.showTableData();
|
},
|
//新增一条数据
|
async addInsertData() {
|
this.editForm.guid = this.rowGuid;
|
const data = await report_insert(this.editForm);
|
if (data.code != 200) {
|
return this.$message.error("新增失败");
|
}
|
this.$message({
|
message: "新增成功",
|
type: "success",
|
});
|
this.closeInsertData();
|
},
|
//关闭新增
|
closeInsertData() {
|
this.dialogVisible = false;
|
this.editForm = {
|
fname: "",
|
guid: "",
|
name: "",
|
code: "",
|
type: "",
|
bak: "",
|
};
|
this.setRefreshTable();
|
document.getElementById("editFile").value = "";
|
},
|
//文件上传
|
async geteditFile(res) {
|
|
if (parseInt(this.editForm.type) == 1) {
|
this.selectFileType = ".docx";
|
} else if (parseInt(this.editForm.type) == 2) {
|
this.selectFileType = ".xlsx";
|
}
|
this.$nextTick(() => {
|
this.setEditFile(res)
|
})
|
|
},
|
async setEditFile(res) {
|
if (res == 0) {
|
if (this.editForm.type == "") {
|
return this.$message("请选择上传文件类型");
|
}
|
|
|
|
$("#editFile").click();
|
} else if (res == 1) {
|
var val = document.getElementById("editFile").files;
|
if (!val || !val.length) return;
|
this.editForm.fname = val[0].name;
|
} else if (res == 2) {
|
var fs = document.getElementById("editFile");
|
if (fs.files.length == 0) {
|
return;
|
}
|
var formData = new FormData();
|
formData.append("file", fs.files[0]);
|
var val_data = await report_upload(formData);
|
if (val_data.code == 200) {
|
this.editForm.guid = val_data.result;
|
this.rowGuid = val_data.result;
|
this.$message({
|
message: "上传成功!",
|
type: "success",
|
});
|
} else {
|
this.$message({
|
message: "上传失败!",
|
type: "warning",
|
});
|
}
|
}
|
},
|
//格式化列表
|
formatData(row, column) {
|
let data = row[column.property];
|
if (data == null) {
|
return data;
|
}
|
return this.format(data);
|
},
|
//格式化时间
|
format(shijianchuo) {
|
//shijianchuo是整数,否则要parseInt转换
|
var time = new Date(shijianchuo);
|
var y = time.getFullYear();
|
var m = time.getMonth() + 1;
|
var d = time.getDate();
|
var h = time.getHours();
|
var mm = time.getMinutes();
|
var s = time.getSeconds();
|
return y + "-" + this.add0(m) + "-" + this.add0(d);
|
},
|
//格式化时间
|
add0(m) {
|
return m < 10 ? "0" + m : m;
|
},
|
//Table选择事件
|
handleSelectionChange(val) {
|
this.multipleSelection = val;
|
},
|
|
editFormStart() {
|
this.editForm.code = "dataTable";
|
var name;
|
for (var i in this.options) {
|
if (this.options[i].value == this.editForm.code) {
|
name = this.options[i].label
|
break;
|
}
|
}
|
|
if (name.indexOf('统计') > -1) {
|
this.typeOption = [{
|
label: "World模板",
|
value: "1"
|
}, {
|
label: "Excel模板",
|
value: "2"
|
}]
|
|
} else {
|
this.typeOption = [{
|
label: "World模板",
|
value: "1"
|
}, {
|
label: "Excel模板",
|
value: "2"
|
}, {
|
label: "Zip模板",
|
value: "3"
|
}]
|
}
|
this.editForm.type = this.typeOption[0].value
|
},
|
|
//新增弹窗
|
setTableInsert() {
|
this.editFormStart();
|
this.behavior = "新增";
|
this.dialogVisible = true;
|
},
|
//分页切换
|
handleSizeChange(val) {
|
this.listData.pageSize = val;
|
this.listData.pageIndex = 1;
|
this.showTableData();
|
},
|
//分页切换
|
handleCurrentChange(val) {
|
this.listData.pageIndex = val;
|
this.showTableData();
|
},
|
//列表调用
|
async showTableData() {
|
this.listData.name = this.ruleForm.name;
|
const data = await report_selectByPageAndCount(this.listData);
|
if (data.code != 200) {
|
return this.$message.error("列表调用失败");
|
}
|
|
this.tableData = data.result;
|
this.listData.count = data.count;
|
},
|
//权限配置
|
showPermsBtn() {
|
let currentPerms = this.$store.state.currentPerms;
|
let permsEntity = this.$store.state.permsEntity;
|
permsEntity
|
.filter((item) => item.perms == currentPerms)
|
.map((item) => (this.btnStatus[item.tag.substr(1)] = true));
|
},
|
},
|
};
|
</script>
|
|
<style lang="less" scoped>
|
//@import url(); 引入公共css类
|
.authorityManagement_box {
|
height: 98%;
|
width: 98%;
|
padding: 0.5%;
|
|
.el-input {
|
width: 730px;
|
}
|
|
.searchComp {
|
//padding: 8px;
|
//margin-top: 20px;
|
|
border-radius: 5px;
|
|
//margin-bottom: 20px;
|
|
.el-form-item {
|
margin: 5px;
|
}
|
|
.el-input {
|
width: 467px;
|
}
|
}
|
|
.leftTree {
|
position: absolute;
|
z-index: 10;
|
z-index: 9999;
|
top: 100px;
|
left: 800px;
|
width: 400px;
|
height: 600px;
|
|
.treeBox {
|
height: 550px;
|
overflow: auto;
|
}
|
|
.btnBox {
|
width: 160px;
|
margin: 10px auto 0;
|
}
|
}
|
|
.bottom {
|
width: 100%;
|
height: 85%;
|
|
.rightTable {
|
height: 100%;
|
width: 100%;
|
|
.table_box {
|
width: 100%;
|
height: 80%;
|
margin: 0 auto;
|
overflow: auto;
|
}
|
}
|
}
|
}
|
</style>
|