|
|
@ -1,15 +1,38 @@ |
|
|
|
<script setup lang="ts"> |
|
|
|
import { getPointList } from 'apis/point' |
|
|
|
import FtButton from 'components/common/FTButton/index.vue' |
|
|
|
import Edit from 'components/point/Edit/index.vue' |
|
|
|
import { cloneDeep } from 'lodash' |
|
|
|
import { h, provide, ref } from 'vue' |
|
|
|
import { provide, ref, useTemplateRef } from 'vue' |
|
|
|
|
|
|
|
const upDataVisible = ref(false) |
|
|
|
const currentData = ref<Point.Point>() |
|
|
|
provide('currentData', currentData) |
|
|
|
|
|
|
|
const edit = (data: Point.Point[]) => { |
|
|
|
currentData.value = data[0] |
|
|
|
upDataVisible.value = true |
|
|
|
} |
|
|
|
|
|
|
|
const tableRef = useTemplateRef('tableRef') |
|
|
|
const ok = () => { |
|
|
|
tableRef.value?.initData() |
|
|
|
cancel() |
|
|
|
} |
|
|
|
const cancel = () => { |
|
|
|
upDataVisible.value = false |
|
|
|
} |
|
|
|
const btnList = [ |
|
|
|
{ |
|
|
|
name: '编辑', |
|
|
|
type: 'primary', |
|
|
|
serverUrl: 'edit', |
|
|
|
serverCondition: 1, |
|
|
|
}, |
|
|
|
] |
|
|
|
const columns = [ |
|
|
|
{ |
|
|
|
type: 'selection', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '名称', |
|
|
|
key: 'name', |
|
|
|
}, |
|
|
@ -21,32 +44,13 @@ const columns = [ |
|
|
|
title: '坐标', |
|
|
|
key: 'position', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '操作', |
|
|
|
fixed: 'right', |
|
|
|
width: 120, |
|
|
|
render: (row: any) => { |
|
|
|
return h( |
|
|
|
FtButton, |
|
|
|
{ |
|
|
|
class: ['table-cell-mouse-on'], |
|
|
|
id: row.id, |
|
|
|
onClick: () => { |
|
|
|
upDataVisible.value = true |
|
|
|
currentData.value = cloneDeep(row) |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ default: () => '编辑' }, |
|
|
|
) |
|
|
|
}, |
|
|
|
}, |
|
|
|
] |
|
|
|
</script> |
|
|
|
|
|
|
|
<template> |
|
|
|
<div> |
|
|
|
<FtTable :columns="columns" :get-data-fn="getPointList" /> |
|
|
|
<Edit v-if="upDataVisible" @ok="upDataVisible = false" @cancel="upDataVisible = false" /> |
|
|
|
<FtTable ref="tableRef" :columns="columns" has-header :btn-list="btnList" :get-data-fn="getPointList" @edit="edit" /> |
|
|
|
<Edit v-if="upDataVisible" @ok="ok" @cancel="cancel" /> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
|
|
|
|