2020-07-14 14:40:55 +08:00
|
|
|
|
<template>
|
2020-07-16 17:33:20 +08:00
|
|
|
|
<div class="right-box right-box-account" v-clickoutside="clickOutside">
|
2020-07-14 14:40:55 +08:00
|
|
|
|
<!-- begin--顶部按钮-->
|
2020-10-15 14:27:46 +08:00
|
|
|
|
<div class="right-box-top-btns right-box-form-delete">
|
2020-07-15 10:58:45 +08:00
|
|
|
|
<button type="button" v-if="editUser.userId" @click="del"
|
2020-10-15 14:27:46 +08:00
|
|
|
|
class="nz-btn nz-btn-size-normal nz-btn-size-alien"
|
2020-07-14 14:40:55 +08:00
|
|
|
|
id="account-edit-del">
|
2020-09-10 17:00:32 +08:00
|
|
|
|
<span class="right-box-top-btn-icon"><i class="nz-icon nz-icon-delete"></i></span>
|
2020-07-14 14:40:55 +08:00
|
|
|
|
<span class="right-box-top-btn-txt">{{$t('overall.delete')}}</span>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<!-- end--顶部按钮-->
|
|
|
|
|
|
|
|
|
|
|
|
<!-- begin--标题-->
|
|
|
|
|
|
<div class="right-box-title">{{editUser.userId ? ($t("config.account.editAccount") + " ID:" + editUser.userId) : $t("config.account.createAccount")}}</div>
|
|
|
|
|
|
<!-- end--标题-->
|
|
|
|
|
|
|
|
|
|
|
|
<!-- begin--表单-->
|
|
|
|
|
|
<el-scrollbar class="right-box-form-box">
|
2020-10-15 14:27:46 +08:00
|
|
|
|
<el-form class="right-box-form right-box-form-left" :model="editUser" :rules="rules" ref="accountForm" label-position="right" label-width="120px">
|
2020-07-14 14:40:55 +08:00
|
|
|
|
<!--username-->
|
|
|
|
|
|
<el-form-item :label="$t('config.account.account')" prop="username">
|
|
|
|
|
|
<el-input autocomplete="new-password" type="text" placeholder=""
|
|
|
|
|
|
v-model="editUser.username" maxlength="64" show-word-limit size="small"></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!--password-->
|
|
|
|
|
|
<el-form-item :label="$t('config.account.password')" prop="password" v-if="!editUser.userId">
|
|
|
|
|
|
<el-input autocomplete="new-password" type="password" placeholder="" v-model="editUser.password"
|
|
|
|
|
|
maxlength="16" show-word-limit size="small"></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!--email-->
|
|
|
|
|
|
<el-form-item label="E-mail" prop="email">
|
|
|
|
|
|
<el-input type="text" placeholder="" v-model="editUser.email" size="small"></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!--enable-->
|
|
|
|
|
|
<el-form-item :label="$t('config.account.enable')">
|
|
|
|
|
|
<el-switch v-model="editUser.status" active-color="#ee9d3f" :disabled="isCurrentUser(editUser.username)" active-value="1"
|
|
|
|
|
|
inactive-value="0">
|
|
|
|
|
|
</el-switch>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item :label="$t('config.account.createTime')" v-if="editUser.userId">
|
|
|
|
|
|
<div class="right-box-form-content-txt">{{editUser.createTime}}</div>
|
|
|
|
|
|
</el-form-item>
|
2020-11-19 15:10:38 +08:00
|
|
|
|
|
|
|
|
|
|
<div class="right-box-sub-title">{{$t('config.account.notification')}}
|
|
|
|
|
|
<button @click="addNotification" id="add-notification" type="button" class="float-right" :disabled="addDisabled">
|
|
|
|
|
|
<span><i class="nz-icon nz-icon-create-square"></i></span>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="right-box-line"></div>
|
|
|
|
|
|
|
|
|
|
|
|
<el-form-item v-for="(notification, index) in editUser.notifications" :key="index" class="notification-item">
|
|
|
|
|
|
<el-select v-model="notification.scriptId" slot="label" placeholder="" popper-class="no-style-class" size="small">
|
|
|
|
|
|
<el-option v-for="(item, i) in selectableScripts" :label="item.name" :key="i" :value="item.id" :disabled="item.disabled"></el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
<el-input placeholder="" v-model="notification.account" size="small" style="width: calc(100% - 37px);"></el-input>
|
|
|
|
|
|
<span @click="removeNotification(index)" style="padding-left: 5px;"><i class="nz-icon nz-icon-shanchu1"></i></span>
|
|
|
|
|
|
</el-form-item>
|
2020-07-14 14:40:55 +08:00
|
|
|
|
</el-form>
|
|
|
|
|
|
</el-scrollbar>
|
|
|
|
|
|
<!-- end--表单-->
|
|
|
|
|
|
<!--底部按钮-->
|
|
|
|
|
|
<div class="right-box-bottom-btns">
|
|
|
|
|
|
<button @click="esc" id="account-esc"
|
2020-10-12 16:13:55 +08:00
|
|
|
|
class="nz-btn nz-btn-size-normal-new nz-btn-style-light-new">
|
2020-07-14 14:40:55 +08:00
|
|
|
|
<span>{{$t('overall.cancel')}}</span>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
<button @click="save" id="account-save"
|
2020-10-12 16:13:55 +08:00
|
|
|
|
class="nz-btn nz-btn-size-normal-new nz-btn-style-normal-new">
|
2020-07-14 14:40:55 +08:00
|
|
|
|
<span>{{$t('overall.save')}}</span>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
|
|
|
export default {
|
|
|
|
|
|
name: "accountBox",
|
|
|
|
|
|
props: {
|
|
|
|
|
|
user: Object
|
|
|
|
|
|
},
|
|
|
|
|
|
computed: {
|
|
|
|
|
|
isCurrentUser() {
|
|
|
|
|
|
return function(username) {
|
|
|
|
|
|
return localStorage.getItem('nz-username') == username;
|
|
|
|
|
|
}
|
2020-11-19 15:10:38 +08:00
|
|
|
|
},
|
|
|
|
|
|
addDisabled() {
|
|
|
|
|
|
let enabled = this.selectableScripts.filter(item => {return !item.disabled});
|
|
|
|
|
|
return enabled.length === 0;
|
2020-07-14 14:40:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
2020-11-19 15:10:38 +08:00
|
|
|
|
scriptIds: [],
|
2020-07-14 14:40:55 +08:00
|
|
|
|
rules: { //表单校验规则
|
|
|
|
|
|
username: [
|
|
|
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'}
|
|
|
|
|
|
],
|
|
|
|
|
|
password: [
|
|
|
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'}
|
|
|
|
|
|
],
|
|
|
|
|
|
email: [
|
|
|
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'},
|
|
|
|
|
|
{type: 'email', message: this.$t('validate.email')}
|
|
|
|
|
|
]
|
|
|
|
|
|
},
|
2020-11-19 15:10:38 +08:00
|
|
|
|
editUser: {},
|
|
|
|
|
|
scripts: [],
|
|
|
|
|
|
selectableScripts: []
|
2020-07-14 14:40:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
/*关闭弹框*/
|
|
|
|
|
|
esc(refresh) {
|
|
|
|
|
|
this.$emit("close", refresh);
|
|
|
|
|
|
},
|
2020-07-16 17:33:20 +08:00
|
|
|
|
clickOutside() {
|
|
|
|
|
|
this.esc(false);
|
|
|
|
|
|
},
|
2020-07-14 14:40:55 +08:00
|
|
|
|
/*保存*/
|
|
|
|
|
|
save() {
|
2020-07-15 20:43:19 +08:00
|
|
|
|
this.$refs.accountForm.validate(valid => {
|
2020-07-14 14:40:55 +08:00
|
|
|
|
if (valid) {
|
|
|
|
|
|
if (this.editUser.userId) {
|
|
|
|
|
|
this.$put('sys/user/update', this.editUser).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")});
|
|
|
|
|
|
this.esc(true);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$post('sys/user/save', this.editUser).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")});
|
|
|
|
|
|
this.esc(true);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
/*删除*/
|
|
|
|
|
|
del() {
|
|
|
|
|
|
this.$confirm(this.$t("tip.confirmDelete"), {
|
|
|
|
|
|
confirmButtonText: this.$t("tip.yes"),
|
|
|
|
|
|
cancelButtonText: this.$t("tip.no"),
|
|
|
|
|
|
type: 'warning'
|
|
|
|
|
|
}).then(() => {
|
|
|
|
|
|
this.$delete("sys/user/delete?userIds=" + this.editUser.userId).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.$message({duration: 1000, type: 'success', message: this.$t("tip.deleteSuccess")});
|
|
|
|
|
|
this.esc(true);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
2020-11-19 15:10:38 +08:00
|
|
|
|
|
|
|
|
|
|
getScripts() {
|
|
|
|
|
|
/*this.$get("/alert/script?pageNo=1&pageSize=-1").then(response => {
|
|
|
|
|
|
this.scripts = response.data.list;
|
|
|
|
|
|
this.getSelectableScripts();
|
|
|
|
|
|
});*/
|
|
|
|
|
|
this.scripts = [
|
|
|
|
|
|
{id: 1, name: "DOLBY"},
|
|
|
|
|
|
{id: 2, name: "IMAX"},
|
|
|
|
|
|
{id: 3, name: "CGS"},
|
|
|
|
|
|
{id: 4, name: "LUXE"},
|
|
|
|
|
|
{id: 5, name: "DST:X"},
|
|
|
|
|
|
];
|
|
|
|
|
|
this.getSelectableScripts();
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
getSelectableScripts() {
|
|
|
|
|
|
this.selectableScripts = this.scripts.map(item => {
|
|
|
|
|
|
let exist = this.editUser.notifications.some(n => {
|
|
|
|
|
|
return item.id === n.scriptId;
|
|
|
|
|
|
});
|
|
|
|
|
|
if (exist) {
|
|
|
|
|
|
this.$set(item, "disabled", true);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$set(item, "disabled", false);
|
|
|
|
|
|
}
|
|
|
|
|
|
return item;
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
addNotification() {
|
|
|
|
|
|
let scripts = this.selectableScripts.find(item => {
|
|
|
|
|
|
return item.disabled === false;
|
|
|
|
|
|
});
|
|
|
|
|
|
scripts && this.editUser.notifications.push({scriptId: scripts.id, account: ""});
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
removeNotification(index) {
|
|
|
|
|
|
this.editUser.notifications.splice(index, 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
mounted() {
|
|
|
|
|
|
this.getScripts();
|
2020-07-14 14:40:55 +08:00
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
2020-07-15 10:58:45 +08:00
|
|
|
|
//将prop里的user转为组件内部对象
|
2020-07-14 14:40:55 +08:00
|
|
|
|
user: {
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
deep: true,
|
|
|
|
|
|
handler(n) {
|
|
|
|
|
|
this.editUser = JSON.parse(JSON.stringify(n));
|
|
|
|
|
|
}
|
2020-11-19 15:10:38 +08:00
|
|
|
|
},
|
|
|
|
|
|
"editUser.notifications": {
|
|
|
|
|
|
deep: true,
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
handler(n) {
|
|
|
|
|
|
this.getSelectableScripts();
|
|
|
|
|
|
}
|
2020-07-14 14:40:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
2020-11-19 15:10:38 +08:00
|
|
|
|
<style lang="scss">
|
|
|
|
|
|
.right-box-account {
|
|
|
|
|
|
.right-box-sub-title {
|
|
|
|
|
|
#add-notification {
|
|
|
|
|
|
border: none;
|
|
|
|
|
|
outline: none;
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
|
|
|
|
i {
|
|
|
|
|
|
font-size: 17px;
|
|
|
|
|
|
background-color: #f6f6f6;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.notification-item {
|
|
|
|
|
|
.el-select {
|
|
|
|
|
|
width: 100px;
|
|
|
|
|
|
|
|
|
|
|
|
.el-input__inner {
|
|
|
|
|
|
vertical-align: top;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|