Browse Source

添加社区截止时间

11wqe1 3 months ago
parent
commit
26e0c843c3
2 changed files with 139 additions and 18 deletions
  1. 69 9
      src/components/organList.vue
  2. 70 9
      src/components/schoolList.vue

+ 69 - 9
src/components/organList.vue

@@ -270,6 +270,12 @@
                     prop="createtime"
                     label="创建时间"
                     >
+                </el-table-column>
+                <el-table-column
+					show-overflow-tooltip
+                    prop="evatime2"
+                    label="截止日期"
+                    >
                 </el-table-column>
                  <el-table-column label="操作" width="200px">
                     <template slot-scope="scope">
@@ -339,14 +345,28 @@
                         </div>
                     </div>
                     <!-- banner -->
-                    <div class="el-form-item">
+					<div class="el-form-item">
+                        <label class="el-form-item__label" style="width: 100px">截止日期</label>
+						<el-date-picker
+							v-model="editCyInfo.evatime"
+							type="datetimerange"
+							align="right"
+							start-placeholder="开始日期"
+							end-placeholder="结束日期"
+							:default-time="['12:00:00', '08:00:00']">
+						</el-date-picker>
+                    </div>
+					<div class="el-form-item">
                         <label class="el-form-item__label" style="width: 100px">banner</label>
                         <div class="el-form-item__content" style="margin-left: 5px">
                             <el-button type="primary" @click="cyImgAdd">添加</el-button>
                         </div>
                     </div>
-                    <div class="el-form-item" v-if="editCyInfo.banner">
-                        <img style="width: 60px;height: 60px;object-fit: cover;" :src="editCyInfo.banner" alt="">                    
+                    <div class="el-form-item"  v-if="editCyInfo.banner">
+						<div style="position: relative;">
+							<div class="cha" @click="delImg">❌</div>
+							<img style="width: 60px;height: 60px;object-fit: cover;" :src="editCyInfo.banner" alt="">                  
+						</div>
                     </div>
                    
                 </form>
