|
@@ -0,0 +1,183 @@
|
|
|
|
|
+<template>
|
|
|
|
|
+ <div class="ele-body">
|
|
|
|
|
+ <el-card shadow="never">
|
|
|
|
|
+ <!-- 搜索表单 -->
|
|
|
|
|
+ <el-form :model="table.where" label-width="90px" class="ele-form-search"
|
|
|
|
|
+ @keyup.enter.native="$refs.table.reload()" @submit.native.prevent>
|
|
|
|
|
+ <el-row :gutter="15">
|
|
|
|
|
+ <el-col :md="8" :sm="12">
|
|
|
|
|
+ <el-form-item label="关键词:">
|
|
|
|
|
+ <el-input v-model="table.where.keyword" placeholder="请输入分类名称" clearable />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </el-col>
|
|
|
|
|
+ <el-col :md="6" :sm="12">
|
|
|
|
|
+ <el-form-item label="状态:">
|
|
|
|
|
+ <el-select v-model="table.where.status" placeholder="请选择" class="ele-fluid">
|
|
|
|
|
+ <el-option label="全部" :value="0" />
|
|
|
|
|
+ <el-option label="有效" :value="1" />
|
|
|
|
|
+ <el-option label="无效" :value="2" />
|
|
|
|
|
+ </el-select>
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </el-col>
|
|
|
|
|
+ <el-col :md="6" :sm="12">
|
|
|
|
|
+ <div class="ele-form-actions">
|
|
|
|
|
+ <el-button type="primary" @click="$refs.table.reload()" icon="el-icon-search"
|
|
|
|
|
+ class="ele-btn-icon">查询</el-button>
|
|
|
|
|
+ <el-button @click="handleReset()">重置</el-button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </el-col>
|
|
|
|
|
+ </el-row>
|
|
|
|
|
+ </el-form>
|
|
|
|
|
+ <!-- 操作按钮 -->
|
|
|
|
|
+ <div class="ele-table-tool ele-table-tool-default">
|
|
|
|
|
+ <el-button @click="add()" type="primary" icon="el-icon-plus" class="ele-btn-icon" size="small"
|
|
|
|
|
+ v-if="permission.includes('sys:jobsCategory:add')">添加分类</el-button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <!-- 数据表格 -->
|
|
|
|
|
+ <ele-data-table ref="table" :config="table" :choose.sync="choose" height="calc(100vh - 315px)"
|
|
|
|
|
+ highlight-current-row>
|
|
|
|
|
+ <template>
|
|
|
|
|
+ <el-table-column type="selection" width="45" align="center" fixed="left" />
|
|
|
|
|
+ <el-table-column prop="id" label="ID" width="60" align="center" fixed="left" show-overflow-tooltip />
|
|
|
|
|
+ <el-table-column prop="name" label="分类名称" show-overflow-tooltip min-width="200" />
|
|
|
|
|
+ <el-table-column prop="sort" label="排序" width="100" align="center" />
|
|
|
|
|
+ <el-table-column prop="create_time" label="添加时间" show-overflow-tooltip min-width="160" align="center" />
|
|
|
|
|
+ <el-table-column prop="status" label="状态" :resizable="false" min-width="120">
|
|
|
|
|
+ <template slot-scope="{row}">
|
|
|
|
|
+ <el-switch v-model="row.status" @change="editStatus(row)" :active-value="1" :inactive-value="2" />
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-table-column>
|
|
|
|
|
+ <el-table-column label="操作" width="180px" align="center" :resizable="false" fixed="right">
|
|
|
|
|
+ <template slot-scope="{row}">
|
|
|
|
|
+ <el-link @click="edit(row)" icon="el-icon-edit" type="primary" :underline="false"
|
|
|
|
|
+ v-if="permission.includes('sys:jobsCategory:edit')">修改</el-link>
|
|
|
|
|
+ <el-popconfirm title="确定要删除此分类吗?删除后不可恢复!" @confirm="remove(row)" class="ele-action">
|
|
|
|
|
+ <el-link slot="reference" icon="el-icon-delete" type="danger" :underline="false"
|
|
|
|
|
+ v-if="permission.includes('sys:jobsCategory:delete')">删除</el-link>
|
|
|
|
|
+ </el-popconfirm>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-table-column>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </ele-data-table>
|
|
|
|
|
+ </el-card>
|
|
|
|
|
+ <!-- 编辑弹窗 -->
|
|
|
|
|
+ <el-dialog :title="editForm.id ? '修改分类' : '添加分类'" :visible.sync="showEdit" width="600px" @closed="resetEditForm()"
|
|
|
|
|
+ :destroy-on-close="true" custom-class="ele-dialog-form" :lock-scroll="false" :close-on-click-modal="false">
|
|
|
|
|
+ <el-form :model="editForm" ref="editForm" :rules="editRules" label-width="100px">
|
|
|
|
|
+ <el-form-item label="分类名称:" prop="name">
|
|
|
|
|
+ <el-input v-model="editForm.name" placeholder="请输入分类名称" clearable />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <el-form-item label="排序:" prop="sort">
|
|
|
|
|
+ <el-input-number v-model="editForm.sort" :min="0" :max="9999" controls-position="right" class="ele-fluid" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <el-form-item label="备注:">
|
|
|
|
|
+ <el-input v-model="editForm.remark" type="textarea" :rows="3" placeholder="请输入备注信息" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <el-form-item label="状态:">
|
|
|
|
|
+ <el-radio-group v-model="editForm.status">
|
|
|
|
|
+ <el-radio :label="1">有效</el-radio>
|
|
|
|
|
+ <el-radio :label="2">无效</el-radio>
|
|
|
|
|
+ </el-radio-group>
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </el-form>
|
|
|
|
|
+ <div slot="footer">
|
|
|
|
|
+ <el-button @click="showEdit = false">取消</el-button>
|
|
|
|
|
+ <el-button type="primary" @click="save">保存</el-button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </el-dialog>
|
|
|
|
|
+ </div>
|
|
|
|
|
+</template>
|
|
|
|
|
+
|
|
|
|
|
+<script>
|
|
|
|
|
+import { mapGetters } from "vuex";
|
|
|
|
|
+export default {
|
|
|
|
|
+ name: "JobsCategory",
|
|
|
|
|
+ data() {
|
|
|
|
|
+ return {
|
|
|
|
|
+ table: { url: '/jobsCategory/index', where: { status: 0 } },
|
|
|
|
|
+ choose: [],
|
|
|
|
|
+ showEdit: false,
|
|
|
|
|
+ editForm: { status: 1, sort: 0 },
|
|
|
|
|
+ editRules: {
|
|
|
|
|
+ name: [
|
|
|
|
|
+ { required: true, message: '请输入分类名称', trigger: 'blur' }
|
|
|
|
|
+ ],
|
|
|
|
|
+ },
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ computed: {
|
|
|
|
|
+ ...mapGetters(["permission"]),
|
|
|
|
|
+ },
|
|
|
|
|
+ methods: {
|
|
|
|
|
+ add() {
|
|
|
|
|
+ this.resetEditForm();
|
|
|
|
|
+ this.showEdit = true;
|
|
|
|
|
+ },
|
|
|
|
|
+ edit(row) {
|
|
|
|
|
+ this.editForm = Object.assign({}, row);
|
|
|
|
|
+ this.showEdit = true;
|
|
|
|
|
+ },
|
|
|
|
|
+ resetEditForm() {
|
|
|
|
|
+ this.editForm = { status: 1, sort: 0, name: '', remark: '' };
|
|
|
|
|
+ if (this.$refs.editForm) {
|
|
|
|
|
+ this.$refs.editForm.clearValidate();
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ handleReset() {
|
|
|
|
|
+ this.table.where = { status: 0 };
|
|
|
|
|
+ this.$refs.table.reload();
|
|
|
|
|
+ },
|
|
|
|
|
+ save() {
|
|
|
|
|
+ this.$refs['editForm'].validate((valid) => {
|
|
|
|
|
+ if (valid) {
|
|
|
|
|
+ const loading = this.$loading({ lock: true });
|
|
|
|
|
+ this.$http.post('/jobsCategory/edit', this.editForm).then(res => {
|
|
|
|
|
+ loading.close();
|
|
|
|
|
+ if (res.data.code === 0) {
|
|
|
|
|
+ this.showEdit = false;
|
|
|
|
|
+ this.$message({ type: 'success', message: res.data.msg });
|
|
|
|
|
+ this.$refs.table.reload();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.$message.error(res.data.msg);
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch(e => {
|
|
|
|
|
+ loading.close();
|
|
|
|
|
+ this.$message.error(e.message);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ remove(row) {
|
|
|
|
|
+ const loading = this.$loading({ lock: true });
|
|
|
|
|
+ this.$http.post('/jobsCategory/delete', { id: row.id }).then(res => {
|
|
|
|
|
+ loading.close();
|
|
|
|
|
+ if (res.data.code === 0) {
|
|
|
|
|
+ this.$message({ type: 'success', message: res.data.msg });
|
|
|
|
|
+ this.$refs.table.reload();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.$message.error(res.data.msg);
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch(e => {
|
|
|
|
|
+ loading.close();
|
|
|
|
|
+ this.$message.error(e.message);
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ editStatus(row) {
|
|
|
|
|
+ this.$message.closeAll()
|
|
|
|
|
+ const loading = this.$loading({ lock: true });
|
|
|
|
|
+ this.$http.post('/jobsCategory/status', row).then(res => {
|
|
|
|
|
+ loading.close();
|
|
|
|
|
+ if (res.data.code === 0) {
|
|
|
|
|
+ this.$message({ type: 'success', message: res.data.msg });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ row.status = row.status === 1 ? 2 : 1;
|
|
|
|
|
+ this.$message.error(res.data.msg);
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch(e => {
|
|
|
|
|
+ loading.close();
|
|
|
|
|
+ this.$message.error(e.message);
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+</script>
|