123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663 |
- <template>
- <div>
- <el-alert
- title="基础信息"
- type="info"
- :closable="false"
- class="baseMsg"
- ></el-alert>
- <div class="m-core">
- <el-form
- :label-position="labelPosition"
- :model="baseForm"
- ref="vipform"
- label-width="140px"
- :rules="vipformRules"
- class="vipform"
- >
- <el-form-item label="活动名称" prop="name">
- <el-input
- style="width: 400px"
- v-model.trim="baseForm.name"
- :disabled="isDisabled || status != 'DRAFT'"
- ></el-input>
- </el-form-item>
- <!-- @visible-change="$forceUpdate()" -->
- <el-form-item label="适用分部" prop="organ">
- <select-all
- v-model.trim="baseForm.organ"
- style="width: 400px"
- multiple
- filterable
- @change="onOrganChange"
- clearable
- :disabled="isDisabled || status != 'DRAFT'"
- >
- <el-option
- v-for="(item, index) in selects.branchs"
- :key="index"
- :label="item.name"
- :value="item.id"
- ></el-option>
- </select-all>
- <!-- <el-button @click="onCheckAllBranch">适用所有分部</el-button> -->
- </el-form-item>
- <el-form-item label="活动描述" prop="description">
- <el-input
- type="textarea"
- v-model.trim="baseForm.description"
- style="width: 400px"
- :rows="5"
- placeholder="请输入活动说明"
- :disabled="isDisabled || status != 'DRAFT'"
- ></el-input>
- </el-form-item>
- <el-form-item label="活动类型" prop="activityType">
- <el-select
- v-model.trim="baseForm.activityType"
- placeholder="请选择活动类型"
- clearable
- style="width: 400px !important"
- @change="changeActivityType"
- :disabled="isDisabled || status != 'DRAFT'"
- >
- <el-option label="课程活动" :value="0"></el-option>
- <el-option label="会员活动" :value="1"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="活动生效时间" prop="activeTime">
- <el-date-picker
- :disabled="isDisabled"
- v-model.trim="baseForm.activeTime"
- type="datetimerange"
- :default-time="['00:00:00', '23:59:59']"
- range-separator="至"
- value-format="yyyy-MM-dd HH:mm:ss"
- start-placeholder="开始日期"
- :picker-options="{
- firstDayOfWeek: 1,
- }"
- end-placeholder="结束日期"
- ></el-date-picker>
- <el-tooltip placement="top" popper-class="mTooltip">
- <div slot="content">
- 可通过该方案购买课程的时间范围,到达开始时间才可购买,到达结束时间后不可购买,不填则不限制且立即生效
- </div>
- <i
- class="el-icon-question micon el-tooltip"
- style="font-size: 18px; color: #f56c6c"
- ></i>
- </el-tooltip>
- </el-form-item>
- <el-form-item label="排课时间范围" prop="courseTime">
- <el-date-picker
- :disabled="isDisabled"
- v-model.trim="baseForm.courseTime"
- type="datetimerange"
- :default-time="['00:00:00', '23:59:59']"
- range-separator="至"
- value-format="yyyy-MM-dd HH:mm:ss"
- start-placeholder="开始日期"
- :picker-options="{
- firstDayOfWeek: 1,
- }"
- end-placeholder="结束日期"
- ></el-date-picker>
- <el-tooltip placement="top" popper-class="mTooltip">
- <div slot="content">
- 通过该方案购买的课程排课时间不可超过该时间范围,不填则不限制
- </div>
- <i
- class="el-icon-question micon el-tooltip"
- style="font-size: 18px; color: #f56c6c"
- ></i>
- </el-tooltip>
- </el-form-item>
- <el-form-item label="适用学员" prop="applyToStudentType">
- <el-row>
- <el-col style="width: 400px">
- <select-all
- v-model.trim="baseForm.applyToStudentType"
- style="width: 400px"
- multiple
- filterable
- clearable
- placeholder="请选择适用学员"
- @change="applyToStudentTypeChange"
- :disabled="isDisabled"
- >
- <el-option label="新学员" value="1"></el-option>
- <el-option label="老学员" value="0"></el-option>
- <el-option label="会员" value="2"></el-option>
- <el-option label="非会员" value="3"></el-option>
- </select-all>
- </el-col>
- <el-tooltip placement="top" popper-class="mTooltip">
- <div slot="content">
- 可通过该方案购买课程的学员群体,不填则不限制
- </div>
- <i
- class="el-icon-question micon el-tooltip"
- style="font-size: 18px; color: #f56c6c; margin-left: 3px"
- ></i>
- </el-tooltip>
- </el-row>
- </el-form-item>
- <el-form-item label="可购买次数" prop="studentMaxUsedTimes">
- <el-input
- style="width: 400px"
- type="number"
- v-model.trim="baseForm.studentMaxUsedTimes"
- :disabled="isDisabled"
- >
- <template slot="append">次</template>
- </el-input>
- <el-tooltip placement="top" popper-class="mTooltip">
- <div slot="content">
- 学员可通购买该活动方案的次数限制,不填则不限制
- </div>
- <i
- class="el-icon-question micon el-tooltip"
- style="font-size: 18px; color: #f56c6c"
- ></i>
- </el-tooltip>
- </el-form-item>
- <el-form-item label="是否充值课程余额" prop="isPayToBalance">
- <el-select
- v-model.trim="baseForm.isPayToBalance"
- placeholder="请选择是否充值课程余额"
- clearable
- style="width: 400px !important"
- :disabled="isDisabled || status != 'DRAFT'"
- >
- <el-option label="课程余额" :value="1"></el-option>
- <el-option label="资格限制" :value="0"></el-option>
- </el-select>
- <el-tooltip placement="top" popper-class="mTooltip">
- <div slot="content">
- 课程余额:学员缴费金额进入课程余额,排课时扣减课程余额;若课程余额不足则不可排课
- 资格限制:学员缴费金额不进入课程余额,学员购买后增加可排课次数,排课后扣减可排课次数
- 会员活动默认为资格限制,不可修改
- </div>
- <i
- class="el-icon-question micon el-tooltip"
- style="font-size: 18px; color: #f56c6c"
- ></i>
- </el-tooltip>
- </el-form-item>
- </el-form>
- </div>
- </div>
- </template>
- <script>
- import { vipGroupCategory, addVipActive } from "@/api/vipSeting";
- import { getEmployeeOrgan } from "@/api/buildTeam";
- import { vipResetTypeList } from "@/utils/searchArray";
- import cleanDeep from "clean-deep";
- export default {
- props: ["baseForm", "isDisabled", "status"],
- name: "vipNewActive",
- data() {
- return {
- vipResetTypeList,
- pageType: "",
- labelPosition: "right",
- vipformRules: {
- name: [
- { required: true, message: "请输入活动名称", trigger: "blur" },
- {
- min: 1,
- max: 25,
- message: "长度在 1 到 25 个字符",
- trigger: "blur",
- },
- ],
- desc: [
- { required: true, message: "请输入文字描述", trigger: "blur" },
- {
- min: 1,
- max: 200,
- message: "长度在 1 到 200 个字符",
- trigger: "blur",
- },
- ],
- activityType: [
- { required: true, message: "请选择活动类型", trigger: "blur" },
- ],
- // activeTime: [
- // { required: false, message: "请选择活动时间", trigger: "blur" },
- // ],
- courseTime: [
- { required: false, message: "请选择课程时间", trigger: "blur" },
- ],
- studentMaxUsedTimes: [
- { required: false, message: "请输入购买次数", trigger: "blur" },
- ],
- organ: [{ required: true, message: "请选择适用分部", trigger: "blur" }],
- stauts: [
- { required: true, message: "请选择活动形式", trigger: "blur" },
- ],
- applyToStudentType: [{ required: true, message: "请选择是否新生专享" }],
- isPayToBalance: [{ required: true, message: "请选择是否支付到余额" }],
- allowOnlineToOffline: [
- { required: true, message: "请选择课程调整方式" },
- ],
- },
- courseStatusList: [], // 获取所有课程形式
- activeType: "",
- online: true,
- unonline: true,
- onlineSalary: "TEACHER_DEFAULT",
- unonlineSalary: "TEACHER_DEFAULT",
- onlineprice: "",
- unonlineprice: "",
- salaryReadonlyFlag: false,
- paymentReadonlyFlag: false,
- attribute1: "",
- attribute2: "",
- courseNumForm: {
- minCourseNum: "",
- maxCourseNum: "",
- studentMaxUsedTimes: "",
- },
- giveClassPaySalaryFlag: true,
- organList: [],
- onlineClassJoinGradientRewards: false,
- offlineClassJoinGradientRewards: false,
- courseNumrules: {
- minCourseNum: [
- { required: true, message: "请输入最小课时数", trigger: "blur" },
- { validator: this.validateCom, trigger: "blur" },
- { validator: this.validateMin, trigger: "blur" },
- ],
- maxCourseNum: [
- { required: true, message: "请输入最大课时数", trigger: "blur" },
- { validator: this.validateCom, trigger: "blur" },
- { validator: this.validateMax, trigger: "blur" },
- ],
- },
- };
- },
- async mounted() {
- // 首先获取课程形式
- // vipGroupCategory().then(res => {
- // if (res.code == 200) {
- // this.courseStatusList = res.data;
- // }
- // });
- // // 适用分部
- // getEmployeeOrgan().then(res => {
- // if (res.code == 200) {
- // this.organList = res.data;
- // }
- // });
- // 获取类型
- await this.$store.dispatch("setVipGroupCategory");
- // 获取分部
- await this.$store.dispatch("setBranchs");
- // this.onReSet();
- // if (this.$route.query.rules) {
- // this.rules = this.$route.query.rules;
- // }
- // if (this.$route.query.searchForm) {
- // this.searchForm = this.$route.query.searchForm;
- // }
- this.pageType = this.$route.query.type;
- if (!this.$route.query.id) {
- this.$refs.vipform.resetFields();
- }
- //
- },
- methods: {
- resetForm() {
- this.$refs.form.resetFields();
- },
- handleMinChange() {
- this.$refs.form.validateField("maxCourseNum");
- },
- handleMaxChange() {
- this.$refs.form.validateField("minCourseNum");
- },
- validateCom(rule, value, callback) {
- const one = Number(value);
- if (Number.isInteger(one)) {
- if (one < MIN_NUMBER) {
- return callback(new Error("输入值必须大于0"));
- } else if (one > MAX_NUMBER) {
- return callback(new Error("输入值必须小于999"));
- }
- return callback();
- }
- return callback(new Error("输入值必须为正整数"));
- },
- validateMin(rule, value, callback) {
- const one = Number(value);
- const max = Number(this.courseNumForm.maxCourseNum);
- if (!max || one <= max) {
- return callback();
- }
- return callback(new Error("输入值不得大于最大课时数"));
- },
- validateMax(rule, value, callback) {
- const one = Number(value);
- const min = Number(this.courseNumForm.minCourseNum);
- if (!min || one >= min) {
- return callback();
- }
- return callback(new Error("输入值不得小于最小课时数"));
- },
- changeStauts(val) {
- console.log(val);
- },
- changeActivityType(val) {
- this.$emit("resetPayInfo");
- },
- submitFrom() {
- this.$refs.form.validate((isok) => {
- if (isok) {
- this.$refs["vipform"].validate((valid) => {
- if (valid) {
- // 验证通过
- let coursesStartTime = null,
- coursesEndTime = null,
- startTime = null,
- endTime = null;
- if (
- this.vipform.courseTime &&
- this.vipform.courseTime.length > 0
- ) {
- coursesStartTime = this.vipform.courseTime[0];
- coursesEndTime = this.vipform.courseTime[1];
- }
- if (
- this.vipform.activeTime &&
- this.vipform.activeTime.length > 0
- ) {
- startTime = this.vipform.activeTime[0];
- endTime = this.vipform.activeTime[1];
- }
- let organId = this.vipform.organ.join(",");
- let type = this.activeType;
- if (!type) {
- this.$message.error("请选择活动类型");
- return;
- }
- if (!this.online && !this.unonline) {
- this.$message.error("请选择活动适用范围");
- return;
- }
- if (type == "DISCOUNT") {
- if (!this.attribute1 || this.attribute1 < 0) {
- this.$message.error("折扣必须大于等于0");
- return;
- }
- } else if (type == "GIVE_CLASS") {
- if (!this.attribute1) {
- this.$message.error("请输入多少节开始赠");
- return;
- }
- if (!this.attribute2) {
- this.$message.error("请输入赠送课时数");
- return;
- }
- }
- let vipGroupCategoryIdList = this.vipform.stauts.join(",");
- let onlineSalarySettlement;
- let offlineSalarySettlement;
- if (this.online) {
- // 勾选线上
- if (this.onlineSalary == "RATIO_DISCOUNT") {
- if (this.onlineprice < 0 || this.onlineprice > 100) {
- this.$message.error("折扣比必须大于0且小于100");
- return;
- }
- } else if (this.onlineSalary == "TEACHER_DEFAULT") {
- this.onlineprice = 0;
- }
- onlineSalarySettlement = {
- salarySettlementType: this.onlineSalary,
- settlementValue: this.onlineprice,
- };
- } else {
- onlineSalarySettlement = null;
- }
- if (this.unonline) {
- // 勾选线下
- if (this.unonlineSalary == "RATIO_DISCOUNT") {
- if (this.unonlineprice < 0 || this.unonlineprice > 100) {
- this.$message.error("折扣比必须大于0且小于100");
- return;
- }
- } else if (this.unonlineSalary == "TEACHER_DEFAULT") {
- this.unonlineprice = 0;
- }
- offlineSalarySettlement = {
- salarySettlementType: this.unonlineSalary,
- settlementValue: this.unonlineprice,
- };
- } else {
- offlineSalarySettlement = null;
- }
- let salaryReadonlyFlag = this.salaryReadonlyFlag * 1;
- let paymentReadonlyFlag = this.paymentReadonlyFlag * 1;
- // let giveClassPaySalaryFlag = this.giveClassPaySalaryFlag * 1;
- let vipGroupSalarySettlement = {
- onlineSalarySettlement,
- offlineSalarySettlement,
- };
- if (type == "BASE_ACTIVITY") {
- this.courseNumForm.studentMaxUsedTimes = -1;
- this.courseNumForm.minCourseNum = -1;
- this.courseNumForm.maxCourseNum = -1;
- } else if (type == "GIVE_CLASS") {
- this.courseNumForm.minCourseNum = -1;
- this.courseNumForm.maxCourseNum = -1;
- }
- // 发请求创建活动
- addVipActive(
- cleanDeep({
- coursesStartTime,
- coursesEndTime,
- startTime,
- endTime,
- name: this.vipform.name,
- description: this.vipform.desc,
- applyToStudentType: this.vipform.applyToStudentType,
- allowOnlineToOffline: this.vipform.allowOnlineToOffline,
- organId,
- type,
- vipGroupCategoryIdList,
- vipGroupSalarySettlement,
- salaryReadonlyFlag,
- paymentReadonlyFlag,
- giveClassPaySalaryFlag: 1,
- attribute1: this.attribute1,
- attribute2: this.attribute2,
- minCourseNum: this.courseNumForm.minCourseNum,
- maxCourseNum: this.courseNumForm.maxCourseNum,
- studentMaxUsedTimes: this.courseNumForm.studentMaxUsedTimes
- ? this.courseNumForm.studentMaxUsedTimes
- : -1,
- offlineClassJoinGradientRewards:
- this.offlineClassJoinGradientRewards * 1,
- onlineClassJoinGradientRewards:
- this.onlineClassJoinGradientRewards * 1,
- })
- ).then((res) => {
- if (res.code == 200) {
- this.$message.success("恭喜你,活动创建成功");
- // this.onReSet();
- this.$store.dispatch("delVisitedViews", this.$route);
- this.$router.push({
- path: "/vipActiveManager/vipActiveList",
- });
- }
- });
- } else {
- this.$nextTick(() => {
- let isError = document.getElementsByClassName("is-error");
- isError[0].scrollIntoView({
- block: "center",
- behavior: "smooth",
- });
- });
- // this.$message.error("请填写必要参数");
- }
- });
- }
- });
- // 线上线下课 勾选就传不勾选就不传
- // addVipActive().then(res => { })
- },
- onOrganChange() {
- // this.$forceUpdate();
- this.$refs.vipform.validateField("organ");
- this.$forceUpdate();
- },
- applyToStudentTypeChange() {
- this.$refs.vipform.validateField("applyToStudentType");
- this.$forceUpdate();
- },
- onCheckAllBranch() {
- // 选择所有分部
- let vipform = this.vipform;
- vipform.organ = [];
- this.selects.branchs.forEach((item) => {
- vipform.organ.push(item.id);
- });
- this.$refs.vipform.validateField("organ");
- this.$forceUpdate();
- },
- onReSet() {
- this.vipform = {
- name: "",
- desc: "",
- activeTime: [],
- courseTime: [],
- };
- this.activeType = "";
- this.online = true;
- this.unonline = true;
- this.salaryReadonlyFlag = false;
- this.onlineSalary = "TEACHER_DEFAULT";
- this.unonlineSalary = "TEACHER_DEFAULT";
- this.onlineprice = "";
- this.unonlineprice = "";
- this.onlineClassJoinGradientRewards = false;
- this.offlineClassJoinGradientRewards = false;
- this.attribute1 = "";
- this.attribute2 = "";
- this.courseNumForm.maxCourseNum = "";
- this.courseNumForm.minCourseNum = "";
- // this.$refs.vipform.resetFields();
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .baseMsg {
- margin: 30px 0;
- }
- .m-core {
- font-size: 14px;
- width: 100%;
- display: flex;
- flex-direction: column;
- justify-content: center;
- // text-align: center;
- .activeRange {
- display: flex;
- flex-direction: row;
- justify-content: flex-start;
- .left {
- height: 72px;
- line-height: 72px;
- }
- .right {
- .chioseWrap {
- display: flex;
- flex-direction: row;
- justify-content: flex-start;
- height: 72px;
- line-height: 72px;
- align-items: center;
- .el-checkbox {
- margin-right: 20px;
- }
- .el-select {
- margin-right: 20px;
- }
- }
- }
- }
- .activeType {
- display: flex;
- flex-direction: row;
- justify-content: flex-start;
- .left {
- margin-right: 20px;
- p {
- height: 40px;
- line-height: 40px;
- }
- }
- .right {
- > div {
- display: flex;
- flex-direction: row;
- justify-content: flex-start;
- height: 40px;
- line-height: 40px;
- margin-bottom: 20px;
- .head {
- width: 120px;
- height: 40px;
- line-height: 40px;
- border: 1px solid #ccc;
- text-align: center;
- border-radius: 5px;
- cursor: pointer;
- margin-right: 10px;
- }
- > .head.active {
- background-color: #13817a;
- color: #fff;
- border: none;
- }
- .title {
- line-height: 40px;
- height: 40px;
- }
- }
- }
- }
- }
- </style>
- <style lang="scss">
- .m-core {
- // .vipform {
- // .el-select {
- // .el-input__inner {
- // }
- // }
- // }
- .activeType {
- .right {
- .el-input {
- width: 150px !important;
- }
- }
- }
- }
- </style>
|