2022-08-12 17:52:06 +08:00
|
|
|
<template>
|
|
|
|
|
<div class="right-box right-box-issue" v-clickoutside="{obj:editIssue,func:clickOutside}">
|
|
|
|
|
<!-- begin--标题-->
|
|
|
|
|
<div class="right-box__header">
|
|
|
|
|
<div class="header__title">{{editIssue.id ? $t("overall.issue.edit") : $t("overall.createIssue")}}</div>
|
|
|
|
|
<div class="header__operation">
|
|
|
|
|
<span v-cancel="{obj: editIssue, func: esc}"><i class="nz-icon nz-icon-close" :title="$t('overall.close')"></i></span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<!-- end--标题-->
|
|
|
|
|
|
|
|
|
|
<!-- begin--表单-->
|
|
|
|
|
<div class="right-box__container">
|
|
|
|
|
<div class="container__form">
|
|
|
|
|
<el-form ref="issueForm" :model="editIssue"
|
|
|
|
|
:rules="rules" label-position="top" label-width="120px">
|
|
|
|
|
<!-- title -->
|
|
|
|
|
<el-form-item :label='$t("project.topology.title")' prop="name">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="editIssue.name" :placeholder="''"
|
|
|
|
|
maxlength="64"
|
|
|
|
|
show-word-limit
|
2022-08-15 15:48:24 +08:00
|
|
|
ref="issueName"
|
2022-08-12 17:52:06 +08:00
|
|
|
size="small">
|
|
|
|
|
</el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<!--type-->
|
|
|
|
|
<el-form-item prop="type" :label='$t("overall.type")' :rules="{ required: true, message: $t('validate.required'), change: 'blur'}">
|
|
|
|
|
<el-select
|
|
|
|
|
v-model="editIssue.type"
|
2022-08-15 15:48:24 +08:00
|
|
|
class="type-select"
|
|
|
|
|
:placeholder="editIssue.type"
|
2022-08-12 17:52:06 +08:00
|
|
|
style="margin-right: 10px"
|
|
|
|
|
filterable
|
|
|
|
|
allow-create
|
|
|
|
|
default-first-option
|
|
|
|
|
>
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in issueTypeSelect"
|
|
|
|
|
:value="item"
|
|
|
|
|
:label="item"
|
|
|
|
|
:key="item"/>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<!--priority-->
|
2022-08-15 15:48:24 +08:00
|
|
|
<el-form-item :label="$t('alert.severity')" prop="priority">
|
|
|
|
|
<el-select v-model="editIssue.priority" clearable :placeholder="$t('issue.middle')" size="small" value-key="state" class="type-select">
|
|
|
|
|
<el-option v-for="item in priorityData" :key="item.id" :label="item.value" :value="item.id">
|
|
|
|
|
{{item.value}}
|
|
|
|
|
</el-option>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
2022-08-12 17:52:06 +08:00
|
|
|
<!--state-->
|
|
|
|
|
<el-form-item :label="$t('overall.state')" prop="state">
|
2022-09-02 15:42:29 +08:00
|
|
|
<el-select v-model="editIssue.state" placeholder='' size="small" value-key="state" class="type-select">
|
2022-08-15 15:48:24 +08:00
|
|
|
<el-option v-for="item in stateData" :key="item.id" :label="item.value" :value="item.id">
|
2022-08-12 17:52:06 +08:00
|
|
|
{{item.value}}
|
|
|
|
|
</el-option>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<!-- Relate Assets -->
|
|
|
|
|
<el-form-item :label="$t('issue.relateAssets')" prop="assetIds">
|
2022-08-16 15:27:42 +08:00
|
|
|
<v-selectpage
|
2022-08-12 17:52:06 +08:00
|
|
|
ref="selectPage"
|
2022-08-16 15:27:42 +08:00
|
|
|
:data="assetList"
|
2022-08-12 17:52:06 +08:00
|
|
|
:tb-columns="columns"
|
2022-08-16 15:27:42 +08:00
|
|
|
:params="{
|
|
|
|
|
varType: 1, panelId: 0,
|
|
|
|
|
returnChildren:0,groupId:0,
|
|
|
|
|
}"
|
|
|
|
|
:multiple="true"
|
|
|
|
|
:language="languages"
|
2022-08-12 17:52:06 +08:00
|
|
|
key-field="id"
|
2022-08-16 15:27:42 +08:00
|
|
|
:width="640"
|
2022-08-12 17:52:06 +08:00
|
|
|
v-model="editIssue.assetIds"
|
2022-08-16 15:27:42 +08:00
|
|
|
show-field="manageIp"
|
|
|
|
|
class="form-control"
|
2022-08-16 11:52:55 +08:00
|
|
|
@values="(data) => {editIssue.assetIds = data.map(d => d.id).join(',')}"
|
2022-08-16 15:27:42 +08:00
|
|
|
:result-format="resultFormat"
|
|
|
|
|
></v-selectpage>
|
2022-08-12 17:52:06 +08:00
|
|
|
</el-form-item>
|
|
|
|
|
<!-- Reporter -->
|
|
|
|
|
<el-form-item :label='$t("issue.reporter")' prop="rid">
|
|
|
|
|
<el-select
|
|
|
|
|
id="issue-box-input-receiver"
|
|
|
|
|
v-model.trim="editIssue.rid"
|
|
|
|
|
class="right-box__select"
|
|
|
|
|
filterable
|
|
|
|
|
placeholder=""
|
|
|
|
|
popper-class="prevent-clickoutside right-box-select-top"
|
|
|
|
|
size="small"
|
|
|
|
|
value-key="userId"
|
|
|
|
|
>
|
|
|
|
|
<el-option
|
|
|
|
|
style="width: 620px"
|
|
|
|
|
v-for="item in userData"
|
|
|
|
|
:key="item.id"
|
|
|
|
|
:label="item.name"
|
|
|
|
|
:value="item.id">
|
|
|
|
|
<span class="user-name" :title="item.name">{{item.name}}</span><span class="user-username" :title="item.username">@{{item.username}}</span>
|
|
|
|
|
</el-option>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<!-- Assignee -->
|
|
|
|
|
<el-form-item :label='$t("issue.assignee")' prop="aid">
|
|
|
|
|
<el-select
|
|
|
|
|
id="issue-box-input-receiver"
|
|
|
|
|
v-model.trim="editIssue.aid"
|
|
|
|
|
class="right-box__select"
|
|
|
|
|
filterable
|
|
|
|
|
placeholder=""
|
|
|
|
|
popper-class="prevent-clickoutside right-box-select-top"
|
|
|
|
|
size="small"
|
|
|
|
|
value-key="userId"
|
|
|
|
|
>
|
|
|
|
|
<el-option
|
|
|
|
|
style="width: 620px"
|
|
|
|
|
v-for="item in userData"
|
|
|
|
|
:key="item.id"
|
|
|
|
|
:label="item.name"
|
|
|
|
|
:value="item.id">
|
|
|
|
|
<span class="user-name" :title="item.name">{{item.name}}</span><span class="user-username" :title="item.username">@{{item.username}}</span>
|
|
|
|
|
</el-option>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<!-- remark -->
|
|
|
|
|
<el-form-item :label='$t("overall.remark")' prop="content">
|
2022-08-16 11:52:55 +08:00
|
|
|
<rich-text-editor ref="richTextEditor" :edit-data="editIssue.content" @textChange="textChange"></rich-text-editor>
|
2022-08-12 17:52:06 +08:00
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
<!-- end--表单-->
|
|
|
|
|
|
|
|
|
|
<!--底部按钮-->
|
|
|
|
|
<div class="right-box__footer">
|
|
|
|
|
<button v-cancel="{obj:editIssue,func:esc}" id="alert-box-esc"
|
|
|
|
|
class="footer__btn footer__btn--light">
|
|
|
|
|
<span>{{$t('overall.cancel')}}</span>
|
|
|
|
|
</button>
|
|
|
|
|
<button :class="{'nz-btn-disabled':prevent_opt.save}" :disabled="prevent_opt.save" @click="save"
|
|
|
|
|
class="footer__btn" id="alert-box-save">
|
|
|
|
|
<span>{{$t('overall.save')}}</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import editRigthBox from '../mixin/editRigthBox'
|
|
|
|
|
import richTextEditor from '@/components/chart/richTextEditor'
|
2022-08-16 11:52:55 +08:00
|
|
|
import { noSpecialChar } from '@/components/common/js/validate'
|
|
|
|
|
import publicConfig from '@/components/common/rightBox/chart/publicConfig'
|
2022-08-12 17:52:06 +08:00
|
|
|
export default {
|
|
|
|
|
name: 'issueBox',
|
|
|
|
|
components: {
|
|
|
|
|
richTextEditor
|
|
|
|
|
},
|
2022-08-16 11:52:55 +08:00
|
|
|
mixins: [editRigthBox, publicConfig],
|
2022-08-12 17:52:06 +08:00
|
|
|
props: {
|
|
|
|
|
issue: Object
|
|
|
|
|
},
|
|
|
|
|
data () {
|
|
|
|
|
return {
|
2022-08-16 15:27:42 +08:00
|
|
|
// selectPageParams: {},
|
|
|
|
|
assetList: [], // asset 列表数据
|
2022-08-12 17:52:06 +08:00
|
|
|
issueTypeSelect: [],
|
|
|
|
|
userData: [],
|
|
|
|
|
editIssue: {
|
|
|
|
|
id: '',
|
|
|
|
|
name: '',
|
2022-08-15 15:48:24 +08:00
|
|
|
type: 'default',
|
2022-08-12 17:52:06 +08:00
|
|
|
content: '',
|
|
|
|
|
state: '',
|
2022-08-15 15:48:24 +08:00
|
|
|
priority: 2,
|
2022-08-12 17:52:06 +08:00
|
|
|
rid: '',
|
|
|
|
|
aid: '',
|
|
|
|
|
assetIds: ''
|
|
|
|
|
},
|
|
|
|
|
rules: {
|
|
|
|
|
name: [
|
2022-08-16 11:52:55 +08:00
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' },
|
|
|
|
|
{ validator: noSpecialChar, trigger: 'blur' }
|
|
|
|
|
],
|
|
|
|
|
type: [
|
|
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'change' }
|
|
|
|
|
],
|
|
|
|
|
content: [
|
|
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
|
|
|
|
|
],
|
|
|
|
|
rid: [
|
|
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'change' }
|
|
|
|
|
],
|
|
|
|
|
aid: [
|
|
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'change' }
|
|
|
|
|
],
|
|
|
|
|
state: [
|
2022-08-12 17:52:06 +08:00
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'change' }
|
|
|
|
|
]
|
|
|
|
|
},
|
2022-08-15 15:48:24 +08:00
|
|
|
// 下拉选择框(表格)
|
2022-08-12 17:52:06 +08:00
|
|
|
columns: [
|
|
|
|
|
{ title: 'ID', data: 'id' },
|
|
|
|
|
{
|
|
|
|
|
title: 'Name',
|
|
|
|
|
data: function (row) {
|
|
|
|
|
if (row.name.length > 15) {
|
|
|
|
|
return row.name.substring(0, 12) + '...'
|
|
|
|
|
}
|
|
|
|
|
return row.name
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{ title: 'Manage Ip', data: 'manageIp' },
|
|
|
|
|
{
|
|
|
|
|
title: 'Type',
|
|
|
|
|
data: (row) => {
|
|
|
|
|
return row.type ? row.type.name : ''
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'Model',
|
|
|
|
|
data: (row) => {
|
|
|
|
|
return row.model ? row.model.name : ''
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'Datacenter',
|
|
|
|
|
data: (row) => {
|
|
|
|
|
return row.dc ? row.dc.name : ''
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
stateData: [
|
|
|
|
|
{
|
|
|
|
|
id: 1,
|
|
|
|
|
value: this.$t('issue.open')
|
|
|
|
|
}, {
|
|
|
|
|
id: 2,
|
|
|
|
|
value: this.$t('issue.hasBeenAssigned')
|
|
|
|
|
}, {
|
|
|
|
|
id: 3,
|
|
|
|
|
value: this.$t('issue.beingProcessed')
|
|
|
|
|
}, {
|
|
|
|
|
id: 4,
|
|
|
|
|
value: this.$t('issue.hangUp')
|
|
|
|
|
}, {
|
|
|
|
|
id: 5,
|
|
|
|
|
value: this.$t('issue.resolved')
|
|
|
|
|
}, {
|
|
|
|
|
id: 6,
|
|
|
|
|
value: this.$t('overall.close')
|
|
|
|
|
}, {
|
|
|
|
|
id: 7,
|
|
|
|
|
value: this.$t('overall.cancel')
|
|
|
|
|
}
|
2022-08-15 15:48:24 +08:00
|
|
|
],
|
|
|
|
|
priorityData: [
|
|
|
|
|
{
|
|
|
|
|
id: 1,
|
|
|
|
|
value: this.$t('dashboard.panel.chartForm.high')
|
|
|
|
|
}, {
|
|
|
|
|
id: 2,
|
|
|
|
|
value: this.$t('issue.middle')
|
|
|
|
|
}, {
|
|
|
|
|
id: 3,
|
|
|
|
|
value: this.$t('issue.low')
|
|
|
|
|
}
|
2022-08-12 17:52:06 +08:00
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
mounted () {
|
|
|
|
|
this.getTypeData()
|
|
|
|
|
this.getUserList()
|
2022-08-16 15:27:42 +08:00
|
|
|
this.assetTemplateList()
|
2022-08-12 17:52:06 +08:00
|
|
|
},
|
|
|
|
|
methods: {
|
2022-08-16 15:27:42 +08:00
|
|
|
/* 获取asset列表数据 */
|
|
|
|
|
assetTemplateList () {
|
|
|
|
|
this.$get('asset/asset', { pageSize: -1, varType: 1, panelId: 0, groupId: 0 }).then(res => {
|
|
|
|
|
this.assetList = res.data.list
|
|
|
|
|
})
|
|
|
|
|
},
|
2022-08-16 11:52:55 +08:00
|
|
|
textChange (val) {
|
|
|
|
|
const html = `<div class="editor-core ql-container ql-snow"><div class="ql-editor">${val}</div></div>`
|
|
|
|
|
this.editIssue.content = html
|
|
|
|
|
this.change()
|
|
|
|
|
},
|
2022-08-12 17:52:06 +08:00
|
|
|
getTypeData () {
|
|
|
|
|
this.$get('issue/type').then(response => {
|
|
|
|
|
if (response.code === 200) {
|
2022-08-30 16:23:29 +08:00
|
|
|
this.issueTypeSelect = response.data.list
|
2022-08-12 17:52:06 +08:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
getUserList () {
|
|
|
|
|
this.$get('sys/user', { pageNo: 1, pageSize: -1 }).then(response => {
|
|
|
|
|
if (response.code == 200) {
|
|
|
|
|
this.userData = response.data.list
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
resultFormat (resp) {
|
|
|
|
|
if (resp && resp.data) {
|
|
|
|
|
const assetData = {}
|
|
|
|
|
assetData.list = resp.data.list
|
|
|
|
|
assetData.totalRow = resp.data.total
|
|
|
|
|
return assetData
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
clickOutside () {
|
|
|
|
|
this.esc(false)
|
|
|
|
|
},
|
|
|
|
|
esc (refresh) {
|
|
|
|
|
this.prevent_opt.save = false
|
|
|
|
|
this.$emit('close', refresh)
|
|
|
|
|
},
|
|
|
|
|
save () {
|
|
|
|
|
this.$refs.issueForm.validate((valid) => {
|
2022-08-15 15:48:24 +08:00
|
|
|
const assetIdsArr = this.editIssue.assetIds.split(',').map((item) => {
|
|
|
|
|
return Number(item)
|
2022-08-12 17:52:06 +08:00
|
|
|
})
|
|
|
|
|
const params = {
|
|
|
|
|
...this.editIssue,
|
2022-08-15 15:48:24 +08:00
|
|
|
assetIds: assetIdsArr,
|
|
|
|
|
content: this.$refs.richTextEditor.getContent()
|
2022-08-12 17:52:06 +08:00
|
|
|
}
|
|
|
|
|
if (valid) {
|
|
|
|
|
this.prevent_opt.save = true
|
|
|
|
|
if (this.editIssue.id) {
|
2022-08-15 15:48:24 +08:00
|
|
|
this.$put('/issue', params).then(response => {
|
2022-08-12 17:52:06 +08:00
|
|
|
this.prevent_opt.save = false
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
|
|
|
|
|
this.esc(true)
|
|
|
|
|
} else {
|
|
|
|
|
this.$message.error(response.msg)
|
|
|
|
|
}
|
|
|
|
|
this.prevent_opt.save = false
|
|
|
|
|
})
|
|
|
|
|
} else {
|
2022-08-15 15:48:24 +08:00
|
|
|
this.$post('issue', params).then(response => {
|
2022-08-12 17:52:06 +08:00
|
|
|
if (response.code === 200) {
|
|
|
|
|
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
|
|
|
|
|
this.esc(true)
|
|
|
|
|
} else {
|
|
|
|
|
this.$message.error(response.msg)
|
|
|
|
|
}
|
|
|
|
|
this.prevent_opt.save = false
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
this.prevent_opt.save = false
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
2022-08-16 11:52:55 +08:00
|
|
|
languages () { return this.$store.getters.getLanguage }
|
2022-08-12 17:52:06 +08:00
|
|
|
},
|
|
|
|
|
watch: {
|
2022-08-15 15:48:24 +08:00
|
|
|
issue: {
|
|
|
|
|
deep: true,
|
|
|
|
|
immediate: true,
|
|
|
|
|
handler (n, o) {
|
|
|
|
|
this.isEdit = true
|
2022-08-30 16:23:29 +08:00
|
|
|
if (n.assets && n.assets[0] != null) {
|
2022-08-16 17:14:50 +08:00
|
|
|
const assetIdData = n.assets.map(item => {
|
|
|
|
|
return item.id
|
|
|
|
|
})
|
|
|
|
|
this.editIssue = {
|
|
|
|
|
...n,
|
|
|
|
|
assetIds: assetIdData.join(',')
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
this.editIssue = {
|
|
|
|
|
...n
|
|
|
|
|
}
|
2022-08-15 15:48:24 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-08-12 17:52:06 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|