|
@@ -0,0 +1,197 @@
|
|
|
|
+<template>
|
|
|
|
+ <div id="specAdd">
|
|
|
|
+ <el-form
|
|
|
|
+ :model="ruleForm"
|
|
|
|
+ :rules="rules"
|
|
|
|
+ ref="ruleForm"
|
|
|
|
+ label-width="170px"
|
|
|
|
+ hide-required-asterisk
|
|
|
|
+ >
|
|
|
|
+ <el-form-item label="使用的业务层次" required>
|
|
|
|
+ <div style="display: flex">
|
|
|
|
+ <el-form-item prop="educationTypeId">
|
|
|
|
+ <el-select
|
|
|
|
+ style="margin-right: 24px"
|
|
|
|
+ v-model="ruleForm.educationTypeId"
|
|
|
|
+ placeholder="请选择教育类型"
|
|
|
|
+ :disabled="!!stId"
|
|
|
|
+ @change="changeEduType"
|
|
|
|
+ >
|
|
|
|
+ <el-option
|
|
|
|
+ v-for="(item, index) in eduTypeOptions"
|
|
|
|
+ :key="index"
|
|
|
|
+ :label="item.educationName"
|
|
|
|
+ :value="item.id"
|
|
|
|
+ >
|
|
|
|
+ </el-option>
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+
|
|
|
|
+ <el-form-item prop="businessId">
|
|
|
|
+ <el-select
|
|
|
|
+ :disabled="!!stId"
|
|
|
|
+ v-model="ruleForm.businessId"
|
|
|
|
+ placeholder="请选择业务层次"
|
|
|
|
+ >
|
|
|
|
+ <el-option
|
|
|
|
+ v-for="(item, index) in newCourTypeOptions"
|
|
|
|
+ :key="index"
|
|
|
|
+ :label="item.projectName + '-' + item.businessName"
|
|
|
|
+ :value="item.id"
|
|
|
|
+ >
|
|
|
|
+ </el-option>
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </div>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="名称" prop="name">
|
|
|
|
+ <el-input v-model="ruleForm.name"></el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <template v-if="!stId">
|
|
|
|
+ <el-form-item label="商品规格" class="eee" prop="specList">
|
|
|
|
+ <Spec-box
|
|
|
|
+ ref="specBox"
|
|
|
|
+ v-for="(item, index) in ruleForm.specList"
|
|
|
|
+ :key="index"
|
|
|
|
+ v-model="ruleForm.specList"
|
|
|
|
+ :num="index"
|
|
|
|
+ >
|
|
|
|
+ </Spec-box>
|
|
|
|
+ <el-button
|
|
|
|
+ size="mini"
|
|
|
|
+ style="margin: 20px"
|
|
|
|
+ type="primary"
|
|
|
|
+ icon="el-icon-plus"
|
|
|
|
+ @click="addSpec"
|
|
|
|
+ >添加规则</el-button
|
|
|
|
+ >
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label=" " style="margin-top: 40px">
|
|
|
|
+ <el-button type="primary" @click="submitForm">下一步</el-button>
|
|
|
|
+ </el-form-item></template
|
|
|
|
+ >
|
|
|
|
+ <template v-else>
|
|
|
|
+ <el-form-item label="商品配置">
|
|
|
|
+ <Config-table></Config-table>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label=" " style="margin-top: 40px">
|
|
|
|
+ <el-button type="primary" @click="submitForm">保存</el-button>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </template>
|
|
|
|
+ </el-form>
|
|
|
|
+ </div>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script>
|
|
|
|
+import SpecBox from "./compoent/SpecBox.vue";
|
|
|
|
+import ConfigTable from "./compoent/configTable.vue";
|
|
|
|
+import { addSpec } from "@/api/resource/good";
|
|
|
|
+export default {
|
|
|
|
+ data() {
|
|
|
|
+ var checkList = (rule, value, callback) => {
|
|
|
|
+ if (!this.ruleForm.specList.length) {
|
|
|
|
+ callback(new Error("请先添加规则"));
|
|
|
|
+ } else {
|
|
|
|
+ callback();
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ return {
|
|
|
|
+ ruleForm: {},
|
|
|
|
+ rules: {
|
|
|
|
+ name: [{ required: true, message: "请输入名称", trigger: "blur" }],
|
|
|
|
+ educationTypeId: [
|
|
|
|
+ { required: true, message: "请选择教育类型", trigger: "change" },
|
|
|
|
+ ],
|
|
|
|
+ businessId: [
|
|
|
|
+ { required: true, message: "请选择业务层次", trigger: "change" },
|
|
|
|
+ ],
|
|
|
|
+ specList: [{ validator: checkList }],
|
|
|
|
+ },
|
|
|
|
+ isNext: true,
|
|
|
|
+ eduTypeOptions: [],
|
|
|
|
+ newCourTypeOptions: [],
|
|
|
|
+ };
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ changeEduType() {
|
|
|
|
+ this.ruleForm.businessId = undefined;
|
|
|
|
+ this.newCourTypeOptions = [];
|
|
|
|
+ this.$api
|
|
|
|
+ .inquirebusinessList({
|
|
|
|
+ status: 1,
|
|
|
|
+ educationId: this.ruleForm.educationTypeId,
|
|
|
|
+ })
|
|
|
|
+ .then((res) => {
|
|
|
|
+ this.newCourTypeOptions = res.rows;
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ resetFrom() {
|
|
|
|
+ this.ruleForm = {
|
|
|
|
+ educationTypeId: undefined,
|
|
|
|
+ businessId: undefined,
|
|
|
|
+ specTemplateId: "123",
|
|
|
|
+ name: "",
|
|
|
|
+ specList: [],
|
|
|
|
+ };
|
|
|
|
+ this.addSpec();
|
|
|
|
+ },
|
|
|
|
+ addSpec() {
|
|
|
|
+ this.ruleForm.specList.push({
|
|
|
|
+ name: "",
|
|
|
|
+ specAttrList: [{ name: "", sort: undefined }],
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ submitForm() {
|
|
|
|
+ this.checkSpecBox() &&
|
|
|
|
+ addSpec(this.ruleForm).then((res) => {
|
|
|
|
+ this.ruleForm.specTemplateId = res.data.specTemplateId;
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ checkSpecBox() {
|
|
|
|
+ let boxs = [this, ...this.$refs.specBox];
|
|
|
|
+ let result = true;
|
|
|
|
+ for (const box of boxs) {
|
|
|
|
+ box.$refs["ruleForm"].validate((valid) => {
|
|
|
|
+ if (!valid) result = false;
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ computed: {
|
|
|
|
+ stId() {
|
|
|
|
+ return this.ruleForm.specTemplateId;
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ created() {
|
|
|
|
+ this.resetFrom();
|
|
|
|
+ this.$api.inquireCourseEducationType({ status: 1 }).then((res) => {
|
|
|
|
+ this.eduTypeOptions = res.rows;
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ components: {
|
|
|
|
+ SpecBox,
|
|
|
|
+ ConfigTable,
|
|
|
|
+ },
|
|
|
|
+};
|
|
|
|
+</script>
|
|
|
|
+
|
|
|
|
+<style lang="scss" scoped>
|
|
|
|
+#specAdd {
|
|
|
|
+ padding-top: 30px;
|
|
|
|
+ .el-form {
|
|
|
|
+ /deep/ {
|
|
|
|
+ .el-input__inner {
|
|
|
|
+ width: 220px;
|
|
|
|
+ }
|
|
|
|
+ .eee {
|
|
|
|
+ .el-form-item__content {
|
|
|
|
+ background: #eee;
|
|
|
|
+ min-height: 60px;
|
|
|
|
+ // padding-bottom: 10px;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+</style>
|