Przeglądaj źródła

创作项目管理平台完美

yichael 4 lat temu
rodzic
commit
c4ab379c40
1 zmienionych plików z 155 dodań i 43 usunięć
  1. 155 43
      components/home/teacher/project.vue

+ 155 - 43
components/home/teacher/project.vue

@@ -256,17 +256,59 @@
 			<view class="edit_form" @touchmove.stop.prevent = "stopPenetrate">
 				<view class="edit_BG">
 					<view class="edit_title">上传文件</view>
-				
 					<view class="edit_row">
 						<text class="edit_text">名称</text>
 						<view class="input_frame">
-							<input class="edit_input" type="string" v-model="projectName" placeholder="" @input="onInputProjectName"/>
+							<input class="edit_input" type="string" placeholder="文件名" @input="onSelectFileName"/>
+						</view>
+					</view>
+					<view class="edit_row">
+						<text class="edit_text">类型</text>
+						<view class="input_frame">
+							<picker class="form-input" @change="onSelectFileType" :value="fileType" :range="addFileType">
+							 	<view class=" df fdr aic jcsb">
+							 		<view>{{addFileType[fileType]}}</view>
+							 		<view>
+							 			<img src="../../../assets/user/pic_user_03.png" />
+							 		</view>
+							 	</view>
+							 </picker>
 						</view>
 					</view>
-					
 					<view class='modify_btn'>
-						<button type="default" size="mini" @click="confirm_modify()" class="modify_confirm">确认</button>
-						<button type="default" size="mini" @click="cancel_modify()" class="modify_cancel">取消</button>
+						<button type="default" size="mini" @click="confirm_file_upload()" class="modify_confirm">确认</button>
+						<button type="default" size="mini" @click="cancel_file_upload()" class="modify_cancel">取消</button>
+					</view>
+				</view>
+			</view>
+		</view>
+		<!--添加学生-->
+		<view class="pop_view" @touchmove.stop.prevent = "stopPenetrate" @click="shut_down_pop_view()" v-if='bShowAddStu'>
+			<view class="edit_form" @touchmove.stop.prevent = "stopPenetrate">
+				<view class="edit_BG">
+					<view class="edit_title">添加学生</view>
+					<view class="edit_row">
+						<text class="edit_text">姓名</text>
+						<view class="input_frame">
+							<input class="edit_input" type="string" placeholder="姓名" @input="onInputStuName"/>
+						</view>
+					</view>
+					<view class="edit_row">
+						<text class="edit_text">类型</text>
+						<view class="input_frame">
+							<picker class="form-input" @change="onSelectStuType" :value="stuType" :range="addproType">
+							 	<view class=" df fdr aic jcsb">
+							 		<view>{{addproType[stuType]}}</view>
+							 		<view>
+							 			<img src="../../../assets/user/pic_user_03.png" />
+							 		</view>
+							 	</view>
+							 </picker>
+						</view>
+					</view>
+					<view class='modify_btn'>
+						<button type="default" size="mini" @click="confirm_add_stu()" class="modify_confirm">确认</button>
+						<button type="default" size="mini" @click="cancel_add_stu()" class="modify_cancel">取消</button>
 					</view>
 				</view>
 			</view>
@@ -351,6 +393,13 @@
 				projectDescribe:'',
 				//上传文件
 				bShowUpLoadFile:false,
