|
@@ -5,7 +5,7 @@
|
|
|
:center="true"
|
|
|
align="left"
|
|
|
top="18vh"
|
|
|
- width="500px"
|
|
|
+ width="600px"
|
|
|
:close-on-click-modal="false"
|
|
|
:visible.sync="showModelThis"
|
|
|
element-loading-text="拼命加载中"
|
|
@@ -25,45 +25,52 @@
|
|
|
label-width="80px"
|
|
|
class="demo-ruleForm"
|
|
|
>
|
|
|
- <el-form-item label="规格类型" prop="brand_name">
|
|
|
+ <el-form-item label="规格类型" prop="spec_id">
|
|
|
<search-spec
|
|
|
- :value="ruleForm.brand_name"
|
|
|
+ :value="ruleForm.spec_id"
|
|
|
:disabled="false"
|
|
|
:size="'mini'"
|
|
|
:isDetail="false"
|
|
|
:placeholder="'规格类型'"
|
|
|
- @searchChange="brand_namesearchChange"
|
|
|
+ @searchChange="spec_idsearchChange"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="规格值" prop="logo_url">
|
|
|
- <el-radio-group v-model="ruleForm.logo_url">
|
|
|
- <el-radio
|
|
|
- v-for="item in specVlist"
|
|
|
- :key="item.id + item.name"
|
|
|
- :label="item.id"
|
|
|
- >{{ item.name }}</el-radio
|
|
|
+ <el-form-item label="规格值" prop="spec_value_id">
|
|
|
+ <div v-if="specVlist.length > 0">
|
|
|
+ <el-radio-group
|
|
|
+ v-model="ruleForm.spec_value_id"
|
|
|
+ @change="spec_value_id_change"
|
|
|
>
|
|
|
- </el-radio-group>
|
|
|
+ <el-radio
|
|
|
+ v-for="item in specVlist"
|
|
|
+ :key="item.id + item.spec_value"
|
|
|
+ :label="item.id"
|
|
|
+ >{{ item.spec_value }}</el-radio
|
|
|
+ >
|
|
|
+ </el-radio-group>
|
|
|
+ </div>
|
|
|
+ <div class="no-data" v-else>暂无规格值,请添加!</div>
|
|
|
</el-form-item>
|
|
|
- <div style="width: 100%; padding: 0 0 0 80px">
|
|
|
- <el-input
|
|
|
- style="width: 209px"
|
|
|
- v-model="sinput"
|
|
|
- :disabled="id == 'edit'"
|
|
|
- :size="'small'"
|
|
|
- placeholder="规格值名称,如红色"
|
|
|
- maxlength="20"
|
|
|
- />
|
|
|
- <el-button
|
|
|
- style="margin: 0 0 0 10px"
|
|
|
- icon="el-icon-plus"
|
|
|
- :size="'small'"
|
|
|
- >新增规格值</el-button
|
|
|
- >
|
|
|
- </div>
|
|
|
</el-form>
|
|
|
</el-col>
|
|
|
<el-col :span="24" style="text-align: right; padding-top: 18px">
|
|
|
+ <el-input
|
|
|
+ style="width: 209px"
|
|
|
+ v-model="sinput"
|
|
|
+ class="fl"
|
|
|
+ :disabled="id == 'edit'"
|
|
|
+ :size="'small'"
|
|
|
+ placeholder="规格值名称,如红色"
|
|
|
+ maxlength="20"
|
|
|
+ />
|
|
|
+ <el-button
|
|
|
+ style="margin: 0 0 0 10px"
|
|
|
+ icon="el-icon-plus"
|
|
|
+ :size="'small'"
|
|
|
+ @click="add_spec"
|
|
|
+ class="fl"
|
|
|
+ >新增规格值</el-button
|
|
|
+ >
|
|
|
<el-button
|
|
|
v-if="id !== 'edit'"
|
|
|
:size="'small'"
|
|
@@ -80,37 +87,32 @@
|
|
|
</el-dialog>
|
|
|
</template>
|
|
|
<script>
|
|
|
-import asyncRequest from "@/apis/service/goodStore/brand";
|
|
|
+import asyncRequest from "@/apis/service/goodStore/goodsCost";
|
|
|
import resToken from "@/mixins/resToken";
|
|
|
export default {
|
|
|
name: "brand",
|
|
|
- props: ["showModel", "id", "sitem"],
|
|
|
+ props: ["showModel", "index", "sitem"],
|
|
|
mixins: [resToken],
|
|
|
data() {
|
|
|
return {
|
|
|
loading: false,
|
|
|
- title: "",
|
|
|
+ title: "商品规格",
|
|
|
sinput: "",
|
|
|
showModelThis: this.showModel,
|
|
|
- select: "1",
|
|
|
- specVlist: [
|
|
|
- { id: "1", name: "111" },
|
|
|
- { id: "2", name: "222" },
|
|
|
- ],
|
|
|
- activeOptions: [],
|
|
|
- actionList: [],
|
|
|
- ruleForm: {
|
|
|
- id: "",
|
|
|
- brand_name: "",
|
|
|
- logo_url: "",
|
|
|
- },
|
|
|
+ specVlist: [],
|
|
|
+ ruleForm: {},
|
|
|
rulesThis: this.rules,
|
|
|
+
|
|
|
rules: {
|
|
|
- brand_name: [
|
|
|
- { required: true, message: "品牌名称不能为空", trigger: "change" },
|
|
|
+ spec_id: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: "规格类型不能为空",
|
|
|
+ trigger: "change",
|
|
|
+ },
|
|
|
],
|
|
|
- logo_url: [
|
|
|
- { required: true, message: "品牌名称不能为空", trigger: "change" },
|
|
|
+ spec_value_id: [
|
|
|
+ { required: true, message: "请选择规格值", trigger: "change" },
|
|
|
],
|
|
|
},
|
|
|
};
|
|
@@ -131,15 +133,12 @@ export default {
|
|
|
methods: {
|
|
|
async initForm() {
|
|
|
this.loading = true;
|
|
|
- if (this.id === "add") {
|
|
|
- this.title = "添加商品类型";
|
|
|
- this.rulesThis = this.rules;
|
|
|
- } else if (this.id === "005") {
|
|
|
- this.title = "修改商品类型";
|
|
|
- this.rulesThis = this.rules;
|
|
|
+ this.resetFormData();
|
|
|
+ this.rulesThis = this.rules;
|
|
|
+ if (this.index === "0") {
|
|
|
+ this.title = "添加商品规格值";
|
|
|
} else {
|
|
|
- this.title = "品牌商品类型";
|
|
|
- this.rulesThis = {};
|
|
|
+ this.title = "修改商品规格值";
|
|
|
}
|
|
|
await this.resetForm();
|
|
|
this.loading = false;
|
|
@@ -150,100 +149,88 @@ export default {
|
|
|
if (this.$refs.ruleForm) {
|
|
|
this.$refs.ruleForm.resetFields();
|
|
|
this.$refs.ruleForm.clearValidate();
|
|
|
- const { id, brand_name, logo_url } = this.sitem;
|
|
|
- this.ruleForm = {
|
|
|
- id: id || "",
|
|
|
- brand_name: brand_name || "",
|
|
|
- logo_url: logo_url || "",
|
|
|
- };
|
|
|
+ console.log(this.index);
|
|
|
+ console.log(this.sitem);
|
|
|
+ this.resetFormData();
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
-
|
|
|
- brand_namesearchChange(e) {
|
|
|
- const { id, code, label } = e;
|
|
|
- if (id) {
|
|
|
- this.ruleForm.brand_name = code;
|
|
|
+ resetFormData() {
|
|
|
+ const { id, spec_id, spec_value, spec_value_id, spec_value_value } =
|
|
|
+ this.sitem;
|
|
|
+ this.ruleForm = {
|
|
|
+ index: this.index,
|
|
|
+ id: id || "",
|
|
|
+ spec_id: spec_id || "",
|
|
|
+ spec_value: spec_value || "",
|
|
|
+ spec_value_id: spec_value_id || "",
|
|
|
+ spec_value_value: spec_value_value || "",
|
|
|
+ };
|
|
|
+ },
|
|
|
+ async add_spec() {
|
|
|
+ const { spec_id } = this.ruleForm;
|
|
|
+ if (spec_id) {
|
|
|
+ if (this.sinput) {
|
|
|
+ const { code, data, message } = await asyncRequest.valueadd({
|
|
|
+ spec_id: spec_id,
|
|
|
+ spec_value: this.sinput,
|
|
|
+ });
|
|
|
+ if (code === 0) {
|
|
|
+ await this.getlist();
|
|
|
+ } else if (code >= 100 && code <= 104) {
|
|
|
+ await this.logout();
|
|
|
+ } else {
|
|
|
+ this.$message.warning(message);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.$message.warning("请输入规格值!");
|
|
|
+ }
|
|
|
} else {
|
|
|
- this.ruleForm.brand_name = "";
|
|
|
+ this.$message.warning("请选择规格类型!");
|
|
|
}
|
|
|
- this.$refs.ruleForm.validateField("brand_name");
|
|
|
- this.getlist();
|
|
|
},
|
|
|
- async getlist() {
|
|
|
- const { brand_name } = this.ruleForm;
|
|
|
- const { code, data, message } = await asyncRequest.list({
|
|
|
- brand_name: brand_name,
|
|
|
- });
|
|
|
- if (code === 0) {
|
|
|
- this.options = data;
|
|
|
- } else if (code >= 100 && code <= 104) {
|
|
|
- await this.logout();
|
|
|
+ async spec_idsearchChange(e) {
|
|
|
+ const { id, spec_name } = e;
|
|
|
+ this.ruleForm.spec_id = id || "";
|
|
|
+ this.ruleForm.spec_value = spec_name || "";
|
|
|
+ this.$refs.ruleForm.validateField("spec_id");
|
|
|
+ await this.getlist();
|
|
|
+ },
|
|
|
+ spec_value_id_change(e) {
|
|
|
+ if (e) {
|
|
|
+ const { id, spec_value } = this.specVlist.find((i) => i.id === e);
|
|
|
+ this.ruleForm.spec_value_id = id || "";
|
|
|
+ this.ruleForm.spec_value_value = spec_value || "";
|
|
|
} else {
|
|
|
- this.$message.warning(message);
|
|
|
+ this.ruleForm.spec_value_id = "";
|
|
|
+ this.ruleForm.spec_value_value = "";
|
|
|
}
|
|
|
+ this.$refs.ruleForm.validateField("spec_value_id");
|
|
|
},
|
|
|
-
|
|
|
- async submitForm() {
|
|
|
- await this.$refs.ruleForm.validate(async (valid) => {
|
|
|
- if (valid) {
|
|
|
- this.loading = true;
|
|
|
- let model = JSON.parse(JSON.stringify(this.ruleForm));
|
|
|
- let res = {};
|
|
|
- if (this.id === "003") {
|
|
|
- delete model["id"];
|
|
|
- res = await asyncRequest.add(model);
|
|
|
- } else {
|
|
|
- res = await asyncRequest.update(model);
|
|
|
- }
|
|
|
- this.loading = false;
|
|
|
- if (res && res.code === 0) {
|
|
|
- const title = this.id === "add" ? "添加成功!" : "修改成功!";
|
|
|
- this.$notify.success({
|
|
|
- title,
|
|
|
- message: "",
|
|
|
- });
|
|
|
- this.showModelThis = false;
|
|
|
- // 刷新
|
|
|
- this.$emit("refresh");
|
|
|
- } else if (res && res.code >= 100 && res.code <= 104) {
|
|
|
- await this.logout();
|
|
|
- } else {
|
|
|
- this.$message.warning(res.message);
|
|
|
- }
|
|
|
+ async getlist() {
|
|
|
+ const { spec_id } = this.ruleForm;
|
|
|
+ if (spec_id) {
|
|
|
+ const { code, data, message } = await asyncRequest.valueall({
|
|
|
+ spec_id: spec_id,
|
|
|
+ });
|
|
|
+ if (code === 0) {
|
|
|
+ this.specVlist = data;
|
|
|
+ } else if (code >= 100 && code <= 104) {
|
|
|
+ await this.logout();
|
|
|
} else {
|
|
|
- console.log("error submit!!");
|
|
|
- return false;
|
|
|
+ this.$message.warning(message);
|
|
|
}
|
|
|
- });
|
|
|
+ } else {
|
|
|
+ this.specVlist = [];
|
|
|
+ }
|
|
|
},
|
|
|
- async submitForm1() {
|
|
|
+
|
|
|
+ async submitForm() {
|
|
|
await this.$refs.ruleForm.validate(async (valid) => {
|
|
|
if (valid) {
|
|
|
this.loading = true;
|
|
|
- let model = JSON.parse(JSON.stringify(this.ruleForm));
|
|
|
- let res = {};
|
|
|
- if (this.id === "003") {
|
|
|
- delete model["id"];
|
|
|
- res = await asyncRequest.add(model);
|
|
|
- } else {
|
|
|
- res = await asyncRequest.update(model);
|
|
|
- }
|
|
|
+ this.$emit("refresh", this.ruleForm);
|
|
|
this.loading = false;
|
|
|
- if (res && res.code === 0) {
|
|
|
- const title = this.id === "add" ? "添加成功!" : "修改成功!";
|
|
|
- this.$notify.success({
|
|
|
- title,
|
|
|
- message: "",
|
|
|
- });
|
|
|
- this.showModelThis = false;
|
|
|
- // 刷新
|
|
|
- this.$emit("refresh");
|
|
|
- } else if (res && res.code >= 100 && res.code <= 104) {
|
|
|
- await this.logout();
|
|
|
- } else {
|
|
|
- this.$message.warning(res.message);
|
|
|
- }
|
|
|
} else {
|
|
|
console.log("error submit!!");
|
|
|
return false;
|
|
@@ -255,6 +242,13 @@ export default {
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
-.brand {
|
|
|
+.goodsCostAdd {
|
|
|
+ .no-data {
|
|
|
+ text-align: center;
|
|
|
+ line-height: 32px;
|
|
|
+ color: #8492a6;
|
|
|
+ // border: 1px solid #ccc;
|
|
|
+ border-radius: 6px;
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|