[pricelist][chore] minor cleanup
This commit is contained in:
parent
8ecbddc6ca
commit
909275727a
|
@ -335,14 +335,9 @@ import MinPriceSetting from 'src/plugins/pricelist/components/MinPriceSetting.vu
|
||||||
import NewDrink from 'src/plugins/pricelist/components/CalculationTable/NewDrink.vue';
|
import NewDrink from 'src/plugins/pricelist/components/CalculationTable/NewDrink.vue';
|
||||||
import BuildManual from 'src/plugins/pricelist/components/CalculationTable/BuildManual.vue';
|
import BuildManual from 'src/plugins/pricelist/components/CalculationTable/BuildManual.vue';
|
||||||
import SearchInput from './SearchInput.vue';
|
import SearchInput from './SearchInput.vue';
|
||||||
import { filter } from '../utils/filter';
|
import { filter, Search } from '../utils/filter';
|
||||||
import { Notify } from 'quasar';
|
import { Notify } from 'quasar';
|
||||||
|
import { sort } from '../utils/sort';
|
||||||
function sort(a: string | number, b: string | number) {
|
|
||||||
if (a > b) return 1;
|
|
||||||
if (b > a) return -1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'CalculationTable',
|
name: 'CalculationTable',
|
||||||
|
@ -528,7 +523,7 @@ export default defineComponent({
|
||||||
updateDrink(drink);
|
updateDrink(drink);
|
||||||
}
|
}
|
||||||
|
|
||||||
const search = ref({
|
const search = ref<Search>({
|
||||||
value: '',
|
value: '',
|
||||||
key: '',
|
key: '',
|
||||||
label: '',
|
label: '',
|
||||||
|
|
|
@ -91,12 +91,8 @@ import { defineComponent, onBeforeMount, computed, ref } from 'vue';
|
||||||
import { usePricelistStore } from '../store';
|
import { usePricelistStore } from '../store';
|
||||||
import { useMainStore } from 'src/stores';
|
import { useMainStore } from 'src/stores';
|
||||||
import SearchInput from './SearchInput.vue';
|
import SearchInput from './SearchInput.vue';
|
||||||
import { filter } from '../utils/filter';
|
import { filter, Search } from '../utils/filter';
|
||||||
function sort(a: string | number, b: string | number) {
|
import { sort } from '../utils/sort';
|
||||||
if (a > b) return 1;
|
|
||||||
if (b > a) return -1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'Pricelist',
|
name: 'Pricelist',
|
||||||
components: { SearchInput },
|
components: { SearchInput },
|
||||||
|
@ -223,7 +219,7 @@ export default defineComponent({
|
||||||
});
|
});
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
const search = ref({ label: '', value: '', key: '' });
|
const search = ref<Search>({ label: '', value: '', key: '' });
|
||||||
|
|
||||||
return {
|
return {
|
||||||
columns_drinks,
|
columns_drinks,
|
||||||
|
|
|
@ -7,19 +7,16 @@
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, computed, PropType } from 'vue';
|
import { defineComponent, computed, PropType } from 'vue';
|
||||||
|
import { Search, Col } from '../utils/filter';
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'SearchInput',
|
name: 'SearchInput',
|
||||||
props: {
|
props: {
|
||||||
modelValue: {
|
modelValue: {
|
||||||
type: Object as PropType<{
|
type: Object as PropType<Search>,
|
||||||
value: string;
|
|
||||||
key: string | undefined;
|
|
||||||
label: string | undefined;
|
|
||||||
}>,
|
|
||||||
default: { value: '', key: undefined, label: '' },
|
default: { value: '', key: undefined, label: '' },
|
||||||
},
|
},
|
||||||
keys: {
|
keys: {
|
||||||
type: Object as PropType<Array<{ name: string; label: string }>>,
|
type: Object as PropType<Array<Col>>,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -51,7 +48,6 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
//emit('update:modelValue', {value: split[0], label: split[1], key: undefined})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -59,3 +55,4 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
a
|
||||||
|
|
|
@ -44,12 +44,8 @@ import { usePricelistStore } from 'src/plugins/pricelist/store';
|
||||||
import BuildManual from 'src/plugins/pricelist/components/CalculationTable/BuildManual.vue';
|
import BuildManual from 'src/plugins/pricelist/components/CalculationTable/BuildManual.vue';
|
||||||
import BuildManualVolume from '../components/BuildManual/BuildManualVolume.vue';
|
import BuildManualVolume from '../components/BuildManual/BuildManualVolume.vue';
|
||||||
import SearchInput from '../components/SearchInput.vue';
|
import SearchInput from '../components/SearchInput.vue';
|
||||||
import { filter } from '../utils/filter';
|
import { filter, Search } from '../utils/filter';
|
||||||
function sort(a: string | number, b: string | number) {
|
import { sort } from '../utils/sort';
|
||||||
if (a > b) return 1;
|
|
||||||
if (b > a) return -1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'Reciepts',
|
name: 'Reciepts',
|
||||||
components: { BuildManual, BuildManualVolume, SearchInput },
|
components: { BuildManual, BuildManualVolume, SearchInput },
|
||||||
|
@ -123,7 +119,7 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const search = ref({ value: '', key: '', label: '' });
|
const search = ref<Search>({ value: '', key: '', label: '' });
|
||||||
|
|
||||||
return {
|
return {
|
||||||
drinks,
|
drinks,
|
||||||
|
|
|
@ -2,9 +2,9 @@ import { Drink } from '../store';
|
||||||
|
|
||||||
function filter(
|
function filter(
|
||||||
rows: Array<Drink>,
|
rows: Array<Drink>,
|
||||||
terms: { value: string; key: string },
|
terms: Search,
|
||||||
cols: Array<{ name: string; label: string; field: string }>,
|
cols: Array<Col>,
|
||||||
cellValue: { (col: { name: string; label: string; field: string }, row: Drink): string }
|
cellValue: { (col: Col, row: Drink): string }
|
||||||
) {
|
) {
|
||||||
if (terms.value) {
|
if (terms.value) {
|
||||||
return rows.filter((row) => {
|
return rows.filter((row) => {
|
||||||
|
@ -24,4 +24,16 @@ function filter(
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
export { filter };
|
interface Search {
|
||||||
|
value: string;
|
||||||
|
label: string | undefined;
|
||||||
|
key: string | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Col {
|
||||||
|
name: string;
|
||||||
|
label: string;
|
||||||
|
field: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export { filter, Search, Col };
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
function sort(a: string | number, b: string | number) {
|
||||||
|
if (a > b) return 1;
|
||||||
|
if (b > a) return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
export { sort };
|
Loading…
Reference in New Issue