|
@@ -0,0 +1,353 @@
|
|
|
+<template>
|
|
|
+<!-- 专家 -->
|
|
|
+ <div class="container">
|
|
|
+ <el-card class="box-card">
|
|
|
+ <div slot="header" class="clearfix">
|
|
|
+ <span>专家管理</span>
|
|
|
+ <el-button style="float: right; padding: 3px 0" type="text" @click="addspecialist">添加专家</el-button>
|
|
|
+ </div>
|
|
|
+ <div class="main">
|
|
|
+ <div class="left">
|
|
|
+ <el-select class="select" size="mini" v-model="options" @change="optionschange" placeholder="请选择">
|
|
|
+ <el-option
|
|
|
+ v-for="item in hospitalList"
|
|
|
+ :key="item.code"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.code">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ <el-tree
|
|
|
+ :data="subject"
|
|
|
+ default-expand-all
|
|
|
+ :props="defaultProps"
|
|
|
+ @node-click="treeClick"
|
|
|
+ node-key="code"
|
|
|
+ ref="deeptree"
|
|
|
+ class="deeptree"
|
|
|
+ >
|
|
|
+ </el-tree>
|
|
|
+ </div>
|
|
|
+ <el-card class="maincard">
|
|
|
+ <div slot="header" class="clearfix">
|
|
|
+ <span>所属科室:{{ is_title }}</span>
|
|
|
+ </div>
|
|
|
+ <naf-grid class="grid" ref="grid" @edit="edit" @delete="deletespecialist" :data="specialistList" :meta="meta" :total="total" @query="query"></naf-grid>
|
|
|
+ </el-card>
|
|
|
+ </div>
|
|
|
+ </el-card>
|
|
|
+ <el-card class="box-dj" v-if="visible">
|
|
|
+ <div slot="header" class="clearfix">
|
|
|
+ <span>{{ isNew ? '修改专家' : '添加专家' }}</span>
|
|
|
+ </div>
|
|
|
+ <div class="main">
|
|
|
+ <naf-form v-if="visible" ref="ruleForm" @save="save" :meta="formmeta" :rules="rules" :data="is_data" :close="true" @close="close">
|
|
|
+ <template v-slot:field="{ form, item }">
|
|
|
+ <!-- 图片上传 -->
|
|
|
+ <el-upload
|
|
|
+ v-if="item.name == 'thumbnail'"
|
|
|
+ class="avatar-uploader avatar"
|
|
|
+ action="/tyylfiles/upload"
|
|
|
+ :show-file-list="false"
|
|
|
+ :on-success="handleAvatarSuccess"
|
|
|
+ :before-upload="beforeAvatarUpload"
|
|
|
+ :headers="myHeaders"
|
|
|
+ :on-error="imgerror"
|
|
|
+ >
|
|
|
+ <img v-if="imageUrl" :src="imageUrl" class="avatar">
|
|
|
+ <i v-else class="el-icon-plus avatar-uploader-icon"></i>
|
|
|
+ </el-upload>
|
|
|
+ <!-- 富文本 -->
|
|
|
+ <editor-bar v-if="item.name == 'content'" v-model="form[item.name]" :isClear="isClear"></editor-bar>
|
|
|
+ </template>
|
|
|
+ </naf-form>
|
|
|
+ </div>
|
|
|
+ </el-card>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import nafGrid from '@naf/data/tables/naf-grid'
|
|
|
+import nafForm from '@naf/data/form'
|
|
|
+import editorBar from '@naf/data/editoritem'
|
|
|
+import { createNamespacedHelpers, mapMutations } from 'vuex'
|
|
|
+const token = sessionStorage.getItem('token')
|
|
|
+const { mapState, mapActions } = createNamespacedHelpers('specialist')
|
|
|
+const { mapState: subjectmapState, mapActions: subjectmapActions } = createNamespacedHelpers('subject')
|
|
|
+const { mapState: hospitalmapState, mapActions: hospitalmapActions } = createNamespacedHelpers('hospital')
|
|
|
+export default {
|
|
|
+ components: {
|
|
|
+ nafGrid,
|
|
|
+ nafForm,
|
|
|
+ editorBar
|
|
|
+ },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ options: null,
|
|
|
+ subject: null,
|
|
|
+ is_title: null,
|
|
|
+ isClear: false,
|
|
|
+ detail: '',
|
|
|
+ myHeaders: { Authorization: `Bearer ${token}` },
|
|
|
+ imageUrl: '',
|
|
|
+ fileList: [],
|
|
|
+ is_data: {},
|
|
|
+ visible: false,
|
|
|
+ meta: [
|
|
|
+ { name: 'name', title: '专家名称', filter: true },
|
|
|
+ { name: 'code', title: '专家编码' }
|
|
|
+ ],
|
|
|
+ formmeta: [
|
|
|
+ { name: 'thumbnail', title: '缩略图', slots: 'field' },
|
|
|
+ { name: 'name', title: '专家名称' },
|
|
|
+ { name: 'code', title: '专家编码' },
|
|
|
+ { name: 'ability', title: '擅长领域' },
|
|
|
+ { name: 'money', title: '价格(元)' },
|
|
|
+ { name: 'content', title: '内容', slots: 'field' }
|
|
|
+ ],
|
|
|
+ rules: {
|
|
|
+ money: [
|
|
|
+ { required: true, message: '请输入价格(元)', trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ name: [
|
|
|
+ { required: true, message: '请输入专家名称', trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ code: [
|
|
|
+ { required: true, message: '请输入专家编码', trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ ability: [
|
|
|
+ { required: true, message: '请输入擅长领域室', trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ thumbnail: [
|
|
|
+ { required: true, message: '请上传缩略图', trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ content: [
|
|
|
+ { required: true, message: '请输入内容', trigger: 'blur' }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ defaultProps: {
|
|
|
+ children: 'children',
|
|
|
+ label: 'name'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ ...mapMutations(['setdice']),
|
|
|
+ ...mapActions(['specialistquery', 'specialistcreate', 'specialistupdate', 'specialistdelete', 'specialistdetails']),
|
|
|
+ ...subjectmapActions(['subjectquery']),
|
|
|
+ ...hospitalmapActions(['hospitalquery']),
|
|
|
+ // 选择改变
|
|
|
+ optionschange (e) {
|
|
|
+ this.getsubject({ code: this.options })
|
|
|
+ },
|
|
|
+ // 点击树
|
|
|
+ treeClick (data) {
|
|
|
+ this.is_title = data.name
|
|
|
+ this.data = data
|
|
|
+ this.query()
|
|
|
+ },
|
|
|
+ // 添加
|
|
|
+ async addspecialist () {
|
|
|
+ this.is_data = {
|
|
|
+ hospitalId: this.data.hospitalId,
|
|
|
+ subjectId: this.data.code,
|
|
|
+ subjectName: this.data.name
|
|
|
+ }
|
|
|
+ this.visible = true
|
|
|
+ },
|
|
|
+ // 删除
|
|
|
+ async deletespecialist (e) {
|
|
|
+ this.$confirm('请确认删除', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }).then(async () => {
|
|
|
+ const res = await this.specialistdelete(e)
|
|
|
+ // eslint-disable-next-line eqeqeq
|
|
|
+ if (res.errcode == 0) {
|
|
|
+ this.$message.success('操作成功')
|
|
|
+ this.query()
|
|
|
+ this.$refs.grid.resetpage(-1)
|
|
|
+ }
|
|
|
+ }).catch(() => {
|
|
|
+ this.$message({
|
|
|
+ type: 'info',
|
|
|
+ message: '已取消删除'
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 修改
|
|
|
+ async edit (e) {
|
|
|
+ // await this.columnquery({ filter: {}, paging: {} })
|
|
|
+ await this.specialistdetails({ _id: e._id })
|
|
|
+ this.is_data = { ...this.specialistItem }
|
|
|
+ if (this.specialistItem.thumbnail) this.imageUrl = this.specialistItem.thumbnail
|
|
|
+ this.visible = true
|
|
|
+ },
|
|
|
+ // 查询
|
|
|
+ async query ({ filter = {}, paging = {} } = {}) {
|
|
|
+ filter.subjectId = this.data.code
|
|
|
+ await this.specialistquery({ filter, paging })
|
|
|
+ },
|
|
|
+ // 保存按钮
|
|
|
+ async save (e) {
|
|
|
+ let res
|
|
|
+ if (this.isNew) {
|
|
|
+ // 修改
|
|
|
+ res = await this.specialistupdate(e)
|
|
|
+ } else {
|
|
|
+ // 添加
|
|
|
+ res = await this.specialistcreate(e)
|
|
|
+ }
|
|
|
+ // eslint-disable-next-line eqeqeq
|
|
|
+ if (res.errcode == 0) {
|
|
|
+ this.$message.success('操作成功')
|
|
|
+ this.query()
|
|
|
+ this.$refs.grid.resetpage(-1)
|
|
|
+ this.visible = false
|
|
|
+ this.fileList = []
|
|
|
+ this.imageUrl = ''
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 获取科室
|
|
|
+ async getsubject ({ code }) {
|
|
|
+ const res = await this.subjectquery({ filter: { hospitalId: code }, paging: { page: 1, size: 500 } })
|
|
|
+ this.setdice({ type: 'subject', list: res.data })
|
|
|
+ // 获取字典
|
|
|
+ this.subject = this.$dict('subject')
|
|
|
+ // eslint-disable-next-line eqeqeq
|
|
|
+ if (this.subject.length > 0) {
|
|
|
+ this.is_title = this.subject[0].name
|
|
|
+ this.$refs.deeptree.setCurrentKey(this.subject[0].code)
|
|
|
+ this.data = this.subject[0]
|
|
|
+ this.query()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 关闭弹窗
|
|
|
+ close () {
|
|
|
+ this.visible = false
|
|
|
+ this.fileList = []
|
|
|
+ this.imageUrl = ''
|
|
|
+ },
|
|
|
+ // 图片上传
|
|
|
+ // 文件上传成功时的钩子
|
|
|
+ handleAvatarSuccess (res, file) {
|
|
|
+ this.is_data = { ...this.$refs.ruleForm.form }
|
|
|
+ this.is_data.thumbnail = res.uri
|
|
|
+ this.$refs.ruleForm.formChage('thumbnail', res.uri)
|
|
|
+ this.imageUrl = URL.createObjectURL(file.raw)
|
|
|
+ },
|
|
|
+ imgerror () {
|
|
|
+ this.$message.error('上传失败')
|
|
|
+ },
|
|
|
+ // 上传文件之前的钩子
|
|
|
+ beforeAvatarUpload (file) {
|
|
|
+ const isJPG = file.type === 'image/jpeg'
|
|
|
+ const isPNG = file.type === 'image/png'
|
|
|
+ const isLt2M = file.size / 1024 / 1024 < 2
|
|
|
+
|
|
|
+ if (!isJPG && !isPNG) {
|
|
|
+ this.$message.error('上传图片只能是 JPG 或 PNG 格式!')
|
|
|
+ }
|
|
|
+ if (!isLt2M) {
|
|
|
+ this.$message.error('上传图片大小不能超过 2MB!')
|
|
|
+ }
|
|
|
+ return (isJPG || isPNG) && isLt2M
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async mounted () {
|
|
|
+ await this.hospitalquery({ filter: {}, paging: { page: 1, size: 500 } })
|
|
|
+ this.options = this.hospitalList[0].code
|
|
|
+ this.getsubject({ code: this.options })
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ ...mapState(['total', 'specialistList', 'specialistItem']),
|
|
|
+ ...subjectmapState(['total', 'subjectList', 'subjectItem']),
|
|
|
+ ...hospitalmapState(['total', 'hospitalList', 'hospitalItem']),
|
|
|
+ isNew () {
|
|
|
+ return Boolean(this.is_data && this.is_data._id)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped>
|
|
|
+.container {
|
|
|
+ height: 100%;
|
|
|
+ position: relative;
|
|
|
+ .box-card {
|
|
|
+ height: 100%;
|
|
|
+ /deep/ .el-card__body {
|
|
|
+ height: 100%;
|
|
|
+ padding: 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+.main {
|
|
|
+ display: flex;
|
|
|
+ height: 100%;
|
|
|
+ .left{
|
|
|
+ width: 15%;
|
|
|
+ .select {
|
|
|
+ width: 90%;
|
|
|
+ margin: 5% auto;
|
|
|
+ margin-left: 5%;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .deeptree {
|
|
|
+ width: 15%;
|
|
|
+ height: 100%;
|
|
|
+ padding-top: 1%;
|
|
|
+ }
|
|
|
+ .maincard {
|
|
|
+ width: 85%;
|
|
|
+ height: 100%;
|
|
|
+ padding: 0;
|
|
|
+ margin: 0;
|
|
|
+ /deep/ .el-card__body {
|
|
|
+ height: 100%;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+.box-dj {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ position: absolute;
|
|
|
+ left: 0;
|
|
|
+ top: 0;
|
|
|
+ z-index: 999;
|
|
|
+ /deep/ .el-card__body {
|
|
|
+ height: 90%;
|
|
|
+ overflow-y: auto;
|
|
|
+ width: 100%;
|
|
|
+ .main {
|
|
|
+ width: 60%;
|
|
|
+ margin: 0 auto;
|
|
|
+ margin-bottom: 4em;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+.avatar-uploader {
|
|
|
+ border: 1px dashed #d9d9d9;
|
|
|
+ border-radius: 6px;
|
|
|
+ cursor: pointer;
|
|
|
+ position: relative;
|
|
|
+ overflow: hidden;
|
|
|
+}
|
|
|
+.avatar-uploader .el-upload:hover {
|
|
|
+ border-color: #409EFF;
|
|
|
+}
|
|
|
+.avatar-uploader-icon {
|
|
|
+ font-size: 28px;
|
|
|
+ color: #8c939d;
|
|
|
+ width: 150px;
|
|
|
+ height: 150px;
|
|
|
+ line-height: 150px;
|
|
|
+ text-align: center;
|
|
|
+}
|
|
|
+.avatar {
|
|
|
+ width: 150px;
|
|
|
+ height: 150px;
|
|
|
+ display: block;
|
|
|
+}
|
|
|
+
|
|
|
+</style>
|