|
@@ -14,7 +14,7 @@ const mixin = {
|
|
|
value: 1,
|
|
|
label: '上架'
|
|
|
}, {
|
|
|
- value: 2,
|
|
|
+ value: 4,
|
|
|
label: '下架'
|
|
|
}]
|
|
|
}
|
|
@@ -142,9 +142,37 @@ import {
|
|
|
} from '@/api/service/musicPackage'
|
|
|
const detailMixin = {
|
|
|
data() {
|
|
|
+ let checkedPrice = (rule, value, callback) => {
|
|
|
+ if (Number(value) > 500) {
|
|
|
+ callback(new Error('原价不得超过500'))
|
|
|
+ } else {
|
|
|
+ if (this.form.discount !== undefined) {
|
|
|
+ this.$refs.form.validateField('discount')
|
|
|
+ }
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let checkedDiscount = (rule, value, callback) => {
|
|
|
+ if (Number(value) > Number(this.form.price)) {
|
|
|
+ callback(new Error('活动价不得大于原价!'))
|
|
|
+ } else {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+ }
|
|
|
return {
|
|
|
// 关联设备
|
|
|
- deviceIds: []
|
|
|
+ deviceIds: [],
|
|
|
+ // 校验
|
|
|
+ rules: {
|
|
|
+ price: [{
|
|
|
+ validator: checkedPrice,
|
|
|
+ trigger: 'blur'
|
|
|
+ }],
|
|
|
+ discount: [{
|
|
|
+ validator: checkedDiscount,
|
|
|
+ trigger: 'blur'
|
|
|
+ }]
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
@@ -170,21 +198,27 @@ const detailMixin = {
|
|
|
},
|
|
|
// 提交
|
|
|
getSubmit() {
|
|
|
- if (this.form.id) {
|
|
|
- edit(this.form).then(res => {
|
|
|
- if (res.code === 0) {
|
|
|
- this.$message.success('修改成功!')
|
|
|
- this.cancel()
|
|
|
- }
|
|
|
- })
|
|
|
- } else {
|
|
|
- create(this.form).then(res => {
|
|
|
- if (res.code === 0) {
|
|
|
- this.$message.success('新增成功!')
|
|
|
- this.cancel()
|
|
|
+ this.$refs.form.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ if (this.form.id) {
|
|
|
+ edit(this.form).then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ this.$message.success('修改成功!')
|
|
|
+ this.cancel()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ create(this.form).then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ this.$message.success('新增成功!')
|
|
|
+ this.cancel()
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
- })
|
|
|
- }
|
|
|
+ } else {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|