提交 e2247469 authored 作者: Yroc's avatar Yroc

'按钮异常修复'

上级 a03a374b
......@@ -75,20 +75,6 @@
width="320"
trigger="hover"
>
<!-- <el-table height="400" :data="examination_questions_select_data">
<el-table-column
align="center"
prop="name"
label="每道题得分选择"
>
</el-table-column>
<el-table-column align="center" label="操作" width="100">
<template slot-scope="scope">
>
</template>
</el-table-column>
</el-table> -->
<el-row>
<el-col :span="16">
<el-input
......
......@@ -241,7 +241,7 @@ export default {
btnClick(val) {
console.log('右侧按钮');
console.log(val);
if (val == 'add') this.addTobaccoInfo();
if (val.val == 'add') this.addTobaccoInfo();
},
init() {
......
......@@ -3,20 +3,38 @@
* @Author: AnthonyD
* @Date: 2023-03-28 10:34:24
* @Last Modified by: AnthonyD
* @Last Modified time: 2023-04-20 15:41:25
* @Last Modified time: 2023-04-21 13:59:01
*/
</script>
<template>
<div class="module_container">
<div class="card_container">
<el-card class="box-card">
<table-head :head_data="head_data" @search="searchEvent" @resetting="resetting" @btnClick="btnClick"></table-head>
<table-head
:head_data="head_data"
@search="searchEvent"
@resetting="resetting"
@btnClick="btnClick"
></table-head>
<div class="table_container">
<el-table v-loading="is_loading" :data="tableData" style="width: 100%;margin-bottom: 20px;" height="650">
<el-table-column prop="id" label="编号" width="50"></el-table-column>
<el-table-column prop="found_user.name" label="题目名称" width="180">
<el-table
v-loading="is_loading"
:data="tableData"
style="width: 100%; margin-bottom: 20px"
height="650"
>
<el-table-column
prop="id"
label="编号"
width="50"
></el-table-column>
<el-table-column
prop="found_user.name"
label="题目名称"
width="180"
>
<template slot-scope="scope">
<!-- <div v-if="(changeReviewContent(scope.row.review_content)).length > 1">
<!-- <div v-if="(changeReviewContent(scope.row.review_content)).length > 1">
<el-popover placement="right" title="多个标题" width="200" trigger="hover">
<div>
<el-tag type="info" v-for="(item, index) in changeReviewContent(scope.row.review_content)"
......@@ -28,46 +46,98 @@
<div v-else-if="(changeReviewContent(scope.row.review_content)).length == 1">{{
(changeReviewContent(scope.row.review_content))[0] }}</div>
<div v-else>暂无...</div> -->
<div v-for="(item, index) in scope.row.examination_questions" :key="index">
<div
v-for="(item, index) in scope.row.examination_questions"
:key="index"
>
{{ item.title }}
</div>
</template>
</el-table-column>
<el-table-column prop="found_user.name" label="创建人" width="90"></el-table-column>
<el-table-column prop="found_remark" label="创建备注"></el-table-column>
<el-table-column prop="auditor_user.name" label="审核人" width="90"></el-table-column>
<el-table-column prop="release_date" label="发布日期"></el-table-column>
<el-table-column prop="created_at" label="创建时间"></el-table-column>
<el-table-column
prop="found_user.name"
label="创建人"
width="90"
></el-table-column>
<el-table-column
prop="found_remark"
label="创建备注"
></el-table-column>
<el-table-column
prop="auditor_user.name"
label="审核人"
width="90"
></el-table-column>
<el-table-column
prop="release_date"
label="发布日期"
></el-table-column>
<el-table-column
prop="created_at"
label="创建时间"
></el-table-column>
<el-table-column prop="remarks" label="备注"></el-table-column>
<el-table-column prop="status" label="状态" width="90">
<template slot-scope="scope">
<el-tag v-if="scope.row.status == 1" type="success">批阅完成</el-tag>
<el-tag v-if="scope.row.status == 2" type="success">审核通过</el-tag>
<el-tag v-if="scope.row.status == 3" type="danger">撤销发布</el-tag>
<el-tag v-if="scope.row.status == 1" type="success"
>批阅完成</el-tag
>
<el-tag v-if="scope.row.status == 2" type="success"
>审核通过</el-tag
>
<el-tag v-if="scope.row.status == 3" type="danger"
>撤销发布</el-tag
>
</template>
</el-table-column>
<el-table-column label="操作" width="120">
<template slot-scope="scope">
<el-button size="mini" type="text" style="color: #000;" @click="toDetail(scope.row)">详情</el-button>
<el-button size="mini" type="text" style="color: #000;"
@click="updateInformation(scope.row)">编辑</el-button>
<el-button size="mini" type="text" style="color: #F56C6C;"
@click="deleteInformation(scope.row)">删除</el-button>
<el-button
size="mini"
type="text"
style="color: #000"
@click="toDetail(scope.row)"
>详情</el-button
>
<el-button
size="mini"
type="text"
style="color: #000"
@click="updateInformation(scope.row)"
>编辑</el-button
>
<el-button
size="mini"
type="text"
style="color: #f56c6c"
@click="deleteInformation(scope.row)"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
</div>
<div style="text-align: right;">
<el-pagination @current-change="handleCurrentChange" :current-page.sync="request_params.page"
:page-size="request_params.limit" layout="total, prev, pager, next" :total="request_params.total">
<div style="text-align: right">
<el-pagination
@current-change="handleCurrentChange"
:current-page.sync="request_params.page"
:page-size="request_params.limit"
layout="total, prev, pager, next"
:total="request_params.total"
>
</el-pagination>
</div>
</el-card>
</div>
<el-dialog :title="is_updata_type == 'add' ? '新增' : '修改'" :visible.sync="is_dialogVisible" width="500px"
:before-close="handleClose" :close-on-click-modal="false">
<el-dialog
:title="is_updata_type == 'add' ? '新增' : '修改'"
:visible.sync="is_dialogVisible"
width="500px"
:before-close="handleClose"
:close-on-click-modal="false"
>
<div>
<el-form label-width="80px">
<el-form-item label="状态">
......@@ -84,7 +154,12 @@
</el-radio-group>
</el-form-item>
<el-form-item label="备注">
<el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="detailed_information.remarks">
<el-input
type="textarea"
:rows="2"
placeholder="请输入内容"
v-model="detailed_information.remarks"
>
</el-input>
</el-form-item>
</el-form>
......@@ -99,13 +174,25 @@
<script>
import TableHead from '@/components/TableHead/index';
import { get_student_list, add_student, delete_student, updat_student, get_student_detail, download_student_info, upload_student_info } from '@/api/student';
import {
get_student_list,
add_student,
delete_student,
updat_student,
get_student_detail,
download_student_info,
upload_student_info,
} from '@/api/student';
import { get_read_over_list, updata_read_over, delete_read_over } from '@/api/student';
import {
get_read_over_list,
updata_read_over,
delete_read_over,
} from '@/api/student';
const standard_template = {
status: null,
remarks: null,
}
};
export default {
data() {
return {
......@@ -113,7 +200,7 @@ export default {
//头部按钮
head_data: {
is_search_show: true,
search_placeholder: "",
search_placeholder: '',
right_buttons: [
// {
// text: '新增',
......@@ -144,7 +231,7 @@ export default {
computed: {},
mounted() {
this.init()
this.init();
},
methods: {
......@@ -157,8 +244,7 @@ export default {
this.getListData();
},
btnClick(val) {
if (val == 'add') this.addInformation();
if (val.val == 'add') this.addInformation();
},
init() {
......@@ -174,34 +260,33 @@ export default {
console.log('提交');
//updata_read_over
if (this.is_updata_type == 'add') {
} else {
let id = this.detailed_information.id;
let data = this.$removeProperty({
status: this.detailed_information.status,
remarks: this.detailed_information.remarks,
});
updata_read_over(id, data).then(res => {
updata_read_over(id, data).then((res) => {
console.log('修改');
console.log(res);
if (res.code == 200) {
this.is_dialogVisible = false;
this.init();
}
})
});
}
},
//获取列表数据
getListData() {
let params = this.$removeProperty(this.request_params);
this.is_loading = true;
get_read_over_list(params).then(res => {
get_read_over_list(params).then((res) => {
console.log('列表数据');
console.log(res);
this.tableData = res.data || [];
this.request_params.total = res.total;
this.is_loading = false;
})
});
},
//分页
handleCurrentChange(val) {
......@@ -228,20 +313,22 @@ export default {
this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
delete_read_over(id).then(res => {
if (res.code == 200) {
this.$message.success(res.message);
this.init();
}
type: 'warning',
})
.then(() => {
delete_read_over(id).then((res) => {
if (res.code == 200) {
this.$message.success(res.message);
this.init();
}
});
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
.catch(() => {
this.$message({
type: 'info',
message: '已取消删除',
});
});
});
},
//跳转详情
......@@ -249,8 +336,8 @@ export default {
let id = item.id;
this.$router.push({
path: '/student/display_board_detail',
query: { id: id }
})
query: { id: id },
});
},
//试题列表
......@@ -263,9 +350,7 @@ export default {
return [];
}
},
},
}
};
</script>
<style lang="scss" scoped></style>
......@@ -3,7 +3,7 @@
* @Author: AnthonyD
* @Date: 2023-03-28 10:34:24
* @Last Modified by: AnthonyD
* @Last Modified time: 2023-04-20 15:34:11
* @Last Modified time: 2023-04-21 13:49:45
*/
</script>
<template>
......@@ -305,11 +305,12 @@ export default {
btnClick(val) {
// console.log('右侧按钮');
// console.log(val);
if (val == 'add') this.addInformation();
if (val.val == 'add') this.addInformation();
if (val.val == 'template_download') this.templateDownload(val.data);
/* pictureBatchUpload */
if (val == 'batch_upload') this.pictureBatchUpload();
if (val == 'examination_download') this.createAnswerCard();
if (val.val == 'batch_upload') this.pictureBatchUpload();
if (val.val == 'examination_download') this.createAnswerCard();
if (val.val == 'select_score') this.selectScoreData(val.data);
},
......@@ -553,10 +554,11 @@ export default {
},
//试题下载
createAnswerCard() {
console.log('11111');
let id = this.examination_questions_id;
create_answer_card(id).then((res) => {
// console.log('下载答题卡回调');
// console.log(res);
console.log('下载答题卡回调');
console.log(res);
if (res.code == 200) {
let s = res.message.split('=');
let name = s[s.length - 1];
......@@ -567,7 +569,9 @@ export default {
},
//得分选择
selectScoreData(val) {
console.log(val);
let amendData = this.$handleParams({ fraction: val });
let id = this.examination_questions_id;
console.log(amendData);
console.log(id);
......
<script>
/**
* @Author: AnthonyD
* @Date: 2023-03-28 10:34:24
* @Last Modified by: AnthonyD
* @Last Modified time: 2023-04-21 13:45:13
*/
</script>
<template>
<div class="module_container">
<div class="card_container">
......@@ -282,8 +289,8 @@ export default {
btnClick(val) {
console.log('右侧按钮');
console.log(val);
if (val == 'add') this.addInformation();
if (val == 'download') this.downloadFormwork();
if (val.val == 'add') this.addInformation();
if (val.val == 'download') this.downloadFormwork();
},
init() {
......
......@@ -9,15 +9,34 @@
<div class="module_container">
<div class="card_container">
<el-card class="box-card">
<table-head :head_data="head_data" @search="searchEvent" @resetting="resetting" @btnClick="btnClick"></table-head>
<table-head
:head_data="head_data"
@search="searchEvent"
@resetting="resetting"
@btnClick="btnClick"
></table-head>
<div class="table_container">
<el-table v-loading="is_loading" :data="tableData" style="width: 100%;margin-bottom: 20px;" height="650">
<el-table
v-loading="is_loading"
:data="tableData"
style="width: 100%; margin-bottom: 20px"
height="650"
>
<el-table-column prop="id" label="编号" width="50">
</el-table-column>
<el-table-column prop="examination_questions_title" label="考试标题">
<el-table-column
prop="examination_questions_title"
label="考试标题"
>
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-document" style="color: #005FC2;"
@click="toDetail(scope.row)">{{ scope.row.examination_questions_title }}</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-document"
style="color: #005fc2"
@click="toDetail(scope.row)"
>{{ scope.row.examination_questions_title }}</el-button
>
</template>
</el-table-column>
<el-table-column prop="name" label="学员姓名">
......@@ -27,48 +46,81 @@
</el-table-column>
<el-table-column prop="begin_answer_time" label="开始时间">
</el-table-column>
<el-table-column prop="answer_duration" label="答题时间" width="100">
<el-table-column
prop="answer_duration"
label="答题时间"
width="100"
>
<template slot-scope="scope">
<div v-if="scope.row.answer_duration">{{ seconds_to_minutes(scope.row.answer_duration) }}</div>
<div v-if="scope.row.answer_duration">
{{ seconds_to_minutes(scope.row.answer_duration) }}
</div>
<div v-else>暂无</div>
</template>
</el-table-column>
<el-table-column prop="score" label="得分">
</el-table-column>
<el-table-column prop="score" label="得分"> </el-table-column>
<el-table-column prop="created_at" label="创建时间">
</el-table-column>
<el-table-column prop="path" label="状态">
<template slot-scope="scope">
<div>
<el-tag v-if="scope.row.status == 1" type="success">预约完成</el-tag>
<el-tag v-if="scope.row.status == 2" type="success"
style="background-color: #b4d7c6;border-color: #71b7a0;color: #038D6E;">考试完成</el-tag>
<el-tag v-if="scope.row.status == 3" type="success">已发布</el-tag>
<el-tag v-if="scope.row.status == 1" type="success"
>预约完成</el-tag
>
<el-tag
v-if="scope.row.status == 2"
type="success"
style="
background-color: #b4d7c6;
border-color: #71b7a0;
color: #038d6e;
"
>考试完成</el-tag
>
<el-tag v-if="scope.row.status == 3" type="success"
>已发布</el-tag
>
<el-tag v-if="scope.row.status == 4" type="info">取消</el-tag>
<el-tag v-if="scope.row.status == 6" type="danger">失效</el-tag>
<el-tag v-if="scope.row.status == 6" type="danger"
>失效</el-tag
>
</div>
</template>
</el-table-column>
<el-table-column label="操作" width="120">
<template slot-scope="scope">
<el-button size="mini" type="text" style="color: #F56C6C;" @click="cancelReservation(scope.row)"
v-if="scope.row.status == 1">取消预约</el-button>
<el-button
size="mini"
type="text"
style="color: #f56c6c"
@click="cancelReservation(scope.row)"
v-if="scope.row.status == 1"
>取消预约</el-button
>
</template>
</el-table-column>
</el-table>
</div>
<div style="text-align: right;">
<el-pagination @current-change="handleCurrentChange" :current-page.sync="request_params.page"
:page-size="request_params.limit" layout="total, prev, pager, next" :total="request_params.total">
<div style="text-align: right">
<el-pagination
@current-change="handleCurrentChange"
:current-page.sync="request_params.page"
:page-size="request_params.limit"
layout="total, prev, pager, next"
:total="request_params.total"
>
</el-pagination>
</div>
</el-card>
</div>
<el-dialog title="提示" :visible.sync="is_dialogVisible" width="60%" :before-close="handleClose">
<div>
</div>
<el-dialog
title="提示"
:visible.sync="is_dialogVisible"
width="60%"
:before-close="handleClose"
>
<div></div>
<span slot="footer" class="dialog-footer">
<el-button @click="handleClose">取 消</el-button>
<el-button type="primary" @click="submitData">确 定</el-button>
......@@ -83,17 +135,17 @@ import { get_test_results_list, cancel_reservation } from '@/api/student';
import { secondsToMinutes } from '@/utils/tool';
const standard_template = {
id: null,
father_id: -1,//父级id
is_show: false,//是否展示为菜单
name: null,//英文名称
name_zh: null,//中文名称
path: null,//路由路径
sort: null,//排序
status: 1,//状态
type: 1,//类型:菜单/按钮
view_path: null,//视图路径
icon: null,//图标
}
father_id: -1, //父级id
is_show: false, //是否展示为菜单
name: null, //英文名称
name_zh: null, //中文名称
path: null, //路由路径
sort: null, //排序
status: 1, //状态
type: 1, //类型:菜单/按钮
view_path: null, //视图路径
icon: null, //图标
};
export default {
data() {
return {
......@@ -101,7 +153,7 @@ export default {
//头部按钮
head_data: {
is_search_show: true,
search_placeholder: "学员姓名/手机号",
search_placeholder: '学员姓名/手机号',
right_buttons: [
// {
// text: '新增',
......@@ -129,12 +181,10 @@ export default {
components: { TableHead },
computed: {
},
computed: {},
mounted() {
this.init()
this.init();
},
methods: {
......@@ -153,8 +203,7 @@ export default {
btnClick(val) {
console.log('右侧按钮');
console.log(val);
if (val == 'add') this.addInformation();
if (val.val == 'add') this.addInformation();
},
init() {
......@@ -166,20 +215,18 @@ export default {
this.is_dialogVisible = false;
},
//提交
submitData() {
},
submitData() {},
//获取列表数据
getListData() {
let params = this.$removeProperty(this.request_params);
this.is_loading = true;
get_test_results_list(params).then(res => {
get_test_results_list(params).then((res) => {
console.log('列表数据');
console.log(res);
this.tableData = res.data || [];
this.request_params.total = res.total;
this.is_loading = false;
})
});
},
//分页
handleCurrentChange(val) {
......@@ -206,24 +253,25 @@ export default {
this.$confirm('确认取消?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let id = item.id;
cancel_reservation(id).then(res => {
console.log('取消预约');
console.log(res);
if (res.code == 200) {
this.$message.success(res.message);
this.getListData();
}
type: 'warning',
})
.then(() => {
let id = item.id;
cancel_reservation(id).then((res) => {
console.log('取消预约');
console.log(res);
if (res.code == 200) {
this.$message.success(res.message);
this.getListData();
}
});
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消'
.catch(() => {
this.$message({
type: 'info',
message: '已取消',
});
});
});
},
//跳转详情
toDetail(item) {
......@@ -232,9 +280,9 @@ export default {
this.$router.push({
path: '/student/test_results_detail',
query: {
id: id
id: id,
},
})
});
},
//秒转分
......@@ -242,11 +290,10 @@ export default {
if (num) {
return secondsToMinutes(num);
} else {
return '暂无'
return '暂无';
}
}
},
},
}
};
</script>
<style lang="scss" scoped></style>
<script>
/**
* @Author: AnthonyD
* @Date: 2023-03-28 10:34:24
* @Last Modified by: AnthonyD
* @Last Modified time: 2023-04-21 13:58:02
*/
</script>
<template>
<div class="module_container">
<div class="card_container">
......@@ -164,7 +171,7 @@ export default {
btnClick(val) {
console.log('右侧按钮');
console.log(val);
if (val == 'add') this.addTobaccoGrades();
if (val.val == 'add') this.addTobaccoGrades();
},
init() {
......
......@@ -9,21 +9,33 @@
<div>
<div class="card_container">
<el-card class="box-card">
<table-head :head_data="head_data" @search="searchEvent" @resetting="resetting" @btnClick="btnClick"></table-head>
<table-head
:head_data="head_data"
@search="searchEvent"
@resetting="resetting"
@btnClick="btnClick"
></table-head>
<div class="table_container">
<el-table v-loading="is_loading" :data="tableData" style="width: 100%;margin-bottom: 20px;" height="650" border
row-key="id" default-expand-all :tree-props="{ children: 'children', hasChildren: '' }">
<el-table
v-loading="is_loading"
:data="tableData"
style="width: 100%; margin-bottom: 20px"
height="650"
border
row-key="id"
default-expand-all
:tree-props="{ children: 'children', hasChildren: '' }"
>
<el-table-column prop="department_name" label="部门名称">
</el-table-column>
<el-table-column prop="leader" label="部门领导">
</el-table-column>
<el-table-column prop="phone" label="电话">
</el-table-column>
<el-table-column prop="email" label="邮箱">
</el-table-column>
<el-table-column prop="leader" label="部门领导"> </el-table-column>
<el-table-column prop="phone" label="电话"> </el-table-column>
<el-table-column prop="email" label="邮箱"> </el-table-column>
<el-table-column prop="status" label="状态" width="80">
<template slot-scope="scope">
<el-tag v-if="scope.row.status == 1" type="success">正常</el-tag>
<el-tag v-if="scope.row.status == 1" type="success"
>正常</el-tag
>
<el-tag v-if="scope.row.status == 2" type="info">失效</el-tag>
</template>
</el-table-column>
......@@ -31,10 +43,27 @@
</el-table-column>
<el-table-column label="操作" width="120">
<template slot-scope="scope">
<el-button size="mini" type="text" style="color: #000;" @click="addDepartment(scope.row)">新增</el-button>
<el-button size="mini" type="text" style="color: #000;" @click="editDepartment(scope.row)">编辑</el-button>
<el-button size="mini" type="text" style="color: #F56C6C;"
@click="deleteDepartment(scope.row)">删除</el-button>
<el-button
size="mini"
type="text"
style="color: #000"
@click="addDepartment(scope.row)"
>新增</el-button
>
<el-button
size="mini"
type="text"
style="color: #000"
@click="editDepartment(scope.row)"
>编辑</el-button
>
<el-button
size="mini"
type="text"
style="color: #f56c6c"
@click="deleteDepartment(scope.row)"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
......@@ -42,45 +71,72 @@
</el-card>
</div>
<el-dialog title="提示" :visible.sync="is_dialogVisible" width="60%" :before-close="handleClose">
<el-dialog
title="提示"
:visible.sync="is_dialogVisible"
width="60%"
:before-close="handleClose"
>
<div>
<el-form label-width="150px">
<el-row>
<el-col :span="12">
<el-form-item label="上级部门">
<treeselect v-model="department_info.department_id" :options="tree_select_list" :normalizer="normalizer"
:show-count="true" placeholder="选择上级菜单" />
<treeselect
v-model="department_info.department_id"
:options="tree_select_list"
:normalizer="normalizer"
:show-count="true"
placeholder="选择上级菜单"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="部门名称">
<el-input placeholder="请输入部门名称" v-model="department_info.department_name" />
<el-input
placeholder="请输入部门名称"
v-model="department_info.department_name"
/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="部门邮箱">
<el-input placeholder="请输入邮箱" v-model="department_info.email" />
<el-input
placeholder="请输入邮箱"
v-model="department_info.email"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="联系电话">
<el-input placeholder="请输入电话" v-model="department_info.phone" />
<el-input
placeholder="请输入电话"
v-model="department_info.phone"
/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item label="领导姓名">
<el-input placeholder="请输入邮箱" v-model="department_info.leader" />
<el-input
placeholder="请输入邮箱"
v-model="department_info.leader"
/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="排序">
<el-input-number controls-position="right" :min="1" v-model="department_info.sort" style="width: 100%;" />
<el-input-number
controls-position="right"
:min="1"
v-model="department_info.sort"
style="width: 100%"
/>
</el-form-item>
</el-col>
<el-col :span="12">
......@@ -93,7 +149,6 @@
</el-col>
</el-row>
</el-form>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="handleClose">取 消</el-button>
......@@ -105,10 +160,15 @@
<script>
import TableHead from '@/components/TableHead/index';
import { get_department_list, add_department, delete_department, edit_department } from '@/api/system';
import {
get_department_list,
add_department,
delete_department,
edit_department,
} from '@/api/system';
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import Treeselect from '@riophae/vue-treeselect';
import '@riophae/vue-treeselect/dist/vue-treeselect.css';
const standard_template = {
department_id: -1,
department_name: null,
......@@ -117,7 +177,7 @@ const standard_template = {
leader: null,
sort: 0,
status: 1,
}
};
export default {
data() {
return {
......@@ -130,12 +190,12 @@ export default {
text: '新增',
icon: 'el-icon-plus',
event: 'add',
}
},
],
},
//初始化请求参数
request_params: {
val: '',//搜索
val: '', //搜索
page: 1,
limit: 10,
total: 1,
......@@ -157,7 +217,7 @@ export default {
computed: {},
mounted() {
this.init()
this.init();
},
methods: {
......@@ -176,7 +236,7 @@ export default {
btnClick(val) {
console.log('右侧按钮');
console.log(val);
if (val == 'add') {
if (val.val == 'add') {
this.addDepartment(null);
}
},
......@@ -191,17 +251,20 @@ export default {
//提交
submitData() {
let data = {
department_id: this.department_info.department_id == -1 ? null : this.department_info.department_id,
department_id:
this.department_info.department_id == -1
? null
: this.department_info.department_id,
department_name: this.department_info.department_name,
email: this.department_info.email,
phone: this.department_info.phone,
leader: this.department_info.leader,
sort: this.department_info.sort,
status: this.department_info.status,
}
};
let params = this.$handleParams(data);
if (this.is_updata_type == 'add') {
add_department(params).then(res => {
add_department(params).then((res) => {
console.log('新增部门');
console.log(res);
if (res.code == 200) {
......@@ -209,17 +272,17 @@ export default {
this.is_dialogVisible = false;
this.init();
}
})
});
} else {
let id = this.department_info.id;
edit_department(id, params).then(res => {
edit_department(id, params).then((res) => {
console.log('修改回调');
if (res.code == 200) {
this.$message.success(res.message);
this.is_dialogVisible = false;
this.init();
}
})
});
}
},
......@@ -230,7 +293,7 @@ export default {
console.log(params);
this.is_loading = true;
this.tree_select_list = [];
get_department_list(params).then(res => {
get_department_list(params).then((res) => {
console.log('部门列表');
console.log(res);
this.tableData = res || [];
......@@ -238,15 +301,18 @@ export default {
menu.children = res;
this.tree_select_list.push(menu);
this.is_loading = false;
})
});
},
/** 转换菜单数据结构 */
normalizer(node) {
if (node.children && !node.children.length) delete node.children;
return { id: node.id, label: node.department_name, children: node.children };
return {
id: node.id,
label: node.department_name,
children: node.children,
};
},
//新增
addDepartment(item) {
this.is_updata_type = 'add';
......@@ -270,24 +336,24 @@ export default {
this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
delete_department(id).then(res => {
if (res.code == 200) {
this.$message.success(res.message);
this.init();
}
type: 'warning',
})
.then(() => {
delete_department(id).then((res) => {
if (res.code == 200) {
this.$message.success(res.message);
this.init();
}
});
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
.catch(() => {
this.$message({
type: 'info',
message: '已取消删除',
});
});
});
}
},
},
}
};
</script>
<style lang="scss" scoped></style>
......@@ -9,33 +9,63 @@
<div>
<div class="card_container">
<el-card class="box-card">
<table-head :head_data="head_data" @search="searchEvent" @resetting="resetting" @btnClick="btnClick"></table-head>
<table-head
:head_data="head_data"
@search="searchEvent"
@resetting="resetting"
@btnClick="btnClick"
></table-head>
<div class="table_container">
<el-table v-loading="is_loading" :data="tableData" style="width: 100%;margin-bottom: 20px;" height="650">
<el-table-column prop="id" label="角色ID">
</el-table-column>
<el-table-column prop="name" label="角色名称">
</el-table-column>
<el-table
v-loading="is_loading"
:data="tableData"
style="width: 100%; margin-bottom: 20px"
height="650"
>
<el-table-column prop="id" label="角色ID"> </el-table-column>
<el-table-column prop="name" label="角色名称"> </el-table-column>
<el-table-column prop="created_at" label="创建时间">
</el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<el-button size="mini" type="text" style="color: #000;" @click="editRoles(scope.row)">编辑</el-button>
<el-button size="mini" type="text" style="color: #F56C6C;" @click="deleteRoles(scope.row)">删除</el-button>
<el-button
size="mini"
type="text"
style="color: #000"
@click="editRoles(scope.row)"
>编辑</el-button
>
<el-button
size="mini"
type="text"
style="color: #f56c6c"
@click="deleteRoles(scope.row)"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
</div>
<div style="text-align: right;">
<el-pagination @current-change="handleCurrentChange" :current-page.sync="request_params.page"
:page-size="request_params.limit" layout="total, prev, pager, next" :total="request_params.total">
<div style="text-align: right">
<el-pagination
@current-change="handleCurrentChange"
:current-page.sync="request_params.page"
:page-size="request_params.limit"
layout="total, prev, pager, next"
:total="request_params.total"
>
</el-pagination>
</div>
</el-card>
</div>
<el-dialog title="提示" :visible.sync="is_dialogVisible" width="600" :before-close="handleClose">
<div style="overflow-y: auto;height: 600px;">
<el-dialog
title="提示"
:visible.sync="is_dialogVisible"
width="600"
:before-close="handleClose"
>
<div style="overflow-y: auto; height: 600px">
<el-form label-width="100px">
<el-form-item label="角色ID" v-if="roles_info.id">
<el-input v-model="roles_info.id" disabled></el-input>
......@@ -46,16 +76,28 @@
<el-row>
<el-col :span="12">
<el-form-item label="授权菜单">
<el-tree ref="routeTree" :data="router_tree" show-checkbox node-key="id"
:default-checked-keys="roles_info.permission" :props="defaultProps"
:key="new Date().getTime()"></el-tree>
<el-tree
ref="routeTree"
:data="router_tree"
show-checkbox
node-key="id"
:default-checked-keys="roles_info.permission"
:props="defaultProps"
:key="new Date().getTime()"
></el-tree>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="授权功能">
<el-tree ref="buttonTree" :data="button_tree" show-checkbox node-key="id"
:default-checked-keys="roles_info.permissionButton" :props="defaultProps"
:key="new Date().getTime()"></el-tree>
<el-tree
ref="buttonTree"
:data="button_tree"
show-checkbox
node-key="id"
:default-checked-keys="roles_info.permissionButton"
:props="defaultProps"
:key="new Date().getTime()"
></el-tree>
</el-form-item>
</el-col>
</el-row>
......@@ -71,7 +113,13 @@
<script>
import TableHead from '@/components/TableHead/index';
import { get_permission_list, add_roles, delete_roles, edit_roles, get_permission_detail } from '@/api/role';
import {
get_permission_list,
add_roles,
delete_roles,
edit_roles,
get_permission_detail,
} from '@/api/role';
import { get_permission_btn_menu } from '@/api/system';
import { button_tree_add, route_tree_all } from '@/utils/route-handle';
const standard_template = {
......@@ -79,7 +127,7 @@ const standard_template = {
name: '',
permission: [],
permissionButton: [],
}
};
export default {
data() {
return {
......@@ -92,12 +140,12 @@ export default {
text: '新增',
icon: 'el-icon-user-solid',
event: 'add',
}
},
],
},
//初始化请求参数
request_params: {
val: '',//搜索
val: '', //搜索
page: 1,
limit: 10,
total: 1,
......@@ -115,8 +163,8 @@ export default {
button_tree: [],
defaultProps: {
children: 'children',
label: 'name_zh'
}
label: 'name_zh',
},
};
},
......@@ -125,7 +173,7 @@ export default {
computed: {},
mounted() {
this.init()
this.init();
},
methods: {
......@@ -144,7 +192,7 @@ export default {
btnClick(val) {
console.log('右侧按钮');
console.log(val);
if (val == 'add') this.addRoles();
if (val.val == 'add') this.addRoles();
},
init() {
this.getPermissionBtnMenu();
......@@ -160,28 +208,36 @@ export default {
console.log(this.roles_info);
let router_key = this.$refs.routeTree.getCheckedNodes(false, true);
let button_key = this.$refs.buttonTree.getCheckedNodes(false, true);
let route_ids = router_key.map(item => { return item.id });
let button_ids = button_key.map(item => { return item.id });
let route_ids = router_key.map((item) => {
return item.id;
});
let button_ids = button_key.map((item) => {
return item.id;
});
let data = this.$handleParams({
name: this.roles_info.name,
permission: router_key.map(item => { return item.id }),
permissionButton: button_key.map(item => { return item.id })
})
permission: router_key.map((item) => {
return item.id;
}),
permissionButton: button_key.map((item) => {
return item.id;
}),
});
console.log('要提交的数据');
console.log(data);
if (this.is_updata_type == 'add') {
add_roles(data).then(res => {
console.log("新增角色回调");
add_roles(data).then((res) => {
console.log('新增角色回调');
console.log(res);
if (res.code == 200) {
this.$message.success(res.message);
this.is_dialogVisible = false;
this.getPermissionList();
}
})
});
} else {
let id = this.roles_info.id;
edit_roles(id, data).then(res => {
edit_roles(id, data).then((res) => {
console.log('修改角色回调');
console.log(res);
if (res.code == 200) {
......@@ -189,9 +245,8 @@ export default {
this.is_dialogVisible = false;
this.getPermissionList();
}
})
});
}
},
//分页
handleCurrentChange(val) {
......@@ -200,7 +255,7 @@ export default {
},
//获取 全部 按钮/路由分类数据
getPermissionBtnMenu() {
get_permission_btn_menu().then(res => {
get_permission_btn_menu().then((res) => {
console.log('获取全部路由按钮数据');
console.log(res);
let permission = JSON.parse(JSON.stringify(res.permission)),
......@@ -208,11 +263,10 @@ export default {
this.router_tree = route_tree_all(permission);
this.button_tree = button_tree_add(permissionButton, permission);
console.log('结构数据@@@@@@@@@@@@@@@@@@@@@');
console.log(this.router_tree);
console.log(this.button_tree);
})
});
},
//获取角色列表
......@@ -223,13 +277,13 @@ export default {
limit: this.request_params.limit,
});
this.is_loading = true;
get_permission_list(params).then(res => {
get_permission_list(params).then((res) => {
console.log('角色列表');
console.log(res);
this.tableData = res.data || [];
this.request_params.total = res.total;
this.is_loading = false;
})
});
},
//新增
addRoles() {
......@@ -241,9 +295,9 @@ export default {
editRoles(item) {
this.is_updata_type = 'edit';
//序号获取详情
get_permission_detail(item.id).then(res => {
get_permission_detail(item.id).then((res) => {
this.roles_info = res;
})
});
this.is_dialogVisible = true;
},
//删除
......@@ -252,23 +306,24 @@ export default {
this.$confirm('此操作将永久删除该角色, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
delete_roles(id).then(res => {
if (res.code == 200) {
this.$message.success(res.message);
this.getPermissionList();
}
type: 'warning',
})
.then(() => {
delete_roles(id).then((res) => {
if (res.code == 200) {
this.$message.success(res.message);
this.getPermissionList();
}
});
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
.catch(() => {
this.$message({
type: 'info',
message: '已取消删除',
});
});
});
},
},
}
};
</script>
<style lang="scss" scoped></style>
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论