Files
2026-09-08 19:49:21 +08:00

458 lines
20 KiB
HTML

<!--#
layout("/layouts/platform.html"){
#-->
<style>
.el-transfer {
text-align: center;
}
.el-transfer-panel {
text-align: left;
width: 35%;
height: 400px;
}
.el-transfer-panel__list.is-filterable {
height: 300px;
}
.v-tree-layout-left {
overflow: unset !important;
}
.v-tree-layout-left .v-tree {
width: 100%;
height: calc(100vh - 170px);
overflow-y: auto;
}
.v-tree:hover::-webkit-scrollbar {
width: 3px;
background-color: transparent;
}
.v-tree-layout-left .custom-tree-node {
width: 90%;
position: relative;
display: flex;
align-items: center;
}
.v-tree-layout-left .v-tree .v-node {
width: 100%;
display: inline-block;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
::-webkit-scrollbar {
/*width: 3px;*/
/*background-color: transparent;*/
display: none;
}
::-webkit-scrollbar-thumb {
background-color: rgba(0, 0, 0, 0.2);
border-radius: 10px;
}
</style>
<div id="app" v-cloak>
<guava>
<el-card shadow="never" style="height: calc(100vh - 70px)">
<tree-layout>
<template #tree>
<div style="padding:0 20px 20px;">
<el-input placeholder="输入单位名称进行过滤" v-model="filterText"></el-input>
</div>
<el-tree class="v-tree" :data="treeData" :props="defaultProps"
:expand-on-click-node="false"
default-expand-all :filter-node-method="filterNode" ref="tree"
highlight-current accordion @node-click="handleNodeClick">
<div class="custom-tree-node" slot-scope="{ node, data }">
<div v-if="node.level==1" style="font-size: 16px;" class="v-node">
<i class="el-icon-office-building"></i>&nbsp;{{ data.unitName }}
</div>
<div v-if="node.level==2" style="font-size: 14px" class="v-node">
<i class="el-icon-s-help" v-if="checkData.unitName==data.unitName"></i>
<i class="el-icon-help" v-else></i>
&emsp;{{ data.unitName }}
</div>
</div>
</el-tree>
</template>
<template>
<div v-if="node.level==1" style="padding:0 10px">
<el-card shadow="never">
<div class="btn-group tool-button">
<el-input placeholder="根据承办单位名称进行查询" clearable v-model="pageForm.unitName"
@keyup.enter.native="doSearch">
</el-input>
</div>
<div class="btn-group tool-button">
<el-button slot="append" icon="el-icon-search" type="primary" @click="doSearch()"></el-button>
</div>
<!-- <div class="pull-right offscreen-right">
<el-button type="primary" @click="openAdd"><i class="ti-plus"></i>增补承办单位</el-button>
</div>-->
</el-card>
<el-card shadow="never" class="mt10">
<el-table ref="underTakeTable" highlight-current-row :data="tableData"
@sort-change="(column)=>{pageForm.pageOrderName = column.prop;pageForm.pageOrderBy = column.order;pageData()}"
height="673px">
<el-table-column label="序号" width="60px">
<template scope="scope">
<span>{{scope.$index+(pageForm.pageNumber - 1) * pageForm.pageSize + 1}}</span>
</template>
</el-table-column>
<el-table-column label="承办单位编码" prop="unitCode" header-align="center"
align="center"
width="130px" sortable></el-table-column>
<el-table-column label="承办单位名称" prop="unitName" header-align="center"
align="center"
width="250px"></el-table-column>
<el-table-column label="分管校领导及联系电话" prop="leader" header-align="center"
align="center" sortable show-overflow-tooltip></el-table-column>
<el-table-column label="负责人及联系电话" prop="principal" header-align="center"
align="center" sortable show-overflow-tooltip></el-table-column>
<el-table-column label="是否启用" prop="isEnable" header-align="center" align="center"
width="100px">
<template scope="{row}">
<el-switch @change="switchChange(row)" v-model="row.isEnable"
active-color="#13ce66" inactive-color="#ff4949">
</el-switch>
</template>
</el-table-column>
<el-table-column align="center" header-align="center" label="操作" fixed="right" width="120px">
<template scope="{row}">
<el-dropdown @command="dropdownCommand">
<el-button plain size="mini">
<i class="ti-settings"></i><span class="ti-angle-down"></span>
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="{type:'leader',data:row}">设置分管校领导</el-dropdown-item>
<el-dropdown-item :command="{type:'principal',data:row}">设置负责人
</el-dropdown-item>
<!-- <el-dropdown-item :command="{type:'edit',data:row}">编辑</el-dropdown-item>
<el-dropdown-item v-if="!row.isEnable" :command="{type:'delete',data:row}">删除
</el-dropdown-item>-->
</el-dropdown-menu>
</el-dropdown>
</template>
</el-table-column>
</el-table>
<!--#include("/layouts/pagination.html"){}#-->
</el-card>
</div>
<div v-if="node.level==2" style="padding:0 10px">
<el-card shadow="never">
<div class="text-right">
<el-button size="medium" type="primary" @click="openAdmin(adminPageForm,adminPageForm.flag)">
{{butTitle}}
</el-button>
</div>
</el-card>
<el-tabs v-model="activeName" type="card" @tab-click="handleTabClick" class="mt10">
<el-tab-pane label="分管校领导" name="one"></el-tab-pane>
<el-tab-pane label="负责人" name="two"></el-tab-pane>
</el-tabs>
<el-card shadow="never">
<el-table highlight-current-row :data="adminTableData" style="width: 100%;" height="661px">
<el-table-column label="序号" width="60px">
<template scope="scope"><span>{{scope.$index+1}}</span></template>
</el-table-column>
<el-table-column label="职工号" prop="loginname" align="center"></el-table-column>
<el-table-column label="姓名" prop="username" align="center"></el-table-column>
<el-table-column label="性别" prop="sex" align="center"></el-table-column>
<el-table-column label="联系方式" prop="mobile" align="center"></el-table-column>
<el-table-column label="操作" align="center">
<template scope="{row}">
<el-button type="danger" size="mini" @click="removeAdmin(row)">
删除
</el-button>
</template>
</el-table-column>
</el-table>
</el-card>
</div>
</template>
</tree-layout>
</el-card>
</guava>
<el-dialog title="增补承办单位" :visible.sync="dialogVisible" width="50%">
<el-form ref="addForm" :model="formData" :rules="formRules" label-width="120px">
<el-form-item label="承办单位编码" prop="unitCode">
<el-input v-model="formData.unitCode" placeholder="请输入承办单位编码"></el-input>
</el-form-item>
<el-form-item label="承办单位名称" prop="unitName">
<el-input v-model="formData.unitName" placeholder="请输入承办单位名称"></el-input>
</el-form-item>
<el-form-item label="是否启用" prop="isEnable">
<el-radio-group v-model="formData.isEnable">
<el-radio-button :label="true"></el-radio-button>
<el-radio-button :label="false"></el-radio-button>
</el-radio-group>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false">取 消</el-button>
<el-button type="primary" @click="operation" :loading="subLoading">确 定</el-button>
</span>
</el-dialog>
<el-dialog :title="title" :visible.sync="adminDialogVisible" width="55%">
<div style="width: 100%;">
<el-transfer :titles="['单位成员', '管理员']" filterable
:props="{key: 'id',label: 'name'}"
:filter-method="adminFilterMethod"
v-model="adminFormData.adminValue"
:data="adminData">
</el-transfer>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="adminDialogVisible = false">取 消</el-button>
<el-button type="primary" @click="doAdmin" :loading="adminSubLoading">确 定</el-button>
</span>
</el-dialog>
</div>
<script>
var vue = new Vue({
el: '#app',
mixins: [initTableMixins],
components: {
'tree-layout': httpVueLoader('/components/plugins/TreeLayout.vue')
},
data() {
return {
title: '',
butTitle: '添加分管校领导',
filterText: '',
activeName: 'one',
subLoading: false,
dialogVisible: false,
treeData: [],
node: {
level: 1
},
formData: {
isEnable: true
},
checkData: {},
adminSubLoading: false,
adminDialogVisible: false,
adminFormData: {
adminValue: [],
flag: true
},
adminData: [],
adminTableData: [],
adminPageForm: {
flag: true
},
defaultProps: {
children: 'childrens',
label: 'unitName',
disabled: 'disabled'
},
formRules: {
unitCode: [{required: true, message: '请输入承办单位编码', trigger: ['blur', 'change']}],
unitName: [{required: true, message: '请输入承办单位名称', trigger: ['blur', 'change']}],
isEnable: [{required: true, message: '请选择是否启用', trigger: ['blur', 'change']}],
},
}
},
watch: {
filterText(val) {
this.$refs.tree.filter(val);
}
},
methods: {
dropdownCommand(command) {
const {type, data} = command
if (type === 'leader') {
this.title = '设置分管校领导'
this.openAdmin(data, true)
} else if (type === 'principal') {
this.title = '设置负责人'
this.openAdmin(data, false)
} else if (type === 'edit') {
this.openEdit(data)
} else if (type === 'delete') {
this.doDelete(data.id)
}
},
filterNode(value, data) {
if (!value) return true;
return data.unitName.indexOf(value) !== -1
return false
},
adminFilterMethod(query, item) {
return item.username.indexOf(query) > -1;
},
handleNodeClick(data, node) {
this.node = node
this.checkData = data
this.adminPageForm.id = data.id
this.adminPageForm.unitCode = data.unitCode
this.adminPageForm.flag = this.activeName === 'one'
this.adminPageData()
},
handleTabClick(tab) {
this.butTitle = tab.name === 'one' ? '添加分管校领导' : '添加负责人'
this.adminPageForm.flag = tab.name === 'one'
this.adminPageData()
},
removeAdmin(row) {
this.$confirm('确定要移除该管理员吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
callback: async (a, b) => {
if ("confirm" === a) {
const resp = await $.post(loc() + "/removeAdmin", {
unitId: this.adminPageForm.id,
userId: row.id,
roleId: row.roleid
})
if(resp.code===0){
this.notifySuccess({title: '成功', message: resp.msg});
this.adminPageData()
}else{
this.notifySuccess('审核失败')
}
}
}
});
},
async adminPageData() {
const resp = await $.post(loc() + "/adminPageData", this.adminPageForm)
if(resp.code===0){
this.adminTableData = resp.data;
}else{
this.notifyWarning(resp.msg)
}
},
openAdd() {
this.formData = {}
this.$set(this.formData, "isEnable", true)
this.resetForm()
},
openEdit(data) {
this.formData = data
this.resetForm()
},
async openAdmin(row, flag) {
const {id, unitCode} = row
this.adminFormData.unitId = id
this.adminFormData.flag = flag
const {data} = await $.get(loc() + "/findUserAndAdmin", {id, unitCode, flag})
if (data) {
this.adminData = data.data
this.adminFormData.adminValue = data.value.map(v => {
return v.id
})
}
this.adminDialogVisible = true
},
async doAdmin() {
this.adminSubLoading = true
const data = clone(this.adminFormData)
data.adminValue = JSON.stringify(data.adminValue)
const resp = await $.post(loc() + "/setAdmin", data)
this.adminSubLoading = false
if(resp.code===0){
this.adminDialogVisible = false
this.pageData()
this.adminPageData()
this.notifySuccess(resp.msg)
}else{
this.notifyWarning(resp.msg)
}
},
resetForm() {
this.dialogVisible = true
if (this.$refs['addForm']) {
this.$refs['addForm'].resetFields()
}
},
async switchChange(data) {
this.formData = data
const resp = await $.post(loc() + "/doEdit", {"data": JSON.stringify(this.formData)})
if(resp.code===0){
this.notifySuccess(resp.msg)
}else{
this.notifyWarning(resp.msg)
}
this.undertakeUnitTree()
},
async operation() {
let method = this.formData.id ? "/doEdit" : "/doAdd"
this.$refs["addForm"].validate(async (valid) => {
if (valid) {
this.subLoading = true
const loading = this.$loading({
lock: true,
text: '正在提交...',
spinner: 'el-icon-loading',
background: COVER_LAYER_COLOR
});
const resp = await $.post(loc() + method, {"data": JSON.stringify(this.formData)})
loading.close()
this.subLoading = false
if(resp.code===0){
this.dialogVisible = false
this.pageData()
this.notifySuccess(resp.msg)
}else{
this.notifyWarning(resp.msg)
}
}
});
},
doDelete(id) {
this.$confirm('确定要删除吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
callback: async (a, b) => {
if ("confirm" == a) {
const resp = await $.post(loc() + "/doDelete", {id})
if(resp.code===0){
this.notifySuccess(resp.msg)
this.undertakeUnitTree()
}else{
this.notifyWarning(resp.msg)
}
}
}
});
},
async undertakeUnitTree() {
const {data} = await $.get(loc() + "/undertakeUnitTree")
this.treeData = [data]
this.pageData()
}
},
async created() {
await this.undertakeUnitTree()
}
})
</script>
<!--#
}
#-->