40 lines
765 B
JavaScript
40 lines
765 B
JavaScript
|
|
import { defineStore } from 'pinia'
|
||
|
|
import { ref } from "vue";
|
||
|
|
|
||
|
|
export const useDispatchScanCodeStore = defineStore('dispatchScanCode', () => {
|
||
|
|
const code = ref([]);
|
||
|
|
|
||
|
|
const addCode = (data) => {
|
||
|
|
code.value.push(data);
|
||
|
|
}
|
||
|
|
|
||
|
|
const clearCode = () => {
|
||
|
|
code.value = [];
|
||
|
|
}
|
||
|
|
|
||
|
|
const delCode = (value) => {
|
||
|
|
const index = code.value.indexOf(value);
|
||
|
|
if (index !== -1) {
|
||
|
|
code.value.splice(index, 1);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
const checkCode = (value) => {
|
||
|
|
return code.value.includes(value);
|
||
|
|
}
|
||
|
|
|
||
|
|
const getCode = () => {
|
||
|
|
return code.value;
|
||
|
|
}
|
||
|
|
|
||
|
|
return {
|
||
|
|
code,
|
||
|
|
checkCode,
|
||
|
|
getCode,
|
||
|
|
clearCode,
|
||
|
|
delCode,
|
||
|
|
addCode
|
||
|
|
};
|
||
|
|
}, {
|
||
|
|
persist: true
|
||
|
|
})
|