<template>
  <div class="manualTagEdit-wrap common-wrap">
    <nav-crumb :navpath="navpath"></nav-crumb>
    <div class="right-content">
      <div class="right-box">
        <div class="manualTagEdit-wrap__title">标签基本信息</div>

        <div class="manualTagEdit-wrap__form">
          <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="78px">
            <el-form-item label="标签名称" prop="tagName" class="w-329">
              <el-input class="w-220" placeholder="请输入内容" v-model="ruleForm.tagName" :maxlength="10"></el-input>
              <label class="input-label">{{ ruleForm.tagName.length }}/10</label>
            </el-form-item>
            <el-form-item label="所属分类" prop="tagLevel">
              <el-form-item prop="tagTwoLevelGroupId" class="fl">
                <el-select class="w-220" placeholder="请选择" v-model="ruleForm.tagTwoLevelGroupId" @change="changeTwo">
                  <el-option
                    v-for="item in optionsTwo"
                    :key="item.tagLevelGroupId"
                    :label="item.levelName"
                    :value="item.tagLevelGroupId">
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item prop="tagLevelGroupId" class="fl">
                <el-select class="w-220 m-l-8" placeholder="请选择" v-model="ruleForm.tagLevelGroupId">
                  <el-option
                    v-for="item in optionsThree"
                    :key="item.tagLevelGroupId"
                    :label="item.levelName"
                    :value="item.tagLevelGroupId">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-form-item>
            <el-form-item label="标签描述" prop="tagDescribe" class="w-560">
              <el-input class="w-447" type="textarea" row="4" v-model="ruleForm.tagDescribe" :maxlength="200">
              </el-input>
              <label class="textarea-label">{{ ruleForm.tagDescribe.length }}/200</label>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" :disabled="canSave" @click="confirmSave">保存</el-button>
            </el-form-item>
          </el-form>
        </div>

        <div class="manualTagEdit-wrap__title">标签值设置</div>

        <!-- 标签值列表 -->
        <div class="manualTagEdit-wrap__form" v-if="tagValTableData.length > 0">
          <el-table :data="tagValTableData">
            <el-table-column label="标签值" prop="tagItemName"></el-table-column>
            <el-table-column label="操作">
              <template slot-scope="scope">
                <!-- 初始状态和导入完成状态 -->
                <template v-if="scope.row.updateStatus === -1 || scope.row.updateStatus === 1">
                  <el-button type="text" size="small" @click="showImportPop(scope.$index, scope.row)">导入会员</el-button>
                  <!-- 导入完成 -->
                  <span v-if="scope.row.updateStatus === 1" class="uploading-succ">
                    上传完成
                    <span v-show="scope.row.needError > 0">
                      <span class="uploading-succ-btn" @click="downloadErrorData(scope.row.tagItemId)">点击下载</span>失败会员清单
                    </span>
                  </span>

                  <!-- 删除的初始状态 -->
                  <template v-if="scope.row.delStatus === -1">
                    <el-popover placement="top" width="300" trigger="click" :v-model="scope.row.showDelPopOver">
                      <p>删除标签后，符合该标签值的会员对应标签值将同步删除。一旦删除将无法恢复，确认要删除吗？</p>
                      <div style="text-align: right; margin: 5px 0 0 0;">
                        <el-button type="text" size="mini" @click="closeDelPopOver(scope.$index)">取消</el-button>
                        <el-button type="primary" size="mini" @click="delTagApi(scope.$index, scope.row)">确定</el-button>
                      </div>
                      <el-button type="text" size="small" slot="reference" @click="scope.row.showDelPopOver = true">删除</el-button>
                    </el-popover>
                  </template>
                  <!-- 删除中的状态 -->
                  <template v-else>
                    <span class="color-c0c4cc">删除中...</span>
                  </template>
                </template>
                <!-- 正在上传中 -->
                <div v-if="scope.row.updateStatus === 0" class="uploading">
                  <span>正在上传</span>
                  <span class="uploading-progress">
                    <el-progress
                      :percentage="scope.row.percent">
                    </el-progress>
                  </span>
                </div>
              </template>
            </el-table-column>
          </el-table>
          <div class="add-tag">
            <div class="add-tag-btn" @click="addTagValPop.isShow = true">
              <i class="iconfont icon-icon02"></i>
              添加标签值
            </div>
          </div>
        </div>
        <!-- 无标签值 -->
        <div class="no-tag-value" v-else>
          <p class="font-14 color-909399">你还没有标签值，</p>
          <p class="m-t-10 font-14 color-909399">请先完善标签基本信息再添加标签值</p>
          <el-button class="m-t-18" :disabled="!canAddTagVal" type="primary" @click="addTagValPop.isShow = true">添加标签值</el-button>
        </div>
        <!-- 添加标签值 -->
        <el-dialog title="添加标签值" :visible.sync="addTagValPop.isShow" width="490px" custom-class="manual-dialog">
          <div class="add-tag-val">
            <span>标签值</span>
            <el-input placeholder="请输入" :maxlength="10" v-model.trim="addTagValPop.tagVal"></el-input>
            <label class="input-label">{{addTagValPop.tagVal.length}}/10</label>
          </div>
          <template slot="footer">
            <el-button @click="closeAddPop">取消</el-button>
            <el-button type="primary" @click="addTagVal">确定</el-button>
          </template>
        </el-dialog>
        <!-- excel导入 -->
        <el-dialog :title="importPop.title" :visible.sync="importPop.isShow" width="600px" custom-class="manual-dialog">
          <div class="import">
            <div class="excel-icon">
              <svg v-show="importPop.excelData.length > 0" aria-hidden="true" width="40px" height="40px">
                <use xlink:href="#icon-excel"></use>
              </svg>
              <svg v-show="importPop.excelData.length === 0" aria-hidden="true" width="40px" height="40px">
                <use xlink:href="#icon-tianjia"></use>
              </svg>
            </div>
            <div class="import-cont">
              <div class="import-handle">
                <input type="file" style="display: none" accept=".xlsx, .xls, .csv" ref="upload" @change="handleFileChange">
                <span v-if="importPop.excelData.length === 0" class="import-btn" @click="handleUpload">点击上传会员</span>
                <template v-if="importPop.excelData.length > 0">
                  <span>{{importPop.excelName}}</span>
                  <span class="import-num">已导入会员 {{importPop.excelData.length}} 人</span>
                  <el-button type="text" @click="handleUpload">重新导入</el-button>
                </template>
              </div>
              <div class="import-tip">
                只能上传一个excle文件（2003版本以上），且数据不超过5000条
                <el-button type="text" @click="downloadExcelTemp">下载Excel模板</el-button>
              </div>
              <div class="clear-old">
                <el-checkbox v-model="importPop.optType">清空标签历史标记会员</el-checkbox>
                <el-tooltip content="勾选后，此前被该标签标记的会员将移除此标签，此标签标记会员以本次导入为准。">
                  <i class="iconfont icon-xinxixianshi"></i>
                </el-tooltip>
              </div>
            </div>
          </div>
          <template slot="footer">
            <el-button @click="closeImportPop">取消</el-button>
            <el-button type="primary" @click="tagItemImport">确定</el-button>
          </template>
        </el-dialog>
      </div>
    </div>
    <vue-gic-footer></vue-gic-footer>
  </div>
