refactor: 优化项目创建相关代码

This commit is contained in:
Captain.B 2021-06-01 11:28:02 +08:00 committed by 刘瑞斌
parent 5df76a9e8b
commit decc06d27c
1 changed files with 352 additions and 342 deletions

View File

@ -2,7 +2,8 @@
<div>
<el-card class="table-card" v-loading="result.loading">
<template v-slot:header>
<ms-table-header :create-permission="['SYSTEM_WORKSPACE:READ+CREATE']" :condition.sync="condition" @search="list" @create="create"
<ms-table-header :create-permission="['SYSTEM_WORKSPACE:READ+CREATE']" :condition.sync="condition"
@search="list" @create="create"
:create-tip="$t('workspace.create')" :title="$t('commons.workspace')"/>
</template>
<!-- workspace table -->
@ -24,7 +25,9 @@
<div>
<ms-table-operator :edit-permission="['SYSTEM_WORKSPACE:READ+EDIT']"
:delete-permission="['SYSTEM_WORKSPACE:READ+DELETE']"
@editClick="edit(scope.row)" @deleteClick="handleDelete(scope.row)"/>
:show-delete="workspaceId !== scope.row.id"
@editClick="edit(scope.row)"
@deleteClick="handleDelete(scope.row)"/>
</div>
</template>
</el-table-column>
@ -216,10 +219,12 @@
import MsDialogFooter from "../../common/components/MsDialogFooter";
import {
getCurrentUser,
getCurrentWorkspaceId, listenGoBack,
refreshSessionAndCookies, removeGoBackListener
getCurrentWorkspaceId,
listenGoBack,
refreshSessionAndCookies,
removeGoBackListener
} from "@/common/js/utils";
import {DEFAULT, GROUP_ORGANIZATION, GROUP_WORKSPACE, WORKSPACE} from "@/common/js/constants";
import {DEFAULT, GROUP_WORKSPACE, WORKSPACE} from "@/common/js/constants";
import MsDeleteConfirm from "../../common/components/MsDeleteConfirm";
export default {
@ -243,16 +248,16 @@
this.form = {};
this.$get("/organization/list", response => {
this.$set(this.form, "orgList", response.data);
})
});
listenGoBack(this.close);
},
dataFilter(val) {
if (val) {
this.memberForm.userList = this.memberForm.copyUserList.filter((item) => {
if (!!~item.id.indexOf(val) || !!~item.id.toUpperCase().indexOf(val.toUpperCase())) {
return true
return true;
}
})
});
} else {
this.memberForm.userList = this.memberForm.copyUserList;
}
@ -262,7 +267,7 @@
if (valid) {
let saveType = 'special/add';
if (this.form.id) {
saveType = 'update'
saveType = 'update';
}
this.result = this.$post("/workspace/" + saveType, this.form, () => {
this.dialogWsAddVisible = false;
@ -282,7 +287,7 @@
});
this.result = this.$post('/user/group/list', {type: GROUP_WORKSPACE, resourceId: this.wsId}, response => {
this.$set(this.memberForm, "groups", response.data);
})
});
listenGoBack(this.handleClose);
},
@ -305,7 +310,7 @@
this.$get(url + "/" + encodeURIComponent(this.memberLineData[i].id), response => {
let groups = response.data;
this.$set(this.memberLineData[i], "groups", groups);
})
});
}
this.dialogTotal = data.itemCount;
});
@ -326,7 +331,7 @@
this.$get(url + "/" + encodeURIComponent(this.memberLineData[i].id), response => {
let groups = response.data;
this.$set(this.memberLineData[i], "groups", groups);
})
});
}
this.dialogTotal = data.itemCount;
});
@ -337,7 +342,7 @@
this.form = Object.assign({}, row);
this.$get("/organization/list", response => {
this.$set(this.form, "orgList1", response.data);
})
});
listenGoBack(this.close);
},
close() {
@ -356,7 +361,7 @@
} else {
return false;
}
})
});
},
handleClose() {
this.memberForm = {};
@ -379,12 +384,12 @@
let param = {
name: '',
workspaceId: this.items[i].id
}
};
let path = "user/special/ws/member/list/all";
this.$post(path, param, res => {
let member = res.data;
this.$set(this.items[i], "memberSize", member.length);
})
});
}
this.total = data.itemCount;
});
@ -400,7 +405,7 @@
this.result = this.$post("user/special/ws/member/add", param, () => {
this.cellClick(this.currentWorkspaceRow);
this.dialogWsMemberAddVisible = false;
})
});
} else {
return false;
}
@ -413,7 +418,7 @@
let groupIds = this.memberForm.groups.map(r => r.id);
this.result = this.$post('/user/group/list', {type: GROUP_WORKSPACE, resourceId: this.wsId}, response => {
this.$set(this.memberForm, "allgroups", response.data);
})
});
// console.log(this.memberForm)
//
this.$set(this.memberForm, 'groupIds', groupIds);
@ -474,7 +479,7 @@
phone: this.memberForm.phone,
groupIds: this.memberForm.groupIds,
workspaceId: this.currentWorkspaceRow.id
}
};
this.$refs[formName].validate((valid) => {
if (valid) {
this.result = this.$post("/workspace/member/update", param, () => {
@ -486,6 +491,11 @@
});
},
},
computed: {
workspaceId() {
return getCurrentWorkspaceId();
}
},
data() {
return {
result: {},
@ -538,9 +548,9 @@
},
currentWorkspaceRow: {},
wsId: ""
};
}
}
}
};
</script>
<style scoped>