<template>
  <div>
    <a-form layout='vertical'>
      <a-spin :spinning="loading">
        <a-tabs v-model="tabName" type="card">
          <a-tab-pane
              :tab="$t('functional-analysis.property-modal.name')"
              key="name">
            <a-row :gutter='24'>
              <a-col :md="12" :sm="24">
                <a-form-item :label="$t('functional-analysis.property-modal.language')">
                  <a-select
                      @change="currentNlsChange"
                      :defaultValue="defaultNls">
                    <a-select-option
                        v-for="(item, index) in currentNls"
                        :key="index"
                        :value="item.lkey">
                      {{ $t('global-dict.select-nls.' + item.lkey) }}
                    </a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
            </a-row>
            <a-row :gutter='24'>
              <a-col :md="12" :sm="24">
                <a-form-item required :label="$t('functional-analysis.property-modal.name')">
                  <a-input v-model="name" :maxLength="1000" @change="nameChange"/>
                </a-form-item>
              </a-col>
            </a-row>
            <!-- 失效分类 -->
            <a-row :gutter='24'>
              <a-col :md="12" :sm="24">
                <a-form-item :label="$t('functional-analysis.property-modal.fault-classification')">
                  <a-input v-model="classify" :maxLength="32" :placeholder="$t('global-constant.please-enter') + $t('functional-analysis.property-modal.fault-classification')" />
                </a-form-item>
              </a-col>
            </a-row>
            <a-row :gutter='24'>
              <a-col :md="12" :sm="24">
                <a-form-item :label="$t('functional-analysis.property-modal.type')">
                  <a-radio-group name="sourceType" @change="typeRadioChange" :value="sourceType">
                    <a-radio :value="'01'">
                      {{ $t('functional-analysis.property-modal.potential-failure') }}
                    </a-radio>
                    <a-radio :value="'02'">
                      {{ $t('functional-analysis.property-modal.history-failure') }}
                    </a-radio>
                  </a-radio-group>
                </a-form-item>
              </a-col>
            </a-row>
          </a-tab-pane>
          <a-tab-pane
              :tab="$t('functional-analysis.property-modal.rating')"
              key="evaluate">
            <a-row :gutter='24'>
              <a-col :md="12" :sm="24">
                <a-form-item :label="$t('functional-analysis.property-modal.severity')">
                  <a-input-number
                      v-model="significInputVal"
                      :min="1"
                      :max="10"
                      @change="significInputValChange"/>
                </a-form-item>
              </a-col>
            </a-row>
            <a-table
                :data-source="significTableData"
                :columns="significTableColumns"
                :customRow="significCustomRow"
                class="evaluate"
                :rowKey="(row, index) => {return index;}"
                :row-selection="{
                type: 'radio',
                selectedRowKeys: significSelectedRowKeys,
                onChange: significRadioChange,
              }"
                bordered
                size="small"
                :scroll="{ y: 'calc(88vh - 400px)' }"
                :pagination="false">
            </a-table>
          </a-tab-pane>
          <a-tab-pane
              :tab="$t('functional-analysis.property-modal.user-defined-characteristics')"
              key="userDefinedProperties">
            <a-table
                :data-source="userTableData"
                :columns="userTableColumns"
                :customRow="userCustomRow"
                :rowKey="(row, index) => {return index;}"
                :row-selection="{
                selectedRowKeys: userSelectedRowKeys,
                onChange: userCheckboxChange
               }"
                bordered
                size="small"
                :scroll="{ y: 'calc(88vh - 400px)' }"
                :pagination="false"/>
          </a-tab-pane>
          <a-tab-pane
              :tab="$t('functional-analysis.property-modal.feature-classification')"
              key="featureClassification">
            <a-table
                :data-source="fcTableData"
                :columns="fcTableColumns"
                :customRow="fcCustomRow"
                class="featureClassification"
                :rowKey="(row, index) => {return index;}"
                :row-selection="{
                type: 'radio',
                selectedRowKeys: fcSelectedRowKeys,
                onChange: fcRadioChange
              }"
                bordered
                size="small"
                :scroll="{ y: 'calc(88vh - 400px)' }"
                :pagination="false">
            </a-table>
          </a-tab-pane>
          <a-tab-pane
              :tab="$t('functional-analysis.property-modal.note')"
              key="remarks">
            <a-row :gutter='24'>
              <a-col :md="12" :sm="24">
                <a-form-item :label="$t('functional-analysis.property-modal.note-group')">
                  <a-select
                      @change="nodeGroupChange"
                      v-model="currentNodeGroupKey"
                  >
                    <a-select-option
                        v-for="(item, index) in nodeGroups"
                        :key="index"
                        :value="item.annotationGroup"
                    >
                      {{ item.groupName }}
                    </a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
            </a-row>
            <a-row :gutter='24'>
              <a-col :md="12" :sm="24">
                <a-form-item :label="$t('functional-analysis.property-modal.note')">
              <span v-for="(item, index) in struNls">
                <a-textarea
                    v-if="defaultNls[0] === item.lkey"
                    :placeholder="$t('functional-analysis.property-modal.click-to-enter-note')"
                    allowClear
                    v-model="item.description"
                    :autoSize="{ minRows: 5 }"
                    :maxLength="500"
                />
              </span>
                </a-form-item>
              </a-col>
            </a-row>
            <a-row :gutter='24'>
              <a-col :md="12" :sm="24">
                <a-form-item :label="$t('functional-analysis.property-modal.attachment')">
                  <a-upload
                      name="file"
                      action=""
                      accept=".jpg,.txt,.png,.doc,.docx,.xls,.xlsx,.pdf,.pptx"
                      :fileList="fileList"
                      :customRequest="customRequest"
                      :remove="removeFile">
                    <a-button v-if="$api.isLook !== '1'">
                      <a-icon type="upload"/>
                      {{ $t('global-btn.select-file') }}
                    </a-button>
                  </a-upload>
                </a-form-item>
              </a-col>
            </a-row>
          </a-tab-pane>
          <a-tab-pane
              :tab="$t('functional-analysis.property-modal.about')"
              key="about">
            <a-row :gutter='24'>
              <a-col :md="12" :sm="24">
                <a-form-item :label="$t('functional-analysis.property-modal.create-time')">
                  {{ insertTime }}
                </a-form-item>
              </a-col>
            </a-row>
            <a-row :gutter='24'>
              <a-col :md="12" :sm="24">
                <a-form-item :label="$t('functional-analysis.property-modal.update-time')">
                  {{ updateTime }}
                </a-form-item>
              </a-col>
            </a-row>
          </a-tab-pane>
        </a-tabs>
      </a-spin>
    </a-form>
    <div slot="footer"
         v-if="$api.isLook !== '1'"
         class="mt10 text-right">
      <a-button @click="closeModal">
        {{ $t('global-btn.cancel') }}
      </a-button>
      <a-button
          type="primary"
          class="ml10"
          @click="save()"
          :loading="saveLoading"
          v-preventReClick>
        {{ $t('global-btn.confirm') }}
      </a-button>
    </div>
  </div>
