<template>
  <a-modal
      :title="$t('plan.correlate-pfmea.share-dfmea')"
      :visible="dialogFormVisible"
      :maskClosable="false"
      @cancel="close"
      :keyboard="false"
      width="100%"
      destroy-on-close
      :footer="false"
      @afterClose="close">
    <div class="filter-boxn">
      <a-form layout="vertical">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="8" :md="12" :sm="24" :xs="24">
            <a-form-item :label="$t('plan.correlate-pfmea.pfmea-number')">
              <a-select
                  :placeholder="$t('plan.correlate-pfmea.please-select-pfmea-number')"
                  :value="queryParam.rfmeaId"
                  @change="handleProjectChange">
                <a-select-option v-for="item in projectPfmeaList" :key="item.rfmeaId" :value="item.rfmeaId">
                  {{ item.dfmeaCode }}
                </a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="8" :md="12" :sm="24" :xs="24">
            <a-form-item :label="$t('plan.correlate-pfmea.pass-node-type')">
              <a-select
                  v-model="queryParam.strucType"
                  :placeholder="$t('plan.correlate-pfmea.please-select-pass-node-type')"
                  @change="handleStrucType">
                <a-select-option v-for="(item, key) in strucTypeList" :key="key" :value="item.key">
                  {{ item.value }}
                </a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="8" :md="24" :sm="24" :xs="24">
            <a-form-item :label="'\xa0'">
              <a-button class='ml10' type @click="reset(1)">
                {{ $t('global-btn.reset') }}
              </a-button>
              <a-button class='ml10' type="primary" @click="search">
                {{ $t('global-btn.search') }}
              </a-button>
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <div style="height: 100%">
      <a-col :span="8" class="boxlr">
        <a-form layout="vertical">
          <a-row :gutter="24">
            <a-col :xl="16" :lg="16" :md="24" :sm="24" :xs="24">
              <a-form-item :label="$t('plan.correlate-pfmea.structure-name')">
                <a-input
                    allowClear
                    v-model="queryParam.struName"
                    :placeholder="$t('plan.correlate-pfmea.please-enter-structure-name')"/>
              </a-form-item>
            </a-col>
            <a-col :xl="8" :lg="8" :md="24" :sm="24" :xs="24">
              <a-form-item :label="'\xa0'">
                <a-button class='ml10' type="primary" @click="searchStru">
                  {{ $t('global-btn.search') }}
                </a-button>
              </a-form-item>
            </a-col>
          </a-row>
        </a-form>
        <!-- Tree Start -->
        <div id="leftTree" class="leftTree" ref="leftTree">
          <div>
            <a-spin
                :tip="spinTip"
                :delay="delayTime"
                :spinning="treeLoading">
              <a-tree
                  v-if="treeData && treeData.length > 0"
                  key="leftTree"
                  :tree-data="treeData"
                  :selected-keys="[]"
                  :blockNode="true"
                  :replaceFields="replaceFields"
                  :expandedKeys="expandedKeys"
                  :autoExpandParent="autoExpandParent"
                  @expand="expand"
                  @select="nodeClick">
                <template slot="treeDataSlot" slot-scope="node">
                  <a :id="'leftTreeNode' + node.id">
                    <span>{{ "\xa0" }}</span>
                    <span
                        :id="'leftTreeNodeName' + node.id"
                        :title="node.name"
                        :class="getNodeClass(node)">
                      {{ node.name }}
                    </span>
                  </a>
                </template>
              </a-tree>
            </a-spin>
          </div>
        </div>
        <!-- Tree End -->
      </a-col>
      <a-col :span="16" class="boxlr">
        <a-form layout="vertical">
          <a-row :gutter="24">
            <a-col :xl="8" :lg="8" :md="24" :sm="24" :xs="24">
              <a-form-item v-if="queryParam.strucType === '02'" :label="$t('plan.correlate-pfmea.function-name')">
                <a-input allowClear v-model="queryParam.functionName"
                         :placeholder="$t('plan.correlate-pfmea.please-enter-function-name')"/>
              </a-form-item>
              <a-form-item v-if="queryParam.strucType === '04'"
                           :label="$t('plan.correlate-pfmea.product-feature-name')">
                <a-input allowClear v-model="queryParam.functionName"
                         :placeholder="$t('plan.correlate-pfmea.please-enter-product-feature-name')"/>
              </a-form-item>
              <a-form-item v-if="queryParam.strucType === '06'" :label="$t('plan.correlate-pfmea.failure-name')">
                <a-input allowClear v-model="queryParam.functionName"
                         :placeholder="$t('plan.correlate-pfmea.please-enter-failure-name')"/>
              </a-form-item>
            </a-col>
            <a-col :xl="8" :lg="8" :md="24" :sm="24" :xs="24">
              <a-form-item :label="$t('plan.correlate-pfmea.feature-class-name')">
                <a-select
                    v-model="queryParam.classifyId"
                    :placeholder="$t('plan.correlate-pfmea.please-select-feature-class-name')"
                    @change="handleFeatureClassify"
                    allowClear>
                  <a-select-option
                      v-for="(item, key) in featureClassifyDict"
                      :key="item.detailId"
                      :value="item.detailId">
                    {{ item.name }}
                  </a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :xl="8" :lg="8" :md="24" :sm="24" :xs="24">
              <a-form-item :label="'\xa0'">
                <a-button class='ml10' type @click="reset(3)">
                  {{ $t('global-btn.reset') }}
                </a-button>
                <a-button class='ml10' type="primary" @click="search">
                  {{ $t('global-btn.search') }}
                </a-button>
              </a-form-item>
            </a-col>
          </a-row>
        </a-form>
        <a-row>
          <a-button class='ml10' type="primary" @click="share">
            {{ $t('global-btn.share') }}
          </a-button>
          <a-button class='ml10' type="primary" @click="allSelectElementStru">
            {{ $t('global-btn.share-all') }}
          </a-button>
        </a-row>
        <a-row>
          <a-col :span="24" class="mt10">
            <a-table
                size="small"
                :pagination="pagination"
                :customRow="customRow"
                :rowKey="(record, index) => { return index; }"
                :row-selection="{
                  fixed: true,
                  selectedRowKeys: selectedRowKeys,
                  onChange: onSelectChange
                }"
                bordered
                :scroll="{ x: scrollX ,y: 'calc(88vh - 440px)'}"
                :columns="columns"
                :dataSource="tableData"
                @change="handleTableChange"
                :loading="loading">
              <!-- 序号列 -->
              <template slot="index" slot-scope="text, record, index">
                <span>{{ (pagination.current - 1) * pagination.pageSize + index + 1 }}</span>
              </template>
              <!-- 特性图标 -->
              <template slot="picFlag" slot-scope="text, record">
                <span v-if="record.explain">{{ record.explain }}</span>
                <img width='25' height='25' v-else-if="record.fileName" :src="baseUrl + '/DFMEA/file/' + record.fileName" />
              </template>
            </a-table>
          </a-col>
        </a-row>
      </a-col>
    </div>
  </a-modal>
