|
|
|
@ -291,14 +291,23 @@ export default { |
|
|
|
} |
|
|
|
}, |
|
|
|
onLoad(options) { |
|
|
|
this.filteredData.resource_id = options.resource_id//客户资源表id |
|
|
|
console.log('页面加载参数:', options) |
|
|
|
// 确保options中有必要的参数 |
|
|
|
if (!options || !options.resource_id) { |
|
|
|
uni.showToast({ |
|
|
|
title: '缺少必要参数', |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
this.formData.resource_id = options.resource_id//客户资源表id |
|
|
|
this.formData.resource_id_name = options.resource_name//客户资源表id姓名 |
|
|
|
this.filteredData.resource_id = options.resource_id // 客户资源表id |
|
|
|
|
|
|
|
this.formData.resource_id = options.resource_id // 客户资源表id |
|
|
|
this.formData.resource_id_name = options.resource_name || '' // 客户资源表id姓名 |
|
|
|
|
|
|
|
this.formData.staff_id = options.staff_id//员工资源表id姓名 |
|
|
|
this.formData.staff_id_name = options.staff_id_name//员工资源表id姓名 |
|
|
|
this.formData.staff_id = options.staff_id || '' // 员工资源表id |
|
|
|
this.formData.staff_id_name = options.staff_id_name || '' // 员工资源表id姓名 |
|
|
|
}, |
|
|
|
onShow(){ |
|
|
|
this.init() |
|
|
|
@ -312,15 +321,23 @@ export default { |
|
|
|
methods: { |
|
|
|
//初始化 |
|
|
|
async init(){ |
|
|
|
//获取付款类型 |
|
|
|
await this.getPaymentTypeList() |
|
|
|
//获取课程列表 |
|
|
|
await this.getCourseList() |
|
|
|
//获取班级列表 |
|
|
|
await this.getClassList() |
|
|
|
|
|
|
|
//获取列表 |
|
|
|
await this.getList(); |
|
|
|
try { |
|
|
|
//获取付款类型 |
|
|
|
await this.getPaymentTypeList() |
|
|
|
//获取课程列表 |
|
|
|
await this.getCourseList() |
|
|
|
//获取班级列表 |
|
|
|
await this.getClassList() |
|
|
|
|
|
|
|
//获取列表 |
|
|
|
await this.getList(); |
|
|
|
} catch (error) { |
|
|
|
console.error('初始化失败:', error) |
|
|
|
uni.showToast({ |
|
|
|
title: '初始化数据失败', |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
//加载更多(下一页) |
|
|
|
@ -381,75 +398,96 @@ export default { |
|
|
|
|
|
|
|
//获取付款类型 |
|
|
|
async getPaymentTypeList(){ |
|
|
|
let res = await apiRoute.common_Dictionary({key:'payment_type'}) |
|
|
|
if(res.code != 1){ |
|
|
|
uni.showToast({ |
|
|
|
title: res.msg, |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
try { |
|
|
|
let res = await apiRoute.common_Dictionary({key:'payment_type'}) |
|
|
|
if(res.code != 1){ |
|
|
|
uni.showToast({ |
|
|
|
title: res.msg || '获取付款类型失败', |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
let dictionary = res.data.dictionary |
|
|
|
let arr = [] |
|
|
|
dictionary.forEach((v,k)=>{ |
|
|
|
arr.push({ |
|
|
|
text: v.name, |
|
|
|
value: v.value, |
|
|
|
let dictionary = res.data |
|
|
|
let arr = [] |
|
|
|
dictionary.forEach((v,k) => { |
|
|
|
arr.push({ |
|
|
|
text: v.name, |
|
|
|
value: v.value, |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
this.payment_type_options = arr |
|
|
|
console.log('付款类型',this.payment_type_options) |
|
|
|
this.payment_type_options = arr |
|
|
|
console.log('付款类型', this.payment_type_options) |
|
|
|
} catch (error) { |
|
|
|
console.error('获取付款类型失败:', error) |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
//获取课程列表 |
|
|
|
async getCourseList(){ |
|
|
|
let params = {} |
|
|
|
|
|
|
|
let res = await apiRoute.common_getCourseAll(params) |
|
|
|
if(res.code != 1){ |
|
|
|
uni.showToast({ |
|
|
|
title: res.msg, |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
try { |
|
|
|
let params = {} |
|
|
|
let res = await apiRoute.common_getCourseAll(params) |
|
|
|
if(res.code != 1){ |
|
|
|
uni.showToast({ |
|
|
|
title: res.msg || '获取课程列表失败', |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if (!res.data || !Array.isArray(res.data)) { |
|
|
|
console.error('课程列表数据格式错误:', res.data) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
let arr = [] |
|
|
|
res.data.forEach((v,k)=>{ |
|
|
|
arr.push({ |
|
|
|
text: `${v.course_name}`, |
|
|
|
value: v.id, |
|
|
|
price: v.price, |
|
|
|
let arr = [] |
|
|
|
res.data.forEach((v,k) => { |
|
|
|
arr.push({ |
|
|
|
text: `${v.course_name}`, |
|
|
|
value: v.id, |
|
|
|
price: v.price, |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
this.course_id_options = arr |
|
|
|
console.log('课程列表',this.course_id_options) |
|
|
|
|
|
|
|
this.course_id_options = arr |
|
|
|
console.log('课程列表', this.course_id_options) |
|
|
|
} catch (error) { |
|
|
|
console.error('获取课程列表失败:', error) |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
//获取班级列表 |
|
|
|
async getClassList(){ |
|
|
|
let params = { |
|
|
|
status:1,//班级状态(1开启 2关闭) |
|
|
|
} |
|
|
|
try { |
|
|
|
let params = { |
|
|
|
status: 1, //班级状态(1开启 2关闭) |
|
|
|
} |
|
|
|
let res = await apiRoute.common_getClassAll(params) |
|
|
|
if(res.code != 1){ |
|
|
|
uni.showToast({ |
|
|
|
title: res.msg || '获取班级列表失败', |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
let res = await apiRoute.common_getClassAll(params) |
|
|
|
if(res.code != 1){ |
|
|
|
uni.showToast({ |
|
|
|
title: res.msg, |
|
|
|
icon: 'none' |
|
|
|
if (!res.data || !Array.isArray(res.data)) { |
|
|
|
console.error('班级列表数据格式错误:', res.data) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
let arr = [] |
|
|
|
res.data.forEach((v,k) => { |
|
|
|
arr.push({ |
|
|
|
text: `${v.campus_name}-${v.class_name}`, |
|
|
|
value: v.id, |
|
|
|
}) |
|
|
|
}) |
|
|
|
return |
|
|
|
this.class_id_options = arr |
|
|
|
console.log('班级列表', this.class_id_options) |
|
|
|
} catch (error) { |
|
|
|
console.error('获取班级列表失败:', error) |
|
|
|
} |
|
|
|
console.log('班级列表',res.data) |
|
|
|
let arr = [] |
|
|
|
res.data.forEach((v,k)=>{ |
|
|
|
arr.push({ |
|
|
|
text: `${v.campus_name}-${v.class_name}`, |
|
|
|
value: v.id, |
|
|
|
}) |
|
|
|
}) |
|
|
|
this.class_id_options = arr |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
@ -488,67 +526,116 @@ export default { |
|
|
|
}, |
|
|
|
//提交表单 |
|
|
|
async submitFormData() { |
|
|
|
let param = {...this.formData} |
|
|
|
//表单验证 |
|
|
|
//... |
|
|
|
if(!param.class_id){ |
|
|
|
uni.showToast({ |
|
|
|
title: '请选择班级', |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
if(!param.course_id){ |
|
|
|
uni.showToast({ |
|
|
|
title: '请选择课程', |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
if(!param.payment_type){ |
|
|
|
uni.showToast({ |
|
|
|
title: '请选择付款类型', |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
try { |
|
|
|
let param = {...this.formData} |
|
|
|
//表单验证 |
|
|
|
if(!param.resource_id){ |
|
|
|
uni.showToast({ |
|
|
|
title: '客户信息缺失', |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
if(!param.class_id){ |
|
|
|
uni.showToast({ |
|
|
|
title: '请选择班级', |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
if(!param.course_id){ |
|
|
|
uni.showToast({ |
|
|
|
title: '请选择课程', |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
if(!param.payment_type){ |
|
|
|
uni.showToast({ |
|
|
|
title: '请选择付款类型', |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
if(!param.staff_id){ |
|
|
|
uni.showToast({ |
|
|
|
title: '员工信息缺失', |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
if(!param.money){ |
|
|
|
uni.showToast({ |
|
|
|
title: '订单金额为空', |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
console.log('提交xxx',param) |
|
|
|
this.closeOrderShow() |
|
|
|
console.log('提交订单数据:', param) |
|
|
|
this.closeOrderShow() |
|
|
|
|
|
|
|
uni.showLoading({ |
|
|
|
title: '提交中...' |
|
|
|
}) |
|
|
|
|
|
|
|
let res = await apiRoute.xs_orderTableAdd(param) |
|
|
|
uni.hideLoading() |
|
|
|
|
|
|
|
if (res.code != 1) { |
|
|
|
uni.showToast({ |
|
|
|
title: res.msg || '创建订单失败', |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
let res = await apiRoute.xs_orderTableAdd(param) |
|
|
|
if (res.code != 1) { |
|
|
|
uni.showToast({ |
|
|
|
title: res.msg, |
|
|
|
title: '创建订单成功', |
|
|
|
icon: 'success' |
|
|
|
}) |
|
|
|
|
|
|
|
//延迟1s执行 |
|
|
|
setTimeout(() => { |
|
|
|
this.resetFilteredData()//重置表单 |
|
|
|
this.getList();//刷新列表 |
|
|
|
}, 1500) |
|
|
|
} catch (error) { |
|
|
|
uni.hideLoading() |
|
|
|
console.error('提交订单失败:', error) |
|
|
|
uni.showToast({ |
|
|
|
title: '创建订单失败,请重试', |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
uni.showToast({ |
|
|
|
title: '操作成功', |
|
|
|
icon: 'success' |
|
|
|
}) |
|
|
|
|
|
|
|
//延迟1s执行 |
|
|
|
setTimeout(() => { |
|
|
|
this.resetFilteredData()//重置表单 |
|
|
|
this.getList();//刷新列表 |
|
|
|
}, 1500) |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
//下拉选择器相关-付款类型 |
|
|
|
//监听-付款类型 |
|
|
|
changePaymentType(e){ |
|
|
|
console.log('选择的付款类型:', e) |
|
|
|
if (!e || !e.value) { |
|
|
|
uni.showToast({ |
|
|
|
title: '请选择有效的付款类型', |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
this.formData.payment_type = e.value |
|
|
|
this.formData.payment_type_name = e.text |
|
|
|
this.cancelPaymentType() |
|
|
|
}, |
|
|
|
//打开选择器-付款类型 |
|
|
|
openPaymentType(){ |
|
|
|
if (!this.payment_type_options || this.payment_type_options.length === 0) { |
|
|
|
uni.showToast({ |
|
|
|
title: '付款类型数据加载中,请稍后再试', |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
this.getPaymentTypeList() // 尝试重新加载 |
|
|
|
return |
|
|
|
} |
|
|
|
this.payment_type_show = true |
|
|
|
}, |
|
|
|
//关闭选择器-付款类型 |
|
|
|
@ -559,17 +646,38 @@ export default { |
|
|
|
//下拉选择器相关-课程 |
|
|
|
//监听-课程 |
|
|
|
changeCourseId(e){ |
|
|
|
console.log('课程',e) |
|
|
|
console.log('选择的课程:', e) |
|
|
|
if (!e || !e.value) { |
|
|
|
uni.showToast({ |
|
|
|
title: '请选择有效的课程', |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
this.formData.course_id = e.value |
|
|
|
this.formData.course_id_name = e.text |
|
|
|
|
|
|
|
this.formData.money = this.course_id_options.find(v=>v.value == e.value).price |
|
|
|
// 查找对应课程的价格 |
|
|
|
const selectedCourse = this.course_id_options.find(v => v.value == e.value) |
|
|
|
if (selectedCourse && selectedCourse.price) { |
|
|
|
this.formData.money = selectedCourse.price |
|
|
|
} else { |
|
|
|
this.formData.money = '' |
|
|
|
console.warn('未找到所选课程的价格信息') |
|
|
|
} |
|
|
|
|
|
|
|
// console.log('课程formData',this.formData) |
|
|
|
this.cancelCourseId() |
|
|
|
}, |
|
|
|
//打开选择器-课程 |
|
|
|
openCourseId(){ |
|
|
|
if (!this.course_id_options || this.course_id_options.length === 0) { |
|
|
|
uni.showToast({ |
|
|
|
title: '课程数据加载中,请稍后再试', |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
this.getCourseList() // 尝试重新加载 |
|
|
|
return |
|
|
|
} |
|
|
|
this.course_id_show = true |
|
|
|
}, |
|
|
|
//关闭选择器-课程 |
|
|
|
@ -580,12 +688,28 @@ export default { |
|
|
|
//下拉选择器相关-班级 |
|
|
|
//监听-班级 |
|
|
|
changeClassId(e){ |
|
|
|
console.log('选择的班级:', e) |
|
|
|
if (!e || !e.value) { |
|
|
|
uni.showToast({ |
|
|
|
title: '请选择有效的班级', |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
this.formData.class_id = e.value |
|
|
|
this.formData.class_id_name = e.text |
|
|
|
this.cancelClassId() |
|
|
|
}, |
|
|
|
//打开选择器-班级 |
|
|
|
openClassId(){ |
|
|
|
if (!this.class_id_options || this.class_id_options.length === 0) { |
|
|
|
uni.showToast({ |
|
|
|
title: '班级数据加载中,请稍后再试', |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
this.getClassList() // 尝试重新加载 |
|
|
|
return |
|
|
|
} |
|
|
|
this.class_id_show = true |
|
|
|
}, |
|
|
|
//关闭选择器-班级 |
|
|
|
|