"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const uuid = require('@lukeed/uuid');
const cheerio = require("cheerio");
const storage_1 = require("../../../../storage");
const Base_1 = require("../Base");
const _ = require("lodash");
class Column extends Base_1.default {
    constructor(data, storage) {
        super(storage);
        this.uuid = '';
        this.components = [];
        this.name = 'column';
        this.previewType = 0;
        this.config = null;
        this.boxStrs = '';
        this.storage = {};
        this.type = 'inline';
        this.path = '/box/Table/column';
        this.storage = storage;
        this.uuid = uuid().split('-')[0];
        if (data.config) {
            this.config = data.config;
        }
        else {
            this.config = _.cloneDeep(require('./columnConfig').default);
        }
        this.setAttrsToStr();
    }
    setPreview() {
        this.previewType = storage_1.default.get('preview_view_status') || 0;
        const type = _.get(this.config, 'model.custom.type');
        let containerBox = `<div class="drag-box"></div>`;
        let column = '';
        let expandStr = '';
        if (type === 'expand') {
            expandStr = `type="${type}"`;
        }
        if (this.previewType === 0) {
            containerBox = ` 
        <box 
          data-id="${this.uuid}"
          :uuid="'${this.uuid}'" 
          class="block-item" 
          label="column"
        >
          ${expandStr ? '<div />' : ''}
          <div class="drag-box"></div>
        </box>`;
            const cellbox = `
      <template slot-scope="{row, column, $index}">
        ${containerBox}
      </template>
      `;
            column = `
        <el-table-column
          ${this._attrStr}
          ${expandStr}
          label="${_.get(this.config, 'model.custom.label')}"
        >
          <template slot="header" slot-scope="{row, column, $index}">
            <edit-text-box uuid="${this.uuid}" :label="column.label"></edit-text-box>
          </template>
          ${cellbox}
        </el-table-column>  
      `;
        }
        else {
            const cellbox = `
      <template slot-scope="{row, column, $index}">
        ${containerBox}
      </template>
      `;
            column = `
        <el-table-column
          ${this._attrStr}
          ${expandStr}
          label="${_.get(this.config, 'model.custom.label')}"
        >
          ${cellbox}
        </el-table-column>  
      `;
        }
        if (type === 'index' || type === 'selection') {
            column = `
        <el-table-column
          ${this._attrStr}
          type="${type}"
          label="${_.get(this.config, 'model.custom.label')}"
        >
        </el-table-column>  
      `;
        }
        this.$fragment = cheerio.load(column, {
            xmlMode: true,
            decodeEntities: false
        });
        this.renderComp();
    }
    insertEditText(params) {
        this.config.model.custom.label = params.value;
    }
    getFragment() {
        return this.$fragment;
    }
}
exports.default = Column;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29sdW1uLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vc3JjL2xpYi9hZGFwdGVyLXZ1ZS9tb2R1bGVzL2JveC9UYWJsZS9jb2x1bW4udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxNQUFNLElBQUksR0FBRyxPQUFPLENBQUMsY0FBYyxDQUFDLENBQUM7QUFDckMsbUNBQW1DO0FBQ25DLGlEQUEwQztBQUMxQyxrQ0FBMkI7QUFDM0IsNEJBQTRCO0FBRzVCLE1BQXFCLE1BQU8sU0FBUSxjQUFJO0lBY3RDLFlBQWEsSUFBUyxFQUFFLE9BQVk7UUFDbEMsS0FBSyxDQUFDLE9BQU8sQ0FBQyxDQUFDO1FBZFYsU0FBSSxHQUFHLEVBQUUsQ0FBQztRQUNWLGVBQVUsR0FBTyxFQUFFLENBQUM7UUFFM0IsU0FBSSxHQUFXLFFBQVEsQ0FBQztRQUN4QixnQkFBVyxHQUFXLENBQUMsQ0FBQztRQUV4QixXQUFNLEdBQVEsSUFBSSxDQUFDO1FBQ25CLFlBQU8sR0FBVyxFQUFFLENBQUM7UUFDckIsWUFBTyxHQUFRLEVBQUUsQ0FBQztRQUNsQixTQUFJLEdBQVcsUUFBUSxDQUFDO1FBQ3hCLFNBQUksR0FBVyxtQkFBbUIsQ0FBQztRQUtqQyxJQUFJLENBQUMsT0FBTyxHQUFHLE9BQU8sQ0FBQztRQUN2QixJQUFJLENBQUMsSUFBSSxHQUFHLElBQUksRUFBRSxDQUFDLEtBQUssQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztRQUNqQyxJQUF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