属性组和商品规格的状态的修改

cloud-ui
刘河平 2024-11-15 20:53:15 +08:00
parent b09cb3270e
commit edb3978432
1 changed files with 83 additions and 81 deletions

View File

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