单档——状态码显示设置,状态码更改链表更新

本文介绍了一种在特定状态下隐藏部分功能,并在状态改变时同步更新数据库中相关字段的方法。通过具体的编程实例展示了如何根据不同状态码进行权限控制及数据更新。

 

范例(cxmt631),状态码显示设置(某状态下不显示某些状态码,即有些状态是不可直接更改的为另一种状态的),更改完状态码后同步更新数据表的指定字段;

1)在cxmt631_statechange 中的statechange.before_menu 下,置入程序:

    
      #add-point:menu前 name="statechange.before_menu"
 
      CASE g_xmabuc_m.xmabucstus
           WHEN "X"
                 CALL cl_set_act_visible("report,factory,Load,pass,valid",FALSE)
           WHEN "01"
                 CALL cl_set_act_visible("Loading,pass",FALSE)
           WHEN "02"
                 CALL cl_set_act_visible("pass",FALSE)
           WHEN "03"
                CALL cl_set_act_visible("report",FALSE)
           WHEN "04"
              CALL cl_set_act_visible("factory,report",FALSE)
      END CASE
      #end add-point
      
        

以上的report、factory等,为功能编号,具体见azzi850;

01、02、03、04、X,为状态码编码;

 

 

2)每一个状态更改时都同时更新数据表的相关字段,同样是在cxmt631_statechange 下:

ON ACTION invalid
         IF cl_auth_chk_act("invalid") THEN
            LET lc_state = "X"
            #add-point:action控制 name="statechange.invalid"
            update xmabuc_t set xmabuc004 = lc_state where xmabucdocno = g_xmabuc_m.xmabucdocno and xmabucent = g_enterprise
            if not cl_null(g_xmabuc_m.xmabuc009) then
                update xmen_t set xmenua003 = lc_state where xmenent = g_enterprise and xmendocno = g_xmabuc_m.xmabuc009
            end if
            #end add-point
         END IF
         EXIT MENU
      ON ACTION report
         IF cl_auth_chk_act("report") THEN
            LET lc_state = "01"
            #add-point:action控制 name="statechange.report"
            update xmabuc_t set xmabuc004 = lc_state where xmabucdocno = g_xmabuc_m.xmabucdocno and xmabucent = g_enterprise
            if not cl_null(g_xmabuc_m.xmabuc009) then
                update xmen_t set xmenua003 = lc_state where xmenent = g_enterprise and xmendocno = g_xmabuc_m.xmabuc009
            end if
            #end add-point
         END IF
         EXIT MENU

      ON ACTION factory
         IF cl_auth_chk_act("factory") THEN
            LET lc_state = "02"
            #add-point:action控制 name="statechange.factory"
            update xmabuc_t set xmabuc004 = lc_state where xmabucdocno = g_xmabuc_m.xmabucdocno and xmabucent = g_enterprise
            if not cl_null(g_xmabuc_m.xmabuc009) then
                update xmen_t set xmenua003 = lc_state where xmenent = g_enterprise and xmendocno = g_xmabuc_m.xmabuc009
            end if
            #end add-point
         END IF
         EXIT MENU

      ON ACTION loading
         IF cl_auth_chk_act("loading") THEN
            LET lc_state = "03"
            #add-point:action控制 name="statechange.loading"
            update xmabuc_t set xmabuc004 = lc_state where xmabucdocno = g_xmabuc_m.xmabucdocno and xmabucent = g_enterprise
            if not cl_null(g_xmabuc_m.xmabuc009) then
                update xmen_t set xmenua003 = lc_state where xmenent = g_enterprise and xmendocno = g_xmabuc_m.xmabuc009
            end if
            #end add-point
         END IF
         EXIT MENU

      ON ACTION pass
         IF cl_auth_chk_act("pass") THEN
            LET lc_state = "04"
            #add-point:action控制 name="statechange.pass"
            update xmabuc_t set xmabuc004 = lc_state where xmabucdocno = g_xmabuc_m.xmabucdocno and xmabucent = g_enterprise
            if not cl_null(g_xmabuc_m.xmabuc009) then
                update xmen_t set xmenua003 = lc_state where xmenent = g_enterprise and xmendocno = g_xmabuc_m.xmabuc009
            end if
            #end add-point
         END IF
         EXIT MENU

  

 

转载于:https://www.cnblogs.com/xiaoli9627/p/6841139.html

