43 lines
1.1 KiB
Swift
43 lines
1.1 KiB
Swift
//
|
||
// PLJobViewModel.swift
|
||
// IOS_study
|
||
//
|
||
// Created by CC-star on 2025/6/29.
|
||
//
|
||
|
||
import Foundation
|
||
|
||
@Observable final class PLJobViewModel {
|
||
var job = PLJob()
|
||
var draftJob = PLJob()
|
||
var jobs: [PLJob] = [.job]//todo上架前要删掉
|
||
|
||
func postJob() {
|
||
job = draftJob
|
||
// job.updatedAt = Date()
|
||
|
||
//处理空格(必填部分)
|
||
job.title = job.title.trimmed
|
||
job.placeName = job.placeName.trimmed
|
||
job.province = job.province.trimmed
|
||
job.city = job.city.trimmed
|
||
//处理空格(选填部分)
|
||
if job.otherTime.isBlank { job.otherTime = "" } else { job.otherTime = job.otherTime.trimmed }
|
||
if job.otherNeed.isBlank { job.otherNeed = "" } else { job.otherNeed = job.otherNeed.trimmed }
|
||
if job.workContent.isBlank { job.workContent = "" } else { job.workContent = job.workContent.trimmed }
|
||
if job.otherBenefit.isBlank { job.otherBenefit = "" } else { job.otherBenefit = job.otherBenefit.trimmed }
|
||
|
||
|
||
//todo存到数据库
|
||
|
||
}
|
||
|
||
func toggleJobStatus() {
|
||
job.isActive.toggle()
|
||
}
|
||
func removeJob() {
|
||
job.isActive.toggle()
|
||
}
|
||
|
||
}
|