158 lines
5.1 KiB
HTML
158 lines
5.1 KiB
HTML
{{template "header" }}
|
|
<style>
|
|
.el-form-item__content{
|
|
line-height: unset;
|
|
}
|
|
</style>
|
|
<div id="app" style="width:100%">
|
|
<template>
|
|
<el-container>
|
|
|
|
<el-main class="mainMain">
|
|
<div style="margin-bottom: 10px;">
|
|
<el-button @click="cateForm.id='';cateForm.cate_name='';showNewsForm=false;showCateForm=true;" type="primary" size="small">添加知识库集合</el-button>
|
|
</div>
|
|
<el-form v-show="showCateForm" label-width="80px" style="width: 500px;border-radius: 4px;padding: 30px 20px 0px 20px;border: 1px dashed #ccc">
|
|
<el-form-item label="集合名称">
|
|
<el-input v-model="cateForm.cate_name"></el-input>
|
|
</el-form-item>
|
|
|
|
<el-form-item>
|
|
<el-button @click="addCate()" type="primary" size="small">保存</el-button>
|
|
<el-button @click="showCateForm=false;" type="info" size="small">关闭</el-button>
|
|
</el-form-item>
|
|
</el-form>
|
|
|
|
<el-table
|
|
:data="cateList"
|
|
border
|
|
style="width: 100%;margin-top: 10px;">
|
|
<el-table-column
|
|
prop="name"
|
|
label="集合名称">
|
|
</el-table-column>
|
|
|
|
|
|
<el-table-column
|
|
prop="id"
|
|
label="删除">
|
|
<template slot-scope="scope">
|
|
|
|
<el-button @click="deleteCate(scope.row.name)" type="primary" size="small" icon="el-icon-delete" circle></el-button>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
|
|
</el-main>
|
|
|
|
</el-container>
|
|
|
|
</template>
|
|
|
|
</div>
|
|
</body>
|
|
|
|
<script>
|
|
var LANG=checkLang();
|
|
new Vue({
|
|
el: '#app',
|
|
delimiters:["<{","}>"],
|
|
data: {
|
|
flyLang:KEFU_LANG[LANG],
|
|
window:window,
|
|
host:getBaseUrl(),
|
|
cateForm:{
|
|
id:"",
|
|
cate_name:""
|
|
},
|
|
cateList:[],
|
|
showCateForm:false,
|
|
uploadUrl:"/system/collectUpload?token="+localStorage.getItem("token"),
|
|
},
|
|
methods: {
|
|
//添加分类
|
|
addCate(){
|
|
var _this=this;
|
|
sendAjax("/system/collect","post",{
|
|
cate_name:_this.cateForm.cate_name,
|
|
id:_this.cateForm.id
|
|
},function(res) {
|
|
_this.$message({
|
|
message: "ok",
|
|
type: 'success'
|
|
});
|
|
_this.getCate();
|
|
});
|
|
},
|
|
//分类列表
|
|
getCate(){
|
|
var _this=this;
|
|
sendAjax("/system/collects","get",{
|
|
},function(res) {
|
|
_this.cateList=JSON.parse(res.result);
|
|
});
|
|
},
|
|
//删除分类
|
|
deleteCate(collectName){
|
|
var _this=this;
|
|
this.$confirm('此操作将进行删除, 是否继续?', '提示', {
|
|
confirmButtonText: '确定',
|
|
cancelButtonText: '取消',
|
|
type: 'warning'
|
|
}).then(function(){
|
|
sendAjax("/system/delCollect","get",{
|
|
collectName:collectName
|
|
},function(res) {
|
|
_this.$message({
|
|
message: "ok",
|
|
type: 'success'
|
|
});
|
|
_this.getCate();
|
|
});
|
|
});
|
|
|
|
},
|
|
|
|
//上传文件失败
|
|
uploadDocSuccess(response, file, fileList){
|
|
this.loading.close();
|
|
if(response.code==20000){
|
|
this.$message({
|
|
message: "上传成功",
|
|
type: 'success'
|
|
});
|
|
}else{
|
|
this.$message({
|
|
message: response.msg,
|
|
type: 'error'
|
|
});
|
|
}
|
|
},
|
|
//上传文件失败
|
|
uploadError(){
|
|
this.loading.close();
|
|
},
|
|
//上传之前
|
|
beforeUpload(file){
|
|
this.loading = this.$loading({
|
|
lock: true,
|
|
text: "上传中",
|
|
});
|
|
|
|
let ext=file.name.substring(file.name.lastIndexOf(".")+1);
|
|
if (ext != 'txt' && ext != 'docx' && ext != 'xlsx') {
|
|
this.$message.error('上传文件只能是 .txt .docx .xlsx 格式!');
|
|
this.loading.close();
|
|
return false;
|
|
}
|
|
},
|
|
},
|
|
mounted:function(){
|
|
},
|
|
created: function () {
|
|
this.getCate();
|
|
|
|
}
|
|
})
|
|
</script>
|