|
@@ -1,25 +1,20 @@
|
|
|
<template>
|
|
<template>
|
|
|
<el-dialog
|
|
<el-dialog
|
|
|
- title="绑定套餐"
|
|
|
|
|
|
|
+ :title="isEdit ? '编辑套餐' : '绑定套餐'"
|
|
|
:visible.sync="dialogVisible"
|
|
:visible.sync="dialogVisible"
|
|
|
width="500px"
|
|
width="500px"
|
|
|
append-to-body
|
|
append-to-body
|
|
|
@close="handleClose"
|
|
@close="handleClose"
|
|
|
>
|
|
>
|
|
|
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
|
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
|
|
- <el-form-item label="小程序" prop="appId">
|
|
|
|
|
- <el-select v-model="form.appId" placeholder="请选择小程序" clearable>
|
|
|
|
|
- <el-option
|
|
|
|
|
- v-for="item in sourceList"
|
|
|
|
|
- :key="item.dictValue1"
|
|
|
|
|
- :label="item.dictLabel"
|
|
|
|
|
- :value="item.dictValue1"
|
|
|
|
|
- />
|
|
|
|
|
- </el-select>
|
|
|
|
|
- </el-form-item>
|
|
|
|
|
-
|
|
|
|
|
<el-form-item label="套餐包" prop="packageId">
|
|
<el-form-item label="套餐包" prop="packageId">
|
|
|
- <el-select v-model="form.packageId" placeholder="请选择套餐包" clearable filterable>
|
|
|
|
|
|
|
+ <el-select
|
|
|
|
|
+ v-model="form.packageId"
|
|
|
|
|
+ placeholder="请选择套餐包"
|
|
|
|
|
+ clearable
|
|
|
|
|
+ filterable
|
|
|
|
|
+ :disabled="isEdit"
|
|
|
|
|
+ >
|
|
|
<el-option
|
|
<el-option
|
|
|
v-for="item in packageOptions"
|
|
v-for="item in packageOptions"
|
|
|
:key="item.dictValue"
|
|
:key="item.dictValue"
|
|
@@ -57,9 +52,8 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
-import { allPrivatePackage } from "@/api/store/package";
|
|
|
|
|
-import { options } from "@/api/course/coursePlaySourceConfig";
|
|
|
|
|
-import { bindCollectionPackage } from "@/api/qw/collectionPendingSales";
|
|
|
|
|
|
|
+import {allPrivatePackage} from "@/api/store/package";
|
|
|
|
|
+import {bindCollectionPackage} from "@/api/qw/collectionPendingSales";
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
|
name: "BindPackageDialog",
|
|
name: "BindPackageDialog",
|
|
@@ -73,36 +67,42 @@ export default {
|
|
|
type: Number,
|
|
type: Number,
|
|
|
default: null,
|
|
default: null,
|
|
|
},
|
|
},
|
|
|
|
|
+ // 编辑时传入的数据 { packageId, payType, amount }
|
|
|
|
|
+ editData: {
|
|
|
|
|
+ type: Object,
|
|
|
|
|
+ default: null,
|
|
|
|
|
+ },
|
|
|
},
|
|
},
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
|
dialogVisible: false,
|
|
dialogVisible: false,
|
|
|
submitLoading: false,
|
|
submitLoading: false,
|
|
|
- sourceList: [],
|
|
|
|
|
packageOptions: [],
|
|
packageOptions: [],
|
|
|
form: {
|
|
form: {
|
|
|
- id: null, // 采集信息主键
|
|
|
|
|
- appId: null,
|
|
|
|
|
|
|
+ id: null,
|
|
|
packageId: null,
|
|
packageId: null,
|
|
|
- payType: 1, // 默认全款
|
|
|
|
|
|
|
+ payType: 1,
|
|
|
amount: null,
|
|
amount: null,
|
|
|
},
|
|
},
|
|
|
rules: {
|
|
rules: {
|
|
|
- appId: [
|
|
|
|
|
- { required: true, message: "请选择小程序", trigger: "change" },
|
|
|
|
|
- ],
|
|
|
|
|
packageId: [
|
|
packageId: [
|
|
|
- { required: true, message: "请选择套餐包", trigger: "change" },
|
|
|
|
|
|
|
+ {required: true, message: "请选择套餐包", trigger: "change"},
|
|
|
],
|
|
],
|
|
|
payType: [
|
|
payType: [
|
|
|
- { required: true, message: "请选择支付类型", trigger: "change" },
|
|
|
|
|
|
|
+ {required: true, message: "请选择支付类型", trigger: "change"},
|
|
|
],
|
|
],
|
|
|
amount: [
|
|
amount: [
|
|
|
- { required: true, message: "请填写物流代收金额", trigger: "blur" },
|
|
|
|
|
|
|
+ {required: true, message: "请填写物流代收金额", trigger: "blur"},
|
|
|
],
|
|
],
|
|
|
},
|
|
},
|
|
|
|
|
+ originalPackageId: null, // 编辑模式下保留的原套餐包ID
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
|
|
+ computed: {
|
|
|
|
|
+ isEdit() {
|
|
|
|
|
+ return this.editData !== null;
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
watch: {
|
|
watch: {
|
|
|
visible: {
|
|
visible: {
|
|
|
handler(val) {
|
|
handler(val) {
|
|
@@ -114,7 +114,6 @@ export default {
|
|
|
immediate: true,
|
|
immediate: true,
|
|
|
},
|
|
},
|
|
|
"form.payType"(val) {
|
|
"form.payType"(val) {
|
|
|
- // 切换支付类型时,重置金额字段
|
|
|
|
|
if (val !== 2) {
|
|
if (val !== 2) {
|
|
|
this.form.amount = null;
|
|
this.form.amount = null;
|
|
|
this.$refs.form?.clearValidate("amount");
|
|
this.$refs.form?.clearValidate("amount");
|
|
@@ -122,15 +121,9 @@ export default {
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
created() {
|
|
created() {
|
|
|
- this.fetchSourceList();
|
|
|
|
|
this.fetchPackageList();
|
|
this.fetchPackageList();
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
- fetchSourceList() {
|
|
|
|
|
- options().then((res) => {
|
|
|
|
|
- this.sourceList = res.data || [];
|
|
|
|
|
- });
|
|
|
|
|
- },
|
|
|
|
|
fetchPackageList() {
|
|
fetchPackageList() {
|
|
|
allPrivatePackage().then((res) => {
|
|
allPrivatePackage().then((res) => {
|
|
|
this.packageOptions = res.rows || [];
|
|
this.packageOptions = res.rows || [];
|
|
@@ -138,10 +131,18 @@ export default {
|
|
|
},
|
|
},
|
|
|
initData() {
|
|
initData() {
|
|
|
this.form.id = this.collectionId;
|
|
this.form.id = this.collectionId;
|
|
|
- this.form.appId = null;
|
|
|
|
|
- this.form.packageId = null;
|
|
|
|
|
- this.form.payType = 1;
|
|
|
|
|
- this.form.amount = null;
|
|
|
|
|
|
|
+ if (this.isEdit) {
|
|
|
|
|
+ // 编辑模式:保留原套餐包ID(用于提交),表单中套餐包下拉框置空(不可选)
|
|
|
|
|
+ this.originalPackageId = this.editData.packageId;
|
|
|
|
|
+ this.form.packageId = null;
|
|
|
|
|
+ this.form.payType = this.editData.payType;
|
|
|
|
|
+ this.form.amount = this.editData.amount;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.originalPackageId = null;
|
|
|
|
|
+ this.form.packageId = null;
|
|
|
|
|
+ this.form.payType = 1;
|
|
|
|
|
+ this.form.amount = null;
|
|
|
|
|
+ }
|
|
|
this.$nextTick(() => {
|
|
this.$nextTick(() => {
|
|
|
if (this.$refs.form) {
|
|
if (this.$refs.form) {
|
|
|
this.$refs.form.clearValidate();
|
|
this.$refs.form.clearValidate();
|
|
@@ -152,26 +153,24 @@ export default {
|
|
|
this.$refs.form.validate((valid) => {
|
|
this.$refs.form.validate((valid) => {
|
|
|
if (!valid) return;
|
|
if (!valid) return;
|
|
|
|
|
|
|
|
- // 构建提交参数,与后端 bindCollectionPackageParam 对应
|
|
|
|
|
const params = {
|
|
const params = {
|
|
|
id: this.form.id,
|
|
id: this.form.id,
|
|
|
- packageId: this.form.packageId,
|
|
|
|
|
- // 以下字段根据实际接口是否需要传递决定,若不需要可省略
|
|
|
|
|
- // appId: this.form.appId,
|
|
|
|
|
- // payType: this.form.payType,
|
|
|
|
|
- // amount: this.form.amount,
|
|
|
|
|
|
|
+ // 编辑模式下使用原套餐包ID,新增模式下使用表单选择的套餐包ID
|
|
|
|
|
+ packageId: this.isEdit ? this.originalPackageId : this.form.packageId,
|
|
|
|
|
+ payType: this.form.payType,
|
|
|
|
|
+ amount: this.form.amount,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
this.submitLoading = true;
|
|
this.submitLoading = true;
|
|
|
bindCollectionPackage(params)
|
|
bindCollectionPackage(params)
|
|
|
.then((res) => {
|
|
.then((res) => {
|
|
|
- this.$message.success("绑定套餐成功");
|
|
|
|
|
|
|
+ this.$message.success(this.isEdit ? "修改成功" : "绑定成功");
|
|
|
this.dialogVisible = false;
|
|
this.dialogVisible = false;
|
|
|
this.$emit("success", res.data);
|
|
this.$emit("success", res.data);
|
|
|
this.$emit("update:visible", false);
|
|
this.$emit("update:visible", false);
|
|
|
})
|
|
})
|
|
|
.catch((error) => {
|
|
.catch((error) => {
|
|
|
- this.$message.error(error.msg || "绑定失败");
|
|
|
|
|
|
|
+ this.$message.error(error.msg || (this.isEdit ? "修改失败" : "绑定失败"));
|
|
|
})
|
|
})
|
|
|
.finally(() => {
|
|
.finally(() => {
|
|
|
this.submitLoading = false;
|
|
this.submitLoading = false;
|
|
@@ -186,7 +185,3 @@ export default {
|
|
|
},
|
|
},
|
|
|
};
|
|
};
|
|
|
</script>
|
|
</script>
|
|
|
-
|
|
|
|
|
-<style scoped>
|
|
|
|
|
-/* 可根据需要添加样式 */
|
|
|
|
|
-</style>
|
|
|