<!--
 * @Description: 党建管理 => 情况说明管理
 * @Author: Rockery
 * @Date: 2021-12-10 10:45:58
 * @LastEditors: Rockery
 * @LastEditTime: 2021-12-29 15:23:58
 * @FilePath: \party_construct_web\src\views\PartyBuildingMgr\SituationDesc\SituationDescIndex.vue
 * @Copyright: Copyright (c) 2016~2021 Rockery(1113269755@qq.com)
-->

<template>
  <div
    class="app-container situationdesc"
    :class="['ADD','VIEW'].includes(pageType) ? 'desc-page':''"
  >
    <template v-if="pageType === 'LIST'">
      <div class="situationdesc-main">
        <el-row :gutter="10">
          <el-col :span="24">
            <div class="situationdesc-main-title">
              <div>
                <img
                  :src="require('@/assets/logo/home-main-title-logo.png')"
                  @error="imgViewerOnerror"
                />
              </div>
              <div>情况说明管理</div>
            </div>
          </el-col>
          <div v-loading="loading">
            <el-col :span="24" class="mt20">
              <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
                <el-form-item prop="beginTime">
                  <el-date-picker
                    v-model="queryParams.beginTime"
                    type="date"
                    size="small"
                    clearable
                    format="yyyy年MM月dd日"
                    value-format="yyyy-MM-dd"
                    style="width: 100%;"
                    placeholder="请选择开始时间"
                  ></el-date-picker>
                </el-form-item>
                <el-form-item prop="endTime">
                  <el-date-picker
                    v-model="queryParams.endTime"
                    type="date"
                    size="small"
                    clearable
                    format="yyyy年MM月dd日"
                    value-format="yyyy-MM-dd"
                    style="width: 100%;"
                    placeholder="请选择结束时间"
                  ></el-date-picker>
                </el-form-item>
                <el-form-item prop="name">
                  <el-input
                    v-model="queryParams.name"
                    placeholder="请输入情况说明人姓名"
                    clearable
                    size="small"
                    style="width: 100%;"
                    @keyup.enter.native="handleQuery"
                  />
                </el-form-item>
                <el-form-item>
                  <el-button
                    v-hasPermi="['partybuildingmgr:situationdesc:query']"
                    type="primary"
                    icon="el-icon-search"
                    @click="handleQueryClick"
                  >搜索</el-button>
                  <el-button
                    v-hasPermi="['partybuildingmgr:situationdesc:reset']"
                    icon="el-icon-refresh"
                    @click="resetQueryClick"
                  >重置</el-button>
                </el-form-item>
                <el-form-item class="fr" style="margin-right: 0;">
                  <el-button
                    v-hasPermi="['partybuildingmgr:situationdesc:add']"
                    type="rocpartyprimarybtn"
                    icon="el-icon-plus"
                    @click="handleAddClick"
                  >新增</el-button>
                </el-form-item>
              </el-form>
            </el-col>
            <el-col :span="24">
              <el-table
                :data="list"
                stripe
                border
                :header-cell-style="{'text-align':'center'}"
                header-row-class-name="situationdesc-table_header-row"
                class="situationdesc-main-table"
                style="width: 100%;"
              >
                <el-table-column
                  label="情况说明人姓名"
                  prop="name"
                  width="180"
                  :show-overflow-tooltip="true"
                />
                <el-table-column
                  label="说明了以下流程节点问题"
                  prop="conditionPoint"
                  :show-overflow-tooltip="true"
                />
                <el-table-column
                  label="情况说明时间"
                  align="center"
                  prop="conditionTime"
                  width="180"
                  :show-overflow-tooltip="true"
                />
                <el-table-column
                  label="操作"
                  align="center"
                  fixed="right"
                  width="100"
                  class-name="small-padding fixed-width"
                >
                  <template slot-scope="scope">
                    <el-button
                      v-hasPermi="['partybuildingmgr:situationdesc:view']"
                      size="mini"
                      type="text"
                      icon="el-icon-view"
                      style="color: #909399;"
                      @click="handleViewClick(scope.row)"
                    >详情</el-button>
                  </template>
                </el-table-column>
              </el-table>
            </el-col>
            <el-col :span="24">
              <pagination
                v-show="total>0"
                :total="total"
                :page.sync="queryParams.pageNum"
                :limit.sync="queryParams.pageSize"
                @pagination="initData"
              />
            </el-col>
          </div>
        </el-row>
      </div>
    </template>
    <template v-else-if="pageType === 'ADD'">
      <div class="situationdesc-addpage">
        <el-form
          ref="situationDescAddpageFormRef"
          :model="addPageFormObj.formModel"
          :rules="addPageFormObj.formRules"
          label-width="190px"
          class="situationdesc-addpage-form"
        >
          <el-row>
            <el-col :span="24">
              <div class="situationdesc-addpage-title">
                <div>
                  <img
                    :src="require('@/assets/logo/home-main-title-logo.png')"
                    @error="imgViewerOnerror"
                  />
                </div>
                <div>新增情况说明</div>
              </div>
            </el-col>
            <el-col :span="24">
              <div class="situationdesc-addpage-line"></div>
            </el-col>
            <el-col :span="24">
              <el-form-item label="情况说明时间：" prop="beginTime">
                <el-date-picker
                  v-model="addPageFormObj.formModel.name"
                  type="date"
                  clearable
                  format="yyyy年MM月dd日"
                  value-format="yyyy-MM-dd"
                  style="width: 100%;"
                  placeholder="请选择情况说明时间"
                ></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="情况说明人:" prop="explainer">
                <el-select
                  v-model="addPageFormObj.formModel.explainer"
                  clearable
                  filterable
                  style="width: 100%;"
                  placeholder="请选择情况说明人"
                >
                  <el-option
                    v-for="situationExplainerOption in situationExplainerOptions"
                    :key="situationExplainerOption.dictValue"
                    :label="situationExplainerOption.dictLabel"
                    :value="situationExplainerOption.dictValue"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="情况说明：" prop="conditionFile">
                <roc-pdf-file-upload
                  key="ROCPDFFILEUPLOADSITUATIONDESCCONDITIONFILEKEY"
                  v-model="addPageFormObj.formModel.conditionFile"
                  upload-file-title="情况说明"
                ></roc-pdf-file-upload>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item
                label="问题类型："
                prop="sort"
                class="situationdesc-addpage-form-processnode"
              >
                <el-radio-group v-model="addPageFormObj.formModel.questionType">
                  <el-radio label="1">流程节点问题</el-radio>
                  <el-radio label="0">其他问题</el-radio>
                </el-radio-group>
                <template v-if="addPageFormObj.formModel.questionType === '0'">
                  <el-input
                    type="textarea"
                    clearable
                    maxlength="300"
                    show-word-limit
                    :autosize="{ minRows: 6}"
                    placeholder="请输入内容"
                    v-model="addPageFormObj.formModel.remark"
                  />
                </template>
                <template v-else-if="addPageFormObj.formModel.questionType === '1'">
                  <el-checkbox-group
                    v-model="addPageFormObj.formModel.checkList"
                    style="width: 100%;"
                  >
                    <el-checkbox label="《入党积极分子、发展对象培养教育考察登记表》" style="width: 100%;">
                      <div class="processnode-circle">6</div>
                      <div class="processnode-label">《入党积极分子、发展对象培养教育考察登记表》</div>
                    </el-checkbox>
                    <el-checkbox label="支委会拟接收预备党员审查会议记录和上报的预审请示" style="width: 100%;">
                      <div class="processnode-circle">13</div>
                      <div class="processnode-label">支委会拟接收预备党员审查会议记录和上报的预审请示</div>
                    </el-checkbox>
                  </el-checkbox-group>
                </template>
                <template v-else>
                  <div>&nbsp;</div>
                </template>
              </el-form-item>
            </el-col>
            <!-- <el-col :span="24">
              <el-form-item
                label="说明了以下流程节点问题:"
                prop="sort"
                class="situationdesc-addpage-form-processnode"
              ></el-form-item>
            </el-col>-->
          </el-row>
        </el-form>
        <div class="pagefooter-btngroup">
          <el-button
            type="rocpartyprimaryplainbtn"
            icon="el-icon-circle-close"
            @click="handleAddpageCloseClick"
          >取 消</el-button>
          <el-button
            type="rocpartyprimarybtn"
            icon="el-icon-circle-check"
            @click="handleAddpageSubmitClick"
          >确 定</el-button>
        </div>
      </div>
    </template>
    <template v-else-if="pageType === 'VIEW'">
      <div class="situationdesc-viewpage">
        <el-form
          ref="situationDescViewpageFormRef"
          :model="viewPageFormObj.formModel"
          label-width="190px"
          class="situationdesc-viewpage-form"
        >
          <el-row>
            <el-col :span="24">
              <div class="situationdesc-viewpage-title">
                <div>
                  <img
                    :src="require('@/assets/logo/home-main-title-logo.png')"
                    @error="imgViewerOnerror"
                  />
                </div>
                <div>情况说明会详情</div>
              </div>
            </el-col>
            <el-col :span="24">
              <div class="situationdesc-viewpage-line"></div>
            </el-col>
            <el-col :span="24">
              <el-form-item label="情况说明时间：" prop="beginTime">
                <div>{{ viewPageFormObj.formModel.beginTime }}</div>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="情况说明人:" prop="explainer">
                <div>{{ viewPageFormObj.formModel.explainer }}</div>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="情况说明：" prop="phone">
                <div class="situationdesc-viewpage-form-desc">
                  <div @click="handleViewPageCheckClick">查看</div>
                  <div @click="handleViewPageDownloadClick">下载</div>
                </div>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item
                label="说明了以下流程节点问题:"
                prop="sort"
                class="situationdesc-viewpage-form-processnode"
              >
                <el-checkbox-group v-model="viewPageFormObj.formModel.checkList">
                  <el-checkbox label="《入党积极分子、发展对象培养教育考察登记表》" disabled>
                    <div class="processnode-circle">6</div>
                    <div class="processnode-label">《入党积极分子、发展对象培养教育考察登记表》</div>
                  </el-checkbox>
                  <el-checkbox label="支委会拟接收预备党员审查会议记录和上报的预审请示" disabled>
                    <div class="processnode-circle">13</div>
                    <div class="processnode-label">支委会拟接收预备党员审查会议记录和上报的预审请示</div>
                  </el-checkbox>
                </el-checkbox-group>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <div class="pagefooter-btngroup">
          <el-button
            type="rocpartyprimaryplainbtn"
            icon="el-icon-circle-close"
            @click="handleViewPageCloseClick"
          >关 闭</el-button>
        </div>
      </div>
    </template>
    <template v-else>
      <div>&nbsp;</div>
    </template>
  </div>
