|
@@ -26,14 +26,14 @@
|
|
|
label-width="80px"
|
|
|
class="demo-ruleForm"
|
|
|
>
|
|
|
- <el-form-item label="规格类型" prop="spec_id">
|
|
|
+ <el-form-item label="规格类型" prop="specid">
|
|
|
<search-spec
|
|
|
- :value="ruleForm.spec_id"
|
|
|
+ :value="ruleForm.specid"
|
|
|
:disabled="false"
|
|
|
:size="'mini'"
|
|
|
:isDetail="false"
|
|
|
:placeholder="'规格类型'"
|
|
|
- @searchChange="spec_idsearchChange"
|
|
|
+ @searchChange="specidsearchChange"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="规格值" prop="spec_value_id">
|
|
@@ -105,7 +105,7 @@ export default {
|
|
|
rulesThis: this.rules,
|
|
|
|
|
|
rules: {
|
|
|
- spec_id: [
|
|
|
+ specid: [
|
|
|
{
|
|
|
required: true,
|
|
|
message: "规格类型不能为空",
|
|
@@ -146,33 +146,43 @@ export default {
|
|
|
},
|
|
|
async resetForm() {
|
|
|
// 重置
|
|
|
- await this.$nextTick(() => {
|
|
|
+ await this.$nextTick(async () => {
|
|
|
if (this.$refs.ruleForm) {
|
|
|
this.$refs.ruleForm.resetFields();
|
|
|
this.$refs.ruleForm.clearValidate();
|
|
|
- this.resetFormData();
|
|
|
+ if (this.index + "" !== "-1") {
|
|
|
+ this.specVlist = [];
|
|
|
+ const { specid, spec_name, spec_value_id, spec_value_name } =
|
|
|
+ this.sitem;
|
|
|
+ this.ruleForm = {
|
|
|
+ index: this.index,
|
|
|
+ specid: specid || "",
|
|
|
+ spec_name: spec_name || "",
|
|
|
+ spec_value_id: spec_value_id || "",
|
|
|
+ spec_value_name: spec_value_name || "",
|
|
|
+ };
|
|
|
+ await this.getlist();
|
|
|
+ console.log(this.ruleForm);
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
resetFormData() {
|
|
|
this.specVlist = [];
|
|
|
- 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 || "",
|
|
|
+ index: "-1",
|
|
|
+ specid: "",
|
|
|
+ spec_name: "",
|
|
|
+ spec_value_id: "",
|
|
|
+ spec_value_name: "",
|
|
|
};
|
|
|
},
|
|
|
async add_spec() {
|
|
|
- const { spec_id } = this.ruleForm;
|
|
|
- if (spec_id) {
|
|
|
+ const { specid } = this.ruleForm;
|
|
|
+ if (specid) {
|
|
|
if (this.sinput) {
|
|
|
const { code, data, message } = await asyncRequest.valueadd({
|
|
|
- spec_id: spec_id,
|
|
|
+ spec_id: specid,
|
|
|
spec_value: this.sinput,
|
|
|
});
|
|
|
if (code === 0) {
|
|
@@ -189,29 +199,29 @@ export default {
|
|
|
this.$message.warning("请选择规格类型!");
|
|
|
}
|
|
|
},
|
|
|
- async spec_idsearchChange(e) {
|
|
|
+ async specidsearchChange(e) {
|
|
|
const { id, spec_name } = e;
|
|
|
- this.ruleForm.spec_id = id || "";
|
|
|
- this.ruleForm.spec_value = spec_name || "";
|
|
|
- this.$refs.ruleForm.validateField("spec_id");
|
|
|
+ this.ruleForm.specid = id || "";
|
|
|
+ this.ruleForm.spec_name = spec_name || "";
|
|
|
+ this.$refs.ruleForm.validateField("specid");
|
|
|
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 || "";
|
|
|
+ this.ruleForm.spec_value_name = spec_value || "";
|
|
|
} else {
|
|
|
this.ruleForm.spec_value_id = "";
|
|
|
- this.ruleForm.spec_value_value = "";
|
|
|
+ this.ruleForm.spec_value_name = "";
|
|
|
}
|
|
|
this.$refs.ruleForm.validateField("spec_value_id");
|
|
|
},
|
|
|
async getlist() {
|
|
|
- const { spec_id } = this.ruleForm;
|
|
|
- if (spec_id) {
|
|
|
+ const { specid } = this.ruleForm;
|
|
|
+ if (specid) {
|
|
|
const { code, data, message } = await asyncRequest.valueall({
|
|
|
- spec_id: spec_id,
|
|
|
+ spec_id: specid,
|
|
|
});
|
|
|
if (code === 0) {
|
|
|
this.specVlist = data;
|
|
@@ -229,6 +239,7 @@ export default {
|
|
|
await this.$refs.ruleForm.validate(async (valid) => {
|
|
|
if (valid) {
|
|
|
this.showModelThis = false;
|
|
|
+ console.log(this.ruleForm);
|
|
|
this.$emit("refresh", this.ruleForm);
|
|
|
} else {
|
|
|
console.log("error submit!!");
|