diff --git a/src/views/product/rule/index.vue b/src/views/product/rule/index.vue index c6414ce..18431f6 100644 --- a/src/views/product/rule/index.vue +++ b/src/views/product/rule/index.vue @@ -213,10 +213,10 @@ export default { // 表单校验 rules: { createBy: [ - { required: true, message: "创建人不能为空", trigger: "blur" } + {required: true, message: "创建人不能为空", trigger: "blur"} ], createTime: [ - { required: true, message: "创建时间不能为空", trigger: "blur" } + {required: true, message: "创建时间不能为空", trigger: "blur"} ], }, ruleAddForm: { @@ -231,20 +231,20 @@ export default { this.getList(); }, methods: { - removeRule(index){ + removeRule(index) { this.form.ruleAttrList.splice(index, 1); }, - removeRuleProperty(valueList,index){ + removeRuleProperty(valueList, index) { valueList.splice(index, 1); }, - addRuleProperty(ruleAttr, continuousInput){ - if (this.addRulePropertyValue === null || this.addRulePropertyValue === 0){ - if (!continuousInput){ + addRuleProperty(ruleAttr, continuousInput) { + if (this.addRulePropertyValue === null || this.addRulePropertyValue === 0) { + if (!continuousInput) { ruleAttr.ruleAttrAddStatus = !ruleAttr.ruleAttrAddStatus } return; } - if (ruleAttr.valueList.indexOf(this.addRulePropertyValue) > -1){ + if (ruleAttr.valueList.indexOf(this.addRulePropertyValue) > -1) { this.$message({ message: `规格[${ruleAttr.name}]属性值[${this.addRulePropertyValue}]已经存在`, type: 'warning' @@ -253,20 +253,20 @@ export default { } ruleAttr.valueList.push(this.addRulePropertyValue) this.addRulePropertyValue = null; - if (!continuousInput){ + if (!continuousInput) { ruleAttr.ruleAttrAddStatus = !ruleAttr.ruleAttrAddStatus } }, - ruleAddFormFun(){ + ruleAddFormFun() { - if (this.ruleAddForm.name === null || this.ruleAddForm.name.length === 0){ + if (this.ruleAddForm.name === null || this.ruleAddForm.name.length === 0) { this.$message({ message: '规格名称不可为空', type: 'warning' }); return; } - if (this.ruleAddForm.valueList === null || this.ruleAddForm.valueList.length === 0){ + if (this.ruleAddForm.valueList === null || this.ruleAddForm.valueList.length === 0) { this.$message({ message: '规格属性不可为空', type: 'warning' @@ -274,14 +274,14 @@ export default { return; } let ruleAttr = this.form.ruleAttrList.find(ruleAttr => ruleAttr.name === this.ruleAddForm.name); - if (ruleAttr === undefined){ + if (ruleAttr === undefined) { this.form.ruleAttrList.push({ "name": this.ruleAddForm.name, "valueList": [this.ruleAddForm.valueList], "ruleAttrAddStatus": false }) - }else { - if (ruleAttr.valueList.indexOf(this.ruleAddForm.valueList) > -1){ + } else { + if (ruleAttr.valueList.indexOf(this.ruleAddForm.valueList) > -1) { this.$message({ message: `规格[${this.ruleAddForm.name}]属性值[${this.ruleAddForm.valueList}]已经存在`, type: 'warning' @@ -317,7 +317,7 @@ export default { name: null, status: null, remark: null, - ruleAttrList:[] + ruleAttrList: [] }; this.resetForm("form"); }, @@ -331,73 +331,75 @@ export default { this.resetForm("queryForm"); this.handleQuery(); }, - // 多选框选中数据 - handleSelectionChange(selection) { - this.ids = selection.map(item => item.id) - this.single = selection.length!==1 - this.multiple = !selection.length - }, - /** 新增按钮操作 */ - handleAdd() { - this.reset(); + + // 多选框选中数据 + handleSelectionChange(selection) { + this.ids = selection.map(item => item.id) + this.single = selection.length !== 1 + this.multiple = !selection.length + }, + /** 新增按钮操作 */ + handleAdd() { + this.reset(); + this.open = true; + this.title = "添加商品规格"; + }, + /** 修改按钮操作 */ + handleUpdate(row) { + this.reset(); + const id = row.id || this.ids + getRule(id).then(response => { + this.form = response.data; + this.form.ruleAttrList = response.data.ruleAttrList this.open = true; - this.title = "添加商品规格"; - }, - /** 修改按钮操作 */ - handleUpdate(row) { - this.reset(); - const id = row.id || this.ids - getRule(id).then(response => { - this.form = response.data; - this.form.ruleAttrList=response.data.ruleAttrList - this.open = true; - this.title = "修改商品规格"; - }); - }, - /** - * 修改状态 - */ - handleStateChange(row) { - changeStatus(row).then(response => { - this.$modal.msgSuccess("修改成功"); - }) - }, - /** 提交按钮 */ - submitForm() { - this.$refs["form"].validate(valid => { - if (valid) { - if (this.form.id != null) { - updateRule(this.form).then(response => { - this.$modal.msgSuccess("修改成功"); - this.open = false; - this.getList(); - }); - } else { - addRule(this.form).then(response => { - this.$modal.msgSuccess("新增成功"); - this.open = false; - this.getList(); - }); - } + this.title = "修改商品规格"; + }); + }, + /** + * 修改状态 + */ + handleStateChange(row) { + changeStatus(row).then(response => { + this.$modal.msgSuccess("修改成功"); + }) + }, + /** 提交按钮 */ + submitForm() { + this.$refs["form"].validate(valid => { + if (valid) { + if (this.form.id != null) { + updateRule(this.form).then(response => { + this.$modal.msgSuccess("修改成功"); + this.open = false; + this.getList(); + }); + } else { + addRule(this.form).then(response => { + this.$modal.msgSuccess("新增成功"); + this.open = false; + this.getList(); + }); } - }); - }, - /** 删除按钮操作 */ - handleDelete(row) { - const ids = row.id || this.ids; - this.$modal.confirm('是否确认删除商品规格编号为"' + ids + '"的数据项?').then(function() { - return delRule(ids); - }).then(() => { - this.getList(); - this.$modal.msgSuccess("删除成功"); - }).catch(() => {}); - }, - /** 导出按钮操作 */ - handleExport() { - this.download('product/rule/export', { - ...this.queryParams - }, `rule_${new Date().getTime()}.xlsx`) - } + } + }); + }, + /** 删除按钮操作 */ + handleDelete(row) { + const ids = row.id || this.ids; + this.$modal.confirm('是否确认删除商品规格编号为"' + ids + '"的数据项?').then(function () { + return delRule(ids); + }).then(() => { + this.getList(); + this.$modal.msgSuccess("删除成功"); + }).catch(() => { + }); + }, + /** 导出按钮操作 */ + handleExport() { + this.download('product/rule/export', { + ...this.queryParams + }, `rule_${new Date().getTime()}.xlsx`) } +} };