/* eslint-disable */
export default {
  data() {
    return {
      editContent: [], //  选项
      activeOption: {}, //  当前操作项
      showRemoveTag: false, //  是否显示移除标签 默认显示
      inputValue: '', //  显示字段
    };
  },
  watch: {
    // editContent: {
    //   handler(list) {
    //     // if(!list) return
    //     // // const inputList = _.cloneDeep(list)
    //     // const inputList = JSON.parse(JSON.stringify(list));
    //     // // const allSelectIndex = _.findIndex(inputList, item => item === 'allSelect')
    //     // const allSelectIndex = inputList.findIndex((v) => v === 'allSelect');
    //     // if (allSelectIndex !== -1)inputList.splice(allSelectIndex, 1);
    //     // this.inputValue = inputList.join(',');
    //   },
    //   // immediate: true,
    //   // deep: true,
    // },
  },
  methods: {
    clickOption(option) {
      console.log('clickOption', option);
      // this.activeOption = option;
      // setTimeout(() => {
      //     this.dealSelect(this.editContent, option)
      // }, 100)
    },
    changeSelect(list) {
      const lastItem = list[list.length - 1];
      // if(lastItem !== 'allSelect') {}
      if (list.some((v) => v === 'allSelect')) {
        // 去除选择全部品牌
        if (lastItem === 'allSelect') {
          console.log('%c全选', 'color:red;font-size:16px;text-shadow:1px 1px 1px blue;', list);
          // list = list.filter(v => v !== 'allSelect')
          list = this.editor.options.filter((o) => o.value !== 'unLimit').map((v) => v.value);
          console.log(list)
        } else if (lastItem !== 'allSelect') {
          console.log('%c取消全选', 'color:red;font-size:16px;text-shadow:1px 1px 1px blue;', list);
          // const allSelectIndex = _.findIndex(list, item => item === 'allSelect')
          const allSelectIndex = list.findIndex((v) => v === 'allSelect');
          list.splice(allSelectIndex, 1);
        }
      }
      // 去除选择不限制
      if (list.some((v) => v === 'unLimit')) {
        // 去除选择全部品牌
        if (lastItem === 'unLimit') {
          console.log('%c反选', 'color:red;font-size:16px;text-shadow:1px 1px 1px blue;', list);
          // list = list.filter(v => v !== 'unLimit')
          list = this.editor.options.filter((o) => o.value === 'unLimit').map((v) => v.value);
        } else if (lastItem !== 'unLimit') {
          console.log('%c取消反选', 'color:red;font-size:16px;text-shadow:1px 1px 1px blue;', list);
          // const unLimitIndex = _.findIndex(list, item => item === 'unLimit')
          const unLimitIndex = list.findIndex((v) => v === 'unLimit');
          list.splice(unLimitIndex, 1);
        }
      }
      if (list.filter(i => i === 'unLimit').length > 0) {
        list = this.editor.options.filter((o) => o.value === 'unLimit').map((v) => v.value);
      }
      // 如果等于全选品牌数量，勾选全部品牌
      else if (list.length === this.editor.options.length - 2) {
        console.log('单独选择品牌-如果等于全选品牌数量，勾选全部品牌');
        list = this.editor.options.filter((o) => o.value !== 'unLimit').map((v) => v.value);
      }
      // const allSelectIndex = list.findIndex(item => item === 'allSelect')
      // if(allSelectIndex !== -1) list.splice(allSelectIndex, 1)
      this.editContent = list;
    },
  },
};
