@tripup-company/element-ui-extended 0.0.1 → 0.0.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.
@@ -0,0 +1,137 @@
1
+ <template>
2
+ <el-form
3
+ ref="form"
4
+ :model="formLocal"
5
+ :rules="config.rules"
6
+ label-position="left"
7
+ label-width="140px"
8
+ >
9
+ <el-card class="m-b-20" shadow="always">
10
+ <div slot="header" class="clearfix">
11
+ <el-row type="flex" justify="space-between">
12
+ <el-col class="flex align-center justify-start" :span="6">
13
+ <h3 class="m-b-0">{{ formLocal.object }} view</h3>
14
+ </el-col>
15
+ <el-col class="flex align-center justify-end is-justify-end el-row--flex" :span="6">
16
+ <slot name="actions" />
17
+ <el-button
18
+ class="delete-icon pull-right"
19
+ icon="el-icon-delete"
20
+ size="mini"
21
+ @click="deleteModel"
22
+ />
23
+ </el-col>
24
+ </el-row>
25
+ </div>
26
+ <el-row :gutter="20">
27
+ <el-col
28
+ :lg="colResolutionLg.lg"
29
+ :md="colResolutionLg.md"
30
+ :sm="colResolutionLg.sm"
31
+ :xl="colResolutionLg.xl"
32
+ :xs="colResolutionLg.xs"
33
+ >
34
+ <part-form>
35
+ <edit-column
36
+ :data="formLocal"
37
+ :fields="config.formFields"
38
+ :errors="errors"
39
+ @save="updateValue"
40
+ />
41
+ </part-form>
42
+ </el-col>
43
+ </el-row>
44
+ </el-card>
45
+ </el-form>
46
+ </template>
47
+
48
+ <script>
49
+ import getResolution from '../../services/resolutions';
50
+ import { BaseModel } from '../../models/base-model';
51
+ import PartForm from '../PartForm';
52
+ import EditColumn from '../PartColumn/EditColumn';
53
+
54
+ export default {
55
+ name: 'UpdateForm',
56
+ components: { PartForm, EditColumn },
57
+ provide() {
58
+ const data = {};
59
+ ['loading'].forEach((key) => {
60
+ Object.defineProperty(data, key, {
61
+ enumerable: true,
62
+ get: () => this[key],
63
+ });
64
+ });
65
+ return {
66
+ data,
67
+ };
68
+ },
69
+ props: {
70
+ form: {
71
+ type: Object,
72
+ default: () => {
73
+ return new BaseModel();
74
+ },
75
+ },
76
+ config: {
77
+ type: Object,
78
+ default: () => {
79
+ return {
80
+ rules: null,
81
+ }
82
+ },
83
+ },
84
+ errors: {
85
+ type: Object,
86
+ default() {
87
+ return {};
88
+ },
89
+ },
90
+ },
91
+ data() {
92
+ return {
93
+ colResolutionLg: getResolution('fullResolution'),
94
+ };
95
+ },
96
+ computed: {
97
+ formLocal: {
98
+ get() {
99
+ return this.form;
100
+ },
101
+ set(value) {
102
+ this.$emit('update:form', this.form);
103
+ },
104
+ },
105
+ },
106
+ methods: {
107
+ updateValue(data) {
108
+ this.$refs['form'].validateField(data.field, (invalid) => {
109
+ if (!invalid) {
110
+ this.$refs['form'].clearValidate();
111
+ this.$emit('save:value', data);
112
+ } else {
113
+ this.$message.error('Validation error');
114
+ }
115
+ });
116
+ },
117
+ deleteModel(){
118
+ this.$confirm('This will permanently delete data. Continue?', 'Warning', {
119
+ confirmButtonText: 'OK',
120
+ cancelButtonText: 'Cancel',
121
+ type: 'warning',
122
+ }).then(() => {
123
+ this.$message({
124
+ type: 'success',
125
+ message: 'Delete completed',
126
+ });
127
+ this.$emit('delete:model');
128
+ }).catch(() => {
129
+ this.$message({
130
+ type: 'info',
131
+ message: 'Delete canceled',
132
+ });
133
+ });
134
+ },
135
+ },
136
+ };
137
+ </script>
@@ -1,22 +0,0 @@
1
- <template>
2
- <div>
3
- Hi {{ model.name }}
4
- </div>
5
- </template>
6
-
7
- <script>
8
- import { Article } from '@/types/article'
9
-
10
- export default {
11
- name: "Test",
12
- data() {
13
- return {
14
- model: new Article(),
15
- }
16
- }
17
- }
18
- </script>
19
-
20
- <style scoped>
21
-
22
- </style>