185 lines
5.1 KiB
JavaScript
185 lines
5.1 KiB
JavaScript
// template/project-list-screen/project-list-screen.js
|
|
Component({
|
|
|
|
/**
|
|
* 组件的属性列表
|
|
*/
|
|
properties: {
|
|
classify: String,
|
|
comOption: {
|
|
type: Object,
|
|
observer(res) {
|
|
if (!res || JSON.stringify(res) == "{}") return
|
|
this.comJGToYear()
|
|
},
|
|
},
|
|
|
|
com: Object,
|
|
|
|
majOption: {
|
|
type: Object,
|
|
observer(res) {
|
|
if (!res || JSON.stringify(res) == "{}") return
|
|
this.majJgList()
|
|
}
|
|
},
|
|
maj: Object,
|
|
},
|
|
|
|
/**
|
|
* 组件的初始数据
|
|
*/
|
|
data: {
|
|
screenState: true, // 筛选状态 true 是选择 机构年份 false 是选择 专业
|
|
comJgList: [], // 综合的 机构列表
|
|
comYearList: [], // 综合的 年份列表
|
|
majJgList: [], // 专业的 机构列表
|
|
majMajorList: [], // 专业的 专业列表
|
|
majYearList: [], // 专业的 年份列表
|
|
},
|
|
|
|
/**
|
|
* 组件的方法列表
|
|
*/
|
|
methods: {
|
|
// 综合 通过机构 计算 出年份
|
|
comJGToYear() {
|
|
const com = this.data.com
|
|
const option = this.data.comOption || {}
|
|
console.log("com", com, "option", option);
|
|
const jg = com.jg || Object.keys(option)[0]
|
|
let comJgList = Object.keys(option)
|
|
let comYearList = Object.keys(option[jg]).sort((a, b) => b - a)
|
|
|
|
this.setData({
|
|
comJgList,
|
|
comYearList,
|
|
com: {
|
|
jg,
|
|
year: comYearList[0],
|
|
}
|
|
})
|
|
},
|
|
|
|
// 选择综合的 机构
|
|
selectComJg(e) {
|
|
const key = e.currentTarget.dataset.key
|
|
this.setData({
|
|
[`com.jg`]: key,
|
|
})
|
|
this.comJGToYear()
|
|
},
|
|
|
|
// 选择综合的 年份
|
|
selectComYear(e) {
|
|
const key = e.currentTarget.dataset.key
|
|
this.setData({
|
|
[`com.year`]: key,
|
|
})
|
|
},
|
|
|
|
// 专业 算出机构列表和默认机构
|
|
majJgList() {
|
|
const maj = this.data.maj
|
|
const option = this.data.majOption || {}
|
|
const jg = maj.jg || Object.keys(option)[0]
|
|
let majJgList = Object.keys(option)
|
|
this.setData({
|
|
majJgList,
|
|
[`maj.jg`]: jg,
|
|
})
|
|
this.majJgToMajor()
|
|
},
|
|
|
|
// 专业 通过 机构 算出 专业列表
|
|
majJgToMajor() {
|
|
const maj = this.data.maj
|
|
const option = this.data.majOption[maj.jg] || {}
|
|
let majMajorList = Object.keys(option)
|
|
const major = maj.major || majMajorList[0]
|
|
this.setData({
|
|
majMajorList,
|
|
[`maj.major`]: major,
|
|
})
|
|
this.majMajorToYear()
|
|
},
|
|
|
|
// 专业 通过专业 算出 年份列表
|
|
majMajorToYear() {
|
|
const maj = this.data.maj
|
|
const option = this.data.majOption[maj.jg][maj.major] || {}
|
|
let majYearList = Object.keys(option).sort((a, b) => b - a) || []
|
|
const year = maj.year || majYearList[0]
|
|
this.setData({
|
|
majYearList,
|
|
[`maj.year`]: year,
|
|
})
|
|
},
|
|
|
|
// 专业 选择 机构
|
|
selectMajJg(e) {
|
|
const jg = e.currentTarget.dataset.key
|
|
this.setData({
|
|
maj: {
|
|
jg,
|
|
major: "",
|
|
year: "",
|
|
}
|
|
})
|
|
|
|
this.majJgToMajor()
|
|
},
|
|
|
|
// 打开专业弹窗
|
|
opneMajorPop() {
|
|
this.setData({
|
|
screenState: false,
|
|
})
|
|
},
|
|
|
|
// 选择专业弹窗的关闭
|
|
closeselect(e) {
|
|
const major = e.detail?.value || ""
|
|
this.setData({
|
|
screenState: true,
|
|
})
|
|
|
|
if (major) {
|
|
this.setData({
|
|
['maj.major']: major,
|
|
['maj.year']: "",
|
|
})
|
|
this.majMajorToYear()
|
|
}
|
|
},
|
|
|
|
// 选择专业的年份
|
|
selectMajYear(e) {
|
|
const key = e.currentTarget.dataset.key
|
|
this.setData({
|
|
[`maj.year`]: key,
|
|
})
|
|
},
|
|
|
|
// 点击取消
|
|
cutScreenState() {
|
|
this.triggerEvent("cutScreenState")
|
|
},
|
|
|
|
// 点击选好了
|
|
haveChosen() {
|
|
const classify = this.data.classify
|
|
if (classify == "school") {
|
|
const com = this.data.com
|
|
const comOption = this.data.comOption
|
|
com['token'] = comOption[com.jg][com.year]
|
|
} else {
|
|
let maj = this.data.maj
|
|
const majOption = this.data.majOption
|
|
maj['token'] = majOption[maj.jg][maj.major][maj.year]
|
|
}
|
|
|
|
this.triggerEvent("haveChosen", this.data.classify == "school" ? this.data.com : this.data.maj)
|
|
},
|
|
}
|
|
}) |