Selaa lähdekoodia

feat(file-edit): 支持文档工作区与个人文档区切换

在文件编辑页面添加文档区域切换功能,允许用户在"文档工作区"和"个人文档区"之间切换,并根据选择的区域加载对应的文件夹树和提交参数。同时为树选择器组件增加工具栏插槽,支持自定义操作区域。
yusheng 2 päivää sitten
vanhempi
commit
ce4b238979
2 muutettua tiedostoa jossa 57 lisäystä ja 12 poistoa
  1. 1 0
      components/ba-tree-picker/ba-tree-picker.vue
  2. 56 12
      pages/doc/file-edit.vue

+ 1 - 0
components/ba-tree-picker/ba-tree-picker.vue

@@ -12,6 +12,7 @@
 					{{ multiple ? '确定' : '' }}
 				</view>
 			</view>
+			<slot name="toolbar"></slot>
 			<view class="tree-view">
 				<scroll-view class="tree-list" :scroll-y="true">
 					<block v-for="(item, index) in treeList" :key="index">

+ 56 - 12
pages/doc/file-edit.vue

@@ -67,7 +67,14 @@
 		</view>
 		<u-toast ref="uToast"></u-toast>
 		<ba-tree-picker ref="directoryIdRef" :multiple="false" title="选择文档位置" :localdata="folderList" valueKey="id"
-			textKey="name" childrenKey='sonDirectoryList' @select-row="directoryIdBack" />
+			textKey="name" childrenKey='sonDirectoryList' @select-row="directoryIdBack">
+			<template #toolbar>
+				<view class="toolbar">
+
+					<u-subsection :list="currentList" :current="current" @change="sectionChange"></u-subsection>
+				</view>
+			</template>
+		</ba-tree-picker>
 
 		<ba-tree-picker ref="codeTypeRef" key="verify" :multiple="false" @select-row="codeTypeBack" title="选择编码分类"
 			:localdata="list" valueKey="id" textKey="name" childrenKey='sonDirectoryList' />
@@ -95,6 +102,7 @@
 			fileSelector
 		},
 		data() {
+
 			const defaultForm = {
 				name: '', //名称
 				type: '', //类型
@@ -114,7 +122,11 @@
 
 			};
 			return {
+				currentList: ['文档工作区', '个人文档区'],
+				current: 0,
 				folderList: [],
+				allFolderList: [],
+				myFolderList: [],
 				files: [],
 				// 表单数据
 				form: {
@@ -122,6 +134,7 @@
 				},
 				list: [],
 				options: [],
+
 				show: false,
 				doc_type: [],
 				rules: {
@@ -145,11 +158,18 @@
 
 		async created() {
 			this.userInfo = uni.getStorageSync('userInfo')
-			let query = {
+
+
+			this.allFolderList = await getDocTreeListAPI({
 				type: 0,
 				currentUserId: this.userInfo.userId
-			};
-			this.folderList = await getDocTreeListAPI(query);
+			});
+			this.myFolderList = await getDocTreeListAPI({
+				type: 1,
+				currentUserId: this.userInfo.userId
+			});
+			this.folderList = JSON.parse(JSON.stringify(this.allFolderList));
+
 			const doc_type = await getByCode('doc_type');
 			this.doc_type = doc_type.map(item => {
 				const key = Object.keys(item)[0]
@@ -163,6 +183,7 @@
 			async open() {
 
 				this.show = true;
+				// this.current = 0
 				this.list = await selectTreeList();
 				this.options = await listCode();
 				if (this.options.length > 0) {
@@ -186,17 +207,20 @@
 			},
 			async directoryIdBack(data) {
 				console.log(data);
-				this.nodeData.id = data?.id
-				this.nodeData.parentId = data.parentId == -1 ? '' : data.parentId
 
 				this.form.directoryName = data.name
 				this.form.directoryId = data.id
+				if (this.current != 1) {
+					this.nodeData.id = data?.id
+					this.nodeData.parentId = data.parentId == -1 ? '' : data.parentId
 
+				}
 				this.options = this.nodeData.id ? await listCode(this.nodeData) : [];
 
 				if (this.options.length > 0) {
 					this.form.businessCodeId = this.options[0].id;
 					this.form.codeType = this.options[0].parentId;
+
 				} else {
 					this.form.businessCodeId = '';
 				}
@@ -258,6 +282,18 @@
 
 				// console.log('文件列表:', fileList)
 			},
+
+			sectionChange(index) {
+				this.form.directoryId = '';
+				this.form.businessCodeId = '';
+				this.form.codeType = '';
+				this.current = index;
+				if (index == 1) {
+					this.folderList = JSON.parse(JSON.stringify(this.myFolderList));
+				} else {
+					this.folderList = JSON.parse(JSON.stringify(this.allFolderList));
+				}
+			},
 			/* 保存编辑 */
 			async save() {
 
@@ -281,13 +317,17 @@
 				})
 
 				this.form.storagePath = await this.uploadFile(this.files)
-				let params = {
-					...this.form
-				}
-				delete params.codeTypeName
-				delete params.directoryName
+				// let params = {
+				// 	...this.form
+				// }
+				// delete params.codeTypeName
+				// delete params.directoryName
+
 
-				fileSaveAPI(this.form)
+				fileSaveAPI({
+						...this.form,
+						fileType: this.current == 1 ? 1 : 0
+					})
 					.then((msg) => {
 						uni.hideLoading()
 						console.log(msg, 'msg')
@@ -376,4 +416,8 @@
 	/deep/ .u-form {
 		padding: 30rpx;
 	}
+
+	/deep/.u-subsection__item__text {
+		font-size: 26rpx !important;
+	}
 </style>