<template>
  <div class="app-container circleButton">
    <el-form :model="queryParams" ref="queryForm"  v-show="showSearch" label-width="100px"
             style="background-color: white;padding: 20px">

      <el-row>
        <el-col :span="8">
          <el-form-item   prop="title" label-width="100">
            <div style="float: left">
            <span slot="label" style="font-size: 18px;font-weight: 600">标题查询:</span>
            </div>
            <el-input style="width:260px;margin-right: 10px;margin-left: 10px"
              v-model="queryParams.title"
              placeholder="请输入标题"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
              @blur="handleQuery"
            />
            <el-button
              type="cyan"
              icon="el-icon-search"
              size="mini"
              @click="handleNameQuery"
            >图表</el-button
            >
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label-width="100" prop="userName">
            <div style="float: left;">
            <span slot="label" class="font">建议人:</span>
            </div>
            <el-input style="width:160px;margin-right: 10px;margin-left: 10px"
              v-model="queryParams.userName"
              placeholder="请输入建议人"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
              @blur="handleQuery"
            />
            <el-button
              type="cyan"
              icon="el-icon-search"
              size="mini"
              @click="handleQueryButton"
            >图表</el-button
            >
            <el-button type="info" icon="el-icon-upload2" size="mini" @click="handleImport"  class="button-import">导入</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery" >重置</el-button>
          </el-form-item>
        </el-col>



      </el-row>
      <el-row>
        <el-col :span="16">
          <el-form-item label-width="100" prop="year">
            <div class="lab">
            <span slot="label" class="font">项目年份:</span>
            </div>
            <el-radio-group v-model="queryParams.year" @change="handleQuery">
              <el-radio-button label="0" border><span class="fontT">全部</span></el-radio-button>
              <el-radio-button label="999" border ><span class="fontT">2016年至今</span></el-radio-button>
              <el-radio-button
                v-for="dict in yearOptions"
                :key="dict"
                :label="dict"
                border
              ><span class="fontT">{{ dict }}</span></el-radio-button
              >
              <el-radio-button label="2015" border><span class="fontT">2016年以前</span></el-radio-button>


            </el-radio-group>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label-width="100" prop="secretLevel">
            <div class="lab">
            <span slot="label" class="font">秘密级别:</span>
            </div>
            <el-radio-group v-model="queryParams.secretLevel" size="small" @change="handleQuery">
              <el-radio-button label="0" border><span class="fontT">全部</span></el-radio-button>
              <el-radio-button label="1" border><span class="fontT">机密</span></el-radio-button>
              <el-radio-button label="2" border><span class="fontT">秘密</span></el-radio-button>
              <el-radio-button label="4" border><span class="fontT">内部</span></el-radio-button>
              <el-radio-button label="3" border><span class="fontT">非密</span></el-radio-button>
            </el-radio-group>
          </el-form-item>
        </el-col>
      </el-row>
          <el-form-item label-width="100" prop="deptId">
            <div class="lab">   <span slot="label" class="font">联系部门:</span></div>

            <el-radio-group v-model="queryParams.deptId" size="small" @change="handleQuery">
              <el-radio-button label="0" border
              ><span class="fontT">全部</span></el-radio-button>
              <el-radio-button label="25" border
              ><span class="fontT">机械学部</span></el-radio-button
              >
              <el-radio-button label="26" border
              ><span class="fontT">信息学部</span></el-radio-button
              >
              <el-radio-button label="27" border
              ><span class="fontT">化工学部</span></el-radio-button
              >
              <el-radio-button label="28" border
              ><span class="fontT">能源学部</span></el-radio-button
              >
              <el-radio-button label="29" border
              ><span class="fontT">土木学部</span></el-radio-button
              >
              <el-radio-button label="30" border
              ><span class="fontT">环境学部</span></el-radio-button
              >
              <el-radio-button label="31" border><span class="fontT">农业学部</span></el-radio-button>
              <el-radio-button label="32" border><span class="fontT">医药学部</span></el-radio-button>
              <el-radio-button label="33" border><span class="fontT">工管学部</span></el-radio-button>
              <el-radio-button label="149" border><span class="fontT">战略咨询中心</span></el-radio-button>
              <el-radio-button label="998" border><span class="fontT">行业研究院</span></el-radio-button>
              <el-radio-button label="999" border><span class="fontT">其他</span></el-radio-button>
            </el-radio-group>
          </el-form-item>
      <el-row>
        <el-col :span="16">
          <el-form-item  prop="status" label-width="100">
            <div class="lab">   <span slot="label" class="font">批示状态:</span></div>
            <el-radio-group v-model="queryParams.status" size="small" @change="handleQuery">
              <el-radio-button label="0" border><span class="fontT">全部</span></el-radio-button>
