I added a button to create payrolls in the attendance sheet, and I hope to achieve the following effects. I would be very grateful if you could give me some reference examples:
I am currently able to get the selected object, but I do not know how to create a payroll.
console.log(item.attributes.dateOfWork);
console.log(item.attributes.assignedUserId);
I am currently able to get the selected object, but I do not know how to create a payroll.
console.log(item.attributes.dateOfWork);
console.log(item.attributes.assignedUserId);
- Select the attendance object.
- Click to create the payroll.
- Create the payroll."
HTML Code:
define('custom:views/Employeework/list', 'views/list', function (Dep) { return Dep.extend({ setup: function() { Dep.prototype.setup.call(this); this.setupCustomButtons(); }, setupCustomButtons: function () { this.menu.buttons.push({ action: 'myAction', html: '<span class="fas fa-comment-dollar fa-sm"></span> ' + this.translate('Create Employeewages', 'labels', this.scope), style: 'default', acl: 'create', // Change 'read' to 'create' aclScope: this.entityType || this.scope }); }, actionMyAction: function() { var selectedItems = this.getSelected(); if (!selectedItems.length) { Espo.Ui.warning(this.translate('请选择出勤对象', 'Employeework')); return; } else { selectedItems.forEach(function(item) { console.log(item); console.log(item.attributes.dateOfWork); console.log(item.attributes.assignedUserId); //corresponding payroll entries // employeework = new Employeework(); // Assuming Employeewages is a model, create a new instance // employeework = item.assignedUserId; // dateOfWork = item.dateOfWork; // Perform any necessary operations with employeewages object here // console.log(employeewages); }, this); } }, /** * Get selected models. * * @return {module:model[]} */ getSelected() { const list = []; this.$el.find('input.record-checkbox:checked').each((i, el) => { const id = $(el).attr('data-id'); const model = this.collection.get(id); list.push(model); }); return list; } }); });
Comment