|
74 | 74 | </div>
|
75 | 75 | </template>
|
76 | 76 |
|
77 |
| -<script> |
| 77 | +<script setup> |
| 78 | +import { computed, ref } from 'vue' |
| 79 | +import { useStore } from 'vuex' |
78 | 80 | import { status, utils } from '../../../../src/jsonapi-vuex'
|
79 | 81 |
|
80 |
| -export default { |
81 |
| - name: 'JsonapiVuex', |
82 |
| - data: () => { |
83 |
| - return { |
84 |
| - searchResult: {}, |
85 |
| - delWidgetId: undefined, |
86 |
| - postWidget: { |
87 |
| - _jv: { |
88 |
| - type: 'widget', |
89 |
| - }, |
90 |
| - }, |
91 |
| - } |
92 |
| - }, |
93 |
| - computed: { |
94 |
| - sessions() { |
95 |
| - return status.status |
96 |
| - }, |
97 |
| - widgets() { |
98 |
| - return this.$store.getters['jv/get']('widget') |
99 |
| - }, |
100 |
| - widget1() { |
101 |
| - return utils.deepCopy(this.$store.getters['jv/get']('widget/1')) |
102 |
| - }, |
103 |
| - }, |
104 |
| - created() { |
105 |
| - status.run(() => this.$store.dispatch('jv/get', 'widget')) |
| 82 | +const store = useStore() |
106 | 83 |
|
107 |
| - status |
108 |
| - .run(() => this.$store.dispatch('jv/search', 'widget')) |
109 |
| - .then((res) => { |
110 |
| - this.searchResult = res |
111 |
| - }) |
112 |
| - }, |
113 |
| - methods: { |
114 |
| - patchRecord(record) { |
115 |
| - this.$store.dispatch('jv/patch', record) |
116 |
| - }, |
117 |
| - postRecord(record) { |
118 |
| - this.$store.dispatch('jv/post', record) |
119 |
| - }, |
120 |
| - deleteRecord(id) { |
121 |
| - this.$store.dispatch('jv/delete', 'widget' + '/' + id) |
122 |
| - }, |
| 84 | +let searchResult = ref({}) |
| 85 | +let delWidgetID = ref() |
| 86 | +let postWidget = ref({ |
| 87 | + _jv: { |
| 88 | + type: 'widget', |
123 | 89 | },
|
124 |
| -} |
| 90 | +}) |
| 91 | +
|
| 92 | +const sessions = computed(() => status.status ) |
| 93 | +const widgets = computed(() => store.getters['jv/get']('widget') ) |
| 94 | +const widget1 = computed(() => utils.deepCopy(store.getters['jv/get']('widget/1'))) |
| 95 | +
|
| 96 | +const patchRecord = ((record) => store.dispatch('jv/patch', record)) |
| 97 | +const postRecord = ((record) => store.dispatch('jv/post', record)) |
| 98 | +const deleteRecord = ((id) => store.dispatch('jv/delete', 'widget' + '/' + id)) |
| 99 | +
|
| 100 | +store.dispatch('jv/get', 'widget') |
| 101 | +store.dispatch('jv/search', 'widget') |
| 102 | + .then((res) => { |
| 103 | + this.searchResult = res |
| 104 | + }) |
125 | 105 | </script>
|
126 | 106 |
|
127 | 107 | <style scoped></style>
|
0 commit comments