Compare commits
76 Commits
pr@dev@k8s
...
v4.8.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
68030d98b2 | ||
|
|
a861f77609 | ||
|
|
e58ec6057c | ||
|
|
7ab20c5885 | ||
|
|
e47ddb5355 | ||
|
|
56aa3caa83 | ||
|
|
19b1dc0dbc | ||
|
|
77ef172a23 | ||
|
|
4596887bf1 | ||
|
|
0a3dc30c85 | ||
|
|
51d24bc8e5 | ||
|
|
1b15a4d043 | ||
|
|
7d3f818242 | ||
|
|
4e26f18d77 | ||
|
|
b22613617a | ||
|
|
e971cbf4a8 | ||
|
|
4672abae35 | ||
|
|
ba36d72602 | ||
|
|
4bfbbba4c5 | ||
|
|
ea038ce43a | ||
|
|
e16b19666c | ||
|
|
c7f5409eb6 | ||
|
|
fdbd7d2222 | ||
|
|
ddbaeeafea | ||
|
|
efb0e9dacb | ||
|
|
f6f8301ad5 | ||
|
|
9a63ae63d4 | ||
|
|
1e007ccda3 | ||
|
|
d1d0b06b53 | ||
|
|
5fb70d2f24 | ||
|
|
b54a95430f | ||
|
|
4d8b4c45af | ||
|
|
a6d642df60 | ||
|
|
2e74f1522f | ||
|
|
fe615e0314 | ||
|
|
09f734e6fc | ||
|
|
3117046342 | ||
|
|
b68aecb5cc | ||
|
|
1c9b155d97 | ||
|
|
75b1be9864 | ||
|
|
615c3c1cf4 | ||
|
|
4d82231af4 | ||
|
|
c6cf6571b6 | ||
|
|
8ea990d070 | ||
|
|
f4a32170d5 | ||
|
|
073508675e | ||
|
|
1d6ca0a93a | ||
|
|
36aea652d6 | ||
|
|
1a42ce90ab | ||
|
|
31a401b55d | ||
|
|
582a84178d | ||
|
|
9b9f7c936c | ||
|
|
2a6100957f | ||
|
|
16606d6a27 | ||
|
|
0a612f50e6 | ||
|
|
fe36fa9390 | ||
|
|
ba109900ec | ||
|
|
ec7768267f | ||
|
|
cc58b374ab | ||
|
|
04ffbb8fd6 | ||
|
|
49880f6739 | ||
|
|
e6f98d58c4 | ||
|
|
fd1f16d43c | ||
|
|
968b2415b1 | ||
|
|
776090d6ba | ||
|
|
3a37952288 | ||
|
|
62b8fc0e3b | ||
|
|
b2028869cb | ||
|
|
5277a725f8 | ||
|
|
f137788c1a | ||
|
|
f7d17c8de7 | ||
|
|
feea70b0be | ||
|
|
04696ef3d6 | ||
|
|
1731f4f788 | ||
|
|
6f25d93909 | ||
|
|
46461ec324 |
269
.eslintrc.js
@@ -14,97 +14,64 @@ module.exports = {
|
|||||||
window: true,
|
window: true,
|
||||||
_: true
|
_: true
|
||||||
},
|
},
|
||||||
plugins: ['vue', 'spellcheck'],
|
|
||||||
// add your custom rules here
|
// add your custom rules here
|
||||||
// it is base on https://github.com/vuejs/eslint-config-vue
|
// it is base on https://github.com/vuejs/eslint-config-vue
|
||||||
rules: {
|
rules: {
|
||||||
'vue/max-attributes-per-line': [
|
'vue/max-attributes-per-line': [2, {
|
||||||
2,
|
'singleline': 10,
|
||||||
{
|
'multiline': {
|
||||||
singleline: 10,
|
'max': 1,
|
||||||
multiline: {
|
'allowFirstLine': false
|
||||||
max: 1,
|
|
||||||
allowFirstLine: false
|
|
||||||
}
|
}
|
||||||
}
|
}],
|
||||||
],
|
|
||||||
'vue/singleline-html-element-content-newline': 'off',
|
'vue/singleline-html-element-content-newline': 'off',
|
||||||
'vue/multiline-html-element-content-newline': 'off',
|
'vue/multiline-html-element-content-newline': 'off',
|
||||||
'vue/name-property-casing': ['error', 'PascalCase'],
|
'vue/name-property-casing': ['error', 'PascalCase'],
|
||||||
'vue/no-v-html': 'off',
|
'vue/no-v-html': 'off',
|
||||||
'accessor-pairs': 2,
|
'accessor-pairs': 2,
|
||||||
'arrow-spacing': [
|
'arrow-spacing': [2, {
|
||||||
2,
|
'before': true,
|
||||||
{
|
'after': true
|
||||||
before: true,
|
}],
|
||||||
after: true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
'block-spacing': [2, 'always'],
|
'block-spacing': [2, 'always'],
|
||||||
'brace-style': [
|
'brace-style': [2, '1tbs', {
|
||||||
2,
|
'allowSingleLine': true
|
||||||
'1tbs',
|
}],
|
||||||
{
|
'camelcase': [0, {
|
||||||
allowSingleLine: true
|
'properties': 'always'
|
||||||
}
|
}],
|
||||||
],
|
|
||||||
camelcase: [
|
|
||||||
0,
|
|
||||||
{
|
|
||||||
properties: 'always'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
'comma-dangle': [2, 'never'],
|
'comma-dangle': [2, 'never'],
|
||||||
'comma-spacing': [
|
'comma-spacing': [2, {
|
||||||
2,
|
'before': false,
|
||||||
{
|
'after': true
|
||||||
before: false,
|
}],
|
||||||
after: true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
'comma-style': [2, 'last'],
|
'comma-style': [2, 'last'],
|
||||||
'constructor-super': 2,
|
'constructor-super': 2,
|
||||||
curly: [2, 'multi-line'],
|
'curly': [2, 'multi-line'],
|
||||||
'dot-location': [2, 'property'],
|
'dot-location': [2, 'property'],
|
||||||
'eol-last': 2,
|
'eol-last': 2,
|
||||||
eqeqeq: ['error', 'always', { null: 'ignore' }],
|
'eqeqeq': ['error', 'always', { 'null': 'ignore' }],
|
||||||
'generator-star-spacing': [
|
'generator-star-spacing': [2, {
|
||||||
2,
|
'before': true,
|
||||||
{
|
'after': true
|
||||||
before: true,
|
}],
|
||||||
after: true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
'handle-callback-err': [2, '^(err|error)$'],
|
'handle-callback-err': [2, '^(err|error)$'],
|
||||||
indent: [
|
'indent': [2, 2, {
|
||||||
2,
|
'SwitchCase': 1
|
||||||
2,
|
}],
|
||||||
{
|
|
||||||
SwitchCase: 1
|
|
||||||
}
|
|
||||||
],
|
|
||||||
'jsx-quotes': [2, 'prefer-single'],
|
'jsx-quotes': [2, 'prefer-single'],
|
||||||
'key-spacing': [
|
'key-spacing': [2, {
|
||||||
2,
|
'beforeColon': false,
|
||||||
{
|
'afterColon': true
|
||||||
beforeColon: false,
|
}],
|
||||||
afterColon: true
|
'keyword-spacing': [2, {
|
||||||
}
|
'before': true,
|
||||||
],
|
'after': true
|
||||||
'keyword-spacing': [
|
}],
|
||||||
2,
|
'new-cap': [2, {
|
||||||
{
|
'newIsCap': true,
|
||||||
before: true,
|
'capIsNew': false
|
||||||
after: true
|
}],
|
||||||
}
|
|
||||||
],
|
|
||||||
'new-cap': [
|
|
||||||
2,
|
|
||||||
{
|
|
||||||
newIsCap: true,
|
|
||||||
capIsNew: false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
'new-parens': 2,
|
'new-parens': 2,
|
||||||
'no-array-constructor': 2,
|
'no-array-constructor': 2,
|
||||||
'no-caller': 2,
|
'no-caller': 2,
|
||||||
@@ -135,23 +102,17 @@ module.exports = {
|
|||||||
'no-irregular-whitespace': 2,
|
'no-irregular-whitespace': 2,
|
||||||
'no-iterator': 2,
|
'no-iterator': 2,
|
||||||
'no-label-var': 2,
|
'no-label-var': 2,
|
||||||
'no-labels': [
|
'no-labels': [2, {
|
||||||
2,
|
'allowLoop': false,
|
||||||
{
|
'allowSwitch': false
|
||||||
allowLoop: false,
|
}],
|
||||||
allowSwitch: false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
'no-lone-blocks': 2,
|
'no-lone-blocks': 2,
|
||||||
'no-mixed-spaces-and-tabs': 2,
|
'no-mixed-spaces-and-tabs': 2,
|
||||||
'no-multi-spaces': 2,
|
'no-multi-spaces': 2,
|
||||||
'no-multi-str': 2,
|
'no-multi-str': 2,
|
||||||
'no-multiple-empty-lines': [
|
'no-multiple-empty-lines': [2, {
|
||||||
2,
|
'max': 1
|
||||||
{
|
}],
|
||||||
max: 1
|
|
||||||
}
|
|
||||||
],
|
|
||||||
'no-native-reassign': 2,
|
'no-native-reassign': 2,
|
||||||
'no-negated-in-lhs': 2,
|
'no-negated-in-lhs': 2,
|
||||||
'no-new-object': 2,
|
'no-new-object': 2,
|
||||||
@@ -179,126 +140,62 @@ module.exports = {
|
|||||||
'no-undef-init': 2,
|
'no-undef-init': 2,
|
||||||
'no-unexpected-multiline': 2,
|
'no-unexpected-multiline': 2,
|
||||||
'no-unmodified-loop-condition': 2,
|
'no-unmodified-loop-condition': 2,
|
||||||
'no-unneeded-ternary': [
|
'no-unneeded-ternary': [2, {
|
||||||
2,
|
'defaultAssignment': false
|
||||||
{
|
}],
|
||||||
defaultAssignment: false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
'no-unreachable': 2,
|
'no-unreachable': 2,
|
||||||
'no-unsafe-finally': 2,
|
'no-unsafe-finally': 2,
|
||||||
'no-unused-vars': [
|
'no-unused-vars': [2, {
|
||||||
2,
|
'vars': 'all',
|
||||||
{
|
'args': 'none'
|
||||||
vars: 'all',
|
}],
|
||||||
args: 'none'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
'no-useless-call': 2,
|
'no-useless-call': 2,
|
||||||
'no-useless-computed-key': 2,
|
'no-useless-computed-key': 2,
|
||||||
'no-useless-constructor': 2,
|
'no-useless-constructor': 2,
|
||||||
'no-useless-escape': 0,
|
'no-useless-escape': 0,
|
||||||
'no-whitespace-before-property': 2,
|
'no-whitespace-before-property': 2,
|
||||||
'no-with': 2,
|
'no-with': 2,
|
||||||
'one-var': [
|
'one-var': [2, {
|
||||||
2,
|
'initialized': 'never'
|
||||||
{
|
}],
|
||||||
initialized: 'never'
|
'operator-linebreak': [2, 'after', {
|
||||||
}
|
'overrides': {
|
||||||
],
|
|
||||||
'operator-linebreak': [
|
|
||||||
2,
|
|
||||||
'after',
|
|
||||||
{
|
|
||||||
overrides: {
|
|
||||||
'?': 'before',
|
'?': 'before',
|
||||||
':': 'before'
|
':': 'before'
|
||||||
}
|
}
|
||||||
}
|
}],
|
||||||
],
|
|
||||||
'padded-blocks': [2, 'never'],
|
'padded-blocks': [2, 'never'],
|
||||||
quotes: [
|
'quotes': [2, 'single', {
|
||||||
2,
|
'avoidEscape': true,
|
||||||
'single',
|
'allowTemplateLiterals': true
|
||||||
{
|
}],
|
||||||
avoidEscape: true,
|
'semi': [2, 'never'],
|
||||||
allowTemplateLiterals: true
|
'semi-spacing': [2, {
|
||||||
}
|
'before': false,
|
||||||
],
|
'after': true
|
||||||
semi: [2, 'never'],
|
}],
|
||||||
'semi-spacing': [
|
|
||||||
2,
|
|
||||||
{
|
|
||||||
before: false,
|
|
||||||
after: true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
'space-before-blocks': [2, 'always'],
|
'space-before-blocks': [2, 'always'],
|
||||||
'space-before-function-paren': [
|
'space-before-function-paren': [2, 'never'],
|
||||||
2,
|
|
||||||
{ anonymous: 'never', named: 'never', asyncArrow: 'always' }
|
|
||||||
],
|
|
||||||
'space-in-parens': [2, 'never'],
|
'space-in-parens': [2, 'never'],
|
||||||
'space-infix-ops': 2,
|
'space-infix-ops': 2,
|
||||||
'space-unary-ops': [
|
'space-unary-ops': [2, {
|
||||||
2,
|
'words': true,
|
||||||
{
|
'nonwords': false
|
||||||
words: true,
|
}],
|
||||||
nonwords: false
|
'spaced-comment': [2, 'always', {
|
||||||
}
|
'markers': ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ',']
|
||||||
],
|
}],
|
||||||
'object-curly-spacing': [2, 'always'],
|
|
||||||
'spaced-comment': [
|
|
||||||
2,
|
|
||||||
'always',
|
|
||||||
{
|
|
||||||
markers: ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ',']
|
|
||||||
}
|
|
||||||
],
|
|
||||||
'template-curly-spacing': [2, 'never'],
|
'template-curly-spacing': [2, 'never'],
|
||||||
'use-isnan': 2,
|
'use-isnan': 2,
|
||||||
'valid-typeof': 2,
|
'valid-typeof': 2,
|
||||||
'wrap-iife': [2, 'any'],
|
'wrap-iife': [2, 'any'],
|
||||||
'yield-star-spacing': [2, 'both'],
|
'yield-star-spacing': [2, 'both'],
|
||||||
yoda: [2, 'never'],
|
'yoda': [2, 'never'],
|
||||||
'prefer-const': 2,
|
'prefer-const': 2,
|
||||||
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
|
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
|
||||||
'array-bracket-spacing': [2, 'never'],
|
'object-curly-spacing': [2, 'always', {
|
||||||
'spellcheck/spell-checker': [
|
objectsInObjects: false
|
||||||
'warn',
|
}],
|
||||||
{
|
'array-bracket-spacing': [2, 'never']
|
||||||
comments: true,
|
|
||||||
strings: false,
|
|
||||||
identifiers: false,
|
|
||||||
lang: 'en_US',
|
|
||||||
skipWords: [
|
|
||||||
'echarts',
|
|
||||||
'resize',
|
|
||||||
'vue',
|
|
||||||
'eslint',
|
|
||||||
'babel',
|
|
||||||
'jsx',
|
|
||||||
'scss',
|
|
||||||
'v-deep',
|
|
||||||
'calc',
|
|
||||||
'vw',
|
|
||||||
'vh',
|
|
||||||
'px',
|
|
||||||
'rgba',
|
|
||||||
'rgb',
|
|
||||||
'var',
|
|
||||||
'lang',
|
|
||||||
'scoped',
|
|
||||||
'pdf',
|
|
||||||
'rbac'
|
|
||||||
],
|
|
||||||
skipIfMatch: [
|
|
||||||
'http://[^s]*',
|
|
||||||
'^[-\\w]+/[-\\w\\.]+$',
|
|
||||||
String.raw`^\/api\/[a-z0-9\/._-]+$`,
|
|
||||||
],
|
|
||||||
minLength: 3
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
# Dependencies
|
|
||||||
node_modules/
|
|
||||||
dist/
|
|
||||||
build/
|
|
||||||
lina/
|
|
||||||
|
|
||||||
# Logs
|
|
||||||
*.log
|
|
||||||
logs/
|
|
||||||
|
|
||||||
# Runtime data
|
|
||||||
pids/
|
|
||||||
*.pid
|
|
||||||
*.seed
|
|
||||||
|
|
||||||
# Coverage directory used by tools like istanbul
|
|
||||||
coverage/
|
|
||||||
|
|
||||||
# Generated files
|
|
||||||
*.min.js
|
|
||||||
*.min.css
|
|
||||||
|
|
||||||
# Package files
|
|
||||||
*.tgz
|
|
||||||
*.tar.gz
|
|
||||||
|
|
||||||
# Lock files
|
|
||||||
package-lock.json
|
|
||||||
yarn.lock
|
|
||||||
|
|
||||||
# Build outputs
|
|
||||||
*.map
|
|
||||||
|
|
||||||
# Config files that shouldn't be formatted
|
|
||||||
.eslintrc.js
|
|
||||||
babel.config.js
|
|
||||||
jest.config.js
|
|
||||||
vue.config.js
|
|
||||||
postcss.config.js
|
|
||||||
|
|
||||||
# Theme files
|
|
||||||
src/styles/fonts/
|
|
||||||
public/fonts/
|
|
||||||
lina/fonts/
|
|
||||||
|
|
||||||
# Assets
|
|
||||||
src/assets/
|
|
||||||
public/
|
|
||||||
|
|
||||||
# Mock data
|
|
||||||
mock/
|
|
||||||
|
|
||||||
# Test files
|
|
||||||
tests/
|
|
||||||
|
|
||||||
# Documentation
|
|
||||||
*.md
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
singleQuote: true,
|
|
||||||
semi: false,
|
|
||||||
trailingComma: 'none',
|
|
||||||
printWidth: 100,
|
|
||||||
tabWidth: 2,
|
|
||||||
useTabs: false,
|
|
||||||
bracketSpacing: true,
|
|
||||||
arrowParens: 'avoid',
|
|
||||||
endOfLine: 'auto'
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM jumpserver/lina-base:20251105_092554 AS stage-build
|
FROM jumpserver/lina-base:20240723_084702 AS stage-build
|
||||||
|
|
||||||
ARG VERSION
|
ARG VERSION
|
||||||
ENV VERSION=$VERSION
|
ENV VERSION=$VERSION
|
||||||
|
|||||||
76
PRETTIER.md
@@ -1,76 +0,0 @@
|
|||||||
# Prettier 配置说明
|
|
||||||
|
|
||||||
本项目已配置 Prettier 代码格式化工具,**仅在保存时自动格式化**,不进行批量格式化,以保持现有代码风格。
|
|
||||||
|
|
||||||
## 配置文件
|
|
||||||
|
|
||||||
- `.prettierrc` - Prettier 配置文件
|
|
||||||
- `.prettierignore` - 忽略格式化的文件列表
|
|
||||||
- `.vscode/settings.json` - VSCode 编辑器配置(保存时自动格式化)
|
|
||||||
- `.vscode/extensions.json` - 推荐的 VSCode 扩展
|
|
||||||
|
|
||||||
## 使用方法
|
|
||||||
|
|
||||||
### 1. 安装依赖
|
|
||||||
项目已安装以下依赖:
|
|
||||||
- `prettier@^2.8.8` - Prettier 核心
|
|
||||||
- `eslint-plugin-prettier@^3.1.4` - ESLint 与 Prettier 集成
|
|
||||||
- `eslint-config-prettier@^6.15.0` - 禁用与 Prettier 冲突的 ESLint 规则
|
|
||||||
|
|
||||||
### 2. 命令行使用
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# ESLint 检查和修复
|
|
||||||
npm run fix
|
|
||||||
```
|
|
||||||
|
|
||||||
**注意**:本项目配置为仅在保存时自动格式化,不提供批量格式化命令。
|
|
||||||
|
|
||||||
### 3. VSCode 编辑器配置
|
|
||||||
|
|
||||||
确保安装了推荐的扩展:
|
|
||||||
- Prettier - Code formatter (esbenp.prettier-vscode)
|
|
||||||
- ESLint (dbaeumer.vscode-eslint)
|
|
||||||
- Vetur (octref.vetur)
|
|
||||||
|
|
||||||
配置已设置为保存时自动格式化。
|
|
||||||
|
|
||||||
### 4. Git 提交钩子
|
|
||||||
|
|
||||||
项目使用 `husky` 和 `lint-staged` 在提交时进行代码检查:
|
|
||||||
- 提交时运行 ESLint 检查和修复
|
|
||||||
- 不进行批量格式化,保持原有代码风格
|
|
||||||
|
|
||||||
## Prettier 配置说明
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"semi": false, // 不使用分号
|
|
||||||
"singleQuote": true, // 使用单引号
|
|
||||||
"tabWidth": 0, // 不使用缩进
|
|
||||||
"useTabs": false, // 使用空格而不是制表符
|
|
||||||
"trailingComma": "none", // 不使用尾随逗号
|
|
||||||
"printWidth": 100, // 行宽 100 字符
|
|
||||||
"bracketSpacing": true, // 对象括号内有空格
|
|
||||||
"arrowParens": "avoid", // 箭头函数单参数时不使用括号
|
|
||||||
"endOfLine": "lf", // 使用 LF 换行符
|
|
||||||
"vueIndentScriptAndStyle": false // Vue 文件中 script 和 style 标签不缩进
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## 常见问题
|
|
||||||
|
|
||||||
### Q: 如何临时禁用格式化?
|
|
||||||
A: 使用注释:
|
|
||||||
```javascript
|
|
||||||
// prettier-ignore
|
|
||||||
const uglyCode = {
|
|
||||||
a:1,b:2
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Q: 如何添加文件到忽略列表?
|
|
||||||
A: 编辑 `.prettierignore` 文件,添加文件或目录路径。
|
|
||||||
|
|
||||||
### Q: VSCode 保存时没有自动格式化?
|
|
||||||
A: 检查是否安装了 Prettier 扩展,并确认 `.vscode/settings.json` 配置正确。
|
|
||||||
@@ -1,25 +1,13 @@
|
|||||||
import Mock from 'mockjs'
|
import Mock from 'mockjs'
|
||||||
|
import { param2Obj } from '../src/utils'
|
||||||
|
|
||||||
import user from './user'
|
import user from './user'
|
||||||
import table from './table'
|
import table from './table'
|
||||||
|
|
||||||
export function param2Obj(url) {
|
const mocks = [
|
||||||
const search = url.split('?')[1]
|
...user,
|
||||||
if (!search) {
|
...table
|
||||||
return {}
|
]
|
||||||
}
|
|
||||||
return JSON.parse(
|
|
||||||
'{"' +
|
|
||||||
decodeURIComponent(search)
|
|
||||||
.replace(/"/g, '\\"')
|
|
||||||
.replace(/&/g, '","')
|
|
||||||
.replace(/=/g, '":"')
|
|
||||||
.replace(/\+/g, ' ') +
|
|
||||||
'"}'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const mocks = [...user, ...table]
|
|
||||||
|
|
||||||
// for front mock
|
// for front mock
|
||||||
// please use it cautiously, it will redefine XMLHttpRequest,
|
// please use it cautiously, it will redefine XMLHttpRequest,
|
||||||
|
|||||||
41
package.json
@@ -2,7 +2,7 @@
|
|||||||
"name": "lina",
|
"name": "lina",
|
||||||
"version": "v4.0.0",
|
"version": "v4.0.0",
|
||||||
"description": "JumpServer Web UI",
|
"description": "JumpServer Web UI",
|
||||||
"author": "JumpServer Team <support@lxware.hk>",
|
"author": "JumpServer Team <support@fit2cloud.com>",
|
||||||
"license": "GPL-3.0-or-later",
|
"license": "GPL-3.0-or-later",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "NODE_OPTIONS=--openssl-legacy-provider vue-cli-service serve",
|
"dev": "NODE_OPTIONS=--openssl-legacy-provider vue-cli-service serve",
|
||||||
@@ -26,22 +26,19 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/plugin-proposal-optional-chaining": "^7.13.12",
|
"@babel/plugin-proposal-optional-chaining": "^7.13.12",
|
||||||
"@fontsource/open-sans": "^5.0.24",
|
"@fontsource/open-sans": "^5.0.24",
|
||||||
"@kangc/v-md-editor": "^1.7.12",
|
|
||||||
"@traptitech/markdown-it-katex": "^3.6.0",
|
"@traptitech/markdown-it-katex": "^3.6.0",
|
||||||
"@ztree/ztree_v3": "3.5.44",
|
"@ztree/ztree_v3": "3.5.44",
|
||||||
"axios": "0.28.0",
|
"axios": "0.28.0",
|
||||||
"axios-retry": "^3.1.9",
|
"axios-retry": "^3.1.9",
|
||||||
"babel-loader": "^10.0.0",
|
|
||||||
"cache-loader": "^4.1.0",
|
|
||||||
"caniuse-lite": "^1.0.30001642",
|
"caniuse-lite": "^1.0.30001642",
|
||||||
"cron-parser": "^4.0.0",
|
"cron-parser": "^4.0.0",
|
||||||
"crypto-js": "^4.1.1",
|
"crypto-js": "^4.1.1",
|
||||||
"css-color-function": "^1.3.3",
|
"css-color-function": "^1.3.3",
|
||||||
"decimal.js": "^10.4.3",
|
"decimal.js": "^10.4.3",
|
||||||
"deepmerge": "^4.2.2",
|
"deepmerge": "^4.2.2",
|
||||||
"dompurify": "^3.2.4",
|
"dompurify": "^3.1.6",
|
||||||
"echarts": "4.7.0",
|
"echarts": "4.7.0",
|
||||||
"element-ui": "https://github.com/jumpserver-dev/element/releases/download/v2.15.15/jumpserver-element-ui-2.15.15.tgz",
|
"element-ui": "2.15.14",
|
||||||
"eslint-plugin-html": "^6.0.0",
|
"eslint-plugin-html": "^6.0.0",
|
||||||
"highlight.js": "^11.9.0",
|
"highlight.js": "^11.9.0",
|
||||||
"install": "^0.13.0",
|
"install": "^0.13.0",
|
||||||
@@ -51,6 +48,17 @@
|
|||||||
"less": "^3.10.3",
|
"less": "^3.10.3",
|
||||||
"less-loader": "^5.0.0",
|
"less-loader": "^5.0.0",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
|
"lodash.clonedeep": "^4.5.0",
|
||||||
|
"lodash.frompairs": "^4.0.1",
|
||||||
|
"lodash.get": "^4.4.2",
|
||||||
|
"lodash.has": "^4.5.2",
|
||||||
|
"lodash.includes": "^4.3.0",
|
||||||
|
"lodash.isempty": "^4.4.0",
|
||||||
|
"lodash.isequal": "^4.5.0",
|
||||||
|
"lodash.isplainobject": "^4.0.6",
|
||||||
|
"lodash.set": "^4.3.2",
|
||||||
|
"lodash.topairs": "^4.3.0",
|
||||||
|
"lodash.values": "^4.3.0",
|
||||||
"markdown-it": "^13.0.2",
|
"markdown-it": "^13.0.2",
|
||||||
"markdown-it-link-attributes": "^4.0.1",
|
"markdown-it-link-attributes": "^4.0.1",
|
||||||
"moment": "^2.29.4",
|
"moment": "^2.29.4",
|
||||||
@@ -59,21 +67,20 @@
|
|||||||
"npm": "^7.8.0",
|
"npm": "^7.8.0",
|
||||||
"nprogress": "0.2.0",
|
"nprogress": "0.2.0",
|
||||||
"path-to-regexp": "3.3.0",
|
"path-to-regexp": "3.3.0",
|
||||||
"sortablejs": "^1.15.6",
|
|
||||||
"v-sanitize": "^0.0.13",
|
"v-sanitize": "^0.0.13",
|
||||||
"vue": "2.7.16",
|
"vue": "2.6.10",
|
||||||
"vue-codemirror": "4.0.6",
|
"vue-codemirror": "4.0.6",
|
||||||
"vue-cookie": "^1.1.4",
|
"vue-cookie": "^1.1.4",
|
||||||
"vue-echarts": "^5.0.0-beta.0",
|
"vue-echarts": "^5.0.0-beta.0",
|
||||||
"vue-i18n": "^8.15.5",
|
"vue-i18n": "^8.15.5",
|
||||||
"vue-json-editor": "^1.4.3",
|
"vue-json-editor": "^1.4.3",
|
||||||
"vue-markdown": "^2.2.4",
|
"vue-markdown": "^2.2.4",
|
||||||
|
"vue-moment": "^4.1.0",
|
||||||
"vue-password-strength-meter": "^1.7.2",
|
"vue-password-strength-meter": "^1.7.2",
|
||||||
"vue-router": "3.0.6",
|
"vue-router": "3.0.6",
|
||||||
"vue-select": "^3.9.5",
|
"vue-select": "^3.9.5",
|
||||||
"vuejs-logger": "^1.5.4",
|
"vuejs-logger": "^1.5.4",
|
||||||
"vuex": "3.1.0",
|
"vuex": "3.1.0",
|
||||||
"watermark-js-plus": "^1.5.8",
|
|
||||||
"xss": "^1.0.14",
|
"xss": "^1.0.14",
|
||||||
"xterm": "^4.5.0",
|
"xterm": "^4.5.0",
|
||||||
"xterm-addon-fit": "^0.3.0",
|
"xterm-addon-fit": "^0.3.0",
|
||||||
@@ -87,18 +94,17 @@
|
|||||||
"@vue/cli-plugin-unit-jest": "3.6.3",
|
"@vue/cli-plugin-unit-jest": "3.6.3",
|
||||||
"@vue/cli-service": "3.6.0",
|
"@vue/cli-service": "3.6.0",
|
||||||
"@vue/test-utils": "1.0.0-beta.29",
|
"@vue/test-utils": "1.0.0-beta.29",
|
||||||
|
"@vue/runtime-dom": "3.5.13",
|
||||||
"autoprefixer": "^9.5.1",
|
"autoprefixer": "^9.5.1",
|
||||||
"babel-core": "6.26.3",
|
"babel-core": "7.0.0-bridge.0",
|
||||||
"babel-eslint": "10.0.1",
|
"babel-eslint": "10.0.1",
|
||||||
"babel-jest": "23.6.0",
|
"babel-jest": "23.6.0",
|
||||||
"chalk": "2.4.2",
|
"chalk": "2.4.2",
|
||||||
"compression-webpack-plugin": "^6.1.1",
|
"compression-webpack-plugin": "^6.1.1",
|
||||||
"connect": "3.6.6",
|
"connect": "3.6.6",
|
||||||
"deasync": "^0.1.29",
|
"deasync": "^0.1.29",
|
||||||
|
"element-theme-chalk": "^2.13.1",
|
||||||
"eslint": "^5.15.3",
|
"eslint": "^5.15.3",
|
||||||
"eslint-config-prettier": "^6.15.0",
|
|
||||||
"eslint-plugin-prettier": "^3.4.1",
|
|
||||||
"eslint-plugin-spellcheck": "^0.0.20",
|
|
||||||
"eslint-plugin-vue": "5.2.2",
|
"eslint-plugin-vue": "5.2.2",
|
||||||
"eslint-plugin-vue-i18n": "^0.3.0",
|
"eslint-plugin-vue-i18n": "^0.3.0",
|
||||||
"github-markdown-css": "^5.1.0",
|
"github-markdown-css": "^5.1.0",
|
||||||
@@ -107,8 +113,6 @@
|
|||||||
"less-loader": "^5.0.0",
|
"less-loader": "^5.0.0",
|
||||||
"lint-staged": "^10.1.2",
|
"lint-staged": "^10.1.2",
|
||||||
"mockjs": "1.0.1-beta3",
|
"mockjs": "1.0.1-beta3",
|
||||||
"prettier": "^3.6.2",
|
|
||||||
"pretty-bytes": "^5.6.0",
|
|
||||||
"runjs": "^4.3.2",
|
"runjs": "^4.3.2",
|
||||||
"sass": "~1.32.6",
|
"sass": "~1.32.6",
|
||||||
"sass-loader": "^7.1.0",
|
"sass-loader": "^7.1.0",
|
||||||
@@ -117,13 +121,12 @@
|
|||||||
"serve-static": "^1.16.0",
|
"serve-static": "^1.16.0",
|
||||||
"strip-ansi": "^7.1.0",
|
"strip-ansi": "^7.1.0",
|
||||||
"svg-sprite-loader": "4.1.3",
|
"svg-sprite-loader": "4.1.3",
|
||||||
"svgo": "1.2.2",
|
"svgo": "1.2.4",
|
||||||
"vue-i18n-extract": "^1.1.1",
|
"vue-i18n-extract": "^1.1.1",
|
||||||
"vue-template-compiler": "2.7.16",
|
"vue-template-compiler": "2.6.10"
|
||||||
"webpack": "^4.28.4"
|
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=12",
|
"node": ">=8.9",
|
||||||
"npm": ">= 3.0.0"
|
"npm": ">= 3.0.0"
|
||||||
},
|
},
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
|
|||||||
78
src/App.vue
@@ -5,90 +5,14 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapState, mapGetters } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
import { Watermark } from 'watermark-js-plus'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'App',
|
name: 'App',
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
watermark: null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
isRouterAlive: state => state.common.isRouterAlive
|
isRouterAlive: state => state.common.isRouterAlive
|
||||||
}),
|
|
||||||
...mapGetters({
|
|
||||||
currentUser: 'currentUser',
|
|
||||||
publicSettings: 'publicSettings'
|
|
||||||
})
|
})
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
currentUser: {
|
|
||||||
handler(newVal) {
|
|
||||||
this.createWatermark()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'publicSettings.SECURITY_WATERMARK_ENABLED': {
|
|
||||||
handler(newVal) {
|
|
||||||
if (!newVal) {
|
|
||||||
return setTimeout(() => {
|
|
||||||
this.watermark?.destroy()
|
|
||||||
this.watermark = null
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
this.createWatermark()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
getWaterMarkFields() {
|
|
||||||
const user = this.currentUser
|
|
||||||
const userId = user?.id || ''
|
|
||||||
const name = user?.name || ''
|
|
||||||
const userName = user?.username || ''
|
|
||||||
const currentTime = this.$moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
|
|
||||||
return { userId, name, userName, currentTime }
|
|
||||||
},
|
|
||||||
getWaterMarkContent() {
|
|
||||||
const fields = this.getWaterMarkFields()
|
|
||||||
const template = this.publicSettings.SECURITY_WATERMARK_CONSOLE_CONTENT || ''
|
|
||||||
|
|
||||||
// 找出模板中所有的变量占位符 ${xxx}
|
|
||||||
const placeholders = template.match(/\${([^}]+)}/g) || []
|
|
||||||
const allVariables = {}
|
|
||||||
|
|
||||||
// 为模板中的每个变量准备值
|
|
||||||
placeholders.forEach(placeholder => {
|
|
||||||
const varName = placeholder.slice(2, -1) // 提取变量名,去掉 ${ 和 }
|
|
||||||
allVariables[varName] = fields[varName] !== undefined ? fields[varName] : 'N/A'
|
|
||||||
})
|
|
||||||
|
|
||||||
// 合并用户现有的字段和模板中可能缺失的字段
|
|
||||||
const safeFields = { ...fields, ...allVariables }
|
|
||||||
|
|
||||||
// 安全解析模板
|
|
||||||
return new Function(...Object.keys(safeFields), `return \`${template}\`;`)(...Object.values(safeFields))
|
|
||||||
},
|
|
||||||
|
|
||||||
createWatermark() {
|
|
||||||
if (this.currentUser?.username && this.publicSettings?.SECURITY_WATERMARK_ENABLED) {
|
|
||||||
this.watermark = new Watermark({
|
|
||||||
content: this.getWaterMarkContent(),
|
|
||||||
width: this.publicSettings?.SECURITY_WATERMARK_WIDTH,
|
|
||||||
height: this.publicSettings?.SECURITY_WATERMARK_HEIGHT,
|
|
||||||
rotate: this.publicSettings?.SECURITY_WATERMARK_ROTATE,
|
|
||||||
fontWeight: 'normal',
|
|
||||||
fontSize: this.publicSettings?.SECURITY_WATERMARK_FONT_SIZE + 'px',
|
|
||||||
fontColor: this.publicSettings?.SECURITY_WATERMARK_COLOR,
|
|
||||||
contentType: 'multi-line-text',
|
|
||||||
lineHeight: this.publicSettings?.SECURITY_WATERMARK_FONT_SIZE
|
|
||||||
})
|
|
||||||
this.watermark.create()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ export function getSystemUserList(data) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getZoneList(data) {
|
export function getDomainList(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/api/v1/assets/zones/',
|
url: '/api/v1/assets/domains/',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: data
|
params: data
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -61,14 +61,13 @@ export function stopJob(form) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function JobUploadFile(form, config = {}) {
|
export function JobUploadFile(form) {
|
||||||
return request({
|
return request({
|
||||||
url: '/api/v1/ops/jobs/upload/',
|
url: '/api/v1/ops/jobs/upload/',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
headers: { 'Content-Type': 'multipart/form-data' },
|
headers: { 'Content-Type': 'multipart/form-data' },
|
||||||
timeout: 60 * 60 * 1000,
|
timeout: 60 * 60 * 1000,
|
||||||
data: form,
|
data: form
|
||||||
...config
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,14 +18,14 @@ export function toggleLockSession(data) {
|
|||||||
|
|
||||||
export function getAllCommandStorage() {
|
export function getAllCommandStorage() {
|
||||||
return request({
|
return request({
|
||||||
url: '/api/v1/terminal/command-storages/',
|
url: `/api/v1/terminal/command-storages/`,
|
||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getAllReplayStorage() {
|
export function getAllReplayStorage() {
|
||||||
return request({
|
return request({
|
||||||
url: '/api/v1/terminal/replay-storages/',
|
url: `/api/v1/terminal/replay-storages/`,
|
||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,20 +8,11 @@ export function login(data) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getProfile(token) {
|
export function getProfile(token) {
|
||||||
let profile = await request({
|
return request({
|
||||||
url: '/api/v1/users/profile/',
|
url: '/api/v1/users/profile/',
|
||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
const perms = await request({
|
|
||||||
url: '/api/v1/users/profile/permissions/',
|
|
||||||
method: 'get'
|
|
||||||
})
|
|
||||||
profile = {
|
|
||||||
...profile,
|
|
||||||
...perms
|
|
||||||
}
|
|
||||||
return profile
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getUserList(data) {
|
export function getUserList(data) {
|
||||||
@@ -31,7 +22,6 @@ export function getUserList(data) {
|
|||||||
params: data
|
params: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getUserGroupList(params) {
|
export function getUserGroupList(params) {
|
||||||
return request({
|
return request({
|
||||||
url: '/api/v1/users/groups/',
|
url: '/api/v1/users/groups/',
|
||||||
@@ -39,7 +29,6 @@ export function getUserGroupList(params) {
|
|||||||
params: params
|
params: params
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getUserGroupDetail(id) {
|
export function getUserGroupDetail(id) {
|
||||||
return request({
|
return request({
|
||||||
url: `/api/v1/users/groups/${id}/`,
|
url: `/api/v1/users/groups/${id}/`,
|
||||||
@@ -61,7 +50,6 @@ export function editUserGroup(data) {
|
|||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateUserGroup(id, data) {
|
export function updateUserGroup(id, data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/api/v1/users/groups/' + id + '/',
|
url: '/api/v1/users/groups/' + id + '/',
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 7.4 KiB |
|
Before Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 8.5 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 3.6 KiB |
@@ -1 +0,0 @@
|
|||||||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1752631175762" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4421" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M93.866667 234.666667c-34.133333 12.8-51.2 25.6-51.2 34.133333 0 4.266667 51.2 64 115.2 136.533333 64 68.266667 115.2 128 115.2 128s-51.2 59.733333-115.2 128C93.866667 729.6 42.666667 793.6 42.666667 797.866667c4.266667 17.066667 59.733333 42.666667 98.133333 42.666666 64 0 81.066667-12.8 217.6-162.133333 68.266667-76.8 128-140.8 128-140.8 0-4.266667-55.466667-64-123.733333-140.8-85.333333-102.4-132.266667-145.066667-153.6-157.866667-29.866667-12.8-81.066667-17.066667-115.2-4.266666z m725.333333 4.266666c-21.333333 8.533333-68.266667 59.733333-153.6 153.6-68.266667 76.8-123.733333 140.8-123.733333 140.8 0 4.266667 55.466667 68.266667 128 140.8 136.533333 153.6 153.6 162.133333 217.6 162.133334 42.666667 0 98.133333-21.333333 98.133333-42.666667 0-4.266667-51.2-68.266667-115.2-136.533333-64-68.266667-115.2-128-115.2-128s51.2-59.733333 115.2-128c64-68.266667 115.2-128 115.2-136.533334-4.266667-17.066667-55.466667-38.4-98.133333-38.4-34.133333 0-46.933333 4.266667-68.266667 12.8z" fill="#E57000" p-id="4422"></path><path d="M238.933333 136.533333c-42.666667 21.333333-42.666667 25.6-4.266666 68.266667 221.866667 243.2 273.066667 302.933333 277.333333 302.933333 4.266667 0 311.466667-332.8 315.733333-341.333333 0-4.266667-8.533333-12.8-21.333333-21.333333-17.066667-12.8-34.133333-17.066667-68.266667-17.066667-64-4.266667-85.333333 8.533333-162.133333 93.866667-34.133333 38.4-64 72.533333-64 72.533333s-29.866667-29.866667-64-68.266667c-34.133333-38.4-72.533333-76.8-89.6-85.333333-25.6-17.066667-89.6-21.333333-119.466667-4.266667zM354.133333 725.333333c-85.333333 93.866667-153.6 170.666667-153.6 174.933334 0 4.266667 8.533333 12.8 21.333334 21.333333 17.066667 12.8 34.133333 17.066667 68.266666 17.066667 59.733333 4.266667 85.333333-8.533333 162.133334-98.133334 34.133333-38.4 64-68.266667 64-68.266666s29.866667 29.866667 64 68.266666c81.066667 89.6 98.133333 102.4 162.133333 98.133334 34.133333 0 51.2-4.266667 68.266667-17.066667 12.8-8.533333 21.333333-17.066667 21.333333-21.333333-4.266667-8.533333-311.466667-345.6-315.733333-341.333334-8.533333 0-76.8 76.8-162.133334 166.4z" p-id="4423"></path></svg>
|
|
||||||
|
Before Width: | Height: | Size: 2.4 KiB |
@@ -1 +0,0 @@
|
|||||||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1748326203303" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2853" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M10.24 605.184l839.168-481.28L1013.76 220.672v191.488L174.592 895.488 10.24 804.352z" fill="#0096FF" p-id="2854"></path><path d="M10.24 416.768V220.672l168.96-96.768 308.736 178.688-331.776 193.536zM541.184 717.312l331.264-195.072 141.312 88.064v194.048l-165.376 95.744z" fill="#25C764" p-id="2855"></path></svg>
|
|
||||||
|
Before Width: | Height: | Size: 645 B |
|
Before Width: | Height: | Size: 210 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.3 KiB |
@@ -1,41 +1,24 @@
|
|||||||
import { UpdateToken, UploadSecret } from '@/components/Form/FormFields'
|
import { UpdateToken, UploadSecret } from '@/components/Form/FormFields'
|
||||||
import Select2 from '@/components/Form/FormFields/Select2.vue'
|
import Select2 from '@/components/Form/FormFields/Select2.vue'
|
||||||
import AssetSelect from '@/components/Apps/AssetSelect/index.vue'
|
|
||||||
import { Required, RequiredChange } from '@/components/Form/DataForm/rules'
|
import { Required, RequiredChange } from '@/components/Form/DataForm/rules'
|
||||||
import AutomationParamsForm from '@/views/assets/Platform/AutomationParamsSetting.vue'
|
import AutomationParamsForm from '@/views/assets/Platform/AutomationParamsSetting.vue'
|
||||||
|
|
||||||
export const accountFieldsMeta = (vm) => {
|
export const accountFieldsMeta = (vm) => {
|
||||||
const defaultPrivilegedAccounts = ['root', 'administrator']
|
const defaultPrivilegedAccounts = ['root', 'administrator']
|
||||||
|
|
||||||
function onPrivilegedUser(value, updateForm) {
|
|
||||||
const maybePrivileged = defaultPrivilegedAccounts.includes(value)
|
|
||||||
if (maybePrivileged) {
|
|
||||||
updateForm({ privileged: true, secret_reset: false, push_now: false })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
nodes: {
|
|
||||||
component: Select2,
|
|
||||||
label: vm.$t('Node'),
|
|
||||||
el: {
|
|
||||||
value: [],
|
|
||||||
ajax: {
|
|
||||||
url: '/api/v1/assets/nodes/',
|
|
||||||
transformOption: (item) => {
|
|
||||||
return { label: item.full_value, value: item.id }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
hidden: () => {
|
|
||||||
return !vm.addTemplate
|
|
||||||
}
|
|
||||||
},
|
|
||||||
assets: {
|
assets: {
|
||||||
component: AssetSelect,
|
component: Select2,
|
||||||
label: vm.$t('Asset'),
|
label: vm.$t('Assets'),
|
||||||
|
rules: [Required],
|
||||||
el: {
|
el: {
|
||||||
multiple: false
|
multiple: true,
|
||||||
|
ajax: {
|
||||||
|
url: '/api/v1/assets/assets/',
|
||||||
|
transformOption: (item) => {
|
||||||
|
return { label: item.name + '(' + item.address + ')', value: item.id }
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
hidden: () => {
|
hidden: () => {
|
||||||
return vm.platform || vm.asset
|
return vm.platform || vm.asset
|
||||||
@@ -48,7 +31,7 @@ export const accountFieldsMeta = (vm) => {
|
|||||||
get disabled() {
|
get disabled() {
|
||||||
return vm.isDisabled
|
return vm.isDisabled
|
||||||
},
|
},
|
||||||
multiple: vm.addTemplate,
|
multiple: false,
|
||||||
ajax: {
|
ajax: {
|
||||||
url: '/api/v1/accounts/account-templates/',
|
url: '/api/v1/accounts/account-templates/',
|
||||||
transformOption: (item) => {
|
transformOption: (item) => {
|
||||||
@@ -87,8 +70,11 @@ export const accountFieldsMeta = (vm) => {
|
|||||||
if (!vm.account?.name) {
|
if (!vm.account?.name) {
|
||||||
updateForm({ username: value })
|
updateForm({ username: value })
|
||||||
}
|
}
|
||||||
|
const maybePrivileged = defaultPrivilegedAccounts.includes(value)
|
||||||
|
if (maybePrivileged) {
|
||||||
|
updateForm({ privileged: true })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
onPrivilegedUser(value, updateForm)
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
hidden: () => {
|
hidden: () => {
|
||||||
@@ -106,7 +92,10 @@ export const accountFieldsMeta = (vm) => {
|
|||||||
vm.usernameChanged = true
|
vm.usernameChanged = true
|
||||||
},
|
},
|
||||||
change: ([value], updateForm) => {
|
change: ([value], updateForm) => {
|
||||||
onPrivilegedUser(value, updateForm)
|
const maybePrivileged = defaultPrivilegedAccounts.includes(value)
|
||||||
|
if (maybePrivileged) {
|
||||||
|
updateForm({ privileged: true })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
hidden: () => {
|
hidden: () => {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import AutoDataForm from '@/components/Form/AutoDataForm/index.vue'
|
import AutoDataForm from '@/components/Form/AutoDataForm/index.vue'
|
||||||
import { encryptPassword } from '@/utils/secure'
|
import { encryptPassword } from '@/utils/crypto'
|
||||||
import { accountFieldsMeta } from '@/components/Apps/AccountCreateUpdateForm/const'
|
import { accountFieldsMeta } from '@/components/Apps/AccountCreateUpdateForm/const'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -63,7 +63,7 @@ export default {
|
|||||||
encryptedFields: ['secret'],
|
encryptedFields: ['secret'],
|
||||||
fields: [
|
fields: [
|
||||||
[this.$t('Basic'), ['name', 'username', 'privileged', 'su_from', 'su_from_username', 'template']],
|
[this.$t('Basic'), ['name', 'username', 'privileged', 'su_from', 'su_from_username', 'template']],
|
||||||
[this.$t('Asset'), ['nodes', 'assets']],
|
[this.$t('Assets'), ['assets']],
|
||||||
[this.$t('Secret'), [
|
[this.$t('Secret'), [
|
||||||
'secret_type', 'password', 'ssh_key', 'token',
|
'secret_type', 'password', 'ssh_key', 'token',
|
||||||
'access_key', 'passphrase', 'api_key',
|
'access_key', 'passphrase', 'api_key',
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import { GenericUpdateFormDialog } from '@/layout/components'
|
import { GenericUpdateFormDialog } from '@/layout/components'
|
||||||
import { accountFieldsMeta } from '@/components/Apps/AccountCreateUpdateForm/const'
|
import { accountFieldsMeta } from '@/components/Apps/AccountCreateUpdateForm/const'
|
||||||
import { encryptPassword } from '@/utils/secure'
|
import { encryptPassword } from '@/utils/crypto'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'AccountBulkUpdateDialog',
|
name: 'AccountBulkUpdateDialog',
|
||||||
|
|||||||
@@ -93,8 +93,8 @@ export default {
|
|||||||
iVisible = true
|
iVisible = true
|
||||||
data = formValue
|
data = formValue
|
||||||
url = `/api/v1/accounts/accounts/bulk/`
|
url = `/api/v1/accounts/accounts/bulk/`
|
||||||
if ((!data.assets || data.assets.length === 0) && (!data.nodes || data.nodes.length === 0)) {
|
if (data.assets.length === 0) {
|
||||||
this.$message.error(this.$tc('PleaseSelectAssetOrNode'))
|
this.$message.error(this.$tc('PleaseSelectAsset'))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,8 +51,8 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapGetters } from 'vuex'
|
import { mapGetters } from 'vuex'
|
||||||
import { accountOtherActions, accountQuickFilters, connectivityMeta, isDirectoryServiceAccount } from './const'
|
import { accountOtherActions, accountQuickFilters, connectivityMeta } from './const'
|
||||||
import { openTaskPage } from '@/utils/jms/index'
|
import { openTaskPage } from '@/utils/jms'
|
||||||
import {
|
import {
|
||||||
AccountConnectFormatter,
|
AccountConnectFormatter,
|
||||||
ActionsFormatter,
|
ActionsFormatter,
|
||||||
@@ -182,21 +182,13 @@ export default {
|
|||||||
},
|
},
|
||||||
columnsMeta: {
|
columnsMeta: {
|
||||||
name: {
|
name: {
|
||||||
minWidth: '60px',
|
width: '120px',
|
||||||
formatterArgs: {
|
formatterArgs: {
|
||||||
can: () => vm.$hasPerm('accounts.view_account'),
|
can: () => vm.$hasPerm('accounts.view_account'),
|
||||||
getRoute: ({ row }) => ({
|
getRoute: ({ row }) => ({
|
||||||
name: 'AccountDetail',
|
name: 'AccountDetail',
|
||||||
params: { id: row.id }
|
params: { id: row.id }
|
||||||
}),
|
}),
|
||||||
getTitle: ({ row }) => {
|
|
||||||
let title = row.name
|
|
||||||
if (row.ds && this.asset && this.asset.id !== row.asset.id) {
|
|
||||||
const dsID = row.ds.id.split('-')[0]
|
|
||||||
title = `${row.name}@${dsID}`
|
|
||||||
}
|
|
||||||
return title
|
|
||||||
},
|
|
||||||
getDrawerTitle({ row }) {
|
getDrawerTitle({ row }) {
|
||||||
return `${row.username}@${row.asset.name}`
|
return `${row.username}@${row.asset.name}`
|
||||||
}
|
}
|
||||||
@@ -216,19 +208,15 @@ export default {
|
|||||||
width: '80px',
|
width: '80px',
|
||||||
formatter: AccountConnectFormatter,
|
formatter: AccountConnectFormatter,
|
||||||
formatterArgs: {
|
formatterArgs: {
|
||||||
asset: this.asset,
|
buttonIcon: 'fa fa-desktop',
|
||||||
can: ({ row }) => {
|
url: '/api/v1/assets/assets/{id}',
|
||||||
return this.currentUserIsSuperAdmin
|
can: () => this.currentUserIsSuperAdmin,
|
||||||
}
|
connectUrlTemplate: (row) => `/luna/pam_connect/${row.id}/${row.username}/${row.asset.id}/${row.asset.name}/`,
|
||||||
}
|
setMapItem: (id, protocol) => {
|
||||||
},
|
this.$store.commit('table/SET_PROTOCOL_MAP_ITEM', {
|
||||||
ds: {
|
key: id,
|
||||||
width: '100px',
|
value: protocol
|
||||||
formatter: (row) => {
|
})
|
||||||
if (row.ds && row.ds['domain_name']) {
|
|
||||||
return row.ds['domain_name']
|
|
||||||
} else {
|
|
||||||
return ''
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -241,20 +229,12 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
asset: {
|
asset: {
|
||||||
minWidth: '100px',
|
|
||||||
formatter: function(row) {
|
formatter: function(row) {
|
||||||
return row.asset.name
|
return row.asset.name
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
username: {
|
username: {
|
||||||
minWidth: '60px',
|
width: '120px'
|
||||||
formatter: function(row) {
|
|
||||||
if (row.ds && row.ds['domain_name']) {
|
|
||||||
return `${row.username}@${row.ds['domain_name']}`
|
|
||||||
} else {
|
|
||||||
return row.username
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
secret_type: {
|
secret_type: {
|
||||||
formatter: function(row) {
|
formatter: function(row) {
|
||||||
@@ -284,15 +264,10 @@ export default {
|
|||||||
formatter: ActionsFormatter,
|
formatter: ActionsFormatter,
|
||||||
has: this.showActions,
|
has: this.showActions,
|
||||||
formatterArgs: {
|
formatterArgs: {
|
||||||
performDelete: ({ row }) => {
|
|
||||||
const id = row.id
|
|
||||||
const url = `/api/v1/accounts/accounts/${id}/`
|
|
||||||
return this.$axios.delete(url)
|
|
||||||
},
|
|
||||||
hasUpdate: false, // can set function(row, value)
|
hasUpdate: false, // can set function(row, value)
|
||||||
hasDelete: true, // can set function(row, value)
|
hasDelete: true, // can set function(row, value)
|
||||||
hasClone: false,
|
hasClone: false,
|
||||||
canDelete: ({ row }) => vm.$hasPerm('accounts.delete_account') && !isDirectoryServiceAccount(row, this),
|
canDelete: () => vm.$hasPerm('accounts.delete_account'),
|
||||||
moreActionsTitle: this.$t('More'),
|
moreActionsTitle: this.$t('More'),
|
||||||
extraActions: accountOtherActions(this)
|
extraActions: accountOtherActions(this)
|
||||||
}
|
}
|
||||||
@@ -341,7 +316,7 @@ export default {
|
|||||||
can: () => {
|
can: () => {
|
||||||
return vm.$hasPerm('accounts.add_account') && !vm.$store.getters.currentOrgIsRoot
|
return vm.$hasPerm('accounts.add_account') && !vm.$store.getters.currentOrgIsRoot
|
||||||
},
|
},
|
||||||
callback: async () => {
|
callback: async() => {
|
||||||
await this.getAssetDetail()
|
await this.getAssetDetail()
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
vm.iAsset = this.asset
|
vm.iAsset = this.asset
|
||||||
@@ -362,7 +337,7 @@ export default {
|
|||||||
can: ({ selectedRows }) => {
|
can: ({ selectedRows }) => {
|
||||||
return selectedRows.length > 0 &&
|
return selectedRows.length > 0 &&
|
||||||
['clickhouse', 'redis', 'website', 'chatgpt'].indexOf(selectedRows[0].asset.type.value) === -1 &&
|
['clickhouse', 'redis', 'website', 'chatgpt'].indexOf(selectedRows[0].asset.type.value) === -1 &&
|
||||||
!this.$store.getters.currentOrgIsRoot && vm.$hasPerm('accounts.verify_account')
|
!this.$store.getters.currentOrgIsRoot
|
||||||
},
|
},
|
||||||
callback: function({ selectedRows }) {
|
callback: function({ selectedRows }) {
|
||||||
const ids = selectedRows.map(v => {
|
const ids = selectedRows.map(v => {
|
||||||
@@ -478,7 +453,7 @@ export default {
|
|||||||
this.$refs.ListTable.reloadTable()
|
this.$refs.ListTable.reloadTable()
|
||||||
},
|
},
|
||||||
async getAssetDetail() {
|
async getAssetDetail() {
|
||||||
const { query: { asset } } = this.$route
|
const { query: { asset }} = this.$route
|
||||||
if (asset) {
|
if (asset) {
|
||||||
this.iAsset = await this.$axios.get(`/api/v1/assets/assets/${asset}/`)
|
this.iAsset = await this.$axios.get(`/api/v1/assets/assets/${asset}/`)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,10 +49,6 @@ export default {
|
|||||||
prop: 'asset',
|
prop: 'asset',
|
||||||
label: this.$t('Asset')
|
label: this.$t('Asset')
|
||||||
},
|
},
|
||||||
{
|
|
||||||
prop: 'account',
|
|
||||||
label: this.$t('Account')
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
prop: 'state',
|
prop: 'state',
|
||||||
label: this.$t('Status'),
|
label: this.$t('Status'),
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Dialog from '@/components/Dialog/index.vue'
|
import Dialog from '@/components/Dialog/index.vue'
|
||||||
import { openTaskPage } from '@/utils/jms/index'
|
import { openTaskPage } from '@/utils/jms'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'RemoveAccount',
|
name: 'RemoveAccount',
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import Dialog from '@/components/Dialog/index.vue'
|
import Dialog from '@/components/Dialog/index.vue'
|
||||||
import { accountFieldsMeta } from '@/components/Apps/AccountCreateUpdateForm/const'
|
import { accountFieldsMeta } from '@/components/Apps/AccountCreateUpdateForm/const'
|
||||||
import { encryptPassword } from '@/utils/secure'
|
import { encryptPassword } from '@/utils/crypto'
|
||||||
import AutoDataForm from '@/components/Form/AutoDataForm/index.vue'
|
import AutoDataForm from '@/components/Form/AutoDataForm/index.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|||||||
@@ -61,7 +61,7 @@
|
|||||||
import Dialog from '@/components/Dialog/index.vue'
|
import Dialog from '@/components/Dialog/index.vue'
|
||||||
import PasswordHistoryDialog from './PasswordHistoryDialog.vue'
|
import PasswordHistoryDialog from './PasswordHistoryDialog.vue'
|
||||||
import { SecretViewerFormatter } from '@/components/Table/TableFormatters'
|
import { SecretViewerFormatter } from '@/components/Table/TableFormatters'
|
||||||
import { encryptPassword } from '@/utils/secure'
|
import { encryptPassword } from '@/utils/crypto'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ShowSecretInfo',
|
name: 'ShowSecretInfo',
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { ChoicesFormatter } from '@/components/Table/TableFormatters'
|
import { ChoicesFormatter } from '@/components/Table/TableFormatters'
|
||||||
import { openTaskPage } from '@/utils/jms/index'
|
import { openTaskPage } from '@/utils/jms'
|
||||||
|
|
||||||
export const connectivityMeta = {
|
export const connectivityMeta = {
|
||||||
formatter: ChoicesFormatter,
|
formatter: ChoicesFormatter,
|
||||||
@@ -7,23 +7,11 @@ export const connectivityMeta = {
|
|||||||
faChoices: {
|
faChoices: {
|
||||||
'-': '',
|
'-': '',
|
||||||
ok: 'fa-check-circle',
|
ok: 'fa-check-circle',
|
||||||
err: 'fa-times-circle',
|
err: 'fa-times-circle'
|
||||||
auth_err: 'fa-times-circle',
|
|
||||||
rdp_err: 'fa-times-circle',
|
|
||||||
password_err: 'fa-times-circle',
|
|
||||||
openssh_key_err: 'fa-times-circle',
|
|
||||||
ntlm_err: 'fa-times-circle',
|
|
||||||
create_temp_err: 'fa-times-circle'
|
|
||||||
},
|
},
|
||||||
classChoices: {
|
classChoices: {
|
||||||
ok: 'text-primary',
|
ok: 'text-primary',
|
||||||
err: 'text-danger',
|
err: 'text-danger'
|
||||||
auth_err: 'text-danger',
|
|
||||||
rdp_err: 'text-danger',
|
|
||||||
password_err: 'text-danger',
|
|
||||||
openssh_key_err: 'text-danger',
|
|
||||||
ntlm_err: 'text-danger',
|
|
||||||
create_temp_err: 'text-danger'
|
|
||||||
},
|
},
|
||||||
getText({ cellValue }) {
|
getText({ cellValue }) {
|
||||||
if (cellValue?.value === '-' || cellValue?.value === 'unknown') {
|
if (cellValue?.value === '-' || cellValue?.value === 'unknown') {
|
||||||
@@ -36,12 +24,7 @@ export const connectivityMeta = {
|
|||||||
width: '130px'
|
width: '130px'
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isDirectoryServiceAccount(account, vm) {
|
export const accountOtherActions = (vm) => [
|
||||||
return vm.asset && vm.asset.id !== account.asset.id
|
|
||||||
}
|
|
||||||
|
|
||||||
export const accountOtherActions = vm => {
|
|
||||||
return [
|
|
||||||
{
|
{
|
||||||
name: 'View',
|
name: 'View',
|
||||||
title: vm.$t('View'),
|
title: vm.$t('View'),
|
||||||
@@ -61,13 +44,7 @@ export const accountOtherActions = vm => {
|
|||||||
{
|
{
|
||||||
name: 'Update',
|
name: 'Update',
|
||||||
title: vm.$t('Edit'),
|
title: vm.$t('Edit'),
|
||||||
can: ({ row }) => {
|
can: vm.$hasPerm('accounts.change_account') && !vm.$store.getters.currentOrgIsRoot,
|
||||||
return (
|
|
||||||
vm.$hasPerm('accounts.change_account') &&
|
|
||||||
!vm.$store.getters.currentOrgIsRoot &&
|
|
||||||
!isDirectoryServiceAccount(row, vm)
|
|
||||||
)
|
|
||||||
},
|
|
||||||
callback: ({ row }) => {
|
callback: ({ row }) => {
|
||||||
vm.isUpdateAccount = true
|
vm.isUpdateAccount = true
|
||||||
const data = {
|
const data = {
|
||||||
@@ -86,13 +63,7 @@ export const accountOtherActions = vm => {
|
|||||||
{
|
{
|
||||||
name: 'UpdateSecret',
|
name: 'UpdateSecret',
|
||||||
title: vm.$t('EditSecret'),
|
title: vm.$t('EditSecret'),
|
||||||
can: ({ row }) => {
|
can: vm.$hasPerm('accounts.change_account') && !vm.$store.getters.currentOrgIsRoot,
|
||||||
return (
|
|
||||||
vm.$hasPerm('accounts.change_account') &&
|
|
||||||
!vm.$store.getters.currentOrgIsRoot &&
|
|
||||||
!isDirectoryServiceAccount(row, vm)
|
|
||||||
)
|
|
||||||
},
|
|
||||||
callback: ({ row }) => {
|
callback: ({ row }) => {
|
||||||
const data = {
|
const data = {
|
||||||
...vm.asset,
|
...vm.asset,
|
||||||
@@ -113,13 +84,7 @@ export const accountOtherActions = vm => {
|
|||||||
has: () => {
|
has: () => {
|
||||||
return !vm.asset
|
return !vm.asset
|
||||||
},
|
},
|
||||||
can: ({ row }) => {
|
can: vm.$hasPerm('accounts.add_account') && !vm.$store.getters.currentOrgIsRoot,
|
||||||
return (
|
|
||||||
vm.$hasPerm('accounts.add_account') &&
|
|
||||||
!vm.$store.getters.currentOrgIsRoot &&
|
|
||||||
!isDirectoryServiceAccount(row, vm)
|
|
||||||
)
|
|
||||||
},
|
|
||||||
callback: ({ row }) => {
|
callback: ({ row }) => {
|
||||||
vm.account = {
|
vm.account = {
|
||||||
name: `${row.name} - ${vm.$t('Duplicate').toLowerCase()}`,
|
name: `${row.name} - ${vm.$t('Duplicate').toLowerCase()}`,
|
||||||
@@ -144,9 +109,10 @@ export const accountOtherActions = vm => {
|
|||||||
row.asset['auto_config'].ansible_enabled &&
|
row.asset['auto_config'].ansible_enabled &&
|
||||||
row.asset['auto_config'].ping_enabled,
|
row.asset['auto_config'].ping_enabled,
|
||||||
callback: ({ row }) => {
|
callback: ({ row }) => {
|
||||||
vm.$axios
|
vm.$axios.post(
|
||||||
.post(`/api/v1/accounts/accounts/tasks/`, { action: 'verify', accounts: [row.id] })
|
`/api/v1/accounts/accounts/tasks/`,
|
||||||
.then(res => {
|
{ action: 'verify', accounts: [row.id] }
|
||||||
|
).then(res => {
|
||||||
openTaskPage(res['task'])
|
openTaskPage(res['task'])
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -154,14 +120,13 @@ export const accountOtherActions = vm => {
|
|||||||
{
|
{
|
||||||
name: 'ClearSecret',
|
name: 'ClearSecret',
|
||||||
title: vm.$t('ClearSecret'),
|
title: vm.$t('ClearSecret'),
|
||||||
can: ({ row }) => {
|
can: vm.$hasPerm('accounts.change_account'),
|
||||||
return vm.$hasPerm('accounts.change_account') && !isDirectoryServiceAccount(row, vm)
|
|
||||||
},
|
|
||||||
type: 'primary',
|
type: 'primary',
|
||||||
callback: ({ row }) => {
|
callback: ({ row }) => {
|
||||||
vm.$axios
|
vm.$axios.patch(
|
||||||
.patch(`/api/v1/accounts/accounts/clear-secret/`, { account_ids: [row.id] })
|
`/api/v1/accounts/accounts/clear-secret/`,
|
||||||
.then(() => {
|
{ account_ids: [row.id] }
|
||||||
|
).then(() => {
|
||||||
vm.$message.success(vm.$tc('ClearSuccessMsg'))
|
vm.$message.success(vm.$tc('ClearSuccessMsg'))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -186,13 +151,7 @@ export const accountOtherActions = vm => {
|
|||||||
title: vm.$t('CopyToAsset'),
|
title: vm.$t('CopyToAsset'),
|
||||||
type: 'primary',
|
type: 'primary',
|
||||||
divided: true,
|
divided: true,
|
||||||
can: ({ row }) => {
|
can: () => vm.$hasPerm('accounts.add_account') && !vm.$store.getters.currentOrgIsRoot,
|
||||||
return (
|
|
||||||
vm.$hasPerm('accounts.add_account') &&
|
|
||||||
!vm.$store.getters.currentOrgIsRoot &&
|
|
||||||
!isDirectoryServiceAccount(row, vm)
|
|
||||||
)
|
|
||||||
},
|
|
||||||
has: () => {
|
has: () => {
|
||||||
return !vm.asset
|
return !vm.asset
|
||||||
},
|
},
|
||||||
@@ -208,13 +167,7 @@ export const accountOtherActions = vm => {
|
|||||||
name: 'MoveToOther',
|
name: 'MoveToOther',
|
||||||
title: vm.$t('MoveToAsset'),
|
title: vm.$t('MoveToAsset'),
|
||||||
type: 'primary',
|
type: 'primary',
|
||||||
can: ({ row }) => {
|
can: () => vm.$hasPerm('accounts.add_account') && !vm.$store.getters.currentOrgIsRoot,
|
||||||
return (
|
|
||||||
vm.$hasPerm('accounts.delete_account') &&
|
|
||||||
!vm.$store.getters.currentOrgIsRoot &&
|
|
||||||
!isDirectoryServiceAccount(row, vm)
|
|
||||||
)
|
|
||||||
},
|
|
||||||
has: () => {
|
has: () => {
|
||||||
return !vm.asset
|
return !vm.asset
|
||||||
},
|
},
|
||||||
@@ -226,10 +179,9 @@ export const accountOtherActions = vm => {
|
|||||||
vm.showAddDialog = true
|
vm.showAddDialog = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
|
||||||
|
|
||||||
export const accountQuickFilters = vm => [
|
export const accountQuickFilters = (vm) => [
|
||||||
{
|
{
|
||||||
label: vm.$t('Recent (7 days)'),
|
label: vm.$t('Recent (7 days)'),
|
||||||
options: [
|
options: [
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import TreeTable from '../../Table/TreeTable/index.vue'
|
import TreeTable from '../../Table/TreeTable/index.vue'
|
||||||
import { setRouterQuery, setUrlParam } from '@/utils/common/index'
|
import { setRouterQuery, setUrlParam } from '@/utils/common'
|
||||||
import $ from '@/utils/jquery-vendor'
|
import $ from '@/utils/jquery-vendor'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -114,11 +114,6 @@ export default {
|
|||||||
treeUrl: `${this.typeUrl}?assets=${showAssets ? '1' : '0'}&count_resource=${this.treeSetting.countResource || 'asset'}`,
|
treeUrl: `${this.typeUrl}?assets=${showAssets ? '1' : '0'}&count_resource=${this.treeSetting.countResource || 'asset'}`,
|
||||||
callback: {
|
callback: {
|
||||||
onSelected: (event, treeNode) => this.getAssetsUrl(treeNode)
|
onSelected: (event, treeNode) => this.getAssetsUrl(treeNode)
|
||||||
},
|
|
||||||
edit: {
|
|
||||||
drag: {
|
|
||||||
isMove: false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div v-if="hasPrompt" class="chat-action">
|
<div class="chat-action">
|
||||||
<Select2
|
<Select2
|
||||||
v-model="select.value"
|
v-model="select.value"
|
||||||
:disabled="isLoading || isSelectDisabled"
|
:disabled="isLoading || isSelectDisabled"
|
||||||
@@ -36,10 +36,6 @@ export default {
|
|||||||
expanded: {
|
expanded: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
},
|
|
||||||
hasPrompt: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
<!-- eslint-disable-next-line -->
|
<!-- eslint-disable-next-line -->
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
<p>
|
<p>
|
||||||
<MessageText :message="item.reasoning" @insert-code="handleInsertCode" />
|
<MessageText :message="item.reasoning" />
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -41,7 +41,8 @@
|
|||||||
<span v-if="isServerError" class="error">
|
<span v-if="isServerError" class="error">
|
||||||
{{ isServerError }}
|
{{ isServerError }}
|
||||||
</span>
|
</span>
|
||||||
<MessageText :message="item.result" :is-terminal="isTerminal" @insert-code="handleInsertCode" /></div>
|
<MessageText :message="item.result" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="action">
|
<div class="action">
|
||||||
@@ -77,9 +78,9 @@
|
|||||||
<script>
|
<script>
|
||||||
import MessageText from './MessageText.vue'
|
import MessageText from './MessageText.vue'
|
||||||
import { mapGetters, mapState } from 'vuex'
|
import { mapGetters, mapState } from 'vuex'
|
||||||
import { copy } from '@/utils/common/index'
|
import { copy } from '@/utils/common'
|
||||||
import { useChat } from '../../useChat.js'
|
import { useChat } from '../../useChat.js'
|
||||||
import { reconnect } from '@/utils/request'
|
import { reconnect } from '@/utils/socket'
|
||||||
|
|
||||||
const { setLoading, removeLoadingMessageInChat } = useChat()
|
const { setLoading, removeLoadingMessageInChat } = useChat()
|
||||||
|
|
||||||
@@ -92,10 +93,6 @@ export default {
|
|||||||
type: Object,
|
type: Object,
|
||||||
default: () => {
|
default: () => {
|
||||||
}
|
}
|
||||||
},
|
|
||||||
isTerminal: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
@@ -145,9 +142,6 @@ export default {
|
|||||||
if (value === 'copy') {
|
if (value === 'copy') {
|
||||||
copy(this.item.result.content)
|
copy(this.item.result.content)
|
||||||
}
|
}
|
||||||
},
|
|
||||||
handleInsertCode(code) {
|
|
||||||
this.$emit('insert-code', code)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import mdKatex from '@traptitech/markdown-it-katex'
|
|||||||
import mila from 'markdown-it-link-attributes'
|
import mila from 'markdown-it-link-attributes'
|
||||||
import hljs from 'highlight.js'
|
import hljs from 'highlight.js'
|
||||||
import 'highlight.js/styles/atom-one-dark.css'
|
import 'highlight.js/styles/atom-one-dark.css'
|
||||||
import { copy } from '@/utils/common/index'
|
import { copy } from '@/utils/common'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
@@ -25,10 +25,6 @@ export default {
|
|||||||
type: Object,
|
type: Object,
|
||||||
default: () => {
|
default: () => {
|
||||||
}
|
}
|
||||||
},
|
|
||||||
isTerminal: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
@@ -49,10 +45,10 @@ export default {
|
|||||||
this.init()
|
this.init()
|
||||||
},
|
},
|
||||||
updated() {
|
updated() {
|
||||||
this.addEvents()
|
this.addCopyEvents()
|
||||||
},
|
},
|
||||||
destroyed() {
|
destroyed() {
|
||||||
this.removeEvents()
|
this.removeCopyEvents()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
init() {
|
init() {
|
||||||
@@ -69,68 +65,30 @@ export default {
|
|||||||
return vm.highlightBlock(hljs.highlightAuto(code).value, '')
|
return vm.highlightBlock(hljs.highlightAuto(code).value, '')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.markdown.use(mila, { attrs: { target: '_blank', rel: 'noopener', class: 'link-style' } })
|
this.markdown.use(mila, { attrs: { target: '_blank', rel: 'noopener', class: 'link-style' }})
|
||||||
this.markdown.use(mdKatex, { blockClass: 'katexmath-block rounded-md', errorColor: ' #cc0000' })
|
this.markdown.use(mdKatex, { blockClass: 'katexmath-block rounded-md', errorColor: ' #cc0000' })
|
||||||
},
|
},
|
||||||
highlightBlock(str, lang) {
|
highlightBlock(str, lang) {
|
||||||
let insertSpanHtml = `<span class="code-block-header__insert">${this.$t('Insert')}</span>`
|
return `<pre class="code-block-wrapper"><div class="code-block-header"><span class="code-block-header__lang">${lang}</span><span class="code-block-header__copy">${'Copy'}</span></div><code class="hljs code-block-body ${lang}">${str}</code></pre>`
|
||||||
if (!this.isTerminal) {
|
|
||||||
insertSpanHtml = ''
|
|
||||||
}
|
|
||||||
return `<pre class="code-block-wrapper">
|
|
||||||
<div class="code-block-header">
|
|
||||||
<span class="code-block-header__lang">${lang}</span>
|
|
||||||
<span class="code-block-header__actions">
|
|
||||||
${insertSpanHtml}
|
|
||||||
<span class="code-block-header__copy">${this.$t('Copy')}</span>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<code class="hljs code-block-body ${lang}">${str}</code></pre>`
|
|
||||||
},
|
},
|
||||||
addEvents() {
|
addCopyEvents() {
|
||||||
this.addBtnClickEvents('.code-block-header__copy', this.handlerClickCopy)
|
const copyBtn = document.querySelectorAll('.code-block-header__copy')
|
||||||
this.addBtnClickEvents('.code-block-header__insert', this.handlerClickInsert)
|
copyBtn.forEach((btn) => {
|
||||||
},
|
btn.addEventListener('click', () => {
|
||||||
|
const code = btn.parentElement?.nextElementSibling?.textContent
|
||||||
handlerClickCopy(event) {
|
if (code) {
|
||||||
const wrapper = event.target.closest('.code-block-wrapper')
|
copy(code)
|
||||||
if (wrapper) {
|
|
||||||
// 查找里面的 code 元素
|
|
||||||
const codeElement = wrapper.querySelector('code.code-block-body')
|
|
||||||
if (codeElement) {
|
|
||||||
const codeText = codeElement.textContent
|
|
||||||
copy(codeText)
|
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
},
|
|
||||||
handlerClickInsert(event) {
|
|
||||||
const wrapper = event.target.closest('.code-block-wrapper')
|
|
||||||
if (wrapper) {
|
|
||||||
// 查找里面的 code 元素
|
|
||||||
const codeElement = wrapper.querySelector('code.code-block-body')
|
|
||||||
if (codeElement) {
|
|
||||||
const codeText = codeElement.textContent
|
|
||||||
this.$emit('insert-code', codeText)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
addBtnClickEvents(selector, callback) {
|
|
||||||
const buttons = this.$refs.textRef.querySelectorAll(selector)
|
|
||||||
buttons.forEach((btn) => {
|
|
||||||
btn.addEventListener('click', callback)
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
removeBtnClickEvent(selector) {
|
removeCopyEvents() {
|
||||||
const buttons = this.$refs.textRef.querySelectorAll(selector)
|
if (this.$refs.textRef) {
|
||||||
buttons.forEach((btn) => {
|
const copyBtn = this.$refs.textRef.querySelectorAll('.code-block-header__copy')
|
||||||
|
copyBtn.forEach((btn) => {
|
||||||
btn.removeEventListener('click', () => {
|
btn.removeEventListener('click', () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
|
||||||
removeEvents() {
|
|
||||||
if (this.$refs.textRef) {
|
|
||||||
this.removeBtnClickEvent('.code-block-header__copy')
|
|
||||||
this.addBtnClickEvents('.code-block-header__insert')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -140,7 +98,6 @@ export default {
|
|||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.markdown-body {
|
.markdown-body {
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
max-width: 300px;;
|
|
||||||
|
|
||||||
&::v-deep p {
|
&::v-deep p {
|
||||||
margin-bottom: 0 !important;
|
margin-bottom: 0 !important;
|
||||||
@@ -158,48 +115,28 @@ export default {
|
|||||||
|
|
||||||
&::v-deep .code-block-wrapper {
|
&::v-deep .code-block-wrapper {
|
||||||
background: #1F2329;
|
background: #1F2329;
|
||||||
padding: 0;
|
padding: 2px 6px;
|
||||||
margin: 5px 0;
|
margin: 5px 0;
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
overflow: hidden;
|
|
||||||
|
|
||||||
.code-block-body {
|
.code-block-body {
|
||||||
padding: 5px 10px;
|
padding: 5px 10px 0;
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
.code-block-header {
|
.code-block-header {
|
||||||
margin-bottom: 4px;
|
margin-bottom: 4px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background: #353946;
|
background: #353946;
|
||||||
color: #c2d1e1;
|
color: #c2d1e1;
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
padding: 4px 8px;
|
|
||||||
width: 100%;
|
|
||||||
box-sizing: border-box;
|
|
||||||
|
|
||||||
.code-block-header__actions {
|
|
||||||
display: flex;
|
|
||||||
gap: 8px;
|
|
||||||
|
|
||||||
.code-block-header__copy {
|
.code-block-header__copy {
|
||||||
|
float: right;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
color: #6e747b;
|
color: #6e747b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.code-block-header__insert {
|
|
||||||
cursor: pointer;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
color: #6e747b;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.hljs.code-block-body.javascript {
|
.hljs.code-block-body.javascript {
|
||||||
@@ -241,7 +178,6 @@ export default {
|
|||||||
0% {
|
0% {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
100% {
|
100% {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<ChatMessage v-for="(item, index) in activeChat.chats" :key="index" :item="item" :is-terminal="isTerminal" @insert-code="insertCode" />
|
<ChatMessage v-for="(item, index) in activeChat.chats" :key="index" :item="item" />
|
||||||
</div>
|
</div>
|
||||||
<div class="input-box">
|
<div class="input-box">
|
||||||
<el-button
|
<el-button
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
size="small"
|
size="small"
|
||||||
@click="onStopHandle"
|
@click="onStopHandle"
|
||||||
>{{ $tc('Stop') }}</el-button>
|
>{{ $tc('Stop') }}</el-button>
|
||||||
<ChatInput ref="chatInput" :expanded="expanded" :has-prompt="!isTerminal" @send="onSendHandle" @select-prompt="onSelectPromptHandle" />
|
<ChatInput ref="chatInput" :expanded="expanded" @send="onSendHandle" @select-prompt="onSelectPromptHandle" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
import ChatInput from './ChatInput.vue'
|
import ChatInput from './ChatInput.vue'
|
||||||
import ChatMessage from './ChatMessage.vue'
|
import ChatMessage from './ChatMessage.vue'
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
import { closeWebSocket, createWebSocket, onSend, ws } from '@/utils/request'
|
import { closeWebSocket, createWebSocket, onSend, ws } from '@/utils/socket'
|
||||||
import { getInputFocus, useChat } from '../../useChat.js'
|
import { getInputFocus, useChat } from '../../useChat.js'
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@@ -68,10 +68,7 @@ export default {
|
|||||||
prompt: '',
|
prompt: '',
|
||||||
conversationId: '',
|
conversationId: '',
|
||||||
showIntroduction: false,
|
showIntroduction: false,
|
||||||
introduction: [],
|
introduction: []
|
||||||
terminalContext: null,
|
|
||||||
isTerminal: false,
|
|
||||||
sessionChat: {}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -103,9 +100,6 @@ export default {
|
|||||||
this.showIntroduction = true
|
this.showIntroduction = true
|
||||||
this.conversationId = ''
|
this.conversationId = ''
|
||||||
this.$refs.chatInput.select.value = ''
|
this.$refs.chatInput.select.value = ''
|
||||||
if (this.terminalContext) {
|
|
||||||
this.prompt = this.terminalContext.content || ''
|
|
||||||
}
|
|
||||||
const chat = {
|
const chat = {
|
||||||
message: {
|
message: {
|
||||||
content: this.$t('ChatHello'),
|
content: this.$t('ChatHello'),
|
||||||
@@ -156,32 +150,6 @@ export default {
|
|||||||
addMessageToActiveChat(data)
|
addMessageToActiveChat(data)
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
},
|
},
|
||||||
onTerminalContext(terminalContext) {
|
|
||||||
const originSessionId = this.terminalContext?.sessionId
|
|
||||||
const newSessionId = terminalContext.sessionId || ''
|
|
||||||
if (originSessionId) {
|
|
||||||
this.saveSessionChat(originSessionId)
|
|
||||||
}
|
|
||||||
this.terminalContext = terminalContext
|
|
||||||
this.isTerminal = true
|
|
||||||
this.prompt = terminalContext.content || ''
|
|
||||||
if (originSessionId !== newSessionId) {
|
|
||||||
if (this.sessionChat[newSessionId]) {
|
|
||||||
clearChats()
|
|
||||||
for (const chat of this.sessionChat[newSessionId]) {
|
|
||||||
addChatMessageById(chat)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.onNewChat()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
saveSessionChat(sessionId) {
|
|
||||||
if (this.terminalContext) {
|
|
||||||
this.sessionChat[sessionId] = JSON.parse(JSON.stringify(this.activeChat.chats))
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
onSendHandle(value) {
|
onSendHandle(value) {
|
||||||
this.showIntroduction = false
|
this.showIntroduction = false
|
||||||
this.socket = ws || {}
|
this.socket = ws || {}
|
||||||
@@ -236,15 +204,6 @@ export default {
|
|||||||
sendIntroduction(item) {
|
sendIntroduction(item) {
|
||||||
this.showIntroduction = false
|
this.showIntroduction = false
|
||||||
this.onSendHandle(item.content)
|
this.onSendHandle(item.content)
|
||||||
},
|
|
||||||
insertCode(code) {
|
|
||||||
this.sendPostMessage({
|
|
||||||
name: 'INSERT_TERMINAL_CODE',
|
|
||||||
data: code.replace(/^[\s\r\n]+|[\s\r\n]+$/g, '')
|
|
||||||
})
|
|
||||||
},
|
|
||||||
sendPostMessage(data) {
|
|
||||||
window.parent.postMessage(data)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { BASE_URL } from '@/utils/common/index'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
active: {
|
active: {
|
||||||
@@ -43,16 +41,6 @@ export default {
|
|||||||
},
|
},
|
||||||
handleExpand() {
|
handleExpand() {
|
||||||
this.$emit('expand-full')
|
this.$emit('expand-full')
|
||||||
},
|
|
||||||
async openWebsite() {
|
|
||||||
let url = `${BASE_URL}/?_=${Date.now()}`
|
|
||||||
if (process.env.NODE_ENV !== 'production') {
|
|
||||||
url = url.replace('9528', '5173')
|
|
||||||
}
|
|
||||||
|
|
||||||
const newUrl = new URL(url)
|
|
||||||
window.open(newUrl.toString(), '_blank')
|
|
||||||
return url
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<DrawerPanel
|
<DrawerPanel
|
||||||
v-if="visible"
|
|
||||||
ref="drawer"
|
ref="drawer"
|
||||||
:default-show-panel="!!defaultShowPanel"
|
:default-show-panel="!!defaultShowPanel"
|
||||||
:expanded="expanded"
|
:expanded="expanded"
|
||||||
@@ -46,12 +45,9 @@
|
|||||||
import Sidebar from './components/Sidebar/index.vue'
|
import Sidebar from './components/Sidebar/index.vue'
|
||||||
import Chat from './components/ChitChat/index.vue'
|
import Chat from './components/ChitChat/index.vue'
|
||||||
import { getInputFocus } from './useChat.js'
|
import { getInputFocus } from './useChat.js'
|
||||||
import { ws } from '@/utils/request'
|
import { ws } from '@/utils/socket'
|
||||||
import DrawerPanel from '@/components/Apps/DrawerPanel/index.vue'
|
import DrawerPanel from '@/components/Apps/DrawerPanel/index.vue'
|
||||||
import { ObjectLocalStorage } from '@/utils/common'
|
|
||||||
import { mapGetters } from 'vuex'
|
|
||||||
|
|
||||||
const aiPannelLocalStorage = new ObjectLocalStorage('ai_panel_settings')
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
DrawerPanel,
|
DrawerPanel,
|
||||||
@@ -76,68 +72,23 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
visible: false,
|
|
||||||
active: 'chat',
|
active: 'chat',
|
||||||
robotUrl: require('@/assets/img/robot-assistant.png'),
|
robotUrl: require('@/assets/img/robot-assistant.png'),
|
||||||
height: '400px',
|
height: '400px',
|
||||||
expanded: false,
|
expanded: false,
|
||||||
clientOffset: {},
|
clientOffset: {}
|
||||||
currentTerminalContent: {}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
|
||||||
...mapGetters([
|
|
||||||
'publicSettings'
|
|
||||||
])
|
|
||||||
},
|
|
||||||
watch: {
|
watch: {
|
||||||
'publicSettings.CHAT_AI_METHOD': {
|
|
||||||
handler(newVal) {
|
|
||||||
this.visible = newVal === 'api'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.handleStartChat()
|
this.handlePostMessage()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleStartChat() {
|
|
||||||
if (this.publicSettings.CHAT_AI_METHOD === 'api') {
|
|
||||||
this.visible = true
|
|
||||||
const expanded = aiPannelLocalStorage.get('expanded')
|
|
||||||
this.updateExpandedState(expanded)
|
|
||||||
this.handlePostMessage()
|
|
||||||
} else if (this.publicSettings.CHAT_AI_METHOD === 'embed') {
|
|
||||||
const embedScriptId = 'chat-ai-embed-id'
|
|
||||||
if (document.getElementById(embedScriptId)) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const script = document.createElement('script')
|
|
||||||
script.id = embedScriptId
|
|
||||||
script.src = this.publicSettings.CHAT_AI_EMBED_URL
|
|
||||||
script.async = true
|
|
||||||
script.onload = () => {
|
|
||||||
const loadEvent = new Event('load', { bubbles: false, cancelable: false })
|
|
||||||
window.dispatchEvent(loadEvent)
|
|
||||||
}
|
|
||||||
document.body.appendChild(script)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
handlePostMessage() {
|
handlePostMessage() {
|
||||||
window.addEventListener('message', (event) => {
|
window.addEventListener('message', (event) => {
|
||||||
if (event.data === 'show-chat-panel') {
|
if (event.data === 'show-chat-panel') {
|
||||||
this.$refs.drawer.show = true
|
this.$refs.drawer.show = true
|
||||||
this.initWebSocket()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const msg = event.data
|
|
||||||
switch (msg.name) {
|
|
||||||
case 'current_terminal_content':
|
|
||||||
// {content: '...', terminalId: '',sessionId: '',viewId: '',viewName: ''}
|
|
||||||
this.$log.debug('current_terminal_content', msg)
|
|
||||||
this.currentTerminalContent = msg.data
|
|
||||||
this.$refs.component?.onTerminalContext(msg.data)
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -145,11 +96,6 @@ export default {
|
|||||||
this.$refs.drawer.handleHeaderMoveDown(event)
|
this.$refs.drawer.handleHeaderMoveDown(event)
|
||||||
},
|
},
|
||||||
handleMouseMoveUp(event) {
|
handleMouseMoveUp(event) {
|
||||||
// Prevent the new chat button from triggering the header move up
|
|
||||||
const newButton = event.target.closest('.new')
|
|
||||||
if (newButton) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.$refs.drawer.handleHeaderMoveUp(event)
|
this.$refs.drawer.handleHeaderMoveUp(event)
|
||||||
},
|
},
|
||||||
initWebSocket() {
|
initWebSocket() {
|
||||||
@@ -161,20 +107,12 @@ export default {
|
|||||||
this.$refs.drawer.show = false
|
this.$refs.drawer.show = false
|
||||||
},
|
},
|
||||||
expandFull() {
|
expandFull() {
|
||||||
this.updateExpandedState(true)
|
this.height = '100%'
|
||||||
this.save_pannel_settings()
|
this.expanded = true
|
||||||
},
|
},
|
||||||
compress() {
|
compress() {
|
||||||
this.updateExpandedState(false)
|
this.height = '400px'
|
||||||
this.save_pannel_settings()
|
this.expanded = false
|
||||||
},
|
|
||||||
save_pannel_settings() {
|
|
||||||
aiPannelLocalStorage.set('expanded', this.expanded)
|
|
||||||
console.log('AI panel settings saved:', this.expanded)
|
|
||||||
},
|
|
||||||
updateExpandedState(expanded) {
|
|
||||||
this.expanded = expanded
|
|
||||||
this.height = expanded ? '100%' : '400px'
|
|
||||||
},
|
},
|
||||||
onNewChat() {
|
onNewChat() {
|
||||||
this.active = 'chat'
|
this.active = 'chat'
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import store from '@/store'
|
import store from '@/store'
|
||||||
import { pageScroll } from '@/utils/common/index'
|
import { pageScroll } from '@/utils/common'
|
||||||
|
|
||||||
export const getInputFocus = () => {
|
export const getInputFocus = () => {
|
||||||
const dom = document.querySelector('.chat-input .el-textarea__inner')
|
const dom = document.querySelector('.chat-input .el-textarea__inner')
|
||||||
@@ -9,11 +9,11 @@ export const getInputFocus = () => {
|
|||||||
export function useChat() {
|
export function useChat() {
|
||||||
const chatStore = {}
|
const chatStore = {}
|
||||||
|
|
||||||
const setLoading = loading => {
|
const setLoading = (loading) => {
|
||||||
store.commit('chat/setLoading', loading)
|
store.commit('chat/setLoading', loading)
|
||||||
}
|
}
|
||||||
|
|
||||||
const onNewChat = name => {
|
const onNewChat = (name) => {
|
||||||
const data = {
|
const data = {
|
||||||
name: name || `new chat`,
|
name: name || `new chat`,
|
||||||
id: 1,
|
id: 1,
|
||||||
@@ -27,7 +27,7 @@ export function useChat() {
|
|||||||
store.commit('chat/clearChats')
|
store.commit('chat/clearChats')
|
||||||
}
|
}
|
||||||
|
|
||||||
const addMessageToActiveChat = chat => {
|
const addMessageToActiveChat = (chat) => {
|
||||||
store.commit('chat/addMessageToActiveChat', chat)
|
store.commit('chat/addMessageToActiveChat', chat)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ export function useChat() {
|
|||||||
store.commit('chat/removeLoadingMessageInChat')
|
store.commit('chat/removeLoadingMessageInChat')
|
||||||
}
|
}
|
||||||
|
|
||||||
const addChatMessageById = chat => {
|
const addChatMessageById = (chat) => {
|
||||||
store.commit('chat/addMessageToActiveChat', chat)
|
store.commit('chat/addMessageToActiveChat', chat)
|
||||||
if (chat?.conversation_id) {
|
if (chat?.conversation_id) {
|
||||||
store.commit('chat/setActiveChatConversationId', chat.conversation_id)
|
store.commit('chat/setActiveChatConversationId', chat.conversation_id)
|
||||||
@@ -54,7 +54,7 @@ export function useChat() {
|
|||||||
addChatMessageById(temporaryChat)
|
addChatMessageById(temporaryChat)
|
||||||
}
|
}
|
||||||
|
|
||||||
const newChatAndAddMessageById = chat => {
|
const newChatAndAddMessageById = (chat) => {
|
||||||
onNewChat(chat.message.content)
|
onNewChat(chat.message.content)
|
||||||
addChatMessageById(chat)
|
addChatMessageById(chat)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Dialog from '@/components/Dialog/index.vue'
|
import Dialog from '@/components/Dialog/index.vue'
|
||||||
import { openTaskPage } from '@/utils/jms/index'
|
import { openTaskPage } from '@/utils/jms'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'GatewayDialog',
|
name: 'GatewayDialog',
|
||||||
|
|||||||
@@ -85,7 +85,6 @@ export default {
|
|||||||
hasTree: true,
|
hasTree: true,
|
||||||
columnsExtra: ['view_account'],
|
columnsExtra: ['view_account'],
|
||||||
columnsExclude: ['spec_info'],
|
columnsExclude: ['spec_info'],
|
||||||
columns: ['id', 'name', 'address', 'comment', 'labels', 'connectivity', 'platform', 'view_account', 'actions'],
|
|
||||||
columnsShow: {
|
columnsShow: {
|
||||||
min: ['name', 'address', 'accounts'],
|
min: ['name', 'address', 'accounts'],
|
||||||
default: ['name', 'address', 'platform', 'view_account', 'actions']
|
default: ['name', 'address', 'platform', 'view_account', 'actions']
|
||||||
@@ -109,6 +108,11 @@ export default {
|
|||||||
},
|
},
|
||||||
connectivity: connectivityMeta,
|
connectivity: connectivityMeta,
|
||||||
comment: { ...this.comment }
|
comment: { ...this.comment }
|
||||||
|
},
|
||||||
|
tableAttrs: {
|
||||||
|
rowClassName({ row }) {
|
||||||
|
return !row.is_active ? 'row_disabled' : ''
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
headerActions: {
|
headerActions: {
|
||||||
|
|||||||
@@ -1,63 +0,0 @@
|
|||||||
<template>
|
|
||||||
<ListTable ref="ListTable" :header-actions="headerActions" :table-config="tableConfig" :create-drawer="createDrawer" />
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { DrawerListTable as ListTable } from '@/components'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'LeakPasswordList',
|
|
||||||
components: {
|
|
||||||
ListTable
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
object: {
|
|
||||||
type: Object,
|
|
||||||
required: false,
|
|
||||||
default: () => ({})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
createDrawer: () => import('@/components/Apps/LeakPasswords/LeakPasswordsCreateUpdate.vue'),
|
|
||||||
tableConfig: {
|
|
||||||
url: '/api/v1/settings/leak-passwords/',
|
|
||||||
columns: [
|
|
||||||
'password'
|
|
||||||
],
|
|
||||||
columnsMeta: {
|
|
||||||
actions: {
|
|
||||||
formatterArgs: {
|
|
||||||
hasClone: false,
|
|
||||||
canDelete: this.$hasPerm('settings.change_security'),
|
|
||||||
canUpdate: this.$hasPerm('settings.change_security')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
headerActions: {
|
|
||||||
hasExport: true,
|
|
||||||
hasImport: true,
|
|
||||||
importOptions: {
|
|
||||||
encryptFields: [''], // 这里不加密 password,''只是为了保证数组有值
|
|
||||||
canImportUpdate: false
|
|
||||||
},
|
|
||||||
hasCreate: true,
|
|
||||||
hasSearch: true,
|
|
||||||
hasRefresh: true,
|
|
||||||
hasBulkDelete: true,
|
|
||||||
hasBulkUpdate: false,
|
|
||||||
hasLeftActions: true,
|
|
||||||
hasRightActions: true,
|
|
||||||
canCreate: this.$hasPerm('settings.change_security'),
|
|
||||||
canBulkDelete: this.$hasPerm('settings.change_security')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang='less' scoped>
|
|
||||||
|
|
||||||
</style>
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div v-loading="loading">
|
|
||||||
<GenericCreateUpdatePage
|
|
||||||
v-if="!loading"
|
|
||||||
class="user-create-update"
|
|
||||||
v-bind="$data"
|
|
||||||
:title="null"
|
|
||||||
v-on="$listeners"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { GenericCreateUpdatePage } from '@/layout/components'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'LeakPasswordsCreateUpdate',
|
|
||||||
components: {
|
|
||||||
GenericCreateUpdatePage
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
loading: true,
|
|
||||||
fields: [
|
|
||||||
[this.$t('Basic'), ['password']]
|
|
||||||
],
|
|
||||||
encryptedFields: [],
|
|
||||||
url: '/api/v1/settings/leak-passwords/'
|
|
||||||
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async mounted() {
|
|
||||||
this.loading = false
|
|
||||||
},
|
|
||||||
methods: {}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
|
|
||||||
</style>
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<div>
|
|
||||||
<el-button
|
|
||||||
size="mini"
|
|
||||||
type="primary"
|
|
||||||
@click="onOpenDialog"
|
|
||||||
>
|
|
||||||
{{ $tc('View') }}
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
<Dialog
|
|
||||||
:destroy-on-close="true"
|
|
||||||
:show-cancel="false"
|
|
||||||
:show-confirm="false"
|
|
||||||
:title="title"
|
|
||||||
:visible.sync="visible"
|
|
||||||
v-bind="$attrs"
|
|
||||||
width="40%"
|
|
||||||
v-on="$listeners"
|
|
||||||
>
|
|
||||||
<LeakPasswordList />
|
|
||||||
</Dialog>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { Dialog } from '@/components'
|
|
||||||
import LeakPasswordList from '@/components/Apps/LeakPasswords/LeakPasswordList.vue'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
componentName: 'LeakPasswords',
|
|
||||||
components: {
|
|
||||||
LeakPasswordList,
|
|
||||||
Dialog
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
value: {
|
|
||||||
type: Object,
|
|
||||||
default: () => ({})
|
|
||||||
},
|
|
||||||
title: {
|
|
||||||
type: String,
|
|
||||||
default: function() {
|
|
||||||
return this.$t('LeakPasswordList')
|
|
||||||
}
|
|
||||||
},
|
|
||||||
url: {
|
|
||||||
type: String,
|
|
||||||
default: `/api/v1/settings/leak-passwords/`
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
visible: false,
|
|
||||||
form: this.value,
|
|
||||||
config: {
|
|
||||||
url: this.url,
|
|
||||||
hasSaveContinue: false,
|
|
||||||
hasButtons: true,
|
|
||||||
fields: [],
|
|
||||||
fieldsMeta: {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
onOpenDialog() {
|
|
||||||
this.visible = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
</style>
|
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { DrawerListTable as ListTable } from '@/components'
|
import { DrawerListTable as ListTable } from '@/components'
|
||||||
import { toM2MJsonParams } from '@/utils/jms/index'
|
import { toM2MJsonParams } from '@/utils/jms'
|
||||||
import { DetailFormatter } from '@/components/Table/TableFormatters'
|
import { DetailFormatter } from '@/components/Table/TableFormatters'
|
||||||
import TwoCol from '@/layout/components/Page/TwoColPage.vue'
|
import TwoCol from '@/layout/components/Page/TwoColPage.vue'
|
||||||
|
|
||||||
@@ -25,7 +25,6 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
const [key, value] = toM2MJsonParams(this.object.assets)
|
const [key, value] = toM2MJsonParams(this.object.assets)
|
||||||
const org_id = this.object.org_id || this.$store.getters.currentOrg.id
|
|
||||||
return {
|
return {
|
||||||
config: {
|
config: {
|
||||||
headerActions: {
|
headerActions: {
|
||||||
@@ -34,7 +33,7 @@ export default {
|
|||||||
hasExport: false
|
hasExport: false
|
||||||
},
|
},
|
||||||
tableConfig: {
|
tableConfig: {
|
||||||
url: `/api/v1/assets/assets/?${key}=${value}&oid=${org_id}`,
|
url: `/api/v1/assets/assets/?${key}=${value}`,
|
||||||
columns: ['name', 'address', 'platform', 'type', 'is_active'],
|
columns: ['name', 'address', 'platform', 'type', 'is_active'],
|
||||||
columnsShow: {
|
columnsShow: {
|
||||||
min: ['name', 'address'],
|
min: ['name', 'address'],
|
||||||
@@ -46,7 +45,7 @@ export default {
|
|||||||
formatter: DetailFormatter,
|
formatter: DetailFormatter,
|
||||||
formatterArgs: {
|
formatterArgs: {
|
||||||
getRoute: ({ row }) => {
|
getRoute: ({ row }) => {
|
||||||
return { name: 'AssetDetail', params: { id: row.id } }
|
return { name: 'AssetDetail', params: { id: row.id }}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { DrawerListTable as ListTable } from '@/components'
|
import { DrawerListTable as ListTable } from '@/components'
|
||||||
import { toM2MJsonParams } from '@/utils/jms/index'
|
import { toM2MJsonParams } from '@/utils/jms'
|
||||||
import TwoCol from '@/layout/components/Page/TwoColPage.vue'
|
import TwoCol from '@/layout/components/Page/TwoColPage.vue'
|
||||||
import { DetailFormatter } from '@/components/Table/TableFormatters'
|
import { DetailFormatter } from '@/components/Table/TableFormatters'
|
||||||
|
|
||||||
@@ -25,7 +25,6 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
const [key, value] = toM2MJsonParams(this.object.users)
|
const [key, value] = toM2MJsonParams(this.object.users)
|
||||||
const org_id = this.object.org_id || this.$store.getters.currentOrg.id
|
|
||||||
return {
|
return {
|
||||||
config: {
|
config: {
|
||||||
headerActions: {
|
headerActions: {
|
||||||
@@ -34,7 +33,7 @@ export default {
|
|||||||
hasExport: false
|
hasExport: false
|
||||||
},
|
},
|
||||||
tableConfig: {
|
tableConfig: {
|
||||||
url: `/api/v1/users/users/?${key}=${value}&oid=${org_id}`,
|
url: `/api/v1/users/users/?${key}=${value}`,
|
||||||
columns: [
|
columns: [
|
||||||
'name', 'username', 'email', 'groups', 'system_roles',
|
'name', 'username', 'email', 'groups', 'system_roles',
|
||||||
'org_roles', 'source', 'is_valid'
|
'org_roles', 'source', 'is_valid'
|
||||||
|
|||||||
@@ -30,8 +30,8 @@
|
|||||||
<script>
|
<script>
|
||||||
import IBox from '@/components/Common/IBox/index.vue'
|
import IBox from '@/components/Common/IBox/index.vue'
|
||||||
import DiffDetail from '@/components/Dialog/DiffDetail.vue'
|
import DiffDetail from '@/components/Dialog/DiffDetail.vue'
|
||||||
import { openTaskPage } from '@/utils/jms/index'
|
import { openTaskPage } from '@/utils/jms'
|
||||||
import { toSafeLocalDateStr } from '@/utils/common/time'
|
import { toSafeLocalDateStr } from '@/utils/time'
|
||||||
import TwoCol from '@/layout/components/Page/TwoColPage.vue'
|
import TwoCol from '@/layout/components/Page/TwoColPage.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|||||||
@@ -8,17 +8,22 @@
|
|||||||
:visible.sync="visible"
|
:visible.sync="visible"
|
||||||
class="dialog-content"
|
class="dialog-content"
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
width="600px"
|
width="740px"
|
||||||
@confirm="visible = false"
|
@confirm="visible = false"
|
||||||
v-on="$listeners"
|
v-on="$listeners"
|
||||||
>
|
>
|
||||||
<div v-if="confirmTypeRequired === 'relogin'">
|
<div v-if="confirmTypeRequired === 'relogin'">
|
||||||
<el-row :gutter="24" style="margin: 0 auto">
|
<el-row :gutter="24" style="margin: 0 auto;">
|
||||||
<el-col :md="24" :sm="24">
|
<el-col :md="24" :sm="24">
|
||||||
<el-alert :title="$tc('ReLoginTitle')" center style="margin-bottom: 20px" type="error" />
|
<el-alert
|
||||||
|
:title="$tc('ReLoginTitle')"
|
||||||
|
center
|
||||||
|
style="margin-bottom: 20px;"
|
||||||
|
type="error"
|
||||||
|
/>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-row :gutter="24" style="margin: 0 auto">
|
<el-row :gutter="24" style="margin: 0 auto;">
|
||||||
<el-col :md="24" :sm="24">
|
<el-col :md="24" :sm="24">
|
||||||
<el-button class="confirm-btn" size="mini" type="primary" @click="logout">
|
<el-button class="confirm-btn" size="mini" type="primary" @click="logout">
|
||||||
{{ this.$t('ReLogin') }}
|
{{ this.$t('ReLogin') }}
|
||||||
@@ -27,11 +32,11 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<el-row :gutter="24" style="margin: 0 auto">
|
<el-row :gutter="24" style="margin: 0 auto;">
|
||||||
<el-col :md="24" :sm="24" :span="24" class="add">
|
<el-col :md="24" :sm="24" :span="24" class="add">
|
||||||
<el-select
|
<el-select
|
||||||
v-model="subTypeSelected"
|
v-model="subTypeSelected"
|
||||||
style="width: 100%; margin-bottom: 20px"
|
style="width: 100%; margin-bottom: 20px;"
|
||||||
@change="handleSubTypeChange"
|
@change="handleSubTypeChange"
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
@@ -44,46 +49,41 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-row v-if="!noCodeMFA.includes(subTypeSelected)" :gutter="24" style="margin: 0 auto">
|
<el-row :gutter="24" style="margin: 0 auto;">
|
||||||
<el-col :md="24" :sm="24" style="display: flex; align-items: center">
|
<el-col :md="24" :sm="24" style="display: flex; align-items: center; margin-bottom: 20px;">
|
||||||
<el-input
|
<el-input
|
||||||
|
v-if="subTypeSelected !== 'face'"
|
||||||
v-model="secretValue"
|
v-model="secretValue"
|
||||||
:placeholder="inputPlaceholder"
|
:placeholder="inputPlaceholder"
|
||||||
:show-password="showPassword"
|
:show-password="showPassword"
|
||||||
@keyup.enter.native="handleConfirm"
|
@keyup.enter.native="handleConfirm"
|
||||||
/>
|
/>
|
||||||
<span
|
|
||||||
v-if="subTypeSelected === 'sms' || subTypeSelected === 'email'"
|
<iframe
|
||||||
style="margin: -1px 0 0 20px"
|
v-if="isFaceCaptureVisible && subTypeSelected ==='face' && faceCaptureUrl"
|
||||||
>
|
:src="faceCaptureUrl"
|
||||||
|
allow="camera"
|
||||||
|
sandbox="allow-scripts allow-same-origin"
|
||||||
|
style="width: 100%; height: 800px;border: none;"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<span v-if="subTypeSelected === 'sms'" style="margin: -1px 0 0 20px;">
|
||||||
<el-button
|
<el-button
|
||||||
:disabled="smsBtnDisabled"
|
:disabled="smsBtnDisabled"
|
||||||
size="mini"
|
size="mini"
|
||||||
style="line-height: 14px; float: right"
|
style="line-height: 14px; float: right;"
|
||||||
type="primary"
|
type="primary"
|
||||||
@click="sendCode"
|
@click="sendSMSCode"
|
||||||
>
|
>
|
||||||
{{ smsBtnText }}
|
{{ smsBtnText }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</span>
|
</span>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-row>
|
<el-row :gutter="24" style="margin: 10px auto;">
|
||||||
<el-col>
|
|
||||||
<iframe v-if="passkeyVisible" :src="passkeyUrl" style="display: none" />
|
|
||||||
<iframe
|
|
||||||
v-if="isFaceCaptureVisible && subTypeSelected === 'face' && faceCaptureUrl"
|
|
||||||
:src="faceCaptureUrl"
|
|
||||||
allow="camera"
|
|
||||||
sandbox="allow-scripts allow-same-origin"
|
|
||||||
style="width: 100%; height: 600px; border: none"
|
|
||||||
/>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
<el-row :gutter="24" style="margin: 20px auto 10px">
|
|
||||||
<el-col :md="24" :sm="24">
|
<el-col :md="24" :sm="24">
|
||||||
<el-button
|
<el-button
|
||||||
v-if="!noCodeMFA.includes(subTypeSelected)"
|
v-if="subTypeSelected!=='face'"
|
||||||
class="confirm-btn"
|
class="confirm-btn"
|
||||||
size="mini"
|
size="mini"
|
||||||
type="primary"
|
type="primary"
|
||||||
@@ -92,8 +92,7 @@
|
|||||||
{{ this.$t('Confirm') }}
|
{{ this.$t('Confirm') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
v-if="subTypeSelected === 'face'"
|
v-if="subTypeSelected==='face'&&!isFaceCaptureVisible"
|
||||||
v-show="!isFaceCaptureVisible"
|
|
||||||
class="confirm-btn"
|
class="confirm-btn"
|
||||||
size="mini"
|
size="mini"
|
||||||
type="primary"
|
type="primary"
|
||||||
@@ -101,16 +100,6 @@
|
|||||||
>
|
>
|
||||||
{{ this.$tc('VerifyFace') }}
|
{{ this.$tc('VerifyFace') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
|
||||||
v-if="subTypeSelected === 'passkey'"
|
|
||||||
v-loading="passkeyVisible"
|
|
||||||
class="confirm-btn"
|
|
||||||
size="mini"
|
|
||||||
type="primary"
|
|
||||||
@click="handlePasskeyVerify"
|
|
||||||
>
|
|
||||||
{{ this.$tc('Next') }}
|
|
||||||
</el-button>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</div>
|
</div>
|
||||||
@@ -118,7 +107,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import Dialog from '@/components/Dialog/index.vue'
|
import Dialog from '@/components/Dialog/index.vue'
|
||||||
import { encryptPassword } from '@/utils/secure'
|
import { encryptPassword } from '@/utils/crypto'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'UserConfirmDialog',
|
name: 'UserConfirmDialog',
|
||||||
@@ -152,11 +141,7 @@ export default {
|
|||||||
processing: false,
|
processing: false,
|
||||||
isFaceCaptureVisible: false,
|
isFaceCaptureVisible: false,
|
||||||
faceToken: null,
|
faceToken: null,
|
||||||
faceCaptureUrl: null,
|
faceCaptureUrl: null
|
||||||
noCodeMFA: ['face', 'passkey'],
|
|
||||||
sendCodeMFA: ['email', 'sms', 'otp'],
|
|
||||||
passkeyVisible: false,
|
|
||||||
passkeyUrl: '/api/v1/authentication/passkeys/login/?mfa=1'
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -189,19 +174,14 @@ export default {
|
|||||||
this.$log.debug('perform confirm action')
|
this.$log.debug('perform confirm action')
|
||||||
const confirmType = response.data?.code
|
const confirmType = response.data?.code
|
||||||
const confirmUrl = '/api/v1/authentication/confirm/'
|
const confirmUrl = '/api/v1/authentication/confirm/'
|
||||||
this.$axios
|
this.$axios.get(confirmUrl, { params: { confirm_type: confirmType }}).then((data) => {
|
||||||
.get(confirmUrl, { params: { confirm_type: confirmType } })
|
|
||||||
.then(data => {
|
|
||||||
this.confirmTypeRequired = data.confirm_type
|
this.confirmTypeRequired = data.confirm_type
|
||||||
|
|
||||||
if (this.confirmTypeRequired === 'relogin') {
|
if (this.confirmTypeRequired === 'relogin') {
|
||||||
this.$axios
|
this.$axios.post(confirmUrl, { 'confirm_type': 'relogin', 'secret_key': 'x' }).then(() => {
|
||||||
.post(confirmUrl, { confirm_type: 'relogin', secret_key: 'x' })
|
|
||||||
.then(() => {
|
|
||||||
this.callback()
|
this.callback()
|
||||||
this.visible = false
|
this.visible = false
|
||||||
})
|
}).catch(() => {
|
||||||
.catch(() => {
|
|
||||||
this.title = this.$t('NeedReLogin')
|
this.title = this.$t('NeedReLogin')
|
||||||
this.visible = true
|
this.visible = true
|
||||||
})
|
})
|
||||||
@@ -212,24 +192,20 @@ export default {
|
|||||||
this.subTypeSelected = defaultSubType.name
|
this.subTypeSelected = defaultSubType.name
|
||||||
this.inputPlaceholder = defaultSubType.placeholder
|
this.inputPlaceholder = defaultSubType.placeholder
|
||||||
this.visible = true
|
this.visible = true
|
||||||
})
|
}).catch((err) => {
|
||||||
.catch(err => {
|
|
||||||
const data = err.response?.data
|
const data = err.response?.data
|
||||||
const msg = data?.error || data?.detail || data?.msg || this.$t('GetConfirmTypeFailed')
|
const msg = data?.error || data?.detail || data?.msg || this.$t('GetConfirmTypeFailed')
|
||||||
this.$message.error(msg)
|
this.$message.error(msg)
|
||||||
this.cancel(err)
|
this.cancel(err)
|
||||||
})
|
}).finally(() => {
|
||||||
.finally(() => {
|
|
||||||
this.processing = false
|
this.processing = false
|
||||||
})
|
})
|
||||||
}, 500),
|
}, 500),
|
||||||
logout() {
|
logout() {
|
||||||
window.location.href = `${process.env.VUE_APP_LOGOUT_PATH}?next=${this.$route.fullPath}`
|
window.location.href = `${process.env.VUE_APP_LOGOUT_PATH}?next=${this.$route.fullPath}`
|
||||||
},
|
},
|
||||||
sendCode() {
|
sendSMSCode() {
|
||||||
this.$axios
|
this.$axios.post(`/api/v1/authentication/mfa/select/`, { type: 'sms' }).then(res => {
|
||||||
.post(`/api/v1/authentication/mfa/select/`, { type: this.subTypeSelected })
|
|
||||||
.then(res => {
|
|
||||||
this.$message.success(this.$tc('VerificationCodeSent'))
|
this.$message.success(this.$tc('VerificationCodeSent'))
|
||||||
let time = 60
|
let time = 60
|
||||||
this.smsBtnDisabled = true
|
this.smsBtnDisabled = true
|
||||||
@@ -244,36 +220,13 @@ export default {
|
|||||||
this.smsBtnDisabled = false
|
this.smsBtnDisabled = false
|
||||||
}
|
}
|
||||||
}, 1000)
|
}, 1000)
|
||||||
})
|
}).catch(() => {
|
||||||
.catch(() => {
|
|
||||||
this.$message.error(this.$tc('FailedToSendVerificationCode'))
|
this.$message.error(this.$tc('FailedToSendVerificationCode'))
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handlePasskeyVerify() {
|
|
||||||
this.passkeyVisible = true
|
|
||||||
this.checkPasskeyStatus()
|
|
||||||
},
|
|
||||||
checkPasskeyStatus() {
|
|
||||||
const url = '/api/v1/authentication/confirm/check/?confirm_type=mfa'
|
|
||||||
const t = setInterval(() => {
|
|
||||||
this.$axios.get(url).then(data => {
|
|
||||||
this.passkeyVisible = false
|
|
||||||
this.onSuccess()
|
|
||||||
})
|
|
||||||
}, 2000)
|
|
||||||
setTimeout(() => {
|
|
||||||
clearInterval(t)
|
|
||||||
if (this.passkeyVisible) {
|
|
||||||
this.passkeyVisible = false
|
|
||||||
this.$message.error(this.$tc('PasskeyTimeout'))
|
|
||||||
}
|
|
||||||
}, 20000)
|
|
||||||
},
|
|
||||||
startFaceCapture() {
|
startFaceCapture() {
|
||||||
const url = '/api/v1/authentication/face/context/'
|
const url = '/api/v1/authentication/face/context/'
|
||||||
this.$axios
|
this.$axios.post(url).then(data => {
|
||||||
.post(url)
|
|
||||||
.then(data => {
|
|
||||||
const token = data['token']
|
const token = data['token']
|
||||||
this.faceCaptureUrl = '/facelive/capture?token=' + token
|
this.faceCaptureUrl = '/facelive/capture?token=' + token
|
||||||
this.isFaceCaptureVisible = true
|
this.isFaceCaptureVisible = true
|
||||||
@@ -287,21 +240,13 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, 1000)
|
}, 1000)
|
||||||
})
|
}).catch(() => {
|
||||||
.catch(() => {
|
|
||||||
this.$message.error(this.$tc('FailedToStartFaceCapture'))
|
this.$message.error(this.$tc('FailedToStartFaceCapture'))
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleFaceCapture() {
|
handleFaceCapture() {
|
||||||
this.startFaceCapture()
|
this.startFaceCapture()
|
||||||
},
|
},
|
||||||
onSuccess() {
|
|
||||||
this.secretValue = ''
|
|
||||||
this.visible = false
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.callback()
|
|
||||||
})
|
|
||||||
},
|
|
||||||
handleConfirm() {
|
handleConfirm() {
|
||||||
if (this.confirmTypeRequired === 'relogin') {
|
if (this.confirmTypeRequired === 'relogin') {
|
||||||
return this.logout()
|
return this.logout()
|
||||||
@@ -313,18 +258,16 @@ export default {
|
|||||||
const data = {
|
const data = {
|
||||||
confirm_type: this.confirmTypeRequired,
|
confirm_type: this.confirmTypeRequired,
|
||||||
mfa_type: this.confirmTypeRequired === 'mfa' ? this.subTypeSelected : '',
|
mfa_type: this.confirmTypeRequired === 'mfa' ? this.subTypeSelected : '',
|
||||||
secret_key:
|
secret_key: this.confirmTypeRequired === 'password' ? encryptPassword(this.secretValue) : this.secretValue
|
||||||
this.confirmTypeRequired === 'password'
|
|
||||||
? encryptPassword(this.secretValue)
|
|
||||||
: this.secretValue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$axios
|
this.$axios.post(`/api/v1/authentication/confirm/`, data).then(() => {
|
||||||
.post(`/api/v1/authentication/confirm/`, data)
|
this.secretValue = ''
|
||||||
.then(() => {
|
this.visible = false
|
||||||
this.onSuccess()
|
this.$nextTick(() => {
|
||||||
|
this.callback()
|
||||||
})
|
})
|
||||||
.catch(err => {
|
}).catch((err) => {
|
||||||
this.$message.error(err.message || this.$tc('ConfirmFailed'))
|
this.$message.error(err.message || this.$tc('ConfirmFailed'))
|
||||||
this.faceCaptureUrl = null
|
this.faceCaptureUrl = null
|
||||||
this.isFaceCaptureVisible = false
|
this.isFaceCaptureVisible = false
|
||||||
|
|||||||
@@ -39,9 +39,6 @@ export default {
|
|||||||
['', ['name', 'var_name', 'type', 'text_default_value', 'select_default_value', 'extra_args', 'tips', 'required']]
|
['', ['name', 'var_name', 'type', 'text_default_value', 'select_default_value', 'extra_args', 'tips', 'required']]
|
||||||
],
|
],
|
||||||
fieldsMeta: {
|
fieldsMeta: {
|
||||||
var_name: {
|
|
||||||
helpTextAsTip: false
|
|
||||||
},
|
|
||||||
text_default_value: {
|
text_default_value: {
|
||||||
label: this.$t('DefaultValue'),
|
label: this.$t('DefaultValue'),
|
||||||
hidden: (formValue) => {
|
hidden: (formValue) => {
|
||||||
|
|||||||
@@ -1,100 +0,0 @@
|
|||||||
<template>
|
|
||||||
<Dialog
|
|
||||||
:show-cancel="false"
|
|
||||||
:show-confirm="false"
|
|
||||||
:title="title"
|
|
||||||
:visible.sync="iVisible"
|
|
||||||
class="help-dialog"
|
|
||||||
top="1vh"
|
|
||||||
width="50%"
|
|
||||||
>
|
|
||||||
<p>{{ variablesHelpText }}</p>
|
|
||||||
<table border="1" class="help-table">
|
|
||||||
<tr>
|
|
||||||
<th>{{ $tc('Variable') }}</th>
|
|
||||||
<th>{{ $tc('Description') }}</th>
|
|
||||||
<th>{{ $tc('Example') }}</th>
|
|
||||||
</tr>
|
|
||||||
<tr v-for="(item, index) in variables" :key="index">
|
|
||||||
<td :title="$tc('ClickCopy')" class="item-td text-link" @click="onCopy(item.name)">
|
|
||||||
<label class="item-label">{{ item.name }}</label>
|
|
||||||
</td>
|
|
||||||
<td><span>{{ item.label }}</span></td>
|
|
||||||
<td><span>{{ item.default }}</span></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</Dialog>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import Dialog from '@/components/Dialog/index.vue'
|
|
||||||
import { copy } from '@/utils/common/index'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
components: {
|
|
||||||
Dialog
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
visible: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false
|
|
||||||
},
|
|
||||||
variables: {
|
|
||||||
type: Array,
|
|
||||||
default: () => []
|
|
||||||
},
|
|
||||||
variablesHelpText: {
|
|
||||||
type: String,
|
|
||||||
default() {
|
|
||||||
return this.$t('WatermarkVariableHelpText')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
title: this.$t('BuiltinVariable')
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
iVisible: {
|
|
||||||
set(val) {
|
|
||||||
this.$emit('update:visible', val)
|
|
||||||
},
|
|
||||||
get() {
|
|
||||||
return this.visible
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
onCopy(key) {
|
|
||||||
copy(key)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
::v-deep .help-dialog.dialog .el-dialog__footer {
|
|
||||||
border-top: none;
|
|
||||||
padding: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.help-table {
|
|
||||||
width: 100%;
|
|
||||||
border-collapse: collapse;
|
|
||||||
border: 1px solid #dee2e6;
|
|
||||||
}
|
|
||||||
|
|
||||||
::v-deep .help-table th,
|
|
||||||
::v-deep .help-table td {
|
|
||||||
height: 40px;
|
|
||||||
padding: 0 8px;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
::v-deep .help-table .item-td,
|
|
||||||
::v-deep .help-table .item-label {
|
|
||||||
cursor: pointer;
|
|
||||||
color: var(--color-primary);
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<script type="text/jsx">
|
<script type="text/jsx">
|
||||||
import { toSafeLocalDateStr } from '@/utils/common/time'
|
import { toSafeLocalDateStr } from '@/utils/time'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ItemValue',
|
name: 'ItemValue',
|
||||||
|
|||||||
@@ -12,8 +12,8 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import DetailCard from './index.vue'
|
import DetailCard from './index.vue'
|
||||||
import { copy } from '@/utils/common/index'
|
import { copy } from '@/utils/common'
|
||||||
import { toSafeLocalDateStr } from '@/utils/common/time'
|
import { toSafeLocalDateStr } from '@/utils/time'
|
||||||
import IBox from '@/components/Common/IBox/index.vue'
|
import IBox from '@/components/Common/IBox/index.vue'
|
||||||
import LabelsDetailFormatter from '../Formatters/LabelsDetailFormatter.vue'
|
import LabelsDetailFormatter from '../Formatters/LabelsDetailFormatter.vue'
|
||||||
|
|
||||||
@@ -129,18 +129,8 @@ export default {
|
|||||||
parseArrayValue(value, excludes, label) {
|
parseArrayValue(value, excludes, label) {
|
||||||
if (Array.isArray(value)) {
|
if (Array.isArray(value)) {
|
||||||
const tp = typeof value[0]
|
const tp = typeof value[0]
|
||||||
let object = {}
|
|
||||||
|
|
||||||
if (value.length === 0) {
|
|
||||||
object = {
|
|
||||||
key: label,
|
|
||||||
value: '-'
|
|
||||||
}
|
|
||||||
return this.items.push(object)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果是空数组,那么循环体将不会执行
|
|
||||||
for (const [index, item] of value.entries()) {
|
for (const [index, item] of value.entries()) {
|
||||||
|
let object = {}
|
||||||
if (tp === 'object') {
|
if (tp === 'object') {
|
||||||
const firstValue = value[0]
|
const firstValue = value[0]
|
||||||
if (firstValue.hasOwnProperty('name')) {
|
if (firstValue.hasOwnProperty('name')) {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<div v-if="item.has !== false" :key="item.key" :class="item.class " :label="item.key" class="el-form-item">
|
<div v-if="item.has !== false" :key="item.key" :class="item.class " :label="item.key" class="el-form-item">
|
||||||
<span slot="label" class="el-form-item__label"> {{ formateLabel(item.key) }}</span>
|
<span slot="label" class="el-form-item__label"> {{ formateLabel(item.key) }}</span>
|
||||||
<span class="item-value el-form-item__content">
|
<span class="item-value el-form-item__content">
|
||||||
<component
|
<template
|
||||||
:is="item.component"
|
:is="item.component"
|
||||||
v-if="item.component"
|
v-if="item.component"
|
||||||
v-bind="{...item}"
|
v-bind="{...item}"
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
v-if="action.dropdown"
|
v-if="action.dropdown"
|
||||||
v-show="action.dropdown.length > 0"
|
v-show="action.dropdown.length > 0"
|
||||||
:key="action.name"
|
:key="action.name"
|
||||||
:class="[action.name, { grouped: action.grouped }]"
|
:class="[action.name, {grouped: action.grouped }]"
|
||||||
:size="action.size"
|
:size="action.size"
|
||||||
:split-button="!!action.split"
|
:split-button="!!action.split"
|
||||||
:type="action.type"
|
:type="action.type"
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
@click="handleClick(action)"
|
@click="handleClick(action)"
|
||||||
@command="handleDropdownCallback"
|
@command="handleDropdownCallback"
|
||||||
>
|
>
|
||||||
<span v-if="action.split" :style="{ cursor: action.disabled ? 'not-allowed' : 'pointer' }">
|
<span v-if="action.split">
|
||||||
{{ action.title }}
|
{{ action.title }}
|
||||||
</span>
|
</span>
|
||||||
<el-button
|
<el-button
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
:class="action.name"
|
:class="action.name"
|
||||||
:size="size"
|
:size="size"
|
||||||
class="more-action"
|
class="more-action"
|
||||||
v-bind="{ ...cleanButtonAction(action), icon: '' }"
|
v-bind="{...cleanButtonAction(action), icon: ''}"
|
||||||
>
|
>
|
||||||
<span class="pre-icon">
|
<span class="pre-icon">
|
||||||
<Icon v-if="action.icon" :icon="action.icon" />
|
<Icon v-if="action.icon" :icon="action.icon" />
|
||||||
@@ -32,13 +32,13 @@
|
|||||||
{{ action.title }}<i class="el-icon-arrow-down el-icon--right" />
|
{{ action.title }}<i class="el-icon-arrow-down el-icon--right" />
|
||||||
</span>
|
</span>
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-dropdown-menu slot="dropdown" style="overflow: auto; max-height: 60vh">
|
<el-dropdown-menu slot="dropdown" style="overflow: auto;max-height: 60vh">
|
||||||
<template v-for="option in action.dropdown">
|
<template v-for="option in action.dropdown">
|
||||||
<div
|
<div
|
||||||
v-if="option.group"
|
v-if="option.group"
|
||||||
:key="'group:' + option.name"
|
:key="'group:'+option.name"
|
||||||
class="dropdown-menu-title"
|
class="dropdown-menu-title"
|
||||||
style="width: 130px"
|
style="width:130px"
|
||||||
>
|
>
|
||||||
{{ option.group }}
|
{{ option.group }}
|
||||||
</div>
|
</div>
|
||||||
@@ -54,7 +54,7 @@
|
|||||||
:command="[option, action]"
|
:command="[option, action]"
|
||||||
:title="option.tip"
|
:title="option.tip"
|
||||||
class="dropdown-item"
|
class="dropdown-item"
|
||||||
v-bind="{ ...option, icon: '' }"
|
v-bind="{...option, icon: ''}"
|
||||||
>
|
>
|
||||||
<span v-if="actionsHasIcon(action.dropdown)" class="pre-icon">
|
<span v-if="actionsHasIcon(action.dropdown)" class="pre-icon">
|
||||||
<Icon v-if="option.icon" :icon="option.icon" />
|
<Icon v-if="option.icon" :icon="option.icon" />
|
||||||
@@ -69,10 +69,10 @@
|
|||||||
<el-button
|
<el-button
|
||||||
v-else
|
v-else
|
||||||
:key="action.name"
|
:key="action.name"
|
||||||
:class="[action.name, { grouped: action.grouped }]"
|
:class="[action.name, {grouped: action.grouped }]"
|
||||||
:size="size"
|
:size="size"
|
||||||
class="action-item"
|
class="action-item"
|
||||||
v-bind="{ ...cleanButtonAction(action), icon: '' }"
|
v-bind="{...cleanButtonAction(action), icon: ''}"
|
||||||
@click="handleClick(action)"
|
@click="handleClick(action)"
|
||||||
>
|
>
|
||||||
<el-tooltip :content="action.tip" :disabled="!action.tip" placement="top">
|
<el-tooltip :content="action.tip" :disabled="!action.tip" placement="top">
|
||||||
@@ -89,7 +89,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { toSentenceCase } from '@/utils/common/index'
|
import { toSentenceCase } from '@/utils/common'
|
||||||
import Icon from '@/components/Widgets/Icon/index.vue'
|
import Icon from '@/components/Widgets/Icon/index.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -228,9 +228,9 @@ export default {
|
|||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
$btn-text-color: #ffffff;
|
$btn-text-color: #ffffff;
|
||||||
$color-btn-background: #e8f7f4;
|
$color-btn-background: #E8F7F4;
|
||||||
$color-btn-focus-background: #83cbba;
|
$color-btn-focus-background: #83CBBA;
|
||||||
$color-divided: #e4e7ed;
|
$color-divided: #E4E7ED;
|
||||||
$color-drop-menu-title: #909399;
|
$color-drop-menu-title: #909399;
|
||||||
$color-drop-menu-border: #e4e7ed;
|
$color-drop-menu-border: #e4e7ed;
|
||||||
|
|
||||||
@@ -284,8 +284,6 @@ $color-drop-menu-border: #e4e7ed;
|
|||||||
|
|
||||||
.el-button {
|
.el-button {
|
||||||
padding: 2px 5px;
|
padding: 2px 5px;
|
||||||
line-height: 1.3;
|
|
||||||
font-size: 13px;
|
|
||||||
|
|
||||||
&:not(.is-plain) {
|
&:not(.is-plain) {
|
||||||
color: $btn-text-color;
|
color: $btn-text-color;
|
||||||
@@ -321,6 +319,7 @@ $color-drop-menu-border: #e4e7ed;
|
|||||||
// 下拉 options
|
// 下拉 options
|
||||||
.el-dropdown-menu {
|
.el-dropdown-menu {
|
||||||
::v-deep .more-batch-processing {
|
::v-deep .more-batch-processing {
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color: transparent !important;
|
background-color: transparent !important;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<tr>
|
<tr>
|
||||||
|
<td>{{ getActionTitle(action) }}</td>
|
||||||
<td>
|
<td>
|
||||||
{{ getActionTitle(action) }}
|
<el-popover
|
||||||
<el-tooltip v-if="action.attrs.showTip" :content="action.attrs.tip" :open-delay="500" effect="dark">
|
:content="action.attrs.tip"
|
||||||
<i class="fa fa-question-circle-o" />
|
:disabled="!action.attrs.showTip"
|
||||||
</el-tooltip>
|
placement="left-end"
|
||||||
</td>
|
trigger="hover"
|
||||||
<td>
|
>
|
||||||
<span slot="reference">
|
<span slot="reference">
|
||||||
<component
|
<component
|
||||||
:is="iType"
|
:is="iType"
|
||||||
@@ -18,6 +19,7 @@
|
|||||||
{{ label }}
|
{{ label }}
|
||||||
</component>
|
</component>
|
||||||
</span>
|
</span>
|
||||||
|
</el-popover>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</template>
|
</template>
|
||||||
@@ -26,7 +28,7 @@
|
|||||||
import Switcher from '@/components/Form/FormFields/Switcher.vue'
|
import Switcher from '@/components/Form/FormFields/Switcher.vue'
|
||||||
import Select2 from '@/components/Form/FormFields/Select2.vue'
|
import Select2 from '@/components/Form/FormFields/Select2.vue'
|
||||||
import UpdateSelect from '@/components/Form/FormFields/UpdateSelect.vue'
|
import UpdateSelect from '@/components/Form/FormFields/UpdateSelect.vue'
|
||||||
import { toSentenceCase } from '@/utils/common/index'
|
import { toSentenceCase } from '@/utils/common'
|
||||||
|
|
||||||
class Action {
|
class Action {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div class="content">
|
||||||
<Echart
|
<echarts
|
||||||
ref="echarts"
|
ref="echarts"
|
||||||
:options="options"
|
:options="options"
|
||||||
:autoresize="true"
|
:autoresize="true"
|
||||||
@@ -12,10 +12,9 @@
|
|||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
import * as echarts from 'echarts'
|
import * as echarts from 'echarts'
|
||||||
import { mix } from '@/utils/theme/color'
|
import { mix } from '@/utils/theme/color'
|
||||||
import Echart from '@/components/Dashboard/Echart.vue'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { Echart },
|
components: {},
|
||||||
props: {
|
props: {
|
||||||
datesMetrics: {
|
datesMetrics: {
|
||||||
type: Array,
|
type: Array,
|
||||||
|
|||||||
@@ -1,71 +0,0 @@
|
|||||||
<template>
|
|
||||||
<echarts
|
|
||||||
:options="iOptions"
|
|
||||||
v-bind="$attrs"
|
|
||||||
@finished="onFinished"
|
|
||||||
v-on="$listeners"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import 'echarts'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
components: {},
|
|
||||||
props: {
|
|
||||||
options: {
|
|
||||||
type: Object,
|
|
||||||
required: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
const urlParams = new URLSearchParams(window.location.search)
|
|
||||||
const isExport = urlParams.get('export') === 'true'
|
|
||||||
return {
|
|
||||||
isExport: isExport
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
iOptions() {
|
|
||||||
return {
|
|
||||||
...this.options,
|
|
||||||
animation: !this.isExport
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
if (!window._echarts) {
|
|
||||||
window._echarts = {
|
|
||||||
total: new Set(),
|
|
||||||
finished: new Set()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 唯一 id,避免重复计数
|
|
||||||
this._chartId = `chart_${Date.now()}_${Math.random().toString(36).slice(2)}`
|
|
||||||
window._echarts.total.add(this._chartId)
|
|
||||||
},
|
|
||||||
beforeDestroy() {
|
|
||||||
if (window._echarts) {
|
|
||||||
window._echarts.total.delete(this._chartId)
|
|
||||||
window._echarts.finished.delete(this._chartId)
|
|
||||||
// 可选:当没有图表时清理全局对象
|
|
||||||
if (window._echarts.total.size === 0) {
|
|
||||||
delete window._echarts
|
|
||||||
delete window.echartsFinished
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
onFinished() {
|
|
||||||
if (!window._echarts) return
|
|
||||||
window._echarts.finished.add(this._chartId)
|
|
||||||
if (window._echarts.finished.size === window._echarts.total.size) {
|
|
||||||
window.echartsFinished = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped lang="scss">
|
|
||||||
</style>
|
|
||||||
@@ -1,12 +1,14 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<Echart
|
<echarts
|
||||||
ref="echarts"
|
ref="echarts"
|
||||||
:options="options"
|
:options="options"
|
||||||
:autoresize="true"
|
:autoresize="true"
|
||||||
theme="light"
|
theme="light"
|
||||||
@finished="genSnapshot"
|
class="disabled-when-print"
|
||||||
|
@finished="getDataUrl"
|
||||||
/>
|
/>
|
||||||
|
<img v-if="dataUrl" :src="dataUrl" class="enabled-when-print" style="display: none;width: 100%;">
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -14,11 +16,9 @@
|
|||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
import * as echarts from 'echarts'
|
import * as echarts from 'echarts'
|
||||||
import { mix } from '@/utils/theme/color'
|
import { mix } from '@/utils/theme/color'
|
||||||
import Echart from '@/components/Dashboard/Echart.vue'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'LoginMetric',
|
name: 'LoginMetric',
|
||||||
components: { Echart },
|
|
||||||
props: {
|
props: {
|
||||||
range: {
|
range: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -110,6 +110,7 @@ export default {
|
|||||||
},
|
},
|
||||||
axisLabel: {
|
axisLabel: {
|
||||||
textStyle: {
|
textStyle: {
|
||||||
|
// 坐标轴颜色
|
||||||
color: '#8F959E'
|
color: '#8F959E'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -219,58 +220,23 @@ export default {
|
|||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
range() {
|
range() {
|
||||||
this.genSnapshot()
|
this.getMetricData()
|
||||||
},
|
|
||||||
datesMetrics() {
|
|
||||||
this.genSnapshot()
|
|
||||||
},
|
|
||||||
primaryData() {
|
|
||||||
this.genSnapshot()
|
|
||||||
},
|
|
||||||
secondaryData() {
|
|
||||||
this.genSnapshot()
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.genSnapshot()
|
this.getMetricData()
|
||||||
this._before = () => this.genSnapshot(true)
|
|
||||||
this._after = () => this.forceResize()
|
|
||||||
window.addEventListener('beforeprint', this._before)
|
|
||||||
window.addEventListener('afterprint', this._after)
|
|
||||||
// 兼容某些浏览器(Safari)触发 print 媒体切换
|
|
||||||
this._mql = window.matchMedia && window.matchMedia('print')
|
|
||||||
if (this._mql) {
|
|
||||||
const handler = e => (e.matches ? this._before() : this._after())
|
|
||||||
this._mql.addEventListener?.('change', handler)
|
|
||||||
this._mql.addListener?.(handler)
|
|
||||||
this._mql._handler = handler
|
|
||||||
}
|
|
||||||
},
|
|
||||||
beforeDestroy() {
|
|
||||||
window.removeEventListener('beforeprint', this._before)
|
|
||||||
window.removeEventListener('afterprint', this._after)
|
|
||||||
if (this._mql) {
|
|
||||||
this._mql.removeEventListener?.('change', this._mql._handler)
|
|
||||||
this._mql.removeListener?.(this._mql._handler)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
forceResize() {
|
getDataUrl() {
|
||||||
const inst = this.$refs.echarts?.echartsInstance
|
const instance = this.$refs.echarts.echartsInstance
|
||||||
if (inst) inst.resize()
|
if (instance) {
|
||||||
|
this.dataUrl = instance.getDataURL()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
async genSnapshot(force = false) {
|
getMetricData() {
|
||||||
if (force) this.forceResize()
|
this.getDataUrl()
|
||||||
const inst = this.$refs.echarts?.echartsInstance
|
|
||||||
if (!inst) return
|
|
||||||
try {
|
|
||||||
this.dataUrl = inst.getDataURL({ pixelRatio: 2, backgroundColor: '#ffffff' })
|
|
||||||
} catch (e) {
|
|
||||||
this.dataUrl = ''
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -279,4 +245,16 @@ export default {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 272px;
|
height: 272px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media print {
|
||||||
|
.disabled-when-print {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.enabled-when-print {
|
||||||
|
display: inherit !important;
|
||||||
|
}
|
||||||
|
.print-margin {
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<Echart
|
<echarts
|
||||||
ref="echarts"
|
ref="echarts"
|
||||||
:options="options"
|
:options="options"
|
||||||
:autoresize="true"
|
:autoresize="true"
|
||||||
@@ -13,10 +13,8 @@
|
|||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
import * as echarts from 'echarts'
|
import * as echarts from 'echarts'
|
||||||
import { mix } from '@/utils/theme/color'
|
import { mix } from '@/utils/theme/color'
|
||||||
import Echart from '@/components/Dashboard/Echart.vue'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { Echart },
|
|
||||||
props: {
|
props: {
|
||||||
colors: {
|
colors: {
|
||||||
type: Array,
|
type: Array,
|
||||||
@@ -37,15 +35,14 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {}
|
return {
|
||||||
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
options() {
|
options() {
|
||||||
const seriesList = []
|
const seriesList = []
|
||||||
const labels = this.data.map(item => item.label)
|
const labels = this.data.map(item => item.label)
|
||||||
const total = _.sumBy(this.data, function(i) {
|
const total = _.sumBy(this.data, function(i) { return i.total })
|
||||||
return i.total
|
|
||||||
})
|
|
||||||
for (let i = 0, len = this.data.length; i < len; i++) {
|
for (let i = 0, len = this.data.length; i < len; i++) {
|
||||||
const current = this.data[i]
|
const current = this.data[i]
|
||||||
let num = (current.total / total) * 100
|
let num = (current.total / total) * 100
|
||||||
@@ -180,8 +177,8 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.echarts {
|
.echarts {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 72px;
|
height: 72px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
class="table"
|
class="table"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
>
|
>
|
||||||
<el-table-column :label="$tc('Ranking')" width="100">
|
<el-table-column :label="$tc('Ranking')">
|
||||||
<template #header>
|
<template #header>
|
||||||
<el-tooltip :content="$t('Ranking')" placement="top" :open-delay="500">
|
<el-tooltip :content="$t('Ranking')" placement="top" :open-delay="500">
|
||||||
<span style="cursor: pointer;">{{ $t('Ranking') }}</span>
|
<span style="cursor: pointer;">{{ $t('Ranking') }}</span>
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export default {
|
|||||||
{
|
{
|
||||||
title: this.$t('OnlineSessions'),
|
title: this.$t('OnlineSessions'),
|
||||||
body: {
|
body: {
|
||||||
route: { name: `SessionList`, params: { activeMenu: 'OnlineList' } },
|
route: { name: `SessionList`, params: { activeMenu: 'OnlineList' }},
|
||||||
count: this.counter.total_count_online_sessions,
|
count: this.counter.total_count_online_sessions,
|
||||||
disabled: !this.$hasPerm('terminal.view_session')
|
disabled: !this.$hasPerm('terminal.view_session')
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,7 @@ export default {
|
|||||||
{
|
{
|
||||||
title: this.$t('CurrentConnectionUsers'),
|
title: this.$t('CurrentConnectionUsers'),
|
||||||
body: {
|
body: {
|
||||||
route: { name: `SessionList`, params: { activeMenu: 'OnlineList' } },
|
route: { name: `SessionList`, params: { activeMenu: 'OnlineList' }},
|
||||||
count: this.counter.total_count_online_users,
|
count: this.counter.total_count_online_users,
|
||||||
disabled: !this.$hasPerm('terminal.view_session')
|
disabled: !this.$hasPerm('terminal.view_session')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<Echart
|
<echarts
|
||||||
ref="echarts"
|
ref="echarts"
|
||||||
:autoresize="true"
|
:autoresize="true"
|
||||||
:options="options"
|
:options="options"
|
||||||
@@ -13,15 +13,12 @@ import 'echarts/lib/chart/line'
|
|||||||
import 'echarts/lib/component/legend'
|
import 'echarts/lib/component/legend'
|
||||||
|
|
||||||
import Decimal from 'decimal.js'
|
import Decimal from 'decimal.js'
|
||||||
import Echart from '@/components/Dashboard/Echart.vue'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { Echart },
|
|
||||||
props: {
|
props: {
|
||||||
config: {
|
config: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => {
|
default: () => {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -36,7 +33,7 @@ export default {
|
|||||||
|
|
||||||
const formatTitle = (text) => {
|
const formatTitle = (text) => {
|
||||||
if (!text) return ''
|
if (!text) return ''
|
||||||
const maxLength = 25
|
const maxLength = 23
|
||||||
const lines = []
|
const lines = []
|
||||||
for (let i = 0; i < text.length; i += maxLength) {
|
for (let i = 0; i < text.length; i += maxLength) {
|
||||||
lines.push(text.slice(i, i + maxLength))
|
lines.push(text.slice(i, i + maxLength))
|
||||||
@@ -91,7 +88,6 @@ export default {
|
|||||||
{
|
{
|
||||||
name: title,
|
name: title,
|
||||||
type: 'pie',
|
type: 'pie',
|
||||||
minAngle: 5,
|
|
||||||
radius: ['72%', '90%'],
|
radius: ['72%', '90%'],
|
||||||
avoidLabelOverlap: false,
|
avoidLabelOverlap: false,
|
||||||
itemStyle: {
|
itemStyle: {
|
||||||
|
|||||||
@@ -16,13 +16,11 @@
|
|||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
name: {
|
|
||||||
type: String,
|
|
||||||
default: 'dashboardDays'
|
|
||||||
},
|
|
||||||
days: {
|
days: {
|
||||||
type: [String, Number],
|
type: String,
|
||||||
default: null
|
default: () => {
|
||||||
|
return localStorage.getItem('dashboardDays') || '7'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
type: Array,
|
type: Array,
|
||||||
@@ -49,28 +47,8 @@ export default {
|
|||||||
iOptions: this.options.length > 0 ? this.options : defaultOptions
|
iOptions: this.options.length > 0 ? this.options : defaultOptions
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
|
||||||
let days = this.days
|
|
||||||
if (!days) {
|
|
||||||
days = this.$route.query.days
|
|
||||||
}
|
|
||||||
if (!days) {
|
|
||||||
days = localStorage.getItem(this.name)
|
|
||||||
}
|
|
||||||
if (!days) {
|
|
||||||
days = '7'
|
|
||||||
}
|
|
||||||
if (days && days !== this.select) {
|
|
||||||
this.select = days
|
|
||||||
this.$emit('change', days)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.$emit('change', this.select)
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
onChange(val) {
|
onChange(val) {
|
||||||
localStorage.setItem(this.name, val)
|
|
||||||
this.$emit('change', val)
|
this.$emit('change', val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import i18n from '@/i18n/i18n'
|
import i18n from '@/i18n/i18n'
|
||||||
import { copy } from '@/utils/common/index'
|
import { copy } from '@/utils/common'
|
||||||
import Dialog from '@/components/Dialog/index'
|
import Dialog from '@/components/Dialog/index'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { getDrawerWidth } from '@/utils/common/index'
|
import { getDrawerWidth } from '@/utils/common'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
ref="dataForm"
|
ref="dataForm"
|
||||||
:fields="totalFields"
|
:fields="totalFields"
|
||||||
:form="iForm"
|
:form="iForm"
|
||||||
:server-errors="serverErrors"
|
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
v-on="$listeners"
|
v-on="$listeners"
|
||||||
>
|
>
|
||||||
@@ -29,7 +28,6 @@
|
|||||||
import DataForm from '../DataForm/index.vue'
|
import DataForm from '../DataForm/index.vue'
|
||||||
import FormGroupHeader from '@/components/Form/FormGroupHeader/index.vue'
|
import FormGroupHeader from '@/components/Form/FormGroupHeader/index.vue'
|
||||||
import { FormFieldGenerator } from '@/components/Form/AutoDataForm/utils'
|
import { FormFieldGenerator } from '@/components/Form/AutoDataForm/utils'
|
||||||
import { UniqueCheck } from '@/components/Form/DataForm/rules'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'AutoDataForm',
|
name: 'AutoDataForm',
|
||||||
@@ -67,8 +65,7 @@ export default {
|
|||||||
totalFields: [],
|
totalFields: [],
|
||||||
loading: true,
|
loading: true,
|
||||||
groups: [],
|
groups: [],
|
||||||
errors: {},
|
errors: {}
|
||||||
serverErrors: {}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -97,7 +94,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async optionUrlMetaAndGenerateColumns() {
|
async optionUrlMetaAndGenerateColumns() {
|
||||||
let data = { actions: {} }
|
let data = { actions: {}}
|
||||||
if (this.url) {
|
if (this.url) {
|
||||||
data = await this.$store.dispatch('common/getUrlMeta', { url: this.url })
|
data = await this.$store.dispatch('common/getUrlMeta', { url: this.url })
|
||||||
}
|
}
|
||||||
@@ -106,8 +103,6 @@ export default {
|
|||||||
this.generateColumns()
|
this.generateColumns()
|
||||||
this.$emit('afterGenerateColumns', this.totalFields)
|
this.$emit('afterGenerateColumns', this.totalFields)
|
||||||
this.cleanFormValue()
|
this.cleanFormValue()
|
||||||
// 初始化时清空错误
|
|
||||||
this.serverErrors = {}
|
|
||||||
this.loading = false
|
this.loading = false
|
||||||
},
|
},
|
||||||
generateColumns() {
|
generateColumns() {
|
||||||
@@ -115,47 +110,6 @@ export default {
|
|||||||
this.totalFields = generator.generateFields(this.fields, this.fieldsMeta, this.remoteMeta)
|
this.totalFields = generator.generateFields(this.fields, this.fieldsMeta, this.remoteMeta)
|
||||||
this.groups = generator.groups
|
this.groups = generator.groups
|
||||||
this.$log.debug('Total fields: ', this.totalFields)
|
this.$log.debug('Total fields: ', this.totalFields)
|
||||||
this.applyUniqueRules()
|
|
||||||
},
|
|
||||||
applyUniqueRules() {
|
|
||||||
const fields = this.totalFields || []
|
|
||||||
const currentIdGetter = () => {
|
|
||||||
return this.$route?.params?.id || this.form?.id || this.iForm?.id
|
|
||||||
}
|
|
||||||
|
|
||||||
// 移除 url 后拼接的参数
|
|
||||||
const defaultListUrl = (() => {
|
|
||||||
try {
|
|
||||||
const u = new URL(this.url, location.origin)
|
|
||||||
u.pathname = u.pathname.replace(/\/(\d+|[0-9a-fA-F-]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12})\/?$/, '/')
|
|
||||||
return u.origin ? u.origin + u.pathname : u.pathname
|
|
||||||
} catch (e) {
|
|
||||||
return (this.url || '').replace(/\/(\d+|[0-9a-fA-F-]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12})\/?($|\?)/, '/$2')
|
|
||||||
}
|
|
||||||
})()
|
|
||||||
|
|
||||||
fields.forEach(field => {
|
|
||||||
const conf = field?.uniqueCheck
|
|
||||||
|
|
||||||
if (!conf) return
|
|
||||||
|
|
||||||
const confObj = (typeof conf === 'object') ? conf : {}
|
|
||||||
const param = confObj.param || field.prop || field.id
|
|
||||||
const url = confObj.url || defaultListUrl
|
|
||||||
const label = confObj.label || field.label || param
|
|
||||||
const entityName = confObj.entityName || ''
|
|
||||||
|
|
||||||
if (!Array.isArray(field.rules)) field.rules = []
|
|
||||||
|
|
||||||
field.rules.push(UniqueCheck({
|
|
||||||
url,
|
|
||||||
param,
|
|
||||||
label,
|
|
||||||
entityName,
|
|
||||||
getIgnoreId: currentIdGetter,
|
|
||||||
fieldName: field.prop || field.id
|
|
||||||
}))
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
_cleanFormValue(form, remoteMeta) {
|
_cleanFormValue(form, remoteMeta) {
|
||||||
if (!form) {
|
if (!form) {
|
||||||
@@ -185,57 +139,18 @@ export default {
|
|||||||
cleanFormValue() {
|
cleanFormValue() {
|
||||||
this._cleanFormValue(this.iForm, this.remoteMeta)
|
this._cleanFormValue(this.iForm, this.remoteMeta)
|
||||||
},
|
},
|
||||||
_getElFormInstance() {
|
|
||||||
try {
|
|
||||||
return this.$refs?.dataForm?.$refs?.form?.$refs?.elForm || null
|
|
||||||
} catch (e) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* @description 仅清理 UI 的错误展示,不触发表单内容重建
|
|
||||||
*/
|
|
||||||
clearAllFieldErrors() {
|
|
||||||
const elForm = this._getElFormInstance()
|
|
||||||
if (elForm && Array.isArray(elForm.fields)) {
|
|
||||||
elForm.fields.forEach((item) => {
|
|
||||||
item.validateMessage = ''
|
|
||||||
item.validateState = ''
|
|
||||||
})
|
|
||||||
}
|
|
||||||
// 不修改 totalFields/attrs,避免触发 content 重建导致输入丢失
|
|
||||||
this.serverErrors = {}
|
|
||||||
},
|
|
||||||
setFieldError(name, error) {
|
setFieldError(name, error) {
|
||||||
error = (error || '').toString().replace(/[。.]+$/, '')
|
const field = this.totalFields.find((v) => v.prop === name)
|
||||||
const elForm = this._getElFormInstance()
|
if (!field) {
|
||||||
if (elForm && Array.isArray(elForm.fields)) {
|
return
|
||||||
const item = elForm.fields.find(f => f.prop === name)
|
|
||||||
if (item) {
|
|
||||||
item.validateMessage = error
|
|
||||||
item.validateState = error ? 'error' : ''
|
|
||||||
}
|
}
|
||||||
|
if (field.attrs.error === error) {
|
||||||
|
error += '.'
|
||||||
}
|
}
|
||||||
// 不写入 totalFields,避免触发 innerContent 变化导致表单值被覆盖
|
|
||||||
this.$set(this.serverErrors, name, error)
|
if (typeof error === 'string') {
|
||||||
},
|
field.el.errors = error
|
||||||
setErrors(errors) {
|
field.attrs.error = error
|
||||||
const mapped = {}
|
|
||||||
Object.entries(errors || {}).forEach(([k, v]) => {
|
|
||||||
let msg = v
|
|
||||||
// v是数组并且数组都是字符串,则拼接为字符串
|
|
||||||
if (Array.isArray(v) && v.every(item => typeof item === 'string')) msg = v.join('; ')
|
|
||||||
else if (typeof v === 'object' && v !== null) msg = JSON.stringify(v)
|
|
||||||
mapped[k] = String(msg || '')
|
|
||||||
})
|
|
||||||
this.serverErrors = mapped
|
|
||||||
const elForm = this._getElFormInstance()
|
|
||||||
if (elForm && Array.isArray(elForm.fields)) {
|
|
||||||
elForm.fields.forEach((item) => {
|
|
||||||
const msg = mapped[item.prop] || ''
|
|
||||||
item.validateMessage = msg
|
|
||||||
item.validateState = msg ? 'error' : ''
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
groupHidden(group, i) {
|
groupHidden(group, i) {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import NestedField from '@/components/Form/AutoDataForm/components/NestedField.v
|
|||||||
import rules from '@/components/Form/DataForm/rules'
|
import rules from '@/components/Form/DataForm/rules'
|
||||||
import BasicTree from '@/components/Form/FormFields/BasicTree.vue'
|
import BasicTree from '@/components/Form/FormFields/BasicTree.vue'
|
||||||
import JsonEditor from '@/components/Form/FormFields/JsonEditor.vue'
|
import JsonEditor from '@/components/Form/FormFields/JsonEditor.vue'
|
||||||
import { assignIfNot, toSentenceCase } from '@/utils/common/index'
|
import { assignIfNot, toSentenceCase } from '@/utils/common'
|
||||||
import TagInput from '@/components/Form/FormFields/TagInput.vue'
|
import TagInput from '@/components/Form/FormFields/TagInput.vue'
|
||||||
import i18n from '@/i18n/i18n'
|
import i18n from '@/i18n/i18n'
|
||||||
|
|
||||||
@@ -177,10 +177,7 @@ export class FormFieldGenerator {
|
|||||||
const systemLang = document.cookie.django_language
|
const systemLang = document.cookie.django_language
|
||||||
if (helpTextAsPlaceholder !== undefined) {
|
if (helpTextAsPlaceholder !== undefined) {
|
||||||
helpTextAsPlaceholder = !!helpTextAsPlaceholder
|
helpTextAsPlaceholder = !!helpTextAsPlaceholder
|
||||||
} else if (
|
} else if (placeholderType.indexOf(field.type) === -1 && placeholderComponent.indexOf(field.component) === -1) {
|
||||||
placeholderType.indexOf(field.type) === -1 &&
|
|
||||||
placeholderComponent.indexOf(field.component) === -1
|
|
||||||
) {
|
|
||||||
helpTextAsPlaceholder = false
|
helpTextAsPlaceholder = false
|
||||||
} else if ((helpTextWordLength <= 5 || helpText.length <= 10) && systemLang === 'en') {
|
} else if ((helpTextWordLength <= 5 || helpText.length <= 10) && systemLang === 'en') {
|
||||||
helpTextAsPlaceholder = true
|
helpTextAsPlaceholder = true
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
:prop="prop"
|
:prop="prop"
|
||||||
:rules="_show && Array.isArray(data.rules) ? data.rules : []"
|
:rules="_show && Array.isArray(data.rules) ? data.rules : []"
|
||||||
v-bind="data.attrs"
|
v-bind="data.attrs"
|
||||||
:error="errorText"
|
|
||||||
>
|
>
|
||||||
<template v-if="data.label" #label>
|
<template v-if="data.label" #label>
|
||||||
<span :title="data.label">
|
<span :title="data.label">
|
||||||
@@ -20,8 +19,7 @@
|
|||||||
placement="right"
|
placement="right"
|
||||||
popper-class="help-tips"
|
popper-class="help-tips"
|
||||||
>
|
>
|
||||||
<div slot="content" v-sanitize="data.helpTip" class="help-tip-content" />
|
<div slot="content" v-sanitize="data.helpTip" class="help-tip-content" /> <!-- Noncompliant -->
|
||||||
<!-- Noncompliant -->
|
|
||||||
<i class="fa fa-question-circle-o help-tip-icon" />
|
<i class="fa fa-question-circle-o help-tip-icon" />
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</span>
|
</span>
|
||||||
@@ -29,7 +27,11 @@
|
|||||||
<template v-if="readonly && hasReadonlyContent">
|
<template v-if="readonly && hasReadonlyContent">
|
||||||
<div
|
<div
|
||||||
v-if="data.type === 'input'"
|
v-if="data.type === 'input'"
|
||||||
:style="componentProps.type === 'textarea' ? { padding: '10px 0', lineHeight: 1.5 } : ''"
|
:style="
|
||||||
|
componentProps.type === 'textarea'
|
||||||
|
? {padding: '10px 0', lineHeight: 1.5}
|
||||||
|
: ''
|
||||||
|
"
|
||||||
>
|
>
|
||||||
{{ itemValue }}
|
{{ itemValue }}
|
||||||
</div>
|
</div>
|
||||||
@@ -48,7 +50,11 @@
|
|||||||
v-on="listeners"
|
v-on="listeners"
|
||||||
>
|
>
|
||||||
<template v-for="opt in options">
|
<template v-for="opt in options">
|
||||||
<el-option v-if="data.type === 'select'" :key="opt.label" v-bind="opt" />
|
<el-option
|
||||||
|
v-if="data.type === 'select'"
|
||||||
|
:key="opt.label"
|
||||||
|
v-bind="opt"
|
||||||
|
/>
|
||||||
<el-checkbox-button
|
<el-checkbox-button
|
||||||
v-else-if="data.type === 'checkbox-group' && data.style === 'button'"
|
v-else-if="data.type === 'checkbox-group' && data.style === 'button'"
|
||||||
:key="opt.value"
|
:key="opt.value"
|
||||||
@@ -105,10 +111,10 @@
|
|||||||
<script>
|
<script>
|
||||||
import getEnableWhenStatus from '../util/enable-when'
|
import getEnableWhenStatus from '../util/enable-when'
|
||||||
import { noop } from '../util/utils'
|
import { noop } from '../util/utils'
|
||||||
import _get from 'lodash/get'
|
import _get from 'lodash.get'
|
||||||
import _includes from 'lodash/includes'
|
import _includes from 'lodash.includes'
|
||||||
import _topairs from 'lodash/toPairs'
|
import _topairs from 'lodash.topairs'
|
||||||
import _frompairs from 'lodash/fromPairs'
|
import _frompairs from 'lodash.frompairs'
|
||||||
|
|
||||||
function validator(data) {
|
function validator(data) {
|
||||||
if (!data) {
|
if (!data) {
|
||||||
@@ -146,10 +152,6 @@ export default {
|
|||||||
props: {
|
props: {
|
||||||
// eslint-disable-next-line vue/require-default-prop
|
// eslint-disable-next-line vue/require-default-prop
|
||||||
data: Object,
|
data: Object,
|
||||||
serverErrors: {
|
|
||||||
type: Object,
|
|
||||||
default: () => ({})
|
|
||||||
},
|
|
||||||
prop: {
|
prop: {
|
||||||
type: String,
|
type: String,
|
||||||
default() {
|
default() {
|
||||||
@@ -168,8 +170,7 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
propsInner: {},
|
propsInner: {},
|
||||||
isBlurTrigger:
|
isBlurTrigger: this.data.rules &&
|
||||||
this.data.rules &&
|
|
||||||
this.data.rules.some(rule => {
|
this.data.rules.some(rule => {
|
||||||
return rule.required && rule.trigger === 'blur'
|
return rule.required && rule.trigger === 'blur'
|
||||||
})
|
})
|
||||||
@@ -178,7 +179,7 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
// 解构运算符会处理 undefined 的情况
|
// 解构运算符会处理 undefined 的情况
|
||||||
componentProps: ({ data: { el }, propsInner }) => ({ ...el, ...propsInner }),
|
componentProps: ({ data: { el }, propsInner }) => ({ ...el, ...propsInner }),
|
||||||
hasReadonlyContent: ({ data: { type } }) => _includes(['input', 'select'], type),
|
hasReadonlyContent: ({ data: { type }}) => _includes(['input', 'select'], type),
|
||||||
hiddenStatus: ({ data: { hidden = () => false }, data, value }) => hidden(value, data),
|
hiddenStatus: ({ data: { hidden = () => false }, data, value }) => hidden(value, data),
|
||||||
enableWhenStatus: ({ data: { enableWhen }, value }) => getEnableWhenStatus(enableWhen, value),
|
enableWhenStatus: ({ data: { enableWhen }, value }) => getEnableWhenStatus(enableWhen, value),
|
||||||
// 是否显示
|
// 是否显示
|
||||||
@@ -188,11 +189,6 @@ export default {
|
|||||||
classes() {
|
classes() {
|
||||||
return 'el-form-item-' + this.data.prop + ' ' + (this.data.attrs?.class || '')
|
return 'el-form-item-' + this.data.prop + ' ' + (this.data.attrs?.class || '')
|
||||||
},
|
},
|
||||||
errorText() {
|
|
||||||
const fromAttrs = this.data?.attrs?.error
|
|
||||||
const fromServer = this.serverErrors ? this.serverErrors[this.data.prop] : ''
|
|
||||||
return fromAttrs || fromServer || ''
|
|
||||||
},
|
|
||||||
listeners() {
|
listeners() {
|
||||||
const {
|
const {
|
||||||
data: {
|
data: {
|
||||||
@@ -208,7 +204,10 @@ export default {
|
|||||||
} = this
|
} = this
|
||||||
return {
|
return {
|
||||||
..._frompairs(
|
..._frompairs(
|
||||||
_topairs(on).map(([eName, handler]) => [eName, (...args) => handler(args, updateForm)])
|
_topairs(on).map(([eName, handler]) => [
|
||||||
|
eName,
|
||||||
|
(...args) => handler(args, updateForm)
|
||||||
|
]),
|
||||||
),
|
),
|
||||||
// 手动更新表单数据
|
// 手动更新表单数据
|
||||||
input: (value, ...rest) => {
|
input: (value, ...rest) => {
|
||||||
@@ -233,7 +232,9 @@ export default {
|
|||||||
|
|
||||||
multipleValue: ({ data, itemValue, options = [] }) => {
|
multipleValue: ({ data, itemValue, options = [] }) => {
|
||||||
const multipleSelectValue =
|
const multipleSelectValue =
|
||||||
_get(data, 'el.multiple') && Array.isArray(itemValue) ? itemValue : [itemValue]
|
_get(data, 'el.multiple') && Array.isArray(itemValue)
|
||||||
|
? itemValue
|
||||||
|
: [itemValue]
|
||||||
return multipleSelectValue
|
return multipleSelectValue
|
||||||
.map(val => (options.find(op => op.value === val) || {}).label)
|
.map(val => (options.find(op => op.value === val) || {}).label)
|
||||||
.join()
|
.join()
|
||||||
@@ -253,7 +254,8 @@ export default {
|
|||||||
if (v.url === oldV.url || v.request === oldV.request) return
|
if (v.url === oldV.url || v.request === oldV.request) return
|
||||||
}
|
}
|
||||||
const isOptionsCase =
|
const isOptionsCase =
|
||||||
['select', 'checkbox-group', 'radio-group'].indexOf(this.data.type) > -1
|
['select', 'checkbox-group', 'radio-group'].indexOf(this.data.type) >
|
||||||
|
-1
|
||||||
const {
|
const {
|
||||||
url,
|
url,
|
||||||
request = () => this.$axios.get(url).then(resp => resp.data),
|
request = () => this.$axios.get(url).then(resp => resp.data),
|
||||||
@@ -321,7 +323,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang='scss' scoped>
|
||||||
.help-tips {
|
.help-tips {
|
||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
line-height: 2;
|
line-height: 2;
|
||||||
@@ -330,7 +332,7 @@ export default {
|
|||||||
|
|
||||||
.help-block {
|
.help-block {
|
||||||
::v-deep .el-alert__icon {
|
::v-deep .el-alert__icon {
|
||||||
font-size: 16px;
|
font-size: 16px
|
||||||
}
|
}
|
||||||
|
|
||||||
&.checkbox {
|
&.checkbox {
|
||||||
|
|||||||
@@ -1,18 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-form
|
<el-form ref="elForm" :model="value" class="el-form-renderer" v-bind="$attrs">
|
||||||
ref="elForm"
|
|
||||||
:model="value"
|
|
||||||
class="el-form-renderer"
|
|
||||||
v-bind="$attrs"
|
|
||||||
@submit.native.prevent
|
|
||||||
>
|
|
||||||
<template v-for="item in innerContent">
|
<template v-for="item in innerContent">
|
||||||
<slot v-if="!isHidden(item)" :name="`id:${item.id}`" />
|
<slot v-if="!isHidden(item)" :name="`id:${item.id}`" />
|
||||||
<component
|
<component
|
||||||
:is="item.type === GROUP ? 'render-form-group' : 'render-form-item'"
|
:is="item.type === GROUP ? 'render-form-group' : 'render-form-item'"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
:data="item"
|
:data="item"
|
||||||
:server-errors="serverErrors"
|
|
||||||
:disabled="disabled || item.disabled"
|
:disabled="disabled || item.disabled"
|
||||||
:item-value="value[item.id]"
|
:item-value="value[item.id]"
|
||||||
:options="options[item.id]"
|
:options="options[item.id]"
|
||||||
@@ -26,19 +19,13 @@
|
|||||||
</el-form>
|
</el-form>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import _set from 'lodash/set'
|
import _set from 'lodash.set'
|
||||||
import _isequal from 'lodash/isEqual'
|
import _isequal from 'lodash.isequal'
|
||||||
import _clonedeep from 'lodash/cloneDeep'
|
import _clonedeep from 'lodash.clonedeep'
|
||||||
import RenderFormGroup from './components/render-form-group.vue'
|
import RenderFormGroup from './components/render-form-group.vue'
|
||||||
import RenderFormItem from './components/render-form-item.vue'
|
import RenderFormItem from './components/render-form-item.vue'
|
||||||
import transformContent from './util/transform-content'
|
import transformContent from './util/transform-content'
|
||||||
import {
|
import { collect, correctValue, mergeValue, transformInputValue, transformOutputValue } from './util/utils'
|
||||||
collect,
|
|
||||||
correctValue,
|
|
||||||
mergeValue,
|
|
||||||
transformInputValue,
|
|
||||||
transformOutputValue
|
|
||||||
} from './util/utils'
|
|
||||||
|
|
||||||
const GROUP = 'group'
|
const GROUP = 'group'
|
||||||
|
|
||||||
@@ -60,10 +47,6 @@ export default {
|
|||||||
type: Array,
|
type: Array,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
serverErrors: {
|
|
||||||
type: Object,
|
|
||||||
default: () => ({})
|
|
||||||
},
|
|
||||||
disabled: {
|
disabled: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import _get from 'lodash/get'
|
import _get from 'lodash.get'
|
||||||
import _has from 'lodash/has'
|
import _has from 'lodash.has'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理 enableWhen
|
* 处理 enableWhen
|
||||||
@@ -20,5 +20,7 @@ export default function getEnableWhenStatus(enableWhen, value) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return Array.isArray(enableWhen) ? enableWhen.some(handleCondition) : handleCondition(enableWhen)
|
return Array.isArray(enableWhen)
|
||||||
|
? enableWhen.some(handleCondition)
|
||||||
|
: handleCondition(enableWhen)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* eslint-disable no-sequences */
|
/* eslint-disable no-sequences */
|
||||||
import _ from 'lodash'
|
import _kebabcase from 'lodash.kebabcase'
|
||||||
/**
|
/**
|
||||||
* content 的每一项会浅拷贝一层
|
* content 的每一项会浅拷贝一层
|
||||||
* 只可以在 item 层新增修改属性,如 item.a = b
|
* 只可以在 item 层新增修改属性,如 item.a = b
|
||||||
@@ -13,7 +13,7 @@ export default function transformContent(content) {
|
|||||||
removeDollarInKey(item)
|
removeDollarInKey(item)
|
||||||
extractRulesFromComponent(item)
|
extractRulesFromComponent(item)
|
||||||
// 有些旧写法是 checkboxGroup & radioGroup
|
// 有些旧写法是 checkboxGroup & radioGroup
|
||||||
item.type = _.kebabCase(item.type)
|
item.type = _kebabcase(item.type)
|
||||||
}
|
}
|
||||||
|
|
||||||
return item
|
return item
|
||||||
@@ -34,5 +34,8 @@ export function extractRulesFromComponent(item) {
|
|||||||
if (!component || typeof component === 'string') return
|
if (!component || typeof component === 'string') return
|
||||||
|
|
||||||
const { rules = [] } = component
|
const { rules = [] } = component
|
||||||
item.rules = [...(item.rules || []), ...(typeof rules === 'function' ? rules(item) : rules)]
|
item.rules = [
|
||||||
|
...(item.rules || []),
|
||||||
|
...(typeof rules === 'function' ? rules(item) : rules)
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import _frompairs from 'lodash/fromPairs'
|
import _frompairs from 'lodash.frompairs'
|
||||||
import _isplainobject from 'lodash/isPlainObject'
|
import _isplainobject from 'lodash.isplainobject'
|
||||||
|
|
||||||
export function noop() {}
|
export function noop() {}
|
||||||
|
|
||||||
@@ -12,9 +12,11 @@ export function collect(content, key) {
|
|||||||
value: item.type === 'group' ? collect(item.items, key) : item[key]
|
value: item.type === 'group' ? collect(item.items, key) : item[key]
|
||||||
}))
|
}))
|
||||||
.filter(
|
.filter(
|
||||||
({ type, value }) => value !== undefined || (type === 'group' && Object.keys(value).length)
|
({ type, value }) =>
|
||||||
|
value !== undefined ||
|
||||||
|
(type === 'group' && Object.keys(value).length),
|
||||||
)
|
)
|
||||||
.map(({ id, value }) => [id, value])
|
.map(({ id, value }) => [id, value]),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,10 +8,8 @@
|
|||||||
:form="basicForm"
|
:form="basicForm"
|
||||||
:label-position="iLabelPosition"
|
:label-position="iLabelPosition"
|
||||||
class="form-fields"
|
class="form-fields"
|
||||||
:label-width="labelWidth"
|
label-width="25%"
|
||||||
:style="{ '--label-width': labelWidth }"
|
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
:server-errors="serverErrors"
|
|
||||||
v-on="$listeners"
|
v-on="$listeners"
|
||||||
>
|
>
|
||||||
<!-- slot 透传 -->
|
<!-- slot 透传 -->
|
||||||
@@ -56,7 +54,7 @@
|
|||||||
|
|
||||||
<el-button
|
<el-button
|
||||||
v-for="button in moreButtons"
|
v-for="button in moreButtons"
|
||||||
v-show="!iHidden(button)"
|
v-show="!button.hidden"
|
||||||
:key="button.title"
|
:key="button.title"
|
||||||
:loading="button.loading"
|
:loading="button.loading"
|
||||||
size="small"
|
size="small"
|
||||||
@@ -72,20 +70,8 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import ElFormRender from './components/el-form-renderer'
|
import ElFormRender from './components/el-form-renderer'
|
||||||
import { randomString } from '@/utils/common/index'
|
import { randomString } from '@/utils/string'
|
||||||
|
import { scrollToError } from '@/utils'
|
||||||
const scrollToError = (
|
|
||||||
el,
|
|
||||||
scrollOption = {
|
|
||||||
behavior: 'smooth',
|
|
||||||
block: 'center'
|
|
||||||
}
|
|
||||||
) => {
|
|
||||||
setTimeout(() => {
|
|
||||||
const isError = el.getElementsByClassName('is-error')
|
|
||||||
isError[0].scrollIntoView(scrollOption)
|
|
||||||
}, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@@ -122,10 +108,6 @@ export default {
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true
|
default: true
|
||||||
},
|
},
|
||||||
serverErrors: {
|
|
||||||
type: Object,
|
|
||||||
default: () => ({})
|
|
||||||
},
|
|
||||||
fields: {
|
fields: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => []
|
default: () => []
|
||||||
@@ -146,10 +128,6 @@ export default {
|
|||||||
labelPosition: {
|
labelPosition: {
|
||||||
type: String,
|
type: String,
|
||||||
default: ''
|
default: ''
|
||||||
},
|
|
||||||
labelWidth: {
|
|
||||||
type: String,
|
|
||||||
default: '25%'
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
@@ -231,9 +209,6 @@ export default {
|
|||||||
},
|
},
|
||||||
getFormValue() {
|
getFormValue() {
|
||||||
return this.$refs.form.getFormValue()
|
return this.$refs.form.getFormValue()
|
||||||
},
|
|
||||||
iHidden(item) {
|
|
||||||
return typeof item.hidden === 'function' ? item.hidden() : item.hidden
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -244,10 +219,6 @@ export default {
|
|||||||
margin-right: 80px;
|
margin-right: 80px;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
|
|
||||||
.el-form {
|
|
||||||
margin-right: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
::v-deep .el-input-group__prepend {
|
::v-deep .el-input-group__prepend {
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
}
|
}
|
||||||
@@ -292,7 +263,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.el-form-item__content {
|
.el-form-item__content {
|
||||||
width: calc(100% - var(--label-width));
|
width: 75%;
|
||||||
line-height: 32px;
|
line-height: 32px;
|
||||||
|
|
||||||
// 禁用的输入框
|
// 禁用的输入框
|
||||||
@@ -366,7 +337,7 @@ export default {
|
|||||||
|
|
||||||
::v-deep .form-buttons {
|
::v-deep .form-buttons {
|
||||||
margin-top: 30px;
|
margin-top: 30px;
|
||||||
margin-left: var(--label-width);
|
margin-left: 25%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import i18n from '@/i18n/i18n'
|
import i18n from '@/i18n/i18n'
|
||||||
import request from '@/utils/request'
|
|
||||||
|
|
||||||
export const Required = {
|
export const Required = {
|
||||||
required: true, message: i18n.t('FieldRequiredError'), trigger: 'blur'
|
required: true, message: i18n.t('FieldRequiredError'), trigger: 'blur'
|
||||||
@@ -119,69 +118,3 @@ export default {
|
|||||||
matchAlphanumericUnderscore,
|
matchAlphanumericUnderscore,
|
||||||
MatchExcludeParenthesis
|
MatchExcludeParenthesis
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @description 表单唯一性校验
|
|
||||||
*
|
|
||||||
* @param {Object} options
|
|
||||||
* @param {string} 列表查询地址
|
|
||||||
* @param {string} 查询参数名
|
|
||||||
* @param {string} 字段中文名
|
|
||||||
* @param {string} 字段名
|
|
||||||
* @param {function(): (string|number)} 返回更新场景下的当前对象 id
|
|
||||||
*/
|
|
||||||
export function UniqueCheck(options = {}) {
|
|
||||||
const { url, param, label, fieldName, getIgnoreId } = options
|
|
||||||
|
|
||||||
function existsInResponse(res) {
|
|
||||||
if (Array.isArray(res)) return res.length > 0
|
|
||||||
if (res && typeof res === 'object') {
|
|
||||||
if (typeof res.count === 'number') return res.count > 0
|
|
||||||
if (Array.isArray(res.results)) return res.results.length > 0
|
|
||||||
}
|
|
||||||
return !!res
|
|
||||||
}
|
|
||||||
|
|
||||||
function extractIds(res) {
|
|
||||||
if (Array.isArray(res)) return res.map(i => i?.id).filter(Boolean)
|
|
||||||
if (res && Array.isArray(res.results)) return res.results.map(i => i?.id).filter(Boolean)
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
async validator(rule, value, callback) {
|
|
||||||
try {
|
|
||||||
let v = value
|
|
||||||
|
|
||||||
if (typeof v === 'string') v = v.trim()
|
|
||||||
if (v === '' || v === undefined || v === null) return callback()
|
|
||||||
if (!url || !param) return callback()
|
|
||||||
|
|
||||||
const res = await request.get(url, { params: { [param]: v } })
|
|
||||||
let duplicated = existsInResponse(res)
|
|
||||||
|
|
||||||
if (duplicated && typeof getIgnoreId === 'function') {
|
|
||||||
const curId = getIgnoreId()
|
|
||||||
if (curId) {
|
|
||||||
const ids = extractIds(res)
|
|
||||||
|
|
||||||
// 查询结果只包含自身,因此不被视为重复
|
|
||||||
if (ids.length >= 1 && ids.every(id => id === curId)) {
|
|
||||||
duplicated = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (duplicated) {
|
|
||||||
const _label = label || fieldName || ''
|
|
||||||
const msg = `${_label}${i18n.t('Existing')}`
|
|
||||||
callback(new Error(msg))
|
|
||||||
} else {
|
|
||||||
callback()
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
callback()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
trigger: ['blur']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
<el-button
|
<el-button
|
||||||
:type="item.el && item.el.type"
|
:type="item.el && item.el.type"
|
||||||
class="start-stop-btn"
|
class="start-stop-btn"
|
||||||
:disabled="item.disabled"
|
|
||||||
size="mini"
|
size="mini"
|
||||||
@click="item.callback()"
|
@click="item.callback()"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -361,10 +361,9 @@ export default {
|
|||||||
},
|
},
|
||||||
// 填充表达式
|
// 填充表达式
|
||||||
submitFill() {
|
submitFill() {
|
||||||
const minMinutes = 60
|
|
||||||
const crontabDiffMin = this.crontabDiff / 1000 / 60
|
const crontabDiffMin = this.crontabDiff / 1000 / 60
|
||||||
if (crontabDiffMin > 0 && crontabDiffMin < minMinutes) {
|
if (crontabDiffMin > 0 && crontabDiffMin < 10) {
|
||||||
const msg = this.$t('CrontabDiffError', { minutes: minMinutes })
|
const msg = this.$tc('CrontabDiffError')
|
||||||
this.$message.error(msg)
|
this.$message.error(msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,18 +10,15 @@
|
|||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-radio v-model="radioValue" :label="2">
|
<el-radio v-model="radioValue" :label="2">
|
||||||
{{ this.$t('From') }}
|
{{ this.$t('From') }}
|
||||||
<el-input-number v-model="cycle01" :max="23" :min="0" size="mini" />
|
<el-input-number v-model="cycle01" :max="60" :min="0" size="mini" /> -
|
||||||
-
|
<el-input-number v-model="cycle02" :max="60" :min="0" size="mini" /> {{ this.$t('Hour') }}
|
||||||
<el-input-number v-model="cycle02" :max="23" :min="0" size="mini" />
|
|
||||||
{{ this.$t('Hour') }}
|
|
||||||
</el-radio>
|
</el-radio>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-radio v-model="radioValue" :label="3">
|
<el-radio v-model="radioValue" :label="3">
|
||||||
{{ this.$t('Every') }}
|
{{ this.$t('Every') }}
|
||||||
<el-input-number v-model="average02" :max="23" :min="1" size="mini" />
|
<el-input-number v-model="average02" :max="60" :min="1" size="mini" /> {{ this.$t('Hour') }} {{ this.$t('ExecuteOnce') }}
|
||||||
{{ this.$t('Hour') }} {{ this.$t('ExecuteOnce') }}
|
|
||||||
</el-radio>
|
</el-radio>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
@@ -35,7 +32,7 @@
|
|||||||
multiple
|
multiple
|
||||||
style="width:100%"
|
style="width:100%"
|
||||||
>
|
>
|
||||||
<el-option v-for="item in 24" :key="item" :value="item-1">{{ item - 1 }}</el-option>
|
<el-option v-for="item in 24" :key="item" :value="item-1">{{ item-1 }}</el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-radio>
|
</el-radio>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-radio v-model="radioValue" :label="3">
|
<el-radio v-model="radioValue" :label="3">
|
||||||
{{ this.$t('From') }}
|
{{ this.$t('From') }}
|
||||||
<el-input-number v-model="average02" :max="59" :min="1" size="mini" />
|
<el-input-number v-model="average02" :max="60" :min="1" size="mini" />
|
||||||
{{ this.$t('Min') }} {{ this.$t('ExecuteOnce') }}
|
{{ this.$t('Min') }} {{ this.$t('ExecuteOnce') }}
|
||||||
</el-radio>
|
</el-radio>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import parser from 'cron-parser'
|
import parser from 'cron-parser'
|
||||||
import { toSafeLocalDateStr } from '@/utils/common/time'
|
import { toSafeLocalDateStr } from '@/utils/time'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'CrontabResult',
|
name: 'CrontabResult',
|
||||||
|
|||||||
@@ -39,13 +39,6 @@ export default {
|
|||||||
showCron: false
|
showCron: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
|
||||||
value: {
|
|
||||||
handler(val) {
|
|
||||||
this.crontabFill(val)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
crontabFill(value) {
|
crontabFill(value) {
|
||||||
// 确定后回传的值
|
// 确定后回传的值
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import BaseFormatter from '@/components/Table/TableFormatters/base.vue'
|
import BaseFormatter from '@/components/Table/TableFormatters/base.vue'
|
||||||
import { setUrlParam } from '@/utils/common/index'
|
import { setUrlParam } from '@/utils/common'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ValueFormatter',
|
name: 'ValueFormatter',
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ import DataTable from '@/components/Table/DataTable/index.vue'
|
|||||||
import ValueFormatter from './ValueFormatter.vue'
|
import ValueFormatter from './ValueFormatter.vue'
|
||||||
import AttrFormDialog from './AttrFormDialog.vue'
|
import AttrFormDialog from './AttrFormDialog.vue'
|
||||||
import AttrMatchResultDialog from './AttrMatchResultDialog.vue'
|
import AttrMatchResultDialog from './AttrMatchResultDialog.vue'
|
||||||
import { setUrlParam } from '@/utils/common/index'
|
import { setUrlParam } from '@/utils/common'
|
||||||
import { attrMatchOptions } from '@/components/const'
|
import { attrMatchOptions } from '@/components/const'
|
||||||
import { toM2MJsonParams } from '@/utils/jms/index'
|
import { toM2MJsonParams } from '@/utils/jms'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'JSONManyToManySelect',
|
name: 'JSONManyToManySelect',
|
||||||
@@ -109,7 +109,7 @@ export default {
|
|||||||
columns: [
|
columns: [
|
||||||
{ prop: 'name', label: this.$t('AttrName'), formatter: tableFormatter('name') },
|
{ prop: 'name', label: this.$t('AttrName'), formatter: tableFormatter('name') },
|
||||||
{ prop: 'match', label: this.$t('Match'), formatter: tableFormatter('match') },
|
{ prop: 'match', label: this.$t('Match'), formatter: tableFormatter('match') },
|
||||||
{ prop: 'value', label: this.$t('AttrValue'), formatter: ValueFormatter, formatterArgs: { attrs: this.attrs } },
|
{ prop: 'value', label: this.$t('AttrValue'), formatter: ValueFormatter, formatterArgs: { attrs: this.attrs }},
|
||||||
{
|
{
|
||||||
prop: 'action',
|
prop: 'action',
|
||||||
label: this.$t('Action'),
|
label: this.$t('Action'),
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export default {
|
|||||||
props: {
|
props: {
|
||||||
value: {
|
value: {
|
||||||
type: [Array, String, Number, Boolean, Object],
|
type: [Array, String, Number, Boolean, Object],
|
||||||
default: () => []
|
default: () => ([])
|
||||||
},
|
},
|
||||||
multiple: {
|
multiple: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
@@ -36,7 +36,7 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
attrsWithoutValue() {
|
attrsWithoutValue() {
|
||||||
const attrs = Object.assign({ clearable: this.clearable }, this.$attrs)
|
const attrs = Object.assign({}, this.$attrs)
|
||||||
delete attrs.value
|
delete attrs.value
|
||||||
return attrs
|
return attrs
|
||||||
},
|
},
|
||||||
@@ -50,13 +50,6 @@ export default {
|
|||||||
const value = this.objectsToValues(this.value)
|
const value = this.objectsToValues(this.value)
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
},
|
|
||||||
clearable() {
|
|
||||||
if (this.$attrs.clearable === undefined) {
|
|
||||||
return this.multiple
|
|
||||||
} else {
|
|
||||||
return this.$attrs.clearable
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -78,11 +71,8 @@ export default {
|
|||||||
value = value.map(v => {
|
value = value.map(v => {
|
||||||
// uuid v4
|
// uuid v4
|
||||||
const uuid = /^[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i
|
const uuid = /^[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i
|
||||||
return typeof v === 'object'
|
return typeof v === 'object' ? v
|
||||||
? v
|
: this.$attrs?.allowCreate && !uuid.test(v) ? { [this.customLabelKeyName]: v } : { pk: v }
|
||||||
: this.$attrs?.allowCreate && !uuid.test(v)
|
|
||||||
? { [this.customLabelKeyName]: v }
|
|
||||||
: { pk: v }
|
|
||||||
})
|
})
|
||||||
if (!this.multiple) {
|
if (!this.multiple) {
|
||||||
value = value[0]
|
value = value[0]
|
||||||
@@ -97,13 +87,9 @@ export default {
|
|||||||
if (!Array.isArray(val)) {
|
if (!Array.isArray(val)) {
|
||||||
val = [val]
|
val = [val]
|
||||||
}
|
}
|
||||||
val = val.map(v => {
|
val = val.map((v) => {
|
||||||
if (v && typeof v === 'object') {
|
if (v && typeof v === 'object') {
|
||||||
return (
|
return v.pk || v.id || (this.$attrs?.allowCreate ? (v?.[this.customLabelKeyName] + ':' + v?.value) : '')
|
||||||
v.pk ||
|
|
||||||
v.id ||
|
|
||||||
(this.$attrs?.allowCreate ? v?.[this.customLabelKeyName] + ':' + v?.value : '')
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
@@ -117,4 +103,6 @@ export default {
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
slot="prepend"
|
slot="prepend"
|
||||||
:placeholder="$tc('Select')"
|
:placeholder="$tc('Select')"
|
||||||
:value="rawValue.code"
|
:value="rawValue.code"
|
||||||
|
style="width: 105px;"
|
||||||
@change="onChange"
|
@change="onChange"
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
@@ -46,7 +47,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
const defaults = { code: this.getDefaultCode(), phone: '' }
|
const defaults = { code: localStorage.getItem('prePhoneCode') || '+86', phone: '' }
|
||||||
this.rawValue = this.value || defaults
|
this.rawValue = this.value || defaults
|
||||||
this.$axios.get('/api/v1/common/countries/').then(res => {
|
this.$axios.get('/api/v1/common/countries/').then(res => {
|
||||||
this.countries = res.map(item => {
|
this.countries = res.map(item => {
|
||||||
@@ -56,22 +57,6 @@ export default {
|
|||||||
this.$emit('input', this.fullPhone)
|
this.$emit('input', this.fullPhone)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getDefaultCode() {
|
|
||||||
const mapper = {
|
|
||||||
'zh': '+86',
|
|
||||||
'en': '+1',
|
|
||||||
'ja': '+81',
|
|
||||||
'ko': '+82',
|
|
||||||
'fr': '+33',
|
|
||||||
'de': '+49',
|
|
||||||
'es': '+34',
|
|
||||||
'it': '+39',
|
|
||||||
'ru': '+7',
|
|
||||||
'ar': '+966'
|
|
||||||
}
|
|
||||||
const locale = this.$i18n.locale.split('-')[0]
|
|
||||||
return localStorage.getItem('prePhoneCode') || mapper[locale] || '+86'
|
|
||||||
},
|
|
||||||
onChange(countryCode) {
|
onChange(countryCode) {
|
||||||
this.rawValue.code = countryCode
|
this.rawValue.code = countryCode
|
||||||
this.onInputChange()
|
this.onInputChange()
|
||||||
@@ -84,11 +69,7 @@ export default {
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style scoped>
|
||||||
.el-select {
|
|
||||||
width: 85px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.country-name {
|
.country-name {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 150px;
|
width: 150px;
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ export default {
|
|||||||
const vm = this
|
const vm = this
|
||||||
const platform = this.$route.query.platform
|
const platform = this.$route.query.platform
|
||||||
return {
|
return {
|
||||||
platform: '',
|
|
||||||
loading: true,
|
loading: true,
|
||||||
form: this.protocol,
|
form: this.protocol,
|
||||||
platformDetail: platform ? '#/console/assets/platforms/' + platform : '',
|
platformDetail: platform ? '#/console/assets/platforms/' + platform : '',
|
||||||
@@ -98,29 +97,11 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async mounted() {
|
|
||||||
try {
|
|
||||||
const drawActionMeta = await this.$store.dispatch('common/getDrawerActionMeta')
|
|
||||||
const platform = drawActionMeta.row.platform.id
|
|
||||||
const name = drawActionMeta.row.platform.name
|
|
||||||
|
|
||||||
if (platform) {
|
|
||||||
this.platformDetail = `/ui/#/settings/platforms?id=${platform}&name=${name}`
|
|
||||||
} else {
|
|
||||||
this.platformDetail = ''
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
throw new Error(e)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
onSubmit(form) {
|
onSubmit(form) {
|
||||||
this.protocol = Object.assign(this.protocol, form)
|
this.protocol = Object.assign(this.protocol, form)
|
||||||
this.$emit('update:visible', false)
|
this.$emit('update:visible', false)
|
||||||
this.$emit('confirm', this.protocol)
|
this.$emit('confirm', this.protocol)
|
||||||
},
|
|
||||||
openInNewTab() {
|
|
||||||
window.open(this.platformDetail, '_blank')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,9 +33,6 @@
|
|||||||
>
|
>
|
||||||
<i :class="[isCheckShowPassword ? 'fa-eye-slash' : 'fa-eye']" class="fa" />
|
<i :class="[isCheckShowPassword ? 'fa-eye-slash' : 'fa-eye']" class="fa" />
|
||||||
</span>
|
</span>
|
||||||
<span v-if="filterTags.length > 0" class="clear-icon" @click="handleClearAll">
|
|
||||||
<i class="el-icon-circle-close" :title="$t('Clear')" />
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -81,18 +78,16 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
filterTags: this.value,
|
||||||
focus: false,
|
focus: false,
|
||||||
filterValue: '',
|
filterValue: '',
|
||||||
filterTags: this.value,
|
isCheckShowPassword: this.replaceShowPassword,
|
||||||
isCheckShowPassword: this.replaceShowPassword
|
component: this.autocomplete ? 'el-autocomplete' : 'el-input'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
iPlaceholder() {
|
iPlaceholder() {
|
||||||
return `${this.placeholder} (${this.$t('EnterToContinue')})`
|
return `${this.placeholder} (${this.$t('EnterToContinue')})`
|
||||||
},
|
|
||||||
component() {
|
|
||||||
return this.autocomplete !== null ? 'el-autocomplete' : 'el-input'
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@@ -118,9 +113,8 @@ export default {
|
|||||||
if (!this.filterTags.includes(this.filterValue)) {
|
if (!this.filterTags.includes(this.filterValue)) {
|
||||||
this.filterTags.push(this.filterValue)
|
this.filterTags.push(this.filterValue)
|
||||||
this.filterValue = ''
|
this.filterValue = ''
|
||||||
}
|
|
||||||
this.$emit('change', this.filterTags)
|
this.$emit('change', this.filterTags)
|
||||||
this.$emit('input', this.filterTags)
|
}
|
||||||
this.$refs.SearchInput.focus()
|
this.$refs.SearchInput.focus()
|
||||||
},
|
},
|
||||||
handleTagClick(v, k) {
|
handleTagClick(v, k) {
|
||||||
@@ -143,11 +137,6 @@ export default {
|
|||||||
},
|
},
|
||||||
handleShowPassword() {
|
handleShowPassword() {
|
||||||
this.isCheckShowPassword = !this.isCheckShowPassword
|
this.isCheckShowPassword = !this.isCheckShowPassword
|
||||||
},
|
|
||||||
handleClearAll() {
|
|
||||||
this.filterTags = []
|
|
||||||
this.$emit('change', this.filterTags)
|
|
||||||
this.$emit('input', this.filterTags)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -169,12 +158,11 @@ export default {
|
|||||||
line-height: 30px;
|
line-height: 30px;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
border-color: #c0c4cc;
|
border-color: #C0C4CC;
|
||||||
}
|
}
|
||||||
|
|
||||||
& ::v-deep .el-tag {
|
& ::v-deep .el-tag {
|
||||||
margin-bottom: 2px;
|
margin-bottom: 1px;
|
||||||
margin-top: 2px;
|
|
||||||
font-family: sans-serif !important;
|
font-family: sans-serif !important;
|
||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
}
|
}
|
||||||
@@ -186,7 +174,6 @@ export default {
|
|||||||
|
|
||||||
.search-input {
|
.search-input {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 150px;
|
|
||||||
|
|
||||||
& ::v-deep .el-input__inner {
|
& ::v-deep .el-input__inner {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
@@ -202,7 +189,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.filter-field ::v-deep .el-input__inner {
|
.filter-field ::v-deep .el-input__inner {
|
||||||
height: 27px !important;
|
height: 28px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.show-password {
|
.show-password {
|
||||||
@@ -214,15 +201,4 @@ export default {
|
|||||||
color: #999999;
|
color: #999999;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.clear-icon {
|
|
||||||
display: inherit;
|
|
||||||
padding-right: 6px;
|
|
||||||
cursor: pointer;
|
|
||||||
color: #c0c4cc;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
color: #606164;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ export default {
|
|||||||
return { label: item.name, value: item.id }
|
return { label: item.name, value: item.id }
|
||||||
})
|
})
|
||||||
const url = vm.url || vm.ajax.url
|
const url = vm.url || vm.ajax.url
|
||||||
const getPageData = async ({ pageIndex, pageSize, keyword }) => {
|
const getPageData = async({ pageIndex, pageSize, keyword }) => {
|
||||||
const limit = pageSize
|
const limit = pageSize
|
||||||
const offset = (pageIndex - 1) * pageSize
|
const offset = (pageIndex - 1) * pageSize
|
||||||
const params = {
|
const params = {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Select2 from './Select2.vue'
|
import Select2 from './Select2.vue'
|
||||||
import { hasUUID } from '@/utils/common/index'
|
import { hasUUID } from '@/utils/common'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { randomString } from '@/utils/common/index'
|
import { randomString } from '@/utils/string'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ export default {
|
|||||||
const [start, end] = val.split('~')
|
const [start, end] = val.split('~')
|
||||||
const startVal = this.countIndex(start)
|
const startVal = this.countIndex(start)
|
||||||
const endVal = this.countIndex(end)
|
const endVal = this.countIndex(end)
|
||||||
for (let i = startVal; i < (endVal === 0 ? 24 : endVal); i++) {
|
for (let i = startVal; i < (endVal === 0 ? 48 : endVal); i++) {
|
||||||
const curWeek = this.weekTimeData[idNum]
|
const curWeek = this.weekTimeData[idNum]
|
||||||
const curChild = curWeek.child[i]
|
const curChild = curWeek.child[i]
|
||||||
if (curChild) {
|
if (curChild) {
|
||||||
@@ -181,8 +181,11 @@ export default {
|
|||||||
// 计算索引
|
// 计算索引
|
||||||
countIndex(val) {
|
countIndex(val) {
|
||||||
const one = val.substr(0, 2)
|
const one = val.substr(0, 2)
|
||||||
const index = one.startsWith('0') ? one.substr(1, 2) : one
|
const a1 = one.startsWith('0') ? one.substr(1, 2) : one
|
||||||
return Number(index)
|
var reg = RegExp(/30/)
|
||||||
|
const a2 = val.match(reg) ? 1 : 0
|
||||||
|
const curIndex = (a1 * 2) + a2
|
||||||
|
return curIndex
|
||||||
},
|
},
|
||||||
formatDate(date, fmt) {
|
formatDate(date, fmt) {
|
||||||
const o = {
|
const o = {
|
||||||
|
|||||||
@@ -21,11 +21,21 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script type="text/jsx">
|
<script type="text/jsx">
|
||||||
import Sortable from 'sortablejs'
|
|
||||||
import DataTable from '@/components/Table/DataTable/index.vue'
|
import DataTable from '@/components/Table/DataTable/index.vue'
|
||||||
import { newURL, ObjectLocalStorage, replaceAllUUID } from '@/utils/common/index'
|
import {
|
||||||
|
ActionsFormatter,
|
||||||
|
ArrayFormatter,
|
||||||
|
ChoicesFormatter,
|
||||||
|
CopyableFormatter,
|
||||||
|
DateFormatter,
|
||||||
|
DetailFormatter,
|
||||||
|
DisplayFormatter,
|
||||||
|
ObjectRelatedFormatter
|
||||||
|
} from '@/components/Table/TableFormatters'
|
||||||
|
import i18n from '@/i18n/i18n'
|
||||||
|
import { newURL, ObjectLocalStorage, replaceAllUUID, toSentenceCase } from '@/utils/common'
|
||||||
import ColumnSettingPopover from './components/ColumnSettingPopover.vue'
|
import ColumnSettingPopover from './components/ColumnSettingPopover.vue'
|
||||||
import { TableColumnsGenerator } from './utils'
|
import LabelsFormatter from '@/components/Table/TableFormatters/LabelsFormatter.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'AutoDataTable',
|
name: 'AutoDataTable',
|
||||||
@@ -47,9 +57,9 @@ export default {
|
|||||||
return {
|
return {
|
||||||
loading: true,
|
loading: true,
|
||||||
method: 'get',
|
method: 'get',
|
||||||
meta: {},
|
|
||||||
iConfig: {},
|
|
||||||
autoConfig: {},
|
autoConfig: {},
|
||||||
|
iConfig: {},
|
||||||
|
meta: {},
|
||||||
cleanedColumnsShow: {},
|
cleanedColumnsShow: {},
|
||||||
totalColumns: [],
|
totalColumns: [],
|
||||||
popoverColumns: {
|
popoverColumns: {
|
||||||
@@ -59,31 +69,41 @@ export default {
|
|||||||
defaultCols: []
|
defaultCols: []
|
||||||
},
|
},
|
||||||
isDeactivated: false,
|
isDeactivated: false,
|
||||||
tableColumnsStorage: this.getTableColumnsStorage(),
|
objTableColumns: new ObjectLocalStorage('tableColumns')
|
||||||
sortable: null,
|
}
|
||||||
inited: false
|
},
|
||||||
|
computed: {
|
||||||
|
dynamicActionWidth() {
|
||||||
|
if (this.$i18n.locale === 'en') {
|
||||||
|
return '120px'
|
||||||
|
}
|
||||||
|
if (this.$i18n.locale === 'pt-br') {
|
||||||
|
return '160px'
|
||||||
|
}
|
||||||
|
return '100px'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
config: {
|
config: {
|
||||||
immediate: false,
|
|
||||||
handler: _.debounce(function(iNew, iOld) {
|
handler: _.debounce(function(iNew, iOld) {
|
||||||
if (this.isDeactivated || !this.inited) {
|
if (this.isDeactivated) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const changed = this.isConfigChanged(iNew, iOld)
|
try {
|
||||||
if (!changed) {
|
if (JSON.stringify(iNew) === JSON.stringify(iOld)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
this.$log.error('JsonStringify Error: ', error)
|
||||||
|
}
|
||||||
|
|
||||||
this.optionUrlMetaAndGenCols()
|
this.optionUrlMetaAndGenCols()
|
||||||
this.$log.debug('AutoDataTable Config change found')
|
this.$log.debug('AutoDataTable Config change found, ', this.isDeactivated)
|
||||||
}, 200)
|
}, 200)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async created() {
|
created() {
|
||||||
await this.optionUrlMetaAndGenCols()
|
this.optionUrlMetaAndGenCols()
|
||||||
this.loading = false
|
|
||||||
},
|
},
|
||||||
deactivated() {
|
deactivated() {
|
||||||
this.isDeactivated = true
|
this.isDeactivated = true
|
||||||
@@ -92,130 +112,323 @@ export default {
|
|||||||
this.isDeactivated = false
|
this.isDeactivated = false
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
isConfigChanged(iNew, iOld) {
|
|
||||||
const _iNew = _.cloneDeep(iNew)
|
|
||||||
const _iOld = _.cloneDeep(iOld)
|
|
||||||
delete _iNew.columns
|
|
||||||
delete _iOld.columns
|
|
||||||
const oldMeta = _iNew.columnsMeta
|
|
||||||
const newMeta = _iOld.columnsMeta
|
|
||||||
const metas = [oldMeta, newMeta]
|
|
||||||
for (const meta of metas) {
|
|
||||||
if (!meta) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
for (const [key, value] of Object.entries(meta)) {
|
|
||||||
if (!key || !value || typeof value !== 'object') {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
delete value['formatter']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (JSON.stringify(_iNew) === JSON.stringify(_iOld)) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
this.$log.error('JsonStringify Error: ', error)
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
},
|
|
||||||
setColumnDraggable() {
|
|
||||||
const el = this.$el.querySelector('.el-table__header-wrapper thead tr')
|
|
||||||
if (!el) {
|
|
||||||
setTimeout(() => this.setColumnDraggable(), 500)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (this.sortable) {
|
|
||||||
this.sortable.destroy()
|
|
||||||
}
|
|
||||||
|
|
||||||
this.sortable = Sortable.create(el, {
|
|
||||||
animation: 150,
|
|
||||||
onEnd: (evt) => {
|
|
||||||
let { oldIndex, newIndex } = evt
|
|
||||||
if (oldIndex === newIndex) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// 检测表格是否有选择列
|
|
||||||
const hasSelectionColumn = this.$el.querySelector('.el-table-column--selection') !== null
|
|
||||||
if (hasSelectionColumn) {
|
|
||||||
// 如果有选择列,调整索引
|
|
||||||
if (oldIndex > 0) oldIndex -= 1
|
|
||||||
if (newIndex > 0) newIndex -= 1
|
|
||||||
}
|
|
||||||
|
|
||||||
let columnNames = [...this.cleanedColumnsShow.show]
|
|
||||||
if (columnNames.includes('actions')) {
|
|
||||||
columnNames = columnNames.filter(item => item !== 'actions')
|
|
||||||
columnNames.push('actions')
|
|
||||||
}
|
|
||||||
// 边界
|
|
||||||
if (oldIndex >= 0 && oldIndex < columnNames.length &&
|
|
||||||
newIndex >= 0 && newIndex < columnNames.length) {
|
|
||||||
const movedItem = columnNames.splice(oldIndex, 1)[0]
|
|
||||||
columnNames.splice(newIndex, 0, movedItem)
|
|
||||||
|
|
||||||
this.$log.debug('Column moved: ', movedItem, oldIndex, ' => ', newIndex)
|
|
||||||
// 保存更新的列顺序
|
|
||||||
this.tableColumnsStorage.set(columnNames)
|
|
||||||
|
|
||||||
// 更新内部状态
|
|
||||||
this.cleanedColumnsShow.show = columnNames
|
|
||||||
this.popoverColumns.currentCols = columnNames
|
|
||||||
|
|
||||||
// 重新应用列顺序
|
|
||||||
this.filterShowColumns()
|
|
||||||
|
|
||||||
this.loading = true
|
|
||||||
setTimeout(() => {
|
|
||||||
this.loading = false
|
|
||||||
// 在DOM完全更新后重新初始化拖拽
|
|
||||||
this.$nextTick(() => {
|
|
||||||
setTimeout(() => this.setColumnDraggable(), 200)
|
|
||||||
})
|
|
||||||
}, 300)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
generateTotalColumns() {
|
|
||||||
const generator = new TableColumnsGenerator(this.config, this.meta, this)
|
|
||||||
this.totalColumns = generator.generateColumns()
|
|
||||||
this.config.columns = this.totalColumns
|
|
||||||
this.iConfig = _.cloneDeep(this.config)
|
|
||||||
},
|
|
||||||
async optionUrlMetaAndGenCols() {
|
async optionUrlMetaAndGenCols() {
|
||||||
if (this.config.url === '') {
|
if (this.config.url === '') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const url = (this.config.url.indexOf('?') === -1)
|
const url = (this.config.url.indexOf('?') === -1)
|
||||||
? `${this.config.url}?display=1`
|
? `${this.config.url}?draw=1&display=1`
|
||||||
: `${this.config.url}&display=1`
|
: `${this.config.url}&draw=1&display=1`
|
||||||
|
this.$store.dispatch('common/getUrlMeta', { url: url }).then(data => {
|
||||||
/**
|
|
||||||
* 原有代码无法正确的同步 storage 的原因是 currentOrder 总是在 totalColumns 之前进行的
|
|
||||||
* 这导致在首次加载时,currentOrder总是为空数组,因为此时cleanedColumnsShow.show还未初始化
|
|
||||||
*/
|
|
||||||
try {
|
|
||||||
const data = await this.$store.dispatch('common/getUrlMeta', { url: url })
|
|
||||||
const method = this.method.toUpperCase()
|
const method = this.method.toUpperCase()
|
||||||
this.meta = data.actions && data.actions[method] ? data.actions[method] : {}
|
this.meta = data.actions && data.actions[method] ? data.actions[method] : {}
|
||||||
|
|
||||||
this.generateTotalColumns()
|
this.generateTotalColumns()
|
||||||
this.cleanColumnsShow()
|
}).then(() => {
|
||||||
|
// 根据当前列重新生成最终渲染表格
|
||||||
this.filterShowColumns()
|
this.filterShowColumns()
|
||||||
|
}).then(() => {
|
||||||
|
// 生成给子组件使用的TotalColList
|
||||||
this.generatePopoverColumns()
|
this.generatePopoverColumns()
|
||||||
this.setColumnDraggable()
|
}).catch((error) => {
|
||||||
} catch (error) {
|
|
||||||
this.$log.error('Error occur: ', error)
|
this.$log.error('Error occur: ', error)
|
||||||
}
|
}).finally(() => {
|
||||||
|
this.loading = false
|
||||||
|
})
|
||||||
},
|
},
|
||||||
getTableColumnsStorage() {
|
generateColumnByName(name, col) {
|
||||||
let tableName = this.config.name || this.$route.name + '_' + newURL(this.config.url).pathname
|
switch (name) {
|
||||||
tableName = replaceAllUUID(tableName)
|
case 'id':
|
||||||
return new ObjectLocalStorage('tableColumns', tableName)
|
if (!col.width) {
|
||||||
|
col.width = '299px'
|
||||||
|
}
|
||||||
|
if (!col.formatter) {
|
||||||
|
col.formatter = CopyableFormatter
|
||||||
|
col.iconPosition = 'left'
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case 'name':
|
||||||
|
col.formatter = DetailFormatter
|
||||||
|
col.sortable = 'custom'
|
||||||
|
col.showOverflowTooltip = true
|
||||||
|
col.minWidth = '150px'
|
||||||
|
break
|
||||||
|
case 'actions':
|
||||||
|
col = {
|
||||||
|
prop: 'actions',
|
||||||
|
label: i18n.t('Actions'),
|
||||||
|
align: 'center',
|
||||||
|
width: this.dynamicActionWidth,
|
||||||
|
formatter: ActionsFormatter,
|
||||||
|
fixed: 'right',
|
||||||
|
formatterArgs: {}
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case 'is_valid':
|
||||||
|
col.label = i18n.t('Valid')
|
||||||
|
col.formatter = ChoicesFormatter
|
||||||
|
col.formatterArgs = {
|
||||||
|
textChoices: {
|
||||||
|
true: i18n.t('Yes'),
|
||||||
|
false: i18n.t('No')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
col.width = '80px'
|
||||||
|
break
|
||||||
|
case 'is_active':
|
||||||
|
col.formatter = ChoicesFormatter
|
||||||
|
col.formatterArgs = {
|
||||||
|
textChoices: {
|
||||||
|
true: i18n.t('Active'),
|
||||||
|
false: i18n.t('Inactive')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
col.width = '100px'
|
||||||
|
break
|
||||||
|
case 'datetime':
|
||||||
|
case 'date_start':
|
||||||
|
col.formatter = DateFormatter
|
||||||
|
break
|
||||||
|
case 'labels':
|
||||||
|
col.formatter = LabelsFormatter
|
||||||
|
col.width = '200px'
|
||||||
|
break
|
||||||
|
case 'comment':
|
||||||
|
col.showOverflowTooltip = true
|
||||||
|
}
|
||||||
|
return col
|
||||||
|
},
|
||||||
|
generateColumnByType(type, col, meta) {
|
||||||
|
switch (type) {
|
||||||
|
case 'choice':
|
||||||
|
col.sortable = 'custom'
|
||||||
|
col.formatter = DisplayFormatter
|
||||||
|
break
|
||||||
|
case 'labeled_choice':
|
||||||
|
col.sortable = 'custom'
|
||||||
|
col.formatter = ChoicesFormatter
|
||||||
|
break
|
||||||
|
case 'boolean':
|
||||||
|
col.formatter = ChoicesFormatter
|
||||||
|
// col.width = '80px'
|
||||||
|
break
|
||||||
|
case 'datetime':
|
||||||
|
col.formatter = DateFormatter
|
||||||
|
col.width = '155px'
|
||||||
|
break
|
||||||
|
case 'object_related_field':
|
||||||
|
col.formatter = ObjectRelatedFormatter
|
||||||
|
break
|
||||||
|
case 'm2m_related_field':
|
||||||
|
col.formatter = ObjectRelatedFormatter
|
||||||
|
break
|
||||||
|
case 'list':
|
||||||
|
col.formatter = ArrayFormatter
|
||||||
|
break
|
||||||
|
case 'json':
|
||||||
|
case 'field':
|
||||||
|
if (meta.child && meta.child.type === 'nested object') {
|
||||||
|
col.formatter = ObjectRelatedFormatter
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
// this.$log.debug('Field: ', type, col.prop, col)
|
||||||
|
return col
|
||||||
|
},
|
||||||
|
addHelpTipIfNeed(col) {
|
||||||
|
const helpTip = col.helpTip
|
||||||
|
if (!helpTip) {
|
||||||
|
return col
|
||||||
|
}
|
||||||
|
col.renderHeader = (h, { column, $index }) => {
|
||||||
|
const binds = {
|
||||||
|
props: {
|
||||||
|
placement: 'bottom',
|
||||||
|
effect: 'dark',
|
||||||
|
openDelay: 500,
|
||||||
|
popperClass: 'help-tips'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<span>{column.label}
|
||||||
|
<el-tooltip {...binds}>
|
||||||
|
<div slot='content' v-sanitize={helpTip}/>
|
||||||
|
<i class='fa fa-question-circle-o help-tip-icon' style='padding-left: 2px'/>
|
||||||
|
</el-tooltip>
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return col
|
||||||
|
},
|
||||||
|
addFilterIfNeed(col) {
|
||||||
|
if (col.prop) {
|
||||||
|
const column = this.meta[col.prop] || {}
|
||||||
|
if (!column.filter) {
|
||||||
|
return col
|
||||||
|
}
|
||||||
|
if (column.type === 'boolean') {
|
||||||
|
col.filters = [
|
||||||
|
{ text: i18n.t('Yes'), value: true },
|
||||||
|
{ text: i18n.t('No'), value: false }
|
||||||
|
]
|
||||||
|
col.sortable = false
|
||||||
|
col['column-key'] = col.prop
|
||||||
|
}
|
||||||
|
if (column.type === 'choice' && column.choices) {
|
||||||
|
col.filters = column.choices.map(item => {
|
||||||
|
if (typeof (item.value) === 'boolean') {
|
||||||
|
if (item.value) {
|
||||||
|
return { text: item['label'], value: 'True' }
|
||||||
|
} else {
|
||||||
|
return { text: item['label'], value: 'False' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { text: item['label'], value: item.value }
|
||||||
|
})
|
||||||
|
col.sortable = false
|
||||||
|
col['column-key'] = col.prop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return col
|
||||||
|
},
|
||||||
|
addOrderingIfNeed(col) {
|
||||||
|
if (col.prop) {
|
||||||
|
const column = this.meta[col.prop] || {}
|
||||||
|
if (column.order) {
|
||||||
|
col.sortable = 'custom'
|
||||||
|
col['column-key'] = col.prop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return col
|
||||||
|
},
|
||||||
|
setDefaultFormatterIfNeed(col) {
|
||||||
|
if (!col.formatter) {
|
||||||
|
col.formatter = (row, column, cellValue) => {
|
||||||
|
let value = cellValue
|
||||||
|
let padding = '0'
|
||||||
|
const excludes = [undefined, null, '']
|
||||||
|
if (excludes.indexOf(value) !== -1) {
|
||||||
|
padding = '6px'
|
||||||
|
value = '-'
|
||||||
|
}
|
||||||
|
return <span style={{ marginLeft: padding }}>{value}</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return col
|
||||||
|
},
|
||||||
|
setDefaultWidthIfNeed(col) {
|
||||||
|
const lang = this.$i18n.locale
|
||||||
|
let factor = 10
|
||||||
|
if (lang === 'zh') {
|
||||||
|
factor = 20
|
||||||
|
}
|
||||||
|
let [sortable, filters] = [0, 0]
|
||||||
|
if (col && col?.sortable === 'custom') {
|
||||||
|
sortable = 10
|
||||||
|
}
|
||||||
|
if (col && col?.filters?.length > 0) {
|
||||||
|
filters = 12
|
||||||
|
}
|
||||||
|
if (col && !col.width && col.label && !col.minWidth) {
|
||||||
|
col.minWidth = `${col.label.length * factor + sortable + filters + 30}px`
|
||||||
|
}
|
||||||
|
return col
|
||||||
|
},
|
||||||
|
generateColumn(name) {
|
||||||
|
const colMeta = this.meta[name] || {}
|
||||||
|
const customMeta = this.config.columnsMeta ? this.config.columnsMeta[name] : {}
|
||||||
|
let col = { prop: name, label: colMeta.label, showOverflowTooltip: true }
|
||||||
|
|
||||||
|
col = this.generateColumnByType(colMeta.type, col, colMeta)
|
||||||
|
col = this.generateColumnByName(name, col)
|
||||||
|
col = this.setDefaultFormatterIfNeed(col)
|
||||||
|
col = Object.assign(col, customMeta)
|
||||||
|
col = this.addHelpTipIfNeed(col)
|
||||||
|
col = this.addFilterIfNeed(col)
|
||||||
|
col = this.addOrderingIfNeed(col)
|
||||||
|
col = this.updateLabelIfNeed(col)
|
||||||
|
col = this.setDefaultWidthIfNeed(col)
|
||||||
|
return col
|
||||||
|
},
|
||||||
|
updateLabelIfNeed(col) {
|
||||||
|
if (!col.label) {
|
||||||
|
return col
|
||||||
|
}
|
||||||
|
col.label = col.label
|
||||||
|
.replace(' Amount', '')
|
||||||
|
.replace(' amount', '')
|
||||||
|
.replace('数量', '')
|
||||||
|
if (col.label.startsWith('Is ')) {
|
||||||
|
col.label = col.label.replace('Is ', '')
|
||||||
|
}
|
||||||
|
col.label = toSentenceCase(col.label)
|
||||||
|
return col
|
||||||
|
},
|
||||||
|
generateTotalColumns() {
|
||||||
|
const config = _.cloneDeep(this.config)
|
||||||
|
let columns = []
|
||||||
|
const allColumnNames = Object.entries(this.meta)
|
||||||
|
.filter(([name, meta]) => !meta['write_only'])
|
||||||
|
.map(([name, meta]) => name)
|
||||||
|
.concat(config.columnsExtra || [])
|
||||||
|
|
||||||
|
let configColumns = config.columns || allColumnNames
|
||||||
|
const columnsExclude = config.columnsExclude || []
|
||||||
|
const columnsAdd = config.columnsAdd || []
|
||||||
|
configColumns = configColumns.concat(columnsAdd)
|
||||||
|
configColumns = configColumns.filter(item => !columnsExclude.includes(item))
|
||||||
|
|
||||||
|
// 解决后端 API 返回字段中包含 actions 的问题;
|
||||||
|
const hasColumnActions = configColumns.findIndex(item => item?.prop === 'actions') !== -1
|
||||||
|
if (!hasColumnActions) {
|
||||||
|
configColumns = [...configColumns.filter(i => i !== 'actions'), 'actions']
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let col of configColumns) {
|
||||||
|
if (typeof col === 'object') {
|
||||||
|
columns.push(col)
|
||||||
|
} else if (typeof col === 'string') {
|
||||||
|
col = this.generateColumn(col)
|
||||||
|
columns.push(col)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
columns = columns.filter(item => {
|
||||||
|
if (item?.showFullContent) {
|
||||||
|
item.className = 'show-full-content'
|
||||||
|
}
|
||||||
|
let has = item.has
|
||||||
|
if (has === undefined) {
|
||||||
|
has = true
|
||||||
|
} else if (typeof has === 'function') {
|
||||||
|
has = has()
|
||||||
|
}
|
||||||
|
return has
|
||||||
|
})
|
||||||
|
|
||||||
|
columns = this.orderingColumns(columns)
|
||||||
|
// 第一次初始化时记录 totalColumns
|
||||||
|
this.totalColumns = columns
|
||||||
|
config.columns = columns
|
||||||
|
this.iConfig = config
|
||||||
|
},
|
||||||
|
orderingColumns(columns) {
|
||||||
|
const cols = _.cloneDeep(this.config.columns)
|
||||||
|
const defaults = _.get(this.config, 'columnsShow.default')
|
||||||
|
const ordering = (cols || defaults || []).map(item => {
|
||||||
|
let prop = item
|
||||||
|
if (typeof item === 'object') {
|
||||||
|
prop = item.prop
|
||||||
|
}
|
||||||
|
return prop
|
||||||
|
})
|
||||||
|
return _.sortBy(columns, (item) => {
|
||||||
|
if (item.prop === 'actions') {
|
||||||
|
return 1000
|
||||||
|
}
|
||||||
|
const i = ordering.indexOf(item.prop)
|
||||||
|
return i === -1 ? 999 : i
|
||||||
|
})
|
||||||
},
|
},
|
||||||
// 生成给子组件使用的TotalColList
|
// 生成给子组件使用的TotalColList
|
||||||
cleanColumnsShow() {
|
cleanColumnsShow() {
|
||||||
@@ -225,12 +438,16 @@ export default {
|
|||||||
if (defaultColumnsNames.length === 0) {
|
if (defaultColumnsNames.length === 0) {
|
||||||
defaultColumnsNames = totalColumnsNames
|
defaultColumnsNames = totalColumnsNames
|
||||||
}
|
}
|
||||||
|
// Clean it
|
||||||
|
defaultColumnsNames = totalColumnsNames.filter(n => defaultColumnsNames.indexOf(n) > -1)
|
||||||
|
|
||||||
// 最小列
|
// 最小列
|
||||||
const minColumnsNames = _.get(this.iConfig, 'columnsShow.min', ['actions', 'id'])
|
const minColumnsNames = _.get(this.iConfig, 'columnsShow.min', ['actions', 'id'])
|
||||||
.filter(n => totalColumnsNames.includes(n))
|
.filter(n => totalColumnsNames.includes(n))
|
||||||
|
|
||||||
const configShowColumnsNames = this.tableColumnsStorage.get()
|
let tableName = this.config.name || this.$route.name + '_' + newURL(this.config.url).pathname
|
||||||
|
tableName = replaceAllUUID(tableName)
|
||||||
|
const configShowColumnsNames = this.objTableColumns.get(tableName)
|
||||||
let showColumnsNames = configShowColumnsNames || defaultColumnsNames
|
let showColumnsNames = configShowColumnsNames || defaultColumnsNames
|
||||||
if (showColumnsNames.length === 0) {
|
if (showColumnsNames.length === 0) {
|
||||||
showColumnsNames = totalColumnsNames
|
showColumnsNames = totalColumnsNames
|
||||||
@@ -241,6 +458,8 @@ export default {
|
|||||||
showColumnsNames.push(v)
|
showColumnsNames.push(v)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
// Clean it
|
||||||
|
showColumnsNames = totalColumnsNames.filter(n => showColumnsNames.indexOf(n) > -1)
|
||||||
|
|
||||||
this.cleanedColumnsShow = {
|
this.cleanedColumnsShow = {
|
||||||
default: defaultColumnsNames,
|
default: defaultColumnsNames,
|
||||||
@@ -252,39 +471,9 @@ export default {
|
|||||||
},
|
},
|
||||||
filterShowColumns() {
|
filterShowColumns() {
|
||||||
this.cleanColumnsShow()
|
this.cleanColumnsShow()
|
||||||
const showFieldNames = this.cleanedColumnsShow.show
|
this.iConfig.columns = this.totalColumns.filter(obj => {
|
||||||
let showFields = this.totalColumns.filter(obj => {
|
return this.cleanedColumnsShow.show.indexOf(obj.prop) > -1
|
||||||
return showFieldNames.indexOf(obj.prop) > -1
|
|
||||||
})
|
})
|
||||||
showFields = this.orderingColumns(showFields)
|
|
||||||
this.iConfig.columns = showFields
|
|
||||||
|
|
||||||
// 确保最新的列配置也应用到config对象上,保持同步
|
|
||||||
this.config.columns = this.iConfig.columns
|
|
||||||
|
|
||||||
this.$nextTick(() => {
|
|
||||||
if (this.$refs.dataTable) {
|
|
||||||
this.$refs.dataTable.getList()
|
|
||||||
}
|
|
||||||
this.inited = true
|
|
||||||
})
|
|
||||||
},
|
|
||||||
orderingColumns(columns) {
|
|
||||||
const cols = _.cloneDeep(this.config.columns)
|
|
||||||
const show = this.cleanedColumnsShow.show
|
|
||||||
const ordering = (show || cols || []).map(item => {
|
|
||||||
let prop = item
|
|
||||||
if (typeof item === 'object') {
|
|
||||||
prop = item.prop
|
|
||||||
}
|
|
||||||
return prop
|
|
||||||
})
|
|
||||||
const sorted = _.sortBy(columns, (item) => {
|
|
||||||
const i = ordering.indexOf(item.prop)
|
|
||||||
item.order = i
|
|
||||||
return i === -1 ? 999 : i
|
|
||||||
})
|
|
||||||
return sorted
|
|
||||||
},
|
},
|
||||||
generatePopoverColumns() {
|
generatePopoverColumns() {
|
||||||
this.popoverColumns.totalColumnsList = this.totalColumns.filter(obj => {
|
this.popoverColumns.totalColumnsList = this.totalColumns.filter(obj => {
|
||||||
@@ -304,7 +493,13 @@ export default {
|
|||||||
columns = this.cleanedColumnsShow.default
|
columns = this.cleanedColumnsShow.default
|
||||||
}
|
}
|
||||||
this.popoverColumns.currentCols = columns
|
this.popoverColumns.currentCols = columns
|
||||||
this.tableColumnsStorage.set(columns)
|
|
||||||
|
let tableName = this.config.name || this.$route.name + '_' + newURL(url).pathname
|
||||||
|
// 替换url中的uuid,避免同一个类型接口生成多个key,localStorage中的数据无法共用.
|
||||||
|
tableName = replaceAllUUID(tableName)
|
||||||
|
|
||||||
|
this.objTableColumns.set(tableName, columns)
|
||||||
|
|
||||||
this.filterShowColumns()
|
this.filterShowColumns()
|
||||||
},
|
},
|
||||||
filterChange(filters) {
|
filterChange(filters) {
|
||||||
|
|||||||