</template>
<script>
import './manualTagEdit.css';
import '@/../static/font/iconfont';
import XLSX from 'xlsx';
import navCrumb from '@/components/nav/nav.vue';
import { export_json_to_excel } from '@/vendor/Export2Excel';
import showMsg from '@/common/js/showmsg';
import errMsg from '@/common/js/error';
import { getRequest, postRequest } from '@/api/api';
export default {
  name: 'manualTagEdit',
  data() {
    return {
      // 编辑标签的时候,获取标签的 id
      tagId: '',
      // 标签的基本信息
      tagInfo: {
        tagName: '',
        tagDescribe: '',
        tagLevelGroupId: ''
      },
      // 标签基本信息模块的表单
      ruleForm: {
        tagName: '',
        tagLevel: 'test',
        tagTwoLevelGroupId: '',
        tagLevelGroupId: '',
        tagDescribe: ''
      },
      // 标签基本信息模块的表单验证
      rules: {
        tagName: [{ required: true, message: '请输入标签名称', trigger: 'blur' }],
        tagLevel: [{ required: true, message: '' }],
        tagLevelGroupId: [{ required: true, message: '请选择所属分类', trigger: 'blur' }],
        tagTwoLevelGroupId: [{ required: true, message: '请选择所属分类', trigger: 'blur' }]
      },
      // 标签所属分类的下拉列表数据
      optionsTwo: [],
      optionsThree: [],

      // 添加标签值的弹窗的相关数据
      addTagValPop: {
        isShow: false,
        tagVal: '',
      },

      // excel导入的弹窗的相关数据
      importPop: {
        isShow: false,
        // 标签值的索引
        tagItemIndex: '',
        // 标签值的id
        tagItemId: '',
        // false=0: 不删除, true=1: 删除
        optType: false,
        title: '',
        // 当前上传 excel 的表格名字
        excelName: '',
        // 当前上传 excel 内容的数据
        excelData: [],
        // 当前上传 excel 表头的数据
        excelHeader: []
      },

      // 标签值列表的数据
      tagValTableData: []
    };
  },
  computed: {
    // 面包屑参数
    navpath() {
      let that = this;
      return [
        {
          name: '首页',
          path: `${window.location.origin}/report/#/memberSummary`,
          relocation: true
        },
        {
          name: '会员管理',
          path: ''
        },
        {
          name: '会员标签',
          path: `/member-tag`
        },
        // {
        //   name: '手工标签列表',
        //   path: '/manualTagList'
        // },
        {
          name: that.$route.query.tagId ? '手工标签编辑' : '新增手工标签',
          path: ''
        }
      ];
    },
    // 新增标签，保存按钮长亮
    // 编辑标签，当标签基本信息有改动时，保存按钮亮起
    canSave() {
      // 新增标签
      if (!this.tagId) return false;
      // 编辑标签
      return this.tagInfo.tagName === this.ruleForm.tagName
        && this.tagInfo.tagDescribe === this.ruleForm.tagDescribe
        && this.tagInfo.tagLevelGroupId === this.ruleForm.tagLevelGroupId;
    },
    // 新增标签值按钮是否可用
    canAddTagVal() {
      /**
       * 新增分组，必须先保存标签基本信息
       * 编辑分组，保持常亮
       * */
      return !!this.tagId;
    }
  },
  methods: {
    // 关闭删除标签值得popover弹窗
    closeDelPopOver(index) {
      let copy = this.tagValTableData.slice(0);
      copy[index].showDelPopOver = false;
      this.tagValTableData.splice(0);
      this.$nextTick(() => {
        this.tagValTableData = copy;
      })
    },

    // 保存标签基本信息
    confirmSave() {
      this.$refs.ruleForm.validate((valid) => {
        if (valid) this.saveApi();
      });
    },

    // 保存标签基本信息
    saveApi() {
      const para = {
        tagId: this.tagId,
        tagName: this.ruleForm.tagName,
        tagDescribe: this.ruleForm.tagDescribe,
        tagLevelGroupId: this.ruleForm.tagLevelGroupId
      };

      getRequest('/memberTag/saveHandMemberTag', para).then(res => {
        const { errorCode, result, message } = res.data;
        if (errorCode !== 1) {
          this.$message.error({
            duration: 1000,
            message: message
          })
          return;
        }
        showMsg.showmsg('保存成功', 'success');
        // 如果新增需要获取 tagId
        this.tagId = result;
        this.tagInfo = {
          tagName: this.ruleForm.tagName,
          tagDescribe: this.ruleForm.tagDescribe,
          tagLevelGroupId: this.ruleForm.tagLevelGroupId
        }
        // 获取标签值列表
        this.getValueData();
      }).catch(error => {
        this.$message.error({
          duration: 1000,
          message: error.message
        });
      });
    },

    // 取消添加标签值
    closeAddPop() {
      this.addTagValPop.isShow = false;
      this.addTagValPop.tagVal = '';
    },

    // 添加标签值
    addTagVal() {
      if (this.addTagValPop.tagVal.length === 0) {
        this.$message.error({
          duration: 1000,
          message: '请输入标签值'
        });
        return false;
      }
      if (this.tagValTableData.some(item => item.name === this.addTagValPop.tagVal)) {
        this.$message.error({
          duration: 1000,
          message: '标签值已存在'
        });
        return false;
      }
      this.addTagItem('', this.addTagValPop.tagVal);
      this.closeAddPop();
    },

    // 添加和编辑标签值
    addTagItem(tagItemId, tagItemName) {
      const para = {
        tagItemId: tagItemId,
        tagItemName: tagItemName,
        tagId: this.tagId
      };

      getRequest('/memberTag/saveHandTagItem', para).then(res => {
        const { errorCode } = res.data;
        if (errorCode === 1) {
          showMsg.showmsg('添加成功', 'success');
          this.getValueData();
          return;
        }
        errMsg.errorMsg(res.data);
      }).catch(error => {
        this.$message.error({
          duration: 1000,
          message: error.message
        });
      });
    },

    confirmDel(index, item) {
      // 业务逻辑变更，不需要此拦截弹窗  2019-05-22
      return;
      this.$confirm('删除标签后，符合该标签值的会员对应标签值将同步删除。一旦删除将无法恢复，确认要删除吗？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.delTagApi(index, item);
      });
    },

    // 删除标签值
    delTagApi(index, item) {
      const para = {
        tagItemId: item.tagItemId
      };
      getRequest('/memberTag/delHandTagItem', para).then(res => {
        const { errorCode } = res.data;
        if (errorCode === 1) {
          item.delStatus = 0;
          this.getImportReport(index, item.tagItemId);
          return;
        }
        errMsg.errorMsg(res.data);
      }).catch(error => {
        this.$message.error({
          duration: 1000,
          message: error.message
        });
      });
    },

    // 获取标签值列表
    getValueData() {
      const para = {
        tagId: this.tagId
      };
      getRequest('/memberTag/queryHandTagItem', para).then((res) => {
        const { errorCode, result } = res.data;
        if (errorCode === 1) {
          /**
           * 前端自定义的扩展字段
           * 为了实现一个标签值的数据上传中另一个标签值仍可以上传的功能
           * 上传完毕后，扩展字段需要重置
           * */
          result.forEach(ele => {
            // 删除状态 -1=默认 0=删除中
            ele.delStatus = -1;
            ele.showDelPopOver = false;
            // 上传状态 -1=默认 0=上传中 1=上传完成
            ele.updateStatus = -1;
            // 上传的错误数量
            ele.needError = 0;
            // 上传进度百分比值
            ele.percent = 0;
          });
          this.tagValTableData = result;
          return;
        }
        errMsg.errorMsg(res.data);
      }).catch(error => {
        this.$message.error({
          duration: 1000,
          message: error.message
        });
      });
    },

    // 显示导入会员的弹窗
    showImportPop(index, row) {
      this.importPop.isShow = true;
      this.importPop.tagItemIndex = index;
      this.importPop.tagItemId = row.tagItemId;
      this.importPop.title = `${row.tagItemName}-导入会员`
    },

    // 关闭导入会员的弹窗
    closeImportPop() {
      this.importPop.isShow = false;
      this.resetImportData();
    },

    // 计算上传进度百分比的值
    getUpdatePercent(total, need) {
      const num = parseInt((total - need) / total * 100);
      return num === 100 ? 99 : num;
    },

    // 重置导入的表格数据
    resetImportData() {
      this.importPop.excelName = '';
      this.importPop.excelData = [];
      this.importPop.excelHeader = [];
      this.importPop.optType = false;
    },

    // 点击上传文件、重新导入按钮
    handleUpload() {
      this.$refs.upload.click();
    },

    // 处理上传的表格
    handleFileChange(e) {
      const files = e.target.files[0];
      if (!files) return;
      this.importPop.excelName = files.name;
      const reader = new FileReader();
      reader.onload = e => {
        const data = e.target.result;
        const fixedData = this.fixData(data);
        const workbook = XLSX.read(btoa(fixedData), { type: 'base64' });
        const firstSheetName = workbook.SheetNames[0];
        const worksheet = workbook.Sheets[firstSheetName];
        if (Object.keys(worksheet).indexOf('!ref') === -1) {
          this.$message.error({
            duration: 1000,
            message: '文档内容为空'
          });
          return false;
        }
        this.importPop.excelHeader = this.get_header_row(worksheet);
        this.importPop.excelData = XLSX.utils.sheet_to_json(worksheet);
        if (this.importPop.excelData.length > 5000) {
          this.$message.error({
            duration: 1000,
            message: '单次上传数据不能超过 5000 条,请重新上传文件'
          });
        }
      };
      reader.readAsArrayBuffer(files);
    },

    fixData(data) {
      let o = '';
      let l = 0;
      const w = 10240;
      for (; l < data.byteLength / w; ++l) o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w, l * w + w)));
      o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w)));
      return o;
    },

    get_header_row(sheet) {
      const headers = [];
      const range = XLSX.utils.decode_range(sheet['!ref']);
      let C;
      const R = range.s.r; /* start in the first row */
      for (C = range.s.c; C <= range.e.c; ++C) {
        /* walk every column in the range */
        let cell = sheet[XLSX.utils.encode_cell({ c: C, r: R })]; /* find the cell in the first row */
        let hdr = 'UNKNOWN ' + C; // <-- replace with your desired default
        if (cell && cell.t) hdr = XLSX.utils.format_cell(cell);
        headers.push(hdr);
      }
      return headers;
    },

    uploadExcel() {
      // 上传之前，不需要根据是否勾选“清空标签历史标记会员”进行拦截 2019-05-22
      return;
      if (this.importPop.optType) {
        this.$confirm('勾选此选项则清空之前有此标签会员身上的标签，以本次导入会员为准；否则本次导入和之前已有数据去重添加。请慎重选择！', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(this.tagItemImport);
        return;
      }
      this.tagItemImport()
    },

    // 导入数据到服务端
    tagItemImport() {
      if (this.importPop.excelData.length === 0) {
        this.$message.error({
          duration: 1000,
          message: '导入数据有为空或者数据异常'
        });
        return;
      }
      const para = {
        tagItemId: this.importPop.tagItemId,
        data: JSON.stringify(this.importPop.excelData)
      };
      postRequest('/memberTag/uploadHandTagItemImport', para).then((res) => {
        const { errorCode } = res.data;
        errorCode === 1 ? this.handTagItemImport() : errMsg.errorMsg(res.data);
      }).catch(error => {
        this.$message.error({
          duration: 1000,
          message: error.message
        });
      });
    },

    // 服务端处理导入数据
    handTagItemImport() {
      let { tagItemIndex, tagItemId, optType } = this.importPop;
      optType = optType ? 1 : 0;

      getRequest('/memberTag/dealHandTagItemImport', { tagItemId, optType }).then((res) => {
        const { errorCode } = res.data;
        if (errorCode === 1) {
          // 关闭上传的弹窗
          this.closeImportPop();
          // 查询上传进度
          this.getImportReport(tagItemIndex, tagItemId);
        } else {
          errMsg.errorMsg(res.data);
        }
      }).catch(error => {
        this.$message.error({
          duration: 1000,
          message: error.message
        });
      });
    },

    // 查询上传、删除的进度
    getImportReport(tagItemIndex, tagItemId) {
      getRequest('/memberTag/getImportReport', { tagItemId }).then((res) => {
        const { errorCode, result } = res.data;
        if (errorCode === 1) {
          // 0 删除 1正常 2导入中 3 导入完成 4 删除中 5删除项 6 处理中 7 异常 8 处理成功
          switch (result.status) {
            case 0:
              // 已删除
              this.getValueData();
              break;
            case 5:
              // 删除中
              setTimeout(() => { this.getImportReport(tagItemIndex, tagItemId) }, 500);
              break;
            case 4:
            case 6:
              // 上传中，此状态下需要轮询
              // 上传状态 0=上传中 1=上传完成
              this.tagValTableData[tagItemIndex].updateStatus = 0;
              // 上传的错误数量
              this.tagValTableData[tagItemIndex].needError = result.needError;
              this.tagValTableData[tagItemIndex].percent = this.getUpdatePercent(result.totalNum, result.needExec);
              setTimeout(() => { this.getImportReport(tagItemIndex, tagItemId) }, 500);
              break;
            case 8:
              // 上传完成， 结束轮询
              this.tagValTableData[tagItemIndex].updateStatus = 1;
              // 上传的错误数量
              this.tagValTableData[tagItemIndex].needError = result.needError;
              // 重置百分比为0
              this.tagValTableData[tagItemIndex].percent = 0;
              break;
            default:
              // 出现异常情况，上传按钮恢复到-1状态
              this.tagValTableData[tagItemIndex].delStatus = -1;
              this.tagValTableData[tagItemIndex].updateStatus = -1;
              // 重置错误数量、百分比为0
              this.tagValTableData[tagItemIndex].needError = 0;
              this.tagValTableData[tagItemIndex].percent = 0;
              break;
          }
        } else {
          errMsg.errorMsg(res.data);
        }
      }).catch(error => {
        this.$message.error({
          duration: 1000,
          message: error.message
        });
      });
    },

    // 下载上传失败的会员清单
    downloadErrorData(tagItemId) {
      getRequest('/memberTag/queryImportErrorData', { tagItemId }).then(res => {
        const { errorCode, result } = res.data;
        if (errorCode === 1) {
          if (result && result.length) {
            const header = Object.keys(result[0]);
            //获取数据后执行 excel 导出
            const data = result.map(item => header.map(key => item[key]));
            export_json_to_excel(header, data, '导出列表');
          } else {
            this.$message.error({
              duration: 1000,
              message: '暂无失败数据'
            });
          }
          return;
        }
        errMsg.errorMsg(res.data);
      }).catch(error => {
        this.$message.error({
          duration: 1000,
          message: error.message
        });
      });
    },

    // 导出 excel 模板
    downloadExcelTemp() {
      const tHeader = ['手机号', '卡号'];
      const data = [
        ['17098078224', 'jhdm2018071315'],
        ['13100000055', 'jhdm20180608000000003']
      ];
      export_json_to_excel(tHeader, data, '导入 excel 模板');
    },

    // 获取二级分类列表
    getOptionsTwo() {
      getRequest('/tagLevel/handSecondLevel', {}).then(res => {
        const { errorCode, result } = res.data;
        if (errorCode === 1) {
          this.optionsTwo = result;
        }
      }).catch(error => {
        this.$message.error({
          duration: 1000,
          message: error.message
        });
      });
    },

    // 点击二级分类获取三级分类列表
    changeTwo(value) {
      this.ruleForm.tagLevelGroupId = '';
      this.getOptionsThree(value);
    },

    // 获取三级分类列表
    getOptionsThree(tagLevelGroupId) {
      getRequest('/tagLevel/handThirdLevel', { tagLevelGroupId }).then(res => {
        const { errorCode, result } = res.data;
        if (errorCode === 1) {
          this.optionsThree = result;
        }
      }).catch(error => {
        this.$message.error({
          duration: 1000,
          message: error.message
        });
      });
    },

    // 编辑时获取当前标签数据
    getTagData(tagId) {
      getRequest('/memberTag/getTagById', { tagId }).then(res => {
        const { errorCode, result } = res.data;
        if (errorCode === 1) {
          this.ruleForm.tagName = result.tagName;
          this.ruleForm.tagLevelGroupId = result.tagLevelGroupId;
          this.ruleForm.tagTwoLevelGroupId = result.tagTwoLevelGroupId;
          this.ruleForm.tagDescribe = result.tagDescribe;
          this.tagInfo = {
            tagName: result.tagName,
            tagLevelGroupId: result.tagLevelGroupId,
            tagDescribe: result.tagDescribe
          }
          // 根据已选二级 id 获取三级列表
          this.getOptionsThree(result.tagTwoLevelGroupId);
          // 获取标签值列表
          this.getValueData();
        }
      }).catch(err => {
        console.log(err);
      });
    }
  },
  mounted() {
    const tagId = this.$route.query.tagId;

    // 获取二级列表
    this.getOptionsTwo();

    if (tagId) {
      // 编辑
      this.tagId = tagId;
      this.getTagData(tagId);
    } else {
      // 新增
      let tagList = localStorage.getItem('jumpTag');
      let tagThirdList = localStorage.getItem('jumpThirdTag');

      if (tagList) {
        tagList = JSON.parse(tagList);
        this.ruleForm.tagTwoLevelGroupId = tagList.id;
        this.getOptionsThree(tagList.id);
      }
      if (tagList && tagThirdList) {
        tagThirdList = JSON.parse(tagThirdList);
        this.ruleForm.tagLevelGroupId = tagThirdList.id;
      }
    }
  },
  components: {
    navCrumb
  }
}
</script>
<style lang="less" scoped>
  .right-box {
    padding: 0 !important;
    .manualTagEdit-wrap__title {
      padding: 18px 42px 16px;
      width: 100%;
      font-size: 16px;
      color: #303133;
      border-bottom: 2px solid #EDEFF2;
    }
    .manualTagEdit-wrap__form {
      padding: 30px 42px;
    }
    .input-label {
      position: absolute;
      top: 2px;
      right: 45px;
      z-index: 1;
      font-size: 12px;
      color: #C0C4CC;
    }
    .textarea-label {
      .input-label;
      top: 65px;
      right: 55px;
    }
    .no-tag-value {
      padding: 60px 0 65px;
      text-align: center;
    }
    .add-tag-val {
      position: relative;
      display: flex;
      align-items: center;
      margin: 0 auto;
      width: 375px;
      span {
        margin-right: 10px;
        flex: 1 1 55px;
        font-size: 14px;
      }
      .input-label{
        display: flex;
        align-items: center;
        right: 10px;
        top: 0;
        height: 100%;
      }
    }
    .add-tag {
      border-bottom: 1px solid #E4E7ED;
      .add-tag-btn {
        margin: 0 auto;
        width: 100px;
        height: 48px;
        text-align: center;
        line-height: 48px;
        font-size: 14px;
        color: #909399;
        cursor: pointer;
        &:hover {
          color: #1890ff;
        }
      }
    }
    .import {
      display: flex;
      align-items: start;

      .excel-icon {
        margin-right: 10px;
        width: 40px;
      }

      .import-cont {
        padding-top: 5px;
        width: 500px;

        .import-handle {
          display: flex;
          align-items: center;
          font-size: 14px;
          color: #606266;

          .import-btn {
            display: inline-block;
            max-width: 200px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            cursor: pointer;
          }

          .import-num {
            margin-left: 24px;
            padding-right: 15px;
            margin-right: 12px;
            color: #909399;
            border-right: 1px solid #DCDFE6;
          }
        }

        .import-tip {
          font-size: 12px;
          color: #909399;
        }

        .clear-old {
          margin-top: 24px;
          font-size: 14px;
          color: #606266;

          .icon-xinxixianshi {
            font-size: 12px;
            color: #909399;
          }
        }
      }
    }
    .uploading {
      color: #909399;
      font-size: 14px;
      .uploading-progress {
        padding: 0 0 0 10px;
        display: inline-block;
        width: 200px;
      }
    }
    .uploading-succ {
      padding: 0 30px 0 20px;
      color: #909399;
      .uploading-succ-btn {
        padding: 0 10px 0 5px;
        color: #f5222d;
        cursor: pointer;
      }
    }
  }

  .w-447 {
    width: 447px;
  }

  .w-560 {
    width: 560px;
  }
</style>
