diff --git a/public/index.html b/public/index.html index 687f318..33f4e2a 100644 --- a/public/index.html +++ b/public/index.html @@ -16,8 +16,8 @@ - - - + diff --git a/public/static/ueditor/ueditor.config.js b/public/static/ueditor/ueditor.config.js index 1160999..5a27678 100644 --- a/public/static/ueditor/ueditor.config.js +++ b/public/static/ueditor/ueditor.config.js @@ -1,6 +1,6 @@ !function () { window.UEDITOR_HOME_URL = "./static/ueditor/"; var s = window.UEDITOR_HOME_URL || l(); function l (s, l) { return function (s, l) { var t = l; /^(\/|\\\\)/.test(l) ? t = /^.+?\w(\/|\\\\)/.exec(s)[0] + l.replace(/^(\/|\\\\)/, "") : /^[a-z]+:/i.test(l) || (s = s.split("#")[0].split("?")[0].replace(/[^\\\/]+$/, ""), t = s + "" + l); return function (s) { var l = /^[a-z]+:\/\//.exec(s)[0], t = null, e = []; (s = (s = s.replace(l, "").split("?")[0].split("#")[0]).replace(/\\/g, "/").split(/\//))[s.length - 1] = ""; for (; s.length;)".." === (t = s.shift()) ? e.pop() : "." !== t && e.push(t); return l + e.join("/") }(t) }(s || self.document.URL || self.location.href, l || (t = document.getElementsByTagName("script"))[t.length - 1].src); var t } window.UEDITOR_CONFIG = { - UEDITOR_HOME_URL: s, serverUrl: "http://192.168.31.51:9000/exam/upload/configAndUpload", toolbars: [[ + UEDITOR_HOME_URL: s, serverHeaders: { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept, Authorization', 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS' }, serverUrl: "http://192.168.31.51:9000/exam/exam/upload/configAndUpload", toolbars: [[ "fullscreen", "source", "|", @@ -57,7 +57,6 @@ "imageright", "imagecenter", "|", - "simpleupload", "insertimage", "emotion", "scrawl", diff --git a/src/api/index.js b/src/api/index.js index 8bb4a5f..565fd00 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -1,6 +1,17 @@ import Setting from '@/setting' const { apiBaseURL: host } = Setting +// const host = 'http://192.168.31.217:9000/' export default { - upload: `${host}/iasf/sysFiles/upload`, + categoriesDel: `/exam/question/bank/categories/batchDeletion`, + categoriesFind: `/exam/question/bank/categories/findById`, + getAllQuestionBankCategories: `/exam/question/bank/categories/getAllQuestionBankCategories`, + categoriesSave: `/exam/question/bank/categories/saveOrUpdate`, + categoriesDisable: `/exam/question/bank/categories/updateStatus`, + + questionBankDel: `/exam/questionBank/batchDeletion`, + questionBankFind: `/exam/questionBank/findById`, + questionBankList: `/exam/questionBank/pagingQuery`, + questionBankSave: `/exam/questionBank/saveOrUpdate`, + questionBankDisable: `/exam/questionBank/updateStatus`, } \ No newline at end of file diff --git a/src/components/ueditor/index.vue b/src/components/ueditor/index.vue index 018859d..e2fc2a0 100644 --- a/src/components/ueditor/index.vue +++ b/src/components/ueditor/index.vue @@ -43,10 +43,23 @@ export default { }, methods: { initEditor () { + console.log(44, UE.Editor.prototype.getActionUrl) + this.$nextTick(() => { // eslint-disable-next-line no-undef this.instance = UE.getEditor(this.randomId) this.instance.addListener('ready', () => { + + // UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl; + // UE.Editor.prototype.getActionUrl = function (action) { + // console.log("🚀 ~ initEditor ~ action:", action) + // if (action == 'uploadimage' || action == 'uploadscrawl' || action == 'uploadimage') { + // return 'http://192.168.31.51:9000/nakadai/nakadai/oss/fileUpload'; + // } else { + // return this._bkGetActionUrl.call(this, action); + // } + // } + this.ready = true this.$emit('ready', this.instance) }) diff --git a/src/layouts/home/index.vue b/src/layouts/home/index.vue index 793a208..630d906 100644 --- a/src/layouts/home/index.vue +++ b/src/layouts/home/index.vue @@ -31,7 +31,7 @@ export default { }, mounted () { const { token } = this.$route.query - Util.local.set(Setting.tokenKey, token, Setting.tokenExpires) + token && Util.local.set(Setting.tokenKey, token, Setting.tokenExpires) }, }; diff --git a/src/pages/ques/index.vue b/src/pages/ques/index.vue index 8421768..af5b2ae 100644 --- a/src/pages/ques/index.vue +++ b/src/pages/ques/index.vue @@ -202,7 +202,7 @@ @@ -232,6 +232,7 @@ export default { components: { Ueditor }, data () { return { + radio: '', type: 1, orgList: [], status: [ @@ -524,11 +525,11 @@ export default { this.quesVisible = true }, editorReady (instance) { - this.richEditor.instance = instance - let currentContent = this.richEditor.object[this.richEditor.parameterName] - this.richEditor.instance.setContent(currentContent) - // 光标定位到Ueditor - this.richEditor.instance.focus(true) + // this.richEditor.instance = instance + // let currentContent = this.richEditor.object[this.richEditor.parameterName] + // this.richEditor.instance.setContent(currentContent) + // // 光标定位到Ueditor + // this.richEditor.instance.focus(true) }, // 题目提交 quesSubmit () { diff --git a/src/pages/quesBank/index.vue b/src/pages/quesBank/index.vue index 6e5fdfb..eda4431 100644 --- a/src/pages/quesBank/index.vue +++ b/src/pages/quesBank/index.vue @@ -3,23 +3,24 @@
题库分类
- +
- 所有题库 + 所有题库
- 未加入分类的题库 + 未加入分类的题库
- +
- + :props="{ children: 'children', label: 'name', isLeaf: 'leaf' }">
@@ -36,7 +37,7 @@
  • -
  • @@ -46,23 +47,25 @@ + @selection-change="handleSelectionChange" row-key="id" @sort-change="sortChange"> - - - - - - - + + + + + + + @@ -72,20 +75,19 @@ :total="total"> - - +

    您将复制当前题库中的所有题目到新题库,请输入新题库名称

    + - - - + - - + + - - + + @@ -103,21 +105,25 @@ import Setting from "@/setting"; export default { data () { return { - type: 1, - orgList: [], + loading: false, + keyword: '', + isNotJoin: 0, + types: [], status: [ { id: 1, name: '启用' }, { - id: 2, + id: 0, name: '禁用' }, ], filter: { + questionNumOrderBy: '', + timeOrderBy: '', status: '', - keyWord: '', + name: '', }, list: [], page: 1, @@ -125,136 +131,96 @@ export default { total: 0, multipleSelection: [], - types: [], form: { - userName: '', - provinceId: '', - cityId: '', - roleList: [] + questionBankDescription: '', + questionBankName: '', + categoryIds: [], }, rules: { - userName: [ - { required: true, message: "请输入姓名", trigger: "blur" } - ], - provinceId: [ - { required: true, message: '请选择省份', trigger: "change" } - ], - cityId: [ - { required: true, message: '请选择城市', trigger: "change" } - ], - roleList: [ - { required: true, message: '请选择角色', trigger: "change" } - ], + questionBankName: [ + { required: true, message: '请输入题库名称', trigger: 'blur' } + ] }, + enableTypes: [], quesBankVisible: false, - - - submiting: false, // 新增编辑防抖标识 - setKey: '', - transferVisible: false, - chooseVisible: false, - members: [], - choosePartnerId: '', - curRow: '', - provinces: [], - cities: [], - editVisible: false + submiting: false, + isCopy: false, }; }, watch: { - keyWord: function (val) { - clearTimeout(this.searchTimer); - this.searchTimer = setTimeout(this.initData, 500); + keyword: function (val) { + clearTimeout(this.searchTimer) + this.searchTimer = setTimeout(this.getType, 500) + }, + 'filter.name': function (val) { + clearTimeout(this.searchTimer) + this.searchTimer = setTimeout(this.initData, 500) } }, mounted () { - this.getOrg() + this.getType() }, methods: { - // 获取组织 - async getOrg () { - const res = await this.$post(this.api.listParner) - const list = res.treeList - // 没有子级,删除children属性 - const handleLeaf = (list, ids) => { - list.map(e => { - e.ids = ids ? [...ids, e.id] : [e.id] - if (e.children.length) { - if (e.isTeam) { - delete e.children - } else { - handleLeaf(e.children, e.ids) - } - } else { - delete e.children - } + // 获取题库分类 + async getType () { + try { + this.loading = true + const { data } = await this.$post(this.api.getAllQuestionBankCategories, { + keyword: this.keyword, + createSource: 1, }) + this.handleList(data) + this.types = data + // 如果刚编辑完,则选中刚编辑的分类 + this.setKey && this.$nextTick(() => { + this.$refs.typeTree.setCurrentKey(this.setKey) + }) + this.getList() + } finally { + this.loading = false } - handleLeaf(list) - this.orgList = list - // 如果刚编辑完,则选中刚编辑的分类 - this.setKey && this.$nextTick(() => { - this.$refs.orgTree.setCurrentKey(this.setKey) + }, + // 处理树形 + handleList (list) { + list.map(e => { + if (e.children && e.children.length) { + this.handleList(e.children) + } else { + delete e.children + } }) - this.getList() }, + // 类型回调 typeChange () { - this.$refs.orgTree.setCurrentKey(null) - this.curTeamId = '' + this.$refs.typeTree.setCurrentKey(null) this.initData() }, - // 获得点击层级里的第一个城市合伙人id - getTeamId (list) { - for (const i in list) { - const e = list[i] - if (e.isTeam && !this.curTeamId) { - this.curTeamId = e.id - break - } else { - this.getTeamId(e.children) - } - } - }, // 点击树节点查询列表数据 handleNodeClick (data) { - this.type = '' - this.curTeamId = '' - if (data.isTeam) { - this.curTeamId = data.id - } else { - // this.getTeamId(data.children) - } - if (!this.curTeamId) this.curTeamId = data.id + this.isNotJoin = '' this.initData() this.$refs.table.clearSelection() }, - // 查询全部 - getAll () { - this.curTeamId = '' - this.getList() - }, - // 员工列表 - getList () { - this.$post(this.api[this.type ? 'partnerAccountMergeList' : 'partnerAccountList'], { - type: this.type || 1, - partnerClassificationId: this.curTeamId, + // 题库列表 + async getList () { + const res = await this.$post(this.api.questionBankList, { + ...this.filter, + isNotJoin: this.isNotJoin || '', pageNum: this.page, - pageSize: this.pageSize - }).then(({ pageList }) => { - pageList.records.forEach((e, i) => { - e.id = i - }) - this.list = pageList.records - this.total = pageList.total - }).catch(err => { }) + pageSize: this.pageSize, + questionCategoryId: this.$refs.typeTree.getCurrentKey() || '', + }) + this.list = res.message.records + this.total = res.message.total }, // 切换页码 currentChange (val) { this.page = val this.getList() }, - handleSelectionChange (val) { // 多选 + // 多选 + handleSelectionChange (val) { this.multipleSelection = val }, initData () { @@ -262,80 +228,93 @@ export default { this.page = 1 this.getList() }, + // 排序回调 + sortChange (column) { + // 1上2下 + if (column.prop === 'questionNumOrderBy') this.filter.questionNumOrderBy = column.order ? column.order === 'ascending' ? 'asc' : 'desc' : '' + if (column.prop === 'createTime') this.filter.timeOrderBy = column.order ? column.order === 'ascending' ? 'asc' : 'desc' : '' + this.getList() + }, // 删除 - del (row) { - this.$confirm("确定要删除吗?", "提示", { - type: "warning" - }).then(() => { - this.$post(`${this.api.delPartnerAccount}?accountId=${row.accountId}`).then(res => { - Util.successMsg("删除成功") - this.getList() - }).catch(res => { }) - }).catch(() => { }) + async del (row) { + try { + await this.$confirm(`

    确认要删除【${row.questionBankName}】吗?

    删除后,题库中的知识点框架与题目将会被删除,请谨慎操作!

    `, '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning', + closeOnClickModal: false, + dangerouslyUseHTMLString: true, + }) + await this.$post(this.api.questionBankDel, [row.id]) + Util.successMsg('删除成功') + this.getList() + } catch (e) { } }, async switchOff (val, row) { - this.$post(this.api.disabledEventsCompetition, { - competitionId: row.id, - isOpen: val, - type: 0 // 禁用平台来源(0中台,1职站) - }).then(res => { - Util.successMsg(val == 1 ? '禁用成功' : '启用成功') - }).catch(err => { }) - - await this.$post(`${this.api.refreshPageNotification}?content=1`) - }, - // 编辑 - edit (row) { - if (!row.provinceId) row.provinceId = '' - if (!row.cityId) row.cityId = '' - row.roleList = row.roleId.split(',').map(e => +e) - this.editVisible = true - this.form = JSON.parse(JSON.stringify(row)) - }, - // 编辑提交 - submitEdit () { - this.$refs.form.validate((valid) => { - if (valid) { - if (this.submiting) return false - this.submiting = true - const form = JSON.parse(JSON.stringify(this.form)) - form.classificationId = form.partnerClassificationId - this.$post(this.api.editProvinceCity, form).then(res => { - this.getList() - Util.successMsg("编辑成功!") - this.editVisible = false - setTimeout(() => { - this.submiting = false - }, 2000) - }).catch(res => { - setTimeout(() => { - this.submiting = false - }, 2000) - }) - } - }) + await this.$post(`${this.api.questionBankDisable}?id=${row.id}&status=${val}`) + Util.successMsg(val ? '启用成功' : '禁用成功') + this.getList() }, // 添加 add () { + this.getEnableType() + this.isCopy = false + const type = this.$refs.typeTree.getCurrentNode() + this.form = { + questionBankDescription: '', + questionBankName: '', + categoryIds: type ? type.path.split('/').map(e => +e) : [], + } + this.quesBankVisible = true + }, + // 编辑/复制 + async edit (row, isCopy) { + this.getEnableType() + this.isCopy = isCopy + const res = await this.$post(`${this.api.questionBankFind}?id=${row.id}`) + const type = res.message.questionBankCategoryRelations this.quesBankVisible = true + this.form = { + id: row.id, + questionBankName: row.questionBankName, + questionBankDescription: row.questionBankDescription, + categoryIds: type && type.length ? type[0].path.split('/').map(e => +e) : [], + } + }, + // 获取启用的题库分类 + async getEnableType () { + if (!this.enableTypes.length) { + try { + const { data } = await this.$post(this.api.getAllQuestionBankCategories, { + createSource: 1, + status: 1, + }) + this.handleList(data) + this.enableTypes = data + } catch (e) { } + } }, // 题库提交 - quesBankSubmit () { - + async quesBankSubmit () { + if (this.submiting) return false + const { form } = this + if (!form.categoryIds.length) return Util.warningMsg('请选择分类') + if (!form.questionBankName) return Util.warningMsg('请输入题库名称') + this.submiting = true + if (form.categoryIds.length) form.categoryIds = [form.categoryIds[form.categoryIds.length - 1]] + // form.systemId = this.systemId + form.createSource = 1 + await this.$post(this.api.questionBankSave, form) + Util.successMsg('保存成功') + this.quesBankVisible = false + this.submiting = false + this.getList() }, } };