|
@@ -11,8 +11,8 @@
|
|
element-loading-text="拼命加载中"
|
|
element-loading-text="拼命加载中"
|
|
element-loading-spinner="el-icon-loading"
|
|
element-loading-spinner="el-icon-loading"
|
|
element-loading-background="rgba(0, 0, 0, 0.8)"
|
|
element-loading-background="rgba(0, 0, 0, 0.8)"
|
|
- append-to-body
|
|
|
|
@close="showModelThis = false"
|
|
@close="showModelThis = false"
|
|
|
|
+ append-to-body
|
|
>
|
|
>
|
|
<el-card style="margin: -20px 0 0 0">
|
|
<el-card style="margin: -20px 0 0 0">
|
|
<el-row :gutter="10">
|
|
<el-row :gutter="10">
|
|
@@ -31,32 +31,36 @@
|
|
:value="ruleForm.specid"
|
|
:value="ruleForm.specid"
|
|
:disabled="sitem.isMust"
|
|
:disabled="sitem.isMust"
|
|
:size="'mini'"
|
|
:size="'mini'"
|
|
- :is-detail="false"
|
|
|
|
|
|
+ :isDetail="false"
|
|
:placeholder="'规格类型'"
|
|
:placeholder="'规格类型'"
|
|
@searchChange="specidsearchChange"
|
|
@searchChange="specidsearchChange"
|
|
/>
|
|
/>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
<el-form-item label="规格值" prop="spec_value_id">
|
|
<el-form-item label="规格值" prop="spec_value_id">
|
|
<div v-if="specVlist.length > 0">
|
|
<div v-if="specVlist.length > 0">
|
|
- <el-radio-group
|
|
|
|
|
|
+ <el-select
|
|
|
|
+ placeholder="请选择规格值"
|
|
v-model="ruleForm.spec_value_id"
|
|
v-model="ruleForm.spec_value_id"
|
|
@change="spec_value_id_change"
|
|
@change="spec_value_id_change"
|
|
|
|
+ style="width: 100%"
|
|
|
|
+ filterable
|
|
>
|
|
>
|
|
- <el-radio
|
|
|
|
|
|
+ <el-option
|
|
v-for="item in specVlist"
|
|
v-for="item in specVlist"
|
|
:key="item.id + item.spec_value"
|
|
:key="item.id + item.spec_value"
|
|
- :label="item.id"
|
|
|
|
- >{{ item.spec_value }}</el-radio>
|
|
|
|
- </el-radio-group>
|
|
|
|
|
|
+ :label="item.spec_value"
|
|
|
|
+ :value="item.id"
|
|
|
|
+ >{{ item.spec_value }}</el-option>
|
|
|
|
+ </el-select>
|
|
</div>
|
|
</div>
|
|
- <div v-else class="no-data">暂无规格值,请添加!</div>
|
|
|
|
|
|
+ <div class="no-data" v-else>暂无规格值,请添加!</div>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
</el-form>
|
|
</el-form>
|
|
</el-col>
|
|
</el-col>
|
|
<el-col :span="24" style="text-align: right">
|
|
<el-col :span="24" style="text-align: right">
|
|
<el-input
|
|
<el-input
|
|
- v-model="sinput"
|
|
|
|
style="width: 209px"
|
|
style="width: 209px"
|
|
|
|
+ v-model="sinput"
|
|
class="fl"
|
|
class="fl"
|
|
:disabled="id == 'edit'"
|
|
:disabled="id == 'edit'"
|
|
:size="'small'"
|
|
:size="'small'"
|
|
@@ -67,36 +71,32 @@
|
|
style="margin: 0 0 0 10px"
|
|
style="margin: 0 0 0 10px"
|
|
icon="el-icon-plus"
|
|
icon="el-icon-plus"
|
|
:size="'small'"
|
|
:size="'small'"
|
|
- class="fl"
|
|
|
|
@click="add_spec"
|
|
@click="add_spec"
|
|
|
|
+ class="fl"
|
|
>新增规格值</el-button>
|
|
>新增规格值</el-button>
|
|
- <el-button
|
|
|
|
- v-if="id !== 'edit'"
|
|
|
|
- :size="'small'"
|
|
|
|
- type="primary"
|
|
|
|
- @click="submitForm"
|
|
|
|
- >保 存
|
|
|
|
- </el-button>
|
|
|
|
- <el-button :size="'small'" @click="showModelThis = false">{{
|
|
|
|
|
|
+ <el-button v-if="id !== 'edit'" :size="'small'" type="primary" @click="submitForm">保 存</el-button>
|
|
|
|
+ <el-button @click="showModelThis = false" :size="'small'">
|
|
|
|
+ {{
|
|
id == "edit" ? "关 闭" : "取 消"
|
|
id == "edit" ? "关 闭" : "取 消"
|
|
- }}</el-button>
|
|
|
|
|
|
+ }}
|
|
|
|
+ </el-button>
|
|
</el-col>
|
|
</el-col>
|
|
</el-row>
|
|
</el-row>
|
|
</el-card>
|
|
</el-card>
|
|
</el-dialog>
|
|
</el-dialog>
|
|
</template>
|
|
</template>
|
|
<script>
|
|
<script>
|
|
-import asyncRequest from '@/apis/service/goodStore/goodsCost'
|
|
|
|
-import resToken from '@/mixins/resToken'
|
|
|
|
|
|
+import asyncRequest from "@/apis/service/goodStore/goodsCost";
|
|
|
|
+import resToken from "@/mixins/resToken";
|
|
export default {
|
|
export default {
|
|
- name: 'Brand',
|
|
|
|
|
|
+ name: "brand",
|
|
|
|
+ props: ["showModel", "index", "sitem"],
|
|
mixins: [resToken],
|
|
mixins: [resToken],
|
|
- props: ['showModel', 'index', 'sitem'],
|
|
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
loading: false,
|
|
loading: false,
|
|
- title: '商品规格',
|
|
|
|
- sinput: '',
|
|
|
|
|
|
+ title: "商品规格",
|
|
|
|
+ sinput: "",
|
|
showModelThis: this.showModel,
|
|
showModelThis: this.showModel,
|
|
specVlist: [],
|
|
specVlist: [],
|
|
ruleForm: {},
|
|
ruleForm: {},
|
|
@@ -106,140 +106,151 @@ export default {
|
|
specid: [
|
|
specid: [
|
|
{
|
|
{
|
|
required: true,
|
|
required: true,
|
|
- message: '规格类型不能为空',
|
|
|
|
- trigger: 'change'
|
|
|
|
|
|
+ message: "规格类型不能为空",
|
|
|
|
+ trigger: "change"
|
|
}
|
|
}
|
|
],
|
|
],
|
|
- spec_value_id: [{ required: true, message: '请选择规格值', trigger: 'change' }]
|
|
|
|
|
|
+ spec_value_id: [
|
|
|
|
+ { required: true, message: "请选择规格值", trigger: "change" }
|
|
|
|
+ ]
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ };
|
|
},
|
|
},
|
|
watch: {
|
|
watch: {
|
|
showModel: function(val) {
|
|
showModel: function(val) {
|
|
- this.showModelThis = val
|
|
|
|
|
|
+ this.showModelThis = val;
|
|
if (val) {
|
|
if (val) {
|
|
- this.initForm()
|
|
|
|
|
|
+ this.initForm();
|
|
}
|
|
}
|
|
},
|
|
},
|
|
showModelThis(val) {
|
|
showModelThis(val) {
|
|
if (!val) {
|
|
if (!val) {
|
|
- this.$emit('cancel')
|
|
|
|
|
|
+ this.$emit("cancel");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
async initForm() {
|
|
async initForm() {
|
|
- this.loading = true
|
|
|
|
- this.resetFormData()
|
|
|
|
- this.rulesThis = this.rules
|
|
|
|
- if (this.index + '' === '-1') {
|
|
|
|
- this.title = '添加商品规格值'
|
|
|
|
|
|
+ this.loading = true;
|
|
|
|
+ this.resetFormData();
|
|
|
|
+ this.rulesThis = this.rules;
|
|
|
|
+ if (this.index + "" === "-1") {
|
|
|
|
+ this.title = "添加商品规格值";
|
|
} else {
|
|
} else {
|
|
- this.title = '修改商品规格值'
|
|
|
|
|
|
+ this.title = "修改商品规格值";
|
|
}
|
|
}
|
|
- await this.resetForm()
|
|
|
|
- this.loading = false
|
|
|
|
|
|
+ await this.resetForm();
|
|
|
|
+ this.loading = false;
|
|
},
|
|
},
|
|
async resetForm() {
|
|
async resetForm() {
|
|
// 重置
|
|
// 重置
|
|
- await this.$nextTick(async() => {
|
|
|
|
|
|
+ await this.$nextTick(async () => {
|
|
if (this.$refs.ruleForm) {
|
|
if (this.$refs.ruleForm) {
|
|
- this.$refs.ruleForm.resetFields()
|
|
|
|
- this.$refs.ruleForm.clearValidate()
|
|
|
|
- if (this.index + '' !== '-1') {
|
|
|
|
- this.specVlist = []
|
|
|
|
- const { specid, spec_name, spec_value_id, spec_value_name } = this.sitem
|
|
|
|
|
|
+ this.$refs.ruleForm.resetFields();
|
|
|
|
+ this.$refs.ruleForm.clearValidate();
|
|
|
|
+ if (this.index + "" !== "-1") {
|
|
|
|
+ this.specVlist = [];
|
|
|
|
+ const {
|
|
|
|
+ specid,
|
|
|
|
+ spec_name,
|
|
|
|
+ spec_value_id,
|
|
|
|
+ spec_value_name
|
|
|
|
+ } = this.sitem;
|
|
this.ruleForm = {
|
|
this.ruleForm = {
|
|
index: this.index,
|
|
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)
|
|
|
|
|
|
+ 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() {
|
|
resetFormData() {
|
|
- this.specVlist = []
|
|
|
|
|
|
+ this.specVlist = [];
|
|
this.ruleForm = {
|
|
this.ruleForm = {
|
|
- index: '-1',
|
|
|
|
- specid: '',
|
|
|
|
- spec_name: '',
|
|
|
|
- spec_value_id: '',
|
|
|
|
- spec_value_name: ''
|
|
|
|
- }
|
|
|
|
|
|
+ index: "-1",
|
|
|
|
+ specid: "",
|
|
|
|
+ spec_name: "",
|
|
|
|
+ spec_value_id: "",
|
|
|
|
+ spec_value_name: ""
|
|
|
|
+ };
|
|
},
|
|
},
|
|
async add_spec() {
|
|
async add_spec() {
|
|
- const { specid } = this.ruleForm
|
|
|
|
|
|
+ const { specid } = this.ruleForm;
|
|
if (specid) {
|
|
if (specid) {
|
|
if (this.sinput) {
|
|
if (this.sinput) {
|
|
- const res = await asyncRequest.valueadd({
|
|
|
|
|
|
+ const { code, data, message } = await asyncRequest.valueadd({
|
|
spec_id: specid,
|
|
spec_id: specid,
|
|
spec_value: this.sinput
|
|
spec_value: this.sinput
|
|
- })
|
|
|
|
- const { code, data, message } = await this.useResHandle(res, true)
|
|
|
|
|
|
+ });
|
|
if (code === 0) {
|
|
if (code === 0) {
|
|
- await this.getlist()
|
|
|
|
|
|
+ await this.getlist();
|
|
|
|
+ } else if (code >= 100 && code <= 104) {
|
|
|
|
+ await this.logout();
|
|
|
|
+ } else {
|
|
|
|
+ this.$message.warning(message);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- this.$message.warning('请输入规格值!')
|
|
|
|
|
|
+ this.$message.warning("请输入规格值!");
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- this.$message.warning('请选择规格类型!')
|
|
|
|
|
|
+ this.$message.warning("请选择规格类型!");
|
|
}
|
|
}
|
|
},
|
|
},
|
|
async specidsearchChange(e) {
|
|
async specidsearchChange(e) {
|
|
- const { id, spec_name } = e
|
|
|
|
- this.ruleForm.specid = id || ''
|
|
|
|
- this.ruleForm.spec_name = spec_name || ''
|
|
|
|
- this.$refs.ruleForm.validateField('specid')
|
|
|
|
- await this.getlist()
|
|
|
|
|
|
+ const { id, spec_name } = e;
|
|
|
|
+ this.ruleForm.specid = id || "";
|
|
|
|
+ this.ruleForm.spec_name = spec_name || "";
|
|
|
|
+ this.$refs.ruleForm.validateField("specid");
|
|
|
|
+ await this.getlist();
|
|
},
|
|
},
|
|
spec_value_id_change(e) {
|
|
spec_value_id_change(e) {
|
|
if (e) {
|
|
if (e) {
|
|
- const { id, spec_value } = this.specVlist.find((i) => i.id === e)
|
|
|
|
- this.ruleForm.spec_value_id = id || ''
|
|
|
|
- this.ruleForm.spec_value_name = spec_value || ''
|
|
|
|
|
|
+ const { id, spec_value } = this.specVlist.find(i => i.id === e);
|
|
|
|
+ this.ruleForm.spec_value_id = id || "";
|
|
|
|
+ this.ruleForm.spec_value_name = spec_value || "";
|
|
} else {
|
|
} else {
|
|
- this.ruleForm.spec_value_id = ''
|
|
|
|
- this.ruleForm.spec_value_name = ''
|
|
|
|
|
|
+ this.ruleForm.spec_value_id = "";
|
|
|
|
+ this.ruleForm.spec_value_name = "";
|
|
}
|
|
}
|
|
- this.$refs.ruleForm.validateField('spec_value_id')
|
|
|
|
|
|
+ this.$refs.ruleForm.validateField("spec_value_id");
|
|
},
|
|
},
|
|
async getlist() {
|
|
async getlist() {
|
|
- const { specid } = this.ruleForm
|
|
|
|
|
|
+ const { specid } = this.ruleForm;
|
|
if (specid) {
|
|
if (specid) {
|
|
- const res = await asyncRequest.valueall({
|
|
|
|
|
|
+ const { code, data, message } = await asyncRequest.valueall({
|
|
spec_id: specid
|
|
spec_id: specid
|
|
- })
|
|
|
|
- const { code, data, message } = await this.useResHandle(res)
|
|
|
|
|
|
+ });
|
|
if (code === 0) {
|
|
if (code === 0) {
|
|
- this.specVlist = data
|
|
|
|
|
|
+ this.specVlist = data;
|
|
|
|
+ } else if (code >= 100 && code <= 104) {
|
|
|
|
+ await this.logout();
|
|
} else {
|
|
} else {
|
|
- this.specVlist = []
|
|
|
|
|
|
+ this.$message.warning(message);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- this.specVlist = []
|
|
|
|
|
|
+ this.specVlist = [];
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
async submitForm() {
|
|
async submitForm() {
|
|
- await this.$refs.ruleForm.validate(async(valid) => {
|
|
|
|
|
|
+ await this.$refs.ruleForm.validate(async valid => {
|
|
if (valid) {
|
|
if (valid) {
|
|
- this.showModelThis = false
|
|
|
|
- console.log(this.ruleForm)
|
|
|
|
- this.$emit('refresh', this.ruleForm)
|
|
|
|
|
|
+ this.showModelThis = false;
|
|
|
|
+ console.log(this.ruleForm);
|
|
|
|
+ this.$emit("refresh", this.ruleForm);
|
|
} else {
|
|
} else {
|
|
- console.log('error submit!!')
|
|
|
|
- return false
|
|
|
|
|
|
+ console.log("error submit!!");
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
- })
|
|
|
|
|
|
+ });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+};
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|