@xilonglab/vue-main 0.8.7 → 0.8.9

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xilonglab/vue-main",
3
- "version": "0.8.7",
3
+ "version": "0.8.9",
4
4
  "description": "xilong vue main",
5
5
  "main": "packages/index.js",
6
6
  "scripts": {
@@ -37,7 +37,7 @@ const onConfirm = async () => {
37
37
  if (validation) {
38
38
  emits('confirm');
39
39
  const code = await props.callback()
40
- if (code) {
40
+ if (!code) {
41
41
  hide();
42
42
  emits('finish');
43
43
  }
package/packages/index.js CHANGED
@@ -32,25 +32,25 @@ import XlTextarea from './form/XlTextarea.vue'
32
32
  import XlTime from './form/XlTime.vue'
33
33
 
34
34
  // Dialog Components
35
- import XlDialog from './dialog/XlDialog.vue'
36
- import XlFormDialog from './dialog/XlFormDialog.vue'
37
- import XlStateDialog from './dialog/XlStateDialog.vue'
38
- import XlEditReviewDialog from './dialog/XlEditReviewDialog.vue'
39
- import XlImagePreviewDialog from './dialog/XlImagePreviewDialog.vue'
40
- import XlMessageDialog from './dialog/XlMessageDialog.vue'
41
- import XlReviewDialog from './dialog/XlReviewDialog.vue'
35
+ // import XlDialog from './dialog/XlDialog.vue'
36
+ // import XlFormDialog from './dialog/XlFormDialog.vue'
37
+ // import XlStateDialog from './dialog/XlStateDialog.vue'
38
+ // import XlEditReviewDialog from './dialog/XlEditReviewDialog.vue'
39
+ // import XlImagePreviewDialog from './dialog/XlImagePreviewDialog.vue'
40
+ // import XlMessageDialog from './dialog/XlMessageDialog.vue'
41
+ // import XlReviewDialog from './dialog/XlReviewDialog.vue'
42
42
 
43
43
  // Main Components
44
- import XlDataView from './main/XlDataView.vue'
45
- import XlTableFormDialog from './main/XlTableFormDialog.vue'
46
- import XlNavBar from './main/XlNavBar.vue'
47
- import XlTabView from './main/XlTabView.vue'
48
- import XlToolBar from './main/XlToolBar.vue'
49
- import XlVerticalMenu from './main/XlVerticalMenu.vue'
50
- import XlStatusIndicator from './main/XlStatusIndicator.vue'
51
- import XlUpdateIndicator from './main/XlUpdateIndicator.vue'
52
- import XlAutoSaver from './main/XlAutoSaver.vue'
53
- import XlLoginForm from './main/XlLoginForm.vue'
44
+ // import XlDataView from './main/XlDataView.vue'
45
+ // import XlTableFormDialog from './main/XlTableFormDialog.vue'
46
+ // import XlNavBar from './main/XlNavBar.vue'
47
+ // import XlTabView from './main/XlTabView.vue'
48
+ // import XlToolBar from './main/XlToolBar.vue'
49
+ // import XlVerticalMenu from './main/XlVerticalMenu.vue'
50
+ // import XlStatusIndicator from './main/XlStatusIndicator.vue'
51
+ // import XlUpdateIndicator from './main/XlUpdateIndicator.vue'
52
+ // import XlAutoSaver from './main/XlAutoSaver.vue'
53
+ // import XlLoginForm from './main/XlLoginForm.vue'
54
54
 
55
55
  const components = [
56
56
  XlSideBar,
@@ -84,40 +84,53 @@ const components = [
84
84
  XlTextarea,
85
85
  XlTime,
86
86
  // Dialogs
87
- XlDialog,
88
- XlFormDialog,
89
- XlStateDialog,
90
- XlEditReviewDialog,
91
- XlImagePreviewDialog,
92
- XlMessageDialog,
93
- XlReviewDialog,
94
- // Main Components
95
- XlDataView,
96
- XlTableFormDialog,
97
- XlNavBar,
98
- XlTabView,
99
- XlToolBar,
100
- XlVerticalMenu,
101
- XlStatusIndicator,
102
- XlUpdateIndicator,
103
- XlAutoSaver,
104
- XlLoginForm
87
+ // XlDialog,
88
+ // XlFormDialog,
89
+ // XlStateDialog,
90
+ // XlEditReviewDialog,
91
+ // XlImagePreviewDialog,
92
+ // XlMessageDialog,
93
+ // XlReviewDialog,
94
+ // // Main Components
95
+ // XlDataView,
96
+ // XlTableFormDialog,
97
+ // XlNavBar,
98
+ // XlTabView,
99
+ // XlToolBar,
100
+ // XlVerticalMenu,
101
+ // XlStatusIndicator,
102
+ // XlUpdateIndicator,
103
+ // XlAutoSaver,
104
+ // XlLoginForm
105
105
  ];
106
106
 
107
- const install = (app) => {
108
- components.forEach((component) => {
109
- app.component(component.name, component);
110
- });
107
+ // const install = (app) => {
108
+ // components.forEach((component) => {
109
+ // app.component(component.name, component);
110
+ // });
111
+ // };
112
+
113
+ const imports = import.meta.globEager('./**/*.vue');
114
+ export default {
115
+ install(app) {
116
+ for (const path in imports) {
117
+ const component = imports[path];
118
+ const regex = /\.\/\w+\/(\w+)\.vue$/;
119
+ const match = path.match(regex);
120
+ const name = match ? match[1] : null;
121
+ app.component(name, component.default);
122
+ }
123
+ },
111
124
  };
112
125
 
113
- let componentsJson = {}
114
- components.forEach(component => {
115
- const componentName = component.name
116
- component.install = function (app) {
117
- app.component(componentName, component)
118
- }
119
- componentsJson[componentName] = component
120
- })
126
+ // let componentsJson = {}
127
+ // components.forEach(component => {
128
+ // const componentName = component.name
129
+ // component.install = function (app) {
130
+ // app.component(componentName, component)
131
+ // }
132
+ // componentsJson[componentName] = component
133
+ // })
121
134
 
122
135
 
123
136
  if (typeof window !== 'undefined' && window.Vue) {
@@ -126,5 +139,5 @@ if (typeof window !== 'undefined' && window.Vue) {
126
139
 
127
140
  export default {
128
141
  install,
129
- ...componentsJson
142
+ // ...componentsJson
130
143
  }
@@ -1,5 +1,5 @@
1
1
  <script setup>
2
- defineOptions({ name: "XlTableFormDialog" })
2
+ defineOptions({ name: "XlDataFormDialog" })
3
3
 
4
4
  import { ref, computed } from 'vue'
5
5
 
@@ -62,7 +62,7 @@ defineExpose({
62
62
 
63
63
 
64
64
  <template>
65
- <xl-dialog class="xl-edit-dialog" :ref="refs.dialog" :title="chinese" :width="width" :validate="validate"
65
+ <xl-dialog class="xl-data-form-dialog" :ref="refs.dialog" :title="chinese" :width="width" :validate="validate"
66
66
  :callback="callback" @finish="emits('finish')">
67
67
  <el-form :ref="refs.form" :model="obj" :rules="rules" :label-width="`${labelWidth}px`">
68
68
  <slot />
@@ -72,7 +72,7 @@ defineExpose({
72
72
 
73
73
 
74
74
  <style lang="less">
75
- .xl-edit-dialog {
75
+ .xl-data-form-dialog {
76
76
  .xl-form-item {
77
77
  width: 100% !important;
78
78
  }
@@ -0,0 +1,217 @@
1
+ <script setup>
2
+ defineOptions({ name: "XlDataReview" })
3
+
4
+ import { inject } from 'vue'
5
+
6
+ const props = defineProps({
7
+ selectable: {
8
+ type: Boolean,
9
+ default: false,
10
+ },
11
+ columns: {
12
+ type: Array,
13
+ default: () => [],
14
+ },
15
+ showSummary: {
16
+ type: Boolean,
17
+ default: true,
18
+ },
19
+ rowClick: {
20
+ type: Function,
21
+ default: () => { },
22
+ },
23
+ summaryMethod: {
24
+ type: Function,
25
+ },
26
+ showIndex: {
27
+ type: Boolean,
28
+ default: false,
29
+ },
30
+ disableAdd: {
31
+ type: Boolean,
32
+ default: false,
33
+ },
34
+ pagination: {
35
+ type: Object,
36
+ default() {
37
+ return {
38
+ pageNum: 1,
39
+ pageSize: 20,
40
+ total: 0,
41
+ };
42
+ },
43
+ },
44
+ spanMethod: {
45
+ type: Function,
46
+ default: () => { },
47
+ },
48
+ headerCellStyle: {
49
+ type: Function,
50
+ default: () => { },
51
+ },
52
+ rowClassName: {
53
+ type: Function,
54
+ default: () => { },
55
+ },
56
+ rowKey: {
57
+ type: Function,
58
+ default: () => { },
59
+ },
60
+ rowDblClick: {
61
+ type: Function,
62
+ default: () => { },
63
+ },
64
+ selectionChange: {
65
+ type: Function,
66
+ default: () => { },
67
+ },
68
+ layout: {
69
+ type: String,
70
+ default: 'prev, pager, next, jumper'
71
+ },
72
+ small: {
73
+ type: Boolean,
74
+ default: false
75
+ },
76
+ chinese: {
77
+ type: String,
78
+ default: ''
79
+ },
80
+ english: {},
81
+ type: {
82
+ type: String,
83
+ default: ''
84
+ },
85
+ width: {
86
+ default: 70
87
+ },
88
+ labelWidth: {
89
+ default: 90
90
+ },
91
+ passCallback: {
92
+ type: Function,
93
+ default: () => { },
94
+ },
95
+ rejectCallback: {
96
+ type: Function,
97
+ default: () => { },
98
+ },
99
+ });
100
+
101
+ const { refs, api, params, obj, chartOptions, total } = inject('injections')
102
+ </script>
103
+
104
+
105
+ <template>
106
+ <div :class="['xl-data-review', english]">
107
+ <xl-tool-bar :type="type" :table="refs.table" :params="params" @query="() => api.stat()">
108
+ <template #inputs>
109
+ <template v-for="col in columns" :key="col.prop">
110
+ <template v-if="col.search">
111
+ <component
112
+ :is="`xl-${col.search.type || 'input'}`"
113
+ :placeholder="col.label"
114
+ v-model="params[col.prop]"
115
+ v-bind="col.search || {}"
116
+ />
117
+ </template>
118
+ </template>
119
+ <slot name="inputs" />
120
+ </template>
121
+ <template #buttons>
122
+ <slot name="buttons" />
123
+ <el-button class="add-btn" v-if="!disableAdd" type="success" @click="() => api.onAdd()">新增</el-button>
124
+ </template>
125
+ </xl-tool-bar>
126
+ <xl-query-page-table v-show="params.view != 'chart'" :ref="refs.table" :api="api" :params="params"
127
+ v-bind="$props" :summary-method="summaryMethod?summaryMethod:()=>({0:total})" :sort-change="(data) => api.sort(data)">
128
+ <template v-for="col in columns" :key="col.prop">
129
+ <template v-if="!col.hidden">
130
+ <xl-datetime-col
131
+ v-if="col.type === 'datetime'"
132
+ :l="col.label"
133
+ :p="col.prop"
134
+ />
135
+ <xl-map-col
136
+ v-else-if="col.type === 'map'"
137
+ :l="col.label"
138
+ :p="col.prop"
139
+ :width="col.width"
140
+ :map="col.map"
141
+ />
142
+ <xl-status-col
143
+ v-else-if="col.type === 'status'"
144
+ :l="col.label"
145
+ :p="col.prop"
146
+ :map="col.map"
147
+ />
148
+ <xl-review-col
149
+ v-else-if="col.type === 'review'"
150
+ :l="col.label"
151
+ :p="col.prop"
152
+ />
153
+ <xl-clamp-col
154
+ v-else-if="col.type === 'clamp'"
155
+ :l="col.label"
156
+ :p="col.prop"
157
+ :width="col.width"
158
+ />
159
+ <xl-bool-col
160
+ v-else-if="col.type === 'bool'"
161
+ :l="col.label"
162
+ :p="col.prop"
163
+ :width="col.width"
164
+ />
165
+ <xl-col
166
+ v-else
167
+ :l="col.label"
168
+ :p="col.prop"
169
+ :width="col.width"
170
+ />
171
+ </template>
172
+ </template>
173
+ <slot name="columns" />
174
+ </xl-query-page-table>
175
+ <xl-chart v-show="params.view == 'chart'" :options="chartOptions" />
176
+ <xl-data-review-dialog
177
+ :ref="refs.editDialog"
178
+ :title="chinese"
179
+ :width="width"
180
+ :label-width="labelWidth"
181
+ :obj="obj"
182
+ :columns="columns"
183
+ :pass-callback="passCallback"
184
+ :reject-callback="rejectCallback"
185
+ >
186
+ <el-row>
187
+ <template v-for="col in columns" :key="col.prop">
188
+ <xl-form-col
189
+ v-if="col.form"
190
+ :span="col.form.span"
191
+ :l="col.label"
192
+ :p="col.prop"
193
+ >
194
+ <component
195
+ :is="`xl-${col.form.type || 'input'}`"
196
+ v-model="obj[col.prop]"
197
+ v-bind="col.form || {}"
198
+ />
199
+ </xl-form-col>
200
+ </template>
201
+ </el-row>
202
+ <slot name="items" />
203
+ </xl-data-review-dialog>
204
+ <slot name="others" />
205
+ <xl-message-dialog l="确认删除?" :ref="refs.deleteDialog" @confirm="() => api.delete()" />
206
+ </div>
207
+ </template>
208
+
209
+
210
+ <style lang="less">
211
+ .xl-data-review {
212
+ div.cell {
213
+ padding: 0 !important;
214
+
215
+ }
216
+ }
217
+ </style>
@@ -1,5 +1,5 @@
1
1
  <script setup>
2
- defineOptions({ name: "XlEditReviewDialog" })
2
+ defineOptions({ name: "XlDataReviewDialog" })
3
3
 
4
4
  import { ref, computed } from 'vue'
5
5
 
@@ -7,12 +7,12 @@ import { ref, computed } from 'vue'
7
7
  const emits = defineEmits(['confirm', 'pass', 'reject'])
8
8
 
9
9
  const props = defineProps({
10
- title: {},
10
+ chinese: {},
11
11
  width: {},
12
- data: {},
13
- ruleMap: {
12
+ obj: {},
13
+ columns: {
14
14
  default() {
15
- return {}
15
+ return []
16
16
  }
17
17
  },
18
18
  labelWidth: {
@@ -33,17 +33,21 @@ const refs = {
33
33
  form: ref(null),
34
34
  }
35
35
 
36
- function convertRuleMapToRules(ruleMap) {
37
- const rules = {};
38
-
39
- for (const key in ruleMap) {
40
- rules[key] = [{ required: true, message: `请输�?{ruleMap[key]}`, trigger: "blur" }];
36
+ const convertColumnsToRules = (columns) => {
37
+ const rules = {};
38
+ columns.forEach(col => {
39
+ if (col.form?.required) {
40
+ rules[col.prop] = [{
41
+ required: true,
42
+ message: `请输入${col.label}`,
43
+ trigger: "blur"
44
+ }];
41
45
  }
46
+ });
47
+ return rules;
48
+ };
42
49
 
43
- return rules;
44
- }
45
-
46
- const rules = computed(() => convertRuleMapToRules(props.ruleMap));
50
+ const rules = computed(() => convertColumnsToRules(props.columns));
47
51
 
48
52
  async function validate() {
49
53
  let flag = 0
@@ -62,10 +66,10 @@ defineExpose({
62
66
 
63
67
 
64
68
  <template>
65
- <xl-review-dialog class="xl-edit-review-dialog xl-dialog" :ref="refs.dialog" :title="title" :width="width"
69
+ <xl-review-dialog class="xl-data-review-dialog xl-dialog" :ref="refs.dialog" :title="chinese" :width="width"
66
70
  :validate="validate" :pass-callback="passCallback" :reject-callback="rejectCallback" @pass="emits('pass')"
67
71
  @reject="emits('reject')">
68
- <el-form :ref="refs.form" :model="data" :rules="rules" :label-width="`${labelWidth}px`">
72
+ <el-form :ref="refs.form" :model="obj" :rules="rules" :label-width="`${labelWidth}px`">
69
73
  <slot />
70
74
  </el-form>
71
75
  </xl-review-dialog>
@@ -73,7 +77,7 @@ defineExpose({
73
77
 
74
78
 
75
79
  <style lang="less">
76
- .xl-edit-review-dialog {
80
+ .xl-data-review-dialog {
77
81
  .xl-form-item {
78
82
  width: 100% !important;
79
83
  }
@@ -169,7 +169,7 @@ const { refs, api, params, obj, chartOptions, total } = inject('injections')
169
169
  <slot name="columns" />
170
170
  </xl-query-page-table>
171
171
  <xl-chart v-show="params.view == 'chart'" :options="chartOptions" />
172
- <xl-table-form-dialog
172
+ <xl-data-form-dialog
173
173
  :ref="refs.editDialog"
174
174
  :chinese="chinese"
175
175
  :width="width"
@@ -195,7 +195,7 @@ const { refs, api, params, obj, chartOptions, total } = inject('injections')
195
195
  </template>
196
196
  </el-row>
197
197
  <slot name="items" />
198
- </xl-table-form-dialog>
198
+ </xl-data-form-dialog>
199
199
  <slot name="others" />
200
200
  <xl-message-dialog l="确认删除?" :ref="refs.deleteDialog" @confirm="() => api.delete()" />
201
201
  </div>
File without changes