</template>

<script>
import {
  listSituationDesc,
  viewSituationDesc,
  addSituationDesc
} from "@/api/PartyBuildingMgr/SituationDesc";
import {
  getFullPartyMemberOptions
} from "@/api/PartyBuildingMgr/FullPartyMember";

export default {
  name: "Situationdesc",
  components: {
    'roc-pdf-file-upload': () => import('@/components/RocPdfFileUpload')
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      pageType: 'LIST',
      // 情况说明人选项列表
      situationExplainerOptions: [],
      total: 10,
      queryParams: {
        pageNum: 0,
        pageSize: 10
      },
      list: [
        {
          name: '张三'
        },
        {
          name: '李四'
        }
      ],
      /** 新增或编辑弹框 */
      addPageFormObj: {
        formModel: {
          checkList: []
        },
        formRules: {
          sort: [{ required: true, message: '排序不能为空！', trigger: ['blur', 'change'] }],
          bannerUrl: [{ required: true, message: '封面图片不能为空！', trigger: 'change' }]
        }
      },
      viewPageFormObj: {
        formModel: {
          checkList: []
        }
      },
      pdfDialogVisible: false
    };
  },
  created() {
    this.initData();
  },
  methods: {
    /**
    * 初始化数据
    */
    initData() {
      this.getList();
    },
    /**
    * 获取表格数据
    */
    getList() {
      this.loading = true;
      listSituationDesc(this.queryParams).then(
        response => {
          this.list = response.rows || [];
          this.total = response.total ?? 0;
          this.loading = false;
        }
      );
    },
    /**
     * 获取情况说明人选项列表
     */
    async getSituationExplainerOptions() {
      await getFullPartyMemberOptions().then(
        response => {
          this.situationExplainerOptions = response.rows || [];
        }
      );
    },
    /**
    * 搜索按钮事件
    */
    handleQueryClick() {
      this.initData();
    },
    /**
    * 重置按钮事件
    */
    resetQueryClick() {
      this.resetForm("queryForm");
      this.handleQueryClick();
    },
    /**
    * 新增按钮事件
    */
    async handleAddClick() {
      await this.getSituationExplainerOptions();
      this.pageType = 'ADD';
    },
    /**
    * 详情按钮事件
    */
    handleViewClick(row) {
      this.pageType = 'VIEW';
    },
    /**
    * 新增页面确定按钮事件
    */
    handleAddpageSubmitClick() {
      this.pageType = 'LIST';
    },
    /**
    * 新增页面取消按钮事件
    */
    handleAddpageCloseClick() {
      this.addPageFormObj.formModel = {};
      this.resetForm('situationDescAddpageFormRef');
      this.pageType = 'LIST';
    },
    /**
     * 详情页面查看按钮事件
     */
    handleViewPageCheckClick() {
    },
    /**
     * 详情页面下载按钮事件
     */
    handleViewPageDownloadClick() {
    },
    /**
     * 详情页面关闭按钮事件
     */
    handleViewPageCloseClick() {
      this.pageType = 'LIST';
    }
  }
};
</script>

