<template>
  <div class="app-container">
    <div style="background-color: #fff;padding: 20px; border-radius: 5px;"  class="instabf">
    <el-form class="jugesfrss sousde" :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="108px">
      <el-row>
        <el-col :span="24">
          <p class='jivbf'> <img src="../../../assets/images/icon_htgl_cxtj.png" alt="" style="width:15px;height: 15px;">查询条件</p>
        </el-col>
        <el-col :span="8">
          <el-form-item label="贷款申请编号" prop="loanApplicationNumber">
            <el-input
              v-model="queryParams.loanApplicationNumber"
              placeholder="请输入贷款申请编号"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="提醒标题" prop="remindTitle">
            <el-input
              v-model="queryParams.remindTitle"
              placeholder="请输入提醒标题"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="提醒类型" prop="remindType">
            <el-select v-model="queryParams.remindType" placeholder="请选择提醒类型" clearable>
              <el-option
                v-for="dict in dict.type.remind_type"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              />
            </el-select>
          </el-form-item>
        </el-col>
       <!-- <el-col :span="8">
          <el-form-item label="是否已读" prop="isRead">
            <el-select v-model="queryParams.isRead" placeholder="请选择是否已读s" clearable>
              <el-option
                v-for="dict in dict.type.is_read"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              />
            </el-select>
          </el-form-item>
        </el-col> -->
        <el-col :span="8">
          <el-form-item class="qiuchu">
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-col>
      </el-row>

    </el-form>
   <div class="ntgs">
      <p class='jivb'><span>待办信息</span></p>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:remind:add']"
        >新增</el-button>
      </el-col>

      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:remind:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:remind:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="remindList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="贷款申请编号" align="center" prop="loanApplicationNumber" />
      <el-table-column label="提醒标题" align="center" prop="remindTitle" />
      <el-table-column label="提醒类型" align="center" prop="remindType">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.remind_type" :value="scope.row.remindType"/>
        </template>
      </el-table-column>
      <el-table-column label="提醒内容" align="center" prop="remindContent" />
      <el-table-column label="提醒时间" align="center" prop="remindTime" width="180">
        <template slot-scope="scope">
          <span>{{scope.row.remindTime}}</span>
        </template>
      </el-table-column>
      <!-- <el-table-column label="已读过的用户ID" align="center" prop="readUserId" /> -->
      <!-- <el-table-column label="是否已读" align="center" prop="isRead">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.is_read" :value="scope.row.isRead"/>
        </template>
      </el-table-column> -->
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
         <!-- <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:remind:edit']"
          >修改</el-button> -->
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            v-if="scope.row.remindType != 13 &&scope.row.remindType != 12 "
            @click="handleUpdatech(scope.row)"
          >查看详情</el-button>
          <el-button
                      size="mini"
                      type="text"
                      icon="el-icon-edit"
                      v-if="scope.row.remindType == 12"
                      @click="handleUpdatechxq(scope.row)"
                    >查看详情</el-button>
          <el-button
                      size="mini"
                      type="text"
                      icon="el-icon-edit"
                      v-if="scope.row.remindType == 13"
                      @click="handleUpdatechxqbao(scope.row)"
                    >查看详情</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:remind:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    </div>
  </div>

    <!-- 添加或修改待办提醒对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="贷款申请编号" prop="loanApplicationNumber">
              <el-input v-model="form.loanApplicationNumber" placeholder="请输入贷款申请编号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="提醒标题" prop="remindTitle">
              <el-input v-model="form.remindTitle" placeholder="请输入提醒标题" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="提醒类型" prop="remindType">
              <el-select v-model="form.remindType" placeholder="请选择提醒类型">
                <el-option
                  v-for="dict in dict.type.remind_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="提醒时间" prop="remindTime">
              <el-date-picker clearable
                v-model="form.remindTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="请选择提醒时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="提醒内容">
              <editor v-model="form.remindContent" :min-height="192"/>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="备注" prop="remark">
              <el-input v-model="form.remark" placeholder="请输入备注" />
            </el-form-item>
          </el-col>
        </el-row>
      </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>

<script>
import { listRemind, getRemind, delRemind, addRemind, updateRemind } from "@/api/dabgs/remind";

