    import FeatureRender from '../base/FeatureRender'
    import { defaultValue } from '../util'
    import { LayerView } from './index'

    class BaseGraphicsLayerView extends LayerView {
      constructor(options) {
        super(options)
        this.render = defaultValue(options.render, new FeatureRender())
        this._initHandlers()
      }

      /**
       * @description: 初始化监听
       * @return {*}
       */
      _initHandlers() {
        this._layerChangeAction = this._layerChangeAction.bind(this)
        this.layer.on('set', this._layerChangeAction)
      }

      /**
       * @description: 移除监听
       * @return {*}
       */
      _removeHandlers() {
        this.layer.off('set', this._layerChangeAction)
      }

      /**
       * @description: 图层变化Action
       * @param {*} event
       * @return {*}
       */
      _layerChangeAction(event) {
        this._featureCollectionChangeAction(event)
      }

      /**
       * @description: 要素变化Action
       * @param {*} event
       * @return {*}
       */
      _featureCollectionChangeAction(event) {
        const eventPath = event.eventPath || []
        const { key, value } = event.eventData
        const sourceEventData = event.sourceEventData
        // 处理要素刷新机制
        if (key === 'graphics') {
          const graphics = value
          if (eventPath.length <= 0 || !graphics) return
          if (eventPath.length === 1) {
            // 事件路径为['graphics']，表示刷新数据
            const graphics = value
            this.render.clear(this.innerLayer)
            this.render.drawFeature(this.innerLayer, graphics.items)
          } else if (eventPath.length > 1) {
            // 获取到要素
            const featureKey = eventPath[1]
            const feature = graphics.getFeatureById(featureKey)
            if (!feature) return
            if (eventPath.length > 2) {
              const updateType = eventPath[2]
              const updateDetail = {
                geometryUpdated: null,
                symbolUpdated: null
              }
              if (updateType === 'symbol') {
                updateDetail.symbolUpdated = sourceEventData
              } else if (updateType === 'geometry') {
                updateDetail.geometryUpdated = sourceEventData
              }
              this.render.updateFeature(this.innerLayer, [feature], [updateDetail])
            }
          }
        }
      }
    }

    export default BaseGraphicsLayerView