kouxiangtang 0.0.27-beta.1 → 0.0.27-beta.2
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/package.json +1 -1
- package/src/framework/DomainEdit.vue +14 -7
- package/src/framework/DomainNew.vue +5 -3
- package/src/framework/PageActions.vue +8 -1
- package/src/framework/RowActionFormEditor.vue +8 -2
- package/src/framework/RowActions.vue +10 -2
- package/src/framework/config-loader.js +14 -0
- package/src/framework/domain-config.js +8 -1
- package/src/framework/field/editor/FieldDisplay.vue +1 -1
- package/src/framework/field/tree-select/FieldEditor.vue +2 -2
- package/src/framework/rest-client.js +2 -3
package/package.json
CHANGED
|
@@ -67,13 +67,14 @@ const removable = ref(props.operations?.removable);
|
|
|
67
67
|
async function editItem() {
|
|
68
68
|
const formHook = props.settings.formHook;
|
|
69
69
|
const formBtnVisible = props.settings.btnVisible;
|
|
70
|
+
const restRepeat = props.settings.restRepeat;
|
|
70
71
|
const restApi = props.settings.rest;
|
|
71
72
|
|
|
72
73
|
const { data } = await restApi.getOne({
|
|
73
74
|
...props.row,
|
|
74
75
|
...routeQuery,
|
|
75
76
|
});
|
|
76
|
-
form.value = data;
|
|
77
|
+
form.value = { ...data, idempotentToken: await restRepeat() };
|
|
77
78
|
if (formHook.setupUpdate) {
|
|
78
79
|
form.value = formHook.setupUpdate(form.value);
|
|
79
80
|
}
|
|
@@ -81,6 +82,7 @@ async function editItem() {
|
|
|
81
82
|
if (formBtnVisible.showRemove) {
|
|
82
83
|
removable.value = formBtnVisible.showRemove(form.value);
|
|
83
84
|
}
|
|
85
|
+
|
|
84
86
|
showEditor.value = true;
|
|
85
87
|
}
|
|
86
88
|
|
|
@@ -102,22 +104,23 @@ function onSubmit(formData, callBack) {
|
|
|
102
104
|
dataTableStore.fireUpdated();
|
|
103
105
|
callBack();
|
|
104
106
|
})
|
|
105
|
-
.catch(() => {
|
|
107
|
+
.catch(async () => {
|
|
108
|
+
const restRepeat = props.settings.restRepeat;
|
|
109
|
+
form.value = { ...form.value, idempotentToken: await restRepeat() };
|
|
106
110
|
callBack();
|
|
107
111
|
});
|
|
108
112
|
return;
|
|
109
113
|
}
|
|
110
114
|
|
|
111
115
|
function onRemove() {
|
|
116
|
+
let formData = {
|
|
117
|
+
...form.value,
|
|
118
|
+
};
|
|
112
119
|
props.settings.rest
|
|
113
|
-
.remove(
|
|
114
|
-
...props.row,
|
|
115
|
-
...routeQuery,
|
|
116
|
-
})
|
|
120
|
+
.remove(formData)
|
|
117
121
|
.then(() => {
|
|
118
122
|
alert.show({ type: "success", message: "删除成功" });
|
|
119
123
|
showEditor.value = false;
|
|
120
|
-
console.log(props.isDetail);
|
|
121
124
|
if (props.isDetail) {
|
|
122
125
|
const routeList = routeHistoryStore.history;
|
|
123
126
|
routeList.forEach((item) => {
|
|
@@ -128,6 +131,10 @@ function onRemove() {
|
|
|
128
131
|
});
|
|
129
132
|
}
|
|
130
133
|
dataTableStore.fireRemoved();
|
|
134
|
+
})
|
|
135
|
+
.catch(async () => {
|
|
136
|
+
const restRepeat = props.settings.restRepeat;
|
|
137
|
+
form.value = { ...form.value, idempotentToken: await restRepeat() };
|
|
131
138
|
});
|
|
132
139
|
}
|
|
133
140
|
</script>
|
|
@@ -45,7 +45,7 @@ const creatable = computed(() => {
|
|
|
45
45
|
|
|
46
46
|
async function newItem() {
|
|
47
47
|
const formHook = props.settings.formHook;
|
|
48
|
-
|
|
48
|
+
const restRepeat = props.settings.restRepeat;
|
|
49
49
|
const defaultValues = props.settings.fields.reduce((cum, current) => {
|
|
50
50
|
cum[current.code] = current.default;
|
|
51
51
|
return cum;
|
|
@@ -54,7 +54,7 @@ async function newItem() {
|
|
|
54
54
|
if (formHook.setupCreate) {
|
|
55
55
|
form.value = formHook.setupCreate(form.value);
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
form.value = { ...form.value, idempotentToken: await restRepeat() };
|
|
58
58
|
showEditor.value = true;
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -77,7 +77,9 @@ function onSubmit(formData, callBack) {
|
|
|
77
77
|
dataTableStore.fireCreated();
|
|
78
78
|
callBack();
|
|
79
79
|
})
|
|
80
|
-
.catch(() => {
|
|
80
|
+
.catch(async () => {
|
|
81
|
+
const restRepeat = props.settings.restRepeat;
|
|
82
|
+
form.value = { ...form.value, idempotentToken: await restRepeat() };
|
|
81
83
|
callBack();
|
|
82
84
|
});
|
|
83
85
|
}
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
<el-button
|
|
12
12
|
v-else
|
|
13
13
|
:type="item.type"
|
|
14
|
+
:loading="isloading"
|
|
14
15
|
:disabled="!item.enable && !hasSelectedData"
|
|
15
16
|
@click="pageAction(item)"
|
|
16
17
|
>
|
|
@@ -40,9 +41,15 @@ const pageActions = shallowRef([]);
|
|
|
40
41
|
const hasSelectedData = computed(() => {
|
|
41
42
|
return props.tableDataSelect?.data?.length > 0;
|
|
42
43
|
});
|
|
44
|
+
const isloading = ref(false);
|
|
43
45
|
|
|
44
46
|
async function pageAction(item) {
|
|
45
|
-
|
|
47
|
+
isloading.value = true;
|
|
48
|
+
await item.action({
|
|
49
|
+
...props.tableDataSelect,
|
|
50
|
+
idempotentToken: await props.settings.restRepeat(),
|
|
51
|
+
});
|
|
52
|
+
isloading.value = false;
|
|
46
53
|
dataTableStore.fireUpdated();
|
|
47
54
|
}
|
|
48
55
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
v-model="showEditor"
|
|
7
7
|
:title="props.text"
|
|
8
8
|
:config="config"
|
|
9
|
-
:data="
|
|
9
|
+
:data="formData"
|
|
10
10
|
width="600px"
|
|
11
11
|
@submit="onFormSubmit"
|
|
12
12
|
/>
|
|
@@ -38,7 +38,12 @@ const props = defineProps({
|
|
|
38
38
|
type: String,
|
|
39
39
|
default: "primary",
|
|
40
40
|
},
|
|
41
|
+
restRepeat: {
|
|
42
|
+
type: Function,
|
|
43
|
+
default: () => "",
|
|
44
|
+
},
|
|
41
45
|
});
|
|
46
|
+
const formData = ref(props.row);
|
|
42
47
|
const showEditor = ref(false);
|
|
43
48
|
const config = defineDomain("simple", {
|
|
44
49
|
simple: true,
|
|
@@ -46,7 +51,8 @@ const config = defineDomain("simple", {
|
|
|
46
51
|
fields: props.fields,
|
|
47
52
|
});
|
|
48
53
|
|
|
49
|
-
function show() {
|
|
54
|
+
async function show() {
|
|
55
|
+
formData.value = { ...props.row, idempotentToken: await props.restRepeat() };
|
|
50
56
|
showEditor.value = true;
|
|
51
57
|
}
|
|
52
58
|
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
<el-button
|
|
10
10
|
v-else
|
|
11
11
|
:type="rowAction.type ? rowAction.type : 'primary'"
|
|
12
|
+
:loading="isloading"
|
|
12
13
|
@click="triggerRowAction(rowAction, props.row)"
|
|
13
14
|
>
|
|
14
15
|
{{ rowAction.name }}
|
|
@@ -37,14 +38,21 @@ const props = defineProps({
|
|
|
37
38
|
},
|
|
38
39
|
});
|
|
39
40
|
const rowActions = shallowRef([]);
|
|
41
|
+
const isloading = ref(false);
|
|
40
42
|
|
|
41
43
|
async function triggerRowAction(rowAction, row) {
|
|
44
|
+
isloading.value = true;
|
|
42
45
|
if (rowAction.path) {
|
|
46
|
+
isloading.value = false;
|
|
43
47
|
routeToRowLinkPath(rowAction, row);
|
|
44
48
|
return;
|
|
45
49
|
}
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
await rowAction.action({
|
|
51
|
+
...row,
|
|
52
|
+
...props.query,
|
|
53
|
+
idempotentToken: await props.settings.restRepeat(),
|
|
54
|
+
});
|
|
55
|
+
isloading.value = false;
|
|
48
56
|
dataTableStore.fireUpdated();
|
|
49
57
|
}
|
|
50
58
|
|
|
@@ -10,9 +10,13 @@ let domainConfigs = {};
|
|
|
10
10
|
export function setupAppConfig(_config) {
|
|
11
11
|
config = { ...config, ..._config };
|
|
12
12
|
domainConfigs = _config.domainConfigs;
|
|
13
|
+
console.log("setupAppConfig");
|
|
14
|
+
console.log(config);
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
export function setupDomainConfigLoader(domainConfigLoader) {
|
|
18
|
+
console.log("setupDomainConfigLoader");
|
|
19
|
+
console.log(domainConfigs);
|
|
16
20
|
Object.keys(domainConfigs).forEach((side) => {
|
|
17
21
|
const sideDomainConfigs = domainConfigs[side];
|
|
18
22
|
|
|
@@ -24,10 +28,20 @@ export function setupDomainConfigLoader(domainConfigLoader) {
|
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
export function getConfig() {
|
|
31
|
+
console.log("getConfig");
|
|
32
|
+
console.log(config);
|
|
33
|
+
return config;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function getAppConfig() {
|
|
37
|
+
console.log("getAppConfig");
|
|
38
|
+
console.log(config);
|
|
27
39
|
return config;
|
|
28
40
|
}
|
|
29
41
|
|
|
30
42
|
export function getDomainConfigs() {
|
|
43
|
+
console.log("getDomainConfigs");
|
|
44
|
+
console.log(domainConfigs);
|
|
31
45
|
return domainConfigs;
|
|
32
46
|
}
|
|
33
47
|
|
|
@@ -21,7 +21,6 @@ class DomainConfig {
|
|
|
21
21
|
this.showSubmit = _config.showSubmit || true;
|
|
22
22
|
this.removeConfirm = _config.removeConfirm;
|
|
23
23
|
this.showCreate = this.setupShowCreate(_config.showCreate);
|
|
24
|
-
|
|
25
24
|
this.hasMany = rawConfig.hasMany || [];
|
|
26
25
|
this.hasOne = rawConfig.hasOne || [];
|
|
27
26
|
this.formatName = this.createFormatName(rawConfig.formatName);
|
|
@@ -31,6 +30,7 @@ class DomainConfig {
|
|
|
31
30
|
this.actionsWidth = rawConfig.actionsWidth || 150;
|
|
32
31
|
this.formHook = rawConfig.form || {};
|
|
33
32
|
this.filterHook = rawConfig.filterForm || {};
|
|
33
|
+
this.restRepeat = this.restRepeat(rawConfig.restRepeat);
|
|
34
34
|
this.btnVisible = rawConfig.btnVisible || {};
|
|
35
35
|
this.operations = this.setupOperations();
|
|
36
36
|
}
|
|
@@ -119,6 +119,13 @@ class DomainConfig {
|
|
|
119
119
|
|
|
120
120
|
return () => true;
|
|
121
121
|
}
|
|
122
|
+
restRepeat(restRepeat) {
|
|
123
|
+
if (typeof restRepeat == "function") {
|
|
124
|
+
return (query) => restRepeat();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return () => "";
|
|
128
|
+
}
|
|
122
129
|
|
|
123
130
|
setupOperations(query) {
|
|
124
131
|
const ops = {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
:multiple="props.field.multiple"
|
|
9
9
|
:render-after-expand="false"
|
|
10
10
|
show-checkbox
|
|
11
|
-
check-on-click-node
|
|
11
|
+
:check-on-click-node="false"
|
|
12
12
|
:expand-on-click-node="false"
|
|
13
13
|
default-expand-all
|
|
14
14
|
highlight-current
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
remote
|
|
18
18
|
filterable
|
|
19
19
|
:remote-method="remoteSearch"
|
|
20
|
-
@
|
|
20
|
+
@check="change"
|
|
21
21
|
/>
|
|
22
22
|
</template>
|
|
23
23
|
|
|
@@ -66,7 +66,7 @@ export class Client {
|
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
return http.remove(`${this.side}/${this.resources}/${data.id}
|
|
69
|
+
return http.remove(`${this.side}/${this.resources}/${data.id}`, data);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
_restore(data) {
|
|
@@ -75,7 +75,7 @@ export class Client {
|
|
|
75
75
|
return;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
return http.put(`${this.side}/${this.resources}/${data.id}/restore
|
|
78
|
+
return http.put(`${this.side}/${this.resources}/${data.id}/restore`, data);
|
|
79
79
|
}
|
|
80
80
|
_enable(data) {
|
|
81
81
|
if (!this.operations.includes(REMOVE)) {
|
|
@@ -108,7 +108,6 @@ export class ReadOnlyClient {
|
|
|
108
108
|
return http.get(`${this.side}/${this.resources}/${data.id}`);
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
-
|
|
112
111
|
export default {
|
|
113
112
|
Client,
|
|
114
113
|
ReadOnlyClient,
|