|
|
@@ -2,105 +2,103 @@
|
|
|
<template>
|
|
|
<div class="g-view-tree">
|
|
|
<app-view>
|
|
|
- <el-tree ref="treeRef" :data="nodeList"
|
|
|
- :props="{ label: (data: { enumgroupname: string; enumdicname: string }) => data.enumgroupname || data.enumdicname }"
|
|
|
- :expand-on-click-node="false" @node-click="nodeClick" highlight-current default-expand-all />
|
|
|
+ <el-tree ref="treeRef" :data="nodeList" node-key="id"
|
|
|
+ :props="{ label: (data: Tree) => data.enumdicname || data.enumgroupname }" :expand-on-click-node="false"
|
|
|
+ @node-click="nodeClick" highlight-current default-expand-all />
|
|
|
</app-view>
|
|
|
<app-view>
|
|
|
<app-table :data="dataList" :columns="tableColumns">
|
|
|
<template #headerLeft>
|
|
|
- <app-operation :data-list="getActionButtons(['investor_custom_tradecfg_add'])"
|
|
|
- @click="openComponent" />
|
|
|
- <app-operation
|
|
|
- :data-list="getActionButtons(['investor_custom_tradecfg_modify', 'investor_custom_tradecfg_delete'])"
|
|
|
- @click="openComponent" v-if="data" />
|
|
|
+ <span>当前分组名称:{{ selectedNode?.enumgroupname }}</span>
|
|
|
+ <span v-if="selectedNode?.enumdiccode">当前枚举名称:{{ selectedNode.enumdicname }}({{
|
|
|
+ selectedNode.enumdiccode }})</span>
|
|
|
+ </template>
|
|
|
+ <template #headerRight>
|
|
|
+ <app-operation :data-list="getActionButtons(['base_dictionary_update'])" @click="openComponent" />
|
|
|
+ </template>
|
|
|
+ <!-- 操作 -->
|
|
|
+ <template #operate="{ row }">
|
|
|
+ <app-operation size="small"
|
|
|
+ :data-list="getActionButtons(['base_dictionary_modify', 'base_dictionary_delete'])"
|
|
|
+ @click="(code: string) => openComponent(code, row)" circle />
|
|
|
</template>
|
|
|
</app-table>
|
|
|
</app-view>
|
|
|
- <component :is="componentMap.get(componentId)" v-bind="{ record: toRaw(data) }" @closed="closeComponent"
|
|
|
+ <component :is="componentMap.get(componentId)" v-bind="{ record }" @closed="closeComponent"
|
|
|
v-if="componentId" />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { ref, computed, reactive, toRaw, nextTick } from 'vue'
|
|
|
-import { ElMessage } from 'element-plus'
|
|
|
-import type Node from 'element-plus/es/components/tree/src/model/node'
|
|
|
-import { buildTree, handleNoneValue } from '@/filters'
|
|
|
-import { Language } from '@/constants/language'
|
|
|
+import { ref, computed, nextTick } from 'vue'
|
|
|
+import { ElMessage, TreeInstance } from 'element-plus'
|
|
|
import { useEnum } from '@/hooks/enum'
|
|
|
import { useRequest } from '@/hooks/request'
|
|
|
import { useOperation } from '@/hooks/operation'
|
|
|
-import { getInvestorTree, tradeConfigView } from '@/services/api/investor'
|
|
|
import { queryEnumDicItemByPage, getEnumDics } from '@/services/api/base'
|
|
|
-import { CellProp } from '@pc/components/base/table-details/types'
|
|
|
import AppTable from '@pc/components/base/table/index.vue'
|
|
|
import AppOperation from '@pc/components/base/operation/index.vue'
|
|
|
-import AppTableDetails from '@pc/components/base/table-details/index.vue'
|
|
|
-import { i18n } from '@/stores'
|
|
|
-
|
|
|
-const { t } = i18n.global
|
|
|
-const customerTypeEnum = useEnum('customerType')
|
|
|
-const feetypeEnum = useEnum('feetype')
|
|
|
-const scfRiskMode = useEnum('SCFRiskMode')
|
|
|
-const traderuleEnum = useEnum('traderule') // 交易规则
|
|
|
-const tradefeeEnum = useEnum('tradefee') // 交易费用
|
|
|
|
|
|
-const treeRef = ref()
|
|
|
-const nodeList = ref<(Base.EnumGroup & { children: Base.EnumDic[]; })[]>([])
|
|
|
-const selectedNode = ref<Node>()
|
|
|
+interface Tree {
|
|
|
+ id: string;
|
|
|
+ enumgroupid: number;
|
|
|
+ enumgroupname: string;
|
|
|
+ enumdiccode: string;
|
|
|
+ enumdicname: string;
|
|
|
+ ismappingtobank?: number;
|
|
|
+ children?: Tree[];
|
|
|
+}
|
|
|
|
|
|
-const currentInfo = reactive({
|
|
|
- groupName: '',
|
|
|
- marketName: '',
|
|
|
- goodsName: '',
|
|
|
- customerType: '',
|
|
|
- marginValue: ''
|
|
|
-})
|
|
|
+const flagEnum = useEnum('flag')
|
|
|
+const statusEnum = useEnum('status')
|
|
|
|
|
|
-const qs = computed<Investor.TradeConfigViewReq>(() => {
|
|
|
- const data = selectedNode.value?.data
|
|
|
- return {
|
|
|
- usergroupid: data?.usergroupid,
|
|
|
- marketid: data?.marketid,
|
|
|
- goodsid: data?.goodsid,
|
|
|
- }
|
|
|
-})
|
|
|
+const treeRef = ref<TreeInstance>()
|
|
|
+const nodeList = ref<Tree[]>([])
|
|
|
+const selectedNode = ref<Tree>() // 当前选中的树节点
|
|
|
|
|
|
-const { componentMap, componentId, openComponent, closeComponent, getActionButtons } = useOperation<Investor.TradeConfigViewRsp>({
|
|
|
+const { componentMap, componentId, record, openComponent, closeComponent, getActionButtons } = useOperation<Base.EnumDicItemByPageRsp>({
|
|
|
onClose: (componentId) => {
|
|
|
- getNodeList()
|
|
|
- if (componentId === 'investor_custom_tradecfg_modify') {
|
|
|
- getDetails(qs.value)
|
|
|
- }
|
|
|
- if (componentId === 'investor_custom_tradecfg_delete') {
|
|
|
- data.value = undefined
|
|
|
- }
|
|
|
+ console.log(componentId)
|
|
|
}
|
|
|
})
|
|
|
|
|
|
-const { run: getNodeList } = useRequest(getEnumDics, {
|
|
|
+useRequest(getEnumDics, {
|
|
|
onSuccess: (res) => {
|
|
|
- nodeList.value = res.data.enumgroups.map((e) => {
|
|
|
- const children: Base.EnumDic[] = []
|
|
|
- res.data.enumdics.forEach((item) => {
|
|
|
+ nodeList.value = res.data.enumgroups.map((e, i) => {
|
|
|
+ const children: Tree[] = []
|
|
|
+ res.data.enumdics.forEach((item, n) => {
|
|
|
if (e.enumgroupid === item.enumgroupid) {
|
|
|
- children.push(item)
|
|
|
+ children.push({
|
|
|
+ id: i.toString() + n.toString(),
|
|
|
+ enumgroupname: e.enumgroupname,
|
|
|
+ enumgroupid: item.enumgroupid,
|
|
|
+ enumdiccode: item.enumdiccode,
|
|
|
+ enumdicname: item.enumdicname,
|
|
|
+ ismappingtobank: item.ismappingtobank
|
|
|
+ })
|
|
|
}
|
|
|
})
|
|
|
return {
|
|
|
- ...e,
|
|
|
- children,
|
|
|
+ id: i.toString(),
|
|
|
+ enumgroupname: e.enumgroupname,
|
|
|
+ enumgroupid: e.enumgroupid,
|
|
|
+ enumdiccode: '',
|
|
|
+ enumdicname: '',
|
|
|
+ children
|
|
|
}
|
|
|
})
|
|
|
- },
|
|
|
- onError: (err) => {
|
|
|
- ElMessage.error(err)
|
|
|
- }
|
|
|
-})
|
|
|
|
|
|
-const { data, run: getDetails } = useRequest(tradeConfigView, {
|
|
|
- manual: true,
|
|
|
+ selectedNode.value = nodeList.value[0] // 默认选中第一个节点
|
|
|
+
|
|
|
+ // 设置选中节点
|
|
|
+ nextTick(() => {
|
|
|
+ const data = selectedNode.value
|
|
|
+ if (data) {
|
|
|
+ treeRef.value?.setCurrentKey(data.id, true)
|
|
|
+ nodeClick(data)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
onError: (err) => {
|
|
|
ElMessage.error(err)
|
|
|
}
|
|
|
@@ -117,24 +115,23 @@ const { dataList, run: getDataList } = useRequest(queryEnumDicItemByPage, {
|
|
|
}
|
|
|
})
|
|
|
|
|
|
-const detailProps = computed<CellProp[]>(() => [
|
|
|
- { prop: 'groupName', label: 'investor.custom.tradecfg.usergroupid1' },
|
|
|
- { prop: 'marketName', label: 'investor.custom.tradecfg.marketid1' },
|
|
|
- { prop: 'goodsName', label: 'investor.custom.tradecfg.goodsid1' },
|
|
|
- { prop: 'customerType', label: 'investor.custom.tradecfg.paramid', formatValue: () => customerTypeEnum.getEnumTypeName(data.value?.paramid) },
|
|
|
- { prop: 'marginValue', label: 'investor.custom.tradecfg.marketmarginvaluedisplay', formatValue: () => data.value?.marketmarginvaluedisplay },
|
|
|
-])
|
|
|
+const tableColumns = computed<Model.TableColumn[]>(() => {
|
|
|
+ const data = selectedNode.value ?? {}
|
|
|
+ return [
|
|
|
+ { field: 'enumdiccode', label: '所属枚举代码' },
|
|
|
+ { field: 'enumdicname', label: '枚举项名称' },
|
|
|
+ { field: 'ismappingtobank', label: '是否映射银行', formatValue: (val) => flagEnum.getEnumTypeName(val), show: !('ismappingtobank' in data) },
|
|
|
+ { field: 'itemstatus', label: '枚举项状态', formatValue: (val) => statusEnum.getEnumTypeName(val), show: !('ismappingtobank' in data) },
|
|
|
+ { field: 'enumitemname', label: '枚举项值', show: ('ismappingtobank' in data) },
|
|
|
+ { field: 'enumitemstatus', label: '枚举状态', formatValue: (val) => statusEnum.getEnumTypeName(val), show: ('ismappingtobank' in data) },
|
|
|
+ // { field: 'operate', label: 'common.operate', fixed: 'right', show: ('ismappingtobank' in data) }
|
|
|
+ ]
|
|
|
+})
|
|
|
|
|
|
-const tableColumns: Model.TableColumn[] = [
|
|
|
- { field: 'enumdiccode', label: '所属枚举代码' },
|
|
|
- { field: 'enumdicname', label: '枚举项名称' },
|
|
|
- { field: 'enumitemname', label: '枚举项值' },
|
|
|
- { field: 'itemstatus', label: '枚举项状态' },
|
|
|
- { field: 'operate', label: 'common.operate', fixed: 'right' }
|
|
|
-]
|
|
|
+const nodeClick = (data: Tree) => {
|
|
|
+ selectedNode.value = data
|
|
|
|
|
|
-const nodeClick = (data: Base.EnumGroup | Base.EnumDic, node: Node) => {
|
|
|
- if ('enumdiccode' in data) {
|
|
|
+ if (data.enumdiccode) {
|
|
|
getDataList({
|
|
|
enumgroupid: data.enumgroupid,
|
|
|
enumdiccode: data.enumdiccode,
|
|
|
@@ -145,13 +142,5 @@ const nodeClick = (data: Base.EnumGroup | Base.EnumDic, node: Node) => {
|
|
|
enumgroupid: data.enumgroupid
|
|
|
})
|
|
|
}
|
|
|
-
|
|
|
- if (data.goodsid) {
|
|
|
- selectedNode.value = node
|
|
|
- currentInfo.goodsName = node.label
|
|
|
- currentInfo.marketName = node.parent.label
|
|
|
- currentInfo.groupName = node.parent.parent.label
|
|
|
- getDetails(qs.value)
|
|
|
- }
|
|
|
}
|
|
|
</script>
|