|
|
@ -30,7 +30,7 @@ |
|
|
|
<el-col :span="12"> |
|
|
|
<el-form-item label="设置时间" prop="time"> |
|
|
|
<!-- <el-input v-model="data.time"></el-input> --> |
|
|
|
<el-date-picker v-model="data.time" type="datetime" placeholder="设置时间"> </el-date-picker> |
|
|
|
<el-date-picker v-model="data.time" type="datetime" placeholder="设置时间"></el-date-picker> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="12"> |
|
|
@ -134,9 +134,12 @@ |
|
|
|
</template> |
|
|
|
|
|
|
|
<script setup> |
|
|
|
import { reactive, ref } from 'vue'; |
|
|
|
import { ref } from 'vue'; |
|
|
|
import { ElMessage } from 'element-plus'; |
|
|
|
import { cloneDeep, isDate } from 'lodash'; |
|
|
|
import { getConfigFunction, createConfigFunction } from 'apis/index'; |
|
|
|
|
|
|
|
const data = reactive({ |
|
|
|
const data = ref({ |
|
|
|
frequency: { |
|
|
|
so2: 0, // SO2采样频率 |
|
|
|
metal: 0, // 金属腐蚀采样频率 |
|
|
@ -170,10 +173,36 @@ const types = ref([ |
|
|
|
|
|
|
|
const functionForm = ref(null); // form |
|
|
|
|
|
|
|
/** |
|
|
|
* 格式化时间 |
|
|
|
*/ |
|
|
|
const formatTime = date => { |
|
|
|
const hour = date.getHours(); |
|
|
|
const minute = date.getMinutes(); |
|
|
|
return `${hour}:${minute}`; |
|
|
|
}; |
|
|
|
|
|
|
|
// 提交表单 |
|
|
|
const onSubmit = () => { |
|
|
|
functionForm.value.validate(valid => { |
|
|
|
console.log(valid, { ...data }); |
|
|
|
functionForm.value.validate(async () => { |
|
|
|
try { |
|
|
|
const param = cloneDeep({ ...data.value }); |
|
|
|
if (param.report.type === 0) { |
|
|
|
// 按时间点上报 格式化时间格式 |
|
|
|
const points = [...param.report.timePoints]; |
|
|
|
for (let i = 0; i < points.length; i++) { |
|
|
|
if (points[i] && isDate(points[i])) { |
|
|
|
points[i] = formatTime(points[i]); |
|
|
|
} |
|
|
|
} |
|
|
|
param.report.timePoints = points; |
|
|
|
} |
|
|
|
await createConfigFunction(param); |
|
|
|
ElMessage.success('提交成功'); |
|
|
|
} catch (error) { |
|
|
|
ElMessage.error('提交失败, 请稍后重试'); |
|
|
|
throw new Error(error); |
|
|
|
} |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
@ -181,4 +210,9 @@ const onSubmit = () => { |
|
|
|
const onReset = () => { |
|
|
|
functionForm.value.resetFields(); |
|
|
|
}; |
|
|
|
|
|
|
|
// 获取功能参数 |
|
|
|
getConfigFunction().then(res => { |
|
|
|
data.value = res; |
|
|
|
}); |
|
|
|
</script> |
|
|
|