12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- import {invokeServer, msg, Scope} from 'yvan-ext'
- import vjson from "./{{{ groovyClass }}}.view"
- import model from "./{{{ groovyClass }}}.model"
- export default class {{{ groovyClass }}} extends Scope {
- path = '{{{ invokeUrlPrefix }}}'
- constructor() {
- super({model, vjson});
- }
- onLoad() {
- }
- refresh() {
- this.refs.grid1.reload()
- }
- grid1Select(sender, selected) {
- this.viewModel.set('selectedRow', selected[0]?.data)
- }
- {{#if addButton}}
- add() {
- this.refs.grid1.appendEditRow({}, 1)
- }
- {{/if}}
- {{#if deleteButton}}
- remove() {
- const grid1 = this.refs.grid1
- const selected = grid1?.selModel?.selected?.items?.map(row => row.data)[0]
- if (selected && grid1?.getStore().getNewRecords().map(row => row.data).indexOf(selected) < 0) {
- system.confirm(`{{{ deleteTips }}}`)
- .then(() => {
- this.setLoading(true)
- invokeServer(`${this.path}@deleteItem`, selected)
- .then(res => {
- grid1?.removeEditRow()
- system.msg(res.msg)
- }).finally(() => this.setLoading(false))
- })
- } else {
- grid1?.removeEditRow()
- }
- }
- {{/if}}
- {{#if saveButton}}
- save() {
- let {newRows, modifyRows, removeRecords, err} = system.getGridEditRows(this.refs.grid1)
- if (err) return
- this.setLoading(true)
- invokeServer(`${this.path}@saveItems`, {newRows, modifyRows, removeRecords})
- .then(res => {
- system.msg(res.msg)
- this.refs.grid1.reload()
- }).finally(() => this.setLoading(false))
- }
- {{/if}}
- }
|