|
@@ -53,6 +53,15 @@
|
|
<script>
|
|
<script>
|
|
import { getItem, saveItem } from '@/api/base/banner';
|
|
import { getItem, saveItem } from '@/api/base/banner';
|
|
|
|
|
|
|
|
+const checkUrl = value => {
|
|
|
|
+ const pattern = /http[s]{0,1}:\/\/([\w.]+\/?)\S*/;
|
|
|
|
+ if (pattern.test(value)) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ this.$error('请以http://或者https://');
|
|
|
|
+ return false;
|
|
|
|
+};
|
|
|
|
+
|
|
export default {
|
|
export default {
|
|
name: 'BannerItemModal',
|
|
name: 'BannerItemModal',
|
|
|
|
|
|
@@ -64,14 +73,6 @@ export default {
|
|
},
|
|
},
|
|
|
|
|
|
data() {
|
|
data() {
|
|
- const checkUrl = (rule, value, callback) => {
|
|
|
|
- const pattern = /http[s]{0,1}:\/\/([\w.]+\/?)\S*/;
|
|
|
|
- if (pattern.test(value)) {
|
|
|
|
- callback();
|
|
|
|
- }
|
|
|
|
- callback(new Error('请以http://或者https://'));
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
return {
|
|
return {
|
|
modal: true,
|
|
modal: true,
|
|
|
|
|
|
@@ -95,11 +96,11 @@ export default {
|
|
message: '请上传图片',
|
|
message: '请上传图片',
|
|
trigger: 'change'
|
|
trigger: 'change'
|
|
}
|
|
}
|
|
- ],
|
|
|
|
- link: [
|
|
|
|
- { required: true, message: '请输入链接地址', trigger: 'change' },
|
|
|
|
- { validator: checkUrl, trigger: 'blur' }
|
|
|
|
]
|
|
]
|
|
|
|
+ // link: [
|
|
|
|
+ // { required: true, message: '请输入链接地址', trigger: 'change' },
|
|
|
|
+ // { validator: checkUrl, trigger: 'blur' }
|
|
|
|
+ // ]
|
|
},
|
|
},
|
|
|
|
|
|
typeOptions: []
|
|
typeOptions: []
|
|
@@ -146,14 +147,16 @@ export default {
|
|
handleConfirm() {
|
|
handleConfirm() {
|
|
this.$refs.form.validate(async valid => {
|
|
this.$refs.form.validate(async valid => {
|
|
if (valid) {
|
|
if (valid) {
|
|
- let params = Object.assign({}, this.form);
|
|
|
|
- params.imgUrl = this.form.imgUrl[0].url;
|
|
|
|
- if (this.id) params.id = this.id;
|
|
|
|
- const { success, msg } = await saveItem(params);
|
|
|
|
- if (success) {
|
|
|
|
- this.$success('保存成功!');
|
|
|
|
- this.modal = false;
|
|
|
|
- this.$g_emit('banner_reload');
|
|
|
|
|
|
+ if (checkUrl(this.form.link)) {
|
|
|
|
+ let params = Object.assign({}, this.form);
|
|
|
|
+ params.imgUrl = this.form.imgUrl[0].url;
|
|
|
|
+ if (this.id) params.id = this.id;
|
|
|
|
+ const { success, msg } = await saveItem(params);
|
|
|
|
+ if (success) {
|
|
|
|
+ this.$success('保存成功!');
|
|
|
|
+ this.modal = false;
|
|
|
|
+ this.$g_emit('banner_reload');
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|