mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-05 07:28:37 +08:00
feat: Add duplicate name judgment and null value judgment
调整部分样式,并给下载器、媒体服务器、自定义规则、优先级规则组,名称与ID增加重名警告和空值警告,
This commit is contained in:
@@ -1,15 +1,25 @@
|
||||
<script lang="ts" setup>
|
||||
import { CustomRule } from '@/api/types'
|
||||
import { useToast } from 'vue-toast-notification'
|
||||
import filter_svg from '@images/svg/filter.svg'
|
||||
|
||||
// 输入参数
|
||||
const props = defineProps({
|
||||
// 单条规则
|
||||
rule: {
|
||||
type: Object as PropType<CustomRule>,
|
||||
required: true,
|
||||
},
|
||||
// 所有规则
|
||||
rules: {
|
||||
type: Array as PropType<CustomRule[]>,
|
||||
required: true,
|
||||
},
|
||||
})
|
||||
|
||||
// 提示框
|
||||
const $toast = useToast()
|
||||
|
||||
// 定义触发的自定义事件
|
||||
const emit = defineEmits(['close', 'change'])
|
||||
|
||||
@@ -43,6 +53,30 @@ function openRuleInfoDialog() {
|
||||
|
||||
// 保存详情数据
|
||||
function saveRuleInfo() {
|
||||
// 有空值
|
||||
if (!ruleId.value && !ruleName.value) {
|
||||
if (!ruleId.value && ruleName.value) {
|
||||
$toast.error('规则ID不能为空')
|
||||
}
|
||||
if (ruleId.value && !ruleName.value) {
|
||||
$toast.error('规则名称不能为空')
|
||||
}
|
||||
if (!ruleId.value && !ruleName.value){
|
||||
$toast.error('规则ID和规则名称不能为空')
|
||||
}
|
||||
return
|
||||
}
|
||||
// ID已存在
|
||||
if (ruleId.value !== props.rule.id && props.rules.find((rule) => rule.id === ruleId.value)) {
|
||||
$toast.error(`规则ID【${ruleId.value}】已存在,请替换`)
|
||||
return
|
||||
}
|
||||
// 规则名称已存在
|
||||
if (ruleName.value !== props.rule.name && props.rules.find((rule) => rule.name === ruleName.value)) {
|
||||
$toast.error(`规则名称【${ruleName.value}】已存在,请替换`)
|
||||
return
|
||||
}
|
||||
// 保存数据
|
||||
ruleInfoDialog.value = false
|
||||
ruleInfo.value.id = ruleId.value
|
||||
ruleInfo.value.name = ruleName.value
|
||||
@@ -78,18 +112,20 @@ function onClose() {
|
||||
<VTextField
|
||||
v-model="ruleId"
|
||||
label="规则ID"
|
||||
placeholder="规则编码"
|
||||
placeholder="必填;不可与其他规则ID重名"
|
||||
hint="字符与数字组合,不能含空格"
|
||||
persistent-hint
|
||||
active
|
||||
/>
|
||||
</VCol>
|
||||
<VCol cols="12" md="6">
|
||||
<VTextField
|
||||
v-model="ruleName"
|
||||
label="规则名称"
|
||||
placeholder="别名"
|
||||
placeholder="必填;不可与其他规则名称重名"
|
||||
hint="使用别名便于区分规则"
|
||||
persistent-hint
|
||||
active
|
||||
/>
|
||||
</VCol>
|
||||
<VCol cols="12">
|
||||
@@ -99,6 +135,7 @@ function onClose() {
|
||||
label="包含"
|
||||
hint="必须包含的关键字或正则表达式,多个值使用|分隔"
|
||||
persistent-hint
|
||||
active
|
||||
/>
|
||||
</VCol>
|
||||
<VCol cols="12">
|
||||
@@ -108,6 +145,7 @@ function onClose() {
|
||||
label="排除"
|
||||
hint="不能包含的关键字或正则表达式,多个值使用|分隔"
|
||||
persistent-hint
|
||||
active
|
||||
/>
|
||||
</VCol>
|
||||
<VCol cols="6">
|
||||
@@ -117,6 +155,7 @@ function onClose() {
|
||||
label="资源体积(MB)"
|
||||
hint="最小资源文件体积或文件体积范围"
|
||||
persistent-hint
|
||||
active
|
||||
/>
|
||||
</VCol>
|
||||
<VCol cols="6">
|
||||
@@ -126,6 +165,7 @@ function onClose() {
|
||||
label="做种人数"
|
||||
hint="最小做种人数或做种人数范围"
|
||||
persistent-hint
|
||||
active
|
||||
/>
|
||||
</VCol>
|
||||
<VCol cols="6">
|
||||
@@ -135,6 +175,7 @@ function onClose() {
|
||||
label="发布时间(分钟)"
|
||||
hint="距离资源发布的最小时间间隔"
|
||||
persistent-hint
|
||||
active
|
||||
/>
|
||||
</VCol>
|
||||
</VRow>
|
||||
|
||||
Reference in New Issue
Block a user