123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- <script setup lang="ts">
- import { ref } from 'vue';
- import SvgIcon from '@/components/SvgIcon.vue';
- import { t } from '@/i18n';
- import type { FormInstance, Rule } from 'ant-design-vue/es/form';
- import type { TemperatureRange } from '@/types';
- interface Props {
- index: number;
- form: TemperatureRange;
- }
- const formRef = ref<FormInstance>();
- const emit = defineEmits(['deleteClick', 'addClick']);
- const props = defineProps<Props>();
- const rules: Record<string, Rule[]> = {
- time: [{ required: true, message: t('common.cannotEmpty'), trigger: 'change' }],
- lower: [{ required: true, message: t('common.cannotEmpty'), trigger: 'change' }],
- upper: [{ required: true, message: t('common.cannotEmpty'), trigger: 'change' }],
- };
- const deleteInterval = () => {
- emit('deleteClick', props.index);
- };
- const formResetFields = () => {
- formRef.value?.resetFields();
- };
- const formRefSubmit = () => {
- return formRef.value?.validate() || Promise.resolve();
- };
- defineExpose({
- formRefSubmit,
- formResetFields,
- });
- </script>
- <template>
- <div>
- <AFlex align="center">
- <div class="set-content">
- <AForm ref="formRef" :model="form" :rules="rules">
- <AFlex justify="space-between">
- <AFormItem name="time">
- <AFlex align="center" class="div-top">
- <div class="time-text">{{ $t('algorithmManage.periodTime') }}</div>
- <ATimeRangePicker
- v-model:value="form.time"
- class="time-width"
- format="HH:mm"
- :separator="$t('common.to')"
- show-time
- />
- </AFlex>
- </AFormItem>
- <AFlex align="center">
- <div class="time-text">{{ $t('algorithmManage.temperatureRange') }}</div>
- <AFlex class="temperature-style" align="center">
- <AFormItem name="lower" class="input-padding">
- <AInputNumber
- class="input-width"
- v-model:value="form.lower"
- :bordered="false"
- :min="-99"
- :max="999"
- :placeholder="t('common.pleaseEnter')"
- />
- </AFormItem>
- <div>{{ $t('common.to') }}</div>
- <AFormItem name="upper">
- <AInputNumber
- class="input-number"
- v-model:value="form.upper"
- addon-after="℃"
- :bordered="false"
- :min="-99"
- :max="999"
- :placeholder="t('common.pleaseEnter')"
- />
- </AFormItem>
- </AFlex>
- </AFlex>
- </AFlex>
- </AForm>
- </div>
- <div @click="$emit('addClick')">
- <AFlex justify="center" align="center" class="add-style">
- <SvgIcon name="plus" />
- </AFlex>
- </div>
- <div @click="deleteInterval">
- <AFlex v-if="index !== 0" justify="center" align="center" class="add-style">
- <SvgIcon name="minus" />
- </AFlex>
- </div>
- </AFlex>
- </div>
- </template>
- <style lang="scss" scoped>
- .div-top {
- margin-top: 8px;
- }
- .input-width {
- width: 100px;
- }
- .input-number {
- width: 100px;
- margin-left: 40px;
- }
- :deep(.set-content) {
- .ant-input-number-group .ant-input-number-group-addon {
- background-color: #fff;
- border: 0;
- border-left: 1px solid #d9d9d9;
- }
- .ant-form-item .ant-form-item-control-input {
- margin-top: -4px;
- }
- }
- :deep(.input-padding) {
- .ant-input-number .ant-input-number-input {
- padding-left: 40px;
- }
- }
- .temperature-style {
- width: 256px;
- height: 32px;
- background: #fff;
- border: 1px solid rgb(0 0 0 / 15%);
- border-radius: 4px;
- }
- .add-style {
- width: 24px;
- height: 24px;
- margin-right: 8px;
- cursor: pointer;
- background: #fff;
- border: 1px solid #d9d9d9;
- border-radius: 4px;
- }
- .time-width {
- width: 256px;
- }
- .time-text {
- margin-right: 12px;
- font-size: 14px;
- font-style: normal;
- font-weight: 400;
- line-height: 22px;
- color: #666;
- text-align: left;
- }
- .set-content {
- width: 706px;
- height: 64px;
- padding: 16px;
- margin-right: 12px;
- margin-bottom: 8px;
- background: #f5f7fa;
- border-radius: 4px;
- }
- </style>
|