diff --git a/package-lock.json b/package-lock.json index c4ab7c1..bfc9dbe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9613,9 +9613,9 @@ } }, "lodash": { - "version": "4.17.15", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, "lodash._basecopy": { "version": "3.0.1", diff --git a/package.json b/package.json index c6d9599..f5db8c1 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "element-ui": "^2.13.0", "image-conversion": "^2.1.1", "js-cookie": "^2.2.1", + "lodash": "^4.17.21", "mavon-editor": "^2.6.17", "postcss-px2rem": "^0.3.0", "px2rem-loader": "^0.1.9", diff --git a/src/api/index.js b/src/api/index.js index a40533b..0504505 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -2,85 +2,90 @@ import Setting from '@/setting' const host = Setting.apiBaseURL export default { - logins: `iasf/sys/user/login`, - verification: `${host}iasf/sys/getVerify`, - upload: `${host}iasf/sysFiles/upload`, - listByPage: `iasf/sysFiles/listByPage`, - delFile: `iasf/sysFiles/delete`, - updateFile: `iasf/sysFiles/update`, - dept: `iasf/sys/dept`, - deptTree: `iasf/sys/dept/tree`, - depts: `iasf/sys/dept/tree`, - users: `iasf/sys/users`, - user: `iasf/sys/user`, - sendPhoneOrEmailCode: `iasf/sys/sendPhoneOrEmailCode`, - updatePhoneOrEmail: `iasf/sys/updatePhoneOrEmail`, - updateUserAvatars: `${host}iasf/sys/updateUserAvatars`, + logins: `/iasf/sys/user/login`, + verification: `${host}/iasf/sys/getVerify`, + upload: `${host}/iasf/sysFiles/upload`, + listByPage: `/iasf/sysFiles/listByPage`, + delFile: `/iasf/sysFiles/delete`, + updateFile: `/iasf/sysFiles/update`, + dept: `/iasf/sys/dept`, + deptTree: `/iasf/sys/dept/tree`, + depts: `/iasf/sys/dept/tree`, + users: `/iasf/sys/users`, + user: `/iasf/sys/user`, + sendPhoneOrEmailCode: `/iasf/sys/sendPhoneOrEmailCode`, + updatePhoneOrEmail: `/iasf/sys/updatePhoneOrEmail`, + updateUserAvatars: `${host}/iasf/sys/updateUserAvatars`, staffTemplate: `http://139.159.254.212/用户导入模板.xlsx`, - checkJobNumber: `iasf/sys/checkJobNumber`, - checkUsername: `iasf/sys/checkUsername`, - resetPwd: `iasf/sys/resetPwd`, - pwd: `iasf/sys/user/pwd`, - exportFailure: `${host}iasf/sys/exportFailure`, - importStaff: `${host}iasf/sys/importStaff`, - roles: `iasf/sys/roles`, - role: `iasf/sys/role`, - deleteRole: `iasf/sys/role/deleted`, - perTree: `iasf/sys/permission/tree/all`, - groupAdd: `iasf/sys/userGroup/add`, - groupDel: `iasf/sys/userGroup/delete`, - groupList: `iasf/sys/userGroup/list`, - groupUpdate: `iasf/sys/userGroup/update`, - site: `iasf/sys/site/list`, - updateSite: `iasf/sys/site/update`, - delSite: `iasf/sys/site/delete`, - listWithTree: `iasf/sysColumn/listWithTree`, - saveColumn: `iasf/sysColumn/save`, - updateColumn: `iasf/sysColumn/update`, - findColumn: `iasf/sysColumn/findById`, - deleteColumn: `iasf/sysColumn/batchDeletion`, - sameLevelJudgment: `iasf/sysColumn/sameLevelJudgment`, - sortByColumn: `iasf/sysColumn/sortByColumn`, - checkIfTheTitleIsRepeat: `iasf/sysContent/checkIfTheTitleIsRepeat`, - deleteArticle: `iasf/sysContent/batchDeletion`, - findArticle: `iasf/sysContent/findById`, - queryArticle: `iasf/sysContent/pagingQuery`, - articleEnableOrDisable: `iasf/sysContent/articleEnableOrDisable`, - saveArticle: `iasf/sysContent/save`, - updateArticle: `iasf/sysContent/update`, - modifiedSort: `iasf/sysContent/modifiedSort`, - longPageColumnList: `iasf/pageManagement/longPageColumnList`, - searchAllBySite: `iasf/sysNavigationStyle/searchAllBySite`, - updateStyle: `iasf/sysNavigationStyle/update`, - saveStyle: `iasf/sysNavigationStyle/save`, - findPage: `iasf/sysColumnLongPage/getLongPageInformation`, - getRedisPage: `iasf/sysColumnLongPage/getRedisCache`, - savePage: `iasf/sysColumnLongPage/save`, - saveRedisPage: `iasf/sysColumnLongPage/saveTheCache`, - updatePage: `iasf/sysColumnLongPage/update`, - listOfColumnTemplates: `iasf/template/listOfColumnTemplates`, - theTemplateIdGetsTheStyle: `iasf/template/theTemplateIdGetsTheStyle`, - queryClassif: `iasf/content/classification/allTheQuery`, - delClassif: `iasf/content/classification/delete`, - checkClassif: `iasf/content/classification/checkForHeavy`, - saveClassif: `iasf/content/classification/save`, - updateClassif: `iasf/content/classification/update`, - checkLabel: `iasf/content/label/checkForHeavy`, - delLabel: `iasf/content/label/delete`, - checkLabel: `iasf/content/label/checkForHeavy`, - queryLabel: `iasf/content/label/queryAllArticleSubjectTags`, - saveLabel: `iasf/content/label/save`, - updateLabel: `iasf/content/label/update`, - delContentFile: `iasf/content/file/delete`, - saveContentFile: `iasf/content/file/save`, - theAttachmentUnderTheQueryColumn: `iasf/content/file/theAttachmentUnderTheQueryColumn`, - individualTemplateDetailsStyle: `iasf/template/individualTemplateDetailsStyle`, - longPageListStyle: `iasf/template/longPageListStyle`, - resort: `iasf/sysContent/sort`, - articleTopOperation: `iasf/sysContent/articleTopOperation`, - deleteUselessData: `iasf/sysColumn/deleteUselessData`, - addSeo: `iasf/seo/add`, - delSeo: `iasf/seo/delete`, - seoList: `iasf/seo/list`, - updateSeo: `iasf/seo/update`, + checkJobNumber: `/iasf/sys/checkJobNumber`, + checkUsername: `/iasf/sys/checkUsername`, + resetPwd: `/iasf/sys/resetPwd`, + pwd: `/iasf/sys/user/pwd`, + exportFailure: `${host}/iasf/sys/exportFailure`, + importStaff: `${host}/iasf/sys/importStaff`, + roles: `/iasf/sys/roles`, + role: `/iasf/sys/role`, + deleteRole: `/iasf/sys/role/deleted`, + perTree: `/iasf/sys/permission/tree/all`, + groupAdd: `/iasf/sys/userGroup/add`, + groupDel: `/iasf/sys/userGroup/delete`, + groupList: `/iasf/sys/userGroup/list`, + groupUpdate: `/iasf/sys/userGroup/update`, + site: `/iasf/sys/site/list`, + updateSite: `/iasf/sys/site/update`, + delSite: `/iasf/sys/site/delete`, + listWithTree: `/iasf/sysColumn/listWithTree`, + saveColumn: `/iasf/sysColumn/save`, + updateColumn: `/iasf/sysColumn/update`, + findColumn: `/iasf/sysColumn/findById`, + deleteColumn: `/iasf/sysColumn/batchDeletion`, + sameLevelJudgment: `/iasf/sysColumn/sameLevelJudgment`, + sortByColumn: `/iasf/sysColumn/sortByColumn`, + checkIfTheTitleIsRepeat: `/iasf/sysContent/checkIfTheTitleIsRepeat`, + deleteArticle: `/iasf/sysContent/batchDeletion`, + findArticle: `/iasf/sysContent/findById`, + queryArticle: `/iasf/sysContent/pagingQuery`, + articleEnableOrDisable: `/iasf/sysContent/articleEnableOrDisable`, + saveArticle: `/iasf/sysContent/save`, + updateArticle: `/iasf/sysContent/update`, + modifiedSort: `/iasf/sysContent/modifiedSort`, + longPageColumnList: `/iasf/pageManagement/longPageColumnList`, + searchAllBySite: `/iasf/sysNavigationStyle/searchAllBySite`, + updateStyle: `/iasf/sysNavigationStyle/update`, + saveStyle: `/iasf/sysNavigationStyle/save`, + findPage: `/iasf/sysColumnLongPage/getLongPageInformation`, + getRedisPage: `/iasf/sysColumnLongPage/getRedisCache`, + savePage: `/iasf/sysColumnLongPage/save`, + saveRedisPage: `/iasf/sysColumnLongPage/saveTheCache`, + updatePage: `/iasf/sysColumnLongPage/update`, + listOfColumnTemplates: `/iasf/template/listOfColumnTemplates`, + theTemplateIdGetsTheStyle: `/iasf/template/theTemplateIdGetsTheStyle`, + queryClassif: `/iasf/content/classification/allTheQuery`, + delClassif: `/iasf/content/classification/delete`, + checkClassif: `/iasf/content/classification/checkForHeavy`, + saveClassif: `/iasf/content/classification/save`, + updateClassif: `/iasf/content/classification/update`, + checkLabel: `/iasf/content/label/checkForHeavy`, + delLabel: `/iasf/content/label/delete`, + checkLabel: `/iasf/content/label/checkForHeavy`, + queryLabel: `/iasf/content/label/queryAllArticleSubjectTags`, + saveLabel: `/iasf/content/label/save`, + updateLabel: `/iasf/content/label/update`, + delContentFile: `/iasf/content/file/delete`, + saveContentFile: `/iasf/content/file/save`, + theAttachmentUnderTheQueryColumn: `/iasf/content/file/theAttachmentUnderTheQueryColumn`, + individualTemplateDetailsStyle: `/iasf/template/individualTemplateDetailsStyle`, + longPageListStyle: `/iasf/template/longPageListStyle`, + resort: `/iasf/sysContent/sort`, + articleTopOperation: `/iasf/sysContent/articleTopOperation`, + deleteUselessData: `/iasf/sysColumn/deleteUselessData`, + addSeo: `/iasf/seo/add`, + delSeo: `/iasf/seo/delete`, + seoList: `/iasf/seo/list`, + updateSeo: `/iasf/seo/update`, + batchDeletionFloating: `/iasf/SysFloatingColumnSchemeService/SysFloatingColumnScheme/batchDeletion`, + findFloating: `/iasf/SysFloatingColumnSchemeService/SysFloatingColumnScheme/findById`, + listFloating: `/iasf/SysFloatingColumnSchemeService/SysFloatingColumnScheme/floatingBarList`, + saveFloating: `/iasf/SysFloatingColumnSchemeService/SysFloatingColumnScheme/saveOrUpdate`, + enableOrDisableScheme: `/iasf/SysFloatingColumnSchemeService/SysFloatingColumnScheme/enableOrDisableScheme`, } \ No newline at end of file diff --git a/src/layouts/header/index.vue b/src/layouts/header/index.vue index c984ea0..795cded 100644 --- a/src/layouts/header/index.vue +++ b/src/layouts/header/index.vue @@ -2,36 +2,28 @@
- +
- +
- - {{userName}} + + {{ userName }}
个人资料 @@ -52,7 +44,7 @@ export default { sites: [], crumbRefresh: true, inContent: false, // 是否显示站点切换 - sitePath: ['/page', '/column', '/article'] + sitePath: ['/page', '/column', '/article', '/seo', '/floatingFrame'] }; }, components: { @@ -127,63 +119,75 @@ export default { \ No newline at end of file diff --git a/src/layouts/navbar/index.vue b/src/layouts/navbar/index.vue index 9828ae4..b4784c2 100644 --- a/src/layouts/navbar/index.vue +++ b/src/layouts/navbar/index.vue @@ -1,115 +1,73 @@ @@ -208,47 +136,67 @@ import Setting from '@/setting' import Util from '@/libs/util' import Axios from 'axios' +import Cropper from '@/components/img-upload/Cropper' import Editor from '@tinymce/tinymce-vue' import editorConfig from '@/components/editor' +import _ from 'lodash' export default { data () { return { editorConfig, siteId: this.$store.state.content.site.id, siteName: this.$store.state.content.site.siteName, - templates: [], - listStyle: [], - pageStyle: [], - detailStyle: [], keyword: '', searchTimer: null, list: [], + page: 1, + pageSize: 10, + total: 0, multipleSelection: [], listLoading: false, - styleVisible: false, - ranges: [], - moduleForm: { - id: '', - columnName: '', - navigationStyle: 1, - styleTemplate: 1, - siteId: this.$store.state.content.site.id + range: 0, + selectColumn: [], + columns: [], + columnProps: { + multiple: true, + value: 'id', + label: 'columnName' }, - moduleRules: { - columnName: [ + originForm: {}, + form: { + editorId: this.$store.state.user.userId, + schemeName: '', + floatingBarStyle: '1', + siteId: this.$store.state.content.site.id, + floatingColumnSchemeModules: [], + floatingColumnSchemeScopeOfApplications: [], + }, + originModules: { + pictureAddress: '', + schemeContentJson: '', + schemeTitle: '', + isDisable: 0, + }, + rules: { + schemeName: [ { required: true, message: '请输入悬浮栏目名称', trigger: 'blur' } ], }, moduleVisible: false, - modules: [{}], + modules: [], curRow: {}, curModule: 0, contentVisible: false, - contentForm: {}, contentRules: { - columnName: [ - { required: true, message: '请输入悬浮栏目名称', trigger: 'blur' } + pictureAddress: [ + { required: true, message: '请上传图片', trigger: 'change' } + ], + schemeTitle: [ + { required: true, message: '请输入标题', trigger: 'blur' } + ], + schemeContentJson: [ + { required: true, message: '请输入内容', trigger: 'blur' } ], }, @@ -259,7 +207,8 @@ export default { }; }, components: { - Editor + Editor, + Cropper, }, watch: { keyword: function (val) { @@ -282,18 +231,20 @@ export default { name: '悬浮栏设置' } ]) + this.originForm = _.cloneDeep(this.form) this.getData() + this.getColumn() }, methods: { getData () { - this.$post(this.api.listWithTree, { + this.$post(this.api.listFloating, { siteId: this.siteId, - columnName: this.keyword, - templateId: '', - typeId: '', - isSort: 1 + search: this.keyword, + pageNum: this.page, + pageSize: this.pageSize, }).then(({ data }) => { - this.list = data + this.list = data.records + this.total = +data.total this.listLoading = false }).catch(err => { this.listLoading = false @@ -305,16 +256,32 @@ export default { this.page = 1 this.getData() }, + // 栏目树形 + async getColumn () { + const { data } = await this.$post(this.api.listWithTree, { + siteId: this.siteId, + columnName: '', + templateId: '', + typeId: '', + isSort: 1 + }) + this.columns = data + }, add () { + this.range = 0 + this.selectColumn = [] + this.form = _.cloneDeep(this.originForm) this.moduleVisible = true }, // 添加行 addRow () { - // this.data.list.push(JSON.parse(JSON.stringify(this.data.historyForm))) + this.curRow = _.cloneDeep(this.originModules) + this.curModule = -1 + this.contentVisible = true }, // 编辑内容 editRow (row, i = 0) { - this.curRow = JSON.parse(JSON.stringify(row)) + this.curRow = _.cloneDeep(row) this.curModule = i this.contentVisible = true }, @@ -323,19 +290,84 @@ export default { this.$confirm('确定要删除吗?', '提示', { type: 'warning' }).then(() => { - // list.splice(i, 1) + this.form.floatingColumnSchemeModules.splice(i, 1) }).catch(() => { }) }, - edit (row, type) { - this.$router.push(`add?id=${row.id}&level=${row.level + 1}&type=${type}`) + async edit (row) { + this.moduleVisible = true + const { data } = await this.$post(`${this.api.findFloating}?id=${row.floatingBarSchemeId}`) + const range = data.floatingColumnSchemeScopeOfApplications + // 应用范围数组里有一个对象的applicationScopeId为0,则是网站全局 + this.range = row.isGlobal ? 0 : 1 + if (!row.isGlobal) { + const column = [] + // 选择栏目 + range.map(e => { + column.push(e.applicationScopeId.split(',').map(n => +n)) + }) + this.selectColumn = column + console.log("🚀 ~ edit ~ this.selectColumn:", this.selectColumn) + } + + this.form = data }, // 模块设置提交 moduleSubmit () { + this.$refs.form.validate(async (valid) => { + if (valid) { + if (this.submiting) return false + const form = JSON.parse(JSON.stringify(this.form)) + if (!form.floatingColumnSchemeModules.length) return Util.warningMsg('请添加内容模块') + const column = this.selectColumn + if (this.range && !column.length) return Util.warningMsg('请选择栏目') + this.submiting = true + if (this.range) { + const scope = [] + // debugger + column.map(e => { + scope.push({ + applicationScopeId: typeof e === 'number' ? e : e.join(',') + }) + }) + form.floatingColumnSchemeScopeOfApplications = scope + } else { + form.floatingColumnSchemeScopeOfApplications = [{ + applicationScopeId: 0 + }] + } + if (!form.floatingBarSchemeId) form.founderId = form.editorId + // debugger + try { + await this.$post(this.api.saveFloating, form) + Util.successMsg('新增成功!') + this.moduleVisible = false + this.getData() + setTimeout(() => { + this.submiting = false + }, 2000) + } catch (e) { + this.submiting = false + } + } + }) }, // 内容设置提交 contentSubmit () { - + this.$refs.contentForm.validate(async (valid) => { + if (valid) { + this.contentVisible = false + const row = this.curRow + if (this.curModule === -1) { + this.form.floatingColumnSchemeModules.push(_.cloneDeep(row)) + } else { + const list = this.form.floatingColumnSchemeModules[this.curModule] + for (const i in row) { + this.$set(list, i, row[i]) + } + } + } + }) }, // 图片裁剪上传事件 customUpload (data) { @@ -362,14 +394,14 @@ export default { }, 1000); return false } - this.$set(this.curForm, 'pic', data.url) + this.$set(this.curRow, 'pictureAddress', data.url) }).catch(res => { }) this.$refs.cropper.isDisabled = false this.isUpload = false this.cropperModel = false }, // 图片改变钩子 - changeFile (file, form) { + changeFile (file) { const { size, name } = file const ext = name.substring(name.lastIndexOf('.') + 1) if (!Util.isImg(ext)) { @@ -381,7 +413,6 @@ export default { return false } this.file = file - this.curForm = form this.cropperModel = true this.$nextTick(() => { this.$refs.cropper.updateImg({ @@ -392,38 +423,37 @@ export default { }, del (row) { - this.$confirm("删除栏目将会同时把栏目下的文章一并删除,是否确认删除栏目?", "提示", { + this.$confirm('确定要删除吗?', "提示", { type: "warning" }).then(() => { - this.$post(`${this.api.deleteColumn}?ids=${row.id}`).then(res => { - util.successMsg("删除成功") + this.$post(`${this.api.batchDeletionFloating}?id=${row.floatingBarSchemeId}`).then(res => { + Util.successMsg("删除成功") this.getData() }).catch(res => { }) }).catch(() => { }) }, // 禁用启用 - switchOff (val, row) { - this.$post(this.api.updateColumn, row).then(res => { }).catch((res) => { }) + async switchOff (val, row) { + await this.$post(`${this.api.enableOrDisableScheme}?id=${row.floatingBarSchemeId}&isDisable=${row.isDisable}`) }, // 批量删除 batchDel () { const list = this.multipleSelection if (list.length) { - this.$confirm('删除栏目将会同时把栏目下的文章一并删除,是否确认删除栏目?', '提示', { + this.$confirm('确定要删除吗?', '提示', { type: 'warning' }).then(() => { - const data = [] - list.map(e => { - data.push('ids=' + e.id) + const ids = list.map(e => { + return 'id=' + e.floatingBarSchemeId }) - this.$post(`${this.api.deleteColumn}?${data.join('&')}`).then(res => { + this.$post(`${this.api.batchDeletionFloating}?${ids.join('&')}`).then(res => { this.$refs.table.clearSelection() - util.successMsg("删除成功") + Util.successMsg("删除成功") this.getData() }).catch(res => { }) }).catch(() => { }) } else { - util.errorMsg('请先选择数据 !') + Util.errorMsg('请先选择数据 !') } }, handleSelectionChange (val) { @@ -440,80 +470,88 @@ export default { \ No newline at end of file diff --git a/src/pages/user/list/index.vue b/src/pages/user/list/index.vue index a044a1d..52587e5 100644 --- a/src/pages/user/list/index.vue +++ b/src/pages/user/list/index.vue @@ -20,7 +20,8 @@
- +
@@ -33,10 +34,12 @@ 编辑部门 - 添加子部门 + 添加子部门 - 删除 + 删除 @@ -44,33 +47,23 @@
- - - - - - - {{ orgForm.pidName }} - - - - - - 取 消 - 确 定 - + + + + + + + {{ orgForm.pidName }} + + + + + + 取 消 + 确 定 +
@@ -95,112 +88,98 @@
- + - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - 取消 - 确定 + 取消 + 确定 -
-
- 模板下载 -
- - 上传文件 - - 部分数据导入失败,查看失败原因 +
+
+ 模板下载
- - 取 消 - 确 定 - + + 上传文件 + + 部分数据导入失败,查看失败原因 +
+ + 取 消 + 确 定 +
@@ -211,641 +190,641 @@ import util from '@/libs/util' import Setting from '@/setting' import Axios from 'axios' export default { - data() { - const accountPass = (rule, value, callback) => { - if (value === '') { - callback(new Error('请输入账号')) - } else { - const pattern = /^[A-Za-z0-9]*$/ - if(pattern.test(value)){ - this.accountChange() - callback() - }else{ - callback(new Error('请输入正确账号格式')) - } - } + data () { + const accountPass = (rule, value, callback) => { + if (value === '') { + callback(new Error('请输入账号')) + } else { + const pattern = /^[A-Za-z0-9]*$/ + if (pattern.test(value)) { + this.accountChange() + callback() + } else { + callback(new Error('请输入正确账号格式')) } - const workNumberPass = (rule, value, callback) => { - if (value === '') { - callback(new Error('请输入工号')) - } else { - const pattern = /^[A-Za-z0-9]*$/ - if(pattern.test(value)){ - this.worknumberChange() - callback() - }else{ - callback(new Error('请输入正确工号格式')) - } - } + } + } + const workNumberPass = (rule, value, callback) => { + if (value === '') { + callback(new Error('请输入工号')) + } else { + const pattern = /^[A-Za-z0-9]*$/ + if (pattern.test(value)) { + this.worknumberChange() + callback() + } else { + callback(new Error('请输入正确工号格式')) } - const phonePass = (rule, value, callback) => { - if (value) { - const pattern = /^1[3456789]\d{9}$/ - if(pattern.test(value)){ - callback() - }else{ - callback(new Error('请输入正确手机号格式')) - } - } else { - callback() - } + } + } + const phonePass = (rule, value, callback) => { + if (value) { + const pattern = /^1[3456789]\d{9}$/ + if (pattern.test(value)) { + callback() + } else { + callback(new Error('请输入正确手机号格式')) } - const emailPass = (rule, value, callback) => { - if (value) { - const pattern = /^[a-zA-Z0-9][a-zA-Z0-9_]+\@[a-zA-Z0-9]+\.[a-zA-Z]{2,5}(\.[a-zA-Z]{2,5})*$/i - if(pattern.test(value)){ - callback() - }else{ - callback(new Error('请输入正确邮箱格式')) - } - } else { - callback() - } + } else { + callback() + } + } + const emailPass = (rule, value, callback) => { + if (value) { + const pattern = /^[a-zA-Z0-9][a-zA-Z0-9_]+\@[a-zA-Z0-9]+\.[a-zA-Z]{2,5}(\.[a-zA-Z]{2,5})*$/i + if (pattern.test(value)) { + callback() + } else { + callback(new Error('请输入正确邮箱格式')) } - return { - orgs: [], - defaultProps: { - label: 'name' - }, - orgListDia: [], - staffType: 1, //类型:必填一个(1.所有员工 2.未加入班级员工) - orgVisible: false, // 员工组织架对话框 - orgForm: { - id: '', - name: '' - }, - cascaderValue: [], // 上级部门 - cascaderProps: { - checkStrictly: true, - label: "name", - value: "id" - }, - treeVisible: true, - treeNode: {}, - treeResolve: [], - isDetail: false, - keyword: '', - searchTimer: null, - originSettings: [], - settings: [ - { - name: '选择框', - show: true - }, - { - name: '员工姓名', - show: true - }, - { - name: '账号', - show: true - }, - { - name: '工号', - show: true - }, - { - name: '手机号', - show: true - }, - { - name: '所在部门', - show: true - }, - { - name: '创建日期', - show: true - }, - { - name: '授权角色', - show: true - }, - { - name: '用户组', - show: true - }, - { - name: '最后登录时间', - show: true - }, - { - name: '操作', - show: true - } - ], - roleIds: [], - userGroups: [], - form: { - id: '', - realName: '', - username: '', - phone: '', - jobNumber: '', - email: '', - groupId: 1, - roleIds: [], - deptArchitectureId: [] - }, - orgRules: { - name: [ - { required: true, message: "请输入部门名称", trigger: "blur" } - ] - }, - rules: { - username: [ - { required: true,validator: accountPass, trigger: 'blur' } - ], - realName: [ - { required: true, message: "请输入姓名", trigger: "blur" } - ], - jobNumber: [ - { required: true,validator: workNumberPass, trigger: 'blur' } - ], - roleIds: [ - { required: true, message: "请选择授权角色", trigger: "change" } - ], - groupId: [ - { required: true, message: "请选择用户组", trigger: "change" } - ], - phone: [ - { validator: phonePass, trigger: 'blur' } - ], - email: [ - { validator: emailPass, trigger: 'blur' } - ] - }, - list: [], - page: 1, - pageSize: 10, - total: 0, - multipleSelection: [], - - staffVisible: false, - accountReapeat: false, - originAccount: '', - workNumberReapeat: false, - originWorkNumber: '', - phoneRepeat: false, - emailRepeat: false, - casProps: { - multiple: true, - checkStrictly: true, - label: 'name', - value: 'id', - isLeaf: 'leaf' - }, - archId: [], - - importVisible: false, - uploadList: [], - uploadFaild: false, - exportCode: '', - headers: { - token: util.local.get(Setting.tokenKey) - }, - disableds:false, - submiting: false // 新增编辑防抖标识 - }; - }, - mounted() { - this.$store.commit('user/setCrumbs', [ + } else { + callback() + } + } + return { + orgs: [], + defaultProps: { + label: 'name' + }, + orgListDia: [], + staffType: 1, //类型:必填一个(1.所有员工 2.未加入班级员工) + orgVisible: false, // 员工组织架对话框 + orgForm: { + id: '', + name: '' + }, + cascaderValue: [], // 上级部门 + cascaderProps: { + checkStrictly: true, + label: "name", + value: "id" + }, + treeVisible: true, + treeNode: {}, + treeResolve: [], + isDetail: false, + keyword: '', + searchTimer: null, + originSettings: [], + settings: [ + { + name: '选择框', + show: true + }, + { + name: '员工姓名', + show: true + }, + { + name: '账号', + show: true + }, + { + name: '工号', + show: true + }, + { + name: '手机号', + show: true + }, + { + name: '所在部门', + show: true + }, + { + name: '创建日期', + show: true + }, + { + name: '授权角色', + show: true + }, + { + name: '用户组', + show: true + }, { - name: '用户管理' + name: '最后登录时间', + show: true }, { - name: '组织与账号管理' + name: '操作', + show: true } - ]) - this.originSettings = JSON.parse(JSON.stringify(this.settings)) - this.getOrg() - this.getRole() - this.getUserGroup() - this.originForm = JSON.parse(JSON.stringify(this.form)) - }, - watch: { - keyword: function(val) { - clearTimeout(this.searchTimer) - this.searchTimer = setTimeout(() => { - this.initData() - }, 500) - }, - filterText(val) { - this.$refs.classTree.filter(val); + ], + roleIds: [], + userGroups: [], + form: { + id: '', + realName: '', + username: '', + phone: '', + jobNumber: '', + email: '', + groupId: 1, + roleIds: [], + deptArchitectureId: [] + }, + orgRules: { + name: [ + { required: true, message: "请输入部门名称", trigger: "blur" } + ] + }, + rules: { + username: [ + { required: true, validator: accountPass, trigger: 'blur' } + ], + realName: [ + { required: true, message: "请输入姓名", trigger: "blur" } + ], + jobNumber: [ + { required: true, validator: workNumberPass, trigger: 'blur' } + ], + roleIds: [ + { required: true, message: "请选择授权角色", trigger: "change" } + ], + groupId: [ + { required: true, message: "请选择用户组", trigger: "change" } + ], + phone: [ + { validator: phonePass, trigger: 'blur' } + ], + email: [ + { validator: emailPass, trigger: 'blur' } + ] + }, + list: [], + page: 1, + pageSize: 10, + total: 0, + multipleSelection: [], + + staffVisible: false, + accountReapeat: false, + originAccount: '', + workNumberReapeat: false, + originWorkNumber: '', + phoneRepeat: false, + emailRepeat: false, + casProps: { + multiple: true, + checkStrictly: true, + label: 'name', + value: 'id', + isLeaf: 'leaf' + }, + archId: [], + + importVisible: false, + uploadList: [], + uploadFaild: false, + exportCode: '', + headers: { + token: util.local.get(Setting.tokenKey) + }, + disableds: false, + submiting: false // 新增编辑防抖标识 + }; + }, + mounted () { + this.$store.commit('user/setCrumbs', [ + { + name: '用户管理' + }, + { + name: '组织与账号管理' } + ]) + this.originSettings = JSON.parse(JSON.stringify(this.settings)) + this.getOrg() + this.getRole() + this.getUserGroup() + this.originForm = JSON.parse(JSON.stringify(this.form)) + }, + watch: { + keyword: function (val) { + clearTimeout(this.searchTimer) + this.searchTimer = setTimeout(() => { + this.initData() + }, 500) }, - methods: { - // 获取组织树形 - getOrg() { - this.$get(this.api.depts).then(({ data }) => { - const list = data[0].children - this.orgs = list - this.handleOrgId(list) - this.$nextTick(() => { - this.getStaff() - }) - }).catch(err => {}) - }, - // 每个层级加上父级id的集合 - handleOrgId(list, ids) { - list.forEach(e => { - e.ids = ids ? [...ids, e.id] : [e.id] - e.children.length ? this.handleOrgId(e.children, e.ids) : delete e.children + filterText (val) { + this.$refs.classTree.filter(val); + } + }, + methods: { + // 获取组织树形 + getOrg () { + this.$get(this.api.depts).then(({ data }) => { + const list = data[0].children + this.orgs = list + this.handleOrgId(list) + this.$nextTick(() => { + this.getStaff() }) - }, - // 组织类别筛选回调 - changeType() { - this.$refs.orgs.setCurrentKey(null) - this.initData() - }, - // 添加部门 - addOrg(node, data) { - const list = JSON.parse(JSON.stringify(this.orgs)) - this.handleOrg(list) - this.orgListDia = list - this.orgForm = { - id: '', - pid: data ? data.id : 0, - pidName: data ? data.name : '', - name: '' - } - this.orgVisible = true - }, - // 编辑部门 - editOrg(node, data) { - const list = JSON.parse(JSON.stringify(this.orgs)) - this.handleOrg(list, data.id, 0) - this.orgListDia = list - this.orgForm = { - id: data.id, - name: data.name - } - this.orgVisible = true - const ids = data.ids - ids.splice(ids.length - 1, 1) - this.cascaderValue = ids - }, - // 处理更换部门的禁选 - handleOrg(list, id, disabled) { - list.forEach(e => { - // 如果是已经找到了要禁选的层级,则直接改变disabled,并递归 - if (disabled) { + }).catch(err => { }) + }, + // 每个层级加上父级id的集合 + handleOrgId (list, ids) { + list.forEach(e => { + e.ids = ids ? [...ids, e.id] : [e.id] + e.children.length ? this.handleOrgId(e.children, e.ids) : delete e.children + }) + }, + // 组织类别筛选回调 + changeType () { + this.$refs.orgs.setCurrentKey(null) + this.initData() + }, + // 添加部门 + addOrg (node, data) { + const list = JSON.parse(JSON.stringify(this.orgs)) + this.handleOrg(list) + this.orgListDia = list + this.orgForm = { + id: '', + pid: data ? data.id : 0, + pidName: data ? data.name : '', + name: '' + } + this.orgVisible = true + }, + // 编辑部门 + editOrg (node, data) { + const list = JSON.parse(JSON.stringify(this.orgs)) + this.handleOrg(list, data.id, 0) + this.orgListDia = list + this.orgForm = { + id: data.id, + name: data.name + } + this.orgVisible = true + const ids = data.ids + ids.splice(ids.length - 1, 1) + this.cascaderValue = ids + }, + // 处理更换部门的禁选 + handleOrg (list, id, disabled) { + list.forEach(e => { + // 如果是已经找到了要禁选的层级,则直接改变disabled,并递归 + if (disabled) { + e.disabled = true + e.children && this.handleOrg(e.children, id, 1) + } else { + if (e.id === id) { e.disabled = true e.children && this.handleOrg(e.children, id, 1) } else { - if (e.id === id) { - e.disabled = true - e.children && this.handleOrg(e.children, id, 1) - } else { - e.children && this.handleOrg(e.children, id, 0) - } + e.children && this.handleOrg(e.children, id, 0) } - }) - }, - // 删除部门 - delOrg(node, data) { - this.$confirm("确定要删除吗?", "提示", { - type: "warning" - }).then(() => { - this.$del(`${this.api.dept}/${data.id}`).then(res => { - util.successMsg("删除成功") - this.getOrg() - }).catch(res => {}) - }).catch(() => {}) - }, - // 提交组织架构新增/编辑 - orgSubmit() { - this.$refs.orgForm.validate((valid) => { - if (valid) { - const form = this.orgForm - const cas = this.cascaderValue - const len = cas.length - if (cas && len) { - this.orgForm.pid = cas[len - 1] - } else if (!form.pid) { - form.pid = 0 - } - if (!form.id) { - // 添加 - this.$post(this.api.dept, form).then(res => { - util.successMsg("新增成功!") - this.closeOrg() - }).catch(err => {}) - } else { - // 编辑 - this.$put(this.api.dept, form).then(res => { - util.successMsg("编辑成功!") - this.closeOrg() - }).catch(err => {}) - } + } + }) + }, + // 删除部门 + delOrg (node, data) { + this.$confirm("确定要删除吗?", "提示", { + type: "warning" + }).then(() => { + this.$del(`${this.api.dept}/${data.id}`).then(res => { + util.successMsg("删除成功") + this.getOrg() + }).catch(res => { }) + }).catch(() => { }) + }, + // 提交组织架构新增/编辑 + orgSubmit () { + this.$refs.orgForm.validate((valid) => { + if (valid) { + const form = this.orgForm + const cas = this.cascaderValue + const len = cas.length + if (cas && len) { + this.orgForm.pid = cas[len - 1] + } else if (!form.pid) { + form.pid = 0 } - }) - }, - // 点击树节点查询列表数据 - handleNodeClick(data) { - this.staffType = null - this.initData() - }, - // 关闭组织新增编辑弹框 - closeOrg() { - this.orgVisible = false - this.cascaderValue = [] - this.getOrg() - }, - // 重置栏位筛选 - resetColumns() { - this.settings = JSON.parse(JSON.stringify(this.originSettings)) - }, - // 员工列表 - getStaff() { - this.$post(this.api.users, { - type: this.staffType || 1, - deptArchitectureId: this.$refs.orgs.getCurrentKey() || '', - keyWord: this.keyword, - pageNum: this.page, - pageSize: this.pageSize - }).then(({ data }) => { - this.list = data.records - this.total = +data.total - }).catch(err => {}) - }, - // 切换页码 - currentChange(val) { - this.page = val - this.getStaff() - }, - handleSelectionChange(val) { // 多选 - this.multipleSelection = val - }, - initData() { - this.$refs.table.clearSelection() - this.page = 1 - this.getStaff() - }, - // 删除 - delStaff(row) { - this.$confirm("确定要删除吗?", "提示", { - type: "warning" + if (!form.id) { + // 添加 + this.$post(this.api.dept, form).then(res => { + util.successMsg("新增成功!") + this.closeOrg() + }).catch(err => { }) + } else { + // 编辑 + this.$put(this.api.dept, form).then(res => { + util.successMsg("编辑成功!") + this.closeOrg() + }).catch(err => { }) + } + } + }) + }, + // 点击树节点查询列表数据 + handleNodeClick (data) { + this.staffType = null + this.initData() + }, + // 关闭组织新增编辑弹框 + closeOrg () { + this.orgVisible = false + this.cascaderValue = [] + this.getOrg() + }, + // 重置栏位筛选 + resetColumns () { + this.settings = JSON.parse(JSON.stringify(this.originSettings)) + }, + // 员工列表 + getStaff () { + this.$post(this.api.users, { + type: this.staffType || 1, + deptArchitectureId: this.$refs.orgs.getCurrentKey() || '', + keyWord: this.keyword, + pageNum: this.page, + pageSize: this.pageSize + }).then(({ data }) => { + this.list = data.records + this.total = +data.total + }).catch(err => { }) + }, + // 切换页码 + currentChange (val) { + this.page = val + this.getStaff() + }, + handleSelectionChange (val) { // 多选 + this.multipleSelection = val + }, + initData () { + this.$refs.table.clearSelection() + this.page = 1 + this.getStaff() + }, + // 删除 + delStaff (row) { + this.$confirm("确定要删除吗?", "提示", { + type: "warning" + }).then(() => { + this.$del(this.api.user, [row.id]).then(res => { + util.successMsg("删除成功") + this.getStaff() + }).catch(res => { }) + }).catch(() => { }) + }, + // 批量删除 + batchDel () { + const list = this.multipleSelection + if (list.length) { + this.$confirm('确定要删除吗?', '提示', { + type: 'warning' }).then(() => { - this.$del(this.api.user, [row.id]).then(res => { - util.successMsg("删除成功") + this.$del(`${this.api.user}`, list.map(e => e.id)).then(res => { + this.$refs.table.clearSelection() + util.successMsg('删除成功') this.getStaff() - }).catch(res => {}) - }).catch(() => {}) - }, - // 批量删除 - batchDel() { - const list = this.multipleSelection - if (list.length) { - this.$confirm('确定要删除吗?', '提示', { - type: 'warning' - }).then(() => { - this.$del(`${this.api.user}`, list.map(e => e.id)).then(res => { - this.$refs.table.clearSelection() - util.successMsg('删除成功') - this.getStaff() - }).catch(res => {}) - }).catch(() => {}) + }).catch(res => { }) + }).catch(() => { }) + } else { + util.errorMsg('请先选择数据 !') + } + }, + // 重置密码 + resetPassword (row) { + this.$confirm(`确定重置密码?重置后密码为111aaa。`, "提示", { type: "warning" }).then(() => { + this.$get(`${this.api.resetPwd}?userId=${row.id}`).then(res => { + util.successMsg("重置成功") + }).catch(res => { }) + }).catch(() => { }) + }, + // 添加员工 + addStaff () { + if (!this.staffType) { + this.archId = [] + this.handleArchId(this.orgs, [this.$refs.orgs.getCurrentKey()]) + this.form.deptArchitectureId = this.archId + } + this.staffVisible = true + this.$nextTick(() => { + this.$refs.form.clearValidate() + }) + }, + // 处理部门id + handleArchId (list, ids, pid = []) { + list.map(e => { + // 把部门id分割成二维数组,[[1, 2], [3, 4]],每个层级的id都要放进去,后端返回的是最后一级的id,无法回显 + if (ids.includes(e.id)) { + this.archId.push([...pid, e.id]) } else { - util.errorMsg('请先选择数据 !') - } - }, - // 重置密码 - resetPassword(row) { - this.$confirm(`确定重置密码?重置后密码为111aaa。`, "提示", { type: "warning" }).then(() => { - this.$get(`${this.api.resetPwd}?userId=${row.id}`).then(res => { - util.successMsg("重置成功") - }).catch(res => {}) - }).catch(() => {}) - }, - // 添加员工 - addStaff() { - if (!this.staffType) { - this.archId = [] - this.handleArchId(this.orgs, [this.$refs.orgs.getCurrentKey()]) - this.form.deptArchitectureId = this.archId + e.children && this.handleArchId(e.children, ids, [...pid, e.id]) } - this.staffVisible = true - this.$nextTick(() => { - this.$refs.form.clearValidate() - }) - }, - // 处理部门id - handleArchId(list, ids, pid = []) { - list.map(e => { - // 把部门id分割成二维数组,[[1, 2], [3, 4]],每个层级的id都要放进去,后端返回的是最后一级的id,无法回显 - if (ids.includes(e.id)) { - this.archId.push([...pid, e.id]) - } else { - e.children && this.handleArchId(e.children, ids, [...pid, e.id]) - } - }) - }, - // 编辑/查看 - queryStaff(row, isDetail) { - this.isDetail = isDetail - this.staffVisible = true - this.$get(`${this.api.user}/${row.id}`).then(({ data }) => { - const { deptArchitectureId, roleId } = data - if (roleId) { - const ids = roleId.split(',').map(e => +e) - const list = this.roleIds - if (ids.length) { - let has = false // 是否在角色列表里有已选择的角色,全部都被删除了,则提示 - for (const i in ids) { - if (list.find(n => n.id == ids[i])) { - has = true - break - } - } - if (!has) { - util.warningMsg('角色被删请重新选择') - data.roleIds = [] - } else { - data.roleIds = ids + }) + }, + // 编辑/查看 + queryStaff (row, isDetail) { + this.isDetail = isDetail + this.staffVisible = true + this.$get(`${this.api.user}/${row.id}`).then(({ data }) => { + const { deptArchitectureId, roleId } = data + if (roleId) { + const ids = roleId.split(',').map(e => +e) + const list = this.roleIds + if (ids.length) { + let has = false // 是否在角色列表里有已选择的角色,全部都被删除了,则提示 + for (const i in ids) { + if (list.find(n => n.id == ids[i])) { + has = true + break } } - } - if (deptArchitectureId) { - this.archId = [] - this.handleArchId(this.orgs, deptArchitectureId.split(',').map(e => +e)) - data.deptArchitectureId = this.archId - } - data.groupId = +data.groupId - this.form = { - id: data.id, - realName: data.realName, - username: data.username, - phone: data.phone, - jobNumber: data.jobNumber, - email: data.email, - groupId: +data.groupId, - roleIds: data.roleIds, - deptArchitectureId: data.deptArchitectureId || [] - } - this.originAccount = data.username - this.originWorkNumber = data.jobNumber - }).catch(res => {}) - }, - // 获取角色数据 - getRole() { - this.$post(this.api.roles, { - page: 1, - limit: 10000 - }).then(({ data }) => { - this.roleIds = data.records - }).catch(res => {}) - }, - // 用户组 - getUserGroup() { - this.$post(this.api.groupList, { - page: 1, - limit : 10000 - }).then(({ data }) => { - this.userGroups = data.records - }).catch(err => {}) - }, - // 账号判重 - accountChange() { - const { username } = this.form - if (username === this.originAccount) { - this.accountReapeat = false - } else { - this.$get(`${this.api.checkUsername}?userName=${username}`).then(res => { - this.accountReapeat = false - }).catch(err => { - this.accountReapeat = true - }) - } - }, - // 工号判重 - worknumberChange() { - const { jobNumber } = this.form - if (jobNumber === this.originWorkNumber) { - this.workNumberReapeat = false - } else { - this.$get(`${this.api.checkJobNumber}?jobNumber=${jobNumber}`).then(res => { - this.workNumberReapeat = false - }).catch(err => { - this.workNumberReapeat = true - }) - } - }, - // 提交新增/编辑员工 - submitStaff() { - this.$refs.form.validate((valid) => { - if (valid) { - if (this.submiting) return false - if (this.accountReapeat) return util.warningMsg("该账号已存在") - if (this.workNumberReapeat) return util.warningMsg("该工号已存在") - if (this.phoneRepeat) return util.warningMsg("该手机号已存在") - if (this.emailRepeat) return util.warningMsg("该邮箱已存在") - this.submiting = true - const form = JSON.parse(JSON.stringify(this.form)) - const ids = form.deptArchitectureId - if (ids) form.deptArchitectureId = ids.map(e => e[e.length - 1]) - if (form.id) { - this.$put(this.api.user, form).then(res => { - util.successMsg("编辑成功!") - this.staffVisible = false - setTimeout(() => { - this.submiting = false - }, 2000) - }).catch(res => { - setTimeout(() => { - this.submiting = false - }, 2000) - }) + if (!has) { + util.warningMsg('角色被删请重新选择') + data.roleIds = [] } else { - this.$post(this.api.user, form).then(res => { - util.successMsg("新增成功!") - this.staffVisible = false - setTimeout(() => { - this.submiting = false - }, 2000) - }).catch(res => { - setTimeout(() => { - this.submiting = false - }, 2000) - }) + data.roleIds = ids } } - }) - }, - // 关闭新增员工对话框 - closeStaff() { + } + if (deptArchitectureId) { + this.archId = [] + this.handleArchId(this.orgs, deptArchitectureId.split(',').map(e => +e)) + data.deptArchitectureId = this.archId + } + data.groupId = +data.groupId this.form = { - id: '', - realName: '', - username: '', - phone: '', - uniqueIdentification: '', - jobNumber: '', - email: '', - deptArchitectureId: [], - roleIds: [] + id: data.id, + realName: data.realName, + username: data.username, + phone: data.phone, + jobNumber: data.jobNumber, + email: data.email, + groupId: +data.groupId, + roleIds: data.roleIds, + deptArchitectureId: data.deptArchitectureId || [] } - this.isDetail = false - this.getStaff() - }, - // 批量导入 - batchImport() { - this.importVisible = true - this.uploadList = [] - this.uploadFaild = false - }, - // 模板下载 - download() { - location.href = this.api.staffTemplate - }, - // 上传文件 - handleExceed(files, fileList) { - util.warningMsg( - `当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!` - ) - }, - // 下载失败文件 - showFaild() { - Axios.get(`${this.api.exportFailure}?exportCode=${this.exportCode}`, { - headers: this.headers, - responseType: 'blob' - }).then((res) => { - util.downloadFileDirect(`导入用户失败原因.xls`, new Blob([res.data])) - }).catch(res => {}) - }, - uploadSuccess(res, file, fileList) { - this.uploadFaild = false - if (res.code === 200) { - if (res.data.exportCode) { - this.exportCode = res.data.exportCode - this.uploadFaild = true - util.errorMsg(`本次上传有${res.data.failureNum}个错误信息录入`) + this.originAccount = data.username + this.originWorkNumber = data.jobNumber + }).catch(res => { }) + }, + // 获取角色数据 + getRole () { + this.$post(this.api.roles, { + page: 1, + limit: 10000 + }).then(({ data }) => { + this.roleIds = data.records + }).catch(res => { }) + }, + // 用户组 + getUserGroup () { + this.$post(this.api.groupList, { + page: 1, + limit: 10000 + }).then(({ data }) => { + this.userGroups = data.records + }).catch(err => { }) + }, + // 账号判重 + accountChange () { + const { username } = this.form + if (username === this.originAccount) { + this.accountReapeat = false + } else { + this.$get(`${this.api.checkUsername}?userName=${username}`).then(res => { + this.accountReapeat = false + }).catch(err => { + this.accountReapeat = true + }) + } + }, + // 工号判重 + worknumberChange () { + const { jobNumber } = this.form + if (jobNumber === this.originWorkNumber) { + this.workNumberReapeat = false + } else { + this.$get(`${this.api.checkJobNumber}?jobNumber=${jobNumber}`).then(res => { + this.workNumberReapeat = false + }).catch(err => { + this.workNumberReapeat = true + }) + } + }, + // 提交新增/编辑员工 + submitStaff () { + this.$refs.form.validate((valid) => { + if (valid) { + if (this.submiting) return false + if (this.accountReapeat) return util.warningMsg("该账号已存在") + if (this.workNumberReapeat) return util.warningMsg("该工号已存在") + if (this.phoneRepeat) return util.warningMsg("该手机号已存在") + if (this.emailRepeat) return util.warningMsg("该邮箱已存在") + this.submiting = true + const form = JSON.parse(JSON.stringify(this.form)) + const ids = form.deptArchitectureId + if (ids) form.deptArchitectureId = ids.map(e => e[e.length - 1]) + if (form.id) { + this.$put(this.api.user, form).then(res => { + util.successMsg("编辑成功!") + this.staffVisible = false + setTimeout(() => { + this.submiting = false + }, 2000) + }).catch(res => { + setTimeout(() => { + this.submiting = false + }, 2000) + }) + } else { + this.$post(this.api.user, form).then(res => { + util.successMsg("新增成功!") + this.staffVisible = false + setTimeout(() => { + this.submiting = false + }, 2000) + }).catch(res => { + setTimeout(() => { + this.submiting = false + }, 2000) + }) } - } else { - res.msg ? util.errorMsg(res.msg) : util.errorMsg("上传失败,请检查数据") } - }, - uploadError(err, file, fileList) { - this.$message({ - message: "上传出错,请重试!", - type: "error", - center: true - }) - }, - beforeRemove(file, fileList) { - return this.$confirm(`确定移除 ${file.name}?`) - }, - handleRemove(file, fileList) { - this.uploadList = fileList - this.uploadFaild = false - }, - uploadSure() { - this.importVisible = false - this.staffType = 1 - this.keyword = '' - this.$refs.orgs.setCurrentKey(null) - this.getOrg() + }) + }, + // 关闭新增员工对话框 + closeStaff () { + this.form = { + id: '', + realName: '', + username: '', + phone: '', + uniqueIdentification: '', + jobNumber: '', + email: '', + deptArchitectureId: [], + roleIds: [] + } + this.isDetail = false + this.getStaff() + }, + // 批量导入 + batchImport () { + this.importVisible = true + this.uploadList = [] + this.uploadFaild = false + }, + // 模板下载 + download () { + location.href = this.api.staffTemplate + }, + // 上传文件 + handleExceed (files, fileList) { + util.warningMsg( + `当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!` + ) + }, + // 下载失败文件 + showFaild () { + Axios.get(`${this.api.exportFailure}?exportCode=${this.exportCode}`, { + headers: this.headers, + responseType: 'blob' + }).then((res) => { + util.downloadFileDirect(`导入用户失败原因.xls`, new Blob([res.data])) + }).catch(res => { }) + }, + uploadSuccess (res, file, fileList) { + this.uploadFaild = false + if (res.code === 200) { + if (res.data.exportCode) { + this.exportCode = res.data.exportCode + this.uploadFaild = true + util.errorMsg(`本次上传有${res.data.failureNum}个错误信息录入`) + } + } else { + res.msg ? util.errorMsg(res.msg) : util.errorMsg("上传失败,请检查数据") } + }, + uploadError (err, file, fileList) { + this.$message({ + message: "上传出错,请重试!", + type: "error", + center: true + }) + }, + beforeRemove (file, fileList) { + return this.$confirm(`确定移除 ${file.name}?`) + }, + handleRemove (file, fileList) { + this.uploadList = fileList + this.uploadFaild = false + }, + uploadSure () { + this.importVisible = false + this.staffType = 1 + this.keyword = '' + this.$refs.orgs.setCurrentKey(null) + this.getOrg() } + } }; @@ -853,39 +832,48 @@ export default { /deep/.org { .el-tree-node__content { height: 40px; + &:hover { background-color: #F0F4FF; } } } + .node-wrap { display: flex; justify-content: space-between; align-items: center; width: 100%; + .left { display: inline-flex; align-items: center; } + .name { margin-left: 3px; font-size: 14px; color: #333; } + .expand { padding: 0 15px; } } + .org-btn { width: 100%; text-align: left; + &.add { color: #666; } + &.del { color: #D0021B; } } + .list-wrap { width: calc(100% - 301px); } diff --git a/src/setting.js b/src/setting.js index c4eadf8..901a426 100644 --- a/src/setting.js +++ b/src/setting.js @@ -1,63 +1,62 @@ /** * 业务配置 * */ -const url = location.host; const isDev = process.env.NODE_ENV === 'development' // 开发环境 -let host = `${location.origin}/` +let host = location.origin if (isDev) { - host = 'https://huorantech.com/' - // host = 'http://139.159.254.212/' + host = 'https://huorantech.com' + host = 'http://192.168.31.217:10000' } const Setting = { - /** - * 基础配置 - * */ - titleSuffix: '职站商城后台', // 网页标题的后缀 - routerMode: "hash", // 路由模式,可选值为 history 或 hash - showProgressBar: true, // 页面切换时,是否显示模拟的进度条 - apiBaseURL: host, // 接口请求地址 - autoLogoutTime: 1000 * 60 * 60 * 3, // 长时间未操作,自动退出登录时间 - modalDuration: 3, // 接口请求返回错误时,弹窗的持续时间,单位:秒 - errorModalType: "Message", // 接口请求返回错误时,弹窗的类型,可选值为 Message 或 Notice - tokenExpires: 1296000000, // token在localStorage的时间(毫秒) - isDev, - /** - * 路由白名单 - * */ - whiteList: ['/login', '/redirect'], - /** - * localStorage里保存的token的key - */ - tokenKey: "huoran_server_token", - /** - * localStorage里保存的vuex的key - */ - storeKey: "huoran_server_store", - /** - * 默认密码 - */ - initialPassword: "111aaa", - /** - * 多语言配置 - * */ - i18n: { - // 默认语言 - default: "zh", - // 是否根据用户电脑配置自动设置语言(仅第一次有效) - auto: false - }, - /** - * 布局配置 - * */ - layout: {}, - /** - * 功能配置 - * */ - // 相同路由,不同参数间进行切换,是否强力更新 - sameRouteForceUpdate: false, - // 是否使用动态路由(即角色权限,开启了的话就会取后端返回的权限树来显示头部导肮和页面按钮) - dynamicRoute: false + /** + * 基础配置 + * */ + titleSuffix: '职站商城后台', // 网页标题的后缀 + routerMode: "hash", // 路由模式,可选值为 history 或 hash + showProgressBar: true, // 页面切换时,是否显示模拟的进度条 + apiBaseURL: host, // 接口请求地址 + autoLogoutTime: 1000 * 60 * 60 * 3, // 长时间未操作,自动退出登录时间 + modalDuration: 3, // 接口请求返回错误时,弹窗的持续时间,单位:秒 + errorModalType: "Message", // 接口请求返回错误时,弹窗的类型,可选值为 Message 或 Notice + tokenExpires: 1296000000, // token在localStorage的时间(毫秒) + isDev, + /** + * 路由白名单 + * */ + whiteList: ['/login', '/redirect'], + /** + * localStorage里保存的token的key + */ + tokenKey: "huoran_server_token", + /** + * localStorage里保存的vuex的key + */ + storeKey: "huoran_server_store", + /** + * 默认密码 + */ + initialPassword: "111aaa", + /** + * 多语言配置 + * */ + i18n: { + // 默认语言 + default: "zh", + // 是否根据用户电脑配置自动设置语言(仅第一次有效) + auto: false + }, + /** + * 布局配置 + * */ + layout: {}, + /** + * 功能配置 + * */ + // 相同路由,不同参数间进行切换,是否强力更新 + sameRouteForceUpdate: false, + // 是否使用动态路由(即角色权限,开启了的话就会取后端返回的权限树来显示头部导肮和页面按钮) + dynamicRoute: false }; export default Setting;