<style  lang="scss" scoped>
.situationdesc {
  .situationdesc-main {
    padding: 20px 20px 72px;
    min-height: 750px;
    background: url("../../../assets/images/home-head-img.png"), #ffffff;
    background-size: 67px 67px, cover;
    background-position: right 20px bottom 5px, center;
    background-repeat: no-repeat, no-repeat;
    border-radius: 10px;

    &-title {
      display: flex;
      align-items: center;

      div {
        &:first-child {
          height: 37px;
          line-height: 37px;
        }

        &:last-child {
          margin-left: 15px;
          height: 37px;
          font-size: 26px;
          font-weight: 400;
          color: #4f4f4f;
          line-height: 37px;
          letter-spacing: 1px;
        }

        img {
          width: 34px;
          height: 34px;
        }
      }
    }

    &-tabs.el-tabs {
      margin-top: 20px;

      ::v-deep {
        .el-tabs__item {
          font-size: 18px;
          font-weight: 500;
          color: #4f4f4f;
          opacity: 0.9;
        }

        .el-tabs__active-bar {
          background-color: #de0010;
        }

        .el-tabs__item.is-active {
          color: #de0010;
          background: #f9e9ea;
        }
      }
    }

    &-table {
      ::v-deep {
        .situationdesc-table_header-row th.el-table__cell {
          background-color: #e5d4b4;
        }

        .el-table__row {
          background-color: #ffffff;
        }

        .el-table__row.el-table__row--striped {
          background-color: #f0f0f0;
        }
      }
    }
  }

  &-addpage {
    width: 100%;

    &-title {
      display: flex;
      align-items: center;
      margin-bottom: 5px;

      div {
        &:first-child {
          height: 37px;
          line-height: 37px;
        }

        &:last-child {
          margin-left: 15px;
          height: 37px;
          font-size: 26px;
          font-weight: 400;
          color: #4f4f4f;
          line-height: 37px;
          letter-spacing: 1px;
        }

        img {
          width: 34px;
          height: 34px;
        }
      }
    }

    &-line {
      width: 100%;
      height: 1px;
      background: #d8dce5;
      margin-bottom: 15px;
    }

    &-form {
      &-processnode {
        ::v-deep {
          .el-checkbox {
            display: flex;
            align-items: center;
            margin-bottom: 20px;

            .el-checkbox__input {
              display: flex;
              align-items: center;
              justify-content: center;
              height: 24px;
              line-height: 24px;
            }

            .el-checkbox__label {
              display: flex;
              align-items: center;
            }
          }
        }
        .processnode-circle {
          display: flex;
          align-items: center;
          justify-content: center;
          width: 24px;
          height: 24px;
          font-size: 14px;
          color: #323232;
          background: #ffffff;
          border: 1px solid #323232;
          border-radius: 50%;
          line-height: 24px;
          opacity: 0.9;
        }

        .processnode-label {
          display: flex;
          align-items: center;
          margin-left: 5px;
          height: 24px;
          font-size: 16px;
          font-weight: 400;
          color: #333333;
          line-height: 20px;
          opacity: 0.9;
        }
      }
    }
  }

  &-viewpage {
    width: 100%;

    &-title {
      display: flex;
      align-items: center;
      margin-bottom: 5px;

      div {
        &:first-child {
          height: 37px;
          line-height: 37px;
        }

        &:last-child {
          margin-left: 15px;
          height: 37px;
          font-size: 26px;
          font-weight: 400;
          color: #4f4f4f;
          line-height: 37px;
          letter-spacing: 1px;
        }

        img {
          width: 34px;
          height: 34px;
        }
      }
    }

    &-line {
      width: 100%;
      height: 1px;
      background: #d8dce5;
      margin-bottom: 15px;
    }

    &-form {
      &-desc {
        display: flex;
        align-items: center;
        width: 100%;
        height: 36px;
        line-height: 36px;

        div {
          display: flex;
          align-items: center;
          justify-content: center;
          height: 36px;
          font-weight: 400;
          font-style: normal;
          font-size: 18px;
          color: rgba(24, 144, 255, 0.996);
          line-height: 36px;
          cursor: pointer;

          &:last-child {
            margin-left: 20px;
          }

          &:hover {
            text-decoration: underline;
          }
        }
      }

      &-processnode {
        ::v-deep {
          .el-checkbox {
            display: flex;
            align-items: center;

            .el-checkbox__input {
              display: flex;
              align-items: center;
              justify-content: center;
              height: 36px;
              line-height: 36px;
            }

            .el-checkbox__label {
              display: flex;
              align-items: center;
            }

            &.is-disabled {
              cursor: not-allowed;
            }
          }
        }
        .processnode-circle {
          display: flex;
          align-items: center;
          justify-content: center;
          width: 24px;
          height: 24px;
          font-size: 14px;
          color: #323232;
          background: #ffffff;
          border: 1px solid #323232;
          border-radius: 50%;
          line-height: 36px;
          opacity: 0.9;
        }

        .processnode-label {
          display: flex;
          align-items: center;
          margin-left: 5px;
          height: 36px;
          font-size: 16px;
          font-weight: 400;
          color: #333333;
          line-height: 36px;
          opacity: 0.9;
        }
      }
    }
  }
}
</style>