Commit d936250a by lixiaomin

修改规格

parent 9814bf55
......@@ -12,12 +12,12 @@
<el-checkbox true-label="1" false-label="0" v-model="scope.row.isRecommend"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="名称" width="100" align="center" prop="name">
<el-table-column label="名称" width="120" align="center" prop="name">
<template slot-scope="scope">
<el-input placeholder="名称" v-model="scope.row.name"></el-input>
<el-input placeholder="名称" v-model="scope.row.name" wi></el-input>
</template>
</el-table-column>
<el-table-column label="价格" width="80" align="center" prop="amount">
<el-table-column label="价格" width="120" align="center" prop="amount">
<template slot-scope="scope">
<el-input placeholder="价格" v-model="scope.row.amount"> </el-input>
</template>
......
......@@ -65,7 +65,7 @@
<el-dialog :title="title" :visible.sync="open" width="900px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="名称" prop="name">
<el-input v-model="form.name" placeholder="请输入规格名称" />
<el-input v-model="form.name" placeholder="请输入规格名称" maxlength="100"/>
</el-form-item>
<el-form-item label="必须原料">
<el-switch v-model="form.isNeccessary" :active-value="2" :inactive-value="1">
......@@ -74,6 +74,9 @@
<el-form-item label="选项" prop="specRules">
<SpecsSelect :initData="form.specRules" ref="specsSelect" />
</el-form-item>
<el-form-item label="备注" prop="remarks">
<el-input v-model="form.remarks" type="textarea" placeholder="请输入内容" maxlength="500" show-word-limit/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
......@@ -97,10 +100,9 @@ export default {
components: { SpecsSelect },
data() {
var validateSpecRules = (rule, value, callback) => {
let SpecRulesValue=this.form.specRules;
if (SpecRulesValue.length==0) {
if (value.length==0) {
callback(new Error('请添加选项'));
}else if(SpecRulesValue.length<2){
}else if(value.length<2){
callback(new Error('请最少添加2个选项'));
}else {
callback();
......@@ -242,6 +244,8 @@ export default {
},
/** 提交按钮 */
submitForm() {
let regular = /^[+]{0,1}([0-9]+)$|^[+]{0,1}(\d+\.\d{2})$/ //正数(保留2位小数)
this.$refs["form"].validate((valid) => {
if (valid) {
let specsSelectList = this.$refs.specsSelect.list;
......@@ -251,10 +255,14 @@ export default {
this.$modal.msgSuccess('选项列表中的第' + index + '行名称不能为空');
return;
}
if(specsSelectList[i].amount=="" || specsSelectList[i].amount==0){
this.$modal.msgSuccess('选项列表中的第' + index + '行价格不能为空或0');
if(specsSelectList[i].amount==""){
this.$modal.msgSuccess('选项列表中的第' + index + '行价格不能为空');
}else{
if(!regular.test(specsSelectList[i].amount)){
this.$modal.msgSuccess('选项列表中的第' + index + '行价格不是大于等于0的两位小数');
return;
}
}
if(!specsSelectList[i].isRecommend){
specsSelectList[i].isRecommend = "0";
}
......
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