浏览代码

对选择时间进行优化

zhuhao 2 年之前
父节点
当前提交
f0b3292824

+ 86 - 43
RMS-FrontEnd/src/views/report/FTO/FTOPage/components/ProductMessage.vue

@@ -9,17 +9,19 @@
                     <div>
                         <el-form ref="form" :model="product" :rules="productRules" label-width="200px">
                             <el-form-item label="标的产品:" prop="productName">
-                                <el-input v-model="product.productName" v-if="isEdit == 'productName'"></el-input>
-                                <span @dblclick="changEdit('productName')" v-else>{{ product.productName }}</span>
+                                <el-input v-model="product.productName" @change="editChange" @blur="editChange" v-if="isEdit == 'productName' " placeholder="请输入"></el-input>
+                                <span @dblclick="changEdit('productName')" placeholder="请输入" v-else>{{ product.productName }}</span>
                                 <!-- <span>{{ product.productName }}</span> -->
                             </el-form-item> 
                             <el-form-item label="调查标的说明:" prop="productDescription">
-                                <el-input v-model="product.productDescription" v-if="isEdit == 'productDescription'"></el-input>
-                                <span @dblclick="changEdit('productDescription')" v-else>{{ product.productDescription }}</span>
+                                <el-input type="textarea" v-model="product.productDescription" @change="editChange" @blur="editChange" v-if="isEdit == 'productDescription'" placeholder="请输入"></el-input>
+                                <span @dblclick="changEdit('productDescription')" placeholder="请输入" v-else>{{ product.productDescription }}</span>
                                 <!-- <span>{{ product.productDescription }}</span> -->
                             </el-form-item>
                             <el-form-item label="调查区域:" prop="surveyArea">
-                                <span>{{ product.surveyArea }}</span>
+                               <el-input type="textarea"  v-model="product.surveyArea" @change="editChange" @blur="editChange" v-if="isEdit == 'surveyArea'" placeholder="请输入"></el-input>
+                                <span @dblclick="changEdit('surveyArea')" placeholder="请输入" v-else>{{ product.surveyArea}}</span>
+                                <!-- <span>{{ product.surveyArea }}</span> -->
                             </el-form-item>
                             <el-form-item label="产品图:">
                                 <el-upload ref="upload"  action="#" :auto-upload="false" multiple :on-change="handleChangeUpload"  list-type="picture" :show-file-list="false">
@@ -47,19 +49,22 @@
                                 </el-upload>
                             </el-form-item>
                             <el-form-item label="检索策略:" prop="searchPolicy">
-                                <el-input v-model="product.searchPolicy" v-if="isEdit == 'searchPolicy'" placeholder="请输入"></el-input>
+                                <el-input v-model="product.searchPolicy" @change="editChange" @blur="editChange" v-if="isEdit == 'searchPolicy'" placeholder="请输入"></el-input>
                                 <span @dblclick="changEdit('searchPolicy')" placeholder="请输入" v-else>{{ product.searchPolicy}}</span>
                             </el-form-item>
-                            <el-form-item label="检索截止日期:">
+                            <el-form-item label="检索截止日期:" prop="deadLine">
                                 <el-date-picker
                                     style="width:100%"
                                         v-model="product.deadLine"
                                         type="date"
-                                        placeholder="选择日期">
+                                        placeholder="选择日期"
+                                        @change="isDates">
                                     </el-date-picker>
                             </el-form-item>
-                            <el-form-item label="关注企业/发明人/技术方向:" v-if="product.focusInformation">
-                                <span>{{ product.focusInformation }}</span>
+                            <el-form-item label="关注企业/发明人/技术方向:">
+                                <el-input type="textarea" v-model="product.focusInformation" @change="editChange" @blur="editChange" v-if="isEdit == 'focusInformation'" placeholder="请输入"></el-input>
+                                <span @dblclick="changEdit('focusInformation')" placeholder="请输入" v-else>{{ product.focusInformation}}</span>
+                                <!-- <span>{{ product.focusInformation }}</span> -->
                             </el-form-item>
                         </el-form>
                     </div>