### T100 开发中的简示例教程 在 Java 开发领域,尤其是针对企业级应用开发时,T100 的程序设计通常涉及基础数据管理、增删改查(CRUD)操作以及业务逻辑实现。以下是基于已有参考资料的内容总结[^1],并结合实际开发经验提供的一份简开发示例。 #### 1. 数据库表结构设计 为了支持简功能,数据库表的设计至关重要。假设我们正在构建一个用于存储客户信息的系统,则可以定义如下 SQL 表结构: ```sql CREATE TABLE customer ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255) NOT NULL, phone_number VARCHAR(15), email VARCHAR(255), address TEXT, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); ``` 此表包含了基本字段 `id`(主键)、`name`(姓名)、`phone_number`(电话号码)、`email`(电子邮件地址)、`address`(住址),以及时间戳字段 `created_at` 记录创建时间[^2]。 --- #### 2. 后端接口设计 通过 RESTful API 实现对上述表的操作。以下是一个典型的 Spring Boot 控制器代码片段,展示如何完成 CRUD 功能: ```java @RestController @RequestMapping("/api/customers") public class CustomerController { @Autowired private CustomerRepository customerRepository; // 查询所有客户 @GetMapping public List<Customer> getAllCustomers() { return customerRepository.findAll(); } // 添加新客户 @PostMapping public ResponseEntity<String> addCustomer(@RequestBody Customer customer) { customerRepository.save(customer); return new ResponseEntity<>("Customer added successfully", HttpStatus.CREATED); } // 更新指定 ID 客户的信息 @PutMapping("/{id}") public ResponseEntity<String> updateCustomer(@PathVariable int id, @RequestBody Customer updatedCustomer) { Optional<Customer> existingCustomerOptional = customerRepository.findById(id); if (existingCustomerOptional.isPresent()) { Customer existingCustomer = existingCustomerOptional.get(); existingCustomer.setName(updatedCustomer.getName()); existingCustomer.setPhoneNumber(updatedCustomer.getPhoneNumber()); existingCustomer.setEmail(updatedCustomer.getEmail()); existingCustomer.setAddress(updatedCustomer.getAddress()); customerRepository.save(existingCustomer); return new ResponseEntity<>("Customer updated successfully", HttpStatus.OK); } else { return new ResponseEntity<>("Customer not found", HttpStatus.NOT_FOUND); } } // 删除指定 ID 客户 @DeleteMapping("/{id}") public ResponseEntity<String> deleteCustomer(@PathVariable int id) { boolean exists = customerRepository.existsById(id); if (!exists) { return new ResponseEntity<>("Customer with given ID does not exist.", HttpStatus.NOT_FOUND); } customerRepository.deleteById(id); return new ResponseEntity<>("Customer deleted successfully", HttpStatus.NO_CONTENT); } } ``` 以上代码实现了四个主要的功能:查询所有记录、新增一条记录、更新某条记录以及删除某条记录[^3]。 --- #### 3. 前端页面交互 前端可以通过 HTML 和 JavaScript 来调用后端提供的 API 接口。下面是一段简的 Vue.js 页面模板,演示如何与后端通信: ```html <template> <div> <h1>T100 管理系统</h1> <button @click="fetchData">刷新列表</button> <!-- 显示表格 --> <table border="1"> <thead> <tr> <th>ID</th> <th>Name</th> <th>Phone Number</th> <th>Email</th> <th>Action</th> </tr> </thead> <tbody> <tr v-for="(customer, index) in customers" :key="index"> <td>{{ customer.id }}</td> <td>{{ customer.name }}</td> <td>{{ customer.phoneNumber }}</td> <td>{{ customer.email }}</td> <td><button @click="deleteCustomer(customer.id)">Delete</button></td> </tr> </tbody> </table> </div> </template> <script> export default { data() { return { customers: [] }; }, methods: { fetchData() { fetch('http://localhost:8080/api/customers') .then(response => response.json()) .then(data => this.customers = data); }, deleteCustomer(id) { fetch(`http://localhost:8080/api/customers/${id}`, { method: 'DELETE' }) .then(() => alert('Deleted!')); this.fetchData(); // 刷新数据 } } }; </script> ``` 这段代码展示了如何加载和显示客户的列表,并提供了删除按钮来移除特定项。 --- ### 总结 本教程涵盖了从数据库建模到前后端交互的核心流程,旨在帮助开发者快速上手 T100 系统下的简开发工作。如果需要更深入的学习资源,可参考《一线大厂 Java 面试题解析+后端开发学习笔记》等相关材料。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值