</template>
<script>

import {dateFormat} from "@/utils/date";
import {checkHotTableLength} from "@/utils/validate";

/**
 * 渲染评估表格
 * @param value
 * @param row
 * @param index
 * @returns {{children, attrs: {}}}
 */
const evaluateRenderContent = (value, row, index) => {
  const obj = {
    children: value,
    attrs: {},
  };
  if (row.standardLevel === undefined) {
    obj.attrs.colSpan = 0;
  }
  return obj;
};

/**
 * 渲染特性分类表格
 * @param value
 * @param row
 * @param index
 * @returns {{children, attrs: {}}}
 */
const fcRenderContent = (value, row, index) => {
  const obj = {
    children: value,
    attrs: {},
  };
  if (!row.detailId) {
    obj.attrs.colSpan = 0;
  }
  return obj;
};

export default {
  name: "PropertyFault",
  components: {},
  props: {
    tabKey: {
      type: String,
      default: "",
    },
    checkedNode: {
      type: Object,
      default: {},
    },
  },
  data() {
    return {
      /** tab默认选中 */
      tabName: this.tabKey || "name",
      /** 语言下拉数组 */
      currentNls: [],
      /** 语言名称数组 */
      struNls: [],
      /** 默认语言标识 */
      defaultNls: [],
      /** 名称 */
      name: "",
      /** 失效分类 */
      classify: "",
      /** 类型，默认潜在失效 */
      sourceType: "01",
      /** 评估/严重度：输入值 */
      significInputVal: "",
      /** 评估/严重度：表格数据 */
      significTableData: [],
      /** 评估/严重度：表格表头 */
      significTableColumns: [
        {
          title: () => this.$t('functional-analysis.property-modal.level'),
          align: "center",
          width: 60,
          dataIndex: 'standardLevel',
          customRender: (text, row, index) => {
            if (row.standardLevel === undefined) text = row.attr1; /** 未设置 */
            if (row.standardLevel) return text;
            return {
              children: text,
              attrs: {
                colSpan: 6,
              },
            };
          },
          ellipsis: true,
        },
        {
          title: () => this.$t('functional-analysis.property-modal.consequence'),
          align: "center",
          dataIndex: 'attr1',
          customRender: evaluateRenderContent,
          ellipsis: true,
        },
        {
          title: () => this.$t('functional-analysis.property-modal.rating-criteria-current-factory'),
          align: "center",
          dataIndex: 'attr2',
          customRender: evaluateRenderContent,
          ellipsis: true,
        },
        {
          title: () => this.$t('functional-analysis.property-modal.scoring-standard-transfer-factory'),
          align: "center",
          dataIndex: 'attr3',
          customRender: evaluateRenderContent,
          ellipsis: true,
        },
        {
          title: () => this.$t('functional-analysis.property-modal.rating-criteria-customers'),
          align: "center",
          dataIndex: 'attr4',
          customRender: evaluateRenderContent,
          ellipsis: true,
        },
        {
          title: () => this.$t('functional-analysis.property-modal.example-business-product-line'),
          align: "center",
          dataIndex: 'attr5',
          customRender: evaluateRenderContent,
          ellipsis: true,
        },
      ],
      /** 评估/严重度：选中索引 */
      significSelectedRowKeys: [],
      /** 评估/严重度：选中数据 */
      significSelectedRow: {},
      /** 用户定义的特性：表格数据 */
      userTableData: [],
      /** 用户定义的特性：表格表头 */
      userTableColumns: [
        {
          title: () => this.$t('functional-analysis.property-modal.name'),
          align: "center",
          dataIndex: "memo",
          key: "memo",
          ellipsis: true,
        },
      ],
      /** 用户定义的特性：选中索引 */
      userSelectedRowKeys: [],
      /** 用户定义的特性：选中数据 */
      userSelectedRows: [],
      /** 特性分类：表格数据 */
      fcTableData: [],
      /** 特性分类：表格表头 */
      fcTableColumns: [
        {
          title: () => this.$t('functional-analysis.property-modal.icon/mark'),
          align: "center",
          dataIndex: 'classifyType',
          customRender: (text, row, index) => {
            /** 1：图标，2：标识 */
            if (row.classifyType === "1") {
              let url = this.$api.baseUrl + '/DFMEA/file/' + row.fileName;
              text = <img width="25" height="25" src={url} alt=""/>;
            } else if (row.classifyType === "2") {
              text = row.lexplain;
            }
            if (row.detailId) return text;
            return {
              children: text,
              attrs: {
                colSpan: 3,
              },
            };
          },
        },
        {
          title: () => this.$t('functional-analysis.property-modal.name'),
          align: "center",
          dataIndex: 'lname',
          customRender: fcRenderContent,
          ellipsis: true,
        }, {
          title: () => this.$t('functional-analysis.property-modal.note'),
          align: "center",
          dataIndex: 'ldescription',
          customRender: fcRenderContent,
          ellipsis: true,
        },
      ],
      /** 特性分类：选中索引 */
      fcSelectedRowKeys: [],
      /** 特性分类：选中数据 */
      fcSelectedRow: {},
      /** 备注分组 */
      nodeGroups: [],
      /** 默认备注分组Key */
      currentNodeGroupKey: undefined,
      /** 文件集合 */
      fileList: [],
      /** 创建时间 */
      insertTime: "",
      /** 更新时间 */
      updateTime: "",
      /** 保存加载中... */
      saveLoading: false,
      /** 加载中状态 */
      loading: false,
    };
  },
  mounted() {
    this.list();
  },
  methods: {
    /**
     * 关闭模态框
     */
    closeModal() {
      this.$emit("closeModal");
    },
    /**
     * 刷新右侧结构树
     */
    initRightTree() {
      this.$emit("initRightTree");
    },
    /**
     * 名称改变时
     */
    nameChange(e) {
      this.struNls.forEach((item, index) => {
        if (item.lkey === this.defaultNls[0]) {
          item.name = e.target.value;
        }
      });
    },
    /**
     * 类型单选框改变事件
     */
    typeRadioChange(e) {
      this.sourceType = e.target.value;
    },
    /**
     * 语言下拉选择时
     */
    currentNlsChange(val) {
      let struNls = this.struNls.filter((item) => {
        return item.lkey === val;
      })[0];
      this.defaultNls[0] = val;
      this.name = struNls.name;
    },
    /**
     * 备注分组下拉选择时
     */
    nodeGroupChange(val) {
      let _that = this;
      _that.currentNodeGroupKey = val;
      _that.$api.getNodeGroupSelect({
        fmeaId: _that.$store.getters.rfmeaId,
        struId: _that.checkedNode.id,
        annotationGroup: _that.currentNodeGroupKey,
      }).then(res => {
        if (res.flag) {
          // 处理附件
          _that.handleFileList(res.data.mfmeaAttachmentList || []);
          // 处理备注分组多语言
          let nodeGroupNls = res.data.mfmeaAnnotationNlsList || [];
          const newStruNls = [..._that.struNls];
          (nodeGroupNls || []).forEach(nodeGroup => {
            (newStruNls || []).forEach(nls => {
              if (nls.lkey === nodeGroup.lkey) {
                nls.description = nodeGroup.lvalue;
              }
            })
          });
          _that.struNls = newStruNls;
        } else {
          _that.$message.error(res.message, 1);
        }
      });
    },
    /**
     * 处理文件列表
     * @param files 文件
     */
    handleFileList(files) {
      this.fileList = []
      if (files.length === 0) return;
      for (let i = 0, len = files.length; i < len; i++) {
        this.fileList.push({
          data: {
            hiddenFileName: files[i].attachmentName,
            hiddenNewFileName: files[i].storageName,
            hiddenDir: files[i].attachmentPath,
            hiddenFileSize: files[i].attachmentSize,
          },
          uid: files[i].attachmentId,
          name: files[i].attachmentName,
          status: 'done',
          url: this.$api.requestUrl + '/DFMEA/mfmea/funAnalysis/Rb0426341/downLoad?fmeaId=' + this.$store.getters.rfmeaId
              + '&attachmentId=' + files[i].attachmentId,
        });
      }
    },
    /**
     * 列表
     */
    list() {
      let _that = this;
      _that.loading = true;
      _that.$api.getFaultProperties({
        fmeaId: _that.$store.getters.rfmeaId,
        struId: _that.checkedNode.id,
      }).then((res) => {
        if (res.flag) {
          /**************** 名称 ****************/
          if (!res.data.display_nls) res.data.display_nls = 1;
          _that.defaultNls[0] = res.data.display_nls;
          _that.currentNls = res.data.mfmeacurrentNls || [];
          // 语言Key升序
          _that.struNls = (res.data.mfmeaStruNlss || []).sort((a, b) => {
            return a.lkey - b.lkey;
          });
          let struNls = _that.struNls.filter((item) => {
            return res.data.display_nls === item.lkey;
          })[0];
          _that.name = struNls.name;
          // 失效分类
          _that.classify = res.data.mfmeaFault.faultType;
          _that.sourceType = res.data.mfmeaFault.sourceType;
          /**************** 评估 ****************/
          _that.significTableData = res.data.rfmStandardDetails || [];
          if (_that.significTableData && _that.significTableData.length > 0) {
            _that.significTableData.push({
              standardLevel: undefined,
              attr1: this.$t('functional-analysis.property-modal.not-set')
            });
            _that.significTableData.forEach((item, index) => {
              if (res.data.mfmeaFault.signific === item.standardLevel) {
                _that.significSelectedRowKeys[0] = index;
                _that.significSelectedRow = item;
                _that.significInputVal = item.standardLevel;
              }
            });
            // 默认：未设置
            if (!res.data.mfmeaFault.signific) {
              let ftSize = _that.significTableData.length;
              _that.significSelectedRowKeys[0] = ftSize - 1;
              _that.significSelectedRow = _that.significTableData[ftSize - 1];
              _that.significInputVal = _that.significSelectedRow.standardLevel;
            }
          }
          /**************** 用户定义的特性 ****************/
          _that.userTableData = res.data.mfmeaStruAttributeModels || [];
          _that.userTableData.forEach((item, index) => {
            if (item.checkFlag) {
              _that.userSelectedRowKeys.push(index);
              _that.userSelectedRows.push(item);
            }
          });
          /**************** 特性分类 ****************/
          _that.fcTableData = res.data.rfmPductClassifyDetailModels || [];
          if (_that.fcTableData && _that.fcTableData.length > 0) {
            _that.fcTableData.push({
              detailId: "",
              classifyType: "2",
              lexplain: this.$t('functional-analysis.property-modal.not-set')
            });
            _that.fcTableData.forEach((item, index) => {
              if (res.data.mfmeaFault.classifyId === item.detailId) {
                _that.fcSelectedRowKeys[0] = index;
                _that.fcSelectedRow = item;
              }
            });
            // 默认：未设置
            if (!res.data.mfmeaFault.classifyId) {
              let ftSize = _that.fcTableData.length;
              _that.fcSelectedRowKeys[0] = ftSize - 1;
              _that.fcSelectedRow = _that.fcTableData[ftSize - 1];
            }
          }
          /**************** 备注 ****************/
          _that.currentNodeGroupKey = res.data.currentGroupId;
          _that.nodeGroups = res.data.mfmeaAnnotationGroupList || [];
          let nodeGroupNls = res.data.mfmeaAnnotationNlsList || [];
          // 处理备注分组多语言
          (nodeGroupNls || []).forEach(nodeGroup => {
            (_that.struNls || []).forEach(nls => {
              if (nls.lkey === nodeGroup.lkey) {
                nls.description = nodeGroup.lvalue;
              }
            })
          });
          // 处理附件
          _that.handleFileList(res.data.mfmeaAttachmentList || []);
          /**************** 关于 ****************/
          _that.insertTime = dateFormat(res.data.mfmeaFault?.insertTime);
          _that.updateTime = dateFormat(res.data.mfmeaFault?.updateTime);
        } else {
          _that.$message.error(res.message, 1);
        }
      }).catch((error) => {
        _that.$message.error(error.response.data.message, 1);
      }).finally(() => {
        _that.loading = false;
      });
    },
    /**
     * 保存
     */
    save() {
      let _that = this;
      // 校验
      if (!_that.validatePropertyData()) return;

      /**************** 数据封装 Start ***********/
      let struNames = _that.struNls.map((item) => {
        return item.name;
      });
      let descriptions = _that.struNls.map((item) => {
        return item.description || '';
      });
      let userDefineIds = _that.userSelectedRows.map((item) => {
        return item.userDefineId;
      });
      let standardLevelId = _that.significSelectedRow ? _that.significSelectedRow.standardLevel : '';
      let pductClassifyDetailId = _that.fcSelectedRow ? _that.fcSelectedRow.detailId : '';
      let hiddenFileName = [];
      let hiddenNewFileName = [];
      let hiddenDir = [];
      let hiddenFileSize = [];
      let files = _that.fileList;
      for (let i = 0, len = files.length; i < len; i++) {
        let file = files[i].data;
        hiddenFileName.push(file.hiddenFileName);
        hiddenNewFileName.push(file.hiddenNewFileName);
        hiddenDir.push(file.hiddenDir);
        hiddenFileSize.push(file.hiddenFileSize);
      }
      /**************** 数据封装 End ***********/

      _that.saveLoading = true; // 开启：加载中...
      _that.$api.saveFaultProperties({
        fmeaId: _that.$store.getters.rfmeaId,
        struId: _that.checkedNode.id,
        struNames: struNames, /** 名称 */
        sourceType: _that.sourceType, /** 类型来源 */
        faultType: _that.classify, /** 失效分类 */
        standardLevelId: standardLevelId, /** 评估 */
        pductClassifyDetailId: pductClassifyDetailId, /** 特性分类 */
        userDefineIds: userDefineIds, /** 用户定义的特性 */
        descriptions: descriptions, /** 备注 */
        lkey: _that.defaultNls[0], /** 备注分组语言Key */
        annotationGroup: _that.currentNodeGroupKey, /** 备注分组Key */
        hiddenFileName: hiddenFileName, /** 隐藏的附件名称 */
        hiddenNewFileName: hiddenNewFileName, /** 隐藏的新生成附件名称 */
        hiddenDir: hiddenDir, /** 隐藏的新生成附件名称 */
        hiddenFileSize: hiddenFileSize, /** 隐藏的新生成附件大小 */
      }).then((res) => {
        if (res.flag) {
          // 添加成功，关闭弹窗，刷新结构树
          _that.$message.success(res.message, 1);
          _that.closeModal();
          _that.initRightTree();
        } else {
          _that.$message.error(res.message, 1);
        }
      }).catch((error) => {
        _that.$message.error(error.response.data.message, 1);
      }).finally(() => {
        _that.saveLoading = false; // 关闭：加载中...
      })
    },
    /**
     * 校验：属性数据
     */
    validatePropertyData() {
      let flag = true;
      this.struNls.some((item, idx) => {
        let nlsKey = this.$t('global-dict.select-nls.' + item.lkey);
        if (!item.name) {
          this.$message.warning(this.$t('global-message.warn.name-cannot-be-empty', [nlsKey]));
          flag = false;
          return true;
        }
        if (checkHotTableLength(item.name, 1000)) {
          this.$message.warning(this.$t('global-message.warn.name-cannot-be-empty', [nlsKey]));
          flag = false;
          return true;
        }
        if (checkHotTableLength(item.description, 500)) {
          this.$message.warning(this.$t('global-message.warn.name-cannot-be-empty', [nlsKey]));
          flag = false;
          return true;
        }
      });
      return flag;
    },
    /**
     * 严重度：数字选择器改变时
     */
    significInputValChange(val) {
      this.significTableData.forEach((item, index) => {
        if (item.standardLevel === val) {
          this.significSelectedRowKeys = [index];
          this.significSelectedRow = item;
        }
      });

    },
    /**
     * 严重度：单选框改变事件
     */
    significRadioChange(rowKeys, row) {
      this.significSelectedRowKeys = rowKeys;
      this.significSelectedRow = row[0];
      this.significInputVal = row[0].standardLevel;
    },
    /**
     * 严重度：行点击事件
     */
    significCustomRow(record, index) {
      let _that = this;
      return {
        on: {
          // 鼠标单击行
          click: () => {
            _that.significSelectedRowKeys = [index];
            _that.significSelectedRow = record;
            _that.significInputVal = record.standardLevel;
          }
        }
      };
    },
    /**
     * 用户定义的特性：复选框改变事件
     */
    userCheckboxChange(rowKeys, row) {
      this.userSelectedRows = row;
      this.userSelectedRowKeys = rowKeys;
    },
    /**
     * 用户定义的特性：复选框行点击事件
     */
    userCustomRow(record, index) {
      let _that = this;
      return {
        on: {
          // 鼠标单击行
          click: () => {
            if (_that.userSelectedRowKeys.indexOf(index) !== -1) {
              _that.userSelectedRows.splice(_that.userSelectedRowKeys.indexOf(index), 1);
              _that.userSelectedRowKeys.splice(_that.userSelectedRowKeys.indexOf(index), 1);
            } else {
              _that.userSelectedRowKeys.push(index)
              _that.userSelectedRows.push(record);
            }
          }
        }
      };
    },
    /**
     * 特性分类：单选框改变事件
     */
    fcRadioChange(rowKeys, row) {
      this.fcSelectedRowKeys = rowKeys;
      this.fcSelectedRow = row[0];
    },
    /**
     * 特性分类：行点击事件
     */
    fcCustomRow(record, index) {
      let _that = this;
      return {
        on: {
          // 鼠标单击行
          click: () => {
            _that.fcSelectedRowKeys = [index];
            _that.fcSelectedRow = record;
          }
        }
      };
    },
    /**
     * 通过覆盖默认的上传行为，可以自定义自己的上传实现
     * @param obj 回调对象
     */
    customRequest(obj) {
      let _that = this;
      if (obj.file.size > 52428800) {
        _that.$message.warning(this.$t('global-message.warn.uploaded-files-cannot-exceed'));
        return;
      }
      _that.loading = true;
      let fd = new FormData();
      fd.append("file", obj.file);
      fd.append("fileType", "10");
      _that.$api.uploadFile(fd).then((res) => {
        if (res.flag) {
          _that.$message.success(res.message, 1);
          obj.file.data = {
            hiddenFileName: res.data.fileName,
            hiddenNewFileName: res.data.newFileName,
            hiddenDir: res.data.filePath,
            hiddenFileSize: res.data.fileSize,
          };
          _that.fileList.push(obj.file);
        } else {
          _that.$message.error(res.message, 1);
        }
      }).catch((error) => {
        _that.$message.error(error.response.data.message, 1);
      }).finally(() => {
        _that.loading = false;
      });
    },
    /**
     * 删除文件
     * @param file 文件
     */
    removeFile(file) {
      let files = this.fileList;
      for (let i = files.length - 1; i >= 0; i--) {
        if (file.uid === files[i].uid) files.splice(i, 1);
      }
    },
  }
};
</script>
<style lang="less" scoped>

