update: 组件替换自测优化

This commit is contained in:
JiangQiming 2023-03-09 15:16:22 +08:00
parent 56122ac90c
commit 257765cb50
4 changed files with 66 additions and 13 deletions

View File

@ -16,10 +16,11 @@
disabled && myValue === item.value
? 'active-checked-disabled'
: '',
item.disabled ? 'disabled' : '',
]"
v-for="(item, index) in options"
:key="index"
@click="myValue = item.value"
@click="handleRadio(item)"
>
<img v-if="item.logo" class="img" :src="item.logo" alt="" />
<span>{{ item.label }}</span>
@ -86,6 +87,11 @@ const myValue = computed({
}
},
});
const handleRadio = (item: any) => {
if (item.disabled) return;
myValue.value = item.value;
};
</script>
<style lang="less" scoped>
@ -93,6 +99,11 @@ const myValue = computed({
display: flex;
flex-wrap: wrap;
justify-content: space-between;
.disabled {
color: rgba(0, 0, 0, 0.25);
border-color: #f5f5f5;
cursor: not-allowed;
}
&-item {
width: 49%;
height: 70px;

View File

@ -133,22 +133,22 @@ watch(
() => dimension.value,
(val) => {
if (val === 'today') {
dateRange[0] = moment().startOf('day').format('x');
dateRange.value[0] = moment().startOf('day').format('x');
}
if (val === 'week') {
dateRange[0] = moment().subtract(1, 'week').format('x');
dateRange.value[0] = moment().subtract(1, 'week').format('x');
}
if (val === 'month') {
dateRange[0] = moment().subtract(1, 'month').format('x');
dateRange.value[0] = moment().subtract(1, 'month').format('x');
}
if (val === 'year') {
dateRange[0] = moment().subtract(1, 'year').format('x');
dateRange.value[0] = moment().subtract(1, 'year').format('x');
}
dateRange[1] = moment().format('x');
dateRange.value[1] = moment().format('x');
emits('change', {
time: {
start: dateRange[0],
end: dateRange[1],
start: dateRange.value[0],
end: dateRange.value[1],
},
});
},

View File

@ -55,7 +55,22 @@
/>
</j-form-item>
</j-col>
<j-col :span="24">
<j-col :span="24" v-if="route.query.type === 'gb28181-2016'">
<j-form-item
label="厂商"
name="manufacturer"
:rules="[
{ required: false, message: '' },
{ max: 64, message: '最多可输入64个字符' },
]"
>
<j-input
v-model:value="formData.manufacturer"
placeholder="请输入厂商名称"
/>
</j-form-item>
</j-col>
<j-col :span="24" v-if="route.query.type === 'fixed-media'">
<j-form-item
name="media_url"
:rules="[
@ -112,6 +127,21 @@
/>
</j-form-item>
</j-col>
<j-col :span="24" v-if="route.query.type === 'gb28181-2016'">
<j-form-item label="云台类型" name="ptzType">
<j-select
v-model:value="formData.ptzType"
:options="[
{ label: '未知', value: 0 },
{ label: '球体', value: 1 },
{ label: '半球体', value: 2 },
{ label: '固定枪机', value: 3 },
{ label: '遥控枪机', value: 4 },
]"
placeholder="请选择云台类型"
/>
</j-form-item>
</j-col>
<j-col :span="24">
<j-form-item name="description" label="说明">
<j-textarea
@ -163,7 +193,9 @@ const formData = ref({
description: '',
deviceId: route.query.id,
name: '',
// , others
manufacturer: '',
ptzType: '',
// , others
media_password: '',
media_url: '',
media_username: '',
@ -172,6 +204,7 @@ const formData = ref({
watch(
() => props.channelData,
(val: any) => {
console.log('val: ', val);
const {
id,
address,
@ -179,6 +212,8 @@ watch(
description,
deviceId,
name,
manufacturer,
ptzType,
others,
...extra
} = val;
@ -189,6 +224,8 @@ watch(
description,
deviceId,
name,
manufacturer,
ptzType: ptzType?.value || 0,
...others,
};
},
@ -225,6 +262,8 @@ const handleSubmit = () => {
media_url,
media_password,
media_username,
manufacturer,
ptzType,
...extraFormData
} = formData.value;
if (media_url || media_password || media_username) {

View File

@ -294,9 +294,12 @@ const getActions = (
data.state.value === 'notActive' ||
data.provider === 'fixed-media',
icon: 'SyncOutlined',
onClick: () => {
// updateChannel()
console.log('updateChannel: ', data);
onClick: async () => {
const res = await DeviceApi.updateChannels(data.id);
if (res.success) {
message.success('通道更新成功');
listRef.value?.reload();
}
},
},
{