提交 0d512496 authored 作者: 王鹏飞's avatar 王鹏飞

update

上级 abd7a84b
...@@ -109,11 +109,11 @@ export function getGraduationOrderList(data) { ...@@ -109,11 +109,11 @@ export function getGraduationOrderList(data) {
} }
// 获取毕业典礼商品列表 // 获取毕业典礼商品列表
export function getGraduationGoodsList(data) { export function getGraduationProductList(data) {
return httpRequest.get('/api/pay/v1/product/params-details', data) return httpRequest.get('/api/pay/v1/product/params-details', data)
} }
// 多个商品合并为一个商品 // 多个商品合并为一个商品
export function mergeGraduationGoods(data) { export function mergeGraduationProduct(data) {
return httpRequest.post('/api/pay/v1/product/create-by-details', data) return httpRequest.post('/api/pay/v1/product/create-by-details', data)
} }
...@@ -5,23 +5,25 @@ ...@@ -5,23 +5,25 @@
<el-button type="text" @click="goBack">返回列表</el-button> <el-button type="text" @click="goBack">返回列表</el-button>
<div class="main-form"> <div class="main-form">
<el-form label-width="100px" ref="ruleForm" :model="ruleForm" :rules="rules"> <el-form label-width="100px" ref="ruleForm" :model="ruleForm" :rules="rules">
<el-form-item label="本人参与方式" prop="goodsId"> <el-form-item label="本人参与方式" prop="product_id">
<el-radio-group v-model="ruleForm.goodsId" size="small"> <el-radio-group v-model="ruleForm.product_id" size="small">
<el-radio border></el-radio> <el-radio border></el-radio>
<el-radio border :label="item.id" v-for="item in selfGoodsList" :key="item.id">{{ item.name }}</el-radio> <el-radio border :label="item.id" v-for="item in selfProductList" :key="item.id">{{
item.name
}}</el-radio>
</el-radio-group> </el-radio-group>
<el-popover placement="top-start" width="400" trigger="hover"> <el-popover placement="top-start" width="400" trigger="hover">
<i class="el-icon-question" slot="reference"></i> <i class="el-icon-question" slot="reference"></i>
<div> <div>
<ol> <ol>
<li v-for="item in selfGoodsList" :key="item.id"> <li v-for="item in selfProductList" :key="item.id">
{{ item.name }}{{ item.desc }} {{ item.price }} {{ item.name }}{{ item.desc }} {{ item.price }}
</li> </li>
</ol> </ol>
</div> </div>
</el-popover> </el-popover>
</el-form-item> </el-form-item>
<template v-if="ruleForm.goodsId"> <template v-if="ruleForm.product_id">
<el-form-item label="姓名" prop="personal_name"> <el-form-item label="姓名" prop="personal_name">
<el-input v-model="ruleForm.personal_name" /> <el-input v-model="ruleForm.personal_name" />
</el-form-item> </el-form-item>
...@@ -46,22 +48,22 @@ ...@@ -46,22 +48,22 @@
<i class="el-icon-error" @click="handleRemoveChild(index)"></i> <i class="el-icon-error" @click="handleRemoveChild(index)"></i>
<el-form-item <el-form-item
label="随同关系" label="随同关系"
:prop="'children.' + index + '.goodsId'" :prop="'children.' + index + '.product_id'"
:rules="{ required: true, message: '请选择', trigger: 'blur' }" :rules="{ required: true, message: '请选择', trigger: 'blur' }"
> >
<el-select v-model="child.goodsId"> <el-select v-model="child.product_id">
<el-option <el-option
:value="item.id" :value="item.id"
:label="item.name" :label="item.name"
:key="item.id" :key="item.id"
v-for="item in otherGoodsList" v-for="item in otherProductList"
></el-option> ></el-option>
</el-select> </el-select>
<el-popover placement="top-start" width="400" trigger="hover"> <el-popover placement="top-start" width="400" trigger="hover">
<i class="el-icon-question" slot="reference"></i> <i class="el-icon-question" slot="reference"></i>
<div> <div>
<ol> <ol>
<li v-for="item in otherGoodsList" :key="item.id"> <li v-for="item in otherProductList" :key="item.id">
{{ item.name }}{{ item.desc }} {{ item.price }} {{ item.name }}{{ item.desc }} {{ item.price }}
</li> </li>
</ol> </ol>
...@@ -92,6 +94,9 @@ ...@@ -92,6 +94,9 @@
<el-radio :label="item.value" v-for="item in payList" :key="item.value">{{ item.label }}</el-radio> <el-radio :label="item.value" v-for="item in payList" :key="item.value">{{ item.label }}</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="支付金额" prop="payment"
><em class="price"></em>{{ formatValue(payPrice) }}
</el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" :disabled="disabled" @click="handleSubmit">立即支付</el-button> <el-button type="primary" :disabled="disabled" @click="handleSubmit">立即支付</el-button>
</el-form-item> </el-form-item>
...@@ -112,22 +117,22 @@ export default { ...@@ -112,22 +117,22 @@ export default {
components: { Pay }, components: { Pay },
data() { data() {
return { return {
goodsList: [], productList: [],
ruleForm: { ruleForm: {
goodsId: '', product_id: '',
personal_name: '', personal_name: '',
telephone: '', telephone: '',
class_name: '', class_name: '',
address: '', address: '',
has_children: 0, has_children: 0,
payment: '2', payment: '2',
children: [{ goodsId: '', personal_name: '', telephone: '' }] children: [{ product_id: '', personal_name: '', telephone: '' }]
}, },
rules: { rules: {
personal_name: [{ required: true, message: '请输入您的姓名', trigger: 'blur' }], personal_name: [{ required: true, message: '请输入您的姓名', trigger: 'blur' }],
telephone: [{ required: true, message: '请输入您的手机号', trigger: 'blur' }], telephone: [{ required: true, message: '请输入您的手机号', trigger: 'blur' }],
class_name: [{ required: true, message: '请输入您的班级', trigger: 'blur' }], class_name: [{ required: true, message: '请输入您的班级', trigger: 'blur' }]
address: [{ required: true, message: '请输入邮寄地址', trigger: 'blur' }] // address: [{ required: true, message: '请输入邮寄地址', trigger: 'blur' }]
}, },
payList: [ payList: [
{ label: '微信支付', value: '2' }, { label: '微信支付', value: '2' },
...@@ -142,17 +147,36 @@ export default { ...@@ -142,17 +147,36 @@ export default {
affairId() { affairId() {
return this.$route.query.id return this.$route.query.id
}, },
selfGoodsList() { selfProductList() {
return this.goodsList.filter((item, index) => index < 3) return this.productList.filter((item, index) => index < 3)
}, },
otherGoodsList() { otherProductList() {
return this.goodsList.filter((item, index) => index >= 3) return this.productList.filter((item, index) => index >= 3)
}, },
disabled() { disabled() {
return (!this.ruleForm.goodsId && !this.ruleForm.has_children) || this.submitDisabled return (!this.ruleForm.product_id && !this.ruleForm.has_children) || this.submitDisabled
},
payPrice() {
let price = 0
if (this.ruleForm.product_id) {
const found = this.productList.find(item => item.id === this.ruleForm.product_id)
price += parseFloat(found.price)
}
if (this.ruleForm.has_children && this.ruleForm.children.length) {
this.ruleForm.children.forEach(item => {
if (item.product_id) {
const found = this.productList.find(product => product.id === item.product_id)
price += parseFloat(found.price)
}
})
}
return price
} }
}, },
methods: { methods: {
formatValue(value = 0) {
return value.toLocaleString()
},
// 返回 // 返回
goBack() { goBack() {
this.$router.push({ path: '/app/offices', query: { id: this.affairId } }) this.$router.push({ path: '/app/offices', query: { id: this.affairId } })
...@@ -164,19 +188,19 @@ export default { ...@@ -164,19 +188,19 @@ export default {
Object.assign(this.ruleForm, data) Object.assign(this.ruleForm, data)
}) })
}, },
getGoodsList() { getProductList() {
api.getGraduationGoodsList().then(response => { api.getGraduationProductList().then(response => {
const { list = [] } = response const { list = [] } = response
const [first] = list const [first] = list
this.goodsList = list this.productList = list
if (first) { if (first) {
this.ruleForm.goodsId = first.id this.ruleForm.product_id = first.id
} }
}) })
}, },
// 添加随同 // 添加随同
handleAddChild() { handleAddChild() {
this.ruleForm.children.push({ goodsId: '', personal_name: '', telephone: '' }) this.ruleForm.children.push({ product_id: '', personal_name: '', telephone: '' })
}, },
// 删除随同 // 删除随同
handleRemoveChild(index) { handleRemoveChild(index) {
...@@ -184,44 +208,47 @@ export default { ...@@ -184,44 +208,47 @@ export default {
}, },
// 提交 // 提交
handleSubmit() { handleSubmit() {
this.$refs.ruleForm.validate().then(this.mergeGoods) this.$refs.ruleForm.validate().then(this.mergeProduct)
}, },
// 合并商品 // 合并商品
mergeGoods() { mergeProduct() {
const params = [] const params = []
// 个人商品数据 // 个人商品数据
if (this.ruleForm.goodsId) { if (this.ruleForm.product_id) {
const goods = this.goodsList.find(goods => goods.id === this.ruleForm.goodsId) const product = this.productList.find(product => product.id === this.ruleForm.product_id)
params.push({ params.push({
id: this.ruleForm.goodsId, id: this.ruleForm.product_id,
num: 1, num: 1,
comment: `${goods.name}:${goods.desc}`, comment: `${product.name}:${product.desc}`,
other_param: JSON.stringify({ personal_name: this.ruleForm.personal_name,
personal_name: this.ruleForm.personal_name, telephone: this.ruleForm.telephone,
telephone: this.ruleForm.telephone, class_name: this.ruleForm.class_name,
class_name: this.ruleForm.class_name, address: this.ruleForm.address,
address: this.ruleForm.address, has_children: this.ruleForm.has_children,
has_children: this.ruleForm.has_children, is_self: 1,
is_self: 1, product: JSON.stringify(product)
goods
})
}) })
} }
// 随同商品数据 // 随同商品数据
if (this.ruleForm.has_children && this.ruleForm.children.length) { if (this.ruleForm.has_children && this.ruleForm.children.length) {
this.ruleForm.children.forEach(item => { this.ruleForm.children.forEach(item => {
const goods = this.goodsList.find(goods => goods.id === item.goodsId) const product = this.productList.find(product => product.id === item.product_id)
params.push({ params.push(
id: item.goodsId, Object.assign(
num: 1, {
comment: `${goods.name}:${goods.desc}`, id: item.product_id,
other_param: JSON.stringify(Object.assign({ goods }, item)) num: 1,
}) comment: `${product.name}:${product.desc}`,
product: JSON.stringify(product)
},
item
)
)
}) })
} }
this.submitDisabled = true this.submitDisabled = true
api api
.mergeGraduationGoods({ params }) .mergeGraduationProduct({ params })
.then(response => { .then(response => {
this.productId = response.product_id this.productId = response.product_id
this.payVisible = true this.payVisible = true
...@@ -239,7 +266,7 @@ export default { ...@@ -239,7 +266,7 @@ export default {
beforeMount() { beforeMount() {
// 获取学生信息 // 获取学生信息
this.getStudent() this.getStudent()
this.getGoodsList() this.getProductList()
} }
} }
</script> </script>
...@@ -249,6 +276,11 @@ export default { ...@@ -249,6 +276,11 @@ export default {
max-width: 600px; max-width: 600px;
margin: 0 auto; margin: 0 auto;
} }
.price {
font-style: normal;
color: #b80037;
font-size: 20px;
}
.children { .children {
position: relative; position: relative;
padding: 20px 0; padding: 20px 0;
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
<el-form label-position="left" class="table-expand" v-if="props.row.others.length"> <el-form label-position="left" class="table-expand" v-if="props.row.others.length">
<template v-for="(item, index) in props.row.others"> <template v-for="(item, index) in props.row.others">
<div class="table-expand-item" :key="index"> <div class="table-expand-item" :key="index">
<el-form-item label="随同关系" v-if="item.goods"> <el-form-item label="随同关系" v-if="item.product">
<span>{{ item.goods.name }}</span> <span>{{ item.product.name }}</span>
</el-form-item> </el-form-item>
<el-form-item label="姓名"> <el-form-item label="姓名">
<span>{{ item.personal_name }}</span> <span>{{ item.personal_name }}</span>
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="姓名" prop="personal.personal_name"></el-table-column> <el-table-column label="姓名" prop="personal.personal_name"></el-table-column>
<el-table-column label="参与方式" prop="personal.goods.name"></el-table-column> <el-table-column label="参与方式" prop="personal.product.name"></el-table-column>
<el-table-column label="手机号" prop="personal.telephone"></el-table-column> <el-table-column label="手机号" prop="personal.telephone"></el-table-column>
<el-table-column label="班级" prop="personal.class_name"></el-table-column> <el-table-column label="班级" prop="personal.class_name"></el-table-column>
<el-table-column label="支付方式" prop="type"> <el-table-column label="支付方式" prop="type">
...@@ -64,7 +64,10 @@ export default { ...@@ -64,7 +64,10 @@ export default {
this.page.total = total this.page.total = total
this.list = list.map(item => { this.list = list.map(item => {
let list = JSON.parse(item.product_desc) || [] let list = JSON.parse(item.product_desc) || []
list = list.map(item => JSON.parse(item.other_param)) list = list.map(item => {
item.product = JSON.parse(item.product)
return item
})
const [personal, ...others] = list const [personal, ...others] = list
item.personal = personal item.personal = personal
item.others = others || [] item.others = others || []
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论