export default {
  name: "Remind",
  dicts: ['remind_type', 'is_read'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 待办提醒表格数据
      remindList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        loanApplicationId: null,
        loanApplicationNumber: null,
        remindTitle: null,
        remindType: null,
        remindContent: null,
        remindTime: null,
        readUserId: null,
        isRead: null,
        status: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        loanApplicationId: [
          { required: true, message: "贷款申请id不能为空", trigger: "blur" }
        ],
        loanApplicationNumber: [
          { required: true, message: "贷款申请编号不能为空", trigger: "blur" }
        ],
        remindTitle: [
          { required: true, message: "提醒标题不能为空", trigger: "blur" }
        ],
        remindType: [
          { required: true, message: "提醒类型不能为空", trigger: "change" }
        ],
        readUserId: [
          { required: true, message: "已读过的用户ID不能为空", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询待办提醒列表 */
    getList() {
      this.loading = true;
      this.queryParams.userId = this.$store.state.user.id
      listRemind(this.queryParams).then(response => {
        this.remindList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    handleUpdatech(row){
      const loanApplicationId = row.loanApplicationId || this.ids
      this.$router.push({
        path: '/shenbaoxinx/bjq',
      		query: {
      			'id':loanApplicationId,
      			'isxz':2,
            'bh':row.loanApplicationNumber
      		}
      })
    },
    handleUpdatechxq(row){
      const loanApplicationId = row.loanApplicationId || this.ids
      this.$router.push({
        path: '/bjqsh',
      		query: {
      			'id':loanApplicationId,
      			'isxz':2,
            'bh':row.loanApplicationNumber,
            'issh':true
      		}
      })
    },
    handleUpdatechxqbao(row){
      const loanApplicationId = row.loanApplicationId || this.ids
      this.$router.push({
        path: '/shenbaoxinx/bjqbao',
      		query: {
      			'id':loanApplicationId,
      			'isxz':2,
            'bh':row.loanApplicationNumber
      		}
      })
    },
    // 表单重置
    reset() {
      this.form = {
        remindId: null,
        loanApplicationId: null,
        loanApplicationNumber: null,
        remindTitle: null,
        remindType: null,
        remindContent: null,
        remindTime: null,
        readUserId: null,
        isRead: null,
        status: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.remindId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加待办提醒";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const remindId = row.remindId || this.ids
      getRemind(remindId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改待办提醒";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.remindId != null) {
            updateRemind(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addRemind(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const remindIds = row.remindId || this.ids;
      this.$modal.confirm('是否确认删除待办提醒编号为"' + remindIds + '"的数据项？').then(function() {
        return delRemind(remindIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/remind/export', {
        ...this.queryParams
      }, `remind_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>

<style lang="scss">
  .instabf{
    .el-table .el-table__fixed-header-wrapper th{
      background-color:#F1F9FD;
    }
    .el-table .el-table__header-wrapper th{
      background-color:#F1F9FD;
    }
  }
  .sousde{
    .el-form-item--small.el-form-item{
      border: 1px solid #E6E6E6;
          }

    .el-input--small .el-input__inner{
      border: 0;
    }
    .qiuchu{
      border:0 !important;
    }
  }
	.nhgrls{
		.el-dialog__body{
			padding: 0;
		}
	}
  .hyr{
    span{
      text-decoration:underline;
    }
  }
</style>
<style scoped lang="scss">
  .iuer{
    display: flex;
    justify-content: space-between;
    align-items: center;
    .ite{
      display: flex;
      justify-content: space-between;
      align-items: center;
      p{
        cursor:pointer;
        margin: 0;
        font-size: 15px;
        font-family: PingFang SC;
        font-weight: 500;
        color:#666666;
        padding: 4px 12px;
        background: #Fff;
        border-radius: 4px;
        margin-right: 20px;
		position: relative;
      }
      .actt{
        background: #fff;
        // border-bottom: 3px solid #5974E0;
        // border-radius: 0;
		// border-bottom-right-radius: 4px;
        color: #5974E0;
      }
	  .actt{
		    &::after {
		          content: "";
		          width: 40%;
		          height: 5px;
				      border-radius: 3px;
		          transform: translate(-50%);
		          background-color: #5974E0;
		          position: absolute;
		          left: 50%;
		          bottom:-3px;
		        }

	  }

    }
  }
  .lqw{
    padding: 0 10px;
    margin: 0;
    margin-bottom: 20px;
  }
.nhgel{
  height: 170px;
  background-color: #313b61;
  width: 100%;
  position: absolute;
  top:0;
  left:0;
  z-index: 0;
}
	.app-container{
		background-color: #f3f4f6;
		padding-top: 10px;
	   // height: 100vh;
	}


	.ksf{
		img{
			width:100%;
			height: 100%;
		}
	}

 .jivbf{
   display: flex;
   align-items: center;
   line-height: 26px;
   font-size: 15px;
   font-family: PingFang SC;
   font-weight: bold;
   color: #333;
   margin-top: 0;
   margin-bottom: 20px;
   img{
   	margin-right: 10px;
   }
 }
  .jivb{
  	display: flex;
  	align-items: center;
  	line-height: 26px;
  	font-size: 15px;
  	font-family: PingFang SC;
  	font-weight: bold;
  	color: #00A9F0;
    margin-top: 0;
  	margin-bottom: 20px;
    border-bottom: 2px solid #E6E6E6;
  	img{
  		margin-right: 10px;
  	}
  	span{
  		border-bottom: 2px solid #00A9F0;
      margin-bottom: -2px;
  	}
  	// border-left: 8px solid #04BFA1;

  }

</style>
