Untitled
unknown
plain_text
2 months ago
2.4 kB
5
Indexable
import { ref, reactive, computed } from 'vue'
import { defineStore } from 'pinia'
import { shallowRef } from 'vue'
export const productStore = defineStore('counter', () => {
const count = ref(0)
const doubleCount = computed(() => count.value * 2)
function increment() {
count.value++
}
const dialog = shallowRef(false)
let productData = ref([
{
id: 1,
category: 'Canned',
name: 'Ligo',
url: '',
description: '',
price: 0,
qty: 0,
remarks: '',
},
{
id: 2,
category: 'Vegetables',
name: 'Okra',
url: '',
description: '',
price: 0,
qty: 0,
remarks: '',
},
{
id: 3,
category: 'Fruits',
name: 'Mangga',
url: '',
price: 0,
qty: 0,
remarks: '',
},
{
id: 4,
category: 'Seasons',
name: 'Ginisa Mix',
url: '',
description: '',
price: 0,
qty: 0,
remarks: '',
},
{
id: 5,
category: 'Froze',
name: 'Skinless',
url: '',
description: '',
price: 0,
qty: 0,
remarks: '',
},
{
id: 6,
category: 'Utensils',
name: 'Sandok',
url: '',
description: '',
price: 0,
qty: 0,
remarks: '',
},
])
let headers = ref([
{ title: 'ID', value: 'id' },
{ title: 'Category', value: 'category' },
{ title: 'Name', value: 'name' },
{ title: 'Image', value: 'url' },
{ title: 'Description', value: 'description' },
{ title: 'Price', value: 'price' },
{ title: 'Quantity', value: 'qty' },
{ title: 'Remarks', value: 'remarks' },
{ title: 'Actions', value: 'actions' },
])
let rules = ref([
(v) => !!v || 'Id required',
(v) => !!v || 'Category required',
(v) => !!v || 'Name required',
(v) => !!v || 'Image required',
(v) => !!v || 'Description required',
(v) => !!v || 'Benefits required',
(v) => !!v || 'Variant required',
(v) => !!v || 'Kind required',
(v) => !!v || 'Price required',
(v) => !!v || 'Quantity required',
(v) => !!v || 'Remark required',
])
return {
//global variables
dialog,
count,
doubleCount,
productData,
headers,
rules,
//Global functions
increment,
}
})
Editor is loading...
Leave a Comment