fixed:添加法规准则
This commit is contained in:
parent
175ece28a2
commit
659e7ca978
|
@ -175,6 +175,12 @@ export const asyncRoutes = [
|
||||||
meta: { title: '资讯资料分享', icon: 'guide', perms: ['consulting_views'] },
|
meta: { title: '资讯资料分享', icon: 'guide', perms: ['consulting_views'] },
|
||||||
alwaysShow: true,
|
alwaysShow: true,
|
||||||
children: [
|
children: [
|
||||||
|
{
|
||||||
|
path: 'rule',
|
||||||
|
name: 'rule',
|
||||||
|
component: () => import('@/views/consulting/rule.vue'),
|
||||||
|
meta: { title: '法规准则', perms: ['policy_view'] }
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'policy',
|
path: 'policy',
|
||||||
name: 'policy',
|
name: 'policy',
|
||||||
|
|
|
@ -1,11 +1,21 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-card>
|
<el-card>
|
||||||
|
|
||||||
<el-button type="primary" icon="el-icon-plus" @click="handleAddContent" v-if="checkPermission(['policy_create'])"
|
<el-button type="primary" icon="el-icon-plus" @click="handleAddContent" v-if="checkPermission(['policy_create'])"
|
||||||
>新增</el-button
|
>
|
||||||
>
|
新增
|
||||||
|
</el-button>
|
||||||
|
<el-input
|
||||||
|
v-model="listQuery.search"
|
||||||
|
placeholder="输入关键字搜索"
|
||||||
|
style="width: 200px;"
|
||||||
|
class="filter-item"
|
||||||
|
/>
|
||||||
|
<el-button
|
||||||
|
class="filter-item"
|
||||||
|
type="primary"
|
||||||
|
icon="el-icon-search"
|
||||||
|
@click="handleSearch">搜索</el-button>
|
||||||
</el-card>
|
</el-card>
|
||||||
<el-card style="margin-top: 10px">
|
<el-card style="margin-top: 10px">
|
||||||
<el-table
|
<el-table
|
||||||
|
@ -18,27 +28,27 @@
|
||||||
max-height="600"
|
max-height="600"
|
||||||
>
|
>
|
||||||
<el-table-column type="index" width="50" />
|
<el-table-column type="index" width="50" />
|
||||||
<el-table-column label="名称">
|
<el-table-column label="名称" min-width="110">
|
||||||
<template slot-scope="scope">{{ scope.row.name }}</template>
|
<template slot-scope="scope">{{ scope.row.name }}</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
<el-table-column align="center" label="文件下载" width="80">
|
||||||
|
|
||||||
<el-table-column align="center" label="文件下载">
|
|
||||||
<template slot-scope="scope" v-if="scope.row.file_.file">
|
<template slot-scope="scope" v-if="scope.row.file_.file">
|
||||||
<el-link :href="scope.row.file_.file" type="primary">{{ scope.row.file_.name }}</el-link>
|
<el-link :href="scope.row.file_.file" type="primary">
|
||||||
|
<el-icon class="el-icon--right"><icon-view /></el-icon>
|
||||||
|
<i class="el-icon-download"></i>
|
||||||
|
</el-link>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="文件描述" >
|
<el-table-column label="文件描述" >
|
||||||
<template slot-scope="scope">{{ scope.row.description }}</template>
|
<template slot-scope="scope">{{ scope.row.description }}</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="创建时间">
|
<el-table-column label="创建时间" width='160'>
|
||||||
<template slot-scope="scope">{{ scope.row.create_time }}</template>
|
<template slot-scope="scope">{{ scope.row.create_time }}</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
<el-table-column
|
<el-table-column
|
||||||
align="center"
|
align="center"
|
||||||
label="操作"
|
label="操作"
|
||||||
width="200px"
|
width="120px"
|
||||||
fixed="right"
|
fixed="right"
|
||||||
>
|
>
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
|
@ -128,6 +138,7 @@ import Treeselect from "@riophae/vue-treeselect";
|
||||||
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
||||||
import { upUrl, upHeaders } from "@/api/file";
|
import { upUrl, upHeaders } from "@/api/file";
|
||||||
const defaultContent = {
|
const defaultContent = {
|
||||||
|
cate:'政策',
|
||||||
name: "",
|
name: "",
|
||||||
description: "",
|
description: "",
|
||||||
file:null
|
file:null
|
||||||
|
@ -140,10 +151,12 @@ export default {
|
||||||
upUrl: upUrl(),
|
upUrl: upUrl(),
|
||||||
fileList:[],
|
fileList:[],
|
||||||
Content: defaultContent,
|
Content: defaultContent,
|
||||||
|
listLoading:false,
|
||||||
dialogVisible: false,
|
dialogVisible: false,
|
||||||
listQuery: {
|
listQuery: {
|
||||||
page: 1,
|
page: 1,
|
||||||
|
cate:'政策',
|
||||||
|
search:'',
|
||||||
page_size: 20,
|
page_size: 20,
|
||||||
},
|
},
|
||||||
contentList: {
|
contentList: {
|
||||||
|
@ -166,6 +179,9 @@ export default {
|
||||||
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
handleSearch(){
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
handlePreview(file) {
|
handlePreview(file) {
|
||||||
if ("url" in file) {
|
if ("url" in file) {
|
||||||
window.open(file.url);
|
window.open(file.url);
|
||||||
|
|
|
@ -0,0 +1,282 @@
|
||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-card>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
icon="el-icon-plus"
|
||||||
|
@click="handleAddContent"
|
||||||
|
v-if="checkPermission(['policy_create'])"
|
||||||
|
>新增
|
||||||
|
</el-button>
|
||||||
|
<el-input
|
||||||
|
v-model="listQuery.search"
|
||||||
|
placeholder="输入关键字搜索"
|
||||||
|
style="width: 200px;"
|
||||||
|
class="filter-item"
|
||||||
|
/>
|
||||||
|
<el-button
|
||||||
|
class="filter-item"
|
||||||
|
type="primary"
|
||||||
|
icon="el-icon-search"
|
||||||
|
@click="handleSearch">搜索</el-button>
|
||||||
|
</el-card>
|
||||||
|
<el-card style="margin-top: 10px">
|
||||||
|
<el-table
|
||||||
|
v-loading="listLoading"
|
||||||
|
:data="contentList.results"
|
||||||
|
border
|
||||||
|
fit
|
||||||
|
stripe
|
||||||
|
highlight-current-row
|
||||||
|
:height="tableHeight"
|
||||||
|
>
|
||||||
|
<el-table-column type="index" width="50" />
|
||||||
|
<el-table-column label="名称" min-width="110">
|
||||||
|
<template slot-scope="scope">{{ scope.row.name }}</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column align="center" label="文件下载" width="80">
|
||||||
|
<template slot-scope="scope" v-if="scope.row.file_.file">
|
||||||
|
<el-link :href="scope.row.file_.file" type="primary">
|
||||||
|
<i class="el-icon-download"></i>
|
||||||
|
</el-link>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="文件描述">
|
||||||
|
<template slot-scope="scope">{{ scope.row.description }}</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="创建时间" width='160'>
|
||||||
|
<template slot-scope="scope">{{ scope.row.create_time }}</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
align="center"
|
||||||
|
label="操作"
|
||||||
|
width="120px"
|
||||||
|
fixed="right"
|
||||||
|
>
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button
|
||||||
|
:disabled="!checkPermission(['policy_update'])"
|
||||||
|
type="primary"
|
||||||
|
size="small"
|
||||||
|
icon="el-icon-edit"
|
||||||
|
@click="handleEdit(scope)"
|
||||||
|
/>
|
||||||
|
<el-button
|
||||||
|
:disabled="!checkPermission(['policy_delete'])"
|
||||||
|
type="danger"
|
||||||
|
size="small"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
@click="handleDelete(scope)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<pagination
|
||||||
|
v-show="contentList.count > 0"
|
||||||
|
:total="contentList.count"
|
||||||
|
:page.sync="listQuery.page"
|
||||||
|
:limit.sync="listQuery.page_size"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
</el-card>
|
||||||
|
<el-dialog
|
||||||
|
:visible.sync="dialogVisible"
|
||||||
|
:title="dialogType === 'edit' ? '编辑法规准则' : '新增法规准则'"
|
||||||
|
>
|
||||||
|
<el-form
|
||||||
|
ref="Form"
|
||||||
|
:model="Content"
|
||||||
|
label-width="80px"
|
||||||
|
label-position="right"
|
||||||
|
:rules="rule1"
|
||||||
|
>
|
||||||
|
<el-form-item label="名称" prop="name">
|
||||||
|
<el-input v-model="Content.name" placeholder="法规准则名称" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="规则描述" prop="description">
|
||||||
|
<el-input
|
||||||
|
type="textarea"
|
||||||
|
:rows="4"
|
||||||
|
v-model="Content.description"
|
||||||
|
placeholder="规则描述"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="文件上传" prop="file" v-if="dialogVisible">
|
||||||
|
<el-upload
|
||||||
|
ref="upload"
|
||||||
|
:action="upUrl"
|
||||||
|
:on-preview="handlePreview"
|
||||||
|
:on-success="handleUpSuccess"
|
||||||
|
:on-remove="handleRemove"
|
||||||
|
:headers="upHeaders"
|
||||||
|
:file-list="fileList"
|
||||||
|
:limit="1"
|
||||||
|
accept=".doc,.docx,.xls,.xlsx,.ppt,.pptx,.pdf,.zip"
|
||||||
|
>
|
||||||
|
<el-button size="small" type="primary">上传文件</el-button>
|
||||||
|
</el-upload>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
</el-form>
|
||||||
|
<div style="text-align: right">
|
||||||
|
<el-button type="danger" @click="dialogVisible = false">取消</el-button>
|
||||||
|
<el-button type="primary" @click="confirm('Form')">确认</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import { getPolicyList, createPolicy, deletePolicy, updatePolicy } from "@/api/policy";
|
||||||
|
import checkPermission from "@/utils/permission";
|
||||||
|
import Pagination from "@/components/Pagination"; // secondary package based on el-pagination
|
||||||
|
import Treeselect from "@riophae/vue-treeselect";
|
||||||
|
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
||||||
|
import { upUrl, upHeaders } from "@/api/file";
|
||||||
|
const defaultContent = {
|
||||||
|
cate:'法规',
|
||||||
|
name: "",
|
||||||
|
description: "",
|
||||||
|
file:null
|
||||||
|
};
|
||||||
|
export default {
|
||||||
|
components: { Pagination, Treeselect },
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
upHeaders: upHeaders(),
|
||||||
|
upUrl: upUrl(),
|
||||||
|
fileList:[],
|
||||||
|
Content: defaultContent,
|
||||||
|
listLoading:false,
|
||||||
|
dialogVisible: false,
|
||||||
|
listQuery: {
|
||||||
|
page: 1,
|
||||||
|
cate:'法规',
|
||||||
|
search:'',
|
||||||
|
page_size: 20,
|
||||||
|
},
|
||||||
|
contentList: {
|
||||||
|
count:0
|
||||||
|
},
|
||||||
|
tableHeight:null,
|
||||||
|
dialogType: "new",
|
||||||
|
rule1: {
|
||||||
|
name: [{ required: true, message: "请输入名称", trigger: "blur" }],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {},
|
||||||
|
watch: {
|
||||||
|
filterOrgText(val) {
|
||||||
|
this.$refs.tree.filter(val);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getList();
|
||||||
|
|
||||||
|
},
|
||||||
|
mounted(){
|
||||||
|
let height1 = document.getElementsByClassName('app-main')[0].clientHeight;
|
||||||
|
this.tableHeight = height1-120;
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
handleSearch(){
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
handlePreview(file) {
|
||||||
|
if ("url" in file) {
|
||||||
|
window.open(file.url);
|
||||||
|
} else {
|
||||||
|
window.open(file.response.data.path);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
handleUpSuccess(res, file, filelist) {
|
||||||
|
this.Content.file = res.data.id;
|
||||||
|
|
||||||
|
},
|
||||||
|
handleRemove(file, filelist){
|
||||||
|
this.Content.file = null;
|
||||||
|
},
|
||||||
|
checkPermission,
|
||||||
|
|
||||||
|
filterNode(value, data) {
|
||||||
|
if (!value) return true;
|
||||||
|
return data.label.indexOf(value) !== -1;
|
||||||
|
},
|
||||||
|
getList() {
|
||||||
|
getPolicyList(this.listQuery).then((response) => {
|
||||||
|
if (response.data) {
|
||||||
|
this.contentList = response.data;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleAddContent() {
|
||||||
|
this.Content = Object.assign({}, defaultContent);
|
||||||
|
this.dialogType = "new";
|
||||||
|
this.dialogVisible = true;
|
||||||
|
this.fileList=[]
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs["Form"].clearValidate();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleEdit(scope) {
|
||||||
|
this.Content = Object.assign({}, scope.row); // copy obj
|
||||||
|
this.dialogType = "edit";
|
||||||
|
this.dialogVisible = true;
|
||||||
|
if (this.Content.file) {
|
||||||
|
this.fileList = [
|
||||||
|
{
|
||||||
|
name:this.Content.file_.name,
|
||||||
|
url: this.Content.file,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs["Form"].clearValidate();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleDelete(scope) {
|
||||||
|
this.$confirm("确认删除?", "警告", {
|
||||||
|
confirmButtonText: "确认",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "error",
|
||||||
|
})
|
||||||
|
.then(async () => {
|
||||||
|
await deletePolicy(scope.row.id);
|
||||||
|
this.getList();
|
||||||
|
this.$message.success("成功");
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error(err);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
async confirm(form) {
|
||||||
|
this.$refs[form].validate((valid) => {
|
||||||
|
if (valid) {
|
||||||
|
const isEdit = this.dialogType === "edit";
|
||||||
|
if (isEdit) {
|
||||||
|
console.log(this.Content)
|
||||||
|
updatePolicy(this.Content.id, this.Content).then((res) => {
|
||||||
|
if (res.code >= 200) {
|
||||||
|
this.getList();
|
||||||
|
this.dialogVisible = false;
|
||||||
|
this.$message.success("编辑成功");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
createPolicy(this.Content).then((res) => {
|
||||||
|
if (res.code >= 200) {
|
||||||
|
this.getList();
|
||||||
|
this.dialogVisible = false;
|
||||||
|
this.$message.success("新建成功");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue