1

我收到“TypeError:MutationObserver.observe 的参数 1 不是对象”的错误。正好在这个变量上

var oc = $('#chart-container').orgchart({
          'data' : datascource,
          'nodeTemplate': nodeTemplate,
          'toggleSiblingsResp': true
        });

完整的功能如下:

odoo.define("org_chart_employee.org_chart_employee_fun", function (require) {
"use strict";

var AbstractAction = require('web.AbstractAction');
var core = require('web.core');
var session = require('web.session');
var ajax = require('web.ajax');
var Widget = require('web.Widget');
var QWeb = core.qweb;
var _t = core._t;
var _lt = core._lt;

  var employee_data = [];
  var nodeTemplate = function(data) {
        return `
          <span class="office">${data.office}</span>
          <div class="title">${data.name}</div>
          <div class="content">${data.title}</div>
        `;
      };

  var OrgChartDepartment = AbstractAction.extend({
    init: function(parent, context) {
      this._super(parent, context);
        var self = this;
        self._rpc({
                model: 'org.chart.employee',
                method: 'get_employee_data',
                args: []
            }).then(function(result){
              employee_data = result;
              self.render();
                  self.href = window.location.href;
               });
    },
    willStart: function() {
      return $.when(ajax.loadLibs(this), this._super());
    },
    start: function() {
      var self = this;
      return this._super();
    },
    render: function() {
        var self = this;
        var org_chart = QWeb.render('org_chart_employeeOrg_chart_template', {
            widget: self,
        });
        $( ".o_control_panel").addClass( "o_hidden" );
        var datascource = employee_data.values;
        var oc = $('#chart-container').orgchart({
          'data' : datascource,
          'nodeTemplate': nodeTemplate,
          'toggleSiblingsResp': true
        });
        $(org_chart).prependTo(self.$el);
        return org_chart;
    },
    reload: function () {
      window.location.href = this.href;
    },
  });
  core.action_registry.add('org_chart_department', OrgChartDepartment);
  return OrgChartDepartment;
});

有什么建议可以解决这个问题吗?

4

0 回答 0