|
@@ -19,7 +19,7 @@
|
|
|
<template v-else>
|
|
|
<div class="form-item mt-8">
|
|
|
<label>从Excel导入</label>
|
|
|
- <div>
|
|
|
+ <div class="flex middle w-full">
|
|
|
<t-button
|
|
|
class="shrink-0"
|
|
|
style="width: 90px; height: 30px"
|
|
@@ -30,6 +30,8 @@
|
|
|
<a href="/data.xlsx" download class="ml-12 mt-4 nowrap">
|
|
|
下载Excel示例
|
|
|
</a>
|
|
|
+ <span class="flex-grow"></span>
|
|
|
+ <a class="ml-12 mt-4 nowrap" @click="showAddData()"> + 添加数据 </a>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -45,7 +47,7 @@
|
|
|
{{ row.type || 'string' }}
|
|
|
</template>
|
|
|
<template v-if="!modelValue.mode" #actions="{ row, rowIndex }">
|
|
|
- <t-icon name="edit" class="hover" @click="showAddData(row)" />
|
|
|
+ <t-icon name="edit" class="hover" @click="showAddData(row, rowIndex)" />
|
|
|
<t-icon
|
|
|
name="delete"
|
|
|
class="ml-12 hover"
|
|
@@ -163,10 +165,11 @@ const importDataset = async () => {
|
|
|
emit('change', modelValue);
|
|
|
};
|
|
|
|
|
|
-const showAddData = (row?: any) => {
|
|
|
+const showAddData = (row?: any, index?: number) => {
|
|
|
if (row) {
|
|
|
addDataDialog.header = '编辑数据';
|
|
|
- addDataDialog.data = row;
|
|
|
+ addDataDialog.data = JSON.parse(JSON.stringify(row));
|
|
|
+ addDataDialog.index = index;
|
|
|
} else {
|
|
|
addDataDialog.header = '添加数据';
|
|
|
addDataDialog.data = { type: 'string' };
|
|
@@ -180,12 +183,17 @@ const onOkAddData = () => {
|
|
|
MessagePlugin.error('请填写名称');
|
|
|
return;
|
|
|
}
|
|
|
- if (!addDataDialog.data.key) {
|
|
|
+ if (!addDataDialog.data.id) {
|
|
|
MessagePlugin.error('请填写数据ID');
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- modelValue.data.push(addDataDialog.data);
|
|
|
+ if (addDataDialog.header === '添加数据') {
|
|
|
+ modelValue.data.push(addDataDialog.data);
|
|
|
+ } else {
|
|
|
+ modelValue.data[addDataDialog.index] = addDataDialog.data;
|
|
|
+ }
|
|
|
+
|
|
|
addDataDialog.show = false;
|
|
|
};
|
|
|
</script>
|