Commit 12e7d0a1 authored by chenjundi's avatar chenjundi

赠品配置验证修复

parent 49752ef7
......@@ -13,7 +13,7 @@
<el-input v-model="form.cost_price"></el-input>
</el-form-item>
<el-form-item label="赠品总数" prop="gift_num">
<el-input v-model="form.gift_num" @change="giftNumChange"></el-input>
<el-input v-model="form.gift_num"></el-input>
</el-form-item>
<el-form-item label="库存数量" prop="stock_num">
<div>{{form.stock_num}}</div>
......@@ -43,8 +43,8 @@
],
data() {
const validGiftNum = (rule, value, callback) => {
if (!/^[\d\/]+$/.test(value)) {
callback(new Error('只能填阿拉伯数字'));
if (!/^[0-9]+$/.test(value)) {
callback(new Error('只能填数字'));
} else {
callback();
}
......@@ -62,7 +62,7 @@
form: {
name: '',
cost_price: '',
gift_num: '/',
gift_num: '',
stock_num: 0,
type: ''
},
......@@ -86,22 +86,15 @@
}
},
methods: {
giftNumChange() {
if (!this.form.gift_num) {
this.form.gift_num = '/';
}
},
sub() {
this.$refs['form'].validate((valid) => {
if (valid) {
let json = {
name: this.form.name,
cost_price: this.form.cost_price,
type: this.form.type
type: this.form.type,
gift_num: this.form.gift_num
};
if (this.form.gift_num != '/') {
json.gift_num = this.form.gift_num;
}
switch (this.dialogObj.type) {
case 0:
giftConfigAddApi(json).then(res => {
......
......@@ -22,7 +22,11 @@
</div>
<div class="table-form">
<el-table :data="dataList" size="mini" style="width: 100%">
<el-table-column prop="id" label="ID"></el-table-column>
<el-table-column prop="id" label="ID">
<template slot-scope="scope">
<span>{{scope.row.id | idFilter}}</span>
</template>
</el-table-column>
<el-table-column prop="name" label="赠品名称"></el-table-column>
<el-table-column prop="gift_type" label="赠品类型">
<template slot-scope="scope">
......@@ -32,7 +36,8 @@
</template>
</el-table-column>
<el-table-column prop="cost_price" label="成本价"></el-table-column>
<el-table-column prop="gift_num" label="赠品总数"></el-table-column>
<el-table-column prop="gift_num" label="赠品总数">
</el-table-column>
<el-table-column prop="stock_num" label="库存数量"></el-table-column>
<el-table-column prop="get_num" label="领取数量"></el-table-column>
<el-table-column prop="status" label="状态">
......@@ -44,7 +49,10 @@
<el-table-column width="150" label="操作">
<template slot-scope="scope">
<el-button type="primary" size="mini" plain @click="edit(scope.row)">编辑</el-button>
<el-button type="warning" size="mini" plain @click="onDown(scope.row)">下架</el-button>
<el-button v-if="scope.row.status == 1" type="warning" size="mini" plain @click="onDown(scope.row)">下架
</el-button>
<el-button v-if="scope.row.status == 2" type="success" size="mini" plain @click="onDown(scope.row)">上架
</el-button>
</template>
</el-table-column>
</el-table>
......@@ -67,6 +75,20 @@
page,
dialogCom
},
filters: {
idFilter(val) {
val = val.toString();
if (val.length == 1) {
return `000${val}`
} else if (val.length == 2) {
return `00${val}`
} else if (val.length == 3) {
return `0${val}`
} else {
return val
}
}
},
data() {
return {
searchFrom: {
......
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