@archbiz/element-ui 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/element-ui.cjs +11 -0
- package/dist/element-ui.js +5518 -0
- package/dist/style.css +1 -0
- package/package.json +50 -4
- package/src/components/ab-checkbox.vue +51 -0
- package/src/components/ab-color-picker.vue +39 -0
- package/src/components/ab-detail/ab-detail.vue +285 -0
- package/src/components/ab-detail/index.js +1 -0
- package/src/components/ab-drawer/ab-drawer.vue +50 -0
- package/src/components/ab-drawer/index.js +3 -0
- package/src/components/ab-icon/ab-icon.vue +90 -0
- package/src/components/ab-icon/index.js +1 -0
- package/src/components/ab-input-number.vue +49 -0
- package/src/components/ab-input-range.vue +90 -0
- package/src/components/ab-radio.vue +51 -0
- package/src/components/ab-router-link.vue +46 -0
- package/src/components/ab-search/ab-search.vue +168 -0
- package/src/components/ab-search/index.js +4 -0
- package/src/components/ab-select.vue +107 -0
- package/src/components/ab-table/ab-table-column.vue +131 -0
- package/src/components/ab-table/ab-table-columns.vue +62 -0
- package/src/components/ab-table/ab-table-operate.vue +160 -0
- package/src/components/ab-table/ab-table.vue +316 -0
- package/src/components/ab-table/columns.js +90 -0
- package/src/components/ab-table/footer.js +77 -0
- package/src/components/ab-table/formatter.js +2 -0
- package/src/components/ab-table/index.js +8 -0
- package/src/components/ab-table/utils.js +36 -0
- package/src/components/ab-time-period.vue +116 -0
- package/src/components/ab-time-picker.vue +38 -0
- package/src/components/ab-toolbar/ab-toolbar.vue +102 -0
- package/src/components/ab-toolbar/index.js +1 -0
- package/src/components/ab-tree-select.vue +456 -0
- package/src/components/ab-upload-file.vue +277 -0
- package/src/components/index.js +27 -0
- package/src/core/ab-form.js +25 -0
- package/src/core/alias.js +36 -0
- package/src/core/config.js +65 -0
- package/src/core/form-render.js +256 -0
- package/src/core/options.js +25 -0
- package/src/hooks/use-cache.js +75 -0
- package/src/index.js +39 -0
- package/src/makers/datePicker.js +8 -0
- package/src/makers/frame.js +23 -0
- package/src/makers/index.js +23 -0
- package/src/makers/input.js +12 -0
- package/src/makers/select.js +8 -0
- package/src/makers/slider.js +7 -0
- package/src/makers/timePicker.js +8 -0
- package/src/makers/tree.js +10 -0
- package/src/makers/upload.js +20 -0
- package/src/parsers/checkbox.js +5 -0
- package/src/parsers/colorPicker.js +29 -0
- package/src/parsers/datePicker.js +24 -0
- package/src/parsers/frame.js +17 -0
- package/src/parsers/hidden.js +11 -0
- package/src/parsers/index.js +36 -0
- package/src/parsers/input.js +15 -0
- package/src/parsers/number.js +29 -0
- package/src/parsers/radio.js +5 -0
- package/src/parsers/select.js +15 -0
- package/src/parsers/slider.js +21 -0
- package/src/parsers/switch.js +11 -0
- package/src/parsers/text.js +25 -0
- package/src/parsers/timePicker.js +12 -0
- package/src/parsers/tree.js +37 -0
- package/src/parsers/upload.js +35 -0
- package/src/plugins/ab-detail.js +7 -0
- package/src/plugins/ab-drawer.js +7 -0
- package/src/plugins/ab-form.js +14 -0
- package/src/plugins/ab-search.js +7 -0
- package/src/plugins/ab-table.js +15 -0
- package/src/plugins/ab-toolbar.js +7 -0
- package/src/rule/defaults.js +187 -0
- package/src/rule/formatter.js +218 -0
- package/src/style/index.css +356 -0
- package/src/utils/formatter.js +188 -0
- package/src/utils/router-link.js +59 -0
- package/README.md +0 -3
package/dist/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.ab-icon{display:inline-flex;align-items:center;justify-content:center;line-height:1;vertical-align:middle}.ab-icon svg{width:1em;height:1em}.ab-tree-select__reference[data-v-2bf84bb8]{display:inline-block;width:100%}.ab-tree-select__tags-wrapper[data-v-2bf84bb8]{width:100%;min-height:38px;cursor:pointer;display:flex;align-items:center;justify-content:space-between;padding:0 8px;background:#fff;border:1px solid #dcdfe6;border-radius:4px;box-sizing:border-box;transition:border-color .2s}.ab-tree-select__tags-wrapper[data-v-2bf84bb8]:hover{border-color:#c0c4cc}.ab-tree-select__tags[data-v-2bf84bb8]{width:100%;display:flex;align-items:center;justify-content:space-between;flex-wrap:nowrap;overflow:hidden;flex:1;min-width:0}.ab-tree-select__input[data-v-2bf84bb8]{width:100%}.ab-tree-select__tag[data-v-2bf84bb8]{flex-shrink:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}.ab-tree-select__first-tag[data-v-2bf84bb8]{flex-shrink:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:180px}.ab-tree-select__tag-multiple[data-v-2bf84bb8]{display:flex;align-items:center;gap:4px}.ab-tree-select__count-tag[data-v-2bf84bb8]{flex-shrink:0;cursor:default}.ab-tree-select__placeholder[data-v-2bf84bb8]{color:#c0c4cc;font-size:14px}.ab-tree-select__dropdown[data-v-2bf84bb8]{min-width:300px}.ab-tree-select__filter[data-v-2bf84bb8]{padding:8px;border-bottom:1px solid #ebeef5}.ab-tree-select__filter-input[data-v-2bf84bb8]{width:100%}.ab-tree-select__empty[data-v-2bf84bb8]{padding:16px;text-align:center;color:#909399}.el-select__caret.is-reverse[data-v-2bf84bb8]{transform:rotate(180deg);transition:transform .2s}.ab-input-range{display:flex;align-items:center;width:100%}.ab-input-range .range-splitter,.ab-input-range .range-prefix,.ab-input-range .range-suffix{margin:0 10px;font-weight:300;white-space:nowrap}.ab-input-range .ab-input-range__val{flex:1}.ab-time-period{display:flex;align-items:center;justify-content:flex-start;width:100%}.ab-time-period .el-slider{flex:1;margin:0 12px}.ab-time-period .start-time,.ab-time-period .end-time{width:78px;height:100%}.ab-time-period .end-time{text-align:right}.ab-time-period .el-slider.is-empty .el-slider__bar{visibility:hidden}.ab-upload-file__list[data-v-0306328f]{margin:0;padding:0;list-style:none}.ab-upload-file__item[data-v-0306328f]{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.ab-upload-file__tip[data-v-0306328f]{font-size:12px;color:#909399}.ab-upload-file__error[data-v-0306328f]{font-size:12px;color:#f56c6c}.ab-router-link[data-v-973bb136]{display:inline-flex;align-items:center;gap:4px}.ab-router-link__anchor[data-v-973bb136]{color:var(--el-color-primary);text-decoration:none}.ab-router-link__anchor[data-v-973bb136]:hover{text-decoration:underline}:root{--el-color-primary: #1890ff;--el-color-success: #13ce66;--el-color-warning: #ffba00;--el-color-danger: #ff4949;--el-card-padding: 12px}::-webkit-scrollbar{width:7px;height:7px}::-webkit-scrollbar:horizontal{height:7px}::-webkit-scrollbar:vertical{height:7px}::-webkit-scrollbar-thumb{background-color:#0000004d;border-radius:4px}::-webkit-scrollbar-track{background-color:transparent}.el-card .el-card__body{padding:var(--el-card-padding)}.w-full{width:100%}.sticky{position:sticky}.top-0{top:0}.z-9{z-index:9}.flex{display:flex}.justify-end{justify-content:flex-end}.items-center{align-items:center}.ab-form,.ab-form .el-row{width:100%;display:flex;flex-direction:row;flex-wrap:wrap}.ab-form .el-form-item{--el-form-item-margin-bottom: 6px;margin-bottom:var(--el-form-item-margin-bottom)!important;margin-right:0!important}.ab-form .el-form-item.w-full{display:flex}.ab-form .ab-search__operates{margin-left:auto}.ab-form .ab-search__operates .el-form-item__content{flex:1 1 auto!important;display:flex;justify-content:flex-end}.ab-form .force-newline{flex-basis:100%}.ab-form .el-divider{width:100%;flex-basis:100%}.ab-form .el-form-item .el-input,.ab-form .el-form-item .el-input-number,.ab-form .el-form-item .el-select,.ab-form .el-form-item .el-date-editor,.ab-form .el-form-item .el-color-picker,.ab-form .el-form-item .el-color-picker__trigger,.ab-form .el-form-item .el-cascader,.ab-form .el-form-item .ab-upload-file{width:100%}.ab-form .el-form-item>.el-form-item__content{flex:0 0 var(--ab-field-width);width:var(--ab-field-width)}.ab-form.is-preview .ab-clock,.ab-form .ab-none,.ab-form.is-preview .el-form-item.is-required>.el-form-item__label-wrap>.el-form-item__label:before,.ab-form.is-preview .el-form-item.is-required>.el-form-item__label:before{display:none!important}.ab-form .el-color-picker__color-inner{display:flex;justify-content:flex-end;align-items:center;padding-right:6px;box-sizing:border-box}.ab-form .el-form-item .el-color-picker__empty,.ab-form .el-form-item .el-color-picker__icon{left:initial;right:0}.ab-form .el-form-item .ab-color-picker__readonly{display:flex;align-items:center;width:100%;min-height:var(--el-component-size-small);border-radius:5px;box-sizing:border-box;padding:0 12px}.ab-router-link{color:var(--el-color-primary);display:flex;align-items:center;text-decoration:none}.ab-router-link:hover{text-decoration:underline}.ab-wrap-right>.el-form-item__label{display:flex;justify-content:flex-end}.ab-wrap-left>.el-form-item__label{display:flex;justify-content:flex-start}.ab-wrap-top.el-form-item{display:block}.ab-wrap-top.el-form-item>.el-form-item__label{display:block;height:auto;line-height:22px;margin-bottom:8px;text-align:left;float:unset}.el-form--large .ab-wrap-top.el-form-item>.el-form-item__label{line-height:22px;margin-bottom:12px}.el-form--default .ab-wrap-top.el-form-item>.el-form-item__label{line-height:22px;margin-bottom:8px}.el-form--small .ab-wrap-top.el-form-item>.el-form-item__label{line-height:20px;margin-bottom:4px}.ab-form-footer{margin-top:12px}.ab-form.is-numbered{counter-reset:q}.ab-form.is-numbered .ab-form-title{counter-increment:q}.ab-form.is-numbered .ab-form-title:before{content:counter(q) ". ";color:var(--ab-number-color, inherit);font-weight:600}.ab-form.is-numbered.is-number-chinese .ab-form-title:before{content:counter(q,simp-chinese-informal) "、"}.el-select-dropdown__item{display:flex;justify-content:space-between;align-items:center;padding:0;margin:0 20px}.el-select-dropdown__item .p-option__left{flex:1 1 auto;padding:0 32px 0 0}.el-select-dropdown__item .p-option__right{min-width:60px;flex:0 0 auto;text-align:right}.ab-form .w-full .el-form-item__label{flex:0 0 auto}.ab-form .w-full .el-form-item__content{width:100%;flex:1 1 auto}.ab-form .w-full .el-upload{width:100%;text-align:right}.ab-detail__header .ab-detail__title{width:50%}.ab-detail__header .ab-detail__opr .el-row{justify-content:flex-end}.ab-table{height:calc(100% - 40px)}.ab-toolbar__title{font-size:1.6em}.ab-toolbar .ab-form{margin-right:8px}.ab-detail__header,.ab-detail__header .el-card__body{width:100%;display:flex;justify-content:space-between;align-items:center;padding-left:var(--el-card-padding);margin:0;box-sizing:border-box}.ab-detail__title{flex:1 1 auto;white-space:nowrap}.ab-detail__opr{flex:1 1 auto;display:flex;justify-content:flex-end;align-items:center}.ab-detail__form{margin-top:1em}.ab-table .vxe-table--footer-wrapper .vxe-footer--column{background-color:var(--vxe-ui-table-header-background-color);color:var(--el-color-primary-dark-2);font-weight:700}.ab-table .vxe-body--column.warning,.ab-table .vxe-cell .ab-icon.warning{color:var(--el-color-warning)}.ab-table .vxe-body--column.success,.ab-table .vxe-cell .ab-icon.success{color:var(--el-color-success)}.ab-table .vxe-body--column.info,.ab-table .vxe-cell .ab-icon.info{color:var(--el-color-info)}.ab-table .vxe-body--column.danger,.ab-table .vxe-cell .ab-icon.danger{color:var(--el-color-danger)}.ab-table .vxe-body--column.primary,.ab-table .vxe-cell .ab-icon.primary{color:var(--el-color-primary)}.ab-table .vxe-cell .ab-icon{margin:0 0 0 6px}.ab-table .items-center .vxe-cell--wrapper{display:flex;align-items:center;justify-content:flex-end}.el-button--text.primary:not(.is-disabled){color:var(--el-color-primary, #409eff)}.el-button--text.success:not(.is-disabled){color:var(--el-color-success, #67c23a)}.el-button--text.warning:not(.is-disabled){color:var(--el-color-warning, #e6a23c)}.el-button--text.danger:not(.is-disabled){color:var(--el-color-danger, #ff4949)}.el-button--text.info:not(.is-disabled){color:var(--el-color-info, #909399)}.ab-input-number .el-input__inner{text-align:right}.ab-search-expand-enter-active[data-v-6f06c64a]{transition:all .3s ease-in-out}.ab-search-expand-leave-active[data-v-6f06c64a]{transition:all .2s ease-out}.ab-search-expand-enter[data-v-6f06c64a],.ab-search-expand-leave-active[data-v-6f06c64a]{transform:translateZ(0);height:0;opacity:0}
|
package/package.json
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@archbiz/element-ui",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Archbiz adapter for Vue 2 and Element UI",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/element-ui.cjs",
|
|
8
|
+
"module": "./dist/element-ui.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/element-ui.js",
|
|
12
|
+
"require": "./dist/element-ui.cjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"dev": "vite --config vite.dev.config.mjs",
|
|
17
|
+
"build": "vite build --config vite.build.config.mjs"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"@archbiz",
|
|
21
|
+
"vue2",
|
|
22
|
+
"element-ui"
|
|
23
|
+
],
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"src",
|
|
27
|
+
"package.json"
|
|
28
|
+
],
|
|
29
|
+
"author": "Dio Zhu",
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@archbiz/core-v2": "^0.1.0",
|
|
32
|
+
"@archbiz/utils": "^0.1.0",
|
|
33
|
+
"dayjs": "^1.11.23",
|
|
34
|
+
"lodash": "^4.18.1"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"element-ui": "2.15.14",
|
|
38
|
+
"vue": "2.6.12",
|
|
39
|
+
"vue-router": "3.0.2",
|
|
40
|
+
"vxe-table": "3.7.9"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@purge-icons/generated": "^0.10.0",
|
|
44
|
+
"element-ui": "2.15.14",
|
|
45
|
+
"vite": "^4.5.0",
|
|
46
|
+
"vite-plugin-vue2": "^2.0.3",
|
|
47
|
+
"vue": "2.6.12",
|
|
48
|
+
"vue-router": "3.0.2",
|
|
49
|
+
"vue-template-compiler": "2.6.12",
|
|
50
|
+
"vxe-table": "3.7.9"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-checkbox-group v-bind="$attrs" :value="value" @input="handleInput" ref="el">
|
|
3
|
+
<template v-for="(option, index) in optionsList">
|
|
4
|
+
<el-checkbox-button
|
|
5
|
+
v-if="type === 'button'"
|
|
6
|
+
:key="`button-${index}-${option.value}`"
|
|
7
|
+
v-bind="optionProps(option)"
|
|
8
|
+
:label="option.value"
|
|
9
|
+
>
|
|
10
|
+
{{ option.label ?? option.value ?? "" }}
|
|
11
|
+
</el-checkbox-button>
|
|
12
|
+
<el-checkbox
|
|
13
|
+
v-else
|
|
14
|
+
:key="`checkbox-${index}-${option.value}`"
|
|
15
|
+
v-bind="optionProps(option)"
|
|
16
|
+
:label="option.value"
|
|
17
|
+
>
|
|
18
|
+
{{ option.label ?? option.value ?? "" }}
|
|
19
|
+
</el-checkbox>
|
|
20
|
+
</template>
|
|
21
|
+
<slot />
|
|
22
|
+
</el-checkbox-group>
|
|
23
|
+
</template>
|
|
24
|
+
|
|
25
|
+
<script>
|
|
26
|
+
export default {
|
|
27
|
+
name: "AbCheckbox",
|
|
28
|
+
inheritAttrs: false,
|
|
29
|
+
props: {
|
|
30
|
+
abFormInject: { type: Object, default: undefined },
|
|
31
|
+
value: { type: Array, default: () => [] },
|
|
32
|
+
options: Array,
|
|
33
|
+
type: String,
|
|
34
|
+
},
|
|
35
|
+
computed: {
|
|
36
|
+
optionsList() {
|
|
37
|
+
const items = this.options || (this.abFormInject && this.abFormInject.options) || [];
|
|
38
|
+
return Array.isArray(items) ? items : [];
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
methods: {
|
|
42
|
+
optionProps(option) {
|
|
43
|
+
const { value, label, ...rest } = option || {};
|
|
44
|
+
return rest;
|
|
45
|
+
},
|
|
46
|
+
handleInput(value) {
|
|
47
|
+
this.$emit("input", value);
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
</script>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-color-picker
|
|
3
|
+
ref="el"
|
|
4
|
+
class="ab-color-picker"
|
|
5
|
+
v-bind="$attrs"
|
|
6
|
+
:value="value"
|
|
7
|
+
:size="currentSize"
|
|
8
|
+
@input="handleInput"
|
|
9
|
+
@change="handleChange"
|
|
10
|
+
/>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script>
|
|
14
|
+
import { useCache } from "../hooks/use-cache.js";
|
|
15
|
+
|
|
16
|
+
export default {
|
|
17
|
+
name: "AbColorPicker",
|
|
18
|
+
inheritAttrs: false,
|
|
19
|
+
props: {
|
|
20
|
+
value: { default: undefined },
|
|
21
|
+
abFormInject: { type: Object, default: undefined },
|
|
22
|
+
},
|
|
23
|
+
computed: {
|
|
24
|
+
currentSize() {
|
|
25
|
+
const { getCurrentSize } = useCache();
|
|
26
|
+
const size = getCurrentSize();
|
|
27
|
+
return size && size !== "default" && size !== "large" ? size : undefined;
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
methods: {
|
|
31
|
+
handleInput(value) {
|
|
32
|
+
this.$emit("input", value);
|
|
33
|
+
},
|
|
34
|
+
handleChange(value) {
|
|
35
|
+
this.$emit("change", value);
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
</script>
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="ab-detail">
|
|
3
|
+
<el-card class="ab-detail__header w-full" shadow="never">
|
|
4
|
+
<div class="ab-detail__title">{{ currentTitle }}</div>
|
|
5
|
+
<ab-table-operate
|
|
6
|
+
class="ab-detail__opr"
|
|
7
|
+
:permi-prefix="permiPrefix"
|
|
8
|
+
:rule="operationRule"
|
|
9
|
+
:model-value="currentValue"
|
|
10
|
+
plain
|
|
11
|
+
:readonly="currentReadonly"
|
|
12
|
+
@input="oapi = $event"
|
|
13
|
+
v-loading="loading"
|
|
14
|
+
/>
|
|
15
|
+
</el-card>
|
|
16
|
+
<el-card class="ab-detail__form" shadow="never">
|
|
17
|
+
<ab-form
|
|
18
|
+
ref="formRef"
|
|
19
|
+
:option="formOption"
|
|
20
|
+
:rule="formRules"
|
|
21
|
+
:id-field="idField"
|
|
22
|
+
:id-field-table="idFieldTable"
|
|
23
|
+
:readonly="currentReadonly"
|
|
24
|
+
v-loading="loading"
|
|
25
|
+
@input="handleFormApi"
|
|
26
|
+
@change="handleFormChange"
|
|
27
|
+
/>
|
|
28
|
+
</el-card>
|
|
29
|
+
</div>
|
|
30
|
+
</template>
|
|
31
|
+
|
|
32
|
+
<script>
|
|
33
|
+
import { AbTableEnum } from "../ab-table/utils.js";
|
|
34
|
+
import { useCache } from "../../hooks/use-cache.js";
|
|
35
|
+
|
|
36
|
+
function isComponent(value) {
|
|
37
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value) && typeof value.render === "function";
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function cloneDeep(value) {
|
|
41
|
+
if (isComponent(value)) return value;
|
|
42
|
+
if (Array.isArray(value)) return value.map(cloneDeep);
|
|
43
|
+
if (value && typeof value === "object") {
|
|
44
|
+
const out = {};
|
|
45
|
+
Object.keys(value).forEach((key) => {
|
|
46
|
+
out[key] = cloneDeep(value[key]);
|
|
47
|
+
});
|
|
48
|
+
return out;
|
|
49
|
+
}
|
|
50
|
+
return value;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export default {
|
|
54
|
+
name: "AbDetail",
|
|
55
|
+
provide() {
|
|
56
|
+
return { abTableDetailRef: { value: this } };
|
|
57
|
+
},
|
|
58
|
+
props: {
|
|
59
|
+
title: String,
|
|
60
|
+
id: { type: [String, Number], default: undefined },
|
|
61
|
+
idField: { type: String, default: "id" },
|
|
62
|
+
idFieldTable: String,
|
|
63
|
+
value: { type: Object, default: () => ({}) },
|
|
64
|
+
rule: { type: Array, default: () => [] },
|
|
65
|
+
validRules: Object,
|
|
66
|
+
permiPrefix: String,
|
|
67
|
+
getHandler: Function,
|
|
68
|
+
createHandler: Function,
|
|
69
|
+
updateHandler: Function,
|
|
70
|
+
deleteHandler: Function,
|
|
71
|
+
vertical: Boolean,
|
|
72
|
+
detailLevel: { type: Number, default: 1 },
|
|
73
|
+
editable: { type: Boolean, default: true },
|
|
74
|
+
readonly: { type: Boolean, default: true },
|
|
75
|
+
},
|
|
76
|
+
data() {
|
|
77
|
+
return {
|
|
78
|
+
currentValue: {},
|
|
79
|
+
currentReadonly: this.readonly,
|
|
80
|
+
loading: false,
|
|
81
|
+
fapi: undefined,
|
|
82
|
+
oapi: undefined,
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
computed: {
|
|
86
|
+
// isStandaloneRoute() {
|
|
87
|
+
// return this.$route?.name === this.$options.name;
|
|
88
|
+
// },
|
|
89
|
+
formOption() {
|
|
90
|
+
const { getCurrentSize } = useCache();
|
|
91
|
+
const size = getCurrentSize();
|
|
92
|
+
return { form: { size } };
|
|
93
|
+
},
|
|
94
|
+
isCreate() {
|
|
95
|
+
const value = this.currentValue ? this.currentValue[this.idField] : undefined;
|
|
96
|
+
return !value || value === "new";
|
|
97
|
+
},
|
|
98
|
+
currentTitle() {
|
|
99
|
+
const title = this.title || (this.$route && this.$route.meta && this.$route.meta.title) || "";
|
|
100
|
+
if (this.isCreate) return `新增 - ${title}`;
|
|
101
|
+
if (this.currentReadonly) return `详情 - ${title}`;
|
|
102
|
+
return `编辑 - ${title}`;
|
|
103
|
+
},
|
|
104
|
+
rules() {
|
|
105
|
+
return (this.rule || []).map((item) => (item && typeof item.getRule === "function" ? item.getRule() : item));
|
|
106
|
+
},
|
|
107
|
+
operationRule() {
|
|
108
|
+
const found = this.rules.find((rule) => rule.type !== AbTableEnum.OPERATE && rule.field === AbTableEnum.OPERATE);
|
|
109
|
+
const out = found ? cloneDeep(found) : { type: "ElRow", field: AbTableEnum.OPERATE, title: "操作", width: 260, fixed: "right", children: [] };
|
|
110
|
+
out.children = (out.children || []).filter((f) => f.field !== AbTableEnum.DETAIL);
|
|
111
|
+
const self = this;
|
|
112
|
+
out.children.push(
|
|
113
|
+
{
|
|
114
|
+
type: "ElButton",
|
|
115
|
+
hidden: !this.currentReadonly,
|
|
116
|
+
children: [{ type: "icon", props: { icon: "ep:edit-pen" } }, "编辑"],
|
|
117
|
+
props: { type: "primary" },
|
|
118
|
+
on: { click: () => self.editHandler() },
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
type: "ElButton",
|
|
122
|
+
hidden: this.currentReadonly,
|
|
123
|
+
children: [{ type: "icon", props: { icon: "ep:check" } }, "保存"],
|
|
124
|
+
props: { type: "success", plain: true },
|
|
125
|
+
on: { click: () => self.saveHandler() },
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
type: "ElButton",
|
|
129
|
+
hidden: this.currentReadonly,
|
|
130
|
+
children: [{ type: "icon", props: { icon: "ep:refresh-right" } }, "取消"],
|
|
131
|
+
on: { click: () => self.cancelHandler() },
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
type: "ElButton",
|
|
135
|
+
children: [{ type: "icon", props: { icon: "ep:back" } }, "返回"],
|
|
136
|
+
on: { click: () => self.returnHandler() },
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
return out;
|
|
140
|
+
},
|
|
141
|
+
formRules() {
|
|
142
|
+
return this.rules.filter((rule) => rule.type !== AbTableEnum.OPERATE && rule.field !== AbTableEnum.OPERATE).map((rule) => cloneDeep(rule));
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
watch: {
|
|
146
|
+
value: {
|
|
147
|
+
handler(next) {
|
|
148
|
+
this.currentValue = { ...next };
|
|
149
|
+
this.syncFormData(next);
|
|
150
|
+
},
|
|
151
|
+
immediate: true,
|
|
152
|
+
deep: true,
|
|
153
|
+
},
|
|
154
|
+
readonly(next) {
|
|
155
|
+
this.currentReadonly = next;
|
|
156
|
+
},
|
|
157
|
+
id(next) {
|
|
158
|
+
this.init(next);
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
mounted() {
|
|
162
|
+
this.init(this.id);
|
|
163
|
+
},
|
|
164
|
+
methods: {
|
|
165
|
+
formApi() {
|
|
166
|
+
return this.fapi || (this.$refs.formRef && this.$refs.formRef.$f);
|
|
167
|
+
},
|
|
168
|
+
handleFormApi(api) {
|
|
169
|
+
this.fapi = api;
|
|
170
|
+
},
|
|
171
|
+
handleFormChange() {
|
|
172
|
+
const api = this.formApi();
|
|
173
|
+
const data = api ? api.formData() : { ...this.currentValue };
|
|
174
|
+
this.currentValue = data;
|
|
175
|
+
this.$emit("input", data);
|
|
176
|
+
},
|
|
177
|
+
resetFormData() {
|
|
178
|
+
const api = this.formApi();
|
|
179
|
+
if (api && typeof api.resetFields === "function") api.resetFields();
|
|
180
|
+
},
|
|
181
|
+
syncFormData(data) {
|
|
182
|
+
const api = this.formApi();
|
|
183
|
+
if (!api || !data) return;
|
|
184
|
+
Object.keys(data).forEach((field) => api.setValue(field, data[field]));
|
|
185
|
+
},
|
|
186
|
+
refreshForm() {
|
|
187
|
+
const api = this.formApi();
|
|
188
|
+
if (api && typeof api.refresh === "function") api.refresh();
|
|
189
|
+
},
|
|
190
|
+
async init(id) {
|
|
191
|
+
this.loading = true;
|
|
192
|
+
let data;
|
|
193
|
+
if (id !== undefined && id !== null && typeof this.getHandler === "function") {
|
|
194
|
+
data = (await this.getHandler(id)) || {};
|
|
195
|
+
} else {
|
|
196
|
+
data = {};
|
|
197
|
+
}
|
|
198
|
+
this.currentValue = data;
|
|
199
|
+
await this.$nextTick();
|
|
200
|
+
this.resetFormData();
|
|
201
|
+
this.syncFormData(data);
|
|
202
|
+
this.refreshForm();
|
|
203
|
+
this.loading = false;
|
|
204
|
+
this.$emit("input", this.currentValue);
|
|
205
|
+
},
|
|
206
|
+
editHandler() {
|
|
207
|
+
this.currentReadonly = false;
|
|
208
|
+
this.refreshForm();
|
|
209
|
+
},
|
|
210
|
+
async saveHandler() {
|
|
211
|
+
this.loading = true;
|
|
212
|
+
if (this.isCreate && typeof this.createHandler === "function") {
|
|
213
|
+
const res = await this.createHandler(this.currentValue);
|
|
214
|
+
if (res) this.currentValue[this.idField] = res;
|
|
215
|
+
await this.$nextTick();
|
|
216
|
+
this.$emit("input", this.currentValue);
|
|
217
|
+
} else if (!this.isCreate && typeof this.updateHandler === "function") {
|
|
218
|
+
await this.updateHandler(this.currentValue);
|
|
219
|
+
}
|
|
220
|
+
this.loading = false;
|
|
221
|
+
this.close();
|
|
222
|
+
},
|
|
223
|
+
cancelHandler() {
|
|
224
|
+
this.currentReadonly = true;
|
|
225
|
+
this.refreshForm();
|
|
226
|
+
},
|
|
227
|
+
returnHandler() {
|
|
228
|
+
this.close();
|
|
229
|
+
},
|
|
230
|
+
async open(d = undefined, r = false) {
|
|
231
|
+
this.currentReadonly = r;
|
|
232
|
+
this.loading = true;
|
|
233
|
+
let data;
|
|
234
|
+
if (typeof this.getHandler === "function" && d && d[this.idField]) {
|
|
235
|
+
data = (await this.getHandler(d[this.idField])) || {};
|
|
236
|
+
} else {
|
|
237
|
+
data = cloneDeep(d) || {};
|
|
238
|
+
this.rules.forEach((rule) => {
|
|
239
|
+
if (
|
|
240
|
+
rule.field &&
|
|
241
|
+
rule.field !== AbTableEnum.OPERATE &&
|
|
242
|
+
typeof data[rule.field] === "undefined" &&
|
|
243
|
+
typeof rule.edit === "undefined" &&
|
|
244
|
+
typeof rule.itemRender === "undefined"
|
|
245
|
+
) {
|
|
246
|
+
data[rule.field] = "";
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
this.currentValue = data;
|
|
251
|
+
await this.$nextTick();
|
|
252
|
+
this.resetFormData();
|
|
253
|
+
this.syncFormData(data);
|
|
254
|
+
this.refreshForm();
|
|
255
|
+
this.loading = false;
|
|
256
|
+
this.$emit("open", this.currentValue);
|
|
257
|
+
this.$emit("input", this.currentValue);
|
|
258
|
+
},
|
|
259
|
+
close() {
|
|
260
|
+
this.currentReadonly = true;
|
|
261
|
+
this.currentValue = {};
|
|
262
|
+
this.resetFormData();
|
|
263
|
+
this.$emit("close");
|
|
264
|
+
// this.$emit("input", this.currentValue);
|
|
265
|
+
// if (this.isStandaloneRoute) {
|
|
266
|
+
// this.$router.back();
|
|
267
|
+
// } else {
|
|
268
|
+
// this.$emit("close");
|
|
269
|
+
// }
|
|
270
|
+
// console.warn("abTableDetail.close: ", this.isStandaloneRoute, this.$route?.name, this.$options.name);
|
|
271
|
+
},
|
|
272
|
+
toggle(v = false, d = undefined, r = false) {
|
|
273
|
+
return v ? this.open(d, r) : this.close();
|
|
274
|
+
},
|
|
275
|
+
async reload() {
|
|
276
|
+
if (typeof this.getHandler !== "function" || !this.currentValue[this.idField]) {
|
|
277
|
+
console.error("abTableDetail.reload: no getHandler or no idField!");
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
const res = await this.getHandler(this.currentValue[this.idField]);
|
|
281
|
+
this.open(res, this.currentReadonly);
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
};
|
|
285
|
+
</script>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as AbDetail } from "./ab-detail.vue";
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-drawer
|
|
3
|
+
:visible.sync="currentVisible"
|
|
4
|
+
:with-header="false"
|
|
5
|
+
:show-close="false"
|
|
6
|
+
append-to-body
|
|
7
|
+
close-on-click-modal
|
|
8
|
+
close-on-press-escape
|
|
9
|
+
destroy-on-close
|
|
10
|
+
:size="drawerSize"
|
|
11
|
+
>
|
|
12
|
+
<slot />
|
|
13
|
+
</el-drawer>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script>
|
|
17
|
+
export default {
|
|
18
|
+
name: "AbDrawer",
|
|
19
|
+
model: {
|
|
20
|
+
prop: "visible",
|
|
21
|
+
event: "update:visible",
|
|
22
|
+
},
|
|
23
|
+
props: {
|
|
24
|
+
visible: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: false,
|
|
27
|
+
},
|
|
28
|
+
detailLevel: {
|
|
29
|
+
type: Number,
|
|
30
|
+
default: 1,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
computed: {
|
|
34
|
+
currentVisible: {
|
|
35
|
+
get() {
|
|
36
|
+
return this.visible;
|
|
37
|
+
},
|
|
38
|
+
set(val) {
|
|
39
|
+
this.$emit("update:visible", val);
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
drawerSize() {
|
|
43
|
+
if (this.detailLevel && this.detailLevel < 5) {
|
|
44
|
+
return `${100 - 24 - this.detailLevel * 8}%`;
|
|
45
|
+
}
|
|
46
|
+
return "32%";
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
</script>
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<span class="ab-icon" :style="wrapperStyle">
|
|
3
|
+
<svg v-if="isLocal" :class="svgClassNames" aria-hidden="true">
|
|
4
|
+
<use :xlink:href="symbolId" />
|
|
5
|
+
</svg>
|
|
6
|
+
<span v-else ref="elRef" :class="svgClassNames" :data-icon="symbolId"></span>
|
|
7
|
+
</span>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script>
|
|
11
|
+
import Iconify from "@purge-icons/generated";
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
name: "AbIcon",
|
|
15
|
+
props: {
|
|
16
|
+
// icon name
|
|
17
|
+
icon: { type: String, default: undefined },
|
|
18
|
+
// icon color
|
|
19
|
+
color: { type: String, default: undefined },
|
|
20
|
+
// icon size
|
|
21
|
+
size: { type: Number, default: 16 },
|
|
22
|
+
// icon svg class
|
|
23
|
+
svgClass: { type: String, default: undefined },
|
|
24
|
+
},
|
|
25
|
+
computed: {
|
|
26
|
+
isLocal() {
|
|
27
|
+
return !!(this.icon && this.icon.startsWith("svg-icon:"));
|
|
28
|
+
},
|
|
29
|
+
symbolId() {
|
|
30
|
+
return this.isLocal ? `#icon-${this.icon.split("svg-icon:")[1]}` : this.icon;
|
|
31
|
+
},
|
|
32
|
+
svgClassNames() {
|
|
33
|
+
return `iconify ${this.svgClass || ""}`.trim();
|
|
34
|
+
},
|
|
35
|
+
wrapperStyle() {
|
|
36
|
+
return {
|
|
37
|
+
fontSize: `${this.size}px`,
|
|
38
|
+
height: "1em",
|
|
39
|
+
color: this.color,
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
watch: {
|
|
44
|
+
icon(icon) {
|
|
45
|
+
this.updateIcon(icon);
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
mounted() {
|
|
49
|
+
this.updateIcon(this.icon);
|
|
50
|
+
},
|
|
51
|
+
methods: {
|
|
52
|
+
async updateIcon(icon) {
|
|
53
|
+
if (this.isLocal || typeof document === "undefined") return;
|
|
54
|
+
|
|
55
|
+
const el = this.$refs.elRef;
|
|
56
|
+
if (!el) return;
|
|
57
|
+
|
|
58
|
+
await this.$nextTick();
|
|
59
|
+
|
|
60
|
+
if (!icon) return;
|
|
61
|
+
|
|
62
|
+
const svg = Iconify && typeof Iconify.renderSVG === "function" ? Iconify.renderSVG(icon, {}) : null;
|
|
63
|
+
if (svg) {
|
|
64
|
+
el.textContent = "";
|
|
65
|
+
el.appendChild(svg);
|
|
66
|
+
} else {
|
|
67
|
+
const span = document.createElement("span");
|
|
68
|
+
span.className = "iconify";
|
|
69
|
+
span.dataset.icon = icon;
|
|
70
|
+
el.textContent = "";
|
|
71
|
+
el.appendChild(span);
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
</script>
|
|
77
|
+
|
|
78
|
+
<style>
|
|
79
|
+
.ab-icon {
|
|
80
|
+
display: inline-flex;
|
|
81
|
+
align-items: center;
|
|
82
|
+
justify-content: center;
|
|
83
|
+
line-height: 1;
|
|
84
|
+
vertical-align: middle;
|
|
85
|
+
}
|
|
86
|
+
.ab-icon svg {
|
|
87
|
+
width: 1em;
|
|
88
|
+
height: 1em;
|
|
89
|
+
}
|
|
90
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as AbIcon } from "./ab-icon.vue";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-input
|
|
3
|
+
ref="el"
|
|
4
|
+
class="ab-input-number"
|
|
5
|
+
type="number"
|
|
6
|
+
v-bind="$attrs"
|
|
7
|
+
:value="displayValue"
|
|
8
|
+
:size="size"
|
|
9
|
+
:disabled="disabled"
|
|
10
|
+
:readonly="readonly"
|
|
11
|
+
:placeholder="placeholder"
|
|
12
|
+
@input="handleInput"
|
|
13
|
+
>
|
|
14
|
+
<span v-if="prefix" slot="prefix" class="ab-input-number__prefix">{{ prefix }}</span>
|
|
15
|
+
<span v-if="suffix" slot="suffix" class="ab-input-number__suffix">{{ suffix }}</span>
|
|
16
|
+
</el-input>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script>
|
|
20
|
+
export default {
|
|
21
|
+
name: "AbInputNumber",
|
|
22
|
+
inheritAttrs: false,
|
|
23
|
+
props: {
|
|
24
|
+
value: { type: [String, Number], default: undefined },
|
|
25
|
+
prefix: { type: String, default: undefined },
|
|
26
|
+
suffix: { type: String, default: undefined },
|
|
27
|
+
size: { type: String, default: undefined },
|
|
28
|
+
disabled: Boolean,
|
|
29
|
+
readonly: Boolean,
|
|
30
|
+
placeholder: String,
|
|
31
|
+
abFormInject: { type: Object, default: undefined },
|
|
32
|
+
},
|
|
33
|
+
computed: {
|
|
34
|
+
displayValue() {
|
|
35
|
+
return this.value === null || this.value === undefined ? "" : this.value;
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
methods: {
|
|
39
|
+
handleInput(value) {
|
|
40
|
+
if (value === "" || value === null || value === undefined) {
|
|
41
|
+
this.$emit("input", undefined);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const number = Number(value);
|
|
45
|
+
this.$emit("input", Number.isNaN(number) ? undefined : number);
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
</script>
|