@@ -74,10 +79,31 @@
 
 <script>
 
+
 export default{
     props:['reportId'],
-    data() {
-        return {
+  data() {
+    const isTime = (rule, value, callback) => {
+      console.log(this.isDate);
+      if (this.isDate) {
+        let a = Date.parse(new Date)
+        let b = Date.parse(value)
+        if (value) {
+          if (b+8.64e7<a) {//8.64e7一天的时间//只适用YYYY-mm-dd格式
+            callback(new Error('禁止选择以前时间,请重新选择'))
+          } else {
+            callback()
+          }
+        } else {
+          callback()
+        }
+      }else {
+          callback()
+        }
+     
+    }
+      return {
+            isDate:true,
             isEdit:'',//是否编辑
             file:[],
             dialogImageUrl:[],
@@ -87,7 +113,10 @@ export default{
             productRules:{
                 name: [{ required: true, message: '请输入标的专利/产品', trigger: 'blur' },],
                 explain: [{ required: true, message: '请输入调查标的说明', trigger: 'blur' },],
-                area: [{ required: true, message: '请输入调查区域', trigger: 'blur' },],
+              area: [{ required: true, message: '请输入调查区域', trigger: 'blur' },],
+              deadLine: [
+                  {  required: false, validator:isTime, trigger: 'change' }
+                ],
             },
             Already:[],
         }
@@ -96,10 +125,15 @@ export default{
         this.$set(this.product,'productName',this.$s.getSession('row').signPatentNo)
         this.getProduct()
     },
-    methods: {
+  methods: {
+    isDates() {
+      this.isDate=true
+    },
         changEdit(val){
-            console.log(val)
             this.isEdit = val
+      },
+      editChange() {
+          this.isEdit = ''
         },
         handleChangeUpload(file, fileList) {
             if(this.product.reportFiles){
@@ -175,39 +209,48 @@ export default{
                 reportId:this.reportId
             }
             this.$api.getProduct(a).then(response=>{
-                if(response.code == 200){
+              if (response.code == 200) {
+                  if (this.data.deadLine) {
+                    this.isDate=false
+                  }
                     this.product = response.data
                 }
             })
         },
-        saveProduct(){
-            this.product.reportId = this.reportId
-            let formData = new FormData()
-            if(this.file.length>0){
-                this.file.forEach(item=>{
-                    formData.append('files', item)
-                })
-            }
-            formData.append('jsons', JSON.stringify(this.product))
-            if(this.product.id){
-                this.$api.updateProduct(formData).then(response=>{
-                    if(response.code == 200){
-                        this.dialogImageUrl = []
-                        this.file = []
-                        this.$message.success('产品信息修改成功')
-                        this.getProduct()
-                    }
-                })
-            }else{
-                this.$api.addProduct(formData).then(response=>{
-                    if(response.code == 200){
-                        this.dialogImageUrl = []
-                        this.file = []
-                        this.$message.success('产品信息保存成功')
-                        this.getProduct()
-                    }
-                })
+    saveProduct() {
+      this.$refs.form.validate(valid => {
+        if (valid) {
+              this.editChange()
+               this.product.reportId = this.reportId
+                let formData = new FormData()
+                if(this.file.length>0){
+                    this.file.forEach(item=>{
+                        formData.append('files', item)
+                    })
+                }
+                formData.append('jsons', JSON.stringify(this.product))
+                if(this.product.id){
+                    this.$api.updateProduct(formData).then(response=>{
+                        if(response.code == 200){
+                            this.dialogImageUrl = []
+                            this.file = []
+                            this.$message.success('产品信息修改成功')
+                            this.getProduct()
+                        }
+                    })
+                }else{
+                    this.$api.addProduct(formData).then(response=>{
+                        if(response.code == 200){
+                            this.dialogImageUrl = []
+                            this.file = []
+                            this.$message.success('产品信息保存成功')
+                            this.getProduct()
+                        }
+                    })
+                }
             }
+          })
+           
             
         },
     },

+ 46 - 0
RMS-FrontEnd/src/views/report/FTO/FTOPage/mixins.js

@@ -0,0 +1,46 @@
+export const changeDateType = {
+    data() {
+       
+        return {
+            
+        }
+    },
+    methods: {
+        getDate(time,type){
+            let Y = time.getFullYear()
+            let M = time.getMonth() + 1 < 10 ? '0' + (time.getMonth() + 1) : (time.getMonth() + 1)
+            let D = time.getDate() < 10 ? ('0' + time.getDate()) : time.getDate()
+            var date = Y + '-' + M + '-' + D
+
+                if(type == 'datetime'){
+                    let hours = time.getHours()< 10 ? ('0' + time.getHours()) : time.getHours()
+                    let minutes = time.getMinutes() < 10 ? ('0' + time.getMinutes()) : time.getMinutes()
+                    let seconds = time.getSeconds() < 10 ? ('0' + time.getSeconds()) : time.getSeconds()
+                    date = date + ' ' + hours + ':' + minutes + ':' + seconds
+                }
+            
+            
+            console.log(date)
+            return Date.parse(date)
+        }
+    },
+}
+
+
+// export const getDate = (time, type) => {
+//             let Y = time.getFullYear()
+//             let M = time.getMonth() + 1 < 10 ? '0' + (time.getMonth() + 1) : (time.getMonth() + 1)
+//             let D = time.getDate() < 10 ? ('0' + time.getDate()) : time.getDate()
+//             var date = Y + '-' + M + '-' + D
+//             if(type){
+//                 if(type == 'datetime'){
+//                     let hours = time.getHours()< 10 ? ('0' + time.getHours()) : time.getHours()
+//                     let minutes = time.getMinutes() < 10 ? ('0' + time.getMinutes()) : time.getMinutes()
+//                     let seconds = time.getSeconds() < 10 ? ('0' + time.getSeconds()) : time.getSeconds()
+//                     date = date + ' ' + hours + ':' + minutes + ':' + seconds
+//                 }
+//             }
+            
+//             console.log(date)
+//             return Date.parse(date)
+//   }

+ 33 - 12
RMS-FrontEnd/src/views/report/FTO/FTOPage/product.vue

@@ -50,7 +50,8 @@
                                 style="width:100%"
                                     v-model="product.deadLine"
                                     type="date"
-                                    placeholder="选择日期">
+                                    placeholder="选择日期"
+                                    @change="isDates">
                                 </el-date-picker>
                         </el-form-item>
                         <el-form-item label="关注企业/发明人/技术方向:">
@@ -69,23 +70,31 @@
 
 <script>
 
+
 export default{
     props:['reportId'],
   data() {
     const isTime = (rule, value, callback) => {
-      let a = Date.parse(new Date)
-      let b = Date.parse(value)
-      if (value) {
-        if (b<a) {
-          callback(new Error('禁止选择现在及以前时间,请重新选择'))
+      console.log(this.isDate);
+      if (this.isDate) {
+        let a = Date.parse(new Date)
+        let b = Date.parse(value)
+        if (value) {
+          if (b+8.64e7<a) {//8.64e7一天的时间//只适用YYYY-mm-dd格式
+            callback(new Error('禁止选择以前时间,请重新选择'))
+          } else {
+            callback()
+          }
         } else {
           callback()
         }
-      } else {
-        callback(new Error('请选择时间'))
+      }else {
+          callback()
       }
+     
     }
-        return {
+    return {
+            isDate:true,
             file:[],
             dialogImageUrl:[],
             ImageUrl:'',
@@ -99,7 +108,13 @@ export default{
                   {  required: false, validator:isTime, trigger: 'change' }
                 ],
             },
-            Already:[],
+          Already: [],
+            //  pickerOptions: {
+            //     disabledDate (time) {
+            //         //disabledDate 文档上:设置禁用状态,参数为当前日期,要求返回 Boolean
+            //         return time.getTime() < Date.now()- 8.64e7//选当前时间之后的时间
+            //       }
+            //   },
         }
     },
     mounted() {
@@ -110,7 +125,10 @@ export default{
         console.log(this.product.productName);
         this.getProduct()
     },
-    methods: {
+  methods: {
+    isDates() {
+      this.isDate=true
+    },
         handleChangeUpload(file, fileList) {
             if(this.product.reportFiles){
                 var index3 = this.product.reportFiles.findIndex(item=>{
@@ -186,7 +204,10 @@ export default{
             }
             this.$api.getProduct(a).then(response=>{
                 if (response.code == 200) {
-                    if(response.data){
+                  if (response.data) {
+                    if (response.data.deadLine) {
+                        this.isDate=false
+                      }
                         this.product = response.data
                     }else{
                         this.$emit('isSave',false)

+ 25 - 13
RMS-FrontEnd/src/views/task/MyInitiate.vue

@@ -5,8 +5,8 @@
 			<el-form-item label="名称">
 				<el-input v-model="queryParams.taskName" size="small" placeholder="请输入任务名称"></el-input>
 			</el-form-item>
-			<el-form-item label="发起人">
-				<el-input v-model="queryParams.createName" size="small" placeholder="请输入发起人名称"></el-input>
+			<el-form-item label="处理人">
+				<el-input v-model="queryParams.handlePersonName" size="small" placeholder="请输入处理人名称"></el-input>
 			</el-form-item>
 			<el-form-item label="类型">
 				<el-select clearable v-model="queryParams.type" size="small" placeholder="请选择任务类型">
@@ -96,7 +96,7 @@
               <el-input v-model="form.createTime" :disabled="true" autocomplete="off" placeholder="请输入创建时间"></el-input>
             </el-form-item>
             <el-form-item label="期限" prop="endTime">
-              <el-date-picker v-model="form.endTime" value-format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间" style="width:100%"> </el-date-picker>
+              <el-date-picker v-model="form.endTime" value-format="yyyy-MM-dd HH:mm:ss"  type="datetime" placeholder="选择日期时间" style="width:100%"> </el-date-picker>
             </el-form-item>
 
         </el-form>
@@ -113,11 +113,13 @@ export default {
   props:['activeName','reportType','status'],
   data() {
     const isTime = (rule, value, callback) => {
-      let a = Date.parse(new Date)
+      if (this.formEndTime) {
+         this.changeEndTime = Date.parse(new Date)
+      }
       let b = Date.parse(value)
-      console.log(a,b);
+      console.log(this.changeEndTime,b);
       if (value) {
-        if (b<a) {
+        if (b<this.changeEndTime) {
           callback(new Error('禁止选择现在及以前时间,请重新选择'))
         } else {
           callback()
@@ -129,6 +131,8 @@ export default {
     return {
       tableData:[],
       form:[],
+      formEndTime: true,
+      changeEndTimes:null,
       queryParams: {
         size: 10,
         current: 1,
@@ -167,6 +171,7 @@ export default {
     this.getAllPersonnelList()
   },
   methods: {
+    
      //获取全部人员
      getAllPersonnelList(){
       this.$api.getAllPersonnel().then(response=>{
@@ -268,18 +273,25 @@ export default {
       }
        
     },
-    submit(){
-      this.$api.UpdateTask(this.form).then(response=>{
-        if(response.code == 200){
-          this.$message.success('任务修改成功')
-          this.handleClose()
-          this.getList()
+    submit() {
+      this.formEndTime=false
+      this.$refs.reportForm.validate(valid => {
+        if (valid) {
+           this.$api.UpdateTask(this.form).then(response=>{
+            if(response.code == 200){
+              this.$message.success('任务修改成功')
+              this.handleClose()
+              this.getList()
+            }
+          })
         }
       })
+     
     },
     //关闭弹窗
 	  handleClose(){
-		  this.showDialog = false
+      this.showDialog = false
+      this.formEndTime=true
 	  }
   },