diff --git a/frontend/src/views/grading-admin/index.vue b/frontend/src/views/grading-admin/index.vue index 923df5b07..69a6a94a2 100644 --- a/frontend/src/views/grading-admin/index.vue +++ b/frontend/src/views/grading-admin/index.vue @@ -61,13 +61,30 @@ @@ -160,13 +177,30 @@ @@ -279,6 +313,7 @@ import IamEditInput from '@/views/my-manage-space/components/iam-edit/input'; import IamEditMemberSelector from '@/views/my-manage-space/components/iam-edit/member-selector'; import IamEditTextarea from '@/views/my-manage-space/components/iam-edit/textarea'; + import IamManagerEditInput from '@/components/iam-edit/input'; import IamSearchSelect from '@/components/iam-search-select'; import ManageInterviewDialog from '@/components/manage-interview-dialog'; @@ -288,6 +323,7 @@ ConfirmDialog, ApplyDialog, IamEditInput, + IamManagerEditInput, IamEditMemberSelector, IamEditTextarea, IamSearchSelect, @@ -418,6 +454,13 @@ return !['child-operate'].includes(column.property) ? 'iam-table-cell-1-cls' : ''; }, + getMemberFilter (value) { + if (value.length) { + return _.isArray(value) ? value.map(item => item.username).join(';') : value; + } + return '--'; + }, + handleExpandChange (row, expandedRows) { // if (row.id !== this.gradingAdminId) return; this.gradingAdminId = row.id; @@ -469,6 +512,40 @@ return JSON.parse(window.localStorage.getItem('gradeManagerList')); }, + handleOpenManagerEdit (payload, index) { + this.$set(this.tableList[index], 'isEdit', true); + this.$nextTick(() => { + const managerRef = this.$refs[`managerRef${index}`]; + if (managerRef) { + managerRef.isEditable = true; + if (!payload.members.length) { + setTimeout(() => { + this.$refs[`managerRef${index}`].$refs.selector.focus(); + }, 10); + } + } + }); + }, + + handleOpenSubManagerEdit (payload, index) { + this.$set(payload, 'isEdit', true); + this.$nextTick(() => { + const subManagerRef = this.$refs[`subManagerRef${index}`]; + if (subManagerRef) { + subManagerRef.isEditable = true; + if (!payload.members.length) { + setTimeout(() => { + subManagerRef.$refs.selector.focus(); + }, 10); + } + } + }); + }, + + handleEmptyMemberChange (index, row) { + row.isEdit = false; + }, + async fetchGradingAdmin (isTableLoading = false) { this.tableLoading = isTableLoading; this.setCurrentQueryCache(this.refreshCurrentQuery()); @@ -479,9 +556,12 @@ name: this.searchValue }); this.pagination.count = data.count || 0; - data.results = data.results.map(e => { - e.children = []; - return e; + data.results = data.results.map((item) => { + item = Object.assign(item, { + isEdit: false, + children: [] + }); + return item; }); this.tableList.splice(0, this.tableList.length, ...(data.results || [])); if (this.isStaff) { diff --git a/frontend/src/views/manage-spaces/secondary-manage-space/index.vue b/frontend/src/views/manage-spaces/secondary-manage-space/index.vue index dc7b7a95c..d5ae423c9 100644 --- a/frontend/src/views/manage-spaces/secondary-manage-space/index.vue +++ b/frontend/src/views/manage-spaces/secondary-manage-space/index.vue @@ -29,13 +29,30 @@ @@ -89,11 +106,13 @@ import { buildURLParams } from '@/common/url'; import { formatCodeData, getWindowHeight } from '@/common/util'; import IamEditMemberSelector from '@/views/my-manage-space/components/iam-edit/member-selector'; + import IamManagerEditInput from '@/components/iam-edit/input'; export default { name: 'secondaryManageSpace', components: { - IamEditMemberSelector + IamEditMemberSelector, + IamManagerEditInput }, data () { return { @@ -215,6 +234,32 @@ await this.fetchGradingAdmin(true); }, + getMemberFilter (value) { + if (value.length) { + return Array.isArray(value) ? value.map(item => item.username).join(';') : value; + } + return '--'; + }, + + handleOpenManagerEdit (payload, index) { + this.$set(this.tableList[index], 'isEdit', true); + this.$nextTick(() => { + const managerRef = this.$refs[`managerRef${index}`]; + if (managerRef) { + managerRef.isEditable = true; + if (!payload.members.length) { + setTimeout(() => { + this.$refs[`managerRef${index}`].$refs.selector.focus(); + }, 10); + } + } + }); + }, + + handleEmptyMemberChange (index, row) { + row.isEdit = false; + }, + handleNavAuthBoundary (payload) { window.localStorage.setItem('iam-header-name-cache', payload.name); this.$store.commit('updateIndex', 1); diff --git a/frontend/src/views/my-manage-space/components/iam-edit/member-selector.vue b/frontend/src/views/my-manage-space/components/iam-edit/member-selector.vue index c523dabdd..01016ace9 100644 --- a/frontend/src/views/my-manage-space/components/iam-edit/member-selector.vue +++ b/frontend/src/views/my-manage-space/components/iam-edit/member-selector.vue @@ -86,9 +86,15 @@ return ['detail', 'edit'].includes(value); } }, + // 默认允许空 allowEmpty: { type: Boolean, default: false + }, + // 编辑不允许空 + isEditAllowEmpty: { + type: Boolean, + default: true } }, data () { @@ -110,6 +116,9 @@ }, isEditMode () { return this.mode === 'edit'; + }, + isAllowTrigger () { + return JSON.stringify(this.displayValue) !== JSON.stringify(this.value); } }, watch: { @@ -169,10 +178,9 @@ handleEnter (event) { if (!this.isEditable) return; const { key, keyCode } = event; - const isUpdate = JSON.stringify(this.displayValue) !== JSON.stringify(this.value); if (key === 'Enter' && keyCode === 13) { this.handleDefaultEmpty(); - if (isUpdate) { + if (this.isAllowTrigger) { this.handleEmptyChange(); this.isEditable = false; } else { @@ -198,7 +206,14 @@ }, triggerChange () { - if (JSON.stringify(this.displayValue) !== JSON.stringify(this.value)) { + console.log(this.isAllowTrigger, this.displayValue, '显示内容'); + // 单独处理初始化为空但编辑不能为空数据 + if (!this.displayValue.length && !this.isEditAllowEmpty) { + this.displayValue = [...this.value]; + this.messageWarn(this.$t(`m.verify['管理员不能为空']`), 3000); + return; + } + if (this.isAllowTrigger) { this.isLoading = true; this.remoteHandler({ [this.field]: this.displayValue @@ -229,7 +244,7 @@ handleRtxBlur () { this.isEditable = false; this.handleDefaultEmpty(); - if (JSON.stringify(this.displayValue) !== JSON.stringify(this.value)) { + if (this.isAllowTrigger) { this.handleEmptyChange(); } }, diff --git a/frontend/src/views/my-manage-space/index.vue b/frontend/src/views/my-manage-space/index.vue index af9820dcb..6625b7af1 100644 --- a/frontend/src/views/my-manage-space/index.vue +++ b/frontend/src/views/my-manage-space/index.vue @@ -86,14 +86,30 @@ @@ -207,16 +223,31 @@ -