<template xmlns="">
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" v-if="!isEmployee" label-width="80px">
      <el-form-item label="部门名称" prop="deptName">
        <el-input
          v-model="queryParams.deptName"
          placeholder="请输入部门名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="职工姓名" prop="empName">
        <el-input
          v-model="queryParams.empName"
          placeholder="请输入职工姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
<!--      <el-form-item label="工号" prop="wordId">
        <el-input
          v-model="queryParams.wordId"
          placeholder="请输入工号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
      <el-form-item>
        <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-form>

<!--
    <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="['kaohe:employee:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['kaohe:employee:edit']"
        >修改</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="['kaohe:employee:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="info" plain
                   icon="el-icon-upload2"
                   size="mini"
                   @click="handleImport" v-hasPermi="['kaohe:employee:import']">导入</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['kaohe:employee:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
-->

    <el-table v-loading="loading" :data="employeeList" @selection-change="handleSelectionChange">
<!--      <el-table-column type="selection" width="55" align="center" fixed/>-->
      <!--      <el-table-column label="主键" align="center" prop="id" fixed/>-->
<!--      <el-table-column label="工号" align="center" prop="wordId" fixed/>-->
<!--      <el-table-column label="所属部门" align="center" prop="deptId" :show-overflow-tooltip="true" min-width="120"/>-->
      <el-table-column label="部门名称" align="center" prop="deptName"/>
      <el-table-column label="职工姓名" align="center" prop="empName"/>
<!--      <el-table-column label="性别" align="center" prop="sex" :show-overflow-tooltip="true" min-width="120">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_user_sex" :value="scope.row.sex"/>
        </template>
      </el-table-column>
      <el-table-column label="年龄" align="center" prop="age" />
      <el-table-column label="身份" align="center" prop="position" />-->
      <el-table-column label="附件" align="center" prop="docs">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            v-hasPermi="['kaohe:employee:query']"
            @click="viewFuJian(scope.row)"
          >详情</el-button>
        </template>
      </el-table-column>
<!--      <el-table-column label="手机号" align="center" prop="phone" />
      <el-table-column label="身份证号" align="center" prop="idcard" />
      <el-table-column label="银行卡号" align="center" prop="bankCardNumber" />
      <el-table-column label="开户行" align="center" prop="openingBank" />
      <el-table-column label="学历" align="center" prop="education" />
      <el-table-column label="家庭住址" align="center" prop="address" :show-overflow-tooltip="true" min-width="120"/>
      <el-table-column label="紧急联系人" align="center" prop="contact" :show-overflow-tooltip="true" min-width="120"/>
      <el-table-column label="紧急联系人电话" align="center" prop="contactPhone" :show-overflow-tooltip="true" min-width="120"/>
      <el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" min-width="120"/>-->
<!--      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="140px">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['kaohe:employee:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['kaohe:employee: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"
    />

    <!-- 添加或修改职工信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="900px" append-to-body :close-on-click-modal="false">
      <el-form ref="form" :model="form" :rules="rules" label-width="110px">
        <el-row :gutter="10">
          <el-col :span="12">
            <el-form-item label="工号" prop="wordId">
              <el-input v-model="form.wordId" placeholder="请输入工号" :disabled="isEmployee"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="所属部门" prop="deptId">
              <treeselect v-model="form.deptId" :options="deptOptions" placeholder="请选择所属部门" :disabled="isEmployee"
                          :show-count="true" @select="changeDept"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="12">
            <el-form-item label="职工姓名" prop="empName">
              <el-input v-model="form.empName" placeholder="请输入职工姓名" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="年龄" prop="age">
              <el-input v-model="form.age" placeholder="请输入年龄" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="12">
            <el-form-item label="身份" prop="position">
              <el-input v-model="form.position" placeholder="请输入年龄" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="性别" prop="sex">
              <el-select v-model="form.sex" placeholder="请选择性别" style="width: 100%;">
                <el-option
                  v-for="dict in dict.type.sys_user_sex"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="12">
            <el-form-item label="手机号" prop="phone">
              <el-input v-model="form.phone" placeholder="请输入手机号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="身份证号" prop="idcard">
              <el-input v-model="form.idcard" placeholder="请输入身份证号" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="12">
            <el-form-item label="银行卡号" prop="bankCardNumber">
              <el-input v-model="form.bankCardNumber" placeholder="请输入银行卡号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="开户行" prop="openingBank">
              <el-input v-model="form.openingBank" placeholder="请输入开户行" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="12">
            <el-form-item label="学历" prop="education">
              <el-input v-model="form.education" placeholder="请输入学历" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="家庭住址" prop="address">
              <el-input v-model="form.address" placeholder="请输入家庭住址" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="12">
            <el-form-item label="紧急联系人" prop="contact">
              <el-input v-model="form.contact" placeholder="请输入紧急联系人" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="紧急联系人电话" prop="contactPhone">
              <el-input v-model="form.contactPhone" placeholder="请输入紧急联系人电话" />
            </el-form-item>
          </el-col>
          <el-col :span="12"></el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="12">
            <el-form-item label="备注" prop="remark">
              <el-input v-model="form.remark" type="textarea" 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>

    <!-- 用户导入对话框 -->
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body :close-on-click-modal="false">
      <el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers" :action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading" :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <div class="el-upload__tip" slot="tip">
            <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据
          </div>
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline" @click="importTemplate">下载模板</el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 附件详情对话框 -->
<!--    <el-dialog title="附件详情" :visible.sync="uploadFJ.open" width="900px" append-to-body :close-on-click-modal="false">

      <div v-for="item in uploadFJ.docDiscripList">
        <el-row :gutter="20">
          <el-col :span="3" style="text-align: right;">
            <div class="my_required" style="margin-top: 10px;">附件主题</div>
          </el-col>
          <el-col :span="20">
            <el-input v-model.trim="item.title" placeholder="请输入附件主题" disabled/>
          </el-col>
        </el-row>
        <el-row :gutter="20" style="margin-top: 10px;">
          <el-col :span="3" style="text-align: right;">
            <div class="my_required" style="margin-top: 10px;">附件简介</div>
          </el-col>
          <el-col :span="20">
            <el-input type="textarea" v-model.trim="item.docDiscrip" placeholder="请输入附件简介" disabled/>
          </el-col>
        </el-row>
      </div>
      <div class="_con">
        <div class="left">
          <el-card style="margin-bottom: 10px;">
            <div slot="header">
              <span>已有附件</span>
            </div>
            <div v-for="(item,index) in uploadFJ.fileList" :key="item.url" class="yy_fj_list">
              <a :href="item.url" :download="item.name" target="_blank">{{ item.name }}</a>
              <i class="el-icon-close" @click="uploadFJListRemove(index)"></i>
            </div>
          </el-card>
        </div>
        <div class="right">
          <el-upload ref="uploadFJ" :limit="5" :headers="uploadFJ.headers" :action="uploadFJ.url" multiple
                     disabled :on-progress="fileUploadProgressFJ" :on-success="fileSuccessFJ"
                     :auto-upload="true" drag>
            <i class="el-icon-upload"></i>
            <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
          </el-upload>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="updateFileFJ" disabled>确定</el-button>
        <el-button @click="uploadFJ.open = false">取 消</el-button>
      </div>
    </el-dialog>-->

    <!-- 详情对话框 -->
    <el-dialog title="附件详情" :visible.sync="viewUploadFJ.open" append-to-body class="my_dialog">

      <el-row :gutter="20" v-for="item in viewUploadFJ.docDiscripList">
        <el-col :span="24">
          <span>附件主题：</span><span>{{ item.title }}</span>
        </el-col>
        <el-col class="mt10" :span="24">
          <span>附件简介：</span><span>{{ item.docDiscrip }}</span>
        </el-col>
      </el-row>

      <el-card style="margin-bottom: 10px;margin-top: 10px;">
        <div slot="header">
          <span>附件</span>
        </div>
        <div v-for="(item,index) in viewUploadFJ.fileList" :key="item.url" class="yy_fj_list1">
<!--          <a :href="item.url" :download="item.name" target="_blank">{{ item.name }}</a>-->
          <el-link type="primary" @click="downloadFJ(item)">{{ item.name }}</el-link>
        </div>
      </el-card>
      <div slot="footer" class="dialog-footer">
        <el-button @click="viewUploadFJ.open = false">取 消</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
import { listEmployee, getEmployee, delEmployee, addEmployee, updateEmployee, editEmployeeDocs } from "@/api/kaohe/employee";
import { getToken } from "@/utils/auth"
import { deptTreeSelect } from "@/api/system/user";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import axios from 'axios'

export default {
  name: "Employee",
  components: { Treeselect },
  dicts: ['sys_user_sex'],
  data() {
    return {
      isEmployee: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 职工信息表格数据
      employeeList: [],
      // 部门树选项
      deptOptions: undefined,
      // 用户导入参数
      upload: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/kaohe/employee/importData"
      },
      // 附件详情参数
      uploadFJ: {
        // 是否显示弹出层
        open: false,
        // 附件上传
        fileList: [],
        // 附件上传
        docDiscripList: [],
        // 是否禁用上传
        isUploading: false,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/common/upload"
      },
      // 修改内容行
      updataRow: {},
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userId: null,
        deptId: null,
        deptName: null,
        empName: null,
        wordId: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        deptId: [
          { required: true, message: "所属部门不能为空", trigger: "blur" }
        ],
        empName: [
          { required: true, message: "职工姓名不能为空", trigger: "blur" }
        ],
        wordId: [
          { required: true, message: "工号不能为空", trigger: "blur" }
        ],
      },
      // 附件详情参数
      viewUploadFJ: {
        // 是否显示弹出层
        open: false,
        // 附件上传
        fileList: [],
        // 附件上传
        docDiscripList: []
      },
    }
  },
  created() {
    let userInfo = this.$store.state.user
/*    if(userInfo.roles.length===1 && userInfo.roles[0]==='employee'){
      this.isEmployee = true;
      this.queryParams.wordId = userInfo.name
    }*/
    this.getList()
    // this.getDeptTree()
  },
  methods: {
    /** 查询职工信息列表 */
    getList() {
      this.loading = true;
      this.queryParams.remark='领导';
      listEmployee(this.queryParams).then(response => {
        /*let arr = ['金佳勇','单丽','靳铎','张杰','李建强','孙溢','马丽贞','王倞','安静','潘颖','马连营','朱玲','李爱民','隋雪莲','亓鋆',
          '冯春爽','徐铁红','王芊然','沈芝','高卫华','张青','李丽娜','王芳','王丽红','朱立明','刘建明','李丽山','杜学东','李诚','时代','张建环',
          '孟祥昕','吴海波','贾长胜','秦丹','董慧彬','杨长锁','马振','李敬华','刘继祥','李志伟','鲁芳','王芳','蔡建丰','常海龙','王建国','尹海',
          '刘云伟','陈伟莲','杜光熙','王文娟','黄静','唐翠云','霍翠红','曹丽君','王丹丹','刘冰怡','张志伟','王洋','杨焱','高一帆','王璐',
          '石野飞','檀艳','周庆平','刘梦','刘庆辉','朱艳伟','李雪梅','谷世海','侯宇','刘颖','郭海莉','于静','李旭','崔岩','郭小松','刘金玲',
          '陈克良','范永山','陈静','王英','马作东','沈方','石瑾','杜福光','白玉海','闫敬','张志宇','谌志鹏','蔡玉梅','安彬','刘凯','鲁丽丽',
          '刘肇民','宋晓敏','董怀晶','赵婉华','武炜','张琮','李晓萍','贾秀敏','李桃桃','郑向群','丁新龙','张海卿','崔乃忠','任翠香','李师广',
          '韩雅倩','杨玉娟','李远航','王学增','康晓梅','张运峰']  //领导
        let arr1 = []
        response.rows.forEach(item=>{
          if(arr.indexOf(item.empName) !== -1 && (item.wordId!='110009') && (item.wordId!='110009') && (item.wordId!='117014')){
            arr1.push(item)
          }
        })
        console.log(arr1);*/
        this.employeeList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    /** 查询部门下拉树结构 */
    getDeptTree() {
      deptTreeSelect().then(response => {
        this.deptOptions = response.data;

        console.log(this.deptOptions);
      });
    },
    /** 查询时选择部门 */
    changeDept(dept) {
      this.form.deptName = dept.label
    },
    // 取消按钮
    cancel() {
      this.open = false
      this.reset()
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        userId: null,
        deptId: null,
        deptName: null,
        empName: null,
        sex: null,
        age: null,
        wordId: null,
        position: null,
        docs: null,
        phone: null,
        idcard: null,
        bankCardNumber: null,
        openingBank: null,
        education: null,
        address: null,
        contact: null,
        contactPhone: 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.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
      getEmployee(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) {
            updateEmployee(this.form).then(response => {
              this.$modal.msgSuccess("修改成功")
              this.open = false
              this.getList()
            })
          } else {
            this.form.userId = this.$store.state.user.id
            addEmployee(this.form).then(response => {
              this.$modal.msgSuccess("新增成功")
              this.open = false
              this.getList()
            })
          }
        }
      })
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids
      this.$modal.confirm('是否确认删除该数据项？').then(function() {
        return delEmployee(ids)
      }).then(() => {
        this.getList()
        this.$modal.msgSuccess("删除成功")
      }).catch(() => {})
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('kaohe/employee/export', {
        ...this.queryParams
      }, `employee_${new Date().getTime()}.xlsx`)
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "用户导入"
      this.upload.open = true
    },
    /** 下载模板操作 */
    importTemplate() {
      this.download('kaohe/employee/importTemplate', {
      }, `职工模板_${new Date().getTime()}.xlsx`)
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false
      this.upload.isUploading = false
      this.$refs.upload.clearFiles()
      this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true })
      this.getList()
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit()
    },
    // 附件详情
    handleFuJian(row){
      this.updataRow = row;
      this.uploadFJ.fileList = [];
      this.uploadFJ.docDiscripList = [{
        title:'',
        docDiscrip:'',
      }];
      if(row.docs){
        let arr = row.docs.split(';');
        arr.forEach( item => {
          let arr1 = item.split(',');
          this.uploadFJ.fileList.push({
            name: arr1[0],
            url: arr1[1]
          });
        })
        this.uploadFJ.docDiscripList = JSON.parse(row.docDiscrip);
      }
      this.uploadFJ.open = true;
    },
    // 已有附件
    uploadFJListRemove(index){
      this.uploadFJ.fileList.splice(index, 1);
    },
    submitFileFormFJ(){
      this.$refs.uploadFJ.submit()
    },
    // 文件上传中处理
    fileUploadProgressFJ(event, file, fileList) {
      this.uploadFJ.isUploading = true
    },
    // 文件上传成功处理
    fileSuccessFJ(response, file, fileList) {
      this.uploadFJ.isUploading = false
    },
    updateFileFJ(){
      let flag = true;
      if(!this.uploadFJ.docDiscripList[0].title){
        flag = false;
        this.$alert(`附近主题不能为空`, `提示`, {
          type: 'warning'
        })
      }
      if(!this.uploadFJ.docDiscripList[0].docDiscrip){
        flag = false;
        this.$alert(`附近简介不能为空`, `提示`, {
          type: 'warning'
        })
      }
      if(flag){
        let uploadFiles = this.$refs.uploadFJ.$data.uploadFiles;
        let arr = []
        this.uploadFJ.fileList.forEach(item=>{
          arr.push(item.name+','+item.url);
        })
        uploadFiles.forEach( item => {
          arr.push(item.response.originalFilename+','+item.response.url);
        })
        this.updataRow.docs = arr.join(';');
        this.updataRow.docDiscrip =JSON.stringify(this.uploadFJ.docDiscripList);
        editEmployeeDocs(this.updataRow).then(response => {
          this.$modal.msgSuccess("修改成功");
          this.uploadFJ.open = false;
          this.$refs.uploadFJ.clearFiles();
          this.getList();
        })
      }
    },
    // 附件详情
    viewFuJian(row){
      this.viewUploadFJ.fileList = [];
      this.viewUploadFJ.docDiscripList = [{
        title:'',
        docDiscrip:'',
      }];
      if(row.docs){
        let arr = row.docs.split(';');
        arr.forEach( item => {
          let arr1 = item.split(',');
          this.viewUploadFJ.fileList.push({
            name: arr1[0],
            url: arr1[1]
          });
        })
        this.viewUploadFJ.docDiscripList = JSON.parse(row.docDiscrip);
      }
      this.viewUploadFJ.open = true;
    },
    // 下载
    downloadFJ(row){
      axios({
        url: row.url,
        method: 'get',
        responseType: 'blob'
      }).then(res => {
        const blob = new Blob([res.data], { type: res.headers['content-type'] });
        const fileName = row.name; // 根据实际需求动态生成
        const link = document.createElement('a');
        link.href = URL.createObjectURL(blob);
        link.download = fileName;
        document.body.appendChild(link);
        link.click();
        URL.revokeObjectURL(link.href);
        document.body.removeChild(link);
      }).catch(err => {
        console.error('下载失败', err);
      });
    }
  }
}
</script>

<style scoped lang="scss">
.el-dialog__body{

  .my_required:before{
    content: "*";
    color: #f56c6c;
    margin-right: 4px;
  }

  ._con{
    display: flex;
    justify-content: space-between;
    min-height: 400px;
    margin-top: 15px;

    .left{
      width: 480px;

      .yy_fj_list {
        display: flex;
        justify-content: space-between;
        align-items: center;
        height: 36px;
        border-bottom: 1px solid #39CCCC;

        i{
          cursor: pointer;
        }
      }
    }

    .right{
      width: 360px;
    }
  }

  .yy_fj_list1 {
    //height: 36px;
    line-height: 30px;
    border-bottom: 1px solid #39CCCC;
  }
}

@media (max-width: 757px){
  ::v-deep.my_dialog .el-dialog{
    width: 95% !important;
  }
}
</style>
