|
@@ -0,0 +1,134 @@
|
|
|
+<template>
|
|
|
+ <div id="level">
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="24" class="style">
|
|
|
+ <el-col :span="24" class="top"><el-button type="primary" size="mini" @click="add">添加</el-button></el-col>
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-table :data="tableData" border style="width: 100%">
|
|
|
+ <el-table-column prop="dept_name" label="部门名称" align="center"> </el-table-column>
|
|
|
+ <el-table-column prop="name" label="职务名称" align="center"> </el-table-column>
|
|
|
+ <el-table-column label="操作" align="center">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-button size="mini" @click="view(scope.row.id)">查看</el-button>
|
|
|
+ <el-button type="danger" size="mini" @click="del(scope.row.id)">删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ <page :total="total" position="right" @query="search"></page>
|
|
|
+ </el-col>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-dialog title="职务信息" :visible.sync="dialog" center>
|
|
|
+ <el-form :model="form" label-width="80px">
|
|
|
+ <el-form-item label="部门名称">
|
|
|
+ <el-select v-model="form.dept_id" filterable placeholder="请选择部门">
|
|
|
+ <el-option v-for="(item, index) in deptList" :key="index" :label="item.name" :value="item._id"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="职务名称">
|
|
|
+ <el-input v-model="form.name" autocomplete="off"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button type="primary" @click="onSubmit">确 定</el-button>
|
|
|
+ <el-button @click="dialog = false">取 消</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import page from '@/components/pagination.vue';
|
|
|
+import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
+const { mapActions: department } = createNamespacedHelpers('department');
|
|
|
+const { mapActions: level } = createNamespacedHelpers('level');
|
|
|
+export default {
|
|
|
+ name: 'level',
|
|
|
+ props: {},
|
|
|
+ components: { page },
|
|
|
+ data: () => ({
|
|
|
+ tableData: [],
|
|
|
+ form: {},
|
|
|
+ total: 0,
|
|
|
+ dialog: false,
|
|
|
+ deptList: [],
|
|
|
+ }),
|
|
|
+ created() {
|
|
|
+ this.search();
|
|
|
+ },
|
|
|
+ computed: {},
|
|
|
+ methods: {
|
|
|
+ ...department({ departmentQuery: 'query', departmentFetch: 'fetch' }),
|
|
|
+ ...level(['create', 'update', 'query', 'fetch', 'delete']),
|
|
|
+ async search({ skip = 0, limit = 10, ...info } = {}) {
|
|
|
+ const res = await this.query({ skip, limit, ...info });
|
|
|
+ console.log(res);
|
|
|
+
|
|
|
+ this.$set(this, `tableData`, res.data);
|
|
|
+ this.$set(this, `total`, res.total);
|
|
|
+ },
|
|
|
+ // 部门
|
|
|
+ async searchInfo() {
|
|
|
+ let res = await this.departmentQuery();
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$set(this, `deptList`, res.data);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async view(id) {
|
|
|
+ this.dialog = true;
|
|
|
+ const res = await this.fetch(id);
|
|
|
+ this.$set(this, `form`, res.data);
|
|
|
+ this.searchInfo();
|
|
|
+ },
|
|
|
+ async add() {
|
|
|
+ this.dialog = true;
|
|
|
+ this.form = {};
|
|
|
+ this.searchInfo();
|
|
|
+ },
|
|
|
+ async del(id) {
|
|
|
+ const res = await this.delete(id);
|
|
|
+ if (res.errcode === 0) {
|
|
|
+ this.$message({
|
|
|
+ message: '信息删除成功',
|
|
|
+ type: 'success',
|
|
|
+ });
|
|
|
+ this.search();
|
|
|
+ } else {
|
|
|
+ this.$message.error('信息删除失败');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async onSubmit() {
|
|
|
+ this.dialog = false;
|
|
|
+ let res = {};
|
|
|
+ let data = JSON.parse(JSON.stringify(this.form));
|
|
|
+ if (data.id) {
|
|
|
+ res = await this.update(data);
|
|
|
+ } else {
|
|
|
+ res = await this.create(data);
|
|
|
+ }
|
|
|
+ if (res.errcode === 0) {
|
|
|
+ this.$message({
|
|
|
+ message: '信息创建成功',
|
|
|
+ type: 'success',
|
|
|
+ });
|
|
|
+ this.display = true;
|
|
|
+ this.search();
|
|
|
+ } else {
|
|
|
+ this.$message.error('信息创建失败');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped>
|
|
|
+.style {
|
|
|
+ width: 95%;
|
|
|
+ margin: 0 auto;
|
|
|
+ float: none;
|
|
|
+}
|
|
|
+.top {
|
|
|
+ text-align: right;
|
|
|
+ padding: 0 0 10px 0;
|
|
|
+}
|
|
|
+</style>
|