Commit 33700983 by chenwq

feat: 添加单一模式下的标签编辑功能,优化标签路径选择体验

1 parent 666fa335
<template>
<el-dialog custom-class="batch-edit-tag-dialog"
title="批量配置三级财务标签"
:title="dialogTitle"
width="450px"
:close-on-click-modal="false"
:visible.sync="dialogVisible"
@close="handleClose">
<div v-loading="loading">
<div class="batch-edit-tag-dialog__tip">
您已勾选 <span>{{ selectedCount }}</span> 条流水,请选择统一覆盖的目标三级标签路径:
<template v-if="isSingleMode">
请选择该流水的目标三级标签路径:
</template>
<template v-else>
您已勾选 <span>{{ selectedCount }}</span> 条流水,请选择统一覆盖的目标三级标签路径:
</template>
</div>
<glsx-combi-form ref="tagForm"
class="batch-edit-tag-dialog__form"
......@@ -60,6 +65,14 @@ export default {
type: Array,
default: () => [],
},
mode: {
type: String,
default: "batch",
},
initialTagId: {
type: [String, Number],
default: "",
},
},
data() {
return {
......@@ -99,6 +112,23 @@ export default {
selectedCount() {
return this.selectedList.length;
},
isSingleMode() {
return this.mode === "single";
},
dialogTitle() {
return this.isSingleMode ? "修改自定义标签" : "批量配置三级财务标签";
},
currentTagId() {
const detail = this.selectedList[0] || {};
return this.initialTagId || detail.accDetailTagId || detail.detailTagId || detail.tagId || "";
},
},
watch: {
visible(val) {
if (val) {
this.setInitialTagPath();
}
},
},
mounted() {
this.getTagOptions();
......@@ -118,6 +148,7 @@ export default {
this.loading = true;
nbcbAccDetailConfig({ custType: 1 }).then((res) => {
this.tagOptions = this.normalizeTagTree(res.accDetailTagOptions || []);
this.setInitialTagPath();
}).catch(() => {
this.tagOptions = [];
}).finally(() => {
......@@ -138,6 +169,30 @@ export default {
handleTagPathChange(value) {
this.tagForm.tagId = value && value.length ? value[value.length - 1] : "";
},
setInitialTagPath() {
if (!this.isSingleMode || !this.currentTagId || !this.tagOptions.length) {
this.resetForm();
return;
}
const tagPath = this.findTagPath(this.tagOptions, this.currentTagId);
this.tagForm = {
tagPath,
tagId: tagPath.length ? tagPath[tagPath.length - 1] : "",
};
},
findTagPath(list, targetId, parentPath = []) {
for (const item of list || []) {
const currentPath = [...parentPath, item.id];
if (`${item.id}` === `${targetId}`) {
return currentPath;
}
const childPath = this.findTagPath(item.children || [], targetId, currentPath);
if (childPath.length) {
return childPath;
}
}
return [];
},
handleClose() {
this.dialogVisible = false;
},
......
......@@ -201,7 +201,15 @@
<div class="itemDiv">
<el-form-item class="halfItem"
label="自定义标签:">
<template slot="label">
自定义标签:
</template>
{{ detailInfo.accDetailTagPathName ? detailInfo.accDetailTagPathName : "-" }}
<el-button class="tag-edit-btn"
icon="el-icon-edit"
type="text"
@click="handleEditTag">
</el-button>
</el-form-item>
<el-form-item class="halfItem"
label="财务报表口径:">
......@@ -226,6 +234,12 @@
</div>
</div>
</basedialog>
<BatchEditTagDialog v-if="tagDialogVisible"
mode="single"
:initial-tag-id="currentTagId"
:selected-list="[detailInfo]"
:visible.sync="tagDialogVisible"
@confirm="handleTagConfirm" />
</div>
</template>
......@@ -233,10 +247,12 @@
import { nbcbAccDetail, nbcbAccDetailBatchSync, receiptBatchSync } from "@api/theAssetData";
import { cdSignOpt, operationResultOpt, operationTypeOpt } from "@/common/constants.js";
import { deepClone, Util } from "@/common/util";
import BatchEditTagDialog from "./batchEditTagDialog";
export default {
name: "DetailDialog",
components: {
BatchEditTagDialog,
},
props: {
visible: {
......@@ -304,6 +320,7 @@ export default {
operationResultOpt: deepClone(operationResultOpt),
operationTypeOpt: deepClone(operationTypeOpt),
refreshFlag: false,
tagDialogVisible: false,
};
},
computed: {
......@@ -317,6 +334,9 @@ export default {
this.$emit("dialogClose", { flag: this.refreshFlag });
},
},
currentTagId() {
return this.detailInfo.accDetailTagId || "";
},
},
mounted() {
this.getDetail();
......@@ -342,6 +362,14 @@ export default {
info.cdSignShow = info.cdSign ? this.cdSignOpt.find(item => item.confId + "" === info.cdSign)?.confValue : "-";
}
},
handleEditTag() {
this.tagDialogVisible = !this.tagDialogVisible;
},
handleTagConfirm() {
this.handleEditTag();
this.refreshFlag = true;
this.getDetail();
},
// handleDetailClose() {
// console.log('this.refreshFlag', this.refreshFlag)
// if (this.refreshFlag) {
......@@ -570,6 +598,10 @@ export default {
width: 50%;
}
}
.tag-edit-btn {
padding: 0;
margin-left: 4px;
}
.onLineItem {
::v-deep .el-form-item__content {
max-width: 80%;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!