@@ -459,7 +479,7 @@ export default {
             cyloading:false,
 
             // 社区添加与修改所存储的信息 
-            editCyInfo:{name:'',banner:''},
+            editCyInfo:{name:'',banner:'',evatime:''},
             // 添加与修改社区共用一个弹框 0是添加信息 1 修改信息
             isedit:0,
             // 添加与修改社区弹框
@@ -940,7 +960,16 @@ export default {
 			getcylist(params)
 				.then(async (res) => {
 					console.log(res);
-                    this.cytableData = res.data[0]
+                    let data = res.data[0]
+					data.forEach(e => {
+
+						if (e.evatime && e.evatime != 'null' && JSON.parse(e.evatime).length) {
+							e.evatime = JSON.parse(e.evatime)
+							e.evatime2 = e.evatime.map(dateStr => this.formatDateCy(dateStr)).join('——')
+						}
+					});
+                    this.cytableData = data
+                    
                     this.cyloading = false;
 				})
 				.catch((error) => {
@@ -948,6 +977,26 @@ export default {
 					console.error("请求失败,错误信息:", error);
 				});
         },
+        formatDateCy(dateStr, format = 'YYYY-MM-DD HH:mm:ss') {
+            const date = new Date(dateStr);
+            
+            const pad = (num) => num.toString().padStart(2, '0');
+            
+            const year = date.getFullYear();
+            const month = pad(date.getMonth() + 1);
+            const day = pad(date.getDate());
+            const hours = pad(date.getHours());
+            const minutes = pad(date.getMinutes());
+            const seconds = pad(date.getSeconds());
+            
+            return format
+                .replace('YYYY', year)
+                .replace('MM', month)
+                .replace('DD', day)
+                .replace('HH', hours)
+                .replace('mm', minutes)
+                .replace('ss', seconds);
+        },
         // 点击添加社区 0 是添加社区 1是修改社区信息
         editCy(val,row){
             console.log('row',row);
@@ -967,6 +1016,7 @@ export default {
                 nam: this.editCyInfo.name,
                 oid:this.cyInfo.id,
                 ban: this.editCyInfo.banner,
+                eva: JSON.stringify(this.editCyInfo.evatime),
             };
             addCommunity(params)
               .then(async (response) => {
@@ -985,7 +1035,7 @@ export default {
                     });
                     this.dialogcyADD = false;
                     this.getCy()
-                    this.editCyInfo = {name:'',banner:''};
+                    this.editCyInfo = {name:'',banner:'',evatime:''};
                 }
               })
               .catch((error) => {
@@ -1000,7 +1050,10 @@ export default {
                 idL:this.editCyInfo.id,
                 nam: this.editCyInfo.name,
                 ban: this.editCyInfo.banner,
+                eva: JSON.stringify(this.editCyInfo.evatime),
             };
+            console.log('params',params);
+            
             updateCommunity(params)
               .then(async (response) => {
                     if (response) {
@@ -1018,7 +1071,7 @@ export default {
                     });
                     this.dialogcyADD = false;
                     this.getCy()
-                    this.editCyInfo = {name:'',banner:''};
+                    this.editCyInfo = {name:'',banner:'',evatime:''};
                 }
               })
               .catch((error) => {
@@ -1063,7 +1116,10 @@ export default {
 			let _url = await this.uploadFile("image/*");
             this.editCyInfo.banner = _url
         },
-
+		// 清除照片
+		delImg(){
+			this.editCyInfo.banner = ''
+		},
         // 全选 
         handleCheckAllChange2(val){
             this.checkboxList3 = val ? this.teacherJuri.map(e=>e.userid) : [];
@@ -1253,7 +1309,7 @@ export default {
         },
         handleClose2(){
             this.editCyInfo = ''
-            this.editCyInfo = {name:'',banner:''};
+            this.editCyInfo = {name:'',banner:'',evatime:''};
             this.dialogcyADD=false;
             this.dialogcyperson = false
         }
@@ -1412,4 +1468,8 @@ export default {
     text-overflow: ellipsis;
     white-space: nowrap;
 }
+.cha{
+	position: absolute;top: 0;right: 5px;
+	cursor: pointer;
+}
 </style>

+ 70 - 9
src/components/schoolList.vue

@@ -345,6 +345,12 @@
                     prop="createtime"
                     label="创建时间"
                     >
+                </el-table-column>
+				<el-table-column
+					show-overflow-tooltip
+                    prop="evatime2"
+                    label="截止日期"
+                    >
                 </el-table-column>
                  <el-table-column label="操作" width="200px">
                     <template slot-scope="scope">
@@ -414,14 +420,28 @@
                         </div>
                     </div>
                     <!-- banner -->
-                    <div class="el-form-item">
+					<div class="el-form-item">
+                        <label class="el-form-item__label" style="width: 100px">截止日期</label>
+						<el-date-picker
+							v-model="editCyInfo.evatime"
+							type="datetimerange"
+							align="right"
+							start-placeholder="开始日期"
+							end-placeholder="结束日期"
+							:default-time="['12:00:00', '08:00:00']">
+						</el-date-picker>
+                    </div>
+					<div class="el-form-item">
                         <label class="el-form-item__label" style="width: 100px">banner</label>
                         <div class="el-form-item__content" style="margin-left: 5px">
                             <el-button type="primary" @click="cyImgAdd">添加</el-button>
                         </div>
                     </div>
-                    <div class="el-form-item" v-if="editCyInfo.banner">
-                        <img style="width: 60px;height: 60px;object-fit: cover;" :src="editCyInfo.banner" alt="">                    
+                    <div class="el-form-item"  v-if="editCyInfo.banner">
+						<div style="position: relative;">
+							<div class="cha" @click="delImg">❌</div>
+							<img style="width: 60px;height: 60px;object-fit: cover;" :src="editCyInfo.banner" alt="">                  
+						</div>
                     </div>
                    
                 </form>
@@ -533,7 +553,7 @@ export default {
             cyloading:false,
 
             // 社区添加与修改所存储的信息 
-            editCyInfo:{name:'',banner:''},
+            editCyInfo:{name:'',banner:'',evatime:''},
             // 添加与修改社区共用一个弹框 0是添加信息 1 修改信息
             isedit:0,
             // 添加与修改社区弹框
@@ -1066,7 +1086,17 @@ export default {
 			getcylist(params)
 				.then(async (res) => {
 					console.log(res);
-                    this.cytableData = res.data[0]
+					let data = res.data[0]
+					data.forEach(e => {
+						
+						if (e.evatime && e.evatime != 'null' && JSON.parse(e.evatime).length) {
+							e.evatime = JSON.parse(e.evatime)
+							e.evatime2 = e.evatime.map(dateStr => this.formatDateCy(dateStr)).join('——')
+						}
+					});
+                    this.cytableData = data
+					console.log('this.cytableData',this.cytableData);
+					
                     this.cyloading = false;
 				})
 				.catch((error) => {
@@ -1074,6 +1104,26 @@ export default {
 					console.error("请求失败,错误信息:", error);
 				});
         },
+		formatDateCy(dateStr, format = 'YYYY-MM-DD HH:mm:ss') {
+			const date = new Date(dateStr);
+			
+			const pad = (num) => num.toString().padStart(2, '0');
+			
+			const year = date.getFullYear();
+			const month = pad(date.getMonth() + 1);
+			const day = pad(date.getDate());
+			const hours = pad(date.getHours());
+			const minutes = pad(date.getMinutes());
+			const seconds = pad(date.getSeconds());
+			
+			return format
+				.replace('YYYY', year)
+				.replace('MM', month)
+				.replace('DD', day)
+				.replace('HH', hours)
+				.replace('mm', minutes)
+				.replace('ss', seconds);
+		},
         // 点击添加社区 0 是添加社区 1是修改社区信息
         editCy(val,row){
             console.log('row',row);
@@ -1093,6 +1143,7 @@ export default {
                 nam: this.editCyInfo.name,
                 oid:this.cyInfo.id,
                 ban: this.editCyInfo.banner,
+                eva: JSON.stringify(this.editCyInfo.evatime),
             };
             addCommunity(params)
               .then(async (response) => {
@@ -1111,7 +1162,7 @@ export default {
                     });
                     this.dialogcyADD = false;
                     this.getCy()
-                    this.editCyInfo = {name:'',banner:''};
+                    this.editCyInfo = {name:'',banner:'',evatime:''};
                 }
               })
               .catch((error) => {
@@ -1126,7 +1177,10 @@ export default {
                 idL:this.editCyInfo.id,
                 nam: this.editCyInfo.name,
                 ban: this.editCyInfo.banner,
+                eva: JSON.stringify(this.editCyInfo.evatime),
             };
+            console.log('params',params);
+
             updateCommunity(params)
               .then(async (response) => {
                     if (response) {
@@ -1144,7 +1198,7 @@ export default {
                     });
                     this.dialogcyADD = false;
                     this.getCy()
-                    this.editCyInfo = {name:'',banner:''};
+                    this.editCyInfo = {name:'',banner:'',evatime:''};
                 }
               })
               .catch((error) => {
@@ -1189,7 +1243,10 @@ export default {
 			let _url = await this.uploadFile("image/*");
             this.editCyInfo.banner = _url
         },
-
+		// 清除照片
+		delImg(){
+			this.editCyInfo.banner = ''
+		},
         // 全选 
         handleCheckAllChange2(val){
             this.checkboxList3 = val ? this.teacherJuri.map(e=>e.userid) : [];
@@ -1379,7 +1436,7 @@ export default {
         },
         handleClose2(){
             this.editCyInfo = ''
-            this.editCyInfo = {name:'',banner:''};
+            this.editCyInfo = {name:'',banner:'',evatime:''};
             this.dialogcyADD=false;
             this.dialogcyperson = false
         }
@@ -1544,4 +1601,8 @@ export default {
     text-overflow: ellipsis;
     white-space: nowrap;
 }
+.cha{
+	position: absolute;top: 0;right: 5px;
+	cursor: pointer;
+}
 </style>