updata: 增加元数据模块
Showing
9 changed files
with
2113 additions
and
31 deletions
| ... | @@ -3,8 +3,8 @@ VITE_APP_TITLE = 数据资产管理系统 | ... | @@ -3,8 +3,8 @@ VITE_APP_TITLE = 数据资产管理系统 |
| 3 | # 接口域名 | 3 | # 接口域名 |
| 4 | # VITE_API_BASEURL = https://www.zgsjzc.com/api | 4 | # VITE_API_BASEURL = https://www.zgsjzc.com/api |
| 5 | # VITE_API_BASEURL = https://swzl-test.csbr.cn/api | 5 | # VITE_API_BASEURL = https://swzl-test.csbr.cn/api |
| 6 | VITE_API_BASEURL = http://localhost:9000 | 6 | # VITE_API_BASEURL = http://localhost:9000 |
| 7 | # VITE_API_BASEURL = http://10.4.82.1:28052/ | 7 | VITE_API_BASEURL = http://10.4.82.1:28052/ |
| 8 | # 平台用户 接口请地址 | 8 | # 平台用户 接口请地址 |
| 9 | VITE_APP_USER_API_BASEURL = gateway-server | 9 | VITE_APP_USER_API_BASEURL = gateway-server |
| 10 | 10 | ||
| ... | @@ -13,6 +13,7 @@ VITE_APP_AUTH_URL = 'ms-daop-auth-service' | ... | @@ -13,6 +13,7 @@ VITE_APP_AUTH_URL = 'ms-daop-auth-service' |
| 13 | 13 | ||
| 14 | # 系统管理 接口地址 | 14 | # 系统管理 接口地址 |
| 15 | VITE_APP_API_BASEURL = ms-daop-zcgl-system-manager-service | 15 | VITE_APP_API_BASEURL = ms-daop-zcgl-system-manager-service |
| 16 | |||
| 16 | # 文件上传请求地址 | 17 | # 文件上传请求地址 |
| 17 | VITE_APP_ADD_FILE = ms-daop-import-data-service | 18 | VITE_APP_ADD_FILE = ms-daop-import-data-service |
| 18 | # 调试工具,可设置 eruda 或 vconsole,如果不需要开启则留空 | 19 | # 调试工具,可设置 eruda 或 vconsole,如果不需要开启则留空 |
| ... | @@ -29,8 +30,8 @@ VITE_APP_PLAN_BASEURL = ms-daop-jgjf-data-plan-service | ... | @@ -29,8 +30,8 @@ VITE_APP_PLAN_BASEURL = ms-daop-jgjf-data-plan-service |
| 29 | VITE_APP_QUALITY_BASEURL = ms-daop-data-quality-service | 30 | VITE_APP_QUALITY_BASEURL = ms-daop-data-quality-service |
| 30 | 31 | ||
| 31 | #数据盘点接口地址ms-daop-zcgl-data-inventory | 32 | #数据盘点接口地址ms-daop-zcgl-data-inventory |
| 32 | VITE_APP_CHECK_BASEURL = /mock | 33 | # VITE_APP_CHECK_BASEURL = /mock |
| 33 | # VITE_APP_CHECK_BASEURL = ms-daop-zcgl-data-inventory | 34 | VITE_APP_CHECK_BASEURL = ms-daop-zcgl-data-inventory |
| 34 | 35 | ||
| 35 | #门户接口 | 36 | #门户接口 |
| 36 | VITE_API_PORTALURL = https://swzl-test.zgsjzc.com/portal | 37 | VITE_API_PORTALURL = https://swzl-test.zgsjzc.com/portal | ... | ... |
| ... | @@ -2,6 +2,159 @@ import request from "@/utils/request"; | ... | @@ -2,6 +2,159 @@ import request from "@/utils/request"; |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | /** | 4 | /** |
| 5 | * 数据字典 | ||
| 6 | **/ | ||
| 7 | // 编码规则流水号 | ||
| 8 | export const getCoderuleList = (params) => request({ | ||
| 9 | url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/code-rule/list`, | ||
| 10 | method: 'post', | ||
| 11 | data: params | ||
| 12 | }) | ||
| 13 | // 获取数据类型的接口 | ||
| 14 | export const getDataTypeList = (params) => request({ | ||
| 15 | url: `${import.meta.env.VITE_APP_API_BASEURL}/data-dict/get-data-list`, | ||
| 16 | method: 'post', | ||
| 17 | data: params, | ||
| 18 | }) | ||
| 19 | // 获取数据库列表 | ||
| 20 | export const getDataBaseList = (params) => request({ | ||
| 21 | url: `${import.meta.env.VITE_APP_API_BASEURL}/data-source/get-source-list`, | ||
| 22 | method: 'post', | ||
| 23 | data: params, | ||
| 24 | }) | ||
| 25 | |||
| 26 | // 新增 | ||
| 27 | export const addDictionary = (params) => request({ | ||
| 28 | url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/data-dictionary-general/add`, | ||
| 29 | method: 'post', | ||
| 30 | data: params | ||
| 31 | }) | ||
| 32 | // 删除 | ||
| 33 | export const deleteDictionary = (params) => request({ | ||
| 34 | url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/data-dictionary-general/del`, | ||
| 35 | method: 'delete', | ||
| 36 | data: params | ||
| 37 | }) | ||
| 38 | // 删除数据字典前的校验 | ||
| 39 | export const checkDeleteDictionary = (params) => request({ | ||
| 40 | url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/data-dictionary-general/check-del`, | ||
| 41 | method: 'delete', | ||
| 42 | data: params | ||
| 43 | }) | ||
| 44 | // 编辑校验数据结构删除的条件 | ||
| 45 | export const checkDeleteDictionaryScheme = (params) => request({ | ||
| 46 | url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/data-dictionary-general/check-del/dictionary-scheme`, | ||
| 47 | method: 'post', | ||
| 48 | data: params | ||
| 49 | }) | ||
| 50 | // 分页查询 | ||
| 51 | export const getDictionary = (params) => request({ | ||
| 52 | url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/data-dictionary-general/page-list`, | ||
| 53 | method: 'post', | ||
| 54 | data: params | ||
| 55 | }) | ||
| 56 | // 查询数据字典启用状态的数据 | ||
| 57 | export const getDictionaryAll = (params) => request({ | ||
| 58 | url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/data-dictionary-general/list-all`, | ||
| 59 | method: 'post', | ||
| 60 | params | ||
| 61 | }) | ||
| 62 | // 修改 | ||
| 63 | export const updateDictionary = (params) => request({ | ||
| 64 | url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/data-dictionary-general/update`, | ||
| 65 | method: 'put', | ||
| 66 | data: params | ||
| 67 | }) | ||
| 68 | // 详情 | ||
| 69 | export const getDictionaryDetail = (params) => request({ | ||
| 70 | url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/data-dictionary-general/detail/${params}`, | ||
| 71 | method: 'get' | ||
| 72 | }) | ||
| 73 | // 查看数据字典数据 | ||
| 74 | export const getDictionaryFileds = (params) => request({ | ||
| 75 | url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/data-dictionary-general/dictionary-data/${params}`, | ||
| 76 | method: 'get' | ||
| 77 | }) | ||
| 78 | // 数据字典启用停用 | ||
| 79 | export const updateDictionaryState = (params) => request({ | ||
| 80 | url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/data-dictionary-general/change-state`, | ||
| 81 | method: 'get', | ||
| 82 | params | ||
| 83 | }) | ||
| 84 | // 检验是否存在 | ||
| 85 | export const checkDictionary = (params) => request({ | ||
| 86 | url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/data-dictionary-general/check-exist`, | ||
| 87 | method: 'get', | ||
| 88 | params | ||
| 89 | }) | ||
| 90 | // 数据字典新增数据时生成编码规则 | ||
| 91 | export const getDictionaryRuleData = (params) => request({ | ||
| 92 | url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/data-dictionary-general/generate/code-rule/byGuid`, | ||
| 93 | method: 'get', | ||
| 94 | params | ||
| 95 | }) | ||
| 96 | // 数据字典树形数据 | ||
| 97 | export const getDictionaryTree = (params) => request({ | ||
| 98 | url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/data-dictionary-general/tree-list`, | ||
| 99 | method: 'post', | ||
| 100 | params | ||
| 101 | }) | ||
| 102 | // 保存动态数据字典数据 | ||
| 103 | export const saveDictionaryData = (params) => request({ | ||
| 104 | url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/data-dictionary-general/save/dictionary-data`, | ||
| 105 | method: 'post', | ||
| 106 | data: params | ||
| 107 | }) | ||
| 108 | // 更新数据字典数据 | ||
| 109 | export const updateDictionaryData = (params) => request({ | ||
| 110 | url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/data-dictionary-general/update/dictionary-data`, | ||
| 111 | method: 'post', | ||
| 112 | data: params | ||
| 113 | }) | ||
| 114 | // 删除数据字典数据 | ||
| 115 | export const deleteDictionaryData = (params) => request({ | ||
| 116 | url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/data-dictionary-general/del/dictionary-data`, | ||
| 117 | method: 'delete', | ||
| 118 | data: params | ||
| 119 | }) | ||
| 120 | // 导入数据字典 | ||
| 121 | export const importDictionary = (params) => request({ | ||
| 122 | url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/import/data-dictionary`, | ||
| 123 | method: 'post', | ||
| 124 | data: params | ||
| 125 | }) | ||
| 126 | // 显示导入的数据字典数据 | ||
| 127 | export const showDictionary = (params) => request({ | ||
| 128 | url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/import/show/data-dictionary`, | ||
| 129 | method: 'post', | ||
| 130 | data: params, | ||
| 131 | headers: { | ||
| 132 | 'Content-Type': 'multipart/form-data' | ||
| 133 | } | ||
| 134 | }) | ||
| 135 | // 导出数据字典模板 | ||
| 136 | export const exportDictionary = (params) => request({ | ||
| 137 | url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/export/data-dictionary/schema`, | ||
| 138 | method: 'post', | ||
| 139 | data: params, | ||
| 140 | responseType: 'blob' | ||
| 141 | }) | ||
| 142 | // 导出数据字典数据 | ||
| 143 | export const exportDictionaryFileds = (params) => request({ | ||
| 144 | url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/export/data-dictionary/data`, | ||
| 145 | method: 'post', | ||
| 146 | data: params, | ||
| 147 | responseType: 'blob' | ||
| 148 | }) | ||
| 149 | // 验证数据是否符合标准 | ||
| 150 | export const checkDictionaryData = (params) => request({ | ||
| 151 | url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/data-dictionary-general/check/dictionary-data`, | ||
| 152 | method: 'post', | ||
| 153 | data: params | ||
| 154 | }) | ||
| 155 | |||
| 156 | |||
| 157 | /** | ||
| 5 | * 获取数据级别 | 158 | * 获取数据级别 |
| 6 | * @param {Object} | 159 | * @param {Object} |
| 7 | * { paramCode: "DATA-CLASSIFY" } | 160 | * { paramCode: "DATA-CLASSIFY" } |
| ... | @@ -230,10 +383,10 @@ export const getCgDirFieldPageList = (data) => request({ | ... | @@ -230,10 +383,10 @@ export const getCgDirFieldPageList = (data) => request({ |
| 230 | /** 获取字典列表 | 383 | /** 获取字典列表 |
| 231 | * VITE_APP_PLAN_BASEURL 为环境变量 现在只是mock数据 | 384 | * VITE_APP_PLAN_BASEURL 为环境变量 现在只是mock数据 |
| 232 | */ | 385 | */ |
| 233 | export const getDictionary = (params) => request({ | 386 | // export const getDictionary = (params) => request({ |
| 234 | url: `${import.meta.env.VITE_APP_CHECK_BASEURL}/data-dictionary-general/list-all?state=1`, | 387 | // url: `${import.meta.env.VITE_APP_CHECK_BASEURL}/data-dictionary-general/list-all?state=1`, |
| 235 | method: 'post' | 388 | // method: 'post' |
| 236 | }) | 389 | // }) |
| 237 | 390 | ||
| 238 | 391 | ||
| 239 | 392 | ||
| ... | @@ -268,3 +421,8 @@ export const getDbDirTablePageList = (data) => request({ | ... | @@ -268,3 +421,8 @@ export const getDbDirTablePageList = (data) => request({ |
| 268 | method: 'post', | 421 | method: 'post', |
| 269 | data | 422 | data |
| 270 | }) | 423 | }) |
| 424 | |||
| 425 | |||
| 426 | |||
| 427 | |||
| 428 | ... | ... |
| ... | @@ -17,10 +17,11 @@ export const deleteMetaDataTask = (params) => request({ | ... | @@ -17,10 +17,11 @@ export const deleteMetaDataTask = (params) => request({ |
| 17 | }) | 17 | }) |
| 18 | // 分页查询 | 18 | // 分页查询 |
| 19 | export const getMetaDataTask = (params) => request({ | 19 | export const getMetaDataTask = (params) => request({ |
| 20 | url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/meta-collect-task/page-list`, | 20 | url: `${import.meta.env.VITE_APP_CHECK_BASEURL}/meta-collect-task/page-list`, |
| 21 | method: 'post', | 21 | method: 'post', |
| 22 | data: params | 22 | data: params |
| 23 | }) | 23 | }) |
| 24 | |||
| 24 | // 修改 | 25 | // 修改 |
| 25 | export const updateMetaDataTask = (params) => request({ | 26 | export const updateMetaDataTask = (params) => request({ |
| 26 | url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/meta-collect-task/update`, | 27 | url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/meta-collect-task/update`, |
| ... | @@ -68,31 +69,31 @@ export const saveMetaReportAnalysis = (params) => request({ | ... | @@ -68,31 +69,31 @@ export const saveMetaReportAnalysis = (params) => request({ |
| 68 | **/ | 69 | **/ |
| 69 | // 树形数据 | 70 | // 树形数据 |
| 70 | export const getMetaTreeData = (params) => request({ | 71 | export const getMetaTreeData = (params) => request({ |
| 71 | url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/meta-table/meta-tree-list`, | 72 | url: `${import.meta.env.VITE_APP_CHECK_BASEURL}/meta-table/meta-tree-list`, |
| 72 | method: 'post', | 73 | method: 'post', |
| 73 | data: params | 74 | data: params |
| 74 | }) | 75 | }) |
| 75 | // 数据库汇总信息 | 76 | // 数据库汇总信息 |
| 76 | export const getMetaDatabaseCollect = (params) => request({ | 77 | export const getMetaDatabaseCollect = (params) => request({ |
| 77 | url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/meta-table/meta-database-collect-list`, | 78 | url: `${import.meta.env.VITE_APP_CHECK_BASEURL}/meta-table/meta-database-collect-list`, |
| 78 | method: 'post', | 79 | method: 'post', |
| 79 | data: params | 80 | data: params |
| 80 | }) | 81 | }) |
| 81 | // 库分页查询 | 82 | // 库分页查询 |
| 82 | export const getMetaDataBase = (params) => request({ | 83 | export const getMetaDataBase = (params) => request({ |
| 83 | url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/meta-table/meta-table-collect-list`, | 84 | url: `${import.meta.env.VITE_APP_CHECK_BASEURL}/meta-table/meta-table-collect-list`, |
| 84 | method: 'post', | 85 | method: 'post', |
| 85 | data: params | 86 | data: params |
| 86 | }) | 87 | }) |
| 87 | // 表分页查询 | 88 | // 表分页查询 |
| 88 | export const getMetaDataSheet = (params) => request({ | 89 | export const getMetaDataSheet = (params) => request({ |
| 89 | url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/meta-table/meta-table-detail-list`, | 90 | url: `${import.meta.env.VITE_APP_CHECK_BASEURL}/meta-table/meta-table-detail-list`, |
| 90 | method: 'post', | 91 | method: 'post', |
| 91 | data: params | 92 | data: params |
| 92 | }) | 93 | }) |
| 93 | // 表字段查询 | 94 | // 表字段查询 |
| 94 | export const getMetaSheetField = (params) => request({ | 95 | export const getMetaSheetField = (params) => request({ |
| 95 | url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/meta-table/meta-table-field-list`, | 96 | url: `${import.meta.env.VITE_APP_CHECK_BASEURL}/meta-table/meta-table-field-list`, |
| 96 | method: 'post', | 97 | method: 'post', |
| 97 | params | 98 | params |
| 98 | }) | 99 | }) | ... | ... |
| ... | @@ -231,7 +231,28 @@ const routes: RouteRecordRaw[] = [ | ... | @@ -231,7 +231,28 @@ const routes: RouteRecordRaw[] = [ |
| 231 | }, | 231 | }, |
| 232 | }, | 232 | }, |
| 233 | ], | 233 | ], |
| 234 | } | 234 | }, |
| 235 | { | ||
| 236 | path: '/data-standards/data-dictionary', | ||
| 237 | component: Layout, | ||
| 238 | meta: { | ||
| 239 | title: '数据字典', | ||
| 240 | icon: 'sidebar-cooperation', | ||
| 241 | }, | ||
| 242 | children: [ | ||
| 243 | { | ||
| 244 | path: '', | ||
| 245 | name: 'dictionary', | ||
| 246 | component: () => import('@/views/data_standards/dictionary.vue'), | ||
| 247 | meta: { | ||
| 248 | title: '数据字典', | ||
| 249 | sidebar: false, | ||
| 250 | breadcrumb: false, | ||
| 251 | cache: true | ||
| 252 | }, | ||
| 253 | }, | ||
| 254 | ], | ||
| 255 | }, | ||
| 235 | ] | 256 | ] |
| 236 | 257 | ||
| 237 | export default routes | 258 | export default routes | ... | ... |
| ... | @@ -58,6 +58,7 @@ const useUserStore = defineStore( | ... | @@ -58,6 +58,7 @@ const useUserStore = defineStore( |
| 58 | userName.value = res.data.userName | 58 | userName.value = res.data.userName |
| 59 | // userData.value = JSON.stringify(res.data.data); | 59 | // userData.value = JSON.stringify(res.data.data); |
| 60 | currentTenantGuid.value = res.data.tenantInfoList && res.data.tenantInfoList.length ? res.data.tenantInfoList[0].guid : ''; | 60 | currentTenantGuid.value = res.data.tenantInfoList && res.data.tenantInfoList.length ? res.data.tenantInfoList[0].guid : ''; |
| 61 | localStorage.setItem('currentTenantGuid', currentTenantGuid.value); | ||
| 61 | let currentTenant = res.data.tenantInfoList?.[0]; | 62 | let currentTenant = res.data.tenantInfoList?.[0]; |
| 62 | return getSystemMenu({ tenantGuid: currentTenantGuid.value }).then((info: any) => { | 63 | return getSystemMenu({ tenantGuid: currentTenantGuid.value }).then((info: any) => { |
| 63 | if (info.code == '00000') { | 64 | if (info.code == '00000') { | ... | ... |
| ... | @@ -31,7 +31,7 @@ service.interceptors.request.use( | ... | @@ -31,7 +31,7 @@ service.interceptors.request.use( |
| 31 | * 为每一次请求生成一个cancleToken | 31 | * 为每一次请求生成一个cancleToken |
| 32 | */ | 32 | */ |
| 33 | const source = axios.CancelToken.source(); | 33 | const source = axios.CancelToken.source(); |
| 34 | config.headers.tenant = '9e5b9d7bfd8c4f4f8079e05de19bf7e0'; //会员guid先写死 | 34 | config.headers.tenant = localStorage.getItem('currentTenantGuid'); //会员guid先写死 |
| 35 | config.cancelToken = source.token; | 35 | config.cancelToken = source.token; |
| 36 | if (config.method === "postfile") { | 36 | if (config.method === "postfile") { |
| 37 | config.method = "post"; | 37 | config.method = "post"; | ... | ... |
| ... | @@ -2,9 +2,86 @@ | ... | @@ -2,9 +2,86 @@ |
| 2 | name: configureRules //标签管理 | 2 | name: configureRules //标签管理 |
| 3 | </route> | 3 | </route> |
| 4 | 4 | ||
| 5 | <script lang="ts" setup name="configureRules"></script> | 5 | <script lang="ts" setup name="configureRules"> |
| 6 | import { TableColumnWidth } from '@/utils/enum'; | ||
| 6 | 7 | ||
| 8 | const dataBasePage = ref({ | ||
| 9 | limit: 10, | ||
| 10 | curr: 1, | ||
| 11 | sizes: [ | ||
| 12 | { label: "10", value: 10 }, | ||
| 13 | { label: "20", value: 20 }, | ||
| 14 | { label: "100", value: 100 }, | ||
| 15 | { label: "150", value: 150 }, | ||
| 16 | { label: "200", value: 200 }, | ||
| 17 | ], | ||
| 18 | }); | ||
| 7 | 19 | ||
| 20 | const dataBaseTableInfo = ref({ | ||
| 21 | id: "data-base-table", | ||
| 22 | multiple: false, | ||
| 23 | fixedSelection: true, | ||
| 24 | fields: [ | ||
| 25 | { label: "序号", type: "index", width: 56, align: "center" }, | ||
| 26 | { label: "数据源", field: "databaseChName", width: 140 }, | ||
| 27 | { label: "表名称", field: "tableChName", width: 180 }, | ||
| 28 | { label: "数据库表", field: "enName", width: 120 }, | ||
| 29 | { | ||
| 30 | label: "新建方式", field: "foundMode", width: 140, getName: (scope) => { | ||
| 31 | let dataGrade = scope.row.foundMode; | ||
| 32 | return dataGrade == 1 ? '根据文件新建' : '已有表新建'; | ||
| 33 | } | ||
| 34 | }, | ||
| 35 | { | ||
| 36 | label: "状态", field: "state", type: 'tag', width: 180, getName: (scope) => { | ||
| 37 | let status = scope.row.state; | ||
| 38 | // 0 草稿中 1 已建表 2 已有默认表 | ||
| 39 | return status == 0 ? '草稿中' : status == 1 ? '已建表' : '已有默认表'; | ||
| 40 | } | ||
| 41 | }, | ||
| 42 | { label: "任务修改人", field: "damName", width: 120 }, | ||
| 43 | { label: "修改时间", field: "updateTime", width: TableColumnWidth.DATETIME }, | ||
| 44 | { label: "描述", field: "databaseName", width: 120, align: 'center' }, | ||
| 45 | { | ||
| 46 | label: "规划数据资产", field: "isDataAsset", type: 'switch', activeText: '是', inactiveText: '否', activeValue: 'Y', | ||
| 47 | inactiveValue: 'N', switchWidth: 56, width: 120, align: 'center' | ||
| 48 | }, | ||
| 49 | |||
| 50 | ], | ||
| 51 | data: [], | ||
| 52 | page: { | ||
| 53 | type: "normal", | ||
| 54 | rows: 0, | ||
| 55 | ...dataBasePage.value, | ||
| 56 | }, | ||
| 57 | actionInfo: { | ||
| 58 | label: "操作", | ||
| 59 | type: "btn", | ||
| 60 | width: 300, | ||
| 61 | fixed: 'right', | ||
| 62 | btns: [ | ||
| 63 | { | ||
| 64 | label: "配置业务规则", value: "edit", click: (scope) => { | ||
| 65 | console.log('编辑', scope); | ||
| 66 | // 路由跳转configure-rules | ||
| 67 | |||
| 68 | |||
| 69 | } | ||
| 70 | }, | ||
| 71 | |||
| 72 | { | ||
| 73 | label: "编辑表结构", value: "copy", click: (scope) => { | ||
| 74 | console.log('复制', scope); | ||
| 75 | } | ||
| 76 | } | ||
| 77 | ] | ||
| 78 | |||
| 79 | }, | ||
| 80 | loading: false | ||
| 81 | }); | ||
| 82 | </script> | ||
| 8 | <template> | 83 | <template> |
| 9 | <div>111</div> | 84 | <div class="table_panel_wrap"> |
| 85 | <Table :tableInfo="dataBaseTableInfo" /> | ||
| 86 | </div> | ||
| 10 | </template> | 87 | </template> | ... | ... |
src/views/data_inventory/dictionary.vue
0 → 100644
| 1 | <route lang="yaml"> | ||
| 2 | name: dictionary | ||
| 3 | </route> | ||
| 4 | |||
| 5 | <script lang="ts" setup name="dictionary"> | ||
| 6 | import { ref } from 'vue' | ||
| 7 | import { ElMessage, ElMessageBox } from "element-plus"; | ||
| 8 | import { Search } from '@element-plus/icons-vue' | ||
| 9 | import Tree from '@/components/Tree/index.vue' | ||
| 10 | import Table from '@/components/Table/index.vue' | ||
| 11 | import Drawer from '@/components/Drawer/index.vue' | ||
| 12 | import DictFileds from './dictFileds.vue' | ||
| 13 | import useCatchStore from "@/store/modules/catch"; | ||
| 14 | import { download } from '@/utils/common' | ||
| 15 | |||
| 16 | import { | ||
| 17 | addDictionary, | ||
| 18 | deleteDictionary, | ||
| 19 | getDictionary, | ||
| 20 | updateDictionary, | ||
| 21 | getDictionaryTree, | ||
| 22 | getDictionaryDetail, | ||
| 23 | exportDictionary, | ||
| 24 | showDictionary, | ||
| 25 | getDataBaseList, | ||
| 26 | getDataTypeList, | ||
| 27 | getCoderuleList, | ||
| 28 | saveDictionaryData, | ||
| 29 | getDictionaryFileds, | ||
| 30 | updateDictionaryState, | ||
| 31 | getDictionaryRuleData, | ||
| 32 | exportDictionaryFileds, | ||
| 33 | checkDeleteDictionary, | ||
| 34 | checkDeleteDictionaryScheme, | ||
| 35 | checkDictionaryData | ||
| 36 | } from '@/api/modules/dataInventory'; | ||
| 37 | |||
| 38 | const { proxy } = getCurrentInstance() as any; | ||
| 39 | |||
| 40 | const cacheStore = useCatchStore() | ||
| 41 | // 禁用字段 | ||
| 42 | const forbidFields = [ | ||
| 43 | 'guid', | ||
| 44 | 'sharding_flag', | ||
| 45 | 'create_user_id', | ||
| 46 | 'create_user_name', | ||
| 47 | 'update_user_id', | ||
| 48 | 'update_user_name', | ||
| 49 | 'create_time', | ||
| 50 | 'update_time', | ||
| 51 | 'is_deleted' | ||
| 52 | ] | ||
| 53 | const showFiledsPage = ref(false) | ||
| 54 | const dictFiledsRef = ref() | ||
| 55 | const dataTypeList = ref([]) | ||
| 56 | const dataBaseList = ref([]) | ||
| 57 | const codeRuleList = ref([]) | ||
| 58 | const dictTreeRef = ref() | ||
| 59 | const dictType = ref(-1) | ||
| 60 | const dictGuid = ref('') | ||
| 61 | const expandedKey: any = ref([]) | ||
| 62 | const currentNodeKey = ref('') | ||
| 63 | const showLoading = ref(true) | ||
| 64 | const treeData = ref([]) | ||
| 65 | const treeInfo = ref({ | ||
| 66 | id: "data-pickup-tree", | ||
| 67 | filter: true, | ||
| 68 | queryValue: "", | ||
| 69 | queryPlaceholder: "输入字典名称搜索", | ||
| 70 | props: { | ||
| 71 | label: "name", | ||
| 72 | value: "guid", | ||
| 73 | }, | ||
| 74 | nodeKey: 'guid', | ||
| 75 | expandedKey: [], | ||
| 76 | currentNodeKey: '', | ||
| 77 | data: [], | ||
| 78 | expandOnNodeClick: false, | ||
| 79 | loading: false | ||
| 80 | }); | ||
| 81 | |||
| 82 | const tableSearchInput = ref('') | ||
| 83 | const currTableData: any = ref<Object>({}); | ||
| 84 | const page = ref({ | ||
| 85 | limit: 50, | ||
| 86 | curr: 1, | ||
| 87 | sizes: [ | ||
| 88 | { label: "10", value: 10 }, | ||
| 89 | { label: "50", value: 50 }, | ||
| 90 | { label: "100", value: 100 }, | ||
| 91 | { label: "150", value: 150 }, | ||
| 92 | { label: "200", value: 200 }, | ||
| 93 | ], | ||
| 94 | }); | ||
| 95 | const selectRowData = ref([]) | ||
| 96 | const tableInfo: any = ref({ | ||
| 97 | id: 'data-source-table', | ||
| 98 | multiple: true, | ||
| 99 | fixedSelection: true, | ||
| 100 | fields: [ | ||
| 101 | { label: "序号", type: "index", width: 56, align: "center" }, | ||
| 102 | { label: "字典中文名", field: "chName", type: 'text_btn', class: 'drawer-detail-cell', width: 120, value: 'detail', columClass: 'text_btn' }, | ||
| 103 | { label: "字典英文名", field: "enName", width: 120 }, | ||
| 104 | { label: "字典类型", field: "dictionaryType", type: 'filter', width: 120 }, | ||
| 105 | { label: "排序", field: "orderNum", type: 'filter', width: 56, align: 'center' }, | ||
| 106 | { label: '状态', field: 'state', type: 'switch', activeText: '启用', inactiveText: '停用', activeValue: 1, inactiveValue: 0, switchWidth: 56, width: 100, align: 'center' }, | ||
| 107 | { label: "编码规则", field: "codeRuleName", width: 120 }, | ||
| 108 | { label: "修改人", field: "updateUserName", width: 140 }, | ||
| 109 | { label: "修改时间", field: "updateTime", width: 180, }, | ||
| 110 | ], | ||
| 111 | data: [], | ||
| 112 | page: { | ||
| 113 | type: "normal", | ||
| 114 | rows: 0, | ||
| 115 | ...page.value, | ||
| 116 | }, | ||
| 117 | actionInfo: { | ||
| 118 | label: "操作", | ||
| 119 | type: "btn", | ||
| 120 | width: 92, //不要刚好90.缩小浏览器会因为小数点的差距而换行, | ||
| 121 | fixed: 'right', | ||
| 122 | btns: [ | ||
| 123 | { label: "编辑", value: "edit" }, | ||
| 124 | { label: "删除", value: "delete" }, | ||
| 125 | ], | ||
| 126 | }, | ||
| 127 | loading: false | ||
| 128 | }) | ||
| 129 | |||
| 130 | const dictionaryType = ref(1) | ||
| 131 | const orginOptions = [ | ||
| 132 | { label: 'code', value: 'code' }, | ||
| 133 | { label: 'name', value: 'name' }, | ||
| 134 | ] | ||
| 135 | const orginItems = [ | ||
| 136 | // { | ||
| 137 | // label: '数据库名称', | ||
| 138 | // type: 'select', | ||
| 139 | // placeholder: '请选择', | ||
| 140 | // field: 'databaseNameZh', | ||
| 141 | // options: [], | ||
| 142 | // clearable: true, | ||
| 143 | // required: true, | ||
| 144 | // visible: true, | ||
| 145 | // }, | ||
| 146 | { | ||
| 147 | label: '字典中文名', | ||
| 148 | type: 'input', | ||
| 149 | maxlength: 50, | ||
| 150 | placeholder: '请输入', | ||
| 151 | field: 'chName', | ||
| 152 | clearable: true, | ||
| 153 | required: true, | ||
| 154 | disabled: false | ||
| 155 | }, { | ||
| 156 | label: '字典英文名', | ||
| 157 | type: 'input', | ||
| 158 | maxlength: 50, | ||
| 159 | placeholder: '请输入', | ||
| 160 | field: 'enName', | ||
| 161 | clearable: true, | ||
| 162 | required: true, | ||
| 163 | disabled: false | ||
| 164 | }, { | ||
| 165 | label: '排序', | ||
| 166 | type: 'input', | ||
| 167 | placeholder: '请输入', | ||
| 168 | field: 'orderNum', | ||
| 169 | maxlength: 6, | ||
| 170 | clearable: true, | ||
| 171 | required: true, | ||
| 172 | visible: true, | ||
| 173 | }, { | ||
| 174 | label: '字典类型', | ||
| 175 | type: 'radio-panel', | ||
| 176 | placeholder: '', | ||
| 177 | field: 'dictionaryType', | ||
| 178 | default: 1, | ||
| 179 | options: [ | ||
| 180 | { label: '列表结构', value: 1 }, | ||
| 181 | { label: '层级结构', value: 2 }, | ||
| 182 | { label: '螺旋结构', value: 3 }, | ||
| 183 | { label: '通用结构', value: 4 }, | ||
| 184 | ], | ||
| 185 | children: [ | ||
| 186 | { | ||
| 187 | label: '编码字段', | ||
| 188 | type: 'select', | ||
| 189 | placeholder: '请输入', | ||
| 190 | field: 'codeColumn', | ||
| 191 | default: '', | ||
| 192 | options: [], | ||
| 193 | clearable: true, | ||
| 194 | required: true | ||
| 195 | }, { | ||
| 196 | label: '编码名称', | ||
| 197 | type: 'select', | ||
| 198 | placeholder: '请输入', | ||
| 199 | field: 'codeName', | ||
| 200 | default: '', | ||
| 201 | options: [], | ||
| 202 | clearable: true, | ||
| 203 | required: true | ||
| 204 | }, { | ||
| 205 | label: '顶级节点值', | ||
| 206 | type: 'input', | ||
| 207 | placeholder: '请输入', | ||
| 208 | field: 'topNodeValue', | ||
| 209 | clearable: true, | ||
| 210 | required: true, | ||
| 211 | visible: false | ||
| 212 | }, { | ||
| 213 | label: '路径', | ||
| 214 | type: 'input', | ||
| 215 | placeholder: '请输入', | ||
| 216 | field: 'path', | ||
| 217 | clearable: true, | ||
| 218 | required: true, | ||
| 219 | block: true, | ||
| 220 | visible: false | ||
| 221 | } | ||
| 222 | ], | ||
| 223 | clearable: true, | ||
| 224 | required: false, | ||
| 225 | block: true, | ||
| 226 | visible: true, | ||
| 227 | }, | ||
| 228 | ] | ||
| 229 | const formItems: any = ref([]) | ||
| 230 | const formRules: any = ref({ | ||
| 231 | chName: [ | ||
| 232 | { | ||
| 233 | required: true, | ||
| 234 | message: "请填写中文名", | ||
| 235 | trigger: "blur", | ||
| 236 | }, | ||
| 237 | ], | ||
| 238 | enName: [ | ||
| 239 | { | ||
| 240 | required: true, | ||
| 241 | message: "请填写英文名", | ||
| 242 | trigger: "blur", | ||
| 243 | }, | ||
| 244 | ], | ||
| 245 | orderNum: [{ | ||
| 246 | validator: (rule: any, value: any, callback: any) => { | ||
| 247 | if (value === 0) { | ||
| 248 | callback(); | ||
| 249 | return; | ||
| 250 | } | ||
| 251 | if (!value) { | ||
| 252 | callback(new Error('请填写排序')); | ||
| 253 | return; | ||
| 254 | } | ||
| 255 | const r = /(^[0-9]([0-9]*)$|^[0-9]$)/; // 正整数(可以以0打头) | ||
| 256 | if (value && !r.test(value)) { | ||
| 257 | callback(new Error('请填写大于或等于零整数')); | ||
| 258 | return; | ||
| 259 | } | ||
| 260 | callback(); | ||
| 261 | }, | ||
| 262 | trigger: "blur", | ||
| 263 | }], | ||
| 264 | codeColumn: [ | ||
| 265 | { | ||
| 266 | required: true, | ||
| 267 | message: "请填写编码字段", | ||
| 268 | trigger: "blur", | ||
| 269 | }, | ||
| 270 | ], | ||
| 271 | codeName: [ | ||
| 272 | { | ||
| 273 | required: true, | ||
| 274 | message: "请填写编码名称", | ||
| 275 | trigger: "blur", | ||
| 276 | }, | ||
| 277 | ], | ||
| 278 | }) | ||
| 279 | const formInfo = ref({ | ||
| 280 | type: 'form', | ||
| 281 | title: '', | ||
| 282 | col: 'span', | ||
| 283 | formInfo: { | ||
| 284 | id: 'add-dict-form', | ||
| 285 | col: 'col3', | ||
| 286 | readonly: false, | ||
| 287 | items: formItems.value, | ||
| 288 | rules: formRules.value | ||
| 289 | } | ||
| 290 | }) | ||
| 291 | |||
| 292 | const orginData = [ | ||
| 293 | { | ||
| 294 | ROWID: 'field_0', | ||
| 295 | fieldName: 'code', | ||
| 296 | description: '编码字段', | ||
| 297 | fieldType: 'varchar', | ||
| 298 | fieldLength: '10', | ||
| 299 | fieldPrecision: '', | ||
| 300 | // orderNum: '1', | ||
| 301 | codeRuleGuid: '', | ||
| 302 | STATUS: 'edit', | ||
| 303 | STATE: 'Running' | ||
| 304 | }, { | ||
| 305 | ROWID: 'field_1', | ||
| 306 | fieldName: 'name', | ||
| 307 | description: '编码名称', | ||
| 308 | fieldType: 'varchar', | ||
| 309 | fieldLength: '20', | ||
| 310 | fieldPrecision: '', | ||
| 311 | // orderNum: '2', | ||
| 312 | codeRuleGuid: '', | ||
| 313 | STATUS: 'edit', | ||
| 314 | STATE: 'Running' | ||
| 315 | } | ||
| 316 | ] | ||
| 317 | const orginFields = [ | ||
| 318 | { label: "序号", type: "index", width: 56, align: "center" }, | ||
| 319 | { label: "字段英文名", field: "fieldName", width: 140, }, | ||
| 320 | { label: "字段中文名", field: "description", width: 140, }, | ||
| 321 | { label: "字段类型", field: "fieldType", width: 100, }, | ||
| 322 | { label: "长度", field: "fieldLength", width: 80, }, | ||
| 323 | { label: "精度", field: "fieldPrecision", width: 80, }, | ||
| 324 | // { label: "排序", field: "orderNum", width: 56, }, | ||
| 325 | { label: "编码规则", field: "codeRuleGuid", width: 140, }, | ||
| 326 | ] | ||
| 327 | const formTableData: any = ref([]) | ||
| 328 | const formTableSelectRowData: any = ref([]) | ||
| 329 | const editTableInfo = ref({ | ||
| 330 | fieldName: { | ||
| 331 | label: '字段英文名', | ||
| 332 | type: 'input', | ||
| 333 | maxlength: 50, | ||
| 334 | placeholder: '', | ||
| 335 | field: 'fieldName', | ||
| 336 | default: '', | ||
| 337 | clearable: true, | ||
| 338 | required: true, | ||
| 339 | }, | ||
| 340 | description: { | ||
| 341 | label: '字段中文名', | ||
| 342 | type: 'input', | ||
| 343 | maxlength: 50, | ||
| 344 | placeholder: '', | ||
| 345 | field: 'description', | ||
| 346 | default: '', | ||
| 347 | clearable: true, | ||
| 348 | required: true, | ||
| 349 | }, | ||
| 350 | fieldType: { | ||
| 351 | label: '字段类型', | ||
| 352 | type: 'select', | ||
| 353 | placeholder: '', | ||
| 354 | field: 'fieldType', | ||
| 355 | default: '', | ||
| 356 | options: [], | ||
| 357 | clearable: true, | ||
| 358 | required: true | ||
| 359 | }, | ||
| 360 | fieldLength: { | ||
| 361 | label: '长度', | ||
| 362 | type: 'input', | ||
| 363 | placeholder: '', | ||
| 364 | field: 'fieldLength', | ||
| 365 | default: '', | ||
| 366 | clearable: true, | ||
| 367 | required: true, | ||
| 368 | }, | ||
| 369 | fieldPrecision: { | ||
| 370 | label: '精度', | ||
| 371 | type: 'input', | ||
| 372 | placeholder: '', | ||
| 373 | field: 'fieldPrecision', | ||
| 374 | default: '', | ||
| 375 | clearable: true, | ||
| 376 | required: true, | ||
| 377 | }, | ||
| 378 | // orderNum: { | ||
| 379 | // label: '排序', | ||
| 380 | // type: 'input', | ||
| 381 | // placeholder: '', | ||
| 382 | // field: 'orderNum', | ||
| 383 | // default: '', | ||
| 384 | // maxlength: 6, | ||
| 385 | // clearable: true, | ||
| 386 | // required: true, | ||
| 387 | // }, | ||
| 388 | codeRuleGuid: { | ||
| 389 | label: '编码规则', | ||
| 390 | type: 'select', | ||
| 391 | placeholder: '', | ||
| 392 | field: 'codeRuleGuid', | ||
| 393 | default: '', | ||
| 394 | options: [], | ||
| 395 | clearable: true, | ||
| 396 | required: true | ||
| 397 | } | ||
| 398 | }) | ||
| 399 | const formTable = ref({ | ||
| 400 | type: "table", | ||
| 401 | title: "定义表结构", | ||
| 402 | col: 'no-margin', | ||
| 403 | style: { | ||
| 404 | height: 'calc(100% - 234px)' | ||
| 405 | }, | ||
| 406 | tableInfo: { | ||
| 407 | id: "role-authority-table", | ||
| 408 | multiple: true, | ||
| 409 | minHeight: 'unset', | ||
| 410 | maxHeight: '100%', | ||
| 411 | fields: [], | ||
| 412 | data: [], | ||
| 413 | showPage: false, | ||
| 414 | actionInfo: { | ||
| 415 | show: true, | ||
| 416 | label: "操作", | ||
| 417 | type: "btn", | ||
| 418 | width: 60, | ||
| 419 | fixed: 'right', | ||
| 420 | btns: [ | ||
| 421 | { label: "删除", value: "remove" }, | ||
| 422 | ] | ||
| 423 | }, | ||
| 424 | editInfo: {}, | ||
| 425 | readonly: false, | ||
| 426 | col: 'auto-height', | ||
| 427 | style: { | ||
| 428 | height: 'calc(100% - 40px)' | ||
| 429 | }, | ||
| 430 | loading: false | ||
| 431 | }, | ||
| 432 | tableTool: { | ||
| 433 | col: 'float-right', | ||
| 434 | visible: true, | ||
| 435 | btns: [ | ||
| 436 | { label: "新增行", value: "add-row", type: 'primary', plain: true }, | ||
| 437 | { label: "批量删除", value: "remove_batch" }, | ||
| 438 | ] | ||
| 439 | }, | ||
| 440 | }) | ||
| 441 | |||
| 442 | const fieldSheetInfo: any = ref({}) | ||
| 443 | const uploadTableData: any = ref([]) | ||
| 444 | const uploadSelectRowData: any = ref([]) | ||
| 445 | const uploadTableFields: any = ref([]) | ||
| 446 | const uploadTableInfo = ref({ | ||
| 447 | id: "role-authority-table", | ||
| 448 | multiple: true, | ||
| 449 | // minHeight: 'unset', | ||
| 450 | // maxHeight: '100%', | ||
| 451 | fields: [], | ||
| 452 | data: [], | ||
| 453 | showPage: false, | ||
| 454 | actionInfo: { | ||
| 455 | label: "操作", | ||
| 456 | type: "btn", | ||
| 457 | width: 60, | ||
| 458 | btns: [ | ||
| 459 | { label: "删除", value: "remove" }, | ||
| 460 | ], | ||
| 461 | }, | ||
| 462 | editInfo: {}, | ||
| 463 | readonly: false, | ||
| 464 | loading: false | ||
| 465 | }) | ||
| 466 | const uploadFiles: any = ref([]) | ||
| 467 | const uploadInfo = ref({ | ||
| 468 | type: 'upload', | ||
| 469 | title: '添加表数据', | ||
| 470 | col: 'row-reverse', | ||
| 471 | uploadInfo: { | ||
| 472 | id: 'upload-file-form', | ||
| 473 | action: '', | ||
| 474 | auto: false, | ||
| 475 | fileList: [], | ||
| 476 | accept: '.xlsx, .xls', | ||
| 477 | cover: true, | ||
| 478 | triggerBtn: { | ||
| 479 | label: '导入文件', | ||
| 480 | value: 'import_file', | ||
| 481 | icon: 'Upload', | ||
| 482 | plain: true, | ||
| 483 | }, | ||
| 484 | toolBar: [ | ||
| 485 | { label: '下载模板', value: 'export_model', plain: true, icon: 'Download' }, | ||
| 486 | ] | ||
| 487 | // showList: false, | ||
| 488 | }, | ||
| 489 | tableInfo: {}, | ||
| 490 | tools: { | ||
| 491 | col: 'right', | ||
| 492 | visible: true, | ||
| 493 | btns: [ | ||
| 494 | { label: '树形显示', value: 'show_tree', type: 'primary', plain: true, visible: false }, | ||
| 495 | { label: '新增行', value: 'add_row', type: 'primary', plain: true }, | ||
| 496 | { label: '批量删除', value: 'remove_batch', plain: true }, | ||
| 497 | ] | ||
| 498 | } | ||
| 499 | }) | ||
| 500 | const fieldTableInfo = ref({ | ||
| 501 | type: 'field-table', | ||
| 502 | title: '表数据', | ||
| 503 | tableInfo: { | ||
| 504 | id: 'dict-field-table', | ||
| 505 | minHeight: 'unset', | ||
| 506 | maxHeight: '100%', | ||
| 507 | fields: [], | ||
| 508 | data: [], | ||
| 509 | loading: false, | ||
| 510 | showPage: false, | ||
| 511 | actionInfo: { | ||
| 512 | show: false | ||
| 513 | }, | ||
| 514 | col: 'auto-height' | ||
| 515 | } | ||
| 516 | }) | ||
| 517 | |||
| 518 | const contents = ref({ | ||
| 519 | add: [ | ||
| 520 | formInfo.value, | ||
| 521 | formTable.value, | ||
| 522 | ], | ||
| 523 | upload: [ | ||
| 524 | formInfo.value, | ||
| 525 | uploadInfo.value, | ||
| 526 | ], | ||
| 527 | sheet: [ | ||
| 528 | formInfo.value, | ||
| 529 | formTable.value, | ||
| 530 | ], | ||
| 531 | field: [ | ||
| 532 | formInfo.value, | ||
| 533 | fieldTableInfo.value, | ||
| 534 | ] | ||
| 535 | }) | ||
| 536 | |||
| 537 | const drawerRef = ref() | ||
| 538 | const drawerInfo: any = ref({ | ||
| 539 | visible: false, | ||
| 540 | direction: "rtl", | ||
| 541 | modalClass: "", | ||
| 542 | modalClose: false, | ||
| 543 | modal: true, | ||
| 544 | size: 700, | ||
| 545 | header: { | ||
| 546 | title: "新增", | ||
| 547 | }, | ||
| 548 | type: '', | ||
| 549 | container: { | ||
| 550 | contents: [], | ||
| 551 | }, | ||
| 552 | footer: { | ||
| 553 | btns: [ | ||
| 554 | { type: 'default', label: '取消', value: 'cancel' }, | ||
| 555 | { type: 'primary', label: '保存', value: 'submit' }, | ||
| 556 | { type: 'primary', label: '查看数据', value: 'fileds', visible: false }, | ||
| 557 | { type: 'primary', label: '查看表结构', value: 'sheet', visible: false }, | ||
| 558 | { type: 'primary', label: '保存并添加数据', value: 'saveAndAdd', visible: true }, | ||
| 559 | ] | ||
| 560 | }, | ||
| 561 | }) | ||
| 562 | |||
| 563 | const setFormItems = (row: any = null) => { | ||
| 564 | formItems.value = JSON.parse(JSON.stringify(orginItems)) | ||
| 565 | formItems.value.map(item => { | ||
| 566 | if (item.field == 'databaseNameZh') { | ||
| 567 | item.options = dataBaseList.value | ||
| 568 | item.default = row ? row[item.field] : '' | ||
| 569 | } else if (item.field == 'dictionaryType') { | ||
| 570 | item.default = dictionaryType.value | ||
| 571 | // item.disabled = drawerInfo.value.type == 'add' ? false : true | ||
| 572 | item.disabled = true | ||
| 573 | item.children.map(child => { | ||
| 574 | child.options = orginOptions | ||
| 575 | if (child.field == 'codeColumn') { | ||
| 576 | child.default = row ? row[child.field] : 'code' | ||
| 577 | } else if (child.field == 'codeName') { | ||
| 578 | child.default = row ? row[child.field] : 'name' | ||
| 579 | } else { | ||
| 580 | child.default = row ? row[child.field] : '' | ||
| 581 | } | ||
| 582 | child.disabled = drawerInfo.value.type == 'detail' ? true : false | ||
| 583 | child.clearable = drawerInfo.value.type == 'detail' ? false : true | ||
| 584 | }) | ||
| 585 | } else if (item.field == 'enName') { | ||
| 586 | item.default = row ? row[item.field] : '' | ||
| 587 | item.disabled = drawerInfo.value.type == 'add' ? false : true | ||
| 588 | item.clearable = drawerInfo.value.type == 'add' ? true : false | ||
| 589 | } else { | ||
| 590 | item.default = row ? row[item.field] : '' | ||
| 591 | item.disabled = drawerInfo.value.type == 'detail' ? true : false | ||
| 592 | item.clearable = drawerInfo.value.type == 'detail' ? false : true | ||
| 593 | } | ||
| 594 | }) | ||
| 595 | formInfo.value.formInfo.readonly = drawerInfo.value.type == 'detail' | ||
| 596 | formInfo.value.formInfo.items = formItems.value | ||
| 597 | |||
| 598 | // for(var e in editTableInfo.value){ | ||
| 599 | // const editItem = editTableInfo.value[e] | ||
| 600 | // if(editItem.field != 'description' && editItem.field != 'codeRuleGuid'){ | ||
| 601 | // editItem.disabled = drawerInfo.value.type != 'add' | ||
| 602 | // } | ||
| 603 | // } | ||
| 604 | } | ||
| 605 | |||
| 606 | // 获取数据类型列表 | ||
| 607 | const getDataType = (type) => { | ||
| 608 | let params = { | ||
| 609 | paramCode: type | ||
| 610 | } | ||
| 611 | getDataTypeList(params).then((res: any) => { | ||
| 612 | if (res.code == proxy.$passCode) { | ||
| 613 | const data = res.data | ||
| 614 | if (type == 'DATA_TYPE') { | ||
| 615 | data.map(item => { | ||
| 616 | item.label = item.paramName | ||
| 617 | item.value = item.paramValue | ||
| 618 | }) | ||
| 619 | dataTypeList.value = data | ||
| 620 | editTableInfo.value['fieldType'].options = data | ||
| 621 | } | ||
| 622 | } else { | ||
| 623 | ElMessage({ | ||
| 624 | type: 'error', | ||
| 625 | message: res.msg, | ||
| 626 | }) | ||
| 627 | } | ||
| 628 | }) | ||
| 629 | } | ||
| 630 | |||
| 631 | // 获取数据库列表 | ||
| 632 | const getDataBase = () => { | ||
| 633 | const params = { | ||
| 634 | pageIndex: 1, | ||
| 635 | connectStatus: '1' | ||
| 636 | } | ||
| 637 | getDataBaseList(params).then((res: any) => { | ||
| 638 | if (res.code == proxy.$passCode) { | ||
| 639 | const data = res.data ?? [] | ||
| 640 | data.map(item => { | ||
| 641 | item.label = item.databaseNameZh | ||
| 642 | item.value = item.guid | ||
| 643 | }) | ||
| 644 | dataBaseList.value = data | ||
| 645 | } else { | ||
| 646 | ElMessage({ | ||
| 647 | type: 'error', | ||
| 648 | message: res.msg, | ||
| 649 | }) | ||
| 650 | } | ||
| 651 | }) | ||
| 652 | } | ||
| 653 | |||
| 654 | // 获取编码规则列表 | ||
| 655 | const getCodeRuleData = () => { | ||
| 656 | let params = {} | ||
| 657 | getCoderuleList(params).then((res: any) => { | ||
| 658 | if (res.code == proxy.$passCode) { | ||
| 659 | const data = res.data | ||
| 660 | data.map(item => { | ||
| 661 | item.label = item.ruleName | ||
| 662 | item.value = item.guid | ||
| 663 | }) | ||
| 664 | codeRuleList.value = data | ||
| 665 | editTableInfo.value['codeRuleGuid'].options = data | ||
| 666 | } else { | ||
| 667 | ElMessage({ | ||
| 668 | type: 'error', | ||
| 669 | message: res.msg, | ||
| 670 | }) | ||
| 671 | } | ||
| 672 | }) | ||
| 673 | } | ||
| 674 | |||
| 675 | const treePromise = ref(); | ||
| 676 | |||
| 677 | // 获取数据字典树形数据 | ||
| 678 | const getTreeData = (needClick = false, currData = {}) => { | ||
| 679 | const params = { | ||
| 680 | paramCode: 'data_structure_code' | ||
| 681 | } | ||
| 682 | treeInfo.value.loading = true | ||
| 683 | treePromise.value = getDictionaryTree(params).then((res: any) => { | ||
| 684 | treePromise.value = null; | ||
| 685 | if (res.code == proxy.$passCode) { | ||
| 686 | const data = res.data ?? [] | ||
| 687 | const treeList = data.filter(item => item.children && item.children.length) | ||
| 688 | treeData.value = treeList | ||
| 689 | treeInfo.value.data = treeList | ||
| 690 | if (treeList.length) { | ||
| 691 | dictType.value = dictType.value == -1 ? Number(treeList[0].dictionaryType) : dictType.value; | ||
| 692 | expandedKey.value = expandedKey.value.length == 0 ? [treeList[0].guid] : expandedKey.value; | ||
| 693 | if (!needClick && !cacheStore.getCatch('dictionaryGuid')) { | ||
| 694 | currentNodeKey.value = currentNodeKey.value == '' ? treeList[0].guid : currentNodeKey.value | ||
| 695 | nextTick(() => { | ||
| 696 | treeInfo.value.currentNodeKey = currentNodeKey.value | ||
| 697 | treeInfo.value.expandedKey = expandedKey.value | ||
| 698 | }) | ||
| 699 | } else { | ||
| 700 | nextTick(() => { | ||
| 701 | treeInfo.value.expandedKey = expandedKey.value; | ||
| 702 | }); | ||
| 703 | } | ||
| 704 | getFirstPageData() | ||
| 705 | } | ||
| 706 | } else { | ||
| 707 | ElMessage({ | ||
| 708 | type: 'error', | ||
| 709 | message: res.msg, | ||
| 710 | }) | ||
| 711 | } | ||
| 712 | treeInfo.value.loading = false; | ||
| 713 | if (needClick) { | ||
| 714 | nextTick(() => { | ||
| 715 | nodeClick(currData); | ||
| 716 | }); | ||
| 717 | } | ||
| 718 | }).catch(() => { | ||
| 719 | treeInfo.value.loading = false | ||
| 720 | }) | ||
| 721 | } | ||
| 722 | |||
| 723 | const getFirstPageData = () => { | ||
| 724 | page.value.curr = 1; | ||
| 725 | toSearch({}) | ||
| 726 | } | ||
| 727 | |||
| 728 | const toSearch = (val: any, clear: boolean = false) => { | ||
| 729 | let params: any = Object.keys(val).length ? { ...val } : {} | ||
| 730 | params.pageIndex = page.value.curr; | ||
| 731 | params.pageSize = page.value.limit; | ||
| 732 | params.dictionaryType = dictType.value | ||
| 733 | params.name = tableSearchInput.value | ||
| 734 | getTableData(params); | ||
| 735 | }; | ||
| 736 | |||
| 737 | const getTableData = (params) => { | ||
| 738 | tableInfo.value.loading = true | ||
| 739 | getDictionary(params).then((res: any) => { | ||
| 740 | if (res.code == proxy.$passCode) { | ||
| 741 | const data = res.data || {} | ||
| 742 | tableInfo.value.data = data.records || [] | ||
| 743 | tableInfo.value.page.limit = data.pageSize | ||
| 744 | tableInfo.value.page.curr = data.pageIndex | ||
| 745 | tableInfo.value.page.rows = data.totalRows | ||
| 746 | } else { | ||
| 747 | ElMessage({ | ||
| 748 | type: 'error', | ||
| 749 | message: res.msg, | ||
| 750 | }) | ||
| 751 | } | ||
| 752 | tableInfo.value.loading = false | ||
| 753 | }).catch(xhr => { | ||
| 754 | tableInfo.value.loading = false | ||
| 755 | }) | ||
| 756 | }; | ||
| 757 | |||
| 758 | const tableSelectionChange = (val, tId) => { | ||
| 759 | if (drawerInfo.value.visible) { | ||
| 760 | if (formItems.value.length == 2) { | ||
| 761 | uploadSelectRowData.value = val | ||
| 762 | } else { | ||
| 763 | formTableSelectRowData.value = val | ||
| 764 | } | ||
| 765 | } else { | ||
| 766 | selectRowData.value = val.map((item) => item.guid); | ||
| 767 | } | ||
| 768 | }; | ||
| 769 | |||
| 770 | const tablePageChange = (info) => { | ||
| 771 | page.value.curr = Number(info.curr); | ||
| 772 | page.value.limit = Number(info.limit); | ||
| 773 | toSearch({}); | ||
| 774 | }; | ||
| 775 | |||
| 776 | const tableInputChange = (val, scope) => { | ||
| 777 | if (forbidFields.indexOf(val) > -1) { | ||
| 778 | ElMessage({ | ||
| 779 | type: "error", | ||
| 780 | message: '该名称已存在,请填写其他名称', | ||
| 781 | }); | ||
| 782 | return | ||
| 783 | } | ||
| 784 | setCodeOptions() | ||
| 785 | } | ||
| 786 | |||
| 787 | const setCodeOptions = () => { | ||
| 788 | let opts: any = [] | ||
| 789 | formTableData.value.map(item => { | ||
| 790 | if (item.fieldName) { | ||
| 791 | const row = JSON.parse(JSON.stringify(item)) | ||
| 792 | row.label = item.fieldName | ||
| 793 | row.value = item.fieldName | ||
| 794 | opts.push(row) | ||
| 795 | } | ||
| 796 | }) | ||
| 797 | formItems.value.at(-1).children.map(child => { | ||
| 798 | if (child.type == 'select') { | ||
| 799 | child.options = opts | ||
| 800 | } | ||
| 801 | }) | ||
| 802 | } | ||
| 803 | |||
| 804 | const toolBtnClick = (btn, data) => { | ||
| 805 | const type = btn.value | ||
| 806 | if (data) { | ||
| 807 | if (type.indexOf('add') > -1) { | ||
| 808 | if (formItems.value.length == 2) { | ||
| 809 | const params = { | ||
| 810 | guid: fieldSheetInfo.value.guid | ||
| 811 | } | ||
| 812 | uploadTableInfo.value.loading = true | ||
| 813 | getDictionaryRuleData(params).then((res: any) => { | ||
| 814 | if (res.code == proxy.$passCode) { | ||
| 815 | const data = res.data ?? {} | ||
| 816 | let rowInfo: any = {} | ||
| 817 | uploadTableFields.value.map(item => { | ||
| 818 | rowInfo[item.field] = data[item.field] ?? '' | ||
| 819 | }) | ||
| 820 | rowInfo.STATUS = 'edit' | ||
| 821 | rowInfo.STATE = 'Running' | ||
| 822 | rowInfo.ROWID = `upload_${uploadTableData.value.length}` | ||
| 823 | uploadTableData.value.push(rowInfo) | ||
| 824 | uploadTableInfo.value.data = uploadTableData.value | ||
| 825 | scrollTable(rowInfo) | ||
| 826 | } else { | ||
| 827 | ElMessage({ | ||
| 828 | type: 'error', | ||
| 829 | message: res.msg | ||
| 830 | }) | ||
| 831 | } | ||
| 832 | uploadTableInfo.value.loading = false | ||
| 833 | }).catch(() => { | ||
| 834 | uploadTableInfo.value.loading = false | ||
| 835 | }) | ||
| 836 | } else { | ||
| 837 | const rowInfo = { | ||
| 838 | ROWID: `formData_${formTableData.value.length}`, | ||
| 839 | fieldName: '', | ||
| 840 | description: '', | ||
| 841 | fieldType: '', | ||
| 842 | fieldLength: '', | ||
| 843 | fieldPrecision: '', | ||
| 844 | orderNum: '', | ||
| 845 | codeRuleGuid: '', | ||
| 846 | STATUS: 'edit', | ||
| 847 | STATE: 'Running' | ||
| 848 | } | ||
| 849 | let list: any = formTableData.value | ||
| 850 | list.push(rowInfo) | ||
| 851 | formTable.value.tableInfo.data = list | ||
| 852 | scrollTable(rowInfo) | ||
| 853 | } | ||
| 854 | } else if (type.indexOf('remove') > -1) { | ||
| 855 | if (formItems.value.length == 2) { | ||
| 856 | if (uploadSelectRowData.value.length == 0) { | ||
| 857 | ElMessage({ | ||
| 858 | type: "error", | ||
| 859 | message: '请选择需要删除的数据', | ||
| 860 | }); | ||
| 861 | return | ||
| 862 | } | ||
| 863 | uploadSelectRowData.value.map(item => { | ||
| 864 | const existIndex = uploadTableData.value.findIndex(s => s.ROWID == item.ROWID) | ||
| 865 | existIndex > -1 && uploadTableData.value.splice(existIndex, 1) | ||
| 866 | }) | ||
| 867 | } else { | ||
| 868 | if (formTableSelectRowData.value.length == 0) { | ||
| 869 | ElMessage({ | ||
| 870 | type: "error", | ||
| 871 | message: '请选择需要删除的数据', | ||
| 872 | }); | ||
| 873 | return | ||
| 874 | } | ||
| 875 | const removeRows = () => { | ||
| 876 | formTableSelectRowData.value.map(item => { | ||
| 877 | const existIndex = formTableData.value.findIndex(s => s.ROWID == item.ROWID) | ||
| 878 | existIndex > -1 && formTableData.value.splice(existIndex, 1) | ||
| 879 | }) | ||
| 880 | } | ||
| 881 | if (drawerInfo.value.type == 'edit') { | ||
| 882 | const editRows = formTableSelectRowData.value.filter(item => item.guid !== undefined) | ||
| 883 | if (editRows.length) { | ||
| 884 | formTable.value.tableInfo.loading = true | ||
| 885 | checkDelete().then((res: any) => { | ||
| 886 | if (res) { | ||
| 887 | ElMessageBox.confirm("数据字典有数据, 确定是否继续删除?", "提示", { | ||
| 888 | confirmButtonText: "确定", | ||
| 889 | cancelButtonText: "取消", | ||
| 890 | type: 'warning', | ||
| 891 | }).then(() => { | ||
| 892 | removeRows() | ||
| 893 | }) | ||
| 894 | } else { | ||
| 895 | removeRows() | ||
| 896 | } | ||
| 897 | formTable.value.tableInfo.loading = false | ||
| 898 | }).catch(xhr => { | ||
| 899 | ElMessage({ | ||
| 900 | type: 'error', | ||
| 901 | message: xhr | ||
| 902 | }) | ||
| 903 | formTable.value.tableInfo.loading = false | ||
| 904 | }) | ||
| 905 | } else { | ||
| 906 | removeRows() | ||
| 907 | } | ||
| 908 | } else { | ||
| 909 | removeRows() | ||
| 910 | } | ||
| 911 | } | ||
| 912 | } | ||
| 913 | } else { | ||
| 914 | if (type == 'export_model') { | ||
| 915 | exportData('model') | ||
| 916 | } else if (type == 'import_file') { | ||
| 917 | importData() | ||
| 918 | } | ||
| 919 | } | ||
| 920 | } | ||
| 921 | |||
| 922 | const tableSwitchBeforeChange = (scope, field, callback) => { | ||
| 923 | const msg = '确定修改状态?' | ||
| 924 | ElMessageBox.confirm( | ||
| 925 | msg, | ||
| 926 | '提示', | ||
| 927 | { | ||
| 928 | confirmButtonText: '确定', | ||
| 929 | cancelButtonText: '取消', | ||
| 930 | type: 'warning', | ||
| 931 | } | ||
| 932 | ).then(() => { | ||
| 933 | const state = scope.row[field] == 1 ? 0 : 1 | ||
| 934 | const result = tableSwitchChange(state, scope, field) | ||
| 935 | callback(result) | ||
| 936 | }).catch(() => { | ||
| 937 | callback(false) | ||
| 938 | }) | ||
| 939 | } | ||
| 940 | |||
| 941 | const tableSwitchChange = (val, scope, field) => { | ||
| 942 | return new Promise((resolve, reject) => { | ||
| 943 | let params = { | ||
| 944 | guid: scope.row.guid, | ||
| 945 | dictionaryState: val | ||
| 946 | } | ||
| 947 | updateDictionaryState(params).then((res: any) => { | ||
| 948 | if (res.code == proxy.$passCode && res.data) { | ||
| 949 | getFirstPageData() | ||
| 950 | ElMessage({ | ||
| 951 | type: "success", | ||
| 952 | message: '状态修改成功', | ||
| 953 | }); | ||
| 954 | resolve(true) | ||
| 955 | } else { | ||
| 956 | ElMessage({ | ||
| 957 | type: "error", | ||
| 958 | message: res.msg, | ||
| 959 | }); | ||
| 960 | reject(false) | ||
| 961 | } | ||
| 962 | }).catch(() => { | ||
| 963 | reject(false) | ||
| 964 | }) | ||
| 965 | }) | ||
| 966 | } | ||
| 967 | |||
| 968 | const tableBtnClick = (scope, btn) => { | ||
| 969 | const type = btn.value; | ||
| 970 | const row = scope.row; | ||
| 971 | if (type == "edit" || type == 'detail') { | ||
| 972 | fieldTableInfo.value.tableInfo.fields = [] | ||
| 973 | fieldTableInfo.value.tableInfo.data = [] | ||
| 974 | drawerInfo.value.header.title = type == 'edit' ? "编辑数据字典" : "数据字典详情"; | ||
| 975 | drawerInfo.value.modalClass = type == 'edit' ? '' : 'wrap_width_auto' | ||
| 976 | drawerInfo.value.type = type | ||
| 977 | drawerInfo.value.visible = true; | ||
| 978 | if (drawerInfo.value.type == 'detail') { | ||
| 979 | formTable.value.tableInfo.multiple = false | ||
| 980 | formTable.value.tableTool.visible = false | ||
| 981 | formTable.value.tableInfo.actionInfo.show = false | ||
| 982 | drawerInfo.value.footer.btns.at(1).visible = false | ||
| 983 | drawerInfo.value.footer.btns.at(-1).visible = false | ||
| 984 | drawerInfo.value.footer.btns.at(-2).visible = false | ||
| 985 | drawerInfo.value.footer.btns.at(-3).visible = true | ||
| 986 | } else { | ||
| 987 | formTable.value.tableInfo.multiple = true | ||
| 988 | formTable.value.tableInfo.actionInfo.show = true | ||
| 989 | formTable.value.tableTool.visible = true | ||
| 990 | drawerInfo.value.footer.btns.at(1).visible = true | ||
| 991 | drawerInfo.value.footer.btns.at(-1).visible = true | ||
| 992 | drawerInfo.value.footer.btns.at(-2).visible = false | ||
| 993 | drawerInfo.value.footer.btns.at(-3).visible = false | ||
| 994 | } | ||
| 995 | drawerInfo.value.loading = true; | ||
| 996 | formTable.value.tableInfo.loading = true | ||
| 997 | getDictionaryDetail(row.guid).then((res: any) => { | ||
| 998 | if (res.code == proxy.$passCode && res.data) { | ||
| 999 | let data = res.data | ||
| 1000 | currTableData.value = data; | ||
| 1001 | setDetailInfo() | ||
| 1002 | } else { | ||
| 1003 | ElMessage({ | ||
| 1004 | type: "error", | ||
| 1005 | message: res.msg, | ||
| 1006 | }); | ||
| 1007 | } | ||
| 1008 | formTable.value.tableInfo.loading = false | ||
| 1009 | drawerInfo.value.loading = false; | ||
| 1010 | }).catch(() => { | ||
| 1011 | formTable.value.tableInfo.loading = false | ||
| 1012 | drawerInfo.value.loading = false; | ||
| 1013 | }) | ||
| 1014 | } else if (type == 'remove') { | ||
| 1015 | const rowIndex = scope.$index | ||
| 1016 | if (formItems.value.length == 2) { | ||
| 1017 | uploadTableData.value.splice(rowIndex, 1) | ||
| 1018 | } else { | ||
| 1019 | if (row.guid !== undefined) { | ||
| 1020 | formTable.value.tableInfo.loading = true | ||
| 1021 | checkDelete().then((res: any) => { | ||
| 1022 | if (res) { | ||
| 1023 | ElMessageBox.confirm("数据字典有数据, 确定是否继续删除?", "提示", { | ||
| 1024 | confirmButtonText: "确定", | ||
| 1025 | cancelButtonText: "取消", | ||
| 1026 | type: 'warning', | ||
| 1027 | }).then(() => { | ||
| 1028 | formTableData.value.splice(rowIndex, 1) | ||
| 1029 | }) | ||
| 1030 | } else { | ||
| 1031 | formTableData.value.splice(rowIndex, 1) | ||
| 1032 | } | ||
| 1033 | formTable.value.tableInfo.loading = false | ||
| 1034 | }).catch(xhr => { | ||
| 1035 | ElMessage({ | ||
| 1036 | type: 'error', | ||
| 1037 | message: xhr | ||
| 1038 | }) | ||
| 1039 | formTable.value.tableInfo.loading = false | ||
| 1040 | }) | ||
| 1041 | } else { | ||
| 1042 | formTableData.value.splice(rowIndex, 1) | ||
| 1043 | } | ||
| 1044 | } | ||
| 1045 | } else if (type == "delete") { | ||
| 1046 | currTableData.value = row; | ||
| 1047 | tableInfo.value.loading = true | ||
| 1048 | checkDelete().then((res: any) => { | ||
| 1049 | if (res.used) { | ||
| 1050 | ElMessage({ | ||
| 1051 | type: 'error', | ||
| 1052 | message: '数据字典被引用,请解除引用关系后再删除' | ||
| 1053 | }) | ||
| 1054 | } else { | ||
| 1055 | const unused = res.data.filter(item => item.have.length > 0) | ||
| 1056 | if (unused.length) { | ||
| 1057 | open("数据字典有数据, 确定是否继续删除?", "warning"); | ||
| 1058 | } else { | ||
| 1059 | open("此操作将永久删除, 是否继续?", "warning"); | ||
| 1060 | } | ||
| 1061 | } | ||
| 1062 | tableInfo.value.loading = false | ||
| 1063 | }).catch(xhr => { | ||
| 1064 | ElMessage({ | ||
| 1065 | type: 'error', | ||
| 1066 | message: xhr | ||
| 1067 | }) | ||
| 1068 | tableInfo.value.loading = false | ||
| 1069 | }) | ||
| 1070 | } | ||
| 1071 | }; | ||
| 1072 | |||
| 1073 | const checkDelete = (isBatch: any = false) => { | ||
| 1074 | if (drawerInfo.value.visible) { | ||
| 1075 | return new Promise((resolve, reject) => { | ||
| 1076 | let params: any = { | ||
| 1077 | guid: currTableData.value.guid | ||
| 1078 | } | ||
| 1079 | checkDeleteDictionaryScheme(params).then((res: any) => { | ||
| 1080 | if (res.code == proxy.$passCode) { | ||
| 1081 | const data = res.data | ||
| 1082 | resolve(data) | ||
| 1083 | } else { | ||
| 1084 | reject(res.msg) | ||
| 1085 | } | ||
| 1086 | }).catch((xhr: any) => { | ||
| 1087 | reject(xhr.msg) | ||
| 1088 | }) | ||
| 1089 | }) | ||
| 1090 | } else { | ||
| 1091 | return new Promise((resolve, reject) => { | ||
| 1092 | let guids = [currTableData.value.guid] | ||
| 1093 | if (isBatch) { | ||
| 1094 | guids = selectRowData.value | ||
| 1095 | } | ||
| 1096 | checkDeleteDictionary(guids).then((res: any) => { | ||
| 1097 | if (res.code == proxy.$passCode) { | ||
| 1098 | const data = res.data ?? {} | ||
| 1099 | if (data.used) { | ||
| 1100 | resolve({ | ||
| 1101 | used: true, | ||
| 1102 | data: data.used | ||
| 1103 | }) | ||
| 1104 | } else { | ||
| 1105 | resolve({ | ||
| 1106 | used: false, | ||
| 1107 | data: data.unuse | ||
| 1108 | }) | ||
| 1109 | } | ||
| 1110 | } else { | ||
| 1111 | reject(res.msg) | ||
| 1112 | } | ||
| 1113 | }).catch((xhr: any) => { | ||
| 1114 | reject(xhr.msg) | ||
| 1115 | }) | ||
| 1116 | }) | ||
| 1117 | } | ||
| 1118 | } | ||
| 1119 | |||
| 1120 | const open = (msg, type, isBatch = false) => { | ||
| 1121 | ElMessageBox.confirm(msg, "提示", { | ||
| 1122 | confirmButtonText: "确定", | ||
| 1123 | cancelButtonText: "取消", | ||
| 1124 | type: type, | ||
| 1125 | }).then(() => { | ||
| 1126 | let guids = [currTableData.value.guid] | ||
| 1127 | if (isBatch) { | ||
| 1128 | guids = selectRowData.value | ||
| 1129 | } | ||
| 1130 | tableInfo.value.loading = true | ||
| 1131 | deleteDictionary(guids).then((res: any) => { | ||
| 1132 | if (res.code == proxy.$passCode) { | ||
| 1133 | getTreeData(); | ||
| 1134 | ElMessage({ | ||
| 1135 | type: "success", | ||
| 1136 | message: "删除成功", | ||
| 1137 | }); | ||
| 1138 | } else { | ||
| 1139 | ElMessage({ | ||
| 1140 | type: "error", | ||
| 1141 | message: res.msg, | ||
| 1142 | }); | ||
| 1143 | } | ||
| 1144 | tableInfo.value.loading = false | ||
| 1145 | }).catch(() => { | ||
| 1146 | tableInfo.value.loading = false | ||
| 1147 | }); | ||
| 1148 | }); | ||
| 1149 | }; | ||
| 1150 | |||
| 1151 | const onUpload = (file, fileList) => { | ||
| 1152 | uploadFiles.value = fileList | ||
| 1153 | } | ||
| 1154 | |||
| 1155 | const uploadFile = (file) => { | ||
| 1156 | importData(file) | ||
| 1157 | } | ||
| 1158 | |||
| 1159 | const exportData = (type: any = null) => { | ||
| 1160 | if (type == 'model') { | ||
| 1161 | let params = { | ||
| 1162 | guid: dictGuid.value | ||
| 1163 | } | ||
| 1164 | if (drawerInfo.value.type == 'add') { | ||
| 1165 | params.guid = fieldSheetInfo.value.guid | ||
| 1166 | } | ||
| 1167 | exportDictionary(params).then((res: any) => { | ||
| 1168 | download(res, '数据字典模板.xlsx', 'excel') | ||
| 1169 | }); | ||
| 1170 | } else { | ||
| 1171 | let params = { | ||
| 1172 | guid: dictGuid.value | ||
| 1173 | } | ||
| 1174 | exportDictionaryFileds(params).then((res: any) => { | ||
| 1175 | download(res, '字典数据.xlsx', 'excel') | ||
| 1176 | }); | ||
| 1177 | } | ||
| 1178 | } | ||
| 1179 | |||
| 1180 | const importData = (file: any = null) => { | ||
| 1181 | let params = new FormData() | ||
| 1182 | if (file) { | ||
| 1183 | params.append("file", file.raw); | ||
| 1184 | } else { | ||
| 1185 | if (uploadFiles.value.length) { | ||
| 1186 | uploadFiles.value.forEach((item: any, index: number) => { | ||
| 1187 | params.append("file", item.raw); | ||
| 1188 | }); | ||
| 1189 | } | ||
| 1190 | } | ||
| 1191 | |||
| 1192 | params.append("dictionaryGuid", fieldSheetInfo.value.guid); | ||
| 1193 | showDictionary(params).then((res: any) => { | ||
| 1194 | if (res.code == proxy.$passCode) { | ||
| 1195 | let data = res.data ?? [] | ||
| 1196 | setUploadDataInfo(data) | ||
| 1197 | } else { | ||
| 1198 | ElMessage({ | ||
| 1199 | type: "error", | ||
| 1200 | message: res.msg, | ||
| 1201 | }); | ||
| 1202 | } | ||
| 1203 | }) | ||
| 1204 | } | ||
| 1205 | |||
| 1206 | // 生成表头 | ||
| 1207 | const setUploadDataFields = (data) => { | ||
| 1208 | let fields: any = [], editInfo: any = {} | ||
| 1209 | data.map(item => { | ||
| 1210 | let fieldItem: any = { | ||
| 1211 | label: item.description, field: item.fieldName, width: 140 | ||
| 1212 | } | ||
| 1213 | if (drawerInfo.value.type != 'detail') { | ||
| 1214 | fieldItem.type = 'edit' | ||
| 1215 | fieldItem.columClass = 'edit-colum' | ||
| 1216 | editInfo[item.fieldName] = { | ||
| 1217 | label: '', | ||
| 1218 | type: 'input', | ||
| 1219 | placeholder: '', | ||
| 1220 | field: item.fieldName, | ||
| 1221 | default: '', | ||
| 1222 | disabled: item.codeRuleGuid ? true : false, | ||
| 1223 | clearable: true, | ||
| 1224 | } | ||
| 1225 | } | ||
| 1226 | fields.push(fieldItem) | ||
| 1227 | }) | ||
| 1228 | uploadTableFields.value = fields | ||
| 1229 | if (drawerInfo.value.type == 'detail') { | ||
| 1230 | fieldTableInfo.value.tableInfo.fields = uploadTableFields.value | ||
| 1231 | } else { | ||
| 1232 | uploadTableInfo.value.fields = uploadTableFields.value | ||
| 1233 | uploadTableInfo.value.editInfo = editInfo | ||
| 1234 | } | ||
| 1235 | } | ||
| 1236 | |||
| 1237 | // 生成表数据 | ||
| 1238 | const setUploadDataInfo = async (info) => { | ||
| 1239 | let data = info | ||
| 1240 | if (drawerInfo.value.type == 'detail') { | ||
| 1241 | data = info.jsonArray ?? [] | ||
| 1242 | const fields = info.schemaDataVOS ?? [] | ||
| 1243 | setUploadDataFields(fields) | ||
| 1244 | } | ||
| 1245 | |||
| 1246 | if (drawerInfo.value.type == 'detail') { | ||
| 1247 | fieldTableInfo.value.tableInfo.data = data | ||
| 1248 | drawerInfo.value.container.contents = contents.value['field'] | ||
| 1249 | } else { | ||
| 1250 | // 设置表数据 | ||
| 1251 | data.map((item, i) => { | ||
| 1252 | item.STATUS = 'edit' | ||
| 1253 | item.STATE = 'Running' | ||
| 1254 | item.ROWID = `upload_${i}` | ||
| 1255 | }) | ||
| 1256 | uploadTableData.value = data | ||
| 1257 | uploadTableInfo.value.data = uploadTableData.value | ||
| 1258 | } | ||
| 1259 | } | ||
| 1260 | |||
| 1261 | const loadDrawer = async () => { | ||
| 1262 | drawerInfo.value.header.title = '新增数据字典' | ||
| 1263 | drawerInfo.value.type = 'add' | ||
| 1264 | drawerInfo.value.modalClass = ''; | ||
| 1265 | await setFormItems() | ||
| 1266 | let fields = JSON.parse(JSON.stringify(orginFields)) | ||
| 1267 | fields.map((item: any) => { | ||
| 1268 | if (!item.type || item.type != 'index') { | ||
| 1269 | item.type = 'edit' | ||
| 1270 | item.columClass = 'edit-colum' | ||
| 1271 | } | ||
| 1272 | }) | ||
| 1273 | formTable.value.tableInfo.fields = fields | ||
| 1274 | formInfo.value.formInfo.items = formItems.value | ||
| 1275 | formTableData.value = JSON.parse(JSON.stringify(orginData)) | ||
| 1276 | formTable.value.tableInfo.data = formTableData.value | ||
| 1277 | formTable.value.tableInfo.editInfo = JSON.parse(JSON.stringify(editTableInfo.value)) | ||
| 1278 | formTable.value.tableInfo.readonly = false | ||
| 1279 | formTable.value.tableInfo.multiple = true | ||
| 1280 | formTable.value.tableInfo.actionInfo.show = true | ||
| 1281 | formTable.value.tableTool.visible = true | ||
| 1282 | drawerInfo.value.container.contents = contents.value['add'] | ||
| 1283 | drawerInfo.value.footer.btns.at(1).visible = true | ||
| 1284 | drawerInfo.value.footer.btns.at(-1).visible = true | ||
| 1285 | drawerInfo.value.footer.btns.at(-2).visible = false | ||
| 1286 | drawerInfo.value.footer.btns.at(-3).visible = false | ||
| 1287 | drawerInfo.value.visible = true | ||
| 1288 | }; | ||
| 1289 | |||
| 1290 | const batching = (type) => { | ||
| 1291 | if (type == 'delete') { | ||
| 1292 | if (selectRowData.value.length == 0) { | ||
| 1293 | ElMessage({ | ||
| 1294 | type: 'error', | ||
| 1295 | message: '请选择需要删除的数据', | ||
| 1296 | }) | ||
| 1297 | return | ||
| 1298 | } | ||
| 1299 | tableInfo.value.loading = true | ||
| 1300 | checkDelete().then((res: any) => { | ||
| 1301 | if (res.used) { | ||
| 1302 | ElMessage({ | ||
| 1303 | type: 'error', | ||
| 1304 | message: '数据字典被引用,请解除引用关系后再删除' | ||
| 1305 | }) | ||
| 1306 | } else { | ||
| 1307 | const unused = res.data.filter(item => !item.have || item.have.length == 0) | ||
| 1308 | if (unused.length) { | ||
| 1309 | open("数据字典有数据, 确定是否继续删除?", "warning", true); | ||
| 1310 | } else { | ||
| 1311 | open("此操作将永久删除, 是否继续?", "warning", true); | ||
| 1312 | } | ||
| 1313 | } | ||
| 1314 | tableInfo.value.loading = false | ||
| 1315 | }).catch(xhr => { | ||
| 1316 | ElMessage({ | ||
| 1317 | type: 'error', | ||
| 1318 | message: xhr | ||
| 1319 | }) | ||
| 1320 | tableInfo.value.loading = false | ||
| 1321 | }) | ||
| 1322 | } | ||
| 1323 | }; | ||
| 1324 | |||
| 1325 | const nodeClick = (data) => { | ||
| 1326 | drawerInfo.value.visible = false | ||
| 1327 | const changeCont = () => { | ||
| 1328 | dictGuid.value = data.guid | ||
| 1329 | const info = { | ||
| 1330 | type: 'dictionary', | ||
| 1331 | dictionaryGuid: dictGuid.value | ||
| 1332 | } | ||
| 1333 | cacheStore.setCatch('uploadSetting', info) | ||
| 1334 | if (data.type == 1) { | ||
| 1335 | showFiledsPage.value = false | ||
| 1336 | dictType.value = Number(data.dictionaryType) | ||
| 1337 | } else { | ||
| 1338 | showFiledsPage.value = true | ||
| 1339 | nextTick(() => { | ||
| 1340 | dictFiledsRef.value.dictionaryGuid = dictGuid.value | ||
| 1341 | dictFiledsRef.value.getFirstPageData() | ||
| 1342 | }) | ||
| 1343 | } | ||
| 1344 | nextTick(() => { | ||
| 1345 | treeInfo.value.currentNodeKey = dictGuid.value | ||
| 1346 | }) | ||
| 1347 | } | ||
| 1348 | if (showFiledsPage.value) { | ||
| 1349 | const toChange = dictFiledsRef.value.checkSave() | ||
| 1350 | if (!toChange) { | ||
| 1351 | ElMessageBox.confirm( | ||
| 1352 | '存在未保存的数据,切换后会丢失,是否确定切换', | ||
| 1353 | '提示', | ||
| 1354 | { | ||
| 1355 | confirmButtonText: '确定', | ||
| 1356 | cancelButtonText: '取消', | ||
| 1357 | type: 'warning', | ||
| 1358 | } | ||
| 1359 | ).then(() => { | ||
| 1360 | changeCont() | ||
| 1361 | }).catch(() => { | ||
| 1362 | treeInfo.value.currentNodeKey = dictGuid.value | ||
| 1363 | }) | ||
| 1364 | } else { | ||
| 1365 | changeCont() | ||
| 1366 | } | ||
| 1367 | } else { | ||
| 1368 | changeCont() | ||
| 1369 | } | ||
| 1370 | } | ||
| 1371 | |||
| 1372 | // 设置详情信息 | ||
| 1373 | const setDetailInfo = () => { | ||
| 1374 | const row = JSON.parse(JSON.stringify(currTableData.value)) | ||
| 1375 | dictionaryType.value = row.dictionaryType | ||
| 1376 | setFormItems(row) | ||
| 1377 | let fields = JSON.parse(JSON.stringify(orginFields)) | ||
| 1378 | let schemaVOS = row.schemaVOS ?? [] | ||
| 1379 | setGroup() | ||
| 1380 | let list: any = [] | ||
| 1381 | schemaVOS.map((schema, s) => { | ||
| 1382 | list.push({ | ||
| 1383 | label: schema.fieldName, | ||
| 1384 | value: schema.fieldName | ||
| 1385 | }) | ||
| 1386 | schema.STATUS = 'edit' | ||
| 1387 | schema.STATE = 'Running' | ||
| 1388 | schema.ROWID = `formData_${s}` | ||
| 1389 | }) | ||
| 1390 | formItems.value.at(-1).children.map(child => { | ||
| 1391 | if (child.type == 'select') { | ||
| 1392 | child.options = list | ||
| 1393 | child.default = row[child.field] | ||
| 1394 | child.clearable = drawerInfo.value.type == 'detail' ? false : true | ||
| 1395 | } | ||
| 1396 | }) | ||
| 1397 | fields.map((item: any) => { | ||
| 1398 | if (!item.type || item.type != 'index') { | ||
| 1399 | item.type = 'edit' | ||
| 1400 | item.columClass = 'edit-colum' | ||
| 1401 | } | ||
| 1402 | }) | ||
| 1403 | for (var key in editTableInfo.value) { | ||
| 1404 | editTableInfo.value[key].clearable = drawerInfo.value.type == 'detail' ? false : true | ||
| 1405 | } | ||
| 1406 | |||
| 1407 | let editInfo = JSON.parse(JSON.stringify(editTableInfo.value)) | ||
| 1408 | if (drawerInfo.value.type == 'edit') { | ||
| 1409 | for (var e in editInfo) { | ||
| 1410 | if (e == 'description' || e == 'fieldType' || e == 'fieldLength' || e == 'fieldPrecision') { | ||
| 1411 | editInfo[e].disabled = true | ||
| 1412 | } | ||
| 1413 | } | ||
| 1414 | } | ||
| 1415 | |||
| 1416 | formInfo.value.formInfo.items = formItems.value | ||
| 1417 | formTableData.value = schemaVOS | ||
| 1418 | formTable.value.tableInfo.fields = fields | ||
| 1419 | formTable.value.tableInfo.data = formTableData.value | ||
| 1420 | formTable.value.tableInfo.readonly = drawerInfo.value.type == 'detail' | ||
| 1421 | formTable.value.tableInfo.editInfo = editInfo | ||
| 1422 | drawerInfo.value.container.contents = contents.value['add'] | ||
| 1423 | |||
| 1424 | drawerInfo.value.visible = true | ||
| 1425 | } | ||
| 1426 | |||
| 1427 | const checkParamsData = () => { | ||
| 1428 | let addJsonArray: any = [], upJsonArray: any = [], jsonArray: any = [], pass = true | ||
| 1429 | let passArr = uploadTableData.value | ||
| 1430 | passArr.map((item, index) => { | ||
| 1431 | const obj = JSON.parse(JSON.stringify(item)) | ||
| 1432 | delete obj.STATE | ||
| 1433 | delete obj.STATUS | ||
| 1434 | delete obj.NOTES | ||
| 1435 | delete obj.ROWID | ||
| 1436 | for (var i in obj) { | ||
| 1437 | if (obj[i] == '') { | ||
| 1438 | pass = false | ||
| 1439 | } | ||
| 1440 | } | ||
| 1441 | if (obj.guid !== undefined) { | ||
| 1442 | upJsonArray.push(obj) | ||
| 1443 | } else { | ||
| 1444 | addJsonArray.push(obj) | ||
| 1445 | } | ||
| 1446 | obj.index = index | ||
| 1447 | jsonArray.push(obj) | ||
| 1448 | }) | ||
| 1449 | return { pass, addJsonArray, upJsonArray, jsonArray } | ||
| 1450 | } | ||
| 1451 | |||
| 1452 | const saveData = async () => { | ||
| 1453 | const passInfo = await checkParamsData() | ||
| 1454 | const checkParams = { | ||
| 1455 | dictionaryGuid: fieldSheetInfo.value.guid, | ||
| 1456 | addJsonArray: passInfo.jsonArray | ||
| 1457 | } | ||
| 1458 | checkDictionaryData(checkParams).then((res: any) => { | ||
| 1459 | if (res.code == proxy.$passCode) { | ||
| 1460 | const data = res.data | ||
| 1461 | if (Object.keys(data).length) { | ||
| 1462 | addColumn(data) | ||
| 1463 | drawerInfo.value.footer.btns.map((item: any) => delete item.disabled) | ||
| 1464 | } else { | ||
| 1465 | addColumn() | ||
| 1466 | const params = { | ||
| 1467 | dictionaryGuid: fieldSheetInfo.value.guid, | ||
| 1468 | addJsonArray: passInfo.addJsonArray, | ||
| 1469 | upJsonArray: passInfo.upJsonArray | ||
| 1470 | } | ||
| 1471 | saveDictionaryData(params).then((res: any) => { | ||
| 1472 | if (res.code == proxy.$passCode) { | ||
| 1473 | showLoading.value = true | ||
| 1474 | getTreeData(); | ||
| 1475 | ElMessage({ | ||
| 1476 | type: 'success', | ||
| 1477 | message: '保存数据字典成功' | ||
| 1478 | }) | ||
| 1479 | drawerInfo.value.visible = false; | ||
| 1480 | } else { | ||
| 1481 | ElMessage({ | ||
| 1482 | type: 'error', | ||
| 1483 | message: res.msg, | ||
| 1484 | }) | ||
| 1485 | drawerInfo.value.footer.btns.map((item: any) => delete item.disabled) | ||
| 1486 | } | ||
| 1487 | }).catch(() => { | ||
| 1488 | drawerInfo.value.footer.btns.map((item: any) => delete item.disabled) | ||
| 1489 | }) | ||
| 1490 | } | ||
| 1491 | } else { | ||
| 1492 | ElMessage({ | ||
| 1493 | type: 'error', | ||
| 1494 | message: res.msg, | ||
| 1495 | }) | ||
| 1496 | drawerInfo.value.footer.btns.map((item: any) => delete item.disabled) | ||
| 1497 | } | ||
| 1498 | }).catch(() => { | ||
| 1499 | drawerInfo.value.footer.btns.map((item: any) => delete item.disabled) | ||
| 1500 | }) | ||
| 1501 | } | ||
| 1502 | |||
| 1503 | const addColumn = (info: any = null) => { | ||
| 1504 | const fields = uploadTableFields.value | ||
| 1505 | const existIndex = fields.findIndex(item => item.field == 'NOTES') | ||
| 1506 | if (info) { | ||
| 1507 | if (existIndex == -1) { | ||
| 1508 | fields.push({ | ||
| 1509 | label: '备注', | ||
| 1510 | field: 'NOTES', | ||
| 1511 | width: 276 | ||
| 1512 | }) | ||
| 1513 | } | ||
| 1514 | for (var d in info) { | ||
| 1515 | uploadTableData.value[d].NOTES = info[d].join(',') | ||
| 1516 | } | ||
| 1517 | } else { | ||
| 1518 | if (existIndex > -1) { | ||
| 1519 | fields.splice(existIndex, 1) | ||
| 1520 | } | ||
| 1521 | } | ||
| 1522 | } | ||
| 1523 | |||
| 1524 | const scrollTable = (rowInfo) => { | ||
| 1525 | nextTick(() => { | ||
| 1526 | const drawerBody = document.getElementsByClassName('el-drawer__body')[0]; | ||
| 1527 | const tableListRef = drawerRef.value.getDrawerConRef("drawerTableRef"); | ||
| 1528 | if (!tableListRef) return; | ||
| 1529 | //设置选中表格当前新增行。 | ||
| 1530 | tableListRef.setCurrentRow(rowInfo); | ||
| 1531 | drawerBody.scrollTop = drawerBody.scrollHeight; | ||
| 1532 | let table = tableListRef.layout.table.refs; | ||
| 1533 | // 获取表格滚动元素 | ||
| 1534 | let tableScrollEle = | ||
| 1535 | table.bodyWrapper.firstElementChild.firstElementChild; | ||
| 1536 | // 设置表格滚动的位置 | ||
| 1537 | tableScrollEle.scrollTop = tableScrollEle.scrollHeight; | ||
| 1538 | }); | ||
| 1539 | }; | ||
| 1540 | |||
| 1541 | const drawerBtnClick = (btn, info) => { | ||
| 1542 | if (btn.value == 'submit' || btn.value == 'saveAndAdd') { | ||
| 1543 | drawerInfo.value.footer.btns.map((item: any) => item.disabled = true) | ||
| 1544 | if (formItems.value.length == 2) { | ||
| 1545 | if (drawerInfo.value.type == 'add') { | ||
| 1546 | saveData() | ||
| 1547 | } | ||
| 1548 | } else { | ||
| 1549 | if (drawerInfo.value.type == 'edit' && btn.value == 'saveAndAdd') { | ||
| 1550 | nodeClick(currTableData.value) | ||
| 1551 | drawerInfo.value.visible = false | ||
| 1552 | return | ||
| 1553 | } | ||
| 1554 | let params = { ...info } | ||
| 1555 | let dtos: any = [] | ||
| 1556 | if (formTableData.value.length == 0) { | ||
| 1557 | ElMessage({ | ||
| 1558 | type: 'error', | ||
| 1559 | message: '表结构至少需要一条数据', | ||
| 1560 | }) | ||
| 1561 | drawerInfo.value.footer.btns.map((item: any) => delete item.disabled) | ||
| 1562 | return | ||
| 1563 | } | ||
| 1564 | formTableData.value.map((item, i) => { | ||
| 1565 | const dto = { ...item } | ||
| 1566 | delete dto.STATE | ||
| 1567 | delete dto.STATUS | ||
| 1568 | delete dto.ROWID | ||
| 1569 | delete dto.NOTES | ||
| 1570 | dto.orderNum = i | ||
| 1571 | dtos.push(dto) | ||
| 1572 | }) | ||
| 1573 | params.dataDictionarySchemaAddDTOS = dtos | ||
| 1574 | if (drawerInfo.value.type == 'add') { | ||
| 1575 | formTable.value.tableInfo.loading = true | ||
| 1576 | addDictionary(params).then((res: any) => { | ||
| 1577 | if (res.code == proxy.$passCode) { | ||
| 1578 | ElMessage({ | ||
| 1579 | type: 'success', | ||
| 1580 | message: '添加数据字典成功' | ||
| 1581 | }) | ||
| 1582 | drawerInfo.value.visible = false; | ||
| 1583 | getTreeData(btn.value == 'saveAndAdd', res.data || {}); | ||
| 1584 | } else { | ||
| 1585 | ElMessage({ | ||
| 1586 | type: 'error', | ||
| 1587 | message: res.msg, | ||
| 1588 | }) | ||
| 1589 | drawerInfo.value.footer.btns.map((item: any) => delete item.disabled) | ||
| 1590 | } | ||
| 1591 | formTable.value.tableInfo.loading = false | ||
| 1592 | }).catch(() => { | ||
| 1593 | drawerInfo.value.footer.btns.map((item: any) => delete item.disabled) | ||
| 1594 | formTable.value.tableInfo.loading = false | ||
| 1595 | }) | ||
| 1596 | } else { | ||
| 1597 | params.guid = currTableData.value.guid | ||
| 1598 | updateDictionary(params).then((res: any) => { | ||
| 1599 | if (res.code == proxy.$passCode) { | ||
| 1600 | if (btn.value == 'saveAndAdd') { | ||
| 1601 | showLoading.value = false | ||
| 1602 | drawerInfo.value.container.id = 'upload-table-form' | ||
| 1603 | drawerInfo.value.footer.btns.at(-1).visible = false | ||
| 1604 | drawerInfo.value.footer.btns.map((item: any) => delete item.disabled) | ||
| 1605 | getDictionaryDataDetail(currTableData.value.guid) | ||
| 1606 | } else { | ||
| 1607 | getTreeData(); | ||
| 1608 | ElMessage({ | ||
| 1609 | type: 'success', | ||
| 1610 | message: '修改数据字典成功' | ||
| 1611 | }) | ||
| 1612 | drawerInfo.value.visible = false; | ||
| 1613 | } | ||
| 1614 | } else { | ||
| 1615 | ElMessage({ | ||
| 1616 | type: 'error', | ||
| 1617 | message: res.msg, | ||
| 1618 | }) | ||
| 1619 | drawerInfo.value.footer.btns.map((item: any) => delete item.disabled) | ||
| 1620 | } | ||
| 1621 | }).catch(() => { | ||
| 1622 | drawerInfo.value.footer.btns.map((item: any) => delete item.disabled) | ||
| 1623 | }) | ||
| 1624 | } | ||
| 1625 | } | ||
| 1626 | } else if (btn.value == 'fileds') { | ||
| 1627 | drawerInfo.value.footer.btns.at(-2).visible = true | ||
| 1628 | drawerInfo.value.footer.btns.at(-3).visible = false | ||
| 1629 | formItems.value.map(item => { | ||
| 1630 | if (item.field != 'chName' && item.field != 'enName') { | ||
| 1631 | item.visible = false | ||
| 1632 | } | ||
| 1633 | }) | ||
| 1634 | if (currTableData.value.detailInfo == null) { | ||
| 1635 | getTableFiled() | ||
| 1636 | } else { | ||
| 1637 | drawerInfo.value.container.contents = contents.value['field'] | ||
| 1638 | } | ||
| 1639 | } else if (btn.value == 'sheet') { | ||
| 1640 | formItems.value.map(item => { | ||
| 1641 | item.visible = true | ||
| 1642 | }) | ||
| 1643 | drawerInfo.value.container.contents = contents.value['add'] | ||
| 1644 | drawerInfo.value.footer.btns.at(-2).visible = false | ||
| 1645 | drawerInfo.value.footer.btns.at(-3).visible = true | ||
| 1646 | } else { | ||
| 1647 | drawerInfo.value.footer.btns.map((item: any) => delete item.disabled) | ||
| 1648 | nextTick(() => { | ||
| 1649 | drawerInfo.value.visible = false | ||
| 1650 | }) | ||
| 1651 | } | ||
| 1652 | } | ||
| 1653 | |||
| 1654 | const getTableFiled = () => { | ||
| 1655 | const guid = currTableData.value.guid; | ||
| 1656 | fieldTableInfo.value.tableInfo.loading = true; | ||
| 1657 | drawerInfo.value.container.contents = contents.value['field'] | ||
| 1658 | getDictionaryFileds(guid).then((res: any) => { | ||
| 1659 | fieldTableInfo.value.tableInfo.loading = false; | ||
| 1660 | if (res.code == proxy.$passCode) { | ||
| 1661 | const data = res.data ?? {} | ||
| 1662 | currTableData.value.detailInfo = data | ||
| 1663 | setUploadDataInfo(data) | ||
| 1664 | } else { | ||
| 1665 | ElMessage({ | ||
| 1666 | type: 'error', | ||
| 1667 | message: res.msg, | ||
| 1668 | }) | ||
| 1669 | } | ||
| 1670 | }).catch(() => { | ||
| 1671 | fieldTableInfo.value.tableInfo.loading = false; | ||
| 1672 | }) | ||
| 1673 | } | ||
| 1674 | |||
| 1675 | const getDictionaryDataDetail = (params) => { | ||
| 1676 | uploadTableInfo.value.loading = true | ||
| 1677 | getDictionaryFileds(params).then((res: any) => { | ||
| 1678 | if (res.code == proxy.$passCode) { | ||
| 1679 | const data = res.data ?? {} | ||
| 1680 | setContents(data) | ||
| 1681 | } else { | ||
| 1682 | ElMessage({ | ||
| 1683 | type: 'error', | ||
| 1684 | message: res.msg, | ||
| 1685 | }) | ||
| 1686 | } | ||
| 1687 | uploadTableInfo.value.loading = false | ||
| 1688 | }).catch(xhr => { | ||
| 1689 | uploadTableInfo.value.loading = false | ||
| 1690 | }) | ||
| 1691 | } | ||
| 1692 | |||
| 1693 | // 设置添加数据面板信息 | ||
| 1694 | const setContents = async (info) => { | ||
| 1695 | formItems.value.splice(2) | ||
| 1696 | formItems.value.map(item => { | ||
| 1697 | item.default = fieldSheetInfo.value[item.field] | ||
| 1698 | item.disabled = true | ||
| 1699 | }) | ||
| 1700 | const fields = info.schemaDataVOS ?? [] | ||
| 1701 | await setUploadDataFields(fields) | ||
| 1702 | uploadTableData.value = [] | ||
| 1703 | uploadTableInfo.value.data = [] | ||
| 1704 | uploadInfo.value.tableInfo = uploadTableInfo.value | ||
| 1705 | drawerInfo.value.container.contents = contents.value['upload'] | ||
| 1706 | } | ||
| 1707 | |||
| 1708 | const radioGroupChange = async (val, info) => { | ||
| 1709 | dictionaryType.value = Number(val) | ||
| 1710 | await setFormItems(info) | ||
| 1711 | setGroup() | ||
| 1712 | } | ||
| 1713 | |||
| 1714 | // 切换结构类型 设置选项显隐 | ||
| 1715 | const setGroup = () => { | ||
| 1716 | let dictionaryOpts = formItems.value.at(-1).children | ||
| 1717 | if (dictionaryType.value == 1) { | ||
| 1718 | dictionaryOpts[2].visible = false | ||
| 1719 | dictionaryOpts[3].visible = false | ||
| 1720 | } else if (dictionaryType.value == 2) { | ||
| 1721 | dictionaryOpts[2].visible = false | ||
| 1722 | dictionaryOpts[3].block = false | ||
| 1723 | dictionaryOpts[3].visible = true | ||
| 1724 | } else if (dictionaryType.value == 3) { | ||
| 1725 | dictionaryOpts[2].visible = true | ||
| 1726 | dictionaryOpts[3].block = true | ||
| 1727 | dictionaryOpts[3].visible = true | ||
| 1728 | } else if (dictionaryType.value == 4) { | ||
| 1729 | dictionaryOpts[2].visible = false | ||
| 1730 | dictionaryOpts[3].block = true | ||
| 1731 | dictionaryOpts[3].visible = true | ||
| 1732 | } | ||
| 1733 | formInfo.value.formInfo.items = formItems.value | ||
| 1734 | } | ||
| 1735 | |||
| 1736 | onActivated(() => { | ||
| 1737 | getCodeRuleData(); | ||
| 1738 | let guid = cacheStore.getCatch('dictionaryGuid'); | ||
| 1739 | if (guid) { | ||
| 1740 | nextTick(() => { | ||
| 1741 | if (treePromise.value) { | ||
| 1742 | treePromise.value.then(() => { | ||
| 1743 | nodeClick({ guid: guid, dictionaryType: '1', type: 2 }); | ||
| 1744 | cacheStore.setCatch('dictionaryGuid', null); | ||
| 1745 | }); | ||
| 1746 | } else { | ||
| 1747 | nodeClick({ guid: guid, type: 1 }); | ||
| 1748 | cacheStore.setCatch('dictionaryGuid', null); | ||
| 1749 | } | ||
| 1750 | }); | ||
| 1751 | } | ||
| 1752 | }) | ||
| 1753 | |||
| 1754 | onBeforeMount(() => { | ||
| 1755 | getDataType('DATA_TYPE') | ||
| 1756 | getTreeData() | ||
| 1757 | }) | ||
| 1758 | |||
| 1759 | onMounted(() => { | ||
| 1760 | let dom = document.getElementById('main-app'); | ||
| 1761 | if (dom) { | ||
| 1762 | dom.addEventListener('click', (event: any) => { | ||
| 1763 | // 新建时不要处理。 | ||
| 1764 | if (drawerInfo.value.header.title == '数据字典详情' && !event.target?.classList?.contains('drawer-detail-cell')) { | ||
| 1765 | if (drawerInfo.value.visible) { | ||
| 1766 | drawerInfo.value.visible = false; | ||
| 1767 | } | ||
| 1768 | } | ||
| 1769 | }); | ||
| 1770 | } | ||
| 1771 | }); | ||
| 1772 | |||
| 1773 | </script> | ||
| 1774 | |||
| 1775 | <template> | ||
| 1776 | <div class="container_wrap full flex"> | ||
| 1777 | <div class="aside_wrap"> | ||
| 1778 | <div class="aside_title">数据字典列表</div> | ||
| 1779 | <Tree ref="dictTreeRef" :treeInfo="treeInfo" @nodeClick="nodeClick" /> | ||
| 1780 | </div> | ||
| 1781 | <DictFileds ref="dictFiledsRef" v-if="showFiledsPage" @exportData="exportData" /> | ||
| 1782 | <div class="main_wrap" v-else> | ||
| 1783 | <div class="table_tool_wrap"> | ||
| 1784 | <div class="tools_btns"> | ||
| 1785 | <el-button type="primary" @click="loadDrawer" v-preReClick>新建</el-button> | ||
| 1786 | <el-button @click="batching('delete')" v-preReClick>批量删除</el-button> | ||
| 1787 | </div> | ||
| 1788 | <el-input class="table_search_input" v-model.trim="tableSearchInput" placeholder="请输入字典中/英文名搜索" | ||
| 1789 | :suffix-icon="Search" clearable @change="val => getFirstPageData()" /> | ||
| 1790 | </div> | ||
| 1791 | <div class="table_panel_wrap full"> | ||
| 1792 | <Table :tableInfo="tableInfo" @tableBtnClick="tableBtnClick" @tableSelectionChange="tableSelectionChange" | ||
| 1793 | @tablePageChange="tablePageChange" @tableSwitchBeforeChange="tableSwitchBeforeChange" /> | ||
| 1794 | </div> | ||
| 1795 | </div> | ||
| 1796 | <Drawer ref="drawerRef" :drawerInfo="drawerInfo" @drawerBtnClick="drawerBtnClick" | ||
| 1797 | @radioGroupChange="radioGroupChange" @drawerTableBtnClick="tableBtnClick" | ||
| 1798 | @drawerTableSelectionChange="tableSelectionChange" @drawerTableToolBtnClick="toolBtnClick" | ||
| 1799 | @drawerTableInputChange="tableInputChange" @drawerToolBtnClick="toolBtnClick" @onUpload="onUpload" | ||
| 1800 | @uploadFile="uploadFile" @uploadBtnClick="toolBtnClick" /> | ||
| 1801 | </div> | ||
| 1802 | </template> | ||
| 1803 | |||
| 1804 | <style lang="scss" scoped> | ||
| 1805 | .container_wrap { | ||
| 1806 | .aside_wrap { | ||
| 1807 | width: 200px; | ||
| 1808 | } | ||
| 1809 | } | ||
| 1810 | |||
| 1811 | .tree_panel { | ||
| 1812 | height: 100%; | ||
| 1813 | padding-top: 0; | ||
| 1814 | |||
| 1815 | :deep(.el-tree) { | ||
| 1816 | margin: 0; | ||
| 1817 | height: calc(100% - 68px); | ||
| 1818 | overflow: hidden auto; | ||
| 1819 | } | ||
| 1820 | } | ||
| 1821 | </style> |
| ... | @@ -4,14 +4,14 @@ | ... | @@ -4,14 +4,14 @@ |
| 4 | 4 | ||
| 5 | <script lang="ts" setup name="importFile"> | 5 | <script lang="ts" setup name="importFile"> |
| 6 | import { ref } from "vue"; | 6 | import { ref } from "vue"; |
| 7 | import { useRoute,useRouter } from "vue-router" | 7 | import { useRoute, useRouter } from "vue-router" |
| 8 | import useUserStore from "@/store/modules/user"; | 8 | import useUserStore from "@/store/modules/user"; |
| 9 | import { ElMessage, ElMessageBox } from "element-plus"; | 9 | import { ElMessage, ElMessageBox } from "element-plus"; |
| 10 | import Tabs from '@/components/Tabs/index.vue' | 10 | import Tabs from '@/components/Tabs/index.vue' |
| 11 | import Table from '@/components/Table/index.vue' | 11 | import Table from '@/components/Table/index.vue' |
| 12 | import Dialog from '@/components/Dialog/index.vue' | 12 | import Dialog from '@/components/Dialog/index.vue' |
| 13 | import useCatchStore from "@/store/modules/catch"; | 13 | import useCatchStore from "@/store/modules/catch"; |
| 14 | import { download, downFile,getDownloadUrl } from '@/utils/common' | 14 | import { download, downFile, getDownloadUrl } from '@/utils/common' |
| 15 | import { | 15 | import { |
| 16 | addImportData, | 16 | addImportData, |
| 17 | deleteImportData, | 17 | deleteImportData, |
| ... | @@ -45,15 +45,15 @@ const defaulttabs = [ | ... | @@ -45,15 +45,15 @@ const defaulttabs = [ |
| 45 | { label: '数据字典导入', name: 'dictionary' }, | 45 | { label: '数据字典导入', name: 'dictionary' }, |
| 46 | // { label: '质量模型导入', name: 'qualityModelGroup' }, | 46 | // { label: '质量模型导入', name: 'qualityModelGroup' }, |
| 47 | // { label: '质量规则导入', name: 'qualityRule' }, | 47 | // { label: '质量规则导入', name: 'qualityRule' }, |
| 48 | ] | 48 | ] |
| 49 | const importTabs = [ | 49 | const importTabs = [ |
| 50 | { label: '导入文件数据', name: 'importFile' }, | 50 | { label: '导入文件数据', name: 'importFile' }, |
| 51 | // { label: '质量模型导入', name: 'qualityModelGroup' }, | 51 | // { label: '质量模型导入', name: 'qualityModelGroup' }, |
| 52 | // { label: '质量规则导入', name: 'qualityRule' }, | 52 | // { label: '质量规则导入', name: 'qualityRule' }, |
| 53 | ] | 53 | ] |
| 54 | const tabsInfo = ref({ | 54 | const tabsInfo = ref({ |
| 55 | activeName: '', | 55 | activeName: '', |
| 56 | tabs: isfileImport?importTabs:defaulttabs | 56 | tabs: isfileImport ? importTabs : defaulttabs |
| 57 | }) | 57 | }) |
| 58 | 58 | ||
| 59 | const currTableData: any = ref<Object>({}); | 59 | const currTableData: any = ref<Object>({}); |
| ... | @@ -232,7 +232,7 @@ const tableBtnClick = async (scope, btn) => { | ... | @@ -232,7 +232,7 @@ const tableBtnClick = async (scope, btn) => { |
| 232 | if (res && !res.msg) { | 232 | if (res && !res.msg) { |
| 233 | let name = row.errorFilePath; | 233 | let name = row.errorFilePath; |
| 234 | var fileSuffix = name ? name.substring(name.lastIndexOf('.') + 1) : ''; | 234 | var fileSuffix = name ? name.substring(name.lastIndexOf('.') + 1) : ''; |
| 235 | let fileName = name ? name.substring(name.lastIndexOf('/') + 1) :'' | 235 | let fileName = name ? name.substring(name.lastIndexOf('/') + 1) : '' |
| 236 | download(res, fileName, fileSuffix); | 236 | download(res, fileName, fileSuffix); |
| 237 | } else { | 237 | } else { |
| 238 | res?.msg && ElMessage.error(res?.msg); | 238 | res?.msg && ElMessage.error(res?.msg); |
| ... | @@ -267,7 +267,7 @@ const batching = (type) => { | ... | @@ -267,7 +267,7 @@ const batching = (type) => { |
| 267 | return | 267 | return |
| 268 | } | 268 | } |
| 269 | open("此操作将永久删除, 是否继续?", "warning", true); | 269 | open("此操作将永久删除, 是否继续?", "warning", true); |
| 270 | } else if(type === 'importFile') { | 270 | } else if (type === 'importFile') { |
| 271 | if (isfileImport == '2' || isfileImport == '4') { | 271 | if (isfileImport == '2' || isfileImport == '4') { |
| 272 | dialogInfo.value.header.title = '导入数据' | 272 | dialogInfo.value.header.title = '导入数据' |
| 273 | dialogInfo.value.type = 'upload' | 273 | dialogInfo.value.type = 'upload' |
| ... | @@ -279,8 +279,8 @@ const batching = (type) => { | ... | @@ -279,8 +279,8 @@ const batching = (type) => { |
| 279 | dialogInfo.value.visible = true | 279 | dialogInfo.value.visible = true |
| 280 | } else { | 280 | } else { |
| 281 | router.push({ | 281 | router.push({ |
| 282 | name:"importData", | 282 | name: "importData", |
| 283 | query:route.query | 283 | query: route.query |
| 284 | }) | 284 | }) |
| 285 | } | 285 | } |
| 286 | } | 286 | } |
| ... | @@ -391,7 +391,7 @@ const importData = (info) => { | ... | @@ -391,7 +391,7 @@ const importData = (info) => { |
| 391 | uploadFiles.value.forEach((item: any, index: number) => { | 391 | uploadFiles.value.forEach((item: any, index: number) => { |
| 392 | params.append("uploadFile", item.raw); | 392 | params.append("uploadFile", item.raw); |
| 393 | }); | 393 | }); |
| 394 | paramUrl = `${import.meta.env.VITE_APP_PLAN_BASEURL}/meta-collect-task/meta-collect-import?staffGuid=${userData.staffGuid}&databaseNameZh=${info.databaseNameZh}&databaseNameEn=${info.databaseNameEn}&isCover=${info.isCover}` | 394 | paramUrl = `${import.meta.env.VITE_APP_CHECK_BASEURL}/meta-collect-task/meta-collect-import?staffGuid=${userData.staffGuid}&databaseNameZh=${info.databaseNameZh}&databaseNameEn=${info.databaseNameEn}&isCover=${info.isCover}` |
| 395 | } else { | 395 | } else { |
| 396 | uploadFiles.value.forEach((item: any, index: number) => { | 396 | uploadFiles.value.forEach((item: any, index: number) => { |
| 397 | params.append("file", item.raw); | 397 | params.append("file", item.raw); |
| ... | @@ -643,7 +643,7 @@ const setUploadInfo = () => { | ... | @@ -643,7 +643,7 @@ const setUploadInfo = () => { |
| 643 | 643 | ||
| 644 | onActivated(() => { | 644 | onActivated(() => { |
| 645 | uploadSetting.value = cacheStore.getCatch('uploadSetting') ?? {} | 645 | uploadSetting.value = cacheStore.getCatch('uploadSetting') ?? {} |
| 646 | if(isfileImport) { | 646 | if (isfileImport) { |
| 647 | tabsActiveName.value = 'importFile' | 647 | tabsActiveName.value = 'importFile' |
| 648 | } else { | 648 | } else { |
| 649 | tabsActiveName.value = uploadSetting.value?.type || 'standard' | 649 | tabsActiveName.value = uploadSetting.value?.type || 'standard' |
| ... | @@ -660,8 +660,10 @@ onActivated(() => { | ... | @@ -660,8 +660,10 @@ onActivated(() => { |
| 660 | <Tabs v-if="!isfileImport" :tabs-info="tabsInfo" @tabChange="tabsChange" /> | 660 | <Tabs v-if="!isfileImport" :tabs-info="tabsInfo" @tabChange="tabsChange" /> |
| 661 | <div class="table_tool_wrap"> | 661 | <div class="table_tool_wrap"> |
| 662 | <div class="tools_btns"> | 662 | <div class="tools_btns"> |
| 663 | <el-button type="primary" @click="batching('import')" v-if="tabsActiveName !== 'importFile'" v-preReClick>批量导入</el-button> | 663 | <el-button type="primary" @click="batching('import')" v-if="tabsActiveName !== 'importFile'" |
| 664 | <el-button type="primary" @click="batching('importFile')" v-if="tabsActiveName == 'importFile'" v-preReClick>文件导入</el-button> | 664 | v-preReClick>批量导入</el-button> |
| 665 | <el-button type="primary" @click="batching('importFile')" v-if="tabsActiveName == 'importFile'" | ||
| 666 | v-preReClick>文件导入</el-button> | ||
| 665 | <el-button @click="batching('delete')" v-preReClick>批量删除</el-button> | 667 | <el-button @click="batching('delete')" v-preReClick>批量删除</el-button> |
| 666 | <el-button @click="getFirstPageData" v-preReClick>刷新结果</el-button> | 668 | <el-button @click="getFirstPageData" v-preReClick>刷新结果</el-button> |
| 667 | </div> | 669 | </div> | ... | ... |
-
Please register or sign in to post a comment