<!--              <el-radio-button label="0" border>无批示</el-radio-button>-->
              <el-radio-button label="1" border><span class="fontT">有批示</span></el-radio-button>
            </el-radio-group>
          </el-form-item>
        </el-col>
      </el-row>

      <el-form-item>
      </el-form-item>
    </el-form>


    <div class="dtable" style="margin-top: 25px">

      <div style="height: 60px;background-color: rgb(242,247,253);margin-top: 20px;margin-bottom: 20px">
        <div style="background-color: rgb(18,107,199);height:100%;width: 4px;float: left;"></div>

          <h2 style="margin-bottom: 20px;position: relative ;top: 18px;margin-left: 20px" class="color333" >
            <span>上报院士建议&nbsp;&nbsp;:&nbsp;&nbsp;<span style="color: #ce2700">{{proposal}}</span></span>
            <span style="margin-left: 20px">得到批示&nbsp;&nbsp;:&nbsp;&nbsp;<span style="color: #ce2700">{{instructions}}</span></span>
          </h2>


      </div>



      <el-table v-loading="loading"  :data="instructionList" @selection-change="handleSelectionChange"
                :header-cell-style="{background:'#fff'}"
                :row-class-name="tableRowClassName" >
        <el-table-column label="序号" align="center" type="index" width="65" />
        <el-table-column label="年度" align="left" prop="year" width="80" />
        <el-table-column label="期数" align="left" prop="num" width="70" />
        <el-table-column label="总期数" align="left" prop="totalNum" width="100" />
        <el-table-column label="标题" align="left" prop="title" width="380" />
        <el-table-column label="密级" align="left" prop="secretLevel" :formatter="secretFormat" width="130"/>
        <el-table-column label="保密期限" align="left" prop="secretYear" width="110" />
        <el-table-column label="建议人" align="left" prop="userName" width="350" />
        <el-table-column label="学部" align="left" prop="deptName" />
        <el-table-column label="印发日期" align="left" prop="printDate" width="130">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.printDate, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
       <!-- <el-table-column label="批示情况" align="center" prop="status" width="180">
          <template slot-scope="scope">
            <span v-if="scope.row.status == '0'">无批示</span>
            <span v-else-if="scope.row.status == '1'">有批示</span>
          </template>
        </el-table-column>-->
        <el-table-column label="附件" align="left" :show-overflow-tooltip="true" width="110" >
          <!--        <template slot-scope="scope" v-if="scope.row.annexName != null">-->
          <template slot-scope="scope" v-if="scope.row.adviseFile != null &&scope.row.adviseFile != '[]'">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="viewAnnexAdviseFileFile(scope.row)"
            >附件下载</el-button>
          </template>
        </el-table-column>
        <el-table-column label="批示情况" align="left" prop="instructions" />
       <!-- <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:instruction:edit']"
            >修改</el-button>
            <el-button
              size="mini"
              type="text"
              icon="el-icon-delete"
              @click="handleDelete(scope.row)"
              v-hasPermi="['system:instruction:remove']"
            >删除</el-button>
          </template>
        </el-table-column>-->
      </el-table>

    </div>
    <div class="explore_right_pages" style="background-color: white;height: 70px;border: 1px solid white">
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </div>
    <!-- 添加或修改【请填写功能名称】对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="110px">
        <el-form-item label="年度" prop="year">
          <el-input v-model="form.year" placeholder="请输入年度" />
        </el-form-item>
        <el-form-item label="期数" prop="num">
          <el-input v-model="form.num" placeholder="请输入期数" />
        </el-form-item>
        <el-form-item label="期数" prop="totalNum">
          <el-input v-model="form.totalNum" placeholder="请输入期数" />
        </el-form-item>
        <el-form-item label="标题" prop="title">
          <el-input v-model="form.title" placeholder="请输入标题" />
        </el-form-item>
        <el-form-item label="密级" prop="secretLevel">
          <el-select v-model="form.secretLevel" placeholder="请输入密级" clearable  style="width: 220px">
            <el-option
              v-for="dict in secretOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="保密期限" prop="secretYear">
          <el-input v-model="form.secretYear" placeholder="请输入保密期限" />
        </el-form-item>
        <el-form-item label="建议人" prop="userName">
          <el-input v-model="form.userName" placeholder="请输入建议人" />
        </el-form-item>
        <el-form-item label="部门id" prop="deptId">
          <el-input v-model="form.deptId" placeholder="请输入部门id" />
        </el-form-item>
        <el-form-item label="学部" prop="deptName">
          <el-input v-model="form.deptName" placeholder="请输入学部" />
        </el-form-item>
        <el-form-item label="印发日期" prop="printDate">
          <el-date-picker clearable size="small" style="width: 200px"
            v-model="form.printDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择印发日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="批示情况"  prop="status" >
          <el-select v-model="form.status" placeholder="请输入密级" clearable  style="width: 220px">
            <el-option label="未选择" value="" />
            <el-option label="有批示" value="1" />
            <el-option label="无批示" value="0" />
          </el-select>
        </el-form-item>
        <el-form-item label="附件" prop="adviseFile" style="width: 220px">
          <el-upload
            ref="upload2"
            multiple
            :action="upload2.url"
            :headers="upload2.headers"
            :on-remove="handle_remove2"
            :file-list="upload2.fileList"
            :on-preview="handlePreview2"
            :on-progress="handleFileUploadProgress2"
            :on-success="handleFileSuccess2"
            :auto-upload="true">
            <el-button slot="trigger"  type="primary">上传文件</el-button>
          </el-upload>
        </el-form-item>

