|
@@ -59,14 +59,19 @@
|
|
|
<!-- 节点别名 -->
|
|
|
<hc-new-dialog v-model="isAliasShow" widths="26rem" title="节点别名" is-footer-center @close="aliasDialogClose">
|
|
|
<el-form ref="formAliasRef" :model="formAliasModel" :rules="formAliasRules" label-position="top" label-width="auto">
|
|
|
- <el-form-item label="节点别名:" prop="aliasName">
|
|
|
- <el-input v-model="formAliasModel.aliasName" clearable class="is-right-btn">
|
|
|
- <template #append>
|
|
|
- <el-button hc-btn type="primary">添加</el-button>
|
|
|
+ <el-form-item prop="aliasName">
|
|
|
+ <el-input v-model="formAliasModel.aliasName" placeholder="请输入节点别名" clearable class="is-right-btn">
|
|
|
+ <template v-if="formModel.pKeyId" #append>
|
|
|
+ <el-button hc-btn type="primary" @click="addAliasName">添加</el-button>
|
|
|
</template>
|
|
|
</el-input>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
+ <div v-if="aliasArr.length > 0" class="hc-tree-node-edit-form-alias-name">
|
|
|
+ <template v-for="(item, index) in aliasArr" :key="index">
|
|
|
+ <el-tag closable type="primary" @close="aliasNameClose(index)">{{ item }}</el-tag>
|
|
|
+ </template>
|
|
|
+ </div>
|
|
|
<template #footer>
|
|
|
<el-button hc-btn @click="aliasDialogClose">取消</el-button>
|
|
|
<el-button hc-btn type="primary" :loading="submitAliasLoading" @click="aliasSubmit">提交</el-button>
|
|
@@ -76,7 +81,7 @@
|
|
|
|
|
|
<script setup>
|
|
|
import { ref, watch } from 'vue'
|
|
|
-import { formValidate, getArrValue, isNullES } from 'js-fast-way'
|
|
|
+import { deepClone, formValidate, getArrValue, isNullES } from 'js-fast-way'
|
|
|
import projectApi from '~api/project/project'
|
|
|
import privateApi from '~api/wbs/private'
|
|
|
|
|
@@ -180,14 +185,49 @@ const formAliasRules = {
|
|
|
}
|
|
|
|
|
|
//显示节点别名弹窗
|
|
|
+const aliasArr = ref([])
|
|
|
const aliasShowClick = () => {
|
|
|
isAliasShow.value = true
|
|
|
+ aliasArr.value = []
|
|
|
+ const { fullName } = deepClone(formModel.value)
|
|
|
+ if (isNullES(fullName)) return
|
|
|
+ aliasArr.value = fullName.split(',')
|
|
|
+}
|
|
|
+
|
|
|
+//添加别名
|
|
|
+const addAliasName = async () => {
|
|
|
+ const formRes = await formValidate(formAliasRef.value)
|
|
|
+ if (!formRes) return false
|
|
|
+ const { aliasName } = deepClone(formAliasModel.value)
|
|
|
+ if (aliasArr.value.indexOf(aliasName) !== -1) {
|
|
|
+ window.$message.warning('请不要重复别名')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ aliasArr.value.push(aliasName)
|
|
|
+ formAliasModel.value.aliasName = ''
|
|
|
+}
|
|
|
+
|
|
|
+//移除别名
|
|
|
+const aliasNameClose = (index) => {
|
|
|
+ aliasArr.value.splice(index, 1)
|
|
|
}
|
|
|
|
|
|
//提交别名
|
|
|
const submitAliasLoading = ref(false)
|
|
|
const aliasSubmit = async () => {
|
|
|
-
|
|
|
+ submitAliasLoading.value = true
|
|
|
+ const { pKeyId } = formModel.value
|
|
|
+ const fullName = aliasArr.value.join(',')
|
|
|
+ const { error, code, msg } = await privateApi.privateSubmitFullName({
|
|
|
+ pKeyId, fullNames: fullName,
|
|
|
+ })
|
|
|
+ submitAliasLoading.value = false
|
|
|
+ if (!error && code === 200) {
|
|
|
+ aliasDialogClose()
|
|
|
+ window?.$message?.success('操作成功')
|
|
|
+ } else {
|
|
|
+ window?.$message?.error(msg ?? '操作失败')
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//关闭节点别名弹窗
|
|
@@ -271,6 +311,15 @@ const dialogClose = () => {
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
-<style scoped lang="scss">
|
|
|
-
|
|
|
+<style lang="scss">
|
|
|
+.hc-tree-node-edit-form-alias-name {
|
|
|
+ position: relative;
|
|
|
+ border: 1px dashed #dcdfe6;
|
|
|
+ border-radius: 4px;
|
|
|
+ padding: 5px 5px 0;
|
|
|
+ .el-tag {
|
|
|
+ margin-right: 5px;
|
|
|
+ margin-bottom: 5px;
|
|
|
+ }
|
|
|
+}
|
|
|
</style>
|