Cruduser Settings

Introduction #

CRUD user settings allow dynamic control of interface display content and operation permissions based on the current logged-in user. Use $username to determine user identity, or query user roles from a dataset to implement different field, button, or data scope visibility for different users.

Control Method Description
filter_param.username Direct username check
Dataset + vapp.btnEdit Control button visibility by role
Config item lookup Config panel edit page shows parameter name hints

Use Cases #

In many scenarios, different configurations are needed for different users, showing different content or interfaces, such as add/edit buttons.

Configuration Method #

  • User-specific settings need to be developed in the template editor’s custom JS code area
  • Example: Disable edit functionality for user “neo”
if (filter_param.username === 'neo') {
    vapp.btnEdit = false
}
  • More personalized configuration, e.g., getting display permissions from a dataset (dataset #4):
select role from xxxx where user='$username'
  • Then set in template development:
ds_refresh(4)
if (data4.length > 1 && data4[1][0] === 'readonly') {
    vapp.btnEdit = false
}
  • You can also use the ds_my function to get user info:
// Get current user info
let my = ds_my()
// my = {username, name, roles:[], position, department, groups:[]}
console.log(my.roles, my.position, my.department, my.groups)

How to Find Corresponding Config Items #

In the configuration interface, click to enter the edit page. The first line has hints with corresponding parameter names.