{"remainingRequest":"D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\vue-loader\\lib\\index.js??vue-loader-options!D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\@jiaminghi\\data-view\\lib\\components\\scrollBoard\\src\\main.vue?vue&type=script&lang=js&","dependencies":[{"path":"D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\@jiaminghi\\data-view\\lib\\components\\scrollBoard\\src\\main.vue","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\babel-loader\\lib\\index.js","mtime":315532800000},{"path":"D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\vue-loader\\lib\\index.js","mtime":499162500000}],"contextDependencies":[],"result":["//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n\nimport autoResize from '../../../mixin/autoResize'\n\nimport { deepMerge } from '@jiaminghi/charts/lib/util/index'\n\nimport { deepClone } from '@jiaminghi/c-render/lib/plugin/util'\n\nexport default {\n  name: 'DvScrollBoard',\n  mixins: [autoResize],\n  props: {\n    config: {\n      type: Object,\n      default: () => ({})\n    }\n  },\n  data () {\n    return {\n      ref: 'scroll-board',\n\n      defaultConfig: {\n        /**\n         * @description Board header\n         * @type {Array<String>}\n         * @default header = []\n         * @example header = ['column1', 'column2', 'column3']\n         */\n        header: [],\n        /**\n         * @description Board data\n         * @type {Array<Array>}\n         * @default data = []\n         */\n        data: [],\n        /**\n         * @description Row num\n         * @type {Number}\n         * @default rowNum = 5\n         */\n        rowNum: 5,\n        /**\n         * @description Header background color\n         * @type {String}\n         * @default headerBGC = '#00BAFF'\n         */\n        headerBGC: '#00BAFF',\n        /**\n         * @description Odd row background color\n         * @type {String}\n         * @default oddRowBGC = '#003B51'\n         */\n        oddRowBGC: '#003B51',\n        /**\n         * @description Even row background color\n         * @type {String}\n         * @default evenRowBGC = '#003B51'\n         */\n        evenRowBGC: '#0A2732',\n        /**\n         * @description Scroll wait time\n         * @type {Number}\n         * @default waitTime = 2000\n         */\n        waitTime: 2000,\n        /**\n         * @description Header height\n         * @type {Number}\n         * @default headerHeight = 35\n         */\n        headerHeight: 35,\n        /**\n         * @description Column width\n         * @type {Array<Number>}\n         * @default columnWidth = []\n         */\n        columnWidth: [],\n        /**\n         * @description Column align\n         * @type {Array<String>}\n         * @default align = []\n         * @example align = ['left', 'center', 'right']\n         */\n        align: [],\n        /**\n         * @description Show index\n         * @type {Boolean}\n         * @default index = false\n         */\n        index: false,\n        /**\n         * @description index Header\n         * @type {String}\n         * @default indexHeader = '#'\n         */\n        indexHeader: '#',\n        /**\n         * @description Carousel type\n         * @type {String}\n         * @default carousel = 'single'\n         * @example carousel = 'single' | 'page'\n         */\n        carousel: 'single',\n        /**\n         * @description Pause scroll when mouse hovered\n         * @type {Boolean}\n         * @default hoverPause = true\n         * @example hoverPause = true | false\n         */\n        hoverPause: true\n      },\n\n      mergedConfig: null,\n\n      header: [],\n\n      rowsData: [],\n\n      rows: [],\n\n      widths: [],\n\n      heights: [],\n\n      avgHeight: 0,\n\n      aligns: [],\n\n      animationIndex: 0,\n\n      animationHandler: '',\n\n      updater: 0,\n\n      needCalc: false\n    }\n  },\n  watch: {\n    config () {\n      const { stopAnimation, calcData } = this\n\n      stopAnimation()\n\n      this.animationIndex = 0\n\n      calcData()\n    }\n  },\n  methods: {\n    handleHover(enter, ri, ci, row, ceil){\n      const { mergedConfig, emitEvent, stopAnimation, animation } = this\n\n      if (enter) emitEvent('mouseover', ri, ci, row, ceil)\n      if (!mergedConfig.hoverPause) return\n\n      if (enter) {\n        stopAnimation()\n      } else {\n        animation(true)\n      }\n    },\n    afterAutoResizeMixinInit () {\n      const { calcData } = this\n\n      calcData()\n    },\n    onResize () {\n      const { mergedConfig, calcWidths, calcHeights } = this\n\n      if (!mergedConfig) return\n\n      calcWidths()\n\n      calcHeights()\n    },\n    calcData () {\n      const { mergeConfig, calcHeaderData, calcRowsData } = this\n\n      mergeConfig()\n\n      calcHeaderData()\n\n      calcRowsData()\n\n      const { calcWidths, calcHeights, calcAligns } = this\n\n      calcWidths()\n\n      calcHeights()\n\n      calcAligns()\n\n      const { animation } = this\n\n      animation(true)\n    },\n    mergeConfig () {\n      let { config, defaultConfig } = this\n\n      this.mergedConfig = deepMerge(deepClone(defaultConfig, true), config || {})\n    },\n    calcHeaderData () {\n      let { header, index, indexHeader} = this.mergedConfig\n\n      if (!header.length) {\n        this.header = []\n\n        return\n      }\n\n      header = [...header]\n\n      if (index) header.unshift(indexHeader)\n\n      this.header = header\n    },\n    calcRowsData () {\n      let { data, index, headerBGC, rowNum } = this.mergedConfig\n\n      if (index) {\n        data = data.map((row, i) => {\n          row = [...row]\n\n          const indexTag = `<span class=\"index\" style=\"background-color: ${headerBGC};\">${i + 1}</span>`\n\n          row.unshift(indexTag)\n\n          return row\n        })\n      }\n\n      data = data.map((ceils, i) => ({ ceils, rowIndex: i }))\n\n      const rowLength = data.length\n\n      if (rowLength > rowNum && rowLength < 2 * rowNum) {\n        data = [...data, ...data]\n      }\n\n      data = data.map((d, i) => ({ ...d, scroll: i }))\n\n      this.rowsData = data\n      this.rows = data\n    },\n    calcWidths () {\n      const { width, mergedConfig, rowsData } = this\n\n      const { columnWidth, header } = mergedConfig\n\n      const usedWidth = columnWidth.reduce((all, w) => all + w, 0)\n\n      let columnNum = 0\n      if (rowsData[0]) {\n        columnNum = rowsData[0].ceils.length\n      } else if (header.length) {\n        columnNum = header.length\n      }\n\n      const avgWidth = (width - usedWidth) / (columnNum - columnWidth.length)\n\n      const widths = new Array(columnNum).fill(avgWidth)\n\n      this.widths = deepMerge(widths, columnWidth)\n    },\n    calcHeights (onresize = false) {\n      const { height, mergedConfig, header } = this\n\n      const { headerHeight, rowNum, data } = mergedConfig\n\n      let allHeight = height\n\n      if (header.length) allHeight -= headerHeight\n\n      const avgHeight = allHeight / rowNum\n\n      this.avgHeight = avgHeight\n\n      if (!onresize) this.heights = new Array(data.length).fill(avgHeight)\n    },\n    calcAligns () {\n      const { header, mergedConfig } = this\n\n      const columnNum = header.length\n\n      let aligns = new Array(columnNum).fill('left')\n\n      const { align } = mergedConfig\n\n      this.aligns = deepMerge(aligns, align)\n    },\n    async animation (start = false) {\n      const { needCalc, calcHeights, calcRowsData } = this\n\n      if (needCalc) {\n        calcRowsData()\n        calcHeights()\n        this.needCalc = false\n      }\n\n      let { avgHeight, animationIndex, mergedConfig, rowsData, animation, updater } = this\n\n      const { waitTime, carousel, rowNum } = mergedConfig\n\n      const rowLength = rowsData.length\n\n      if (rowNum >= rowLength) return\n\n      if (start) {\n        await new Promise(resolve => setTimeout(resolve, waitTime))\n        if (updater !== this.updater) return\n      }\n\n      const animationNum = carousel === 'single' ? 1 : rowNum\n\n      let rows = rowsData.slice(animationIndex)\n      rows.push(...rowsData.slice(0, animationIndex))\n\n      this.rows = rows.slice(0, carousel === 'page' ? rowNum * 2 : rowNum + 1)\n      this.heights = new Array(rowLength).fill(avgHeight)\n\n      await new Promise(resolve => setTimeout(resolve, 300))\n      if (updater !== this.updater) return\n\n      this.heights.splice(0, animationNum, ...new Array(animationNum).fill(0))\n\n      animationIndex += animationNum\n\n      const back = animationIndex - rowLength\n      if (back >= 0) animationIndex = back\n\n      this.animationIndex = animationIndex\n      this.animationHandler = setTimeout(animation, waitTime - 300)\n    },\n    stopAnimation () {\n      const { animationHandler, updater } = this\n\n      this.updater = (updater + 1) % 999999\n\n      if (!animationHandler) return\n\n      clearTimeout(animationHandler)\n    },\n    emitEvent (type, ri, ci, row, ceil) {\n      const { ceils, rowIndex } = row\n\n      this.$emit(type, {\n        row: ceils,\n        ceil,\n        rowIndex,\n        columnIndex: ci\n      })\n    },\n    updateRows(rows, animationIndex) {\n      const { mergedConfig, animationHandler, animation } = this\n\n      this.mergedConfig = {\n        ...mergedConfig,\n        data: [...rows]\n      }\n\n      this.needCalc = true\n\n      if (typeof animationIndex === 'number') this.animationIndex = animationIndex\n      if (!animationHandler) animation(true)\n    }\n  },\n  destroyed () {\n    const { stopAnimation } = this\n\n    stopAnimation()\n  }\n}\n",null]}