Commit 0a9a8feb by lixiaomin

修改商品

parent a9ccb075
......@@ -14,7 +14,12 @@
<el-table-column label="原料名称" align="center" prop="name" />
<el-table-column label="原料数量" align="center" prop="quantity">
<template slot-scope="scope">
<div style="display: flex;align-items: center;">
<el-input v-model="scope.row.quantity" placeholder="请输入原料数量" />
<div style="margin-left: 5px">
<span> {{scope.row.unit}}</span>
</div>
</div>
</template>
</el-table-column>
</el-table>
......@@ -91,9 +96,18 @@ export default {
this.single = selection.length !== 1;
this.multiple = !selection.length;
},
/** 提交按钮 */
submitForm() {
let subTag=true;
this.ids.map((item) => {
if(!item.quantity){
subTag=false;
let name=item.name;
this.$modal.msgSuccess(''+name+"原料名称的原料数量为空");
return;
}
});
if(subTag){
this.$emit(
"callback",
this.ids.map((item) => {
......@@ -104,6 +118,7 @@ export default {
);
this.$refs.table.clearSelection();
this.open = false;
}
},
},
};
......
......@@ -46,7 +46,11 @@
<!-- <el-table v-loading="loading" :data="materialList" @selection-change="handleSelectionChange"> -->
<!-- <el-table-column type="selection" width="55" align="center" /> -->
<el-table v-loading="loading" :data="materialList" >
<el-table-column label="原料名称" width="150" align="center" prop="name" />
<el-table-column label="原料名称" width="150" align="center" prop="name">
<template slot-scope="scope">
<a @click="handleUpdate(scope.row)" style="color: blue">{{ scope.row.name }}</a>
</template>
</el-table-column>
<el-table-column label="编码" width="150" align="center" prop="code" />
<el-table-column label="计量单位" width="150" align="center" prop="unit" />
<el-table-column label="备注" align="center" prop="remarks" />
......@@ -203,6 +207,16 @@ export default {
this.open = true;
this.title = "添加原料";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids;
getMaterial(id).then((response) => {
this.form = response.data;
this.open = true;
this.title = "修改";
});
},
/** 启用、禁用按钮操作 */
handleStatus(row,tag) {
let mess="";
......
......@@ -3,8 +3,8 @@
<el-table :data="list" :row-key="(row) => row.id">
<el-table-column label="默认" width="50" align="center" prop="isDefault">
<template slot-scope="scope">
<el-checkbox true-label="1" false-label="0" @change="(e) => changeDefault(e, scope.$index)"
v-model="scope.row.isDefault"></el-checkbox>
<el-checkbox @change="(e) => changeDefault(e, scope.$index)"
v-model="scope.row.isDefault" :checked="scope.row.isDefault===1"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="推荐" width="50" align="center" prop="isRecommend">
......@@ -29,8 +29,8 @@
scope.row.specRuleMaterials &&
scope.row.specRuleMaterials.length > 0
">
<span v-for="item in scope.row.specRuleMaterials" :key="item.id">
{{ item.name }}* {{ item.quantity || "" }}
<span v-for="item in scope.row.specRuleMaterials" :key="item.id" style="color:blue">
{{ item.materialName }}* {{ item.quantity || "" }}
</span>
</div>
<el-button v-else type="primary" @click="addMaterial(scope.$index)" size="mini">添加原料
......@@ -78,6 +78,14 @@ export default {
},
handleDelete(index) {
this.list.splice(index, 1);
if(this.list.length>1){
for(let i=0;i<this.list.length;i++){
if(i==0){
this.list[i].isDefault="1";
return;
}
}
}
},
addMaterial(index) {
this.index = index;
......@@ -94,6 +102,19 @@ export default {
amount: "",
specRuleMaterials: [],
});
let p=0;
for(let i=0;i<this.list.length;i++){
if(this.list[i].isDefault=="1"){
p=1;
return;
}
}
//没有选择默认项,默认第一条
if(p==0){
console.log("p2",p)
this.list[0].isDefault="1"
}
},
clearMaterial() {
this.list = [];
......
......@@ -27,7 +27,11 @@
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="specsList">
<el-table-column label="规格名称" width="300" align="center" prop="name" />
<el-table-column label="规格名称" width="300" align="center" prop="name">
<template slot-scope="scope">
<a @click="handleUpdate(scope.row)" style="color: blue">{{ scope.row.name }}</a>
</template>
</el-table-column>
<el-table-column label="规格编码" width="180" align="center" prop="code" />
<el-table-column label="选项" align="center" prop="specRules">
<template slot-scope="scope">
......@@ -67,7 +71,7 @@
<el-switch v-model="form.isNeccessary" :active-value="2" :inactive-value="1">
</el-switch>
</el-form-item>
<el-form-item label="选项" prop="specCode">
<el-form-item label="选项" prop="specRules">
<SpecsSelect :initData="form.specRules" ref="specsSelect" />
</el-form-item>
</el-form>
......@@ -92,6 +96,14 @@ export default {
name: "Specs",
components: { SpecsSelect },
data() {
var validateSpecRules = (rule, value, callback) => {
let SpecRulesValue=this.form.specRules;
if (SpecRulesValue.length==0) {
callback(new Error('请添加选项'));
}else {
callback();
}
};
return {
// 遮罩层
loading: true,
......@@ -125,6 +137,7 @@ export default {
name: [
{ required: true, message: "规格名称不能为空", trigger: "blur" },
],
specRules:[{ required: true, validator: validateSpecRules, trigger: 'blur' }],
},
options: [{
value: null,
......@@ -190,6 +203,16 @@ export default {
this.open = true;
this.title = "添加规格";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids;
getSpecs(id).then((response) => {
this.form = response.data;
this.open = true;
this.title = "修改规格";
});
},
/** 启用、禁用按钮操作 */
handleStatus(row,tag) {
let mess="";
......@@ -212,18 +235,6 @@ export default {
})
.catch(() => { });
},
/** 修改按钮操作 */
// handleUpdate(row) {
// this.reset();
// const id = row.id || this.ids;
// getSpecs(id).then((response) => {
// this.form = response.data;
// this.open = true;
// this.title = "修改规格";
// });
// },
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate((valid) => {
......
......@@ -43,7 +43,7 @@
<el-table v-loading="loading" :data="shopList">
<el-table-column label="店铺名称" align="center" prop="name">
<template slot-scope="scope">
<a @click="openSet(scope.row.id)">{{ scope.row.name }}</a>
<a @click="openSet(scope.row.id)" style="color: blue">{{ scope.row.name }}</a>
</template>
</el-table-column>
<el-table-column label="默认店铺" align="center" prop="isDefault">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment