first commit
This commit is contained in:
@@ -0,0 +1,264 @@
|
||||
const MSG_FORM_TEMPLATE = {
|
||||
template: `
|
||||
<div>
|
||||
<el-form :model="formData" ref="addForm" :rules="formRules" label-width="120px">
|
||||
<el-form-item prop="title" label="标题">
|
||||
<el-input maxlength="255" placeholder="请输入标题" v-model="formData.title"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="url" label="链接地址">
|
||||
<el-input placeholder="请输入链接地址" v-model="formData.url"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="needBack" label="是否需要反馈">
|
||||
<el-radio-group v-model="formData.needBack" size="small">
|
||||
<el-radio border :label="true">是</el-radio>
|
||||
<el-radio border :label="false">否</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item prop="type" label="消息类型">
|
||||
<el-radio-group v-model="formData.type" size="small">
|
||||
<!-- <el-radio border label="system">系统消息</el-radio>-->
|
||||
<el-radio border label="user">用户消息</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="用户列表" v-if="'user'==formData.type">
|
||||
<el-row class="mb10">
|
||||
<el-button icon="el-icon-search" @click="openSelect" size="small">选择用户</el-button>
|
||||
<el-button icon="el-icon-delete" @click="clearSelect" type="danger" size="small">清空用户</el-button>
|
||||
</el-row>
|
||||
<el-table :data="userTableData" style="width: 100%" size="mini" max-height="500">
|
||||
<el-table-column fixed prop="loginname" label="工号" width="150"></el-table-column>
|
||||
<el-table-column prop="username" label="姓名" width="120"></el-table-column>
|
||||
<el-table-column prop="sex" label="性别" width="50"></el-table-column>
|
||||
<el-table-column prop="userState" label="在职状态" width="120"></el-table-column>
|
||||
<el-table-column prop="personType" label="教职工类别" width="120"></el-table-column>
|
||||
<el-table-column prop="preparedBy" label="编制类别" width="120"></el-table-column>
|
||||
<el-table-column prop="mobile" label="手机" width="120"></el-table-column>
|
||||
<el-table-column prop="unitName" label="所属单位" show-overflow-tooltip></el-table-column>
|
||||
<el-table-column prop="unionName" label="所属工会" show-overflow-tooltip></el-table-column>
|
||||
</el-table>
|
||||
<p style="color: var(--color-primary)">总计:{{userTableData.length}}人</p>
|
||||
</el-form-item>
|
||||
<el-form-item prop="note" label="消息内容">
|
||||
<text-editor v-model="formData.note"></text-editor>
|
||||
</el-form-item>
|
||||
<el-form-item prop="files" label="消息附件">
|
||||
<file-upload
|
||||
:value.sync="formData.files"
|
||||
:upload_number="5"
|
||||
upload_result_category="array"
|
||||
complete_result
|
||||
></file-upload>
|
||||
</el-form-item>
|
||||
|
||||
<el-row class="mt20" justify="end" type="flex">
|
||||
<el-button @click="back">取消</el-button>
|
||||
<el-button type="primary" @click="doAdd">确定</el-button>
|
||||
</el-row>
|
||||
</el-form>
|
||||
|
||||
<el-dialog title="选择用户" :visible.sync="selectDialogVisible" width="65%" append-to-body top="2%">
|
||||
<div class="btn-group tool-button">
|
||||
<el-input placeholder="请输入内容" v-model="pageForm.searchKeyword" @keyup.enter.native="doSearch" style="width: 300px">
|
||||
<el-select v-model="pageForm.searchName" slot="prepend" placeholder="查询类型" style="width: 80px">
|
||||
<el-option label="工号" value="u.loginname"></el-option>
|
||||
<el-option label="姓名" value="u.username"></el-option>
|
||||
<el-option label="手机" value="u.mobile"></el-option>
|
||||
</el-select>
|
||||
</el-input>
|
||||
<el-select v-model="pageForm.sex" placeholder="性别" clearable>
|
||||
<el-option label="男" value="男"></el-option>
|
||||
<el-option label="女" value="女"></el-option>
|
||||
</el-select>
|
||||
|
||||
<el-select v-model="pageForm.unionId" @change="flushUnits" @clear="flushUnits" placeholder="请选择所属工会" filterable clearable>
|
||||
<el-option v-for="item in unionList" :key="item.id" :label="item.name" :value="item.id"></el-option>
|
||||
</el-select>
|
||||
<el-select v-model="pageForm.unitId" placeholder="请选择所属单位" filterable clearable>
|
||||
<el-option v-for="item in unitList" :key="item.id" :label="item.name" :value="item.id"></el-option>
|
||||
</el-select>
|
||||
<el-select v-model="pageForm.roleId" placeholder="请选择角色" filterable clearable>
|
||||
<el-option v-for="item in roleList" :key="item.id" :label="item.name" :value="item.id"></el-option>
|
||||
</el-select>
|
||||
<el-button icon="el-icon-search" @click="doSearch" type="primary"></el-button>
|
||||
</div>
|
||||
<div class="left-span-label mt20">人员列表</div>
|
||||
<el-table
|
||||
:data="tableData"
|
||||
@selection-change="handleSelectionChange"
|
||||
row-key="id"
|
||||
ref="tableRef"
|
||||
>
|
||||
<el-table-column type="selection" reserve-selection width="35"></el-table-column>
|
||||
<el-table-column fixed prop="loginname" label="工号" width="150"></el-table-column>
|
||||
<el-table-column prop="username" label="姓名" width="120"></el-table-column>
|
||||
<el-table-column prop="sex" label="性别" width="50"></el-table-column>
|
||||
<el-table-column prop="userState" label="在职状态" width="120"></el-table-column>
|
||||
<el-table-column prop="personType" label="教职工类别" width="120"></el-table-column>
|
||||
<el-table-column prop="preparedBy" label="编制类别" width="120"></el-table-column>
|
||||
<el-table-column prop="mobile" label="手机" width="120"></el-table-column>
|
||||
<el-table-column prop="unitName" label="所属单位" show-overflow-tooltip></el-table-column>
|
||||
<el-table-column prop="unionName" label="所属工会" show-overflow-tooltip></el-table-column>
|
||||
</el-table>
|
||||
<!--#include("/layouts/pagination.html"){}#-->
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="selectDialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="doSelect">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</div>
|
||||
`,
|
||||
props: {
|
||||
unionList: {
|
||||
type: Array,
|
||||
required: true
|
||||
},
|
||||
unitList: {
|
||||
type: Array,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
roleList: [],
|
||||
userTableData: [],
|
||||
tableData: [],
|
||||
pageForm: {
|
||||
searchName: "u.username",
|
||||
searchKeyword: "",
|
||||
pageNumber: 1,
|
||||
pageSize: 10,
|
||||
totalCount: 0,
|
||||
pageOrderName: "",
|
||||
pageOrderBy: ""
|
||||
},
|
||||
formData: {},
|
||||
formRules: {
|
||||
title: [{ required: true, message: "必填", trigger: ["blur", "change"] }],
|
||||
note: [{ required: true, message: "必填", trigger: ["blur", "change"] }],
|
||||
needBack: [{ required: true, message: "必填", trigger: ["blur", "change"] }],
|
||||
type: [{ required: true, message: "必填", trigger: ["blur", "change"] }]
|
||||
},
|
||||
selectDialogVisible: false,
|
||||
selectUsers: []
|
||||
}
|
||||
},
|
||||
computed: {},
|
||||
methods: {
|
||||
async flushUnits() {
|
||||
this.$set(this.pageForm, "unitId", null)
|
||||
this.unitList = []
|
||||
if (this.pageForm.unionId) {
|
||||
this.$businessTool.listUnit(this.pageForm.unionId).then((data) => {
|
||||
this.unitList = data
|
||||
})
|
||||
}
|
||||
this.doSearch()
|
||||
},
|
||||
back() {
|
||||
this.$emit("back")
|
||||
},
|
||||
parentDoSearch() {
|
||||
this.$emit("parent-do-search")
|
||||
},
|
||||
doAdd() {
|
||||
this.$refs["addForm"].validate((valid) => {
|
||||
if (valid) {
|
||||
const loginNames = this.userTableData.map((u) => u.loginname)
|
||||
if (loginNames.length === 0 && this.formData.type === "user") {
|
||||
this.$message.warning("请选择用户")
|
||||
return false
|
||||
}
|
||||
|
||||
if(loginNames.length > 100){
|
||||
this.$message.warning("单条消息最多发送100人,请分批次发送。")
|
||||
return false
|
||||
}
|
||||
|
||||
this.$confirm('您确定要发送吗, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(()=>{
|
||||
this.$axios
|
||||
.post("/platform/sys/msg/addDo", {
|
||||
msg: JSON.stringify(this.formData),
|
||||
users: JSON.stringify(loginNames)
|
||||
})
|
||||
.then((resp) => {
|
||||
if (resp.code === 0) {
|
||||
this.$message.success(resp.msg)
|
||||
this.parentDoSearch()
|
||||
this.back()
|
||||
} else {
|
||||
this.$message.error(resp.msg)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
doSearch() {
|
||||
this.pageForm.pageNumber = 1
|
||||
this.pageData()
|
||||
},
|
||||
pageNumberChange(val) {
|
||||
this.pageForm.pageNumber = val
|
||||
this.pageData()
|
||||
},
|
||||
pageSizeChange(val) {
|
||||
this.pageForm.pageSize = val
|
||||
this.pageData()
|
||||
},
|
||||
handleSelectionChange(val) {
|
||||
this.selectUsers = val
|
||||
},
|
||||
initAdd() {
|
||||
this.formData = {
|
||||
id: "",
|
||||
type: "user",
|
||||
needBack: false
|
||||
}
|
||||
if (this.$refs["addForm"]) this.$refs["addForm"].resetFields()
|
||||
},
|
||||
openSelect: function () {
|
||||
this.selectDialogVisible = true
|
||||
this.pageData()
|
||||
},
|
||||
clearSelect() {
|
||||
this.userTableData = []
|
||||
if(this.$refs.tableRef){
|
||||
this.$refs.tableRef.clearSelection()
|
||||
}
|
||||
},
|
||||
pageData() {
|
||||
this.$axios.post("/platform/sys/msg/user_data", this.pageForm).then((res) => {
|
||||
if (res.code === 0) {
|
||||
this.tableData = res.data.list
|
||||
this.pageForm.totalCount = res.data.totalCount
|
||||
}
|
||||
})
|
||||
},
|
||||
doSelect() {
|
||||
const self = this
|
||||
console.log(this.selectUsers)
|
||||
console.log(this.userTableData)
|
||||
const tableLoginNames = this.userTableData.map(v=>v.loginname)
|
||||
this.selectUsers.forEach(function (o) {
|
||||
if(!tableLoginNames.includes(o.loginname)){
|
||||
self.userTableData.push(o)
|
||||
}
|
||||
})
|
||||
if(this.$refs.tableRef){
|
||||
this.$refs.tableRef.clearSelection()
|
||||
}
|
||||
this.selectDialogVisible = false
|
||||
},
|
||||
async getRoleList() {
|
||||
const resp = await this.$axios.post("/platform/sys/msg/getRoleList")
|
||||
return resp.data
|
||||
}
|
||||
},
|
||||
async created() {
|
||||
this.roleList = await this.getRoleList()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
const VIEW_USER_TEMPLATE = {
|
||||
template: `
|
||||
<div>
|
||||
<el-dialog :title="viewUserTitle" :visible.sync="viewDialogVisible" width="65%" top="2%">
|
||||
<div class="btn-group tool-button">
|
||||
<el-input placeholder="请输入内容" v-model="pageForm.searchKeyword" size="small" @keyup.enter.native="doSearch" style="width: 300px">
|
||||
<el-select v-model="pageForm.searchName" slot="prepend" placeholder="查询类型" style="width: 80px">
|
||||
<el-option label="工号" value="u.loginname"></el-option>
|
||||
<el-option label="姓名" value="u.username"></el-option>
|
||||
<el-option label="手机" value="u.mobile"></el-option>
|
||||
</el-select>
|
||||
</el-input>
|
||||
<el-select v-model="pageForm.unionId" @change="flushUnits" @clear="flushUnits" placeholder="请选择所属工会" size="small" filterable clearable>
|
||||
<el-option v-for="item in unionList" :key="item.id" :label="item.name" :value="item.id"></el-option>
|
||||
</el-select>
|
||||
<el-select v-model="pageForm.unitId" placeholder="请选择所属单位" size="small" filterable clearable>
|
||||
<el-option v-for="item in unitList" :key="item.id" :label="item.name" :value="item.id"></el-option>
|
||||
</el-select>
|
||||
<el-button icon="el-icon-search" @click="doSearch" size="small" type="primary"></el-button>
|
||||
</div>
|
||||
<div class="left-span-label mt20">{{viewUserTitle}}列表</div>
|
||||
<el-table
|
||||
:data="tableData"
|
||||
style="width: 100%; margin-top: 10px; margin-bottom: 10px"
|
||||
size="small"
|
||||
>
|
||||
<el-table-column fixed prop="loginname" label="工号" width="150"></el-table-column>
|
||||
<el-table-column prop="username" label="姓名" width="120"></el-table-column>
|
||||
<el-table-column prop="sex" label="性别" width="120"></el-table-column>
|
||||
<el-table-column prop="mobile" label="联系方式"></el-table-column>
|
||||
<el-table-column prop="unitName" label="所属单位"></el-table-column>
|
||||
<el-table-column prop="unionName" label="所属工会"></el-table-column>
|
||||
</el-table>
|
||||
<!--#include("/layouts/pagination.html"){}#-->
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="viewDialogVisible = false">关 闭</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</div>
|
||||
`,
|
||||
props: {
|
||||
type: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
id: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
unionList: {
|
||||
type: Array,
|
||||
required: true
|
||||
},
|
||||
unitList: {
|
||||
type: Array,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
viewUserTitle: "",
|
||||
viewDialogVisible: false,
|
||||
tableData: [],
|
||||
pageForm: {
|
||||
searchName: "u.username",
|
||||
searchKeyword: "",
|
||||
pageNumber: 1,
|
||||
pageSize: 10,
|
||||
totalCount: 0,
|
||||
pageOrderName: "",
|
||||
pageOrderBy: ""
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {},
|
||||
methods: {
|
||||
async flushUnits() {
|
||||
this.$set(this.pageForm, "unitId", null)
|
||||
this.unitList = []
|
||||
if (this.pageForm.unionId) {
|
||||
this.$businessTool.listUnit(this.pageForm.unionId).then((data) => {
|
||||
this.unitList = data
|
||||
})
|
||||
}
|
||||
this.doSearch()
|
||||
},
|
||||
open() {
|
||||
this.viewDialogVisible = true
|
||||
this.$nextTick(() => {
|
||||
if ("all" === this.type) {
|
||||
this.viewUserTitle = "全部用户"
|
||||
}
|
||||
if ("unread" === this.type) {
|
||||
this.viewUserTitle = "未读用户"
|
||||
}
|
||||
this.pageForm.type = this.type
|
||||
this.pageForm.id = this.id
|
||||
this.doSearch()
|
||||
})
|
||||
},
|
||||
doSearch() {
|
||||
this.pageForm.pageNumber = 1
|
||||
this.pageData()
|
||||
},
|
||||
pageNumberChange(val) {
|
||||
this.pageForm.pageNumber = val
|
||||
this.pageData()
|
||||
},
|
||||
pageSizeChange(val) {
|
||||
this.pageForm.pageSize = val
|
||||
this.pageData()
|
||||
},
|
||||
pageData() {
|
||||
this.$axios.post("/platform/sys/msg/user_view_data", this.pageForm).then((res) => {
|
||||
if (res.code === 0) {
|
||||
this.tableData = res.data.list
|
||||
this.pageForm.totalCount = res.data.totalCount
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
async created() {}
|
||||
}
|
||||
Reference in New Issue
Block a user