|
|
@@ -1,138 +1,191 @@
|
|
|
<template>
|
|
|
- <el-dialog v-model="addFile" title="新建文件" width="30%" @close="backTo">
|
|
|
- <el-form :model="createFile">
|
|
|
- <el-form-item label="文件目录">
|
|
|
+ <el-dialog v-model="addFile" title="新建文件" width="30%" @close="backTo">
|
|
|
+ <el-form
|
|
|
+ :model="createFile"
|
|
|
+ :label-position="labelPosition"
|
|
|
+ label-width="80px"
|
|
|
+ ref="labelRef"
|
|
|
+ :rules="rules"
|
|
|
+ >
|
|
|
+ <!-- <el-form-item label="文件目录">
|
|
|
<el-tree :data="treeData" :props="defaultProps" @node-click="handleNodeClick" />
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="你选择的目录是">
|
|
|
- <p>{{ nowFolder }}</p>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="文件名">
|
|
|
+ </el-form-item> -->
|
|
|
+ <el-form-item label="目录" class="title-name">
|
|
|
+ <!-- <p>{{ nowFolder }}</p> -->
|
|
|
+ <span>{{ clickFileData.dirName }}</span>
|
|
|
+ </el-form-item>
|
|
|
+ <!-- <el-form-item label="文件名">
|
|
|
<el-input v-model="createFile.name" maxlength="150" placeholder="请输入文件名" type="textarea" />
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="文件类型">
|
|
|
- <el-select v-model="createFile.fileType" clearable placeholder="Select" @change="optChange">
|
|
|
- <el-option v-for="item in typeF" :key="item.value" :label="item.label" :value="item.value" />
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
- </el-form>
|
|
|
- <template #footer>
|
|
|
- <span class="dialog-footer">
|
|
|
- <el-button @click="back">取消</el-button>
|
|
|
- <el-button type="primary" @click="sureAddFile">
|
|
|
- 确定
|
|
|
- </el-button>
|
|
|
- </span>
|
|
|
- </template>
|
|
|
- </el-dialog>
|
|
|
+ </el-form-item> -->
|
|
|
+ <el-form-item
|
|
|
+ label="文件类型"
|
|
|
+ prop="fileType"
|
|
|
+ >
|
|
|
+ <el-select
|
|
|
+ v-model="createFile.fileType"
|
|
|
+ clearable
|
|
|
+ placeholder="Select"
|
|
|
+ @change="optChange"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in typeF"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <template #footer>
|
|
|
+ <span class="dialog-footer">
|
|
|
+ <el-button @click="back">取消</el-button>
|
|
|
+ <el-button type="primary" @click="sureAddFile"> 确定 </el-button>
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { ref, onMounted, toRef } from 'vue'
|
|
|
-import fileCount from "../../../api/fileCount/fileCount"
|
|
|
-import documents from '../../../api/document/document';
|
|
|
-import { ElMessage } from 'element-plus'
|
|
|
+import { ref, onMounted, toRef } from "vue";
|
|
|
+import fileCount from "../../../api/fileCount/fileCount";
|
|
|
+import documents from "../../../api/document/document";
|
|
|
+import { ElMessage } from "element-plus";
|
|
|
export default {
|
|
|
- props: {
|
|
|
- newAdd: {
|
|
|
- type: Boolean,
|
|
|
- required: true
|
|
|
- }
|
|
|
+ props: {
|
|
|
+ newAdd: {
|
|
|
+ type: Boolean,
|
|
|
+ required: true,
|
|
|
},
|
|
|
- setup(props, { emit }) {
|
|
|
- let { sureAddFile, back } = toRef(props)
|
|
|
- let result = props.newAdd
|
|
|
- let createFile = ref({
|
|
|
- name: "",
|
|
|
- fileType: ""
|
|
|
- })
|
|
|
- let treeData = ref([])
|
|
|
- let defaultProps = ref({
|
|
|
- label: "label",
|
|
|
- value: "id",
|
|
|
- disable: false
|
|
|
- })
|
|
|
- let typeF = ref([
|
|
|
- {
|
|
|
- label: "word",
|
|
|
- value: "word"
|
|
|
- },
|
|
|
- {
|
|
|
- label: "excel",
|
|
|
- value: "excel"
|
|
|
- },
|
|
|
- {
|
|
|
- label: "ppt",
|
|
|
- value: "ppt"
|
|
|
- },
|
|
|
- {
|
|
|
- label: "txt",
|
|
|
- value: "txt"
|
|
|
- }
|
|
|
- ])
|
|
|
- let noChangeSpaceId = ref(0)
|
|
|
- let dirIds = ref(0)
|
|
|
- let addFile = ref(false)
|
|
|
- let nowFolder = ref("")
|
|
|
- function inlineList() {
|
|
|
- addFile.value = result
|
|
|
- }
|
|
|
- //获取文件树
|
|
|
- function getFileTree() {
|
|
|
- documents.fileTree(3).then(res => {
|
|
|
- treeData.value = [res]
|
|
|
- })
|
|
|
- documents.getTop(3).then(res => {
|
|
|
- noChangeSpaceId.value = res.spaceId
|
|
|
- })
|
|
|
- }
|
|
|
- function handleNodeClick(data) {
|
|
|
- console.log(data, 'data');
|
|
|
- dirIds.value = data.id
|
|
|
- nowFolder.value = data.label
|
|
|
- }
|
|
|
- function backTo() {
|
|
|
- addFile.value = false
|
|
|
- emit('threeBe', addFile.value)
|
|
|
- }
|
|
|
- function everyDunk() {
|
|
|
- fileCount.createFiles({
|
|
|
- dirId: dirIds.value - 0,
|
|
|
- spaceId: noChangeSpaceId.value - 0,
|
|
|
- type: createFile.value.fileType + ""
|
|
|
- }).then(res => {
|
|
|
- console.log(res, 'rrr');
|
|
|
- addFile.value = false
|
|
|
- ElMessage({ message: "新增成功", type: "success" })
|
|
|
- emit('threeBe', addFile.value)
|
|
|
- })
|
|
|
-
|
|
|
- }
|
|
|
- function optChange(e) {
|
|
|
- createFile.value.fileType = e
|
|
|
- }
|
|
|
- onMounted(() => {
|
|
|
- inlineList()
|
|
|
- getFileTree()
|
|
|
+ clickFileData: {
|
|
|
+ type: Object,
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ setup(props, { emit }) {
|
|
|
+ const rules = {
|
|
|
+ fileType:{ required: true, message: '请选择文件类型', trigger: 'change' }
|
|
|
+ }
|
|
|
+ const { proxy } = getCurrentInstance();
|
|
|
+ const labelPosition = ref("right");
|
|
|
+ let { sureAddFile, back } = toRef(props);
|
|
|
+ let result = props.newAdd;
|
|
|
+ let createFile = ref({
|
|
|
+ name: "",
|
|
|
+ fileType: "",
|
|
|
+ });
|
|
|
+ let treeData = ref([]);
|
|
|
+ let defaultProps = ref({
|
|
|
+ label: "label",
|
|
|
+ value: "id",
|
|
|
+ disable: false,
|
|
|
+ });
|
|
|
+ let typeF = ref([
|
|
|
+ {
|
|
|
+ label: "word",
|
|
|
+ value: "word",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "excel",
|
|
|
+ value: "excel",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "ppt",
|
|
|
+ value: "ppt",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "txt",
|
|
|
+ value: "txt",
|
|
|
+ },
|
|
|
+ ]);
|
|
|
+ let noChangeSpaceId = ref(0);
|
|
|
+ let dirIds = ref(0);
|
|
|
+ let addFile = ref(false);
|
|
|
+ let nowFolder = ref("");
|
|
|
+ function inlineList() {
|
|
|
+ addFile.value = result;
|
|
|
+ }
|
|
|
+ //获取文件树
|
|
|
+ function getFileTree() {
|
|
|
+ documents.fileTree(3).then((res) => {
|
|
|
+ treeData.value = [res];
|
|
|
+ });
|
|
|
+ documents.getTop(3).then((res) => {
|
|
|
+ noChangeSpaceId.value = res.spaceId;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ function handleNodeClick(data) {
|
|
|
+ console.log(data, "data");
|
|
|
+ dirIds.value = data.id;
|
|
|
+ nowFolder.value = data.label;
|
|
|
+ }
|
|
|
+ function backTo() {
|
|
|
+ addFile.value = false;
|
|
|
+ emit("threeBe", addFile.value);
|
|
|
+ }
|
|
|
+ function everyDunk() {
|
|
|
+ // fileCount.createFiles({
|
|
|
+ // dirId: dirIds.value - 0,
|
|
|
+ // spaceId: noChangeSpaceId.value - 0,
|
|
|
+ // type: createFile.value.fileType + ""
|
|
|
+ // }).then(res => {
|
|
|
+ // console.log(res, 'rrr');
|
|
|
+ // addFile.value = false
|
|
|
+ // ElMessage({ message: "新增成功", type: "success" })
|
|
|
+ // emit('threeBe', addFile.value)
|
|
|
+ // })
|
|
|
+ proxy.$refs.labelRef.validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ fileCount
|
|
|
+ .createFiles({
|
|
|
+ dirId: props.clickFileData.dirId,
|
|
|
+ spaceId: props.clickFileData.spaceId,
|
|
|
+ type: createFile.fileType,
|
|
|
})
|
|
|
- return {
|
|
|
- createFile,
|
|
|
- getFileTree,
|
|
|
- treeData,
|
|
|
- defaultProps,
|
|
|
- handleNodeClick,
|
|
|
- typeF,
|
|
|
- addFile,
|
|
|
- backTo,
|
|
|
- noChangeSpaceId,
|
|
|
- dirIds,
|
|
|
- back: backTo,
|
|
|
- sureAddFile: everyDunk,
|
|
|
- nowFolder,
|
|
|
- optChange,
|
|
|
- }
|
|
|
+ .then((res) => {
|
|
|
+ addFile.value = false;
|
|
|
+ ElMessage({ message: "新增成功", type: "success" });
|
|
|
+ emit("threeBe", addFile.value);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
-}
|
|
|
+ function optChange(e) {
|
|
|
+ createFile.fileType = e;
|
|
|
+ }
|
|
|
+ onMounted(() => {
|
|
|
+ inlineList();
|
|
|
+ getFileTree();
|
|
|
+ });
|
|
|
+ return {
|
|
|
+ createFile,
|
|
|
+ getFileTree,
|
|
|
+ treeData,
|
|
|
+ defaultProps,
|
|
|
+ handleNodeClick,
|
|
|
+ typeF,
|
|
|
+ addFile,
|
|
|
+ backTo,
|
|
|
+ noChangeSpaceId,
|
|
|
+ dirIds,
|
|
|
+ back: backTo,
|
|
|
+ sureAddFile: everyDunk,
|
|
|
+ nowFolder,
|
|
|
+ optChange,
|
|
|
+ labelPosition,
|
|
|
+ rules
|
|
|
+ };
|
|
|
+ },
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
-<style lang="scss" scoped></style>
|
|
|
+<style lang="scss" scoped>
|
|
|
+.el-form-item__label {
|
|
|
+ color: #505870;
|
|
|
+}
|
|
|
+:deep(.el-select) {
|
|
|
+ width: 100% !important;
|
|
|
+}
|
|
|
+.el-dialog__title {
|
|
|
+ color: #000;
|
|
|
+}
|
|
|
+</style>
|