vue-2024-ui 0.0.11 → 0.0.12
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/components/g-table.vue +27 -21
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<slot name="control-add">
|
|
13
13
|
<el-button v-bind="model.control.add" @click="addRow(model)">{{
|
|
14
14
|
model.control.add.label
|
|
15
|
-
|
|
15
|
+
}}</el-button>
|
|
16
16
|
</slot>
|
|
17
17
|
<slot name="control-add-right"></slot>
|
|
18
18
|
</div>
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
v-if="model.control.view.auth(row, column, $index)">
|
|
43
43
|
<el-button v-bind="model.control.view" @click="readForm(row, column, $index, model)">{{
|
|
44
44
|
model.control.view.label
|
|
45
|
-
|
|
45
|
+
}}</el-button>
|
|
46
46
|
</slot>
|
|
47
47
|
<slot name="control-edit-left" :row :column :$index> </slot>
|
|
48
48
|
<slot name="control-edit" :row :column :$index
|
|
49
49
|
v-if="model.control.edit.auth(row, column, $index)">
|
|
50
50
|
<el-button v-bind="model.control.edit" @click="editRow(row, column, $index, model)">{{
|
|
51
51
|
model.control.edit.label
|
|
52
|
-
|
|
52
|
+
}}</el-button>
|
|
53
53
|
</slot>
|
|
54
54
|
<slot name="control-edit-right" :row :column :$index> </slot>
|
|
55
55
|
<slot name="control-delete" :row :column :$index
|
|
@@ -154,13 +154,13 @@ defineOptions({
|
|
|
154
154
|
name: "g-table",
|
|
155
155
|
inheritAttrs: false
|
|
156
156
|
})
|
|
157
|
-
const emits = defineEmits(['load', '
|
|
157
|
+
const emits = defineEmits(['load', 'open', "delete", 'submit', 'reset']);
|
|
158
158
|
const model = defineModel({ required: true });
|
|
159
159
|
const options = inject('options');
|
|
160
160
|
const queryInfo = ref({});
|
|
161
161
|
const dialogVisible = ref(false);
|
|
162
162
|
const tableColumnsAttrs = ['type', 'index', 'label', 'column-key', 'prop', 'width', 'min-width', 'fixed', 'render-header', 'sortable', 'sort-method', 'sort-by', 'sort-orders', 'resizable', 'formatter', 'show-overflow-tooltip', 'align', 'header-align', 'class-name', 'label-class-name', 'selectable', 'reserve-selection', 'filters', 'filter-placement', 'filter-class-name', 'filter-multiple', 'filter-method', 'filtered-value'];
|
|
163
|
-
|
|
163
|
+
const modalState = ref(undefined);
|
|
164
164
|
//合并表格属性包括分页
|
|
165
165
|
const defaultTableAttrs = {
|
|
166
166
|
data: [],
|
|
@@ -287,7 +287,7 @@ model.value.dialog = mergeObjects(
|
|
|
287
287
|
|
|
288
288
|
//记录表单初始值
|
|
289
289
|
const initFormData = Object.fromEntries(Object.entries(filterObject(model.value, (k, val) => {
|
|
290
|
-
return (val.type != 'control' && val.
|
|
290
|
+
return (val.type != 'control' && val.editor !== false && val.type != 'hidden');
|
|
291
291
|
})).map(([key, val]) => [key, val.value]));
|
|
292
292
|
|
|
293
293
|
//扩展formatter方法
|
|
@@ -332,7 +332,7 @@ const formatterExtends = (item, str) => {
|
|
|
332
332
|
|
|
333
333
|
//重置查询初始值
|
|
334
334
|
const queryReset = (q) => {
|
|
335
|
-
console.log(q);
|
|
335
|
+
//console.log(q);
|
|
336
336
|
queryInfo.value = q.value;
|
|
337
337
|
}
|
|
338
338
|
|
|
@@ -343,17 +343,21 @@ const query = (q) => {
|
|
|
343
343
|
|
|
344
344
|
//新增方法
|
|
345
345
|
const addRow = (m) => {
|
|
346
|
-
|
|
347
|
-
model.value.
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
346
|
+
modalState.value = "add";
|
|
347
|
+
if (model.value.control.add?.click) {
|
|
348
|
+
model.value.control.add.click(m);
|
|
349
|
+
} else {
|
|
350
|
+
model.value.form.disabled = false;
|
|
351
|
+
model.value.dialog.mode = model.value.control.add.mode;
|
|
352
|
+
model.value.dialog.title = model.value.control.add.label;
|
|
353
|
+
emits("open", m, 'add');
|
|
354
|
+
Object.keys(initFormData).forEach(key => {
|
|
355
|
+
if (model.value[key]) {
|
|
356
|
+
model.value[key].value = initFormData[key];
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
dialogVisible.value = true;
|
|
360
|
+
}
|
|
357
361
|
};
|
|
358
362
|
|
|
359
363
|
//删除方法
|
|
@@ -375,13 +379,14 @@ const deleteRow = (row, column, $index, m) => {
|
|
|
375
379
|
|
|
376
380
|
//编辑方法
|
|
377
381
|
const editRow = (row, column, $index, m) => {
|
|
382
|
+
modalState.value = "edit";
|
|
378
383
|
if (model.value.control.edit?.click) {
|
|
379
384
|
model.value.control.edit.click(row, column, $index, m);
|
|
380
385
|
} else {
|
|
381
386
|
model.value.form.disabled = false;
|
|
382
387
|
model.value.dialog.mode = model.value.control.edit.mode;
|
|
383
388
|
model.value.dialog.title = model.value.control.edit.label;
|
|
384
|
-
emits("
|
|
389
|
+
emits("open", m, 'edit', row, column, $index);
|
|
385
390
|
Object.keys(row).forEach(key => {
|
|
386
391
|
if (model.value[key]) {
|
|
387
392
|
model.value[key].value = row[key];
|
|
@@ -393,13 +398,14 @@ const editRow = (row, column, $index, m) => {
|
|
|
393
398
|
|
|
394
399
|
//查看方法
|
|
395
400
|
const readForm = (row, column, $index, m) => {
|
|
401
|
+
modalState.value = undefined;
|
|
396
402
|
if (model.value.control.view?.click) {
|
|
397
403
|
model.value.control.view.click(row, column, $index, m);
|
|
398
404
|
} else {
|
|
399
405
|
model.value.form.disabled = true;
|
|
400
406
|
model.value.dialog.mode = model.value.control.view.mode;
|
|
401
407
|
model.value.dialog.title = model.value.control.view.label;
|
|
402
|
-
emits("
|
|
408
|
+
emits("open", m, 'view', row, column, $index);
|
|
403
409
|
Object.keys(row).forEach(key => {
|
|
404
410
|
if (model.value[key]) {
|
|
405
411
|
model.value[key].value = row[key];
|
|
@@ -411,7 +417,7 @@ const readForm = (row, column, $index, m) => {
|
|
|
411
417
|
|
|
412
418
|
//提交方法
|
|
413
419
|
const submit = (formInfo, model) => {
|
|
414
|
-
emits("submit", formInfo, model, (res) => {
|
|
420
|
+
emits("submit", modalState.value, formInfo, model, (res) => {
|
|
415
421
|
if (res) {
|
|
416
422
|
dialogVisible.value = false;
|
|
417
423
|
}
|