123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377 |
- <template>
- <div class="app-container post-page">
- <div class="post-page-min" v-if="pageType == 1">
- <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px" >
- <el-form-item label="关键字" prop="searchValue">
- <el-input
- v-model="queryParams.searchValue"
- placeholder="请输入身份编码"
- clearable
- size="small"
- />
- </el-form-item>
- <!--<el-form-item label="状态" prop="status">-->
- <!--<el-select v-model="queryParams.status" placeholder="身份状态" clearable size="small">-->
- <!--<el-option-->
- <!--v-for="dict in statusOptions"-->
- <!--:key="dict.dictValue"-->
- <!--:label="dict.dictLabel"-->
- <!--:value="dict.dictValue"-->
- <!--/>-->
- <!--</el-select>-->
- <!--</el-form-item>-->
- <el-form-item style="float: right;">
- <el-col :span="1.5" style="margin-right:20px">
- <p class="add-button-one-120"
- @click="handleAdd"
- v-hasPermi="['system:post:add']"
- ><i class="el-icon-plus"></i>新增</p>
- </el-col>
- </el-form-item>
- <el-form-item>
- <p class="inquire-button-one" @click="handleQuery">查询</p>
- <p class="reset-button-one" @click="resetQuery">重置</p>
- </el-form-item>
- </el-form>
- <el-table v-loading="loading" border :data="postList" @selection-change="handleSelectionChange">
- <!--<el-table-column type="selection" width="55" align="center" />-->
- <el-table-column label="序号" width="55" align="center" type="index"/>
- <el-table-column label="身份名称" align="left" prop="postName" :show-overflow-tooltip="true" width="200"/>
- <el-table-column label="身份编码" align="left" prop="postCode" :show-overflow-tooltip="true" width="200"/>
- <el-table-column label="权限组" align="left" prop="roleNameStr" :show-overflow-tooltip="true"/>
- <!--<el-table-column label="状态" align="left" prop="status" :formatter="statusFormat" :show-overflow-tooltip="true" width="80"/>-->
- <el-table-column label="创建时间" align="left" prop="createTime" width="180">
- <template slot-scope="scope">
- <span>{{ parseTime(scope.row.createTime) }}</span>
- </template>
- </el-table-column>
- <el-table-column label="操作" align="left" class-name="small-padding fixed-width" width="180">
- <template slot-scope="scope">
- <div class="table-button-box">
- <p class="table-button-null"></p>
- <p class="table-button-p"
- @click="handleAuthUser(scope.row)"
- >成员维护</p>
- <el-dropdown @command="moreClick" v-hasPermi="['system:post:query','system:post:edit','system:post:remove']">
- <p class="table-button-p">更多>></p>
- <el-dropdown-menu slot="dropdown">
- <el-dropdown-item style="border-bottom:1px solid #E0E0E0;margin:0 10px;" :command="{row:scope.row,command:1}"
- v-hasPermiAnd="['system:post:query','system:post:edit']">编辑</el-dropdown-item>
- <el-dropdown-item style="margin:0 10px;" :command="{row:scope.row,command:2}"
- v-hasPermi="['system:post:remove']">删除</el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- <p class="table-button-null"></p>
- </div>
- </template>
- </el-table-column>
- </el-table>
- <pagination :page-sizes="[20, 30, 40, 50]"
- v-show="total>0"
- :total="total"
- layout="total, prev, pager, next, sizes, jumper"
- :page.sync="queryParams.pageNum"
- :limit.sync="queryParams.pageSize"
- @pagination="getList"
- />
- </div>
- <!-- 添加或修改身份对话框 -->
- <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body
- :close-on-click-modal="false">
- <el-form ref="form" :model="form" :rules="rules" label-width="80px">
- <el-form-item label="身份名称" prop="postName">
- <el-input v-model="form.postName" placeholder="请输入身份名称" maxlength="10" />
- </el-form-item>
- <el-form-item label="身份编码" prop="postCode">
- <el-input v-model="form.postCode" placeholder="请输入编码名称" maxlength="20" />
- </el-form-item>
- <!--<el-form-item label="身份顺序" prop="postSort">-->
- <!--<el-input-number v-model="form.postSort" controls-position="right" :min="0" style="width: 380px"/>-->
- <!--</el-form-item>-->
- <el-form-item label="权限组" prop="roleIds">
- <el-select
- style="width:380px;"
- v-model="form.roleIds"
- multiple
- collapse-tags
- placeholder="请选择">
- <el-option
- v-for="item in optionselectList"
- :key="item.roleId"
- :label="item.roleName"
- :value="item.roleId">
- </el-option>
- </el-select>
- </el-form-item>
- <!--<el-form-item label="身份状态" prop="status">-->
- <!--<el-radio-group v-model="form.status">-->
- <!--<el-radio-->
- <!--v-for="dict in statusOptions"-->
- <!--:key="dict.dictValue"-->
- <!--:label="dict.dictValue"-->
- <!-->{{dict.dictLabel}}</el-radio>-->
- <!--</el-radio-group>-->
- <!--</el-form-item>-->
- <!--<el-form-item label="备注" prop="remark">-->
- <!--<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />-->
- <!--</el-form-item>-->
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button @click="cancel">取 消</el-button>
- <el-button type="primary" @click="submitForm">确 定</el-button>
- </div>
- </el-dialog>
- <!--分配用户-->
- <auth-user :postId="postId" v-if="pageType == 2"></auth-user>
- </div>
- </template>
- <script>
- import { positionByList } from "@/api/system/user";
- import { listPost, getPost, delPost, addPost, updatePost, optionselect } from "@/api/system/post";
- import authUser from "./authUser.vue";
- export default {
- components: {
- authUser,
- },
- name: "Post",
- data() {
- return {
- isShow:true,
- // 遮罩层
- loading: true,
- // 选中数组
- ids: [],
- // 非单个禁用
- single: true,
- // 非多个禁用
- multiple: true,
- // 显示搜索条件
- showSearch: true,
- // 总条数
- total: 0,
- // 身份表格数据
- postList: [],
- // 弹出层标题
- title: "",
- // 是否显示弹出层
- open: false,
- // 状态数据字典
- statusOptions: [],
- // 查询参数
- queryParams: {
- pageNum: 1,
- pageSize:20,
- searchValue: null,
- postCode: undefined,
- postName: undefined,
- status: undefined
- },
- // 表单参数
- form: {},
- pageType:1,
- postId:"",
- // 表单校验
- rules: {
- postName: [
- { required: true, message: "请输入身份名称", trigger: "blur" },
- { required: true, message: "请输入身份名称", validator: this.spaceJudgment, trigger: "blur" }
- ],
- postCode: [
- { required: true, message: "请输入身份编码", trigger: "blur" },
- { required: true, message: "请输入身份编码", validator: this.spaceJudgment, trigger: "blur" }
- ],
- postSort: [
- { required: true, message: "请输入身份顺序", trigger: "blur" },
- { required: true, message: "请输入身份顺序", validator: this.spaceJudgment, trigger: "blur" }
- ],
- roleIds: [
- { required: true, message: "请选择权限组", trigger: "blur" },
- { required: true, message: "请选择权限组", validator: this.spaceJudgment, trigger: "blur" }
- ]
- },
- //权限组列表
- optionselectList:[],
- };
- },
- created() {
- this.getList();
- // this.getDicts("sys_normal_disable").then(response => {
- // this.statusOptions = response.data;
- // });
- this.optionselect();
- },
- methods: {
- //更多选项
- moreClick(item){
- if(item.command == 1){
- this.handleUpdate(item.row)
- }else if(item.command == 2){
- this.handleDelete(item.row)
- }
- },
- clickPage(type){
- if(this.pageType != type){
- this.pageType = type;
- }
- },
- /** 查询身份列表 */
- getList() {
- this.loading = true;
- listPost(this.queryParams).then(response => {
- this.postList = response.rows;
- this.total = response.total;
- this.loading = false;
- });
- },
- //获取权限组列表
- optionselect(){
- optionselect().then(response => {
- this.optionselectList = response.data;
- });
- },
- // 身份状态字典翻译
- statusFormat(row, column) {
- return this.selectDictLabel(this.statusOptions, row.status);
- },
- // 取消按钮
- cancel() {
- this.open = false;
- this.reset();
- },
- // 表单重置
- reset() {
- this.form = {
- postId: undefined,
- postCode: undefined,
- postName: undefined,
- postSort: 0,
- remark: undefined
- };
- this.resetForm("form");
- },
- /** 搜索按钮操作 */
- handleQuery() {
- this.queryParams.pageNum = 1;
- this.getList();
- },
- /** 重置按钮操作 */
- resetQuery() {
- this.queryParams.searchValue='';
- // this.resetForm("queryForm");
- this.$set(this,'queryParams',{
- pageNum: 1,
- pageSize:20,
- searchValue:"",
- });
- this.handleQuery();
- },
- /** 分配用户操作 */
- handleAuthUser: function(row) {
- if(row.roleIds){
- this.postId=row.postId;
- this.pageType=2;
- }else{
- this.msgError('未配置权限组的身份无法分配用户')
- }
- },
- // 多选框选中数据
- handleSelectionChange(selection) {
- this.ids = selection.map(item => item.postId)
- this.single = selection.length!=1
- this.multiple = !selection.length
- },
- /** 新增按钮操作 */
- handleAdd() {
- this.reset();
- this.open = true;
- this.title = "新增身份";
- },
- /** 修改按钮操作 */
- handleUpdate(row) {
- this.reset();
- const postId = row.postId || this.ids
- getPost(postId).then(response => {
- if(response.data.roleIds){
- response.data.roleIds = response.data.roleIds.split(',')
- for(let i=0;i<response.data.roleIds.length;i++){
- response.data.roleIds[i] = parseInt(response.data.roleIds[i]);//字符串转数字
- }
- }
- this.form = response.data;
- this.open = true;
- this.title = "修改身份";
- });
- },
- /** 提交按钮 */
- submitForm: function() {
- this.$refs["form"].validate(valid => {
- if (valid) {
- let obj = JSON.parse(JSON.stringify(this.form))
- obj.roleIds = obj.roleIds+'';
- if (this.form.postId != undefined) {
- updatePost(obj).then(response => {
- this.msgSuccess("修改成功");
- this.open = false;
- this.getList();
- });
- } else {
- addPost(obj).then(response => {
- this.msgSuccess("新增成功");
- this.open = false;
- this.getList();
- });
- }
- }
- });
- },
- /** 删除按钮操作 */
- handleDelete(row) {
- positionByList({position:row.postId}).then(response => {
- if(response.total<1){
- const postIds = row.postId || this.ids;
- this.$confirm('是否确认删除身份?', "警告", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- }).then(function() {
- return delPost(postIds);
- }).then(() => {
- this.getList();
- this.msgSuccess("删除成功");
- }).catch(() => {});
- }else{
- this.msgError('该身份下还有用户无法删除')
- }
- });
- },
- /** 导出按钮操作 */
- handleExport() {
- this.download('system/post/export', {
- ...this.queryParams
- }, `post_${new Date().getTime()}.xlsx`)
- }
- }
- };
- </script>
- <style scoped lang="scss">
- .post-page{
- display: flex!important;
- flex-direction: column;
- box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
- padding:11px 20px 20px!important;
- .post-page-min{
- flex:1;
- display: flex!important;
- flex-direction: column;
- .button-box{
- width:340px;
- display: flex;
- }
- }
- }
- </style>
|