<!--        <el-form-item label="批示情况" prop="remark">-->
<!--          <el-input v-model="form.remark" placeholder="请输入备注" />-->
<!--        </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>
    <el-dialog title="附件" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload
        ref="upload"
        disabled
        :action="upload.url"
        :headers="upload.headers"
        :file-list="upload.fileList"
        :on-preview="handlePreview"
      >
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="upload.open = false">关 闭</el-button>
      </div>
    </el-dialog>
    <el-dialog title="附件" :visible.sync="upload2.open" width="400px" append-to-body>
      <el-upload
        ref="upload2"
        disabled
        :action="upload2.url"
        :headers="upload2.headers"
        :on-remove="handle_remove2"
        :file-list="upload2.fileList"
        :on-preview="handlePreview2"
        :on-progress="handleFileUploadProgress2"
        :on-success="handleFileSuccess2"
      >
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="upload2.open = false">关 闭</el-button>
      </div>
    </el-dialog>
    <el-dialog :title="uploadProject.title" :visible.sync="uploadProject.open" width="400px" append-to-body>
      <el-upload ref="uploadProject"
                 :limit="1"
                 accept=".xls,.xlsx"
                 :headers="uploadProject.headers"
                 :action="uploadProject.url + '?updateSupport=' + uploadProject.updateSupport"
                 :disabled="uploadProject.isUploading"
                 :on-progress="handleProjectFileUploadProgress"
                 :on-success="handleProjectFileSuccess"
                 :before-upload="beforeProjectFileUpload"
                 :auto-upload="false" drag>
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>
        <div class="el-upload__tip" slot="tip">
          <!--<el-checkbox v-model="uploadProject.updateSupport" />是否更新已经存在的用户数据-->
          <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
        </div>
        <div class="el-upload__tip" style="color:red" slot="tip">提示：仅允许导入excel文件！</div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="uploadProject.open = false">取 消</el-button>
      </div>
    </el-dialog>


    <el-dialog  :modal="false" title="" :show-close="false" :close-on-click-modal="false" :visible="nameTuOpen" width="600px" class="rightDialog"    >
      <el-row>
        <el-col >
          <div class="chart-wrapper" >
            <!-- <raddar-chart /> -->
            <DuidieChart :ddXData="ddX" :ddLgData="ddLg" :ddSerData="ddSer" />
          </div>
        </el-col>
      </el-row>
      <br/><br/>
      <el-row>
        <el-col >
          <div class="chart-wrapper">
            <PieChart :deptLg="deptLg" :otTitle="otTitle" :deptData="deptData" />
          </div>
        </el-col>
      </el-row>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="nameTuOpen = false">关 闭</el-button>
      </div>
    </el-dialog>
    <el-dialog :modal="false" title="" :show-close="false" :close-on-click-modal="false" :visible="userNameTuOpen" width="600px" class="rightDialog"  append-to-body>

      <el-row>
        <el-col>
          <div class="chart-wrapper">
            <AdviseNameChart :xAxisDataLeft8="xAxisCenter8" :otTitle="otTitle"  :seriesDataLeft8="seriesCenter8"/>
          </div>
        </el-col>
      </el-row>

      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="userNameTuOpen = false">关 闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import DuidieChart from "../../dashboard/DuidieChart";
  import PieChart from "../../dashboard/DeptPieChart";
  import AdviseNameChart from "../../dashboard/AdviseNameChart";
  import {statistics} from "@/api/project/info3";
  import { leftData1,center2Data,importTemplate,center8Data,listInstruction, getInstruction, delInstruction, addInstruction, updateInstruction, exportInstruction } from "@/api/project/instruction";
  import {getToken} from "@/utils/auth";
