|
|
@@ -1,9 +1,10 @@
|
|
|
<template>
|
|
|
<Base-dialog
|
|
|
- :title="form.id ? '编辑分类' : '添加分类'"
|
|
|
+ :title="categoryId ? '编辑分类' : '添加分类'"
|
|
|
:isShow.sync="isShow"
|
|
|
@close="close"
|
|
|
- :isShowFooter="false"
|
|
|
+ @open="open"
|
|
|
+ @submit="submitForm"
|
|
|
width="450px"
|
|
|
>
|
|
|
<el-form
|
|
|
@@ -14,8 +15,24 @@
|
|
|
:rules="rules"
|
|
|
ref="form"
|
|
|
>
|
|
|
+ <el-form-item label="所属店铺:" prop="storeId">
|
|
|
+ <el-select
|
|
|
+ :disabled="categoryId"
|
|
|
+ :style="{ width: '100%' }"
|
|
|
+ v-model="form.storeId"
|
|
|
+ placeholder="请选择所属店铺"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in storeList"
|
|
|
+ :key="item.storeId"
|
|
|
+ :label="item.storeName"
|
|
|
+ :value="item.storeId"
|
|
|
+ ></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
<el-form-item label="上级分类:" prop="parentId">
|
|
|
<el-cascader
|
|
|
+ :disabled="categoryId"
|
|
|
placeholder="请选择上级分类"
|
|
|
:options="computerTree(categorytreeList)"
|
|
|
:show-all-levels="false"
|
|
|
@@ -28,41 +45,53 @@
|
|
|
v-model="form.parentId"
|
|
|
></el-cascader>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="分类名称:" prop="userName">
|
|
|
- <el-input v-model.Number="form.userName" placeholder="请输入提现金额">
|
|
|
+ <el-form-item label="分类名称:" prop="categoryName">
|
|
|
+ <el-input
|
|
|
+ v-model.Number="form.categoryName"
|
|
|
+ placeholder="请输入分类名称"
|
|
|
+ >
|
|
|
</el-input>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="状态:" prop="status">
|
|
|
- <el-radio-group v-model="formData.status">
|
|
|
+ <el-radio-group v-model="form.status">
|
|
|
<el-radio :label="1">启用</el-radio
|
|
|
><el-radio :label="0">禁用</el-radio>
|
|
|
</el-radio-group>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
- <div class="btns clearfix">
|
|
|
- <el-button @click="visible = false">取消</el-button>
|
|
|
- <el-button type="primary" @click="submitForm">启用</el-button>
|
|
|
- <el-button type="info">保存</el-button>
|
|
|
- </div>
|
|
|
</Base-dialog>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import { mapGetters } from "vuex";
|
|
|
+import {
|
|
|
+ goodscategorytree,
|
|
|
+ addCategory,
|
|
|
+ editCategory,
|
|
|
+ getCategoryDetail,
|
|
|
+} from "../../../api/goods/index";
|
|
|
export default {
|
|
|
props: {
|
|
|
dialogVisible: {
|
|
|
type: Boolean,
|
|
|
default: false,
|
|
|
},
|
|
|
+ categoryId: {
|
|
|
+ type: [Number, String],
|
|
|
+ },
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
form: {},
|
|
|
rules: {
|
|
|
- name: [{ required: true, message: "请输入真实姓名", trigger: "blur" }],
|
|
|
+ categoryName: [
|
|
|
+ { required: true, message: "请输入分类名称", trigger: "blur" },
|
|
|
+ ],
|
|
|
parentId: [
|
|
|
- { required: true, message: "请选择启动状态", trigger: "change" },
|
|
|
+ { required: true, message: "请选择上级分类", trigger: "change" },
|
|
|
+ ],
|
|
|
+ storeId: [
|
|
|
+ { required: true, message: "请选择所属店铺", trigger: "change" },
|
|
|
],
|
|
|
},
|
|
|
options: [
|
|
|
@@ -95,36 +124,57 @@ export default {
|
|
|
],
|
|
|
},
|
|
|
],
|
|
|
+ categorytreeList: [],
|
|
|
};
|
|
|
},
|
|
|
methods: {
|
|
|
+ open() {
|
|
|
+ this.resetForm();
|
|
|
+ this.goodscategorytree();
|
|
|
+ this.categoryId && this.getDatail();
|
|
|
+ },
|
|
|
resetForm() {
|
|
|
this.form = {
|
|
|
- id: undefined,
|
|
|
- name: undefined,
|
|
|
+ categoryId: undefined,
|
|
|
+ storeId: undefined,
|
|
|
+ status: 1,
|
|
|
+ categoryName: undefined,
|
|
|
parentId: undefined,
|
|
|
};
|
|
|
this.clearForm("form");
|
|
|
},
|
|
|
+ getDatail() {
|
|
|
+ getCategoryDetail(this.categoryId).then(({ data }) => {
|
|
|
+ Object.keys(this.form).forEach((key) => {
|
|
|
+ this.form[key] = data[key];
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
submitForm() {
|
|
|
this.$refs.form.validate(async (valid) => {
|
|
|
if (valid) {
|
|
|
- withdrawal(this.form).then((res) => {
|
|
|
- if (res.code == 200) {
|
|
|
- this.$message.success("提现申请成功");
|
|
|
+ const fn = this.categoryId ? editCategory : addCategory;
|
|
|
+ fn(this.form)
|
|
|
+ .then((res) => {
|
|
|
+ this.$message.success(this.categoryId ? "修改成功" : "新增成功");
|
|
|
+ this.$emit("search");
|
|
|
this.isShow = false;
|
|
|
- this.$emit("getSellerInfo");
|
|
|
- }
|
|
|
- });
|
|
|
+ })
|
|
|
+ .catch(() => {});
|
|
|
} else {
|
|
|
return false;
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
close() {
|
|
|
- // this.isShow = false;
|
|
|
+ this.resetForm();
|
|
|
this.clearForm("form");
|
|
|
},
|
|
|
+ goodscategorytree() {
|
|
|
+ goodscategorytree({ status: 1 }).then((res) => {
|
|
|
+ this.categorytreeList = res.data;
|
|
|
+ });
|
|
|
+ },
|
|
|
},
|
|
|
computed: {
|
|
|
isShow: {
|
|
|
@@ -142,40 +192,18 @@ export default {
|
|
|
categoryId: 0,
|
|
|
categoryName: "---无---",
|
|
|
},
|
|
|
+ ...rows,
|
|
|
];
|
|
|
- if (rows?.length > 0) {
|
|
|
- array.push(
|
|
|
- ...rows.filter((i) => i.storeId === this.formData.storeId)
|
|
|
- );
|
|
|
- }
|
|
|
return array;
|
|
|
};
|
|
|
},
|
|
|
- ...mapGetters(["roleList"]),
|
|
|
+ ...mapGetters(["storeList"]),
|
|
|
},
|
|
|
- created() {},
|
|
|
components: {},
|
|
|
- watch: {
|
|
|
- dialogVisible: {
|
|
|
- handler(val) {
|
|
|
- if (val) {
|
|
|
- this.resetForm();
|
|
|
- }
|
|
|
- },
|
|
|
- immediate: true,
|
|
|
- },
|
|
|
- },
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
-.btns {
|
|
|
- .el-button {
|
|
|
- margin-top: 20px;
|
|
|
- float: right;
|
|
|
- margin-left: 14px;
|
|
|
- }
|
|
|
-}
|
|
|
/deep/ {
|
|
|
.el-cascader {
|
|
|
width: 100%;
|