diff --git a/src/router/index.js b/src/router/index.js index 95d64c139503b720820b94794cd4abf47ff0ec55..df0a8afb28779154c11b19ff1de82d608b289e99 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -223,7 +223,7 @@ export const routes = [ { path: '/expert/expertBRegister', name: '专家导入', component: () => import('@/views/expert/components/expertImport.vue'), meta: { title: '专家导入', icon: '', noCache: true } }, { path: '/expert/group', name: '专家组管理', component: () => import('@/views/expertGroup/expertBatch.vue'), meta: { title: '专家组管理', icon: '', noCache: true } }, { path: '/expert/group/members', name: '专家组成员管理', component: () => import('@/views/expertGroup/expertGroupMembers.vue'), meta: { title: '专家组成员管理', icon: '', noCache: true } }, - { path: '/expert/report', name: '专家推荐', component: () => import('@/views/expert/index.vue'), meta: { title: '专家推荐', icon: '', noCache: true } }, + { path: '/expert/report', name: '专家推荐', component: () => import('@/views/report/expert/index.vue'), meta: { title: '专家推荐', icon: '', noCache: true } }, ] }, { diff --git a/src/views/report/expert/components/expertEdit.vue b/src/views/report/expert/components/expertEdit.vue new file mode 100644 index 0000000000000000000000000000000000000000..a06efbf61d7fa425e68cdaf523efc5b256d15d46 --- /dev/null +++ b/src/views/report/expert/components/expertEdit.vue @@ -0,0 +1,235 @@ +<template> + <div style="height:420px;overflow:auto;"> + <a-spin :spinning="loading" style="width: 100%;height: 100%;"> + <a-form-model ref="form" :model="formData" :rules="rules" class="from-table"> + <a-row> + <a-col :span="4" class="bg-gray"> + <div class="required">证件号</div> + </a-col> + <a-col :span="20"> + <a-form-model-item ref="certId" prop="certId" v-if="!!!formData.id"> + <a-input v-model="formData.certId" @blur="() => {$refs.certId.onFieldBlur(); }" style="width: 250px" /> + </a-form-model-item> + <a-input disabled="disabled" style="margin-left:6px;width: 250px" v-model="formData.certId" v-if="!!formData.id" /> + </a-col> + </a-row> + <a-row> + <a-col :span="4" class="bg-gray"> + <div class="required">姓名</div> + </a-col> + <a-col :span="20"> + <a-form-model-item ref="personName" prop="personName"> + <a-input v-model="formData.personName" @blur="() => {$refs.personName.onFieldBlur(); }" style="width: 250px" /> + </a-form-model-item> + </a-col> + </a-row> + <a-row> + <a-col :span="4" class="bg-gray"> + <div class="required">性别</div> + </a-col> + <a-col :span="20"> + <a-form-model-item ref="sex" prop="sex"> + <a-select v-model="formData.sex" style="width: 130px" :disabled="!!formData.id"> + <a-select-option value="">--请选择性别--</a-select-option> + <a-select-option value="男">男</a-select-option> + <a-select-option value="女">女</a-select-option> + </a-select> + </a-form-model-item> + </a-col> + </a-row> + <a-row> + <a-col :span="4" class="bg-gray"> + <div class="required">手机号</div> + </a-col> + <a-col :span="20"> + <a-form-model-item ref="mobile" prop="mobile" v-if="!!!formData.id"> + <a-input v-model="formData.mobile" @blur="() => {$refs.mobile.onFieldBlur();}" style="width: 250px" /> + </a-form-model-item> + <a-input disabled="disabled" style="margin-left:6px;width:250px" v-model="formData.mobile" v-if="!!formData.id" /> + </a-col> + </a-row> + <a-row> + <a-col :span="4" class="bg-gray"> + <div class="required">职称</div> + </a-col> + <a-col :span="20"> + <a-form-model-item ref="title" prop="title" :label-col="{ span: 3 }" :wrapper-col="{ span: 21 }"> + <para-multi-select v-model="formData.title" :typeId="7" /> + </a-form-model-item> + </a-col> + </a-row> + <a-row> + <a-col :span="4" class="bg-gray"> + <div class="required">评审专业</div> + </a-col> + <a-col :span="20"> + <a-form-model-item ref="auditSpecList" prop="auditSpecList" :label-col="{ span: 3 }" :wrapper-col="{ span: 21 }"> + <spec-select v-model="formData.auditSpecList" /> + </a-form-model-item> + </a-col> + </a-row> + <a-row v-if="isShow"> + <a-col :span="4" class="bg-gray"> + <div class="required">工作单位</div> + </a-col> + <a-col :span="20"> + <a-form-model-item ref="treeCode" prop="treeCode"> + <unit-tree-select v-model="formData.treeCode" :disable="false" :unitType="2" :width="300" /> + </a-form-model-item> + </a-col> + </a-row> + <a-row> + <a-col :span="4" class="bg-gray" style="padding-left:16px"> + <div> 邮箱</div> + </a-col> + <a-col :span="20"> + <a-form-model-item ref="email" prop="email"> + <a-input v-model="formData.email" @blur="() => {$refs.email.onFieldBlur();}" style="width: 250px" /> + </a-form-model-item> + </a-col> + </a-row> + <a-row> + <a-col :span="4" class="bg-gray" style="padding-left:16px"> + <div>备注</div> + </a-col> + <a-col :span="20"> + <a-form-model-item ref="email" prop="remark"> + <a-input v-model="formData.remark" @blur="() => {$refs.remark.onFieldBlur();}" style="width: 250px" /> + </a-form-model-item> + </a-col> + </a-row> + <a-row> + <a-col :span="24" style="text-align:center;"> + <a-button type="primary" style="margin-right: 50px" @click="submit">提交</a-button> + </a-col> + </a-row> + </a-form-model> + </a-spin> + </div> +</template> + +<script> +import { isEmptyParams, checkEmail, checkPhone, checkIdentitytionId, personBirthday, personGender } from "@/views/utils/common" +import { isIdentityId } from '@/views/utils/validate' +import moment from 'moment' +import specSelect from '@/views/expert/components/specSelect' +import paraMultiSelect from '@/views/components/common/paraMultiSelect' +import paraSelect from '@/views/components/common/paraSelect' +import baseSelect from '@/views/components/common/baseSelect' +import unitSelect from '@/views/components/common/unitSelect' +import unitTreeSelect from '@/views/components/common/unitTreeSelect' + +export default { + name: 'expertEdit', + components: { + paraMultiSelect, paraSelect, baseSelect, unitSelect, specSelect, unitTreeSelect + }, + data () { + return { + loading: true, + isShow: false, + formData: { id: null, personName: null, sex: '', birthday: null, certId: null, mobile: null, remark: null, email: null, title: null, auditSpecList: [], treeCode: null }, + rules: { + certId: [ + { required: true, message: '请输入证件号', trigger: 'blur' }, + { + validator: (rule, value, callback) => { + if (value == '' || value == undefined) { + callback() + } + var errorMsg = isIdentityId(value); + if (errorMsg != "") { + callback(new Error(errorMsg)); + } else { + let pars = { certId: this.formData.certId, id: this.formData.id } + this.$api.expert.expertIsExist(pars).then(({ data = {} }) => { + if (data) { + callback(new Error("专家已存在")); + } else { + this.formData.sex = personGender(this.formData.certId) + this.formData.birthday = personBirthday(this.formData.certId) + ' 00:00:00' + callback() + } + }) + } + } + } + ], + mobile: [ + { required: true, message: '请输入手机号', trigger: 'blur' }, + { required: true, validator: checkPhone, trigger: 'blur' } + ], + email: [ + { required: false, message: '请输入邮箱', trigger: 'blur' }, + { required: false, validator: checkEmail, trigger: 'blur' } + ], + personName: [{ required: true, message: '请输入姓名', trigger: 'blur' }], + sex: [{ required: true, message: '请选择性别', trigger: 'change' }], + auditSpecList: [{ required: true, message: '请选择评审专业', trigger: 'change' }], + title: [{ required: true, message: '请选择职称', trigger: 'change' }], + treeCode: [{ required: false, message: '请选择单位', trigger: 'change' }], + remark: [{ required: false, message: '请输入备注', trigger: 'blur' }], + }, + } + }, + props: { + value: { + type: String, + default: () => { + return null + } + }, + }, + created () { + let user = JSON.parse(window.sessionStorage.getItem('user')) + if (user && user.roles) { + if (user.roles.indexOf("0") != -1) { + this.isShow = true + } + } + if (this.value) + this.getExpertById() + else + this.loading = false + }, + methods: { + moment, + getExpertById () { + this.$api.expert.getExpertById({ id: this.value }).then(({ data = {} }) => { + if (data) { + this.formData = data + } + this.loading = false + }).catch(() => { this.loading = false }) + }, + submit () { + this.$refs.form.validate(valid => { + if (valid) { + this.loading = true + let pars = isEmptyParams(this.formData) + let par = { ...pars } + if (!!!this.formData.id) { + this.$api.expert.insert(par).then(({ data = {} }) => { + if (data) { + this.$message.success('成功!') + this.$emit('close', 'edit') + } + this.loading = false + }).catch(() => { this.loading = false }) + } else { + this.$api.expert.update(par).then(({ data = {} }) => { + if (data) { + this.$message.success('成功!') + this.$emit('close', 'edit') + } + this.loading = false + }).catch(() => { this.loading = false }) + } + } else { + return false + } + }) + }, + } +} +</script> \ No newline at end of file diff --git a/src/views/report/expert/components/expertImport.vue b/src/views/report/expert/components/expertImport.vue new file mode 100644 index 0000000000000000000000000000000000000000..0da2df0d109f441564117d5025859eb8ccbadefa --- /dev/null +++ b/src/views/report/expert/components/expertImport.vue @@ -0,0 +1,127 @@ +<template> + <div class="app-content" style="height:75vh;overflow: auto;"> + <div class="submit-btn upload-header"> + <a :href="url.downloadUrl" download="ExpertInfo.xlsx"> + <a-icon type="download"></a-icon> <span style="color:green;text-decoration:underline;">模板下载</span> + </a> + <FileUpload @beforeUpload="beforeUpload" /> + <a-divider style="height: 1px; background-color: #e8e8e8;" /> + </div> + <a-divider style="height: 1px; background-color: #e8e8e8;" /> + <div class="upload-table"> + <a-table :dataSource="tableData" :columns="columns" rowKey="index" :pagination="false" :loading="loading"> + <template slot="stateSwitch" slot-scope="record"> + <a-switch checked-children="正常" un-checked-children="注销" :checked="checkedState(record)" @change="switchChange($event, record)" /> + </template> + <template slot="option" slot-scope="record"> + <a-button type="primary" size="small" @click="recordClick(record, 'view')">查看</a-button> + <a-button type="primary" size="small" @click="recordClick(record, 'edit')">修改</a-button> + <a-button type="primary" size="small" @click="recordClick(record, 'reset')">重置密码</a-button> + </template> + </a-table> + </div> + <div class="upload-bottom" style="text-align:center;padding:6px 0"> + <a-button type="primary" @click="dataImport" :disabled="disabled">导入</a-button> + </div> + </div> +</template> +<script> +import { isEmptyParams, readExcelFile, personGender, personBirthday, checkIdentitytionId, checkEmail, checkPhone } from "@/views/utils/common" +import moment from "moment" + +export default { + name: "expertImport", + data () { + return { + columns: [ + { title: "姓名", dataIndex: "personName", align: 'center' }, + { title: "证件号", dataIndex: "certId", align: 'center' }, + // { title: "性别", dataIndex: "sex" }, + // { title: "出生日期", dataIndex: 'birthday' }, + { title: "手机号", dataIndex: "mobile", align: 'center' }, + { title: "邮箱", dataIndex: "email", align: 'center' }, + { title: "职称", dataIndex: "titleName", align: 'center' }, + { title: "专业", dataIndex: "specName", align: 'center' }, + { title: '单位', dataIndex: 'unitName', align: 'center' }, + ], + tableData: [], + disabled: true, + loading: false, + url: { + downloadUrl: '/downloadFile/ExpertInfo.xlsx', + } + }; + }, + created () { + + }, + methods: { + beforeUpload (file) { + this.tableData = [] + let list = readExcelFile(file, 0) + let certList = [] + let mobileList = [] + let exportList = [] + + list.then((d) => { + //读取文件数据 + d.forEach(e => { + let gender = personGender(e.证件号) + let birthday = personBirthday(e.证件号) + ' 00:00:00' + let expert = { personName: e.姓名, certId: e.证件号, sex: gender, birthday: moment(birthday).format('YYYY-MM-DD HH:mm:ss'), mobile: e.手机号, email: e.邮箱, specName: e.专业, titleName: e.职称, unitName: e.单位 } + exportList.push(expert) + certList.push(e.证件号) + mobileList.push(e.手机号) + }) + + let uniqueMobileList = [...new Set(mobileList)] + if (uniqueMobileList.length != exportList.length) { + this.$message.error('手机号出现重复!') + return false + } + + let uniqueCertList = [...new Set(certList)] + if (uniqueCertList.length != exportList.length) { + this.$message.error('证件号出现重复!') + return false + } + + if (exportList.length > 0) { + this.tableData = exportList + this.disabled = false + } + }) + + return false + }, + dataImport () { + if (this.tableData.length == 0) { + this.$message.error('请选择Excel!') + return + } + let pars = isEmptyParams(this.tableData) + let par = { ...pars } + this.$api.expert.expertImport(this.tableData).then(({ data = {} }) => { + if (data) { + this.$message.info(data) + this.tableData = [] + } + }) + } + }, +}; +</script> +<style scoped lang="less"> +.upload-header { + height: 30px; +} +.upload-table { + min-height: 150px; + max-height: calc(100% - 75px); + overflow-y: auto; +} +.upload-bottom { + height: 42px; +} +</style> + diff --git a/src/views/report/expert/components/expertView.vue b/src/views/report/expert/components/expertView.vue new file mode 100644 index 0000000000000000000000000000000000000000..f9d7919b1272cfd2818df57c5e97b0aac6da7a41 --- /dev/null +++ b/src/views/report/expert/components/expertView.vue @@ -0,0 +1,105 @@ +<template> + <div class="from-table" style="height:280px;overflow:auto;"> + <a-spin :spinning="loading" style="width: 100%;height: 100%;"> + <a-row> + <a-col :span="4" class="bg-gray"> + 姓名: + </a-col> + <a-col :span="8"> + {{expertInfo.personName}} + </a-col> + <a-col :span="4" class="bg-gray"> + 证件号: + </a-col> + <a-col :span="8"> + {{expertInfo.certId}} + </a-col> + </a-row> + <a-row> + <a-col :span="4" class="bg-gray"> + 性别: + </a-col> + <a-col :span="8"> + {{expertInfo.sex}} + </a-col> + <a-col :span="4" class="bg-gray"> + 职称: + </a-col> + <a-col :span="8"> + {{expertInfo.titleName}} + </a-col> + </a-row> + <a-row> + <a-col :span="4" class="bg-gray"> + 联系电话: + </a-col> + <a-col :span="8"> + {{expertInfo.mobile}} + </a-col> + <a-col :span="4" class="bg-gray"> + 邮箱: + </a-col> + <a-col :span="8"> + {{expertInfo.email}} + </a-col> + </a-row> + <a-row> + <a-col :span="4" class="bg-gray"> + 专业: + </a-col> + <a-col :span="20"> + <a-tag v-for="data in expertInfo.specList" :key="data.id" :color="'green'">{{data.specName}}</a-tag> + </a-col> + </a-row> + <a-row> + <a-col :span="4" class="bg-gray"> + 工作单位: + </a-col> + <a-col :span="20"> + {{expertInfo.workUnit}} + </a-col> + </a-row> + </a-spin> + </div> +</template> +<script> +import moment from 'moment' + +export default { + name: "expertView", + data () { + return { + expertInfo: { id: '', certId: '', sex: '', birthday: null, mobile: '', email: '', title: '', unitId: null, degree: null, spec: null, address: '' }, + loading: true + } + }, + props: { + value: { + type: String, + default: () => { + return null + } + }, + obj: { + type: Object + } + }, + created () { + this.getExpertById() + }, + methods: { + moment, + getExpertById () { + let pars = { id: this.value } + this.$api.expert.getExpertById(pars).then(({ data = {} }) => { + if (data) { + this.expertInfo = data + } + this.loading = false + }).catch(() => { + this.loading = false + }) + } + } +} +</script> \ No newline at end of file diff --git a/src/views/report/expert/components/specSelect.vue b/src/views/report/expert/components/specSelect.vue new file mode 100644 index 0000000000000000000000000000000000000000..0032ce8132308cd2d0a313052d9063cd5f2532c1 --- /dev/null +++ b/src/views/report/expert/components/specSelect.vue @@ -0,0 +1,71 @@ +<template> + <div style="width:auto;display:inline-block !important; display:inline;"> + <a-select mode="tags" v-model="selected" style="width: 400px" @change="onChange" showArrow allowClear> + <a-select-opt-group v-for="item in selectArray" :key="item.key"> + <span slot="label"> + <a-icon type="bars" />{{ item.title }} + </span> + <a-select-option v-for="arr in item.children" :key="arr.key" :value="arr.key"> + {{ arr.title }} + </a-select-option> + </a-select-opt-group> + </a-select> + </div> +</template> +<script> +// 用法 <spec-select v-model="formData.projClass" /> +export default { + name: "SpecSelect", + data () { + return { + selectArray: [], + selected: [], + loadState: false, + }; + }, + props: { + value: null, + width: { + type: Number, + default () { + return 180 + } + } + }, + created () { + this.load(this.value) + }, + methods: { + load (value) { + if (this.selectArray.length > 0) { + this.selected = value + } else { + this.$api.parameter.getArrayListByType({ typeId: 56 }).then(({ data = {} }) => { + if (data) { + this.selectArray = data + this.selected = value + } + }).catch(() => { }) + } + }, + onChange () { + if (this.selected.length > 3) { + this.$message.error('最多只能选三个专业') + this.selected = this.selected.splice(0, 3) + } + this.$emit("input", this.selected); + this.$emit("change"); + }, + }, + watch: { + value: { + handler (value) { + if (!this.loadState) { + this.load(value) + this.loadState = true + } + } + }, + }, +}; +</script> diff --git a/src/views/report/expert/index.vue b/src/views/report/expert/index.vue new file mode 100644 index 0000000000000000000000000000000000000000..f07b4d243d1759722016d50cf38321b26e57dc3f --- /dev/null +++ b/src/views/report/expert/index.vue @@ -0,0 +1,288 @@ +<template> + <div class="app-content"> + <a-form :form="form" :model="searchForm" layout="inline" class="search_form"> + <a-form-item> + <a-input v-model="searchForm.personName" placeholder="姓名" :maxLength="100" style="width: 130px" /> + </a-form-item> + <a-form-item> + <a-input v-model="searchForm.certId" placeholder="证件号" :maxLength="100" style="width: 150px" /> + </a-form-item> + <a-form-item> + <a-select v-model="searchForm.sex" style="width: 130px"> + <a-select-option value="">--请选择性别--</a-select-option> + <a-select-option value="男">男</a-select-option> + <a-select-option value="女">女</a-select-option> + </a-select> + </a-form-item> + <a-form-item v-if="isShow"> + <a-input v-model="searchForm.unitName" placeholder="单位" :maxLength="100" style="width: 130px" /> + </a-form-item> + <a-form-item> + <a-input v-model="searchForm.username" placeholder="用户名" :maxLength="100" style="width: 130px" /> + </a-form-item> + <a-form-item> + <a-input v-model="searchForm.remark" placeholder="备注" :maxLength="100" style="width: 130px" /> + </a-form-item> + <a-form-item> + <para-multi-select v-model="searchForm.title" @parentChange="titleChange" :title="'职称'" :objType="'project'" :typeId="7" :width="150" /> + </a-form-item> + <a-form-item> + <para-multi-select v-model="searchForm.spec" @parentChange="specChange" :title="'评审专业'" :objType="'project'" :typeId="57" :width="150" /> + </a-form-item> + <a-form-item> + <a-button type="primary" icon="search" @click="search">搜索</a-button> + <a-button icon="reload" style="margin-left: 10px" @click="reset" class="bt-normal">重置</a-button> + </a-form-item> + </a-form> + <a-divider style="height: 1px; background-color: #e8e8e8;" /> + <div class="submit-btn"> + <a-button type="primary" @click="addExpert">添加专家</a-button> + <a-button type="primary" @click="importExcel" v-if="isShow">导入</a-button> + <a-button type="primary" @click="exporExcel">导出excel</a-button> + </div> + <a-table :dataSource="tableData" :columns="columns" rowKey="id" :pagination="false" :loading="loading"> + <template slot="personName" slot-scope="record"> + <a @click="recordClick(record,'view')">{{record.personName}}</a> + </template> + <template slot="spec" slot-scope="record"> + <span v-for="data in record.specList" :key="data.id" :color="'green'">{{data.specName+' '}}</span> + </template> + <template slot="stateSwitch" slot-scope="record"> + <a-switch checked-children="启用" un-checked-children="停用" :checked="checkedState(record)" @change="switchChange($event,record)" /> + </template> + <template slot="option" slot-scope="record"> + <a-button type="link" size="small" @click="recordClick(record,'edit')">修改</a-button> + <a-button type="link" size="small" @click="recordClick(record,'reset')">重置密码</a-button> + <a-button type="link" size="small" @click="recordClick(record,'report')">上报</a-button> + <a-button type="link" size="small" @click="recordClick(record,'del')">删除</a-button> + </template> + </a-table> + <a-pagination v-if="pagination.total > 0" :total="pagination.total" show-size-changer show-quick-jumper v-model="pagination.pageIndex" :page-size="pagination.pageSize" :page-size-options="pagination.pageSizeOptions" @showSizeChange="showSizeChange" @change="change" :showTotal="() => `共 ${pagination.total} 条`" /> + <a-modal v-model="visibleView" title="查看" width="700px" :dialog-style="{ top: '15%' }" :footer="null" destroyOnClose> + <expert-view v-model="id"></expert-view> + </a-modal> + <a-modal v-model="visibleEdit" title="添加/修改" width="850px" :dialog-style="{ top: '15%' }" :footer="null" destroyOnClose> + <expert-edit v-model="id" @close="closeWindow"></expert-edit> + </a-modal> + <a-modal v-model="visibleImport" title="专家导入" width="80%" :dialog-style="{ top: '8%' }" :footer="null" destroyOnClose> + <expert-import /> + </a-modal> + </div> +</template> + +<script> +import { isEmptyParams, filterExportExcelData, tableColumnsName } from "@/views/utils/common"; +import moment from 'moment'; +import expertView from './components/expertView' +import expertEdit from './components/expertEdit'; +import expertImport from './components/expertImport'; +import paraMultiSelect from '@/views/components/common/paraMultiSelect' +export default { + name: 'expertManager', + components: { expertView, expertEdit, expertImport, paraMultiSelect }, + data () { + return { + form: this.$form.createForm(this, { name: 'advanced_search' }), + searchForm: { personName: null, certId: null, sex: '', unitName: null, workUnit: null, username: null, remark: null, title: null, titleParentId: null, spec: null, specParentId: null }, + tableData: [], + columns: [ + { title: "姓名", scopedSlots: { customRender: 'personName', colName: 'personName' }, align: 'center' }, + { title: '证件号', dataIndex: 'certId', align: 'center' }, + { title: '性别', dataIndex: 'sex', align: 'center' }, + { title: '职称', dataIndex: 'titleName', align: 'center' }, + { title: '评审专业', scopedSlots: { customRender: 'spec' }, width: '10%', }, + { title: '单位', dataIndex: 'unitName', align: 'center' }, + { title: '用户名', dataIndex: 'username', align: 'center' }, + { title: '状态', scopedSlots: { customRender: 'stateSwitch' }, align: 'center' }, + { title: '操作', scopedSlots: { customRender: 'option' }, align: 'center', fixed: 'right', width: '180px', }, + ], + excelCol: [ + { title: "姓名", scopedSlots: { customRender: 'personName', colName: 'personName' }, align: 'center' }, + { title: '证件号', dataIndex: 'certId', align: 'center' }, + { title: '性别', dataIndex: 'sex', align: 'center' }, + { title: '手机号', dataIndex: 'mobile', align: 'center' }, + { title: '邮箱', dataIndex: 'email', align: 'center' }, + { title: '职称', dataIndex: 'titleName', align: 'center' }, + { title: '评审专业', dataIndex: 'specName', width: '10%', }, + { title: '单位', dataIndex: 'unitName', align: 'center' }, + { title: '用户名', dataIndex: 'username', align: 'center' }, + ], + pagination: { pageIndex: 1, pageSize: this.$defaultPageSize, total: 0, pageSizeOptions: this.$defaultPageSizeOptions, }, + loading: false, + // 弹窗 + visibleView: false, + visibleEdit: false, + visibleImport: false, + isShow: false, + id: null + } + }, + created () { + let user = JSON.parse(window.sessionStorage.getItem('user')) + if (user && user.roles) { + if (user.roles.indexOf("0") != -1) { + this.isShow = true + } + } + this.getListByPage() + }, + methods: { + search () { + this.pagination.pageIndex = 1 + this.getListByPage() + }, + reset () { + this.searchForm = { personName: null, certId: null, sex: '', unitName: null, workUnit: null, username: null, remark: null, title: null, titleParentId: null, spec: null, specParentId: null } + this.pagination.pageIndex = 1 + this.getListByPage() + }, + getListByPage () { + this.loading = true + let pars = isEmptyParams(this.searchForm) + let par = { ...pars, pageIndex: this.pagination.pageIndex, pageSize: this.pagination.pageSize } + this.$api.expert.getListByPage(par).then(({ data = {} }) => { + if (data) { + const { dataList = [], total = 0 } = data + this.tableData = dataList + this.pagination.total = total + } + this.loading = false + }).catch(() => { this.loading = false }) + }, + change () { + this.getListByPage() + }, + showSizeChange (current, pageSize) { + this.pagination.pageSize = pageSize + this.getListByPage() + }, + importExcel () { + this.visibleImport = true; + }, + exporExcel () { + this.loading = true + let pars = isEmptyParams(this.searchForm) + let par = { ...pars, pageIndex: -1, pageSize: -1 } + this.$api.expert.getListByPage(par).then(({ data = {} }) => { + if (data) { + const { dataList = [], total = 0 } = data + this.$ToDoExcel(`专家列表`, tableColumnsName(this.excelCol), filterExportExcelData(this.excelCol, dataList)) + } + this.loading = false + }).catch(() => { this.loading = false }) + }, + titleChange (value) { + this.searchForm.titleParentId = value + }, + specChange (value) { + this.searchForm.specParentId = value + }, + moment, + recordClick (record, type) { + if (type === 'view') { + this.id = record.id + this.visibleView = true + } else if (type === 'edit') { + this.id = record.id + this.visibleEdit = true + } + else if (type === 'reset') { + this.resetPwd(record) + } + else if (type === 'del') { + this.deleteExpert(record.id, record.userRoleId) + } + else if (type === 'report') { + let request={...record} + request.reportState=2 + this.$api.expert.update(request).then(({ data = {} }) => { + if (data) { + this.$message.success('上报成功!') + this.getListByPage() + } + this.loading = false + }).catch(() => { this.loading = false }) + } + }, + resetPwd (record) { + let self = this + this.$confirm({ + title: '重置密码', + content: '重置后密码为"kycz123456"确定要重置密码?', + okText: '确定', + okType: 'danger', + cancelText: '取消', + onOk () { + self.loading = true + let par = { id: record.userId } + self.$api.systemUser.resetUserPwd(par).then(({ data = {} }) => { + if (data) { + self.$message.success('重置成功!') + self.getListByPage() + } + self.loading = false + }).catch(() => { self.loading = false }) + }, + onCancel () { + }, + }) + }, + checkedState (record) { + return record.expertStateName === "启用" ? true : false + }, + switchChange (checked, record) {//启用/停用单位开关 + if (checked) { + record.expertStateName = "启用"; + record.expertState = 1; + } else { + record.expertStateName = "停用"; + record.expertState = 2; + } + this.loading = true + let par = { id: record.id, userRoleId: record.userRoleId, expertState: record.expertState } + this.$api.expert.updateExpertState(par).then(({ data = {} }) => { + if (data) { + this.$message.success('修改成功!') + } + this.loading = false + }).catch(() => { this.loading = false }) + }, + closeWindow (value) { + if (value === 'edit') { + this.visibleEdit = false + this.getListByPage() + } + else + this.visibleView = false + }, + addExpert () { + this.visibleEdit = true + this.id = null + }, + deleteExpert (id, userRoleId) { + let self = this + this.$confirm({ + title: '管理员删除', + content: '确定要删除该管理员?', + okText: '确定', + okType: 'danger', + cancelText: '取消', + onOk () { + self.loading = true + self.$api.expert.deleteExpert({ id: id, userRoleId: userRoleId }).then(({ data = {} }) => { + if (data) { + self.$message.success('删除成功') + self.getListByPage() + } + self.loading = false + }).catch(() => { + self.loading = false + }) + }, + onCancel () { + }, + }) + }, + } +} +</script> \ No newline at end of file