diff --git a/bun.lockb b/bun.lockb index 18e31b0..5066d39 100644 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 4fad96e..beb6b3f 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "pinia": "^2.2.2", "radash": "^12.1.0", "vue": "^3.5.7", + "vue-draggable-plus": "^0.5.3", "vue-i18n": "^10.0.1", "vue-router": "^4.4.5" }, diff --git a/src/components/ModularFactoryDrawerContent.tsx b/src/components/ModularFactoryDrawerContent.tsx index 247d001..506575a 100644 --- a/src/components/ModularFactoryDrawerContent.tsx +++ b/src/components/ModularFactoryDrawerContent.tsx @@ -28,6 +28,9 @@ import ItemQuantityPerMinuteDisplay from './ItemQuantityPerMinuteDisplay' import ItemRecipeSelect from './ItemRecipeSelect' import ItemSelect from './ItemSelect' import PowerDisplay from './PowerDisplay' +import VueDraggableExt from './VueDraggableExt.vue' +import AddOutlined from './icons/AddOutlined' +import DragHandleOutlined from './icons/DragHandleOutlined' const ItemQuantityPerMinuteDisplayList = defineComponent({ name: 'ItemQuantityPerMinuteDisplayList', @@ -87,6 +90,14 @@ export default defineComponent({ }) const columns = computed>(() => [ + { + title: t('sort'), + key: 'sort', + width: 60, + render: () => ( + + ), + }, { title: t('targetItem'), key: 'targetItem', @@ -282,15 +293,36 @@ export default defineComponent({ modularFactoryStore.newAssemblyLine(modularFactory.value.id) }} > - {t('newAssemblyLine')} + {{ + icon: () => , + default: () => t('newAssemblyLine'), + }} - id} - columns={columns.value} - data={modularFactory.value.data} - /> + {modularFactory.value.data.length > 0 ? ( + { + modularFactory.value.data = value + }} + target=".n-data-table-tbody" + handle=".sort-handle" + animation={150} + > + id} + columns={columns.value} + data={modularFactory.value.data} + /> + + ) : ( + id} + columns={columns.value} + data={modularFactory.value.data} + /> + )} {modularFactoryComputed.value?.averageTotalPowerUsage && ( diff --git a/src/components/VueDraggableExt.vue b/src/components/VueDraggableExt.vue new file mode 100644 index 0000000..800bbe2 --- /dev/null +++ b/src/components/VueDraggableExt.vue @@ -0,0 +1,25 @@ + + + diff --git a/src/components/icons/AddOutlined.tsx b/src/components/icons/AddOutlined.tsx new file mode 100644 index 0000000..c75ce1d --- /dev/null +++ b/src/components/icons/AddOutlined.tsx @@ -0,0 +1,19 @@ +import { defineComponent } from 'vue' + +export default defineComponent({ + name: 'AddOutlined', + setup() { + return () => ( + + + + ) + }, +}) diff --git a/src/components/icons/DragHandleOutlined.tsx b/src/components/icons/DragHandleOutlined.tsx new file mode 100644 index 0000000..67be82e --- /dev/null +++ b/src/components/icons/DragHandleOutlined.tsx @@ -0,0 +1,16 @@ +import { defineComponent } from 'vue' + +export default defineComponent({ + name: 'DragHandleOutlined', + setup() { + return () => ( + + + + ) + }, +}) diff --git a/src/locales/en.yml b/src/locales/en.yml index 238cd9e..d53243a 100644 --- a/src/locales/en.yml +++ b/src/locales/en.yml @@ -13,6 +13,7 @@ globalConfig: Global Config clearAllData: Clear All Data clearAllDataConfirm: Are you sure you want to clear all data? +sort: Sort name: Name remark: Remark power: Power diff --git a/src/locales/zh-CN.yml b/src/locales/zh-CN.yml index dae0d8f..1d011b7 100644 --- a/src/locales/zh-CN.yml +++ b/src/locales/zh-CN.yml @@ -13,6 +13,7 @@ globalConfig: 全局配置 clearAllData: 清空全部数据 clearAllDataConfirm: 确定清空全部数据吗? +sort: 排序 name: 名称 remark: 备注 power: 功率 diff --git a/src/views/HomeView.tsx b/src/views/HomeView.tsx index 4863d80..58d125d 100644 --- a/src/views/HomeView.tsx +++ b/src/views/HomeView.tsx @@ -19,6 +19,9 @@ import ModularFactoryDrawer, { type Exposed as ModularFactoryDrawerExposed, } from '@/components/ModularFactoryDrawer' import PowerDisplay from '@/components/PowerDisplay' +import VueDraggableExt from '@/components/VueDraggableExt.vue' +import AddOutlined from '@/components/icons/AddOutlined' +import DragHandleOutlined from '@/components/icons/DragHandleOutlined' import { useModularFactoryComputedStore } from '@/stores/modularFactoryComputedStore' import { useModularFactoryStore } from '@/stores/modularFactoryStore' import type { Id, ModularFactory } from '@/types' @@ -71,23 +74,28 @@ export default defineComponent({ const columns = computed>(() => { return [ + { + title: t('sort'), + key: 'sort', + width: 60, + render: () => ( + + ), + }, { title: t('name'), key: 'name', minWidth: 160, - width: 240, }, { title: t('remark'), key: 'remark', minWidth: 240, - width: 320, }, { title: t('power'), key: 'power', minWidth: 120, - width: 160, render: (row) => { const modularFactoryComputed = modularFactoryComputedStore.data[row.id] @@ -116,7 +124,6 @@ export default defineComponent({ title: t('inputs'), key: 'inputs', minWidth: 120, - width: 160, render: (row) => ( ( - {t('newFactory')} + {{ + icon: () => , + default: () => t('newFactory'), + }} {t('globalConfig')} @@ -210,11 +219,29 @@ export default defineComponent({ - id} - columns={columns.value} - data={modularFactoryStore.data} - /> + {modularFactoryStore.data.length > 0 ? ( + { + modularFactoryStore.data = value + }} + target=".n-data-table-tbody" + handle=".sort-handle" + animation={150} + > + id} + columns={columns.value} + data={modularFactoryStore.data} + /> + + ) : ( + id} + columns={columns.value} + data={modularFactoryStore.data} + /> + )} {modularFactoryComputedStore.finalComputed ?.averageTotalPowerUsage && (