export default {
  name: "Instruction",
  components: {
    DuidieChart,
     PieChart,
    AdviseNameChart,
  },
  data() {
    return {
      proposal:null,
      instructions:null,
      // 上传参数
      uploadProject: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API +"/system/instruction/importData",
      },
      // 上传参数
      upload: {
        title: "",
        open: false,
        // 是否禁用上传
        isUploading: false,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/project/info/common/upload",
        // 上传的文件列表
        fileList: [],
      },
      // 上传参数
      upload2: {
        title: "",
        open: false,
        // 是否禁用上传
        isUploading: false,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/system/info/common/upload",
        // 上传的文件列表
        fileList: [],
      },
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 【请填写功能名称】表格数据
      instructionList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      nameTuOpen:false,
      userNameTuOpen:false,
      yearOptions: [],
      ddX:[],
      ddLg:[],
      ddSer:[],
      deptLg:[],
      deptData:[],
      seriesCenter8:[],
      xAxisCenter8:[],
      secretOptions :[],
      otTitle:"",
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        year: null,
        num: null,
        totalNum: null,
        title: null,
        secretLevel: null,
        secretYear: null,
        userName: null,
        deptId: null,
        deptName: null,
        printDate: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    if (this.$route.query.yearRadio2){
      this.queryParams.year=this.$route.query.yearRadio2;
      this.queryParams.status = "1";
    }else {
      this.queryParams.year = "0" ;
      this.queryParams.status = "0" ;
    }
    if (this.$route.query.userName){
      this.queryParams.userName=this.$route.query.userName;

    }
    var date = new Date();
    var year = date.getFullYear();

    this.yearOptions[0] = year;
    this.yearOptions[1] = year - 1;
    this.yearOptions[2] = year - 2;
    this.yearOptions[3] = year - 3;
    this.yearOptions[4] = year - 4;
    this.yearOptions[5] = year - 5;

    this.queryParams.deptId = "0" ;
    this.queryParams.secretLevel = "0" ;
    //
    // this.getLeft1();
    // this.getCenter2(this.queryParams);
    // this.getCenter8(this.queryParams);
    this.getList();
    this.getDicts("pro_secret_level").then(response => {
      this.secretOptions = response.data;
    });
  },
  methods: {
    tableRowClassName({ row, rowIndex }) {
      if ((rowIndex + 1) % 2 === 0) {
        return "warning-row"; //类名
      } else {
        return "success-row"; //类名
      }
    },
    getStatistics(queryParams){

      statistics(queryParams).then(resp=>{
        this.proposal=resp.data.proposal;
        this.instructions=resp.data.instructions;

      });
    },
    handleQueryButton() {
      this.userNameTuOpen=true;
      this.queryParams.pageNum = 1;
      this.getCenter8(this.queryParams);
      this.getList();
    },
    handleNameQuery(){
      this.nameTuOpen = true;
      this.queryParams.pageNum = 1;
      this.getList();
      this.getLeft1();
      this.getCenter2(this.queryParams);
    },
    /** 导入按钮操作 */
    handleImport() {
      this.uploadProject.title = "项目导入";
      this.uploadProject.open = true;
    },

    // 文件上传中处理
    handleProjectFileUploadProgress(event, file, fileList) {
      this.uploadProject.isUploading = true;
    },
    beforeProjectFileUpload(file) {
      const isLt200M = file.size / 1024 / 1024 < 300;
      if (!isLt200M) {
        this.$message.error('上传大小不能超过 200MB!');
      }
      return isLt200M;
    },
    // 文件上传成功处理
    handleProjectFileSuccess(response, file, fileList) {
      this.uploadProject.open = false;
      this.uploadProject.isUploading = false;
      this.$refs.uploadProject.clearFiles();
      this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs.uploadProject.submit();
    },
    importTemplate() {
      importTemplate().then((response) => {
        this.download(response.msg);
      });
    },

    secretFormat(row, column) {
      return this.selectDictLabel(this.secretOptions, row.secretLevel);
    },
    getLeft1(){
      leftData1().then(rsp => {
        this.ddX = rsp.data.yearArray;
        this.ddLg =  ['有批示', '无批示'];
        let temp = [];
        let item = {};
        item.name = '有批示';
        item.type = 'bar';
        item.stack= 'one';
        item.data = rsp.data.youArray;
        item.itemStyle={
          normal: {
            //这里是重点
            color: '#5470c6'
          }

        };
        temp.push(item);
        let item2 = {};
        item2.name = '无批示';
        item2.type = 'bar';
        item2.stack= 'one';
        item2.data = rsp.data.wuArray;
        item2.itemStyle={
          normal: {
            //这里是重点
            color: '#ffa200'
          }

        };
        temp.push(item2);
        this.ddSer = temp
      });
    },
    getCenter2(queryParam){
      center2Data(queryParam).then(resp => {
        if(!queryParam.year || queryParam.year=='0'){
          this.otTitle = ''
        }
        else if(queryParam.year =='2015'){
          this.otTitle="2016年以前"
        }else if(queryParam.year =='999'){
          this.otTitle="2016-今"
        }else{
          this.otTitle=queryParam.year +"年"
        }

        this.deptLg = resp.data.lgData;
        this.deptData=resp.data.pieData;
      })
    },
    getCenter8(queryParams){
      center8Data(queryParams).then(
        resp => {
          if(!queryParams.year || queryParams.year=='0'){
            this.otTitle = ''
          }
          else if(queryParams.year =='2015'){
            this.otTitle="2016年以前"
          }else if(queryParams.year =='999'){
            this.otTitle="2016-今"
          }else{
            this.otTitle=queryParams.year +"年"
          }
          this.seriesCenter8 = resp.data.xAxisArray;
          this.xAxisCenter8 = resp.data.yAxisArray;
        }
      );
    },
    /** 查询【请填写功能名称】列表 */
    getList() {
      this.loading = true;
      listInstruction(this.queryParams).then(response => {
        this.instructionList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
      this.getStatistics(this.queryParams)
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        year: null,
        num: null,
        totalNum: null,
        title: null,
        secretLevel: null,
        secretYear: null,
        userName: null,
        deptId: null,
        deptName: null,
        printDate: null,
        remark: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        delFlag: null,
        adviseFilePath:null,
        adviseFile:null,
        status:null
      };
      this.upload2.fileList = [];
      this.resetForm("form");
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
      this.getLeft1();
      this.getCenter2(this.queryParams);
      this.getCenter8(this.queryParams);
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.queryParams.status = "0" ;
      this.queryParams.deptId = "0" ;
      this.queryParams.secretLevel = "0" ;
      this.queryParams.year = "0" ;
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id);
      this.single = selection.length!==1;
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加院士建议";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getInstruction(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改院士建议";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateInstruction(this.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              }
            });
          } else {
            addInstruction(this.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              }
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm('是否确认删除【请填写功能名称】编号为"' + ids + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delInstruction(ids);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(function() {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有【请填写功能名称】数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportInstruction(queryParams);
        }).then(response => {
          this.download(response.msg);
        }).catch(function() {});
    },
    viewAnnexAdviseFileFile(row){
      this.upload.fileList = [];
      this.formatUploadAnnex(row.adviseFile,row.adviseFilePath);
      this.upload.open = true;
    },
    //格式化上传附件
    formatUploadAnnex(annexName,annexPath){
      this.upload.fileList = [];
      if (annexPath != null && annexPath !== ''){
        let a = [],b = [];
        try {
          a = JSON.parse(annexName) ;
          b = JSON.parse(annexPath) ;
        }catch (e){
          a=[];
          b=[];
        }
        for (let i = 0;i<a.length;i++){
          this.upload.fileList.push({
            'name':a[i],
            'url':process.env.VUE_APP_BASE_API + b[i]
          })
        }
      }else {
        this.upload.fileList = [];
      }


    },
    handlePreview(file) {
      var a = document.createElement('a');
      var event = new MouseEvent('click');
      a.download = file.name;
      a.target = '_blank';
      a.href = file.url;
      a.dispatchEvent(event);

    },
    formatUploadAnnex2(annexName,annexPath){
      this.upload2.fileList = [];
      if (annexPath != null && annexPath != ''){
        let a = JSON.parse(annexName);
        let b = JSON.parse(annexPath);
        if (a == null){
          a = [];
          b = [];
        }
        for (let i = 0;i<a.length;i++){
          this.upload2.fileList.push({
            'name':a[i],
            'url':process.env.VUE_APP_BASE_API + b[i]
          })
        }
      }else {
        this.upload2.fileList = [];
      }


    },
    //查看成果
    viewAnnex2(row){
      this.upload2.fileList = [];
      this.formatUploadAnnex2(row.adviseFile,row.adviseFilePath);
      this.upload2.open = true;
    },
    handlePreview2(file) {
      var a = document.createElement('a');
      var event = new MouseEvent('click');
      a.download = file.name;
      a.target = '_blank';
      a.href = file.url;
      a.dispatchEvent(event);

    },
    handle_remove2(file, fileList,type) {
      var _tmp = this.upload2.fileList;
      for (var i = 0, len = _tmp.length; i < len; i++) {
        if (_tmp[i].name = file.name) {
          _tmp.splice(i, 1);
          break;
        }
      }
      this.upload2.fileList = _tmp;
      let a = [];
      let b = [];
      this.upload2.fileList.forEach(s=>{
        let url = s['url'];
        url = url.replace(process.env.VUE_APP_BASE_API ,'');
        a.push(s['name']);
        b.push(url);
      });
      this.form.adviseFile = JSON.stringify(a);
      this.form.adviseFilePath = JSON.stringify(b);
    },
    handleFileUploadProgress2(event, file, fileList) {
      this.upload2.isUploading = true;
    },
    handleFileSuccess2(response, file, fileList) {
      this.upload2.isUploading = false;
      let a = JSON.parse(this.form.adviseFile) ;
      let b = JSON.parse(this.form.adviseFilePath) ;
      if (a == null){
        a = [];
        b = [];
      }
      a.push(response.fileName);
      b.push(response.url);

      this.form.adviseFile = JSON.stringify(a);
      this.form.adviseFilePath = JSON.stringify(b);

      //  this.form.annexName = response.fileName;
      //  this.form.annexPath = response.url;
      this.msgSuccess(response.msg);
    },
  }
};
</script>
<style lang="scss" scoped>
  .app-container{
    background-color: rgb(246,247,251);
  }
  .circleButton {
    /deep/  .el-radio-button__inner {
      padding: 6px 17px;
      font-size: 12px;
      margin: 16px 10px 4px;
      border: 1px;
      border-radius: 17px  !important;
      /*background-color: #f2f1f5;*/
    }
    /deep/  .el-input__inner {
      border-color: #ddd !important;
      padding: 10px;
    }
    .el-form-item{
      margin-bottom: 0;
    }
    ::-webkit-input-placeholder {
      color: #999 !important;
      font-size: 16px;
    }
  }
  .explore_right_pages {


    /deep/.el-pagination .el-pagination__total {
      color: #999999;
      font-size: 18px;
    }

    /deep/.el-pagination .el-pagination__jump {
      color: #999999;
      font-size: 18px;

      .input{
        margin-left: 10px;
        margin-right: 10px;
      }
      .el-pagination__editor{
        margin-left: 10px;
        margin-right: 10px;
        .el-input__inner{
          height: 26px;
          margin-top: 2px;
        }
      }
    }



  }
  .rightDialog{
    right: 0;
    margin-right: 0;
    left:auto;
  }
  .fontT{
    font-size: 18px;
  }
  .lab{
    float: left;
    margin-top: 10px
  }
  .font{
       font-size: 18px;
       font-weight: 700;
     }
  /deep/ .dtable{
    border: 1px solid white;
    background-color: white;
    .el-table .warning-row {
      background: white;
    }

    .el-table .success-row {
      background: #f5f6fa;
    }
  }



</style>
