Ver Fonte

添加复制

lrf há 1 ano atrás
pai
commit
6a839210b7
3 ficheiros alterados com 56 adições e 1 exclusões
  1. 5 0
      src/stores/counter.ts
  2. 1 1
      src/views/parts/form-1.vue
  3. 50 0
      src/views/parts/table-1.vue

+ 5 - 0
src/stores/counter.ts

@@ -115,6 +115,10 @@ export const useCounterStore = defineStore('counter', () => {
     const res = await axios.$post(`${tableApi.url}/exportTS`, data);
     return res.data;
   };
+  const copy = async (data: any): Promise<IQueryResult> => {
+    const res = await axios.$post(`${tableApi.url}/copy`, data);
+    return res;
+  };
   // #endregion
 
   return {
@@ -139,5 +143,6 @@ export const useCounterStore = defineStore('counter', () => {
     dirUpdate,
     dirDelete,
     getSchema,
+    copy,
   };
 });

+ 1 - 1
src/views/parts/form-1.vue

@@ -6,7 +6,7 @@
       <el-button class="button" @click="resetForm(formRef)">重置</el-button>
     </el-col>
     <el-col :span="24" class="form">
-      <el-form-item label="表名中文" prop="name">
+      <el-form-item label="表名中文" prop="name_zh">
         <el-input v-model="form.name_zh" />
       </el-form-item>
       <el-form-item label="表名" prop="name">

+ 50 - 0
src/views/parts/table-1.vue

@@ -25,6 +25,7 @@
             <el-button link type="success" @click.prevent="toMove(scope.row)" v-if="scope.row.type == 'table'">移动到</el-button>
             <el-button link type="warning" @click.prevent="toExport(scope.row)" v-if="scope.row.type == 'table'">导出</el-button>
             <el-button link type="warning" @click.prevent="toExportTs(scope.row)" v-if="scope.row.type == 'table'">导出ts</el-button>
+            <el-button link type="success" @click.prevent="toCopy(scope.row)" v-if="scope.row.type == 'table'">复制到</el-button>
             <el-button link type="danger" @click.prevent="toDel(scope.row)" v-if="scope.row.type == 'table'">删除</el-button>
           </template>
         </el-table-column>
@@ -41,6 +42,23 @@
       </el-form-item>
     </el-form>
   </el-dialog>
+  <el-dialog v-model="copyDialog" title="文件夹" :before-close="handleClose">
+    <el-form ref="copyFormRef" label-width="120px" :size="formSize" status-icon>
+      <el-form-item label="项目" prop="project">
+        <el-select v-model="copyForm.project" @change="searchDir">
+          <el-option v-for="i in projectList" :key="i._id" :label="i.name" :value="i._id"></el-option>
+        </el-select>
+      </el-form-item>
+      <el-form-item label="文件夹" prop="dir">
+        <el-select v-model="copyForm.dir">
+          <el-option v-for="i in dirList" :key="i._id" :label="i.name" :value="i._id"></el-option>
+        </el-select>
+      </el-form-item>
+      <el-form-item>
+        <el-button type="primary" @click="submitCopy()"> 提交 </el-button>
+      </el-form-item>
+    </el-form>
+  </el-dialog>
 </template>
 <script setup lang="ts">
 // #region 引入
@@ -118,6 +136,8 @@ const handleClose = () => {
   ruleForm.value = { _id: '', dir: '', project: '', super: '', name: '', sort: '', remark: '' };
   search();
   dialog.value = false;
+  copyDialog.value = false;
+  copyForm.value = {};
 };
 // #region 传到父组件方法
 const emit = defineEmits(['toEdit', 'toEditDir', 'toAddDir', 'toAddTab']);
@@ -217,6 +237,36 @@ const toExportTs = async (row: { _id: string }) => {
     }
   }
 };
+const copyDialog = ref(false);
+const copyForm: Ref<{ _id?: string; project?: string; dir?: string }> = ref({});
+const copyFormRef = ref<FormInstance>();
+interface baseType {
+  _id: string;
+  name: string;
+}
+const projectList: Ref<Array<baseType>> = ref([]);
+const dirList: Ref<Array<baseType>> = ref([]);
+const toCopy = async (row: { _id: string }) => {
+  // 查询项目
+  const projectResult: IQueryResult = await store.projectQuery();
+  if (projectResult.errcode == 0) {
+    projectList.value = projectResult.data as Array<baseType>;
+  }
+  copyForm.value._id = row._id;
+  copyDialog.value = true;
+};
+const searchDir = async (id: string) => {
+  // 查询项目下的文件夹
+  const dirResult: IQueryResult = await store.dirQuery({ project: id });
+  if (dirResult.errcode == 0) {
+    dirList.value = dirResult.data as Array<baseType>;
+  }
+};
+const submitCopy = async () => {
+  const res: IQueryResult = await store.copy(copyForm.value);
+  console.log(res)
+  if (res.errcode == 0) handleClose();
+};
 // #endregion
 </script>