Commit 1a36215f by 吴云建

会话model detail 添加fieldGroup action

parent 138dfce3
Showing with 149 additions and 2 deletions
......@@ -5,6 +5,14 @@
<div class="data-row" v-for="item in detailData" :key="item.label">
<span class="data-key">{{ item.label }}</span
>: <span class="data-value" v-html="item.template"></span>
<span class="operation_field" v-if="item.actions && item.actions.length > 0">
<el-button v-for="action in item.actions"
:key="action.name"
@click="execute_action(action)"
type="text"
size="small"
>{{ action.label }}</el-button>
</span>
</div>
</el-scrollbar>
</div>
......@@ -16,9 +24,11 @@
<script lang="ts">
import { DetailTypes } from "uniplat-sdk";
import { Component, Prop, Vue } from "vue-property-decorator";
import { EVENTS } from "@/EventConsts"
import { ChatStore, chatStore } from "../store/model";
import Chat from "../xim";
import { goForward } from "@/utils/go-forward"
@Component({ components: {} })
export default class ChatModelDetail extends Vue {
@chatStore.Mutation(ChatStore.MUTATION_HIDE_CHAT)
......@@ -41,15 +51,23 @@ export default class ChatModelDetail extends Vue {
default: null,
})
private readonly name!: string;
private sseMessageRefreshData = false;
private detailData: DetailTypes.getDetailRequestResult["meta"]["header"]["field_groups"] | null = null
private detailRow: DetailTypes.getDetailRequestResult["row"] | null = null
private keyField = ""
public async created() {
await this.init();
}
private async init() {
const data = await Chat.getSdk()
.model(this.model_name)
.detail(this.id, this.name)
.query();
this.detailData = data.meta.header.field_groups;
this.detailRow = data.row;
this.keyField = data.meta.key_field
}
private goTodetail() {
......@@ -58,6 +76,129 @@ export default class ChatModelDetail extends Vue {
);
this.hideChat();
}
private async execute_action(actionParams) {
let {
action_name,
container,
forward,
confirm_caption,
open_in_new_tab,
authed,
} = actionParams
let x = this.detailRow
let r: { v: number } = { v: 0 }
r["id"] = x[this.keyField].value
if (x["uniplat_version"]) r.v = x["uniplat_version"].value
if (!authed) {
this.$eventHub.$emit(EVENTS.ShowModalDialog, {
dialogName: "authors_list",
params: {
actionName: actionParams.action_name,
modelName: this.model_name,
},
})
return
}
if (container === "page") {
this.$message.warning("该类型操作暂不支持");
} else if (container === "dialog" || container === "none") {
this.$eventHub.$emit(EVENTS.ShowModalDialog, {
dialogName: "general_executor_dialog",
params: {
autoSubmit: container === "none",
modelName: this.model_name,
actionName: action_name,
selected: JSON.stringify([r]),
prefilters: JSON.stringify([]),
options: { confirm_caption },
callWhenSuccess: (data) => {
let forward = data.forward
this.init();
if (!!forward && forward != "") {
goForward.call(this, forward, this.init)
}
},
},
})
} else if (container === "batch") {
this.$eventHub.$emit(EVENTS.ShowModalDialog, {
dialogName: "general_execute_batch",
params: {
model_name: this.model_name,
action_name,
selected_list: JSON.stringify([r]),
prefilters: [],
onSuccessed: this.init,
},
})
} else if (container === "detail_dialog") {
this.$eventHub.$emit(EVENTS.ShowModalDialog, {
dialogName: "general_detail_dialog",
params: {
forward: forward,
},
})
} else if (container === "iframe") {
if (
forward.indexOf("http://") !== 0 &&
forward.indexOf("https://") !== 0
) {
if (this.global.$ssr && this.global.$vapperRootPath) {
forward =
"/" +
this.global.$vapperRootPath +
forward.replace(/^\//, "")
}
}
this.$eventHub.$emit(EVENTS.ShowModalDialog, {
dialogName: "general_iframe_dialog",
params: {
title: "",
href: forward,
width: "70%",
height: 500,
},
})
} else if (container === "startProcess") {
this.$eventHub.$emit(EVENTS.ShowModalDialog, {
dialogName: "start_process_dialog",
params: {
autoSubmit: container === "none",
modelName: this.model_name,
actionName: action_name,
selected: JSON.stringify([r]),
prefilters: {},
filters: {},
options: { confirm_caption },
callWhenSuccess: (data) => {
this.$emit("datachange")
},
},
})
} else {
if (
forward.indexOf("http://") == 0 ||
forward.indexOf("https://") == 0
) {
window.open(forward, "_blank")
} else {
if (this.global.$ssr && this.global.$vapperRootPath) {
forward =
"/" +
this.global.$vapperRootPath +
forward.replace(/^\//, "")
}
if (open_in_new_tab) {
window.open(`${forward}`, "_blank")
} else {
this.$router.push(forward)
}
}
}
}
}
</script>
<style lang="less" scoped>
......@@ -83,4 +224,10 @@ export default class ChatModelDetail extends Vue {
.scroll-wrap {
height: calc(100% - 70px);
}
.operation_field {
margin-left: 2px;
/deep/ .el-button {
padding: 0;
}
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment