ソースを参照

设置填报日期

lcmxs 1 年間 前
コミット
072a650b6d
2 ファイル変更119 行追加1 行削除
  1. 15 0
      src/api/portal/ARTICLE/ARTICLE.js
  2. 104 1
      src/views/ARTICLE/index.vue

+ 15 - 0
src/api/portal/ARTICLE/ARTICLE.js

@@ -84,5 +84,20 @@ export function audit(data) {
   })
 }
 
+//设置重点项目录入开放时间
+export function articleDate(data) {
+  return request({
+    url: '/ARTICLE/articleDate/' + data,
+    method: 'post',
+    data:data
+  })
+}
+//设置重点项目录入开放时间
 
+export function getqueryArticleDate() {
+  return request({
+    url: '/ARTICLE/queryArticleDate',
+    method: 'get',
+  })
+}
 

+ 104 - 1
src/views/ARTICLE/index.vue

@@ -65,6 +65,7 @@
           size="mini"
           @click="handleAdd"
           v-hasPermi="['business:ARTICLE:add']"
+          :disabled="isButtonDisabled"
           >新增</el-button
         >
       </el-col>
@@ -79,6 +80,16 @@
           >删除</el-button
         >
       </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="primary"
+          size="mini"
+          icon="el-icon-edit"
+          @click="handleInsert"
+          v-hasPermi="['business:ARTICLE:insert']"
+        >设置重点项目录入开放时间</el-button
+        >
+      </el-col>
       <right-toolbar
         :showSearch.sync="showSearch"
         @queryTable="getList"
@@ -193,6 +204,32 @@
       :limit.sync="queryParams.pageSize"
       @pagination="getList"
     />
+
+    <!-- 设置重点项目录入开放时间对话框 -->
+    <el-dialog :title="title" :visible.sync="open" :close-on-click-modal="false" width="500px" append-to-body>
+      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
+        <el-form-item label="开放时间" prop="beginTime">
+          <el-date-picker
+            v-model="form.beginTime"
+            type="date"
+            value-format="yyyy-MM-dd"
+            placeholder="选择日期">
+          </el-date-picker>
+        </el-form-item>
+        <el-form-item label="截止时间" prop="endTime">
+          <el-date-picker
+            v-model="form.endTime"
+            type="date"
+            value-format="yyyy-MM-dd"
+            placeholder="选择日期">
+          </el-date-picker>
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitForm">确 定</el-button>
+        <el-button @click="cancel">取 消</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
@@ -204,7 +241,9 @@ import {
   addARTICLE,
   updateARTICLE,
   getUserInfo,
-} from "@/api/portal/ARTICLE/ARTICLE.js";
+  articleDate,
+  getqueryArticleDate,
+} from '@/api/portal/ARTICLE/ARTICLE.js'
 import edit from "./edit.vue";
 import enterData from "./enterData.vue";
 import detail from "./detail.vue";
@@ -212,6 +251,7 @@ export default {
   name: "ARTICLE",
   data() {
     return {
+      isButtonDisabled: false,
       scaleList: [
         { label: "小型", value: 1 },
         { label: "中型", value: 2 },
@@ -267,13 +307,51 @@ export default {
         most:null
       },
       deptId: "",
+      // 表单参数
+      form: {
+        beginTime: '',
+        endTime: ''
+      },
+      rules: {
+        beginTime: [
+          { required: true, message: "开始时间不能为空", trigger: "blur" }
+        ],
+        endTime: [
+          { required: true, message: "截止时间不能为空", trigger: "blur" },
+          {
+            validator: (rule, value, callback) => {
+              if (new Date(value) < new Date(this.form.beginTime)) {
+                callback(new Error("截止时间不能早于开始时间"));
+              } else {
+                callback();
+              }
+            },
+            trigger: "blur"
+          }
+        ]
+      }
     };
   },
   created() {
     this.getList();
     this.getDeptId();
+    this.getqueryArticleDate();
   },
   methods: {
+    //获取填报时间
+    getqueryArticleDate() {
+      getqueryArticleDate().then(res => {
+        const beginTime = new Date(res.data.beginTime);
+        const endTime = new Date(res.data.endTime);
+        const currentTime = new Date();
+
+        // 检查当前时间是否在 beginTime 和 endTime 范围内
+        if (currentTime < beginTime || currentTime > endTime) {
+          this.isButtonDisabled = true;
+          this.$message.warning('当前日期不在填报时间范围内')
+        }
+      });
+    },
     getDeptId() {
       getUserInfo().then((res) => {
         this.deptId = res.user.deptId;
@@ -376,6 +454,31 @@ export default {
         })
         .catch(() => {});
     },
+    //设置重点项目录入开放时间
+    handleInsert(){
+      this.open = true;
+      this.title = "设置重点项目录入开放时间";
+    },
+    submitForm(){
+      if (new Date(this.form.endTime) < new Date(this.form.beginTime)) {
+        this.$message.error('截止时间不能早于开始时间');
+        return
+      }
+      // this.form.beginTime = new Date(this.form.beginTime).getTime();
+      // this.form.endTime= new Date(this.form.endTime).getTime();
+      // console.log()
+      // this.form.beginTime= new Date(this.form.beginTime);
+      // this.form.endTime = new Date(this.form.endTime);
+      const timeData = [new Date(this.form.beginTime).getTime(), new Date(this.form.endTime).getTime()];
+
+      articleDate(timeData).then(res => {
+        if (res.code == 200) {
+          this.$modal.msgSuccess("设置重点项目录入开放时间成功");
+          this.open = false;
+          this.getList();
+        }
+      })
+    }
   },
 };
 </script>