/** 表格头部自动换行 */
/deep/ .ant-table-thead {
  .ant-table-row-cell-ellipsis .ant-table-column-title {
    white-space: normal;
  }
}

/deep/ .ant-table-tbody {
  .ant-table-row-cell-ellipsis:nth-of-type(2) {
    text-align: left !important;
  }

  .ant-table-row-cell-ellipsis:nth-of-type(3) {
    text-align: left !important;
  }

  .ant-table-row-cell-ellipsis:nth-of-type(4) {
    text-align: left !important;
  }

  .ant-table-row-cell-ellipsis:nth-of-type(5) {
    text-align: left !important;
  }

  .ant-table-row-cell-ellipsis:nth-of-type(6) {
    text-align: left !important;
  }
}

// 评估/级别居中
/deep/ .evaluate {
  .ant-table-tbody {
    .ant-table-row-cell-ellipsis:nth-of-type(2) {
      text-align: center !important;
    }
  }
}

/*/deep/ .ant-table-fixed-header > .ant-table-content > .ant-table-scroll > .ant-table-body {
  overflow-y: auto !important;
}*/

/deep/ a {
  color: #1890FF;
}
/deep/ .ant-table-fixed-header .ant-table-scroll .ant-table-header {
  overflow: hidden!important;
  margin-bottom: 0!important;
  padding-right: 8px;
  background: rgb(250, 250, 250);
}
</style>