</template>

<script>

import {arrayToTree} from "@/utils/tree";
import {addClass, removeClass} from "@/utils/index";

export default {
  name: "shareDFMEA",
  components: {
    // TaskForm,
    // DfmeaForm,
    // VersionDialog
  },
  props: {
    showShareDFMEA: {
      type: Boolean,
      default: false
    },
  },
  watch: {
    showShareDFMEA(val) {
      this.dialogFormVisible = val;
    },
  },
  data() {
    return {
      loading: false,
      // 当前页
      pageNo: 1,
      // 每页显示的数据条数
      pageSize: 10,
      // 分页
      pagination: {
        // defaultPageSize: 10,
        current: 1,
        pageNo: 1,
        pageSize: 10, // 默认每页显示数量
        showTotal: total => this.$t('global-constant.table.show-total', [total]), // 显示总数
        showSizeChanger: true, // 显示可改变每页数量
        pageSizeOptions: ['10', '20', '50', '100', '200'], // 每页数量选项
        onShowSizeChange: (current, pageSize) => (this.pageSize = pageSize), // 改变每页数量时更新显示
        // onChange: (page, pageSize) => self.changePage(page, pageSize), //点击页码事件
        total: 0 //总条数
      },
      columns: [],
      /** 表格宽度的固定值 */
      scrollX: 1,
      // 表头
      columnFunctions: [
        {
          title: () => this.$t('plan.correlate-pfmea.serial-number'),
          width: 100,
          align: 'center',
          scopedSlots: {
            customRender: 'index'
          },
          ellipsis: true
        },
        {
          title: () => this.$t('plan.correlate-pfmea.structure-name'),
          width: 300,
          dataIndex: 'struName',
          align: 'center',
          ellipsis: true
        },
        {
          title: () => this.$t('plan.correlate-pfmea.function-name'),
          width: 270,
          align: 'center',
          dataIndex: 'name',
          ellipsis: true
        },
        {
          title: () => this.$t('plan.correlate-pfmea.feature-classification'),
          width: 270,
          align: 'center',
          scopedSlots: {customRender: 'picFlag'},
          ellipsis: true
        },
        {
          title: () => this.$t('plan.correlate-pfmea.feature-class-name'),
          width: 270,
          align: 'center',
          dataIndex: 'lname',
          ellipsis: true
        }
      ],
      // 表头
      columnFeatures: [
        {
          title: () => this.$t('plan.correlate-pfmea.serial-number'),
          width: 100,
          align: 'center',
          scopedSlots: {
            customRender: 'index'
          },
          ellipsis: true
        },
        {
          title: () => this.$t('plan.correlate-pfmea.structure-name'),
          width: 300,
          dataIndex: 'struName',
          align: 'center',
          ellipsis: true
        },
        {
          title: () => this.$t('plan.correlate-pfmea.product-feature-name'),
          width: 220,
          align: 'center',
          dataIndex: 'name',
          ellipsis: true
        },
        {
          title: () => this.$t('plan.correlate-pfmea.feature-classification'),
          width: 220,
          align: 'center',
          scopedSlots: {customRender: 'picFlag'},
          ellipsis: true
        },
        {
          title: () => this.$t('plan.correlate-pfmea.feature-class-name'),
          width: 220,
          align: 'center',
          dataIndex: 'lname',
          ellipsis: true
        },
        {
          title: () => this.$t('plan.correlate-pfmea.numerical-value'),
          width: 200,
          align: 'center',
          dataIndex: 'featureValue',
          ellipsis: true
        },
        {
          title: () => this.$t('plan.correlate-pfmea.unit'),
          width: 150,
          align: 'center',
          dataIndex: 'unit',
          ellipsis: true
        },
        {
          title: () => this.$t('plan.correlate-pfmea.tolerance'),
          width: 150,
          align: 'center',
          dataIndex: 'tolerance',
          ellipsis: true
        }
      ],
      // 表头
      columnFaults: [
        {
          title: () => this.$t('plan.correlate-pfmea.serial-number'),
          width: 100,
          align: 'center',
          scopedSlots: {
            customRender: 'index'
          },
          ellipsis: true
        },
        {
          title: () => this.$t('plan.correlate-pfmea.structure-name'),
          width: 300,
          dataIndex: 'struName',
          align: 'center',
          ellipsis: true
        },
        {
          title: () => this.$t('plan.correlate-pfmea.failure-name'),
          width: 220,
          align: 'center',
          dataIndex: 'name',
          ellipsis: true
        },
        {
          title: () => this.$t('plan.correlate-pfmea.feature-classification'),
          width: 220,
          align: 'center',
          scopedSlots: {customRender: 'picFlag'},
          ellipsis: true
        },
        {
          title: () => this.$t('plan.correlate-pfmea.feature-class-name'),
          width: 220,
          align: 'center',
          dataIndex: 'lname',
          ellipsis: true
        },
        {
          title: () => this.$t('plan.correlate-pfmea.s'),
          width: 170,
          align: 'center',
          dataIndex: 'severityD',
          ellipsis: true
        }
      ],
      // 查询参数
      queryParam: {
        rfmeaId: undefined,
        strucType: undefined,
        projectSn: undefined,
        orgId: undefined,
        orgName: undefined,
        functionName: undefined,
        faultName: undefined
      },
      featureClassifyDict: [],
      tableData: [],
      selectedRowKeys: [],
      selectedRows: [],
      options: {
        alert: {
          show: true,
          clear: () => {
            this.selectedRowKeys = [];
          }
        },
        rowSelection: {
          selectedRowKeys: this.selectedRowKeys,
          onChange: this.onSelectChange
        }
      },
      // 节点类型字典
      strucTypeList: [
        {key: '02', value: this.$t('global-dict.function')},
        {key: '04', value: this.$t('global-dict.product-features')},
        {key: '06', value: this.$t('global-dict.failure')},
      ],
      // 参数存储
      fmeaId: '',
      tempFormData: {},
      projectPfmeaList: [],
      /** 模态框状态 */
      dialogFormVisible: false,
      /** 自定义Loading描述文案 */
      // spinTip: "加载中...",
      spinTip: "",
      /** 延迟显示加载效果的时间（防止闪烁）*/
      delayTime: 300,
      /** tree加载中状态 */
      treeLoading: false,
      /** tree数据 */
      treeData: [],
      /** 替换 treeNode 中 title,key,children 字段为 treeData 中对应的字段 */
      replaceFields: {key: "id", title: "name"},
      /** (受控)展开指定的树节点 */
      expandedKeys: [],
      /** 是否自动展开父节点   */
      autoExpandParent: false,
      baseUrl: this.$api.baseUrl === '/' ? 'http://localhost:8080' : this.$api.baseUrl,
    };
  },
  methods: {
    // 重置
    reset(type) {
      if (type == 1) {
        this.queryParam.rfmeaId = this.projectPfmeaList[0].rfmeaId
        this.queryParam.strucType = this.strucTypeList[0].key
      } else if (type == 2) {
        this.queryParam.struName = ''
        this.queryParam.struId = ''
        this.removeHighRedNode()
        this.setHighLightNode(null, 'leftTree')
      } else if (type == 3) {
        this.queryParam.functionName = undefined
        this.queryParam.faultName = undefined
        this.queryParam.classifyId = undefined
      }
      this.pagination.current = 1
      this.pagination.pageNo = 1
      this.pagination.pageSize = 10
      this.pageNo = 1
      this.pageSize = 10
      this.getFmeaElementStru()
    },

    onSelectChange(selectedRowKeys, selectedRows) {
      this.selectedRowKeys = selectedRowKeys
      this.selectedRows = selectedRows
    },
    // 分页列表 - 点击分页中数字触发的方法
    handleTableChange(pagination) {
      this.pageNo = pagination.current
      this.pageSize = pagination.pageSize
      this.pagination.current = pagination.current
      this.pagination.pageSize = pagination.pageSize
      this.share()
    },
    // 搜索
    search() {
      this.pageNo = 1
      this.pageSize = this.pagination.pageSize
      this.pagination.current = 1
      this.getFmeaElementStru()
    },
    // 分享
    share(type) {
      let struIds = []
      let allStruIds = []
      this.selectedRows.forEach(item => {
        struIds.push(item.struId)
      })
      this.tableData.forEach(item => {
        allStruIds.push(item.struId)
      })
      this.$api.updateElementStru({
        fmeaId: this.$route.query.rfmeaId,
        pfmeaId: this.queryParam.rfmeaId,
        status: 3,
        quoteStruIds: struIds,
        allStruIds: allStruIds
      }).then((res) => {
        if (res.flag) {
          if (type == 1) {
            this.close()
          } else {
            this.getFmeaElementStru()
          }
        }
      })
    },
    // 全部关联
    allSelectElementStru() {
      this.$api.allSelectElementStru({
        fmeaId: this.$route.query.rfmeaId,
        pfmeaId: this.queryParam.rfmeaId,
        struTypeCode: this.queryParam.strucType,
        type: 1,
        status: 3
      }).then((res) => {
        if (res.flag) {
          this.getFmeaElementStru()
        }
      })
    },
    // 项目编号模糊搜索
    handleProjectChange(value, options) {
      this.queryParam.rfmeaId = value == undefined ? '' : value
      this.getFmeaElementStru()
    },
    // 获取项目编号字典
    getQuotePFMEAList() {
      let _this = this
      let data = {
        fmeaId: _this.fmeaId,
        pageSize: 10000
      }
      this.$api.getQuotePFMEAPageList(data).then(res => {
        if (!res.flag) {
          this.$notification.error({message: res.message})
        }
        _this.projectPfmeaList = res.data.data || []
        if (_this.projectPfmeaList.length > 0) {
          _this.queryParam.rfmeaId = _this.projectPfmeaList[0].rfmeaId
          _this.queryParam.strucType = _this.strucTypeList[0].key
          _this.columns = _this.columnFunctions
          this.initLeftTree()
        }
      })
    },

    // 类型下拉改变
    handleStrucType(val) {
      this.queryParam.strucType = val
      this.queryParam.functionName = ''
      if (val === this.strucTypeList[1].key) {
        this.columns = this.columnFeatures;
        this.scrollX = 1250;
      } else if (val === this.strucTypeList[0].key) {
        this.columns = this.columnFunctions;
        this.scrollX = 850;
      } else if (val === this.strucTypeList[2].key) {
        this.columns = this.columnFaults;
        this.scrollX = 1000;
      }
      this.getFmeaElementStru()
    },

    // 特性分类下拉改变
    handleFeatureClassify(val) {
      this.queryParam.classifyId = val
      this.getFmeaElementStru()
    },

    delCookie(name) {
      document.cookie = name + '=' + escape('') + ';expires=-1';
    },
    setCookie(name, value) {
      if (value) {
        var days = 1; //定义一天
        var exp = new Date();
        exp.setTime(exp.getTime() + days * 24 * 60 * 60 * 1000);
        // 写入Cookie, toGMTString将时间转换成字符串
        document.cookie = name + '=' + escape(value) + ';expires=' + exp.toGMTString;
      }
    },
    // 基本信息-项目编号模糊查询
    fpid(input, option) {
      return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0;
    },

    /**
     * 复选框改变事件
     */
    onSelectTableChange(selectedRowKeys, row) {
      this.selectedRows = row;
      this.selectedRowKeys = selectedRowKeys;
    },
    /**
     * 行点击事件
     */
    customRow(record, index) {
      let _that = this;
      return {
        on: {
          // 鼠标单击行
          click: () => {
            if (_that.selectedRowKeys.indexOf(index) !== -1) {
              _that.selectedRows.splice(_that.selectedRowKeys.indexOf(index), 1);
              _that.selectedRowKeys.splice(_that.selectedRowKeys.indexOf(index), 1);
            } else {
              _that.selectedRowKeys.push(index)
              _that.selectedRows.push(record);
            }
          }
        }
      };
    },

    close() {
      this.$emit("closeShareDFMEAModal");
    },
    /**
     * 图标展开/收起节点时触发
     * @param expandedKeys
     * @param e
     */
    expand(expandedKeys, e) {
      this.expandedKeys = expandedKeys;
      this.autoExpandParent = false;
      e.node.dataRef.expanded = e.expanded;
    },
    searchStru() {
      this.removeHighRedNode()
      if (this.queryParam.struName) {
        this.initData.forEach(data => {
          if (data.name.indexOf(this.queryParam.struName) != -1) {
            this.setHighRedNode(data)
          }
        })
      }
    },
    /**
     * 节点单击事件
     * 参数：selectedKeys, e:{selected: bool, selectedNodes, node, event}
     */
    async nodeClick(selectedKeys, e) {
      // 高亮当前节点
      await this.setHighLightNode(e.node.dataRef, 'leftTree');
      // 根据所选节点查询右侧数据
      this.queryParam.struId = selectedKeys[0]
      this.getFmeaElementStru()
    },
    setHighLightNode(node, treeFlag) {
      let className = treeFlag + "-node-selected";
      let treeEleId = treeFlag + "Node";
      let arr = document.getElementsByClassName(className);
      // 清除其他高亮节点
      if (arr) {
        for (let i = 0; i < arr.length; i++) {
          removeClass(arr[i], className);
        }
      }
      if (node) {
        addClass(
            document.getElementById(treeEleId + node.id),
            className
        );
      }
    },
    /**
     * 添加条件筛选后红色显示
     */
    setHighRedNode(node) {
      let className = "red-node-selected";
      let treeEleId = "leftTreeNodeName";
      addClass(
          document.getElementById(treeEleId + node.id),
          className
      );
    },
    /**
     * 清除条件筛选后红色显示
     */
    removeHighRedNode() {
      let arr = document.getElementsByClassName('red-node-selected')
      // 清除其他高亮节点
      if (arr) {
        while (arr.length > 0) {
          removeClass(arr[0], 'red-node-selected')
        }
      }
    },
    /**
     * 初始化：左侧结构树
     */
    async initLeftTree() {
      let _that = this;
      _that.treeLoading = true;
      await this.$api.getLeftTree({
        fmeaId: this.$route.query.rfmeaId
      }).then((res) => {
        if (res.flag) {
          let targetNode = res.data.rdfmStruTreeModels.filter((item) => {
            return item.pid === '00000000000000000000000000000000';
          })[0];
          _that.initData = res.data.rdfmStruTreeModels;
          // 构建：treeData数据
          _that.buildTreeData(targetNode, res.data.rdfmStruTreeModels);
          // 初始化数据
          _that.initTreeData = JSON.parse(JSON.stringify(_that.treeData));
          // // 显示/隐藏，节点
          // _that.showHideTreeNode(targetNode);
          // // 是否存在复制，需要高亮显示
          // _that.restoreHighLightCopyNode();
          // // 粘贴后节点可视区域
          // _that.pasteAfterNodeScrollIntoView();
          this.getFmeaElementStru()
        } else {
          _that.$message.error(res.message, 1);
        }
      }).finally(() => {
        _that.treeLoading = false;
        // 上下节点移动标识
        _that.$parent.$parent.$parent.$parent.$parent.moveNodeFlag = true;
        //_that.refreshBtnStatus();
        _that.selectedNode = [];
        _that.multipleDelete = false;
      });
    },
    /**
     * 获取相关联的详细的数据
     */
    getFmeaElementStru() {
      // 初始化数据
      this.selectedRows = []
      this.selectedRowKeys = []
      this.loading = true
      let data = {
        fmeaId: this.$route.query.rfmeaId,
        rfmeaId: this.$route.query.rfmeaId,
        pfmeaId: this.queryParam.rfmeaId,
        struId: this.queryParam.struId,
        struTypeCode: this.queryParam.strucType,
        funcName: this.queryParam.functionName,
        type: 1,
        pageNo: this.pageNo,
        pageSize: this.pageSize,
        classifyId: this.queryParam.classifyId
      }
      this.$api.getFmeaElementStru(data).then((res) => {
        if (res.flag) {
          this.tableData = res.data.data
          this.pagination.total = res.data.total || 0;
          for (let i = 0; i < this.tableData.length; i++) {
            if (this.tableData[i].showFlag == 0) {
              this.selectedRows.push(this.tableData[i])
              this.selectedRowKeys.push(i)
            }
          }
        }
        this.loading = false
      });
    },
    /**
     * 获取节点样式
     * @param node
     */
    getNodeClass(node) {
      let color = "";
      let range = node.rightNo - node.leftNo - 1;
      (node.children || []).forEach(child => {
        range -= (child.rightNo - child.leftNo + 1);
      })
      if (range > 0) {
        color += "left-tree-node-border";
      }
      return color;
    },
    /**
     * 构建：treeData数据
     * @param targetNode 目标节点
     * @param nodes 节点数组
     */
    buildTreeData(targetNode, nodes) {
      // 数组转Tree
      let treeData = arrayToTree(targetNode, nodes);
      this.allNode = [];
      // 添加插槽
      this.treeData = this.addScopedSlots(treeData);
      // 默认展开全部节点
      this.expandedKeys = [];
      this.defaultExpandedAllKeys(treeData);
    },
    /**
     * 添加插槽
     * @param nodes 节点数组
     */
    addScopedSlots(nodes) {
      for (let i = 0, len = nodes.length; i < len; i++) {
        // 默认节点展开状态
        nodes[i]['expanded'] = true;
        this.allNode.push(nodes[i]);
        // 通过vue 自带的$set 给每条数据加上一个名为scopedSlots，值为{title: 'node'}，的插槽
        this.$set(nodes[i], "scopedSlots", {title: "treeDataSlot"});
        if (nodes[i].children && nodes[i].children.length > 0) {
          this.addScopedSlots(nodes[i].children);
        }
      }
      return nodes;
    },
    /**
     * 默认展开全部节点
     */
    defaultExpandedAllKeys(treeData) {
      let _that = this;
      for (let i = 0, len = treeData.length; i < len; i++) {
        // 重新赋值
        if (_that.$store.getters.lastCheckedNode
            && _that.$store.getters.lastCheckedNode.id === treeData[i].id) {
          _that.setCheckedNode(treeData[i]);
        }
        _that.expandedKeys.push(treeData[i].id);
        if (treeData[i].children && treeData[i].children.length > 0) {
          _that.defaultExpandedAllKeys(treeData[i].children);
        }
      }
    },

    getFeatureClassifyDict() {
      this.$api.getFeatureClassifyDict({rfmeaId: this.$route.query.rfmeaId}).then((res) => {
        if (res.flag) {
          this.featureClassifyDict = res.data
        }
      })
    },
  }
  ,
  mounted() {
    this.fmeaId = this.$route.query.fmeaId ? this.$route.query.fmeaId : '';
    //this.getProjectPFMEAPageList();
    this.getQuotePFMEAList();
    this.getFeatureClassifyDict();
    this.removeHighRedNode();
  }
}
</script>
<style lang="less" scoped>
// 设置model 全屏
/deep/ .ant-modal {
  top: 0 !important;
}

// 设置model 全屏
/deep/ .ant-modal-content {
  height: calc(100vh);
}

// 不加上弹窗就会有滚动条;
/deep/ .ant-modal-wrap {
  overflow: hidden !important
}

.red-node-selected {
  border: 3px solid #1890FF !important;
  border-radius: 2px;
}

.leftTree-node-selected {
  background-color: #bae7ff;
  border-radius: 2px;
}

.left-tree-node-border {
  border: 2px solid #d9edf7;
}

/deep/ .clickContent {
  color: #1890ff;
  cursor: pointer;
}

.leftTree {
  height: 95%;
  overflow-x: hidden;
  overflow-y: auto;
  background-color: #f5f5f5;
}

.filter-boxn {
  padding: 8px 0 8px 16px;
}

.boxlr {
  border: 1px solid #e8e8e8;
  padding: 5px;
  height: 92%;
}

.borbot {
  height: 47px;
}

.cannotDel {
  color: gray;
}

.btn-wrap-fmea {
  margin-top: 3%;
  float: right;
}

/deep/ .ant-modal-body {
  padding: 0 !important;
  height: 100%;
}


/deep/ .ant-tree-title {
  width: 100%;

  a {
    width: 100%;
  }
}

.FMEADialog {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/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>
