| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- /* *********************************************************** */
- // 创建: Macheng 2025/09/10.
- // 修改: Macheng 2025/09/10
- // Description:
- // 该文件定义了项目类 Project。用于保存项目的配置数据。
- /* *********************************************************** */
- import BaseModel from './baseModel'
- import Location from './location'
- import Person from './person'
- class Project extends BaseModel {
- id = 0 // 项目ID
- name = '' // 项目名称
- version = 0 // 项目版本
- locations = [] // 区域列表
- persons = [] // 人员列表
- status = 0
- constructor(opts) {
- if (!opts) opts = {}
- super(opts)
- this.init(opts)
- }
- init(opts) {
- if (!opts) opts = {}
- super.init(opts)
- this.id = Number(opts.id) || this.id
- this.name = opts.name || this.wifiLocalMaskname
- this.version = Number(opts.version) || this.version
- this.locations = (opts.locations || []).map(item => new Location(item))
- for (const loc of this.locations) {
- loc.parent = this
- }
- this.persons = (opts.persons || []).map(item => new Person(item))
- this.status = Number(opts.status) || this.status
- this.isEnable = opts.enable || opts.isEnable || false
- }
- toJson() {
- const obj1 = super.toJson()
- const obj2 = {
- id: this.id,
- name: this.name,
- version: this.version,
- locations: this.locations.map(item => item.toJson()),
- persons: this.persons.map(item => item.toJson()),
- status: this.status
- }
- return Object.assign({}, obj1, obj2)
- }
- }
- export default Project
|