+				fileName:'',
+				fileType:0,
+				filePath:null,
+				//添加学生
+				bShowAddStu:false,
+				stuName:'',
+				stuType:0,
 			}
 		},
 		components: {
@@ -631,42 +680,8 @@
 				})
 			},
 			addMember() {
-				this.isShowAddMember = true;
-			},
-			addMemberData(){
-				console.log("添加学生", this.addedMemberModel,this.projectData[0]);
-				if (this.addedMemberModel.IlabAccount == "") {
-					alert("学员id不能为空")
-					return
-				}
-				console.log('删掉成员 ')
-				let url = this.$Api + "/project/addmember"
-				let data = {
-					"UserID" : this.projectData[0].CreateUserID,
-					"ProjectID":this.projectData[0].Id,
-					"AddUserID":this.addedMemberModel.IlabAccount,
-					"Type":this.addedMemberModel.type,
-				}
-				console.log('添加成员 发送数据 '," 地址 ",url," 数据 ",data,"项目数据",this.projectData)
-
-				uni.request({
-					url: url,
-					data: data,
-					method: "POST",
-					dataType: "json",
-					success: res => {
-						console.log('添加成员 返回',res)
-						if (res.data.Code == 100) {
-							// this.$refs.table.getList();
-							this.$forceUpdate()
-							this.isShowAddMember = false
-						}
-						this.getMemberList();
-						this.$forceUpdate()
-						this.isShowAddMember = false
-						// this.projectData.splice(index,index);
-					}
-				})
+				// this.isShowAddMember = true;
+				this.bShowAddStu = true;
 			},
 			addFileData(){
                 uni.chooseImage({
@@ -723,7 +738,14 @@
 			},
 			onClick_addFile(){
 				console.log("项目 点了添加文件")
-				this.isShowAddFile = true
+				// this.isShowAddFile = true
+		
+				uni.chooseFile({
+					success: (chooseImageRes) => {
+						this.filePath = chooseImageRes.tempFilePaths;
+						this.bShowUpLoadFile = true;
+					}
+				});
 			},
 			//删除条目
 			deleteItemProject(){
@@ -860,8 +882,98 @@
 			},
 			onInputProjectDescribe(e){
 				this.projectDescribe=e.detail.value;			
+			},
+			//添加文件
+			onSelectFileName(e){
+				this.fileName=e.detail.value;			
+			},
+			onSelectFileType(e){
+				this.fileType=e.detail.value;			
+			},
+			confirm_file_upload(){
+				
+				uni.uploadFile({
+					url: this.$Api+'/project/uploadprojectfile', //仅为示例,非真实的接口地址
+					filePath: this.filePath[0],
+					name: 'file',
+					formData: {
+						"UserID": this.projectData[0].CreateUserID,
+						"Name": this.fileName,
+						"Type": this.fileType,
+						"ProjectID": this.projectData[0].Id,
+					},
+					success: (uploadFileRes) => {
+						console.log('upload ok=', uploadFileRes.data);
+						this.bShowUpLoadFile = false;
+				        this.getFileList();
+						setTimeout(function(){
+							alert("创建成功");
+						},500)
+					}
+				});		
+			},
+			cancel_file_upload(){
+				this.bShowUpLoadFile = false;
+				this.fileName = '';
+				this.fileType = 0;
+				this.filePath = null;
+			},
+			// 添加学生
+			onInputStuName(e){
+				this.stuName=e.detail.value;
+			},
+			onSelectStuType(e){
+				// addproType[stuType]
+				this.stuType=e.detail.value;
+			},
+			confirm_add_stu(){
+				console.log("添加学生", this.stuName,this.projectData[0]);
+				if (this.stuName == "") {
+					alert("学员id不能为空")
+					return
+				}
+				
+				let url = this.$Api + "/project/addmember"
+				let data = {
+					"UserID" : this.projectData[0].CreateUserID,
+					"ProjectID":this.projectData[0].Id,
+					"AddUserID":this.stuName,
+					"Type":this.addproType[this.stuType],
+				}
+				// console.log('添加成员 发送数据 '," 地址 ",url," 数据 ",data,"项目数据",this.projectData)
+				
+				uni.request({
+					url: url,
+					data: data,
+					method: "POST",
+					dataType: "json",
+					success: res => {
+						console.log('添加成员 返回',res)
+						if (res.data.Code == 100) {
+							// this.$refs.table.getList();
+							this.getMemberList();
+							this.$forceUpdate();
+							this.bShowAddStu = false;
+							
+							setTimeout(function(){
+								alert("添加成功");
+							},500)
+							return;
+						}
+						
+						this.bShowAddStu = false;
+						setTimeout(function(){
+							alert("添加有误,请检查该学生是否存在");
+						},500)
+					}
+				})	
+			},
+			cancel_add_stu(){
+				this.bShowAddStu = false;
+				this.stuName = '';
+				this.stuType = 0;
 			}
-		}
+		},
 	}
 </script>