<template>
  <div class="smart-remind">
    <el-row>
      <div class="remind-top">
        <div class="remind-title">【智能提醒】</div>
        <el-button type="primary" icon="icon iconfont icon-jc-xinjian" size="mini" @click="newRemind">新建提醒</el-button>
      </div>
    </el-row>
    <div class="remind-timeline" v-loading="loading">
      <el-card shadow="never">
        <div class="warn-main">
          <div class="warn-main-left">
            <div class="warn-main-img"><img src="@/assets/images/warn-green.png" alt=""></div>
            <div class="warn-main-content">
              <div class="content-title">关于做好2024年申报任务填报的通知</div>
              <div class="content-middle">该项目即将建设完成，请及时关注！</div>
              <div class="content-time">2024-05-29 09:00:00</div>
            </div>
          </div>
          <div class="warn-main-right">
            <div class="warn-main-right-bianji" @click="putMemo(item)">
              查看
            </div>
          </div>
        </div>
      </el-card>
    </div>
    <my-dialog title="新增智能提醒规则" @close="remindClose" @confirm="confirm" :myclass="true" ref="newRemindRef">
      <div class="remindDialog">
        <el-form :model="remindData" size="small" ref="remindFrom" label-width="160px" :rules="rules">
          <el-row>
            <el-col :span="24">
              <el-form-item label="提醒规则标题" class="importFormItem" prop="ruleTitle">
                <el-input v-model.trim="remindData.ruleTitle" placeholder="请输入内容"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="提醒对象：" class="importFormItem" prop="txObject">
                <el-radio-group v-model="remindData.txObject">
                  <el-radio :label="0">政务用户</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="提醒方式：" class="importFormItem" prop="txMode" disabled>
                <el-radio-group v-model="remindData.txMode">
                  <el-radio :label="0">定期提醒</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="提醒时间：" prop="time" class="importFormItem">
                <el-date-picker
                  v-model="remindData.time"
                  type="date"
                  placeholder="选择日期"
                  style="width:  100%;"
                  value-format="yyyy-MM-dd"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="提醒内容：" class="importFormItem" prop="content">
                <el-input
                  type="textarea"
                  resize="none"
                  :rows="3"
                  placeholder="请输入提醒内容"
                  v-model="remindData.content">
                </el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
    </my-dialog>
  </div>
</template>
<script>
import { getJMemorandumList, postJMemorandum } from "@/api/jin_ji_hu/project/index"
import myDialog from "@/views/components/myDialog/index.vue"
export default {
  name:"tabFive",
  components:{
    myDialog
  },
  data() {
    return {
      remindData:{
        ruleTitle: "",
        txObject: 0,
        txMode: 0,
        time: "",
        content: "",
      },
      rules:{
        ruleTitle:[
          { required: true, message: '请填写提醒规则标题', trigger: 'blur' }
        ],
        txObject:[
          { required: true, message: '请选择提醒对象', trigger: 'change' }
        ],
        txMode:[
          { required: true, message: '请选择提醒方式', trigger: 'change' },
        ],
        time:[
          { required: true, message: '请选择日期', trigger: 'change' },
        ],
        content:[
          { required: true, message: '请填写提醒内容', trigger: 'blur' },
        ],
      },
      loading: false,
      remindList:[],
      formInline:{},
    }
  },
  mounted(){
    this.getList();
  },
  methods:{
    newRemind(){
      this.$nextTick(()=>{
        this.$ref.newRemindRef.open();
        this.$refs.remindFrom.resetFields();
      })
    },
    // 关闭新增智能提醒
    remindClose(){
      this.$nextTick(()=>{
        this.$refs.remindFrom.resetFields();
        this.$refs.newRemindRef.close();
      })
    },
    // 新增智能提醒提交
    confirm(){
      postJMemorandum(this.remindData).then(res=>{
        if(res.code == 200) {
          this.remindClose();
          this.getList();
          this.$message({
            type: "success",
            message: "新增成功!",
          });
        }
      })
    },
    // 获取备忘录列表
    getList() {
      this.loading = true;
      getJMemorandumList(this.formInline).then(res=>{
        // console.log(res,"获取到的备忘录列表");
        this.remindList = res.data;
        this.loading = false;
      })
    },
  },
}
</script>
