diff --git a/.env.front b/.env.front new file mode 100644 index 00000000..2641417d --- /dev/null +++ b/.env.front @@ -0,0 +1,19 @@ +# 本地开发环境 +NODE_ENV=development + +VITE_DEV=true + +# 请求路径 +VITE_BASE_URL='http://api-dashboard.yudao.iocoder.cn' + +# 上传路径 +VITE_UPLOAD_URL='http://api-dashboard.yudao.iocoder.cn/admin-api/infra/file/upload' + +# 接口前缀 +VITE_API_BASEPATH=/dev-api + +# 接口地址 +VITE_API_URL=/admin-api + +# 打包路径 +VITE_BASE_PATH=/ diff --git a/.env.static b/.env.static new file mode 100644 index 00000000..034a7f4d --- /dev/null +++ b/.env.static @@ -0,0 +1,31 @@ +# 开发环境 +NODE_ENV=production + +VITE_DEV=false + +# 请求路径 +VITE_BASE_URL='http://localhost:48080' + +# 上传路径 +VITE_UPLOAD_URL='http://localhost:48080/admin-api/infra/file/upload' + +# 接口前缀 +VITE_API_BASEPATH= + +# 接口地址 +VITE_API_URL=/admin-api + +# 是否删除debugger +VITE_DROP_DEBUGGER=true + +# 是否删除console.log +VITE_DROP_CONSOLE=true + +# 是否sourcemap +VITE_SOURCEMAP=false + +# 打包路径 +VITE_BASE_PATH=/admin-ui-vue3/ + +# 输出路径 +VITE_OUT_DIR=dist-dev diff --git a/README.md b/README.md index 96bdd51b..b3e9cc78 100644 --- a/README.md +++ b/README.md @@ -36,16 +36,16 @@ | 框架 | 说明 | 版本 | |----------------------------------------------------------------------|------------------|--------| | [Vue](https://staging-cn.vuejs.org/) | Vue 框架 | 3.2.47 | -| [Vite](https://cn.vitejs.dev//) | 开发与构建工具 | 4.1.1 | -| [Element Plus](https://element-plus.org/zh-CN/) | Element Plus | 2.2.30 | +| [Vite](https://cn.vitejs.dev//) | 开发与构建工具 | 4.1.4 | +| [Element Plus](https://element-plus.org/zh-CN/) | Element Plus | 2.2.34 | | [TypeScript](https://www.typescriptlang.org/docs/) | JavaScript 的超集 | 4.9.5 | -| [pinia](https://pinia.vuejs.org/) | Vue 存储库 替代 vuex5 | 2.0.30 | -| [vueuse](https://vueuse.org/) | 常用工具集 | 9.12.0 | +| [pinia](https://pinia.vuejs.org/) | Vue 存储库 替代 vuex5 | 2.0.33 | +| [vueuse](https://vueuse.org/) | 常用工具集 | 9.13.0 | | [vxe-table](https://vxetable.cn/) | Vue 最强表单 | 4.3.10 | | [vue-i18n](https://kazupon.github.io/vue-i18n/zh/introduction.html/) | 国际化 | 9.2.2 | | [vue-router](https://router.vuejs.org/) | Vue 路由 | 4.1.6 | | [windicss](https://cn.windicss.org/) | 下一代工具优先的 CSS 框架 | 3.5.6 | -| [iconify](https://icon-sets.iconify.design/) | 在线图标库 | 3.0.1 | +| [iconify](https://icon-sets.iconify.design/) | 在线图标库 | 3.1.0 | | [wangeditor](https://www.wangeditor.com/) | 富文本编辑器 | 5.1.23 | ## 开发工具 diff --git a/build/vite/index.ts b/build/vite/index.ts index 717db992..304ce0d5 100644 --- a/build/vite/index.ts +++ b/build/vite/index.ts @@ -14,6 +14,7 @@ import viteCompression from 'vite-plugin-compression' import vueSetupExtend from 'vite-plugin-vue-setup-extend' import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite' import { createSvgIconsPlugin } from 'vite-plugin-svg-icons' + export function createVitePlugins(VITE_APP_TITLE: string) { const root = process.cwd() // 路径查找 @@ -27,7 +28,7 @@ export function createVitePlugins(VITE_APP_TITLE: string) { progress(), PurgeIcons(), vueSetupExtend(), - ElementPlus(), + ElementPlus({}), AutoImport({ include: [ /\.[tj]sx?$/, // .ts, .tsx, .js, .jsx diff --git a/build/vite/optimize.ts b/build/vite/optimize.ts index a4bff7b9..3d90dbac 100644 --- a/build/vite/optimize.ts +++ b/build/vite/optimize.ts @@ -67,7 +67,19 @@ const include = [ 'element-plus/es/components/dropdown/style/index', 'element-plus/es/components/dropdown-menu/style/index', 'element-plus/es/components/dropdown-item/style/index', - 'element-plus/es/components/skeleton/style/index' + 'element-plus/es/components/skeleton/style/index', + 'element-plus/es/components/skeleton/style/css', + 'element-plus/es/components/backtop/style/css', + 'element-plus/es/components/menu/style/css', + 'element-plus/es/components/sub-menu/style/css', + 'element-plus/es/components/menu-item/style/css', + 'element-plus/es/components/dropdown/style/css', + 'element-plus/es/components/tree/style/css', + 'element-plus/es/components/dropdown-menu/style/css', + 'element-plus/es/components/dropdown-item/style/css', + 'element-plus/es/components/badge/style/css', + 'element-plus/es/components/breadcrumb/style/css', + 'element-plus/es/components/breadcrumb-item/style/css' ] const exclude = ['@iconify/json'] diff --git a/package.json b/package.json index 5b55353a..d067560f 100644 --- a/package.json +++ b/package.json @@ -1,16 +1,18 @@ { "name": "yudao-ui-admin-vue3", - "version": "1.7.0-snapshot.1922", + "version": "1.7.1-snapshot.1941", "description": "基于vue3、vite4、element-plus、typesScript", "author": "xingyu", "private": false, "scripts": { "i": "pnpm install", "dev": "vite --mode base", + "front": "vite --mode front", "ts:check": "vue-tsc --noEmit", - "build:pro": "vite build --mode pro", - "build:dev": "vite build --mode dev", - "build:test": "npm run ts:check && vite build --mode test", + "build:pro": "node --max_old_space_size=8000 ./node_modules/vite/bin/vite.js build --mode pro", + "build:dev": "node --max_old_space_size=8000 ./node_modules/vite/bin/vite.js build --mode dev", + "build:test": "node --max_old_space_size=8000 ./node_modules/vite/bin/vite.js build --mode test", + "build:static": "node --max_old_space_size=8000 ./node_modules/vite/bin/vite.js build --mode static", "serve:pro": "vite preview --mode pro", "serve:dev": "vite preview --mode dev", "serve:test": "vite preview --mode test", @@ -27,12 +29,12 @@ "@form-create/designer": "^3.1.0", "@form-create/element-ui": "^3.1.17", "@iconify/iconify": "^3.1.0", - "@vueuse/core": "^9.12.0", + "@vueuse/core": "^9.13.0", "@wangeditor/editor": "^5.1.23", "@wangeditor/editor-for-vue": "^5.1.10", "@zxcvbn-ts/core": "^2.2.1", "animate.css": "^4.1.1", - "axios": "^1.3.3", + "axios": "^1.3.4", "bpmn-js-token-simulation": "^0.10.0", "camunda-bpmn-moddle": "^7.0.1", "cropperjs": "^1.5.13", @@ -41,18 +43,18 @@ "diagram-js": "^11.6.0", "echarts": "^5.4.1", "echarts-wordcloud": "^2.1.0", - "element-plus": "2.2.30", - "fast-xml-parser": "^4.1.2", + "element-plus": "2.2.34", + "fast-xml-parser": "^4.1.3", "highlight.js": "^11.7.0", "intro.js": "^6.0.0", - "jsencrypt": "^3.3.1", + "jsencrypt": "^3.3.2", "lodash-es": "^4.17.21", "min-dash": "^4.0.0", "mitt": "^3.0.0", "nprogress": "^0.2.0", - "pinia": "^2.0.30", + "pinia": "^2.0.33", "qrcode": "^1.5.1", - "qs": "^6.11.0", + "qs": "^6.11.1", "steady-xml": "^0.1.0", "url": "^0.11.0", "vue": "3.2.47", @@ -66,19 +68,19 @@ "xml-js": "^1.6.11" }, "devDependencies": { - "@commitlint/cli": "^17.4.3", - "@commitlint/config-conventional": "^17.4.3", - "@iconify/json": "^2.2.21", + "@commitlint/cli": "^17.4.4", + "@commitlint/config-conventional": "^17.4.4", + "@iconify/json": "^2.2.31", "@intlify/unplugin-vue-i18n": "^0.8.2", "@purge-icons/generated": "^0.9.0", - "@types/intro.js": "^5.1.0", + "@types/intro.js": "^5.1.1", "@types/lodash-es": "^4.17.6", - "@types/node": "^18.13.0", + "@types/node": "^18.14.6", "@types/nprogress": "^0.2.0", "@types/qrcode": "^1.5.0", "@types/qs": "^6.9.7", - "@typescript-eslint/eslint-plugin": "^5.52.0", - "@typescript-eslint/parser": "^5.52.0", + "@typescript-eslint/eslint-plugin": "^5.54.1", + "@typescript-eslint/parser": "^5.54.1", "@vitejs/plugin-legacy": "^4.0.1", "@vitejs/plugin-vue": "^4.0.0", "@vitejs/plugin-vue-jsx": "^3.0.0", @@ -86,8 +88,8 @@ "bpmn-js": "^8.9.0", "bpmn-js-properties-panel": "^0.46.0", "consola": "^2.15.3", - "eslint": "^8.34.0", - "eslint-config-prettier": "^8.6.0", + "eslint": "^8.35.0", + "eslint-config-prettier": "^8.7.0", "eslint-define-config": "^1.15.0", "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-vue": "^9.9.0", @@ -96,21 +98,21 @@ "postcss-html": "^1.5.0", "postcss-scss": "^4.0.6", "prettier": "^2.8.4", - "rimraf": "^4.1.2", - "rollup": "^3.15.0", - "sass": "^1.58.1", - "stylelint": "^15.1.0", + "rimraf": "^4.3.1", + "rollup": "^3.18.0", + "sass": "^1.58.3", + "stylelint": "^15.2.0", "stylelint-config-html": "^1.1.0", "stylelint-config-prettier": "^9.0.5", "stylelint-config-recommended": "^10.0.1", "stylelint-config-standard": "^30.0.1", "stylelint-order": "^6.0.2", - "terser": "^5.16.3", + "terser": "^5.16.5", "typescript": "4.9.5", - "unplugin-auto-import": "^0.14.2", - "unplugin-element-plus": "^0.6.0", - "unplugin-vue-components": "^0.23.0", - "vite": "4.1.1", + "unplugin-auto-import": "^0.15.1", + "unplugin-element-plus": "^0.7.0", + "unplugin-vue-components": "^0.24.1", + "vite": "4.1.4", "vite-plugin-compression": "^0.5.1", "vite-plugin-ejs": "^1.6.4", "vite-plugin-eslint": "^1.8.1", @@ -119,7 +121,7 @@ "vite-plugin-svg-icons": "^2.0.1", "vite-plugin-vue-setup-extend": "^0.4.0", "vite-plugin-windicss": "^1.8.10", - "vue-tsc": "^1.0.24", + "vue-tsc": "^1.2.0", "windicss": "^3.5.6" }, "engines": { diff --git a/src/components/Descriptions/src/Descriptions.vue b/src/components/Descriptions/src/Descriptions.vue index d6cea87a..fca37000 100644 --- a/src/components/Descriptions/src/Descriptions.vue +++ b/src/components/Descriptions/src/Descriptions.vue @@ -109,7 +109,13 @@ const toggleClick = () => { v-bind="getBindItemValue(item)" > <template #label> - <slot :name="`${item.field}-label`" :label="item.label">{{ item.label }}</slot> + <slot + :name="`${item.field}-label`" + :row="{ + label: item.label + }" + >{{ item.label }}</slot + > </template> <template #default> diff --git a/src/components/DictTag/src/DictTag.vue b/src/components/DictTag/src/DictTag.vue index f70d52bf..15b5f12a 100644 --- a/src/components/DictTag/src/DictTag.vue +++ b/src/components/DictTag/src/DictTag.vue @@ -33,12 +33,15 @@ export default defineComponent({ if (!props.type) { return null } - if (!props.value) { + // 解决自定义字典标签值为零时标签不渲染的问题 + if (!props.value && props.value !== 0) { return null } getDictObj(props.type, props.value.toString()) + // 添加标签的文字颜色为白色,解决自定义背景颜色时标签文字看不清的问题 return ( <ElTag + style={dictData.value?.cssClass ? 'color: #fff' : ''} type={dictData.value?.colorType} color={ dictData.value?.cssClass && isHexColor(dictData.value?.cssClass) diff --git a/src/components/Search/src/Search.vue b/src/components/Search/src/Search.vue index ffff5681..80f2b37c 100644 --- a/src/components/Search/src/Search.vue +++ b/src/components/Search/src/Search.vue @@ -123,6 +123,9 @@ const setVisible = () => { </ElButton> </div> </template> + <template #[name] v-for="name in Object.keys($slots)" :key="name" + ><slot :name="name"></slot + ></template> </Form> <template v-if="layout === 'bottom'"> diff --git a/src/components/XModal/src/XModal.vue b/src/components/XModal/src/XModal.vue index c397edd9..95b9f4be 100644 --- a/src/components/XModal/src/XModal.vue +++ b/src/components/XModal/src/XModal.vue @@ -12,7 +12,9 @@ const props = defineProps({ height: propTypes.string, minWidth: propTypes.string.def('460'), minHeight: propTypes.string.def('320'), - showFooter: propTypes.bool.def(true) + showFooter: propTypes.bool.def(true), + maskClosable: propTypes.bool.def(false), + escClosable: propTypes.bool.def(false) }) const getBindValue = computed(() => { diff --git a/src/components/XTable/src/XTable.vue b/src/components/XTable/src/XTable.vue index 34f91ce0..451d3d30 100644 --- a/src/components/XTable/src/XTable.vue +++ b/src/components/XTable/src/XTable.vue @@ -12,7 +12,7 @@ import { useAppStore } from '@/store/modules/app' import { useDesign } from '@/hooks/web/useDesign' import { XTableProps } from './type' import { isBoolean, isFunction } from '@/utils/is' - +import styleCss from './style/dark.scss?inline' import download from '@/utils/download' const { t } = useI18n() @@ -25,15 +25,38 @@ const prefixCls = getPrefixCls('x-vxe-table') const attrs = useAttrs() const emit = defineEmits(['register']) - +const removeStyles = () => { + const filename = 'cssTheme' + //移除引入的文件名 + const targetelement = 'style' + const targetattr = 'id' + const allsuspects = document.getElementsByTagName(targetelement) + for (let i = allsuspects.length; i >= 0; i--) { + if ( + allsuspects[i] && + allsuspects[i].getAttribute(targetattr) != null && + allsuspects[i].getAttribute(targetattr)?.indexOf(filename) != -1 + ) { + console.log(allsuspects[i], 'node') + allsuspects[i].parentNode?.removeChild(allsuspects[i]) + } + } +} +const reImport = () => { + const head = document.getElementsByTagName('head')[0] + const style = document.createElement('style') + style.innerText = styleCss + style.id = 'cssTheme' + head.appendChild(style) +} watch( () => appStore.getIsDark, () => { - if (appStore.getIsDark == true) { - import('./style/dark.scss') + if (appStore.getIsDark) { + reImport() } - if (appStore.getIsDark == false) { - import('./style/light.scss') + if (!appStore.getIsDark) { + removeStyles() } }, { immediate: true } diff --git a/src/components/bpmnProcessDesigner/package/designer/ProcessDesigner.vue b/src/components/bpmnProcessDesigner/package/designer/ProcessDesigner.vue index 1f471f3e..e16857ec 100644 --- a/src/components/bpmnProcessDesigner/package/designer/ProcessDesigner.vue +++ b/src/components/bpmnProcessDesigner/package/designer/ProcessDesigner.vue @@ -190,12 +190,12 @@ </div> <XModal title="预览" width="80%" height="90%" v-model="previewModelVisible" destroy-on-close> <!-- append-to-body --> - <pre v-highlight> - <code class="hljs"> - <!-- 高亮代码块 --> - {{ previewResult }} - </code> - </pre> + <div v-highlight> + <code class="hljs"> + <!-- 高亮代码块 --> + {{ previewResult }} + </code> + </div> <!-- <pre> <code class="hljs" v-html="highlightedCode(previewType, previewResult)"></code> </pre> --> @@ -331,7 +331,7 @@ const additionalModules = computed(() => { // 插入用户自定义扩展模块 if (Object.prototype.toString.call(props.additionalModel) == '[object Array]') { - Modules.push(...props.additionalModel) + Modules.push(...(props.additionalModel as any[])) } else { props.additionalModel && Modules.push(props.additionalModel) } diff --git a/src/components/bpmnProcessDesigner/package/palette/ProcessPalette.vue b/src/components/bpmnProcessDesigner/package/palette/ProcessPalette.vue index f5272840..38e4ba17 100644 --- a/src/components/bpmnProcessDesigner/package/palette/ProcessPalette.vue +++ b/src/components/bpmnProcessDesigner/package/palette/ProcessPalette.vue @@ -8,9 +8,10 @@ <script setup lang="ts" name="MyProcessPalette"> import { assign } from 'min-dash' -const addTask = (event, options = {}) => { - const ElementFactory = window.bpmnInstances.elementFactory - const create = window.bpmnInstances.modeler.get('create') +const bpmnInstances = () => (window as any).bpmnInstances +const addTask = (event, options: any = {}) => { + const ElementFactory = bpmnInstances().elementFactory + const create = bpmnInstances().modeler.get('create') console.log(ElementFactory, create) diff --git a/src/components/bpmnProcessDesigner/package/penal/PropertiesPanel.vue b/src/components/bpmnProcessDesigner/package/penal/PropertiesPanel.vue index 03dec801..74d8b00a 100644 --- a/src/components/bpmnProcessDesigner/package/penal/PropertiesPanel.vue +++ b/src/components/bpmnProcessDesigner/package/penal/PropertiesPanel.vue @@ -109,6 +109,7 @@ const bpmnElement = ref() const timer = ref() provide('prefix', props.prefix) provide('width', props.width) +const bpmnInstances = () => (window as any)?.bpmnInstances const initModels = () => { // console.log(props, 'props') // console.log(props.bpmnModeler, 'sakdjjaskdsajdkasdjkadsjk') @@ -121,7 +122,8 @@ const initModels = () => { } if (timer.value) { clearTimeout(timer.value) - window.bpmnInstances = { + const w = window as any + w.bpmnInstances = { modeler: props.bpmnModeler, modeling: props.bpmnModeler.get('modeling'), moddle: props.bpmnModeler.get('moddle'), @@ -134,7 +136,7 @@ const initModels = () => { } } - console.log(window.bpmnInstances, 'window.bpmnInstances') + console.log(bpmnInstances(), 'window.bpmnInstances') getActiveElement() // }) } @@ -161,8 +163,8 @@ const initFormOnChanged = (element) => { let activatedElement = element if (!activatedElement) { activatedElement = - window.bpmnInstances.elementRegistry.find((el) => el.type === 'bpmn:Process') ?? - window.bpmnInstances.elementRegistry.find((el) => el.type === 'bpmn:Collaboration') + bpmnInstances().elementRegistry.find((el) => el.type === 'bpmn:Process') ?? + bpmnInstances().elementRegistry.find((el) => el.type === 'bpmn:Collaboration') } if (!activatedElement) return console.log(` @@ -173,7 +175,7 @@ const initFormOnChanged = (element) => { ---------- `) console.log('businessObject: ', activatedElement.businessObject) - window.bpmnInstances.bpmnElement = activatedElement + bpmnInstances().bpmnElement = activatedElement bpmnElement.value = activatedElement elementId.value = activatedElement.id elementType.value = activatedElement.type.split(':')[1] || '' @@ -191,7 +193,8 @@ onMounted(() => { }, 100) }) onBeforeUnmount(() => { - window.bpmnInstances = null + const w = window as any + w.bpmnInstances = null console.log(props, 'props1') console.log(props.bpmnModeler, 'props.bpmnModeler1') }) diff --git a/src/components/bpmnProcessDesigner/package/penal/base/ElementBaseInfo.vue b/src/components/bpmnProcessDesigner/package/penal/base/ElementBaseInfo.vue index d9f178a0..e2bfecba 100644 --- a/src/components/bpmnProcessDesigner/package/penal/base/ElementBaseInfo.vue +++ b/src/components/bpmnProcessDesigner/package/penal/base/ElementBaseInfo.vue @@ -59,11 +59,12 @@ const rules = reactive({ name: [{ required: true, message: '流程名称不能为空', trigger: 'blur' }] }) +const bpmnInstances = () => (window as any)?.bpmnInstances const resetBaseInfo = () => { console.log(window, 'window') console.log(bpmnElement.value, 'bpmnElement') - bpmnElement.value = window?.bpmnInstances?.bpmnElement + bpmnElement.value = bpmnInstances()?.bpmnElement console.log(bpmnElement.value, 'resetBaseInfo11111111111') elementBaseInfo.value = bpmnElement.value.businessObject needProps.value['type'] = bpmnElement.value.businessObject.$type @@ -125,13 +126,13 @@ const updateBaseInfo = (key) => { console.log(window, 'window') console.log(bpmnElement.value, 'bpmnElement') console.log(toRaw(bpmnElement.value), 'bpmnElement') - window.bpmnInstances.modeling.updateProperties(toRaw(bpmnElement.value), { + bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), { id: elementBaseInfo.value[key], di: { id: `${elementBaseInfo.value[key]}_di` } }) } else { console.log(attrObj, 'attrObj') - window.bpmnInstances.modeling.updateProperties(toRaw(bpmnElement.value), attrObj) + bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), attrObj) } } onMounted(() => { diff --git a/src/components/bpmnProcessDesigner/package/penal/flow-condition/FlowCondition.vue b/src/components/bpmnProcessDesigner/package/penal/flow-condition/FlowCondition.vue index ee4512e7..2429bc91 100644 --- a/src/components/bpmnProcessDesigner/package/penal/flow-condition/FlowCondition.vue +++ b/src/components/bpmnProcessDesigner/package/penal/flow-condition/FlowCondition.vue @@ -72,14 +72,16 @@ const bpmnElement = ref() const bpmnElementSource = ref() const bpmnElementSourceRef = ref() const flowConditionRef = ref() +const bpmnInstances = () => (window as any)?.bpmnInstances const resetFlowCondition = () => { - bpmnElement.value = window.bpmnInstances.bpmnElement + bpmnElement.value = bpmnInstances().bpmnElement bpmnElementSource.value = bpmnElement.value.source bpmnElementSourceRef.value = bpmnElement.value.businessObject.sourceRef if ( bpmnElementSourceRef.value && bpmnElementSourceRef.value.default && - bpmnElementSourceRef.value.default.id === this.bpmnElement.id + bpmnElementSourceRef.value.default.id === bpmnElement.value.id && + flowConditionForm.value.type == 'default' ) { // 默认 flowConditionForm.value = { type: 'default' } @@ -113,18 +115,18 @@ const resetFlowCondition = () => { const updateFlowType = (flowType) => { // 正常条件类 if (flowType === 'condition') { - flowConditionRef.value = window.bpmnInstances.moddle.create('bpmn:FormalExpression') - window.bpmnInstances.modeling.updateProperties(toRaw(bpmnElement.value), { + flowConditionRef.value = bpmnInstances().moddle.create('bpmn:FormalExpression') + bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), { conditionExpression: flowConditionRef.value }) return } // 默认路径 if (flowType === 'default') { - window.bpmnInstances.modeling.updateProperties(toRaw(bpmnElement.value), { + bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), { conditionExpression: null }) - window.bpmnInstances.modeling.updateProperties(toRaw(bpmnElementSource.value), { + bpmnInstances().modeling.updateProperties(toRaw(bpmnElementSource.value), { default: bpmnElement.value }) return @@ -134,11 +136,11 @@ const updateFlowType = (flowType) => { bpmnElementSourceRef.value.default && bpmnElementSourceRef.value.default.id === bpmnElement.value.id ) { - window.bpmnInstances.modeling.updateProperties(toRaw(bpmnElementSource.value), { + bpmnInstances().modeling.updateProperties(toRaw(bpmnElementSource.value), { default: null }) } - window.bpmnInstances.modeling.updateProperties(toRaw(bpmnElement.value), { + bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), { conditionExpression: null }) } @@ -146,22 +148,22 @@ const updateFlowCondition = () => { let { conditionType, scriptType, body, resource, language } = flowConditionForm.value let condition if (conditionType === 'expression') { - condition = window.bpmnInstances.moddle.create('bpmn:FormalExpression', { body }) + condition = bpmnInstances().moddle.create('bpmn:FormalExpression', { body }) } else { if (scriptType === 'inlineScript') { - condition = window.bpmnInstances.moddle.create('bpmn:FormalExpression', { body, language }) + condition = bpmnInstances().moddle.create('bpmn:FormalExpression', { body, language }) // this.$set(this.flowConditionForm, "resource", ""); flowConditionForm.value['resource'] = '' } else { // this.$set(this.flowConditionForm, "body", ""); flowConditionForm.value['body'] = '' - condition = window.bpmnInstances.moddle.create('bpmn:FormalExpression', { + condition = bpmnInstances().moddle.create('bpmn:FormalExpression', { resource, language }) } } - window.bpmnInstances.modeling.updateProperties(toRaw(bpmnElement.value), { + bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), { conditionExpression: condition }) } @@ -175,11 +177,13 @@ onBeforeUnmount(() => { watch( () => props.businessObject, (val) => { - if (val) { - nextTick(() => { - resetFlowCondition() - }) - } + console.log(val, 'val') + nextTick(() => { + resetFlowCondition() + }) + }, + { + immediate: true } ) </script> diff --git a/src/components/bpmnProcessDesigner/package/penal/form/ElementForm.vue b/src/components/bpmnProcessDesigner/package/penal/form/ElementForm.vue index a1b51623..cb96a2fb 100644 --- a/src/components/bpmnProcessDesigner/package/penal/form/ElementForm.vue +++ b/src/components/bpmnProcessDesigner/package/penal/form/ElementForm.vue @@ -239,17 +239,18 @@ const elExtensionElements = ref() const formData = ref() const otherExtensions = ref() +const bpmnInstances = () => (window as any)?.bpmnInstances const resetFormList = () => { - bpmnELement.value = window.bpmnInstances.bpmnElement + bpmnELement.value = bpmnInstances().bpmnElement formKey.value = bpmnELement.value.businessObject.formKey // 获取元素扩展属性 或者 创建扩展属性 elExtensionElements.value = bpmnELement.value.businessObject.get('extensionElements') || - window.bpmnInstances.moddle.create('bpmn:ExtensionElements', { values: [] }) + bpmnInstances().moddle.create('bpmn:ExtensionElements', { values: [] }) // 获取元素表单配置 或者 创建新的表单配置 formData.value = elExtensionElements.value.values.filter((ex) => ex.$type === `${prefix}:FormData`)?.[0] || - window.bpmnInstances.moddle.create(`${prefix}:FormData`, { fields: [] }) + bpmnInstances().moddle.create(`${prefix}:FormData`, { fields: [] }) // 业务标识 businessKey, 绑定在 formData 中 businessKey.value = formData.value.businessKey @@ -266,12 +267,12 @@ const resetFormList = () => { updateElementExtensions() } const updateElementFormKey = () => { - window.bpmnInstances.modeling.updateProperties(toRaw(bpmnELement.value), { + bpmnInstances().modeling.updateProperties(toRaw(bpmnELement.value), { formKey: formKey.value }) } const updateElementBusinessKey = () => { - window.bpmnInstances.modeling.updateModdleProperties(toRaw(bpmnELement.value), formData.value, { + bpmnInstances().modeling.updateModdleProperties(toRaw(bpmnELement.value), formData.value, { businessKey: businessKey.value }) } @@ -353,37 +354,37 @@ const saveFieldOption = () => { // 保存字段配置 const saveField = () => { const { id, type, label, defaultValue, datePattern } = formFieldForm.value - const Field = window.bpmnInstances.moddle.create(`${prefix}:FormField`, { id, type, label }) + const Field = bpmnInstances().moddle.create(`${prefix}:FormField`, { id, type, label }) defaultValue && (Field.defaultValue = defaultValue) datePattern && (Field.datePattern = datePattern) // 构建属性 if (fieldPropertiesList.value && fieldPropertiesList.value.length) { const fieldPropertyList = fieldPropertiesList.value.map((fp) => { - return window.bpmnInstances.moddle.create(`${prefix}:Property`, { + return bpmnInstances().moddle.create(`${prefix}:Property`, { id: fp.id, value: fp.value }) }) - Field.properties = window.bpmnInstances.moddle.create(`${this.prefix}:Properties`, { + Field.properties = bpmnInstances().moddle.create(`${prefix}:Properties`, { values: fieldPropertyList }) } // 构建校验规则 if (fieldConstraintsList.value && fieldConstraintsList.value.length) { const fieldConstraintList = fieldConstraintsList.value.map((fc) => { - return window.bpmnInstances.moddle.create(`${prefix}:Constraint`, { + return bpmnInstances().moddle.create(`${prefix}:Constraint`, { name: fc.name, config: fc.config }) }) - Field.validation = window.bpmnInstances.moddle.create(`${prefix}:Validation`, { + Field.validation = bpmnInstances().moddle.create(`${prefix}:Validation`, { constraints: fieldConstraintList }) } // 构建枚举值 if (fieldEnumList.value && fieldEnumList.value.length) { Field.values = fieldEnumList.value.map((fe) => { - return window.bpmnInstances.moddle.create(`${prefix}:Value`, { name: fe.name, id: fe.id }) + return bpmnInstances().moddle.create(`${prefix}:Value`, { name: fe.name, id: fe.id }) }) } // 更新数组 与 表单配置实例 @@ -421,11 +422,11 @@ const removeField = (field, index) => { const updateElementExtensions = () => { // 更新回扩展元素 - const newElExtensionElements = window.bpmnInstances.moddle.create(`bpmn:ExtensionElements`, { + const newElExtensionElements = bpmnInstances().moddle.create(`bpmn:ExtensionElements`, { values: otherExtensions.value.concat(formData.value) }) // 更新到元素上 - window.bpmnInstances.modeling.updateProperties(toRaw(bpmnELement.value), { + bpmnInstances().modeling.updateProperties(toRaw(bpmnELement.value), { extensionElements: newElExtensionElements }) } diff --git a/src/components/bpmnProcessDesigner/package/penal/listeners/ElementListeners.vue b/src/components/bpmnProcessDesigner/package/penal/listeners/ElementListeners.vue index 0c29e6ff..5c2db5af 100644 --- a/src/components/bpmnProcessDesigner/package/penal/listeners/ElementListeners.vue +++ b/src/components/bpmnProcessDesigner/package/penal/listeners/ElementListeners.vue @@ -266,9 +266,10 @@ const otherExtensionList = ref() const bpmnElementListeners = ref() const listenerFormRef = ref() const listenerFieldFormRef = ref() +const bpmnInstances = () => (window as any)?.bpmnInstances const resetListenersList = () => { - bpmnElement.value = window.bpmnInstances.bpmnElement + bpmnElement.value = bpmnInstances().bpmnElement otherExtensionList.value = [] bpmnElementListeners.value = bpmnElement.value.businessObject?.extensionElements?.values?.filter( diff --git a/src/components/bpmnProcessDesigner/package/penal/listeners/UserTaskListeners.vue b/src/components/bpmnProcessDesigner/package/penal/listeners/UserTaskListeners.vue index 7746ca86..e4201b52 100644 --- a/src/components/bpmnProcessDesigner/package/penal/listeners/UserTaskListeners.vue +++ b/src/components/bpmnProcessDesigner/package/penal/listeners/UserTaskListeners.vue @@ -313,13 +313,14 @@ const bpmnElementListeners = ref() const otherExtensionList = ref() const listenerFormRef = ref() const listenerFieldFormRef = ref() +const bpmnInstances = () => (window as any)?.bpmnInstances const resetListenersList = () => { console.log( - window.bpmnInstances.bpmnElement, + bpmnInstances().bpmnElement, 'window.bpmnInstances.bpmnElementwindow.bpmnInstances.bpmnElementwindow.bpmnInstances.bpmnElementwindow.bpmnInstances.bpmnElementwindow.bpmnInstances.bpmnElementwindow.bpmnInstances.bpmnElement' ) - bpmnElement.value = window.bpmnInstances.bpmnElement + bpmnElement.value = bpmnInstances().bpmnElement otherExtensionList.value = [] bpmnElementListeners.value = bpmnElement.value.businessObject?.extensionElements?.values.filter( diff --git a/src/components/bpmnProcessDesigner/package/penal/multi-instance/ElementMultiInstance.vue b/src/components/bpmnProcessDesigner/package/penal/multi-instance/ElementMultiInstance.vue index 6d0229bb..962234d5 100644 --- a/src/components/bpmnProcessDesigner/package/penal/multi-instance/ElementMultiInstance.vue +++ b/src/components/bpmnProcessDesigner/package/penal/multi-instance/ElementMultiInstance.vue @@ -87,6 +87,7 @@ const defaultLoopInstanceForm = ref({ const loopInstanceForm = ref<any>({}) const bpmnElement = ref(null) const multiLoopInstance = ref(null) +const bpmnInstances = () => (window as any)?.bpmnInstances const getElementLoop = (businessObject) => { if (!businessObject.loopCharacteristics) { @@ -112,7 +113,7 @@ const getElementLoop = (businessObject) => { loopCardinality: businessObject.loopCharacteristics?.loopCardinality?.body ?? '' } // 保留当前元素 businessObject 上的 loopCharacteristics 实例 - multiLoopInstance.value = window.bpmnInstances.bpmnElement.businessObject.loopCharacteristics + multiLoopInstance.value = bpmnInstances().bpmnElement.businessObject.loopCharacteristics // 更新表单 if ( businessObject.loopCharacteristics.extensionElements && @@ -127,17 +128,17 @@ const changeLoopCharacteristicsType = (type) => { // this.loopInstanceForm = { ...this.defaultLoopInstanceForm }; // 切换类型取消原表单配置 // 取消多实例配置 if (type === 'Null') { - window.bpmnInstances.modeling.updateProperties(toRaw(bpmnElement.value), { + bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), { loopCharacteristics: null }) return } // 配置循环 if (type === 'StandardLoop') { - const loopCharacteristicsObject = window.bpmnInstances.moddle.create( + const loopCharacteristicsObject = bpmnInstances().moddle.create( 'bpmn:StandardLoopCharacteristics' ) - window.bpmnInstances.modeling.updateProperties(toRaw(bpmnElement.value), { + bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), { loopCharacteristics: loopCharacteristicsObject }) multiLoopInstance.value = null @@ -145,17 +146,17 @@ const changeLoopCharacteristicsType = (type) => { } // 时序 if (type === 'SequentialMultiInstance') { - multiLoopInstance.value = window.bpmnInstances.moddle.create( + multiLoopInstance.value = bpmnInstances().moddle.create( 'bpmn:MultiInstanceLoopCharacteristics', { isSequential: true } ) } else { - multiLoopInstance.value = window.bpmnInstances.moddle.create( + multiLoopInstance.value = bpmnInstances().moddle.create( 'bpmn:MultiInstanceLoopCharacteristics', { collection: '${coll_userList}' } ) } - window.bpmnInstances.modeling.updateProperties(toRaw(bpmnElement.value), { + bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), { loopCharacteristics: toRaw(multiLoopInstance.value) }) } @@ -163,11 +164,11 @@ const changeLoopCharacteristicsType = (type) => { const updateLoopCardinality = (cardinality) => { let loopCardinality = null if (cardinality && cardinality.length) { - loopCardinality = window.bpmnInstances.moddle.create('bpmn:FormalExpression', { + loopCardinality = bpmnInstances().moddle.create('bpmn:FormalExpression', { body: cardinality }) } - window.bpmnInstances.modeling.updateModdleProperties( + bpmnInstances().modeling.updateModdleProperties( toRaw(bpmnElement.value), multiLoopInstance.value, { @@ -179,11 +180,11 @@ const updateLoopCardinality = (cardinality) => { const updateLoopCondition = (condition) => { let completionCondition = null if (condition && condition.length) { - completionCondition = window.bpmnInstances.moddle.create('bpmn:FormalExpression', { + completionCondition = bpmnInstances().moddle.create('bpmn:FormalExpression', { body: condition }) } - window.bpmnInstances.modeling.updateModdleProperties( + bpmnInstances().modeling.updateModdleProperties( toRaw(bpmnElement.value), multiLoopInstance.value, { @@ -193,14 +194,14 @@ const updateLoopCondition = (condition) => { } // 重试周期 const updateLoopTimeCycle = (timeCycle) => { - const extensionElements = window.bpmnInstances.moddle.create('bpmn:ExtensionElements', { + const extensionElements = bpmnInstances().moddle.create('bpmn:ExtensionElements', { values: [ - window.bpmnInstances.moddle.create(`${prefix}:FailedJobRetryTimeCycle`, { + bpmnInstances().moddle.create(`${prefix}:FailedJobRetryTimeCycle`, { body: timeCycle }) ] }) - window.bpmnInstances.modeling.updateModdleProperties( + bpmnInstances().modeling.updateModdleProperties( toRaw(bpmnElement.value), multiLoopInstance.value, { @@ -210,7 +211,7 @@ const updateLoopTimeCycle = (timeCycle) => { } // 直接更新的基础信息 const updateLoopBase = () => { - window.bpmnInstances.modeling.updateModdleProperties( + bpmnInstances().modeling.updateModdleProperties( toRaw(bpmnElement.value), multiLoopInstance.value, { @@ -230,7 +231,7 @@ const updateLoopAsync = (key) => { } else { asyncAttr[key] = loopInstanceForm.value[key] } - window.bpmnInstances.modeling.updateModdleProperties( + bpmnInstances().modeling.updateModdleProperties( toRaw(bpmnElement.value), multiLoopInstance.value, asyncAttr @@ -245,7 +246,7 @@ onBeforeUnmount(() => { watch( () => props.businessObject, (val) => { - bpmnElement.value = window.bpmnInstances.bpmnElement + bpmnElement.value = bpmnInstances().bpmnElement getElementLoop(val) }, { immediate: true } diff --git a/src/components/bpmnProcessDesigner/package/penal/other/ElementOtherConfig.vue b/src/components/bpmnProcessDesigner/package/penal/other/ElementOtherConfig.vue index fe2d004d..2c55481c 100644 --- a/src/components/bpmnProcessDesigner/package/penal/other/ElementOtherConfig.vue +++ b/src/components/bpmnProcessDesigner/package/penal/other/ElementOtherConfig.vue @@ -22,13 +22,14 @@ const props = defineProps({ }) const documentation = ref('') const bpmnElement = ref() +const bpmnInstances = () => (window as any).bpmnInstances const updateDocumentation = () => { ;(bpmnElement.value && bpmnElement.value.id === props.id) || - (bpmnElement.value = (window as any).bpmnInstances.elementRegistry.get(props.id)) - const documentations = window.bpmnInstances.bpmnFactory.create('bpmn:Documentation', { + (bpmnElement.value = bpmnInstances().elementRegistry.get(props.id)) + const documentations = bpmnInstances().bpmnFactory.create('bpmn:Documentation', { text: documentation.value }) - window.bpmnInstances.modeling.updateProperties(toRaw(bpmnElement.value), { + bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), { documentation: [documentations] }) } @@ -41,7 +42,7 @@ watch( (id) => { if (id && id.length) { nextTick(() => { - const documentations = window.bpmnInstances.bpmnElement.businessObject?.documentation + const documentations = bpmnInstances().bpmnElement.businessObject?.documentation documentation.value = documentations && documentations.length ? documentations[0].text : '' }) } else { diff --git a/src/components/bpmnProcessDesigner/package/penal/properties/ElementProperties.vue b/src/components/bpmnProcessDesigner/package/penal/properties/ElementProperties.vue index 388c363f..f1670ffb 100644 --- a/src/components/bpmnProcessDesigner/package/penal/properties/ElementProperties.vue +++ b/src/components/bpmnProcessDesigner/package/penal/properties/ElementProperties.vue @@ -70,10 +70,11 @@ const otherExtensionList = ref() const bpmnElementProperties = ref() const bpmnElementPropertyList = ref() const attributeFormRef = ref() +const bpmnInstances = () => (window as any)?.bpmnInstances const resetAttributesList = () => { console.log(window, 'windowwindowwindowwindowwindowwindowwindow') - bpmnElement.value = window.bpmnInstances.bpmnElement + bpmnElement.value = bpmnInstances().bpmnElement otherExtensionList.value = [] // 其他扩展配置 bpmnElementProperties.value = // bpmnElement.value.businessObject?.extensionElements?.filter((ex) => { @@ -110,7 +111,7 @@ const removeAttributes = (attr, index) => { elementPropertyList.value.splice(index, 1) bpmnElementPropertyList.value.splice(index, 1) // 新建一个属性字段的保存列表 - const propertiesObject = window.bpmnInstances.moddle.create(`${prefix}:Properties`, { + const propertiesObject = bpmnInstances().moddle.create(`${prefix}:Properties`, { values: bpmnElementPropertyList.value }) updateElementExtensions(propertiesObject) @@ -122,7 +123,7 @@ const saveAttribute = () => { console.log(propertyForm.value, 'propertyForm.value') const { name, value } = propertyForm.value if (editingPropertyIndex.value !== -1) { - window.bpmnInstances.modeling.updateModdleProperties( + bpmnInstances().modeling.updateModdleProperties( toRaw(bpmnElement.value), toRaw(bpmnElementPropertyList.value)[toRaw(editingPropertyIndex.value)], { @@ -132,12 +133,12 @@ const saveAttribute = () => { ) } else { // 新建属性字段 - const newPropertyObject = window.bpmnInstances.moddle.create(`${prefix}:Property`, { + const newPropertyObject = bpmnInstances().moddle.create(`${prefix}:Property`, { name, value }) // 新建一个属性字段的保存列表 - const propertiesObject = window.bpmnInstances.moddle.create(`${prefix}:Properties`, { + const propertiesObject = bpmnInstances().moddle.create(`${prefix}:Properties`, { values: bpmnElementPropertyList.value.concat([newPropertyObject]) }) updateElementExtensions(propertiesObject) @@ -146,10 +147,10 @@ const saveAttribute = () => { resetAttributesList() } const updateElementExtensions = (properties) => { - const extensions = window.bpmnInstances.moddle.create('bpmn:ExtensionElements', { + const extensions = bpmnInstances().moddle.create('bpmn:ExtensionElements', { values: otherExtensionList.value.concat([properties]) }) - window.bpmnInstances.modeling.updateProperties(toRaw(bpmnElement.value), { + bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), { extensionElements: extensions }) } diff --git a/src/components/bpmnProcessDesigner/package/penal/signal-message/SignalAndMessage.vue b/src/components/bpmnProcessDesigner/package/penal/signal-message/SignalAndMessage.vue index 285b3411..e2c406db 100644 --- a/src/components/bpmnProcessDesigner/package/penal/signal-message/SignalAndMessage.vue +++ b/src/components/bpmnProcessDesigner/package/penal/signal-message/SignalAndMessage.vue @@ -62,10 +62,11 @@ const modelConfig = computed(() => { return { title: '创建信号', idLabel: '信号ID', nameLabel: '信号名称' } } }) +const bpmnInstances = () => (window as any)?.bpmnInstances const initDataList = () => { console.log(window, 'window') - rootElements.value = window.bpmnInstances.modeler.getDefinitions().rootElements + rootElements.value = bpmnInstances().modeler.getDefinitions().rootElements messageIdMap.value = {} signalIdMap.value = {} messageList.value = [] @@ -91,13 +92,13 @@ const addNewObject = () => { if (messageIdMap.value[modelObjectForm.value.id]) { message.error('该消息已存在,请修改id后重新保存') } - const messageRef = window.bpmnInstances.moddle.create('bpmn:Message', modelObjectForm.value) + const messageRef = bpmnInstances().moddle.create('bpmn:Message', modelObjectForm.value) rootElements.value.push(messageRef) } else { if (signalIdMap.value[modelObjectForm.value.id]) { message.error('该信号已存在,请修改id后重新保存') } - const signalRef = window.bpmnInstances.moddle.create('bpmn:Signal', modelObjectForm.value) + const signalRef = bpmnInstances().moddle.create('bpmn:Signal', modelObjectForm.value) rootElements.value.push(signalRef) } modelVisible.value = false diff --git a/src/components/bpmnProcessDesigner/package/penal/task/ElementTask.vue b/src/components/bpmnProcessDesigner/package/penal/task/ElementTask.vue index 939116ab..23e750a1 100644 --- a/src/components/bpmnProcessDesigner/package/penal/task/ElementTask.vue +++ b/src/components/bpmnProcessDesigner/package/penal/task/ElementTask.vue @@ -45,11 +45,12 @@ const installedComponent = ref({ }) const bpmnElement = ref() +const bpmnInstances = () => (window as any).bpmnInstances const changeTaskAsync = () => { if (!taskConfigForm.value.asyncBefore && !taskConfigForm.value.asyncAfter) { taskConfigForm.value.exclusive = false } - window.bpmnInstances.modeling.updateProperties(window.bpmnInstances.bpmnElement, { + bpmnInstances().modeling.updateProperties(bpmnInstances().bpmnElement, { ...taskConfigForm.value }) } @@ -57,7 +58,7 @@ const changeTaskAsync = () => { watch( () => props.id, () => { - bpmnElement.value = window.bpmnInstances.bpmnElement + bpmnElement.value = bpmnInstances().bpmnElement taskConfigForm.value.asyncBefore = bpmnElement.value?.businessObject?.asyncBefore taskConfigForm.value.asyncAfter = bpmnElement.value?.businessObject?.asyncAfter taskConfigForm.value.exclusive = bpmnElement.value?.businessObject?.exclusive diff --git a/src/components/bpmnProcessDesigner/package/penal/task/task-components/ReceiveTask.vue b/src/components/bpmnProcessDesigner/package/penal/task/task-components/ReceiveTask.vue index 57c68b19..ef2ba0b9 100644 --- a/src/components/bpmnProcessDesigner/package/penal/task/task-components/ReceiveTask.vue +++ b/src/components/bpmnProcessDesigner/package/penal/task/task-components/ReceiveTask.vue @@ -64,8 +64,9 @@ const bpmnElement = ref<any>() const bpmnMessageRefsMap = ref<any>() const bpmnRootElements = ref<any>() +const bpmnInstances = () => (window as any).bpmnInstances const getBindMessage = () => { - bpmnElement.value = window.bpmnInstances.bpmnElement + bpmnElement.value = bpmnInstances().bpmnElement bindMessageId.value = bpmnElement.value.businessObject?.messageRef?.id || '-1' } const openMessageModel = () => { @@ -77,7 +78,7 @@ const createNewMessage = () => { message.error('该消息已存在,请修改id后重新保存') return } - const newMessage = window.bpmnInstances.moddle.create('bpmn:Message', newMessageForm.value) + const newMessage = bpmnInstances().moddle.create('bpmn:Message', newMessageForm.value) bpmnRootElements.value.push(newMessage) messageMap.value[newMessageForm.value.id] = newMessageForm.value.name bpmnMessageRefsMap.value[newMessageForm.value.id] = newMessage @@ -85,11 +86,11 @@ const createNewMessage = () => { } const updateTaskMessage = (messageId) => { if (messageId === '-1') { - window.bpmnInstances.modeling.updateProperties(toRaw(bpmnElement.value), { + bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), { messageRef: null }) } else { - window.bpmnInstances.modeling.updateProperties(toRaw(bpmnElement.value), { + bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), { messageRef: bpmnMessageRefsMap.value[messageId] }) } @@ -97,7 +98,7 @@ const updateTaskMessage = (messageId) => { onMounted(() => { bpmnMessageRefsMap.value = Object.create(null) - bpmnRootElements.value = window.bpmnInstances.modeler.getDefinitions().rootElements + bpmnRootElements.value = bpmnInstances().modeler.getDefinitions().rootElements bpmnRootElements.value .filter((el) => el.$type === 'bpmn:Message') .forEach((m) => { @@ -113,7 +114,7 @@ onBeforeUnmount(() => { watch( () => props.id, () => { - // bpmnElement.value = window.bpmnInstances.bpmnElement + // bpmnElement.value = bpmnInstances().bpmnElement nextTick(() => { getBindMessage() }) diff --git a/src/components/bpmnProcessDesigner/package/penal/task/task-components/ScriptTask.vue b/src/components/bpmnProcessDesigner/package/penal/task/task-components/ScriptTask.vue index ba3e6edf..bacdec0e 100644 --- a/src/components/bpmnProcessDesigner/package/penal/task/task-components/ScriptTask.vue +++ b/src/components/bpmnProcessDesigner/package/penal/task/task-components/ScriptTask.vue @@ -58,6 +58,8 @@ const defaultTaskForm = ref({ const scriptTaskForm = ref<any>({}) const bpmnElement = ref() +const bpmnInstances = () => (window as any)?.bpmnInstances + const resetTaskForm = () => { for (let key in defaultTaskForm.value) { let value = bpmnElement.value?.businessObject[key] || defaultTaskForm.value[key] @@ -76,7 +78,7 @@ const updateElementTask = () => { taskAttr.resource = scriptTaskForm.value.resource || null taskAttr.script = null } - window.bpmnInstances.modeling.updateProperties(toRaw(bpmnElement.value), taskAttr) + bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), taskAttr) } onBeforeUnmount(() => { @@ -86,7 +88,7 @@ onBeforeUnmount(() => { watch( () => props.id, () => { - bpmnElement.value = window.bpmnInstances.bpmnElement + bpmnElement.value = bpmnInstances().bpmnElement nextTick(() => { resetTaskForm() }) diff --git a/src/components/bpmnProcessDesigner/package/penal/task/task-components/UserTask.vue b/src/components/bpmnProcessDesigner/package/penal/task/task-components/UserTask.vue index 118fa71b..725335eb 100644 --- a/src/components/bpmnProcessDesigner/package/penal/task/task-components/UserTask.vue +++ b/src/components/bpmnProcessDesigner/package/penal/task/task-components/UserTask.vue @@ -53,6 +53,8 @@ const defaultTaskForm = ref({ const userTaskForm = ref<any>({}) // const mockData=ref([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) const bpmnElement = ref() +const bpmnInstances = () => (window as any)?.bpmnInstances + const resetTaskForm = () => { for (let key in defaultTaskForm.value) { let value @@ -76,13 +78,13 @@ const updateElementTask = (key) => { } else { taskAttr[key] = userTaskForm.value[key] || null } - window.bpmnInstances.modeling.updateProperties(toRaw(bpmnElement.value), taskAttr) + bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), taskAttr) } watch( () => props.id, () => { - bpmnElement.value = window.bpmnInstances.bpmnElement + bpmnElement.value = bpmnInstances().bpmnElement nextTick(() => { resetTaskForm() }) diff --git a/src/components/bpmnProcessDesigner/package/utils.ts b/src/components/bpmnProcessDesigner/package/utils.ts index 41f06801..bb6c5d52 100644 --- a/src/components/bpmnProcessDesigner/package/utils.ts +++ b/src/components/bpmnProcessDesigner/package/utils.ts @@ -1,4 +1,5 @@ import { toRaw } from 'vue' +const bpmnInstances = () => (window as any)?.bpmnInstances // 创建监听器实例 export function createListenerObject(options, isTask, prefix) { const listenerObj = Object.create(null) @@ -25,16 +26,16 @@ export function createListenerObject(options, isTask, prefix) { } // 任务监听器的 定时器 设置 if (isTask && options.event === 'timeout' && !!options.eventDefinitionType) { - const timeDefinition = window.bpmnInstances.moddle.create('bpmn:FormalExpression', { + const timeDefinition = bpmnInstances().moddle.create('bpmn:FormalExpression', { body: options.eventTimeDefinitions }) - const TimerEventDefinition = window.bpmnInstances.moddle.create('bpmn:TimerEventDefinition', { + const TimerEventDefinition = bpmnInstances().moddle.create('bpmn:TimerEventDefinition', { id: `TimerEventDefinition_${uuid(8)}`, [`time${options.eventDefinitionType.replace(/^\S/, (s) => s.toUpperCase())}`]: timeDefinition }) listenerObj.eventDefinitions = [TimerEventDefinition] } - return window.bpmnInstances.moddle.create( + return bpmnInstances().moddle.create( `${prefix}:${isTask ? 'TaskListener' : 'ExecutionListener'}`, listenerObj ) @@ -44,7 +45,7 @@ export function createListenerObject(options, isTask, prefix) { export function createFieldObject(option, prefix) { const { name, fieldType, string, expression } = option const fieldConfig = fieldType === 'string' ? { name, string } : { name, expression } - return window.bpmnInstances.moddle.create(`${prefix}:Field`, fieldConfig) + return bpmnInstances().moddle.create(`${prefix}:Field`, fieldConfig) } // 创建脚本实例 @@ -52,21 +53,21 @@ export function createScriptObject(options, prefix) { const { scriptType, scriptFormat, value, resource } = options const scriptConfig = scriptType === 'inlineScript' ? { scriptFormat, value } : { scriptFormat, resource } - return window.bpmnInstances.moddle.create(`${prefix}:Script`, scriptConfig) + return bpmnInstances().moddle.create(`${prefix}:Script`, scriptConfig) } // 更新元素扩展属性 export function updateElementExtensions(element, extensionList) { - const extensions = window.bpmnInstances.moddle.create('bpmn:ExtensionElements', { + const extensions = bpmnInstances().moddle.create('bpmn:ExtensionElements', { values: extensionList }) - window.bpmnInstances.modeling.updateProperties(toRaw(element), { + bpmnInstances().modeling.updateProperties(toRaw(element), { extensionElements: extensions }) } // 创建一个id -export function uuid(length = 8, chars) { +export function uuid(length = 8, chars?) { let result = '' const charsString = chars || '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' for (let i = length; i > 0; --i) { diff --git a/src/hooks/web/useCrudSchemas.ts b/src/hooks/web/useCrudSchemas.ts index 34e655b1..543111ca 100644 --- a/src/hooks/web/useCrudSchemas.ts +++ b/src/hooks/web/useCrudSchemas.ts @@ -282,7 +282,7 @@ const filterDescriptionsSchema = (crudSchema: CrudSchema[]): DescriptionsSchema[ // 给options添加国际化 const filterOptions = (options: Recordable, labelField?: string) => { - return options.map((v: Recordable) => { + return options?.map((v: Recordable) => { if (labelField) { v['labelField'] = t(v.labelField) } else { diff --git a/src/hooks/web/useI18n.ts b/src/hooks/web/useI18n.ts index 8b6e7650..d1ab70fa 100644 --- a/src/hooks/web/useI18n.ts +++ b/src/hooks/web/useI18n.ts @@ -41,6 +41,7 @@ export const useI18n = ( const tFn: I18nGlobalTranslation = (key: string, ...arg: any[]) => { if (!key) return '' if (!key.includes('.') && !namespace) return key + //@ts-ignore return t(getKey(namespace, key), ...(arg as I18nTranslationRestParameters)) } return { diff --git a/src/hooks/web/useTimeAgo.ts b/src/hooks/web/useTimeAgo.ts index 08f5d1e6..a6da2819 100644 --- a/src/hooks/web/useTimeAgo.ts +++ b/src/hooks/web/useTimeAgo.ts @@ -5,6 +5,7 @@ const TIME_AGO_MESSAGE_MAP: { 'zh-CN': UseTimeAgoMessages en: UseTimeAgoMessages } = { + // @ts-ignore 'zh-CN': { justNow: '刚刚', past: (n) => (n.match(/\d/) ? `${n}前` : n), @@ -17,6 +18,7 @@ const TIME_AGO_MESSAGE_MAP: { minute: (n) => `${n} 分钟`, second: (n) => `${n} 秒` }, + // @ts-ignore en: { justNow: 'just now', past: (n) => (n.match(/\d/) ? `${n} ago` : n), diff --git a/src/layout/components/TagsView/src/TagsView.vue b/src/layout/components/TagsView/src/TagsView.vue index b3f95594..d6e9768d 100644 --- a/src/layout/components/TagsView/src/TagsView.vue +++ b/src/layout/components/TagsView/src/TagsView.vue @@ -409,7 +409,10 @@ watch( { icon: 'ep:close', label: t('common.closeTab'), - disabled: !!visitedViews?.length && selectedTag?.meta.affix + disabled: !!visitedViews?.length && selectedTag?.meta.affix, + command: () => { + closeSelectedTag(selectedTag!) + } }, { divided: true, diff --git a/src/layout/components/ThemeSwitch/src/ThemeSwitch.vue b/src/layout/components/ThemeSwitch/src/ThemeSwitch.vue index 1af67cf0..45243011 100644 --- a/src/layout/components/ThemeSwitch/src/ThemeSwitch.vue +++ b/src/layout/components/ThemeSwitch/src/ThemeSwitch.vue @@ -37,3 +37,8 @@ const themeChange = (val: boolean) => { @change="themeChange" /> </template> +<style lang="scss" scoped> +:deep(.el-switch__core .el-switch__inner .is-icon) { + overflow: visible; +} +</style> diff --git a/src/main.ts b/src/main.ts index 4aba7d93..b3a9da16 100644 --- a/src/main.ts +++ b/src/main.ts @@ -55,7 +55,7 @@ import 'highlight.js/styles/github.css' //导入代码高亮样式 新版 import Logger from '@/utils/Logger' // 本地开发模式 全局引入 element-plus 样式,加快第一次进入速度 -if (isDevMode() == true) { +if (isDevMode()) { import('element-plus/dist/index.css') } diff --git a/src/store/modules/tagsView.ts b/src/store/modules/tagsView.ts index e9fbf371..a60d0e45 100644 --- a/src/store/modules/tagsView.ts +++ b/src/store/modules/tagsView.ts @@ -58,7 +58,7 @@ export const useTagsViewStore = defineStore('tagsView', { // 删除某个 delView(view: RouteLocationNormalizedLoaded) { this.delVisitedView(view) - this.addCachedView() + this.delCachedView() }, // 删除tag delVisitedView(view: RouteLocationNormalizedLoaded) { @@ -80,7 +80,7 @@ export const useTagsViewStore = defineStore('tagsView', { // 删除所有缓存和tag delAllViews() { this.delAllVisitedViews() - this.addCachedView() + this.delCachedView() }, // 删除所有tag delAllVisitedViews() { diff --git a/src/styles/index.scss b/src/styles/index.scss index d53c2a6c..39c4c4da 100644 --- a/src/styles/index.scss +++ b/src/styles/index.scss @@ -6,6 +6,11 @@ margin-left: 2px !important; } +// 解决抽屉弹出时,body宽度变化的问题 +.el-popup-parent--hidden { + width: 100% !important; +} + /* nprogress 适配 element-plus 的主题色 */ #nprogress { & .bar { diff --git a/src/types/auto-components.d.ts b/src/types/auto-components.d.ts index f06196b1..fa82a4aa 100644 --- a/src/types/auto-components.d.ts +++ b/src/types/auto-components.d.ts @@ -1,5 +1,7 @@ -// generated by unplugin-vue-components -// We suggest you to commit this file into source control +/* eslint-disable */ +/* prettier-ignore */ +// @ts-nocheck +// Generated by unplugin-vue-components // Read more: https://github.com/vuejs/core/pull/3399 import '@vue/runtime-core' @@ -21,6 +23,7 @@ declare module '@vue/runtime-core' { DictTag: typeof import('./../components/DictTag/src/DictTag.vue')['default'] Echart: typeof import('./../components/Echart/src/Echart.vue')['default'] Editor: typeof import('./../components/Editor/src/Editor.vue')['default'] + ElAvatar: typeof import('element-plus/es')['ElAvatar'] ElAutoResizer: typeof import('element-plus/es')['ElAutoResizer'] ElBadge: typeof import('element-plus/es')['ElBadge'] ElButton: typeof import('element-plus/es')['ElButton'] @@ -50,6 +53,7 @@ declare module '@vue/runtime-core' { ElForm: typeof import('element-plus/es')['ElForm'] ElFormItem: typeof import('element-plus/es')['ElFormItem'] ElIcon: typeof import('element-plus/es')['ElIcon'] + ElImage: typeof import('element-plus/es')['ElImage'] ElImageViewer: typeof import('element-plus/es')['ElImageViewer'] ElInput: typeof import('element-plus/es')['ElInput'] ElLink: typeof import('element-plus/es')['ElLink'] @@ -60,12 +64,15 @@ declare module '@vue/runtime-core' { ElScrollbar: typeof import('element-plus/es')['ElScrollbar'] ElSelect: typeof import('element-plus/es')['ElSelect'] ElSkeleton: typeof import('element-plus/es')['ElSkeleton'] + ElSpace: typeof import('element-plus/es')['ElSpace'] ElSwitch: typeof import('element-plus/es')['ElSwitch'] ElTable: typeof import('element-plus/es')['ElTable'] ElTableColumn: typeof import('element-plus/es')['ElTableColumn'] - ElTableV2: typeof import('element-plus/es')['ElTableV2'] ElTabPane: typeof import('element-plus/es')['ElTabPane'] ElTabs: typeof import('element-plus/es')['ElTabs'] + ElTag: typeof import('element-plus/es')['ElTag'] + ElTimeline: typeof import('element-plus/es')['ElTimeline'] + ElTimelineItem: typeof import('element-plus/es')['ElTimelineItem'] ElTooltip: typeof import('element-plus/es')['ElTooltip'] ElUpload: typeof import('element-plus/es')['ElUpload'] Error: typeof import('./../components/Error/src/Error.vue')['default'] diff --git a/src/types/auto-imports.d.ts b/src/types/auto-imports.d.ts index d30eb960..a05a5b48 100644 --- a/src/types/auto-imports.d.ts +++ b/src/types/auto-imports.d.ts @@ -1,4 +1,7 @@ -// Generated by 'unplugin-auto-import' +/* eslint-disable */ +/* prettier-ignore */ +// @ts-nocheck +// Generated by unplugin-auto-import export {} declare global { const DICT_TYPE: typeof import('@/utils/dict')['DICT_TYPE'] @@ -68,5 +71,5 @@ declare global { // for type re-export declare global { // @ts-ignore - export type { Component,ComponentPublicInstance,ComputedRef,InjectionKey,PropType,Ref,VNode } from 'vue' + export type { Component, ComponentPublicInstance, ComputedRef, InjectionKey, PropType, Ref, VNode } from 'vue' } diff --git a/src/utils/env.ts b/src/utils/env.ts index 4a45f622..ea271813 100644 --- a/src/utils/env.ts +++ b/src/utils/env.ts @@ -1,6 +1,6 @@ export const isDevMode = () => { const dev = import.meta.env.VITE_DEV - if (dev && dev === true) { + if (dev && dev === 'true') { return true } else { return false diff --git a/src/utils/routerHelper.ts b/src/utils/routerHelper.ts index 0ae8e1e2..af6a9c3c 100644 --- a/src/utils/routerHelper.ts +++ b/src/utils/routerHelper.ts @@ -212,9 +212,11 @@ const addToChildren = ( } } const toCamelCase = (str: string, upperCaseFirst: boolean) => { - str = (str || '').toLowerCase().replace(/-(.)/g, function (group1: string) { - return group1.toUpperCase() - }) + str = (str || '') + .replace(/-(.)/g, function (group1: string) { + return group1.toUpperCase() + }) + .replaceAll('-', '') if (upperCaseFirst && str) { str = str.charAt(0).toUpperCase() + str.slice(1) diff --git a/src/views/bpm/definition/definition.data.ts b/src/views/bpm/definition/definition.data.ts index 919cbd9c..14a0c319 100644 --- a/src/views/bpm/definition/definition.data.ts +++ b/src/views/bpm/definition/definition.data.ts @@ -17,23 +17,29 @@ const crudSchemas = reactive<VxeCrudSchema>({ title: '定义名称', field: 'name', table: { - width: 120, + // width: 120, slots: { default: 'name_default' } } }, { - title: '流程分类', + title: '定义分类', field: 'category', - dictType: DICT_TYPE.BPM_MODEL_CATEGORY, - dictClass: 'number' + // dictType: DICT_TYPE.BPM_MODEL_CATEGORY, + // dictClass: 'number', + table: { + // width: 120, + slots: { + default: 'category_default' + } + } }, { title: '表单信息', field: 'formId', table: { - width: 120, + // width: 200, slots: { default: 'formId_default' } @@ -43,7 +49,7 @@ const crudSchemas = reactive<VxeCrudSchema>({ title: '流程版本', field: 'version', table: { - width: 80, + // width: 80, slots: { default: 'version_default' } @@ -53,7 +59,7 @@ const crudSchemas = reactive<VxeCrudSchema>({ title: '激活状态', field: 'suspensionState', table: { - width: 80, + // width: 80, slots: { default: 'suspensionState_default' } @@ -63,10 +69,10 @@ const crudSchemas = reactive<VxeCrudSchema>({ title: '部署时间', field: 'deploymentTime', isForm: false, - formatter: 'formatDate', - table: { - width: 180 - } + formatter: 'formatDate' + // table: { + // width: 180 + // } } ] }) diff --git a/src/views/bpm/definition/index.vue b/src/views/bpm/definition/index.vue index 19a7cf06..f2ef640c 100644 --- a/src/views/bpm/definition/index.vue +++ b/src/views/bpm/definition/index.vue @@ -6,6 +6,10 @@ <template #name_default="{ row }"> <XTextButton :title="row.name" @click="handleBpmnDetail(row.id)" /> </template> + <!-- 流程分类 --> + <template #category_default="{ row }"> + <DictTag :type="DICT_TYPE.BPM_MODEL_CATEGORY" :value="Number(row?.category)" /> + </template> <!-- 表单信息 --> <template #formId_default="{ row }"> <XTextButton @@ -43,6 +47,16 @@ v-if="formDetailVisible" /> </XModal> + <!-- 流程模型图的预览 --> + <XModal title="流程图" v-model="showBpmnOpen" width="80%" height="90%"> + <my-process-viewer + key="designer" + v-model="bpmnXML" + :value="bpmnXML" + v-bind="bpmnControlForm" + :prefix="bpmnControlForm.prefix" + /> + </XModal> </ContentWrap> </template> <script setup lang="ts"> @@ -51,8 +65,14 @@ import * as DefinitionApi from '@/api/bpm/definition' // import * as ModelApi from '@/api/bpm/model' import { allSchemas } from './definition.data' import { setConfAndFields2 } from '@/utils/formCreate' +import { DICT_TYPE } from '@/utils/dict' -const message = useMessage() // 消息弹窗 +const bpmnXML = ref(null) +const showBpmnOpen = ref(false) +const bpmnControlForm = ref({ + prefix: 'flowable' +}) +// const message = useMessage() // 消息弹窗 const router = useRouter() // 路由 const { query } = useRoute() // 查询参数 @@ -89,7 +109,13 @@ const handleFormDetail = async (row) => { const handleBpmnDetail = (row) => { // TODO 芋艿:流程组件开发中 console.log(row) - message.success('流程组件开发中,预计 2 月底完成') + DefinitionApi.getProcessDefinitionBpmnXMLApi(row).then((response) => { + console.log(response, 'response') + bpmnXML.value = response + // 弹窗打开 + showBpmnOpen.value = true + }) + // message.success('流程组件开发中,预计 2 月底完成') } // 点击任务分配按钮 @@ -97,7 +123,7 @@ const handleAssignRule = (row) => { router.push({ name: 'BpmTaskAssignRuleList', query: { - modelId: row.id + processDefinitionId: row.id } }) } diff --git a/src/views/bpm/form/formEditor.vue b/src/views/bpm/form/formEditor.vue index 52b3709d..1070739e 100644 --- a/src/views/bpm/form/formEditor.vue +++ b/src/views/bpm/form/formEditor.vue @@ -3,9 +3,21 @@ <!-- 表单设计器 --> <fc-designer ref="designer" height="780px"> <template #handle> + <XButton type="primary" title="生成JSON" @click="showJson" /> + <XButton type="primary" title="生成Options" @click="showOption" /> <XButton type="primary" :title="t('action.save')" @click="handleSave" /> </template> </fc-designer> + <Dialog :title="dialogTitle" v-model="dialogVisible1" maxHeight="600"> + <div ref="editor" v-if="dialogVisible1"> + <XTextButton style="float: right" :title="t('common.copy')" @click="copy(formValue)" /> + <el-scrollbar height="580"> + <pre> + {{ formValue }} + </pre> + </el-scrollbar> + </div> + </Dialog> <!-- 表单保存的弹窗 --> <XModal v-model="dialogVisible" title="保存表单"> <el-form ref="formRef" :model="formValues" :rules="formRules" label-width="80px"> @@ -48,13 +60,18 @@ import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' import { CommonStatusEnum } from '@/utils/constants' import * as FormApi from '@/api/bpm/form' import { encodeConf, encodeFields, setConfAndFields } from '@/utils/formCreate' +import { useClipboard } from '@vueuse/core' + const { t } = useI18n() // 国际化 const message = useMessage() // 消息 const { query } = useRoute() // 路由 const designer = ref() // 表单设计器 - +const type = ref(-1) +const formValue = ref('') +const dialogTitle = ref('') const dialogVisible = ref(false) // 弹窗是否展示 +const dialogVisible1 = ref(false) // 弹窗是否展示 const dialogLoading = ref(false) // 弹窗的加载中 const formRef = ref<FormInstance>() const formRules = reactive({ @@ -98,7 +115,32 @@ const submitForm = async () => { dialogLoading.value = false } } - +const showJson = () => { + openModel('生成JSON') + type.value = 0 + formValue.value = designer.value.getRule() +} +const showOption = () => { + openModel('生成Options') + type.value = 1 + formValue.value = designer.value.getOption() +} +const openModel = (title: string) => { + dialogVisible1.value = true + dialogTitle.value = title +} +/** 复制 **/ +const copy = async (text: string) => { + const { copy, copied, isSupported } = useClipboard({ source: text }) + if (!isSupported) { + message.error(t('common.copyError')) + } else { + await copy() + if (unref(copied)) { + message.success(t('common.copySuccess')) + } + } +} // ========== 初始化 ========== onMounted(() => { // 场景一:新增表单 diff --git a/src/views/bpm/group/group.data.ts b/src/views/bpm/group/group.data.ts index 9d30f3b2..613a7290 100644 --- a/src/views/bpm/group/group.data.ts +++ b/src/views/bpm/group/group.data.ts @@ -16,6 +16,7 @@ const crudSchemas = reactive<VxeCrudSchema>({ primaryType: 'id', primaryTitle: '编号', action: true, + searchSpan: 8, columns: [ { title: '组名', diff --git a/src/views/bpm/group/index.vue b/src/views/bpm/group/index.vue index 7aa2ca4a..b0f08516 100644 --- a/src/views/bpm/group/index.vue +++ b/src/views/bpm/group/index.vue @@ -43,7 +43,7 @@ </XTable> </ContentWrap> - <XModal v-model="dialogVisible" :title="dialogTitle"> + <XModal v-model="dialogVisible" :title="dialogTitle" :mask-closable="false"> <!-- 对话框(添加 / 修改) --> <Form v-if="['create', 'update'].includes(actionType)" diff --git a/src/views/bpm/model/index.vue b/src/views/bpm/model/index.vue index 5fafb960..298b0b6e 100644 --- a/src/views/bpm/model/index.vue +++ b/src/views/bpm/model/index.vue @@ -24,6 +24,10 @@ <template #name_default="{ row }"> <XTextButton :title="row.name" @click="handleBpmnDetail(row.id)" /> </template> + <!-- 流程分类 --> + <template #category_default="{ row }"> + <DictTag :type="DICT_TYPE.BPM_MODEL_CATEGORY" :value="Number(row?.category)" /> + </template> <!-- 表单信息 --> <template #formId_default="{ row }"> <XTextButton @@ -429,6 +433,11 @@ const handleUpdate = async (rowId: number) => { await setDialogTile('edit') // 设置数据 saveForm.value = await ModelApi.getModelApi(rowId) + if (saveForm.value.category == null) { + saveForm.value.category = 1 + } else { + saveForm.value.category = Number(saveForm.value.category) + } } // 提交按钮 diff --git a/src/views/bpm/model/model.data.ts b/src/views/bpm/model/model.data.ts index ebbc5b87..89e886cc 100644 --- a/src/views/bpm/model/model.data.ts +++ b/src/views/bpm/model/model.data.ts @@ -44,7 +44,12 @@ const crudSchemas = reactive<VxeCrudSchema>({ field: 'category', dictType: DICT_TYPE.BPM_MODEL_CATEGORY, dictClass: 'number', - isSearch: true + isSearch: true, + table: { + slots: { + default: 'category_default' + } + } }, { title: '表单信息', diff --git a/src/views/bpm/model/modelEditor.vue b/src/views/bpm/model/modelEditor.vue index b5a41344..43836976 100644 --- a/src/views/bpm/model/modelEditor.vue +++ b/src/views/bpm/model/modelEditor.vue @@ -108,7 +108,7 @@ const initModeler = (item) => { const save = (bpmnXml) => { const data: ModelVO = { - ...model.value, + ...(model.value ?? ({} as ModelVO)), bpmnXml: bpmnXml // bpmnXml 只是初始化流程图,后续修改无法通过它获得 } console.log(data, 'data') diff --git a/src/views/bpm/oa/leave/detail.vue b/src/views/bpm/oa/leave/detail.vue index bb30d075..25ac9981 100644 --- a/src/views/bpm/oa/leave/detail.vue +++ b/src/views/bpm/oa/leave/detail.vue @@ -2,6 +2,7 @@ <ContentWrap> <!-- 详情 --> <Descriptions :schema="allSchemas.detailSchema" :data="formData" /> + <el-button @click="routerReturn" type="primary">返回</el-button> </ContentWrap> </template> @@ -9,7 +10,8 @@ // 业务相关的 import import * as LeaveApi from '@/api/bpm/leave' import { allSchemas } from '@/views/bpm/oa/leave/leave.data' - +import { useRouter } from 'vue-router' +const router = useRouter() const { query } = useRoute() // 查询参数 const message = useMessage() // 消息弹窗 @@ -22,6 +24,10 @@ const formData = ref({ reason: undefined }) +const routerReturn = () => { + router.back() +} + onMounted(() => { id.value = query.id if (!id.value) { diff --git a/src/views/bpm/oa/leave/leave.data.ts b/src/views/bpm/oa/leave/leave.data.ts index da113baf..5b6f2c52 100644 --- a/src/views/bpm/oa/leave/leave.data.ts +++ b/src/views/bpm/oa/leave/leave.data.ts @@ -16,6 +16,7 @@ const crudSchemas = reactive<VxeCrudSchema>({ primaryTitle: '申请编号', action: true, actionWidth: '260', + searchSpan: 8, columns: [ { title: t('common.status'), diff --git a/src/views/bpm/processInstance/create.vue b/src/views/bpm/processInstance/create.vue index c0542b22..1b59ec7c 100644 --- a/src/views/bpm/processInstance/create.vue +++ b/src/views/bpm/processInstance/create.vue @@ -3,6 +3,10 @@ <!-- 第一步,通过流程定义的列表,选择对应的流程 --> <div v-if="!selectProcessInstance"> <XTable @register="registerTable"> + <!-- 流程分类 --> + <template #category_default="{ row }"> + <DictTag :type="DICT_TYPE.BPM_MODEL_CATEGORY" :value="Number(row?.category)" /> + </template> <template #version_default="{ row }"> <el-tag v-if="row">v{{ row.version }}</el-tag> </template> @@ -55,7 +59,8 @@ import { allSchemas } from './process.create' import * as DefinitionApi from '@/api/bpm/definition' import * as ProcessInstanceApi from '@/api/bpm/processInstance' import { setConfAndFields2 } from '@/utils/formCreate' -import { ApiAttrs } from '@form-create/element-ui/types/config' +import type { ApiAttrs } from '@form-create/element-ui/types/config' +import { DICT_TYPE } from '@/utils/dict' const router = useRouter() // 路由 const message = useMessage() // 消息 diff --git a/src/views/bpm/processInstance/detail.vue b/src/views/bpm/processInstance/detail.vue index 7bd89deb..b6d52a4c 100644 --- a/src/views/bpm/processInstance/detail.vue +++ b/src/views/bpm/processInstance/detail.vue @@ -404,9 +404,9 @@ const getDetail = () => { data.formVariables ) nextTick().then(() => { - fApi.value?.btn.show(false) - fApi.value?.resetBtn.show(false) - fApi.value?.disabled(true) + fApi.value?.fapi?.btn.show(false) + fApi.value?.fapi?.resetBtn.show(false) + fApi.value?.fapi?.disabled(true) }) } diff --git a/src/views/bpm/processInstance/index.vue b/src/views/bpm/processInstance/index.vue index d2f81753..f43e53ef 100644 --- a/src/views/bpm/processInstance/index.vue +++ b/src/views/bpm/processInstance/index.vue @@ -7,11 +7,15 @@ <XButton type="primary" preIcon="ep:zoom-in" - title="新建流程" + title="发起流程" v-hasPermi="['bpm:process-instance:query']" @click="handleCreate" /> </template> + <!-- 流程分类 --> + <template #category_default="{ row }"> + <DictTag :type="DICT_TYPE.BPM_MODEL_CATEGORY" :value="Number(row?.category)" /> + </template> <!-- 当前审批任务 --> <template #tasks_default="{ row }"> <el-button v-for="task in row.tasks" :key="task.id" link> @@ -40,6 +44,7 @@ <script setup lang="ts"> // 全局相关的 import import { ElMessageBox } from 'element-plus' +import { DICT_TYPE } from '@/utils/dict' // 业务相关的 import import * as ProcessInstanceApi from '@/api/bpm/processInstance' diff --git a/src/views/bpm/processInstance/process.create.ts b/src/views/bpm/processInstance/process.create.ts index b2282406..7516c0b4 100644 --- a/src/views/bpm/processInstance/process.create.ts +++ b/src/views/bpm/processInstance/process.create.ts @@ -14,7 +14,12 @@ const crudSchemas = reactive<VxeCrudSchema>({ title: '流程分类', field: 'category', dictType: DICT_TYPE.BPM_MODEL_CATEGORY, - dictClass: 'number' + dictClass: 'number', + table: { + slots: { + default: 'category_default' + } + } }, { title: '流程版本', diff --git a/src/views/bpm/processInstance/process.data.ts b/src/views/bpm/processInstance/process.data.ts index 883f4687..317e143d 100644 --- a/src/views/bpm/processInstance/process.data.ts +++ b/src/views/bpm/processInstance/process.data.ts @@ -33,7 +33,12 @@ const crudSchemas = reactive<VxeCrudSchema>({ field: 'category', dictType: DICT_TYPE.BPM_MODEL_CATEGORY, dictClass: 'number', - isSearch: true + isSearch: true, + table: { + slots: { + default: 'category_default' + } + } }, { title: '当前审批任务', diff --git a/src/views/bpm/task/done/index.vue b/src/views/bpm/task/done/index.vue index 31df7bd9..da05549a 100644 --- a/src/views/bpm/task/done/index.vue +++ b/src/views/bpm/task/done/index.vue @@ -21,6 +21,7 @@ const { push } = useRouter() // 路由 const [registerTable] = useXTable({ allSchemas: allSchemas, + topActionSlots: false, getListApi: TaskApi.getDoneTaskPage }) diff --git a/src/views/bpm/task/todo/index.vue b/src/views/bpm/task/todo/index.vue index 86208602..bc21c597 100644 --- a/src/views/bpm/task/todo/index.vue +++ b/src/views/bpm/task/todo/index.vue @@ -22,6 +22,7 @@ const { push } = useRouter() // 路由 const [registerTable] = useXTable({ allSchemas: allSchemas, + topActionSlots: false, getListApi: TaskApi.getTodoTaskPage }) diff --git a/src/views/bpm/task/todo/todo.data.ts b/src/views/bpm/task/todo/todo.data.ts index 85c58ce9..419a80fe 100644 --- a/src/views/bpm/task/todo/todo.data.ts +++ b/src/views/bpm/task/todo/todo.data.ts @@ -7,6 +7,7 @@ const crudSchemas = reactive<VxeCrudSchema>({ primaryKey: 'id', primaryType: null, action: true, + searchSpan: 8, columns: [ { title: '任务编号', diff --git a/src/views/bpm/taskAssignRule/index.vue b/src/views/bpm/taskAssignRule/index.vue index f93e4591..012e6f68 100644 --- a/src/views/bpm/taskAssignRule/index.vue +++ b/src/views/bpm/taskAssignRule/index.vue @@ -1,7 +1,7 @@ <template> <ContentWrap> <!-- 列表 --> - <XTable @register="registerTable"> + <XTable @register="registerTable" ref="xGrid"> <template #options_default="{ row }"> <span :key="option" v-for="option in row.options"> <el-tag> @@ -45,9 +45,9 @@ <el-select v-model="formData.roleIds" multiple clearable style="width: 100%"> <el-option v-for="item in roleOptions" - :key="parseInt(item.id)" + :key="item.id" :label="item.name" - :value="parseInt(item.id)" + :value="item.id" /> </el-select> </el-form-item> @@ -145,11 +145,12 @@ import { listSimpleUserGroupsApi } from '@/api/bpm/userGroup' import { listSimpleDeptApi } from '@/api/system/dept' import { DICT_TYPE, getDictOptions } from '@/utils/dict' import { handleTree, defaultProps } from '@/utils/tree' -import { allSchemas, rules } from './taskAssignRule.data' +import { allSchemas, rules, idShowActionClick } from './taskAssignRule.data' const { t } = useI18n() // 国际化 const message = useMessage() // 消息弹窗 const { query } = useRoute() +const xGrid = ref() // ========== 列表相关 ========== @@ -165,6 +166,8 @@ const taskAssignScriptDictDatas = getDictOptions(DICT_TYPE.BPM_TASK_ASSIGN_SCRIP const modelId = query.modelId // 流程定义的编号。如果 processDefinitionId 非空,则用于流程定义的查看,不支持配置 const processDefinitionId = query.processDefinitionId +let isShow = idShowActionClick(modelId) + // 查询参数 const queryParams = reactive({ modelId: modelId, @@ -346,5 +349,10 @@ onMounted(() => { listSimpleUserGroupsApi().then((data) => { userGroupOptions.value.push(...data) }) + if (!isShow) { + setTimeout(() => { + xGrid.value.Ref.hideColumn('actionbtns') + }, 100) + } }) </script> diff --git a/src/views/bpm/taskAssignRule/taskAssignRule.data.ts b/src/views/bpm/taskAssignRule/taskAssignRule.data.ts index 1ced3425..cad74325 100644 --- a/src/views/bpm/taskAssignRule/taskAssignRule.data.ts +++ b/src/views/bpm/taskAssignRule/taskAssignRule.data.ts @@ -43,4 +43,12 @@ const crudSchemas = reactive<VxeCrudSchema>({ } ] }) + +export const idShowActionClick = (modelId?: any) => { + if (modelId) { + return true + } else { + return false + } +} export const { allSchemas } = useVxeCrudSchemas(crudSchemas) diff --git a/src/views/infra/server/index.vue b/src/views/infra/server/index.vue index 8e748b26..cc7590d6 100644 --- a/src/views/infra/server/index.vue +++ b/src/views/infra/server/index.vue @@ -3,7 +3,7 @@ <IFrame :src="src" /> </ContentWrap> </template> -<script setup lang="ts" name="Server"> +<script setup lang="ts" name="AdminServer"> const BASE_URL = import.meta.env.VITE_BASE_URL const src = ref(BASE_URL + '/admin/applications') </script> diff --git a/src/views/report/jmreport/index.vue b/src/views/report/jmreport/index.vue index 3e33ad3a..bae999f4 100644 --- a/src/views/report/jmreport/index.vue +++ b/src/views/report/jmreport/index.vue @@ -3,7 +3,7 @@ <IFrame :src="src" /> </ContentWrap> </template> -<script setup lang="ts" name="Jmreport"> +<script setup lang="ts" name="JimuReport"> import { getAccessToken } from '@/utils/auth' const BASE_URL = import.meta.env.VITE_BASE_URL diff --git a/src/views/system/dept/dept.data.ts b/src/views/system/dept/dept.data.ts index 5e3d0761..c6945841 100644 --- a/src/views/system/dept/dept.data.ts +++ b/src/views/system/dept/dept.data.ts @@ -6,7 +6,15 @@ const { t } = useI18n() // 国际化 export const rules = reactive({ name: [required], sort: [required], - email: [required], + // email: [required], + email: [ + { required: true, message: t('profile.rules.mail'), trigger: 'blur' }, + { + type: 'email', + message: t('profile.rules.truemail'), + trigger: ['blur', 'change'] + } + ], phone: [ { len: 11, diff --git a/src/views/system/dict/index.vue b/src/views/system/dict/index.vue index d4cce484..713fde97 100644 --- a/src/views/system/dict/index.vue +++ b/src/views/system/dict/index.vue @@ -179,6 +179,7 @@ const tableTypeSelect = ref(false) const cellClickEvent: VxeTableEvents.CellClick = async ({ row }) => { tableTypeSelect.value = true queryParams.dictType = row['type'] + await nextTick() await dataGetList() parentType.value = row['type'] } @@ -197,6 +198,11 @@ const setDialogTile = (type: string) => { dialogVisible.value = true } +// 同步dictTypeValue到form 否则导致表单验证不通过 +watch(dictTypeValue, (val) => { + unref(typeFormRef)?.setValues({ type: val }) +}) + // 提交按钮 const submitTypeForm = async () => { const elForm = unref(typeFormRef)?.getElFormRef() diff --git a/src/views/system/errorCode/errorCode.data.ts b/src/views/system/errorCode/errorCode.data.ts index 36f5e4c5..4736068b 100644 --- a/src/views/system/errorCode/errorCode.data.ts +++ b/src/views/system/errorCode/errorCode.data.ts @@ -11,7 +11,7 @@ export const rules = reactive({ // 新增 + 修改 const crudSchemas = reactive<VxeCrudSchema>({ primaryKey: 'id', - primaryType: 'seq', + primaryType: 'id', primaryTitle: '编号', action: true, columns: [ diff --git a/src/views/system/loginlog/loginLog.data.ts b/src/views/system/loginlog/loginLog.data.ts index 75988e43..c0a51fbe 100644 --- a/src/views/system/loginlog/loginLog.data.ts +++ b/src/views/system/loginlog/loginLog.data.ts @@ -3,7 +3,7 @@ import type { VxeCrudSchema } from '@/hooks/web/useVxeCrudSchemas' // CrudSchema const crudSchemas = reactive<VxeCrudSchema>({ primaryKey: 'id', - primaryType: 'seq', + primaryType: 'id', primaryTitle: '日志编号', action: true, actionWidth: '100px', diff --git a/src/views/system/mail/account/account.data.ts b/src/views/system/mail/account/account.data.ts index a2e29f85..bd05ce4f 100644 --- a/src/views/system/mail/account/account.data.ts +++ b/src/views/system/mail/account/account.data.ts @@ -1,8 +1,18 @@ import type { VxeCrudSchema } from '@/hooks/web/useVxeCrudSchemas' +const { t } = useI18n() // 国际化 + // 表单校验 export const rules = reactive({ - mail: [required], + // mail: [required], + mail: [ + { required: true, message: t('profile.rules.mail'), trigger: 'blur' }, + { + type: 'email', + message: t('profile.rules.truemail'), + trigger: ['blur', 'change'] + } + ], username: [required], password: [required], host: [required], diff --git a/src/views/system/mail/log/index.vue b/src/views/system/mail/log/index.vue index 7983e3c8..e147c52c 100644 --- a/src/views/system/mail/log/index.vue +++ b/src/views/system/mail/log/index.vue @@ -59,6 +59,7 @@ const queryParams = reactive({ }) const [registerTable] = useXTable({ allSchemas: allSchemas, + topActionSlots: false, params: queryParams, getListApi: MailLogApi.getMailLogPageApi }) diff --git a/src/views/system/notify/message/index.vue b/src/views/system/notify/message/index.vue index cb904d27..93a8ed68 100644 --- a/src/views/system/notify/message/index.vue +++ b/src/views/system/notify/message/index.vue @@ -37,6 +37,7 @@ const { t } = useI18n() // 国际化 // 列表相关的变量 const [registerTable] = useXTable({ allSchemas: allSchemas, + topActionSlots: false, getListApi: NotifyMessageApi.getNotifyMessagePageApi }) diff --git a/src/views/system/notify/message/message.data.ts b/src/views/system/notify/message/message.data.ts index ff5eb315..665311d2 100644 --- a/src/views/system/notify/message/message.data.ts +++ b/src/views/system/notify/message/message.data.ts @@ -4,7 +4,7 @@ import type { VxeCrudSchema } from '@/hooks/web/useVxeCrudSchemas' const crudSchemas = reactive<VxeCrudSchema>({ primaryKey: 'id', // 默认的主键ID primaryTitle: '编号', // 默认显示的值 - primaryType: 'seq', // 默认为seq,序号模式 + primaryType: 'id', // 默认为seq,序号模式 action: true, actionWidth: '200', // 3个按钮默认200,如有删减对应增减即可 columns: [ diff --git a/src/views/system/notify/my/index.vue b/src/views/system/notify/my/index.vue index 620a7430..9f3e9b10 100644 --- a/src/views/system/notify/my/index.vue +++ b/src/views/system/notify/my/index.vue @@ -35,7 +35,7 @@ const [registerTable, { reload, getCheckboxRecords }] = useXTable({ }) const handleUpdateList = async () => { - const list = getCheckboxRecords() + const list = getCheckboxRecords() as any as any[] if (list.length === 0) { return } diff --git a/src/views/system/operatelog/operatelog.data.ts b/src/views/system/operatelog/operatelog.data.ts index e0f0578b..f8b4ef90 100644 --- a/src/views/system/operatelog/operatelog.data.ts +++ b/src/views/system/operatelog/operatelog.data.ts @@ -4,7 +4,7 @@ const { t } = useI18n() // 国际化 const crudSchemas = reactive<VxeCrudSchema>({ primaryKey: 'id', - primaryType: 'seq', + primaryType: 'id', primaryTitle: '日志编号', action: true, actionWidth: '80px', diff --git a/src/views/system/role/index.vue b/src/views/system/role/index.vue index 72c602c1..da4b8389 100644 --- a/src/views/system/role/index.vue +++ b/src/views/system/role/index.vue @@ -99,37 +99,46 @@ </el-select> </el-form-item> <!-- 分配角色的菜单权限对话框 --> - <el-form-item - label="权限范围" - v-if=" - actionScopeType === 'menu' || dataScopeForm.dataScope === SystemDataScopeEnum.DEPT_CUSTOM - " - > - <el-card shadow="never"> - <template #header> - 父子联动(选中父节点,自动选择子节点): - <el-switch v-model="checkStrictly" inline-prompt active-text="是" inactive-text="否" /> - 全选/全不选: - <el-switch - v-model="treeNodeAll" - inline-prompt - active-text="是" - inactive-text="否" - @change="handleCheckedTreeNodeAll()" - /> - </template> - <el-tree - ref="treeRef" - node-key="id" - show-checkbox - :default-checked-keys="defaultCheckedKeys" - :check-strictly="!checkStrictly" - :props="defaultProps" - :data="treeOptions" - empty-text="加载中,请稍后" - /> - </el-card> - </el-form-item> + <el-row> + <el-col :span="24"> + <el-form-item + label="权限范围" + v-if=" + actionScopeType === 'menu' || + dataScopeForm.dataScope === SystemDataScopeEnum.DEPT_CUSTOM + " + style="display: flex" + > + <el-card class="card" shadow="never"> + <template #header> + 父子联动(选中父节点,自动选择子节点): + <el-switch + v-model="checkStrictly" + inline-prompt + active-text="是" + inactive-text="否" + /> + 全选/全不选: + <el-switch + v-model="treeNodeAll" + inline-prompt + active-text="是" + inactive-text="否" + @change="handleCheckedTreeNodeAll()" + /> + </template> + <el-tree + ref="treeRef" + node-key="id" + show-checkbox + :check-strictly="!checkStrictly" + :props="defaultProps" + :data="treeOptions" + empty-text="加载中,请稍后" + /> + </el-card> + </el-form-item> </el-col + ></el-row> </el-form> <!-- 操作按钮 --> <template #footer> @@ -245,7 +254,6 @@ const dialogScopeVisible = ref(false) const dialogScopeTitle = ref('数据权限') const actionScopeType = ref('') const dataScopeDictDatas = ref() -const defaultCheckedKeys = ref() // 选项 const checkStrictly = ref(true) const treeNodeAll = ref(false) @@ -258,13 +266,16 @@ const handleScope = async (type: string, row: RoleApi.RoleVO) => { dataScopeForm.id = row.id dataScopeForm.name = row.name dataScopeForm.code = row.code + actionScopeType.value = type + dialogScopeVisible.value = true if (type === 'menu') { const menuRes = await listSimpleMenusApi() treeOptions.value = handleTree(menuRes) const role = await PermissionApi.listRoleMenusApi(row.id) if (role) { - // treeRef.value!.setCheckedKeys(role as unknown as Array<number>) - defaultCheckedKeys.value = role + role?.forEach((item: any) => { + unref(treeRef)?.setChecked(item, true, false) + }) } } else if (type === 'data') { const deptRes = await listSimpleDeptApi() @@ -272,12 +283,11 @@ const handleScope = async (type: string, row: RoleApi.RoleVO) => { const role = await RoleApi.getRoleApi(row.id) dataScopeForm.dataScope = role.dataScope if (role.dataScopeDeptIds) { - // treeRef.value!.setCheckedKeys(role.dataScopeDeptIds as unknown as Array<number>, false) - defaultCheckedKeys.value = role.dataScopeDeptIds + role.dataScopeDeptIds?.forEach((item: any) => { + unref(treeRef)?.setChecked(item, true, false) + }) } } - actionScopeType.value = type - dialogScopeVisible.value = true } // 保存权限 const submitScope = async () => { @@ -312,3 +322,10 @@ onMounted(() => { init() }) </script> +<style scoped> +.card { + width: 100%; + max-height: 400px; + overflow-y: scroll; +} +</style> diff --git a/src/views/system/role/role.data.ts b/src/views/system/role/role.data.ts index fef2ec47..d55b5e21 100644 --- a/src/views/system/role/role.data.ts +++ b/src/views/system/role/role.data.ts @@ -9,12 +9,19 @@ export const rules = reactive({ }) // CrudSchema const crudSchemas = reactive<VxeCrudSchema>({ - primaryKey: 'id', - primaryTitle: '角色编号', - primaryType: 'seq', + // primaryKey: 'id', + // primaryTitle: '角色编号', + // primaryType: 'seq', action: true, actionWidth: '400px', columns: [ + { + title: '角色编号', + field: 'id', + table: { + width: 200 + } + }, { title: '角色名称', field: 'name', diff --git a/src/views/system/sensitiveWord/sensitiveWord.data.ts b/src/views/system/sensitiveWord/sensitiveWord.data.ts index 79c90e6c..d21bb94c 100644 --- a/src/views/system/sensitiveWord/sensitiveWord.data.ts +++ b/src/views/system/sensitiveWord/sensitiveWord.data.ts @@ -10,7 +10,7 @@ export const rules = reactive({ // CrudSchema const crudSchemas = reactive<VxeCrudSchema>({ primaryKey: 'id', - primaryType: 'seq', + primaryType: 'id', primaryTitle: '敏感词编号', action: true, columns: [ diff --git a/src/views/system/sms/smsChannel/sms.channel.data.ts b/src/views/system/sms/smsChannel/sms.channel.data.ts index cc014469..d3a807ed 100644 --- a/src/views/system/sms/smsChannel/sms.channel.data.ts +++ b/src/views/system/sms/smsChannel/sms.channel.data.ts @@ -12,7 +12,7 @@ export const rules = reactive({ // CrudSchema const crudSchemas = reactive<VxeCrudSchema>({ primaryKey: 'id', - primaryType: 'seq', + primaryType: 'id', primaryTitle: '渠道编号', action: true, columns: [ diff --git a/src/views/system/sms/smsLog/sms.log.data.ts b/src/views/system/sms/smsLog/sms.log.data.ts index 501a5a2b..4610ee62 100644 --- a/src/views/system/sms/smsLog/sms.log.data.ts +++ b/src/views/system/sms/smsLog/sms.log.data.ts @@ -4,7 +4,7 @@ const { t } = useI18n() // 国际化 // CrudSchema const crudSchemas = reactive<VxeCrudSchema>({ primaryKey: 'id', - primaryType: 'seq', + primaryType: 'id', primaryTitle: '日志编号', action: true, columns: [ diff --git a/src/views/system/sms/smsTemplate/sms.template.data.ts b/src/views/system/sms/smsTemplate/sms.template.data.ts index 2fb46fda..514a503a 100644 --- a/src/views/system/sms/smsTemplate/sms.template.data.ts +++ b/src/views/system/sms/smsTemplate/sms.template.data.ts @@ -15,7 +15,7 @@ export const rules = reactive({ // CrudSchema const crudSchemas = reactive<VxeCrudSchema>({ primaryKey: 'id', - primaryType: 'seq', + primaryType: 'id', primaryTitle: '模板编号', action: true, actionWidth: '280', diff --git a/src/views/system/tenant/tenant.data.ts b/src/views/system/tenant/tenant.data.ts index 7e81138c..2aab1b90 100644 --- a/src/views/system/tenant/tenant.data.ts +++ b/src/views/system/tenant/tenant.data.ts @@ -27,6 +27,24 @@ export const rules = reactive({ contactMobile: [required], accountCount: [required], expireTime: [required], + username: [ + required, + { + min: 4, + max: 30, + trigger: 'blur', + message: '用户名称长度为 4-30 个字符' + } + ], + password: [ + required, + { + min: 4, + max: 16, + trigger: 'blur', + message: '密码长度为 4-16 位' + } + ], domain: [required], status: [required] }) @@ -35,7 +53,7 @@ export const rules = reactive({ const crudSchemas = reactive<VxeCrudSchema>({ primaryKey: 'id', primaryTitle: '租户编号', - primaryType: 'seq', + primaryType: 'id', action: true, columns: [ { diff --git a/src/views/system/tenantPackage/index.vue b/src/views/system/tenantPackage/index.vue index a665b8af..9222365b 100644 --- a/src/views/system/tenantPackage/index.vue +++ b/src/views/system/tenantPackage/index.vue @@ -25,7 +25,7 @@ ref="formRef" > <template #menuIds> - <el-card class="w-120"> + <el-card> <template #header> <div class="card-header"> 全选/全不选: @@ -91,6 +91,16 @@ const dialogTitle = ref('edit') // 弹出层标题 const handleCheckedTreeNodeAll = () => { treeRef.value!.setCheckedNodes(treeNodeAll.value ? menuOptions.value : []) } + +const validateCategory = (rule: any, value: any, callback: any) => { + if (!treeRef.value!.getCheckedKeys().length) { + callback(new Error('该项为必填项')) + } else { + callback() + } +} +rules.menuIds = [{ required: true, validator: validateCategory, trigger: 'blur' }] + const getTree = async () => { const res = await listSimpleMenusApi() menuOptions.value = handleTree(res) @@ -125,7 +135,9 @@ const handleUpdate = async (rowId: number) => { const res = await TenantPackageApi.getTenantPackageApi(rowId) unref(formRef)?.setValues(res) // 设置选中 - unref(treeRef)?.setCheckedKeys(res.menuIds) + res.menuIds?.forEach((item: any) => { + unref(treeRef)?.setChecked(item, true, false) + }) } // 提交按钮 @@ -166,3 +178,10 @@ onMounted(async () => { }) // getList() </script> +<style scoped> +.el-card { + width: 100%; + max-height: 400px; + overflow-y: scroll; +} +</style> diff --git a/src/views/system/tenantPackage/tenantPackage.data.ts b/src/views/system/tenantPackage/tenantPackage.data.ts index e28ea842..47db56d4 100644 --- a/src/views/system/tenantPackage/tenantPackage.data.ts +++ b/src/views/system/tenantPackage/tenantPackage.data.ts @@ -14,7 +14,7 @@ export const rules = reactive({ // CrudSchema const crudSchemas = reactive<VxeCrudSchema>({ primaryKey: 'id', - primaryType: 'seq', + primaryType: 'id', primaryTitle: '套餐编号', action: true, columns: [ @@ -33,7 +33,12 @@ const crudSchemas = reactive<VxeCrudSchema>({ { title: '菜单权限', field: 'menuIds', - isTable: false + isTable: false, + form: { + colProps: { + span: 24 + } + } }, { title: t('form.remark'), diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue index d125112d..2f9ba9b0 100644 --- a/src/views/system/user/index.vue +++ b/src/views/system/user/index.vue @@ -159,7 +159,7 @@ :data="detailData" > <template #deptId="{ row }"> - <span>{{ row.dept?.name }}</span> + <el-tag>{{ dataFormater(row.deptId) }}</el-tag> </template> <template #postIds="{ row }"> <template v-if="row.postIds !== ''"> @@ -332,6 +332,28 @@ const getPostOptions = async () => { const res = await listSimplePostsApi() postOptions.value.push(...res) } +const dataFormater = (val) => { + return deptFormater(deptOptions.value, val) +} +//部门回显 +const deptFormater = (ary, val: any) => { + var o = '' + if (ary && val) { + for (const v of ary) { + if (v.id == val) { + o = v.name + if (o) return o + } else if (v.children?.length) { + o = deptFormater(v.children, val) + if (o) return o + } + } + return o + } else { + return val + } +} + // 设置标题 const setDialogTile = async (type: string) => { dialogTitle.value = t('action.' + type) @@ -386,24 +408,31 @@ const handleDetail = async (rowId: number) => { // 提交按钮 const submitForm = async () => { - loading.value = true - // 提交请求 - try { - const data = unref(formRef)?.formModel as UserApi.UserVO - if (actionType.value === 'create') { - await UserApi.createUserApi(data) - message.success(t('common.createSuccess')) - } else { - await UserApi.updateUserApi(data) - message.success(t('common.updateSuccess')) + const elForm = unref(formRef)?.getElFormRef() + if (!elForm) return + elForm.validate(async (valid) => { + if (valid) { + // 提交请求 + try { + const data = unref(formRef)?.formModel as UserApi.UserVO + if (actionType.value === 'create') { + loading.value = true + await UserApi.createUserApi(data) + message.success(t('common.createSuccess')) + } else { + loading.value = true + await UserApi.updateUserApi(data) + message.success(t('common.updateSuccess')) + } + dialogVisible.value = false + } finally { + // unref(formRef)?.setSchema(allSchemas.formSchema) + // 刷新列表 + await reload() + loading.value = false + } } - dialogVisible.value = false - } finally { - // unref(formRef)?.setSchema(allSchemas.formSchema) - // 刷新列表 - await reload() - loading.value = false - } + }) } // 改变用户状态操作 const handleStatusChange = async (row: UserApi.UserVO) => { diff --git a/src/views/system/user/user.data.ts b/src/views/system/user/user.data.ts index c5b617c3..94b1d436 100644 --- a/src/views/system/user/user.data.ts +++ b/src/views/system/user/user.data.ts @@ -5,10 +5,20 @@ const { t } = useI18n() export const rules = reactive({ username: [required], nickname: [required], - email: [required], + password: [required], + deptId: [required], + email: [ + { required: true, message: t('profile.rules.mail'), trigger: 'blur' }, + { + type: 'email', + message: t('profile.rules.truemail'), + trigger: ['blur', 'change'] + } + ], status: [required], mobile: [ { + required: true, len: 11, trigger: 'blur', message: '请输入正确的手机号码' @@ -18,7 +28,7 @@ export const rules = reactive({ // crudSchemas const crudSchemas = reactive<VxeCrudSchema>({ primaryKey: 'id', - primaryType: 'seq', + primaryType: 'id', primaryTitle: '用户编号', action: true, actionWidth: '200px', diff --git a/types/env.d.ts b/types/env.d.ts index b34d037d..e5861e32 100644 --- a/types/env.d.ts +++ b/types/env.d.ts @@ -11,7 +11,7 @@ interface ImportMetaEnv { readonly VITE_APP_TITLE: string readonly VITE_PORT: number readonly VITE_OPEN: string - readonly VITE_DEV: boolean + readonly VITE_DEV: string readonly VITE_APP_CAPTCHA_ENABLE: string readonly VITE_APP_TENANT_ENABLE: string readonly VITE_BASE_URL: string diff --git a/types/global.d.ts b/types/global.d.ts index 3179c200..3685ffbd 100644 --- a/types/global.d.ts +++ b/types/global.d.ts @@ -1,4 +1,4 @@ -import type { CSSProperties } from 'vue' +export {} declare global { declare interface Fn<T = any> { (...arg: T[]): T diff --git a/vite.config.ts b/vite.config.ts index e5572436..6b54e183 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -31,15 +31,15 @@ export default ({ command, mode }: ConfigEnv): UserConfig => { port: env.VITE_PORT, host: "0.0.0.0", open: env.VITE_OPEN === 'true', - // 本地跨域代理 - proxy: { - ['/admin-api']: { - target: env.VITE_BASE_URL, - ws: false, - changeOrigin: true, - rewrite: (path) => path.replace(new RegExp(`^/admin-api`), ''), - }, - }, + // 本地跨域代理. 目前注释的原因:暂时没有用途,server 端已经支持跨域 + // proxy: { + // ['/admin-api']: { + // target: env.VITE_BASE_URL, + // ws: false, + // changeOrigin: true, + // rewrite: (path) => path.replace(new RegExp(`^/admin-api`), ''), + // }, + // }, }, // 项目使用的vite插件。 单独提取到build/vite/plugin中管理 plugins: createVitePlugins(env.VITE_APP_TITLE),