|
|
@ -1,12 +1,12 @@ |
|
|
|
<template> |
|
|
|
<a-modal v-model:open="visible" :title="title" @ok="handleOk" width="50%"> |
|
|
|
<a-form :model="form" layout="vertical"> |
|
|
|
<a-modal v-model:open="visible" :title="title" @ok="handleOk" width="50%" @cancel="closeModal"> |
|
|
|
<a-form :model="form" layout="vertical" ref="formRef" :rules="rules"> |
|
|
|
<a-row :gutter="[16, 16]"> |
|
|
|
<a-col :span="24"> |
|
|
|
<a-form-item label="项目名称" name="projectName"> |
|
|
|
<a-select |
|
|
|
v-model:value="form.projectName" |
|
|
|
:options="projectNameOptions" |
|
|
|
:options="projectOptions" |
|
|
|
placeholder="请选择" |
|
|
|
/> |
|
|
|
</a-form-item> |
|
|
@ -24,6 +24,7 @@ |
|
|
|
<a-form-item label="巡检时间" name="inspectionTime"> |
|
|
|
<a-date-picker |
|
|
|
:show-time="{ format: 'HH:mm:ss' }" |
|
|
|
valueFormat="YYYY-MM-DD HH:mm:ss" |
|
|
|
v-model:value="form.inspectionTime" |
|
|
|
placeholder="请选择" |
|
|
|
/> |
|
|
@ -69,7 +70,7 @@ |
|
|
|
<a-col :span="24"> |
|
|
|
<a-form-item label="巡检照片" name="inspectionPhoto"> |
|
|
|
<a-upload |
|
|
|
v-model:file-list="inspectionPhotoList" |
|
|
|
v-model:file-list="form.inspectionPhoto" |
|
|
|
action="https://www.mocky.io/v2/5cc8019d300000980a055e76" |
|
|
|
> |
|
|
|
<a-button type="primary"> 上传 </a-button> |
|
|
@ -77,7 +78,7 @@ |
|
|
|
</a-form-item> |
|
|
|
</a-col> |
|
|
|
</a-row> |
|
|
|
<div v-if="title == '新增后端巡查日报'"> |
|
|
|
<!-- <div v-if="title == '新增后端巡查日报'"> |
|
|
|
<a-table :dataSource="inspectionReportTable" :columns="inspectionReportColumns" bordered> |
|
|
|
<template #bodyCell="{ column }"> |
|
|
|
<template v-if="column.key === 'action'"> |
|
|
@ -85,19 +86,21 @@ |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
</a-table> |
|
|
|
</div> |
|
|
|
</div> --> |
|
|
|
</a-form> |
|
|
|
</a-modal> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import { reactive, ref } from 'vue'; |
|
|
|
|
|
|
|
import { reactive, ref, onMounted } from 'vue'; |
|
|
|
import { message } from 'ant-design-vue'; |
|
|
|
import { getInfo, add, update, getProjectInfo } from './api'; |
|
|
|
export default { |
|
|
|
setup() { |
|
|
|
const title = ref('新增前端巡检日报'); |
|
|
|
const attachmentList = ref([]); |
|
|
|
const inspectionPhotoList = ref([]); |
|
|
|
const title = ref('新增'); |
|
|
|
const formRef = ref(); |
|
|
|
// const attachmentList = ref([]); |
|
|
|
// const inspectionPhotoList = ref([]); |
|
|
|
const visible = ref(false); |
|
|
|
const form = reactive({ |
|
|
|
projectName: '', |
|
|
@ -106,85 +109,121 @@ |
|
|
|
platformOnlineRate: null, |
|
|
|
problemHandleDesc: '', |
|
|
|
inspectionStatus: null, |
|
|
|
attachment: [], |
|
|
|
inspectionPhoto: '', |
|
|
|
attachment: null, |
|
|
|
inspectionPhoto: null, |
|
|
|
id: null, |
|
|
|
}); |
|
|
|
//弹窗列表 |
|
|
|
const inspectionReportTable = ref([]); |
|
|
|
const inspectionReportColumns = [ |
|
|
|
{ |
|
|
|
title: '设备地址', |
|
|
|
dataIndex: 'deviceLocation', |
|
|
|
key: 'deviceLocation', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '设备名称', |
|
|
|
dataIndex: 'deviceName', |
|
|
|
key: 'deviceName', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '型号', |
|
|
|
dataIndex: 'type', |
|
|
|
key: 'type', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: 'IP地址', |
|
|
|
dataIndex: 'ip', |
|
|
|
key: 'ip', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '检查结果', |
|
|
|
dataIndex: 'inspectionResult', |
|
|
|
key: 'inspectionResult', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '详细记录', |
|
|
|
dataIndex: 'detailLog', |
|
|
|
key: 'detailLog', |
|
|
|
}, |
|
|
|
]; |
|
|
|
// const inspectionReportTable = ref([]); |
|
|
|
// const inspectionReportColumns = [ |
|
|
|
// { |
|
|
|
// title: '设备地址', |
|
|
|
// dataIndex: 'deviceLocation', |
|
|
|
// key: 'deviceLocation', |
|
|
|
// }, |
|
|
|
// { |
|
|
|
// title: '设备名称', |
|
|
|
// dataIndex: 'deviceName', |
|
|
|
// key: 'deviceName', |
|
|
|
// }, |
|
|
|
// { |
|
|
|
// title: '型号', |
|
|
|
// dataIndex: 'type', |
|
|
|
// key: 'type', |
|
|
|
// }, |
|
|
|
// { |
|
|
|
// title: 'IP地址', |
|
|
|
// dataIndex: 'ip', |
|
|
|
// key: 'ip', |
|
|
|
// }, |
|
|
|
// { |
|
|
|
// title: '检查结果', |
|
|
|
// dataIndex: 'inspectionResult', |
|
|
|
// key: 'inspectionResult', |
|
|
|
// }, |
|
|
|
// { |
|
|
|
// title: '详细记录', |
|
|
|
// dataIndex: 'detailLog', |
|
|
|
// key: 'detailLog', |
|
|
|
// }, |
|
|
|
// ]; |
|
|
|
//下拉框 |
|
|
|
const projectNameOptions = [ |
|
|
|
{ |
|
|
|
value: '1', |
|
|
|
label: 'a', |
|
|
|
}, |
|
|
|
{ |
|
|
|
value: '2', |
|
|
|
label: 'b', |
|
|
|
}, |
|
|
|
{ |
|
|
|
value: '3', |
|
|
|
label: 'c', |
|
|
|
}, |
|
|
|
]; |
|
|
|
const showModal = (type, id) => { |
|
|
|
const projectOptions = ref([]); |
|
|
|
const getProjectOptions = async () => { |
|
|
|
const res = await getProjectInfo(); |
|
|
|
res.forEach((i) => { |
|
|
|
i.value = i.projectName; |
|
|
|
i.label = i.projectName; |
|
|
|
}); |
|
|
|
projectOptions.value = res; |
|
|
|
}; |
|
|
|
//弹窗 |
|
|
|
const showModal = async (type, id) => { |
|
|
|
if (type == 1) { |
|
|
|
title.value = '新增前端巡查日报'; |
|
|
|
title.value = '新增'; |
|
|
|
} else if (type == 2) { |
|
|
|
title.value = '新增后端巡查日报'; |
|
|
|
console.log(id); |
|
|
|
title.value = '编辑'; |
|
|
|
const data = await getInfo(id); |
|
|
|
for (let i in form) { |
|
|
|
form[i] = data[i]; |
|
|
|
} |
|
|
|
} |
|
|
|
visible.value = true; |
|
|
|
getProjectOptions() |
|
|
|
}; |
|
|
|
|
|
|
|
const handleOk = () => { |
|
|
|
console.log('Form Data:', form); |
|
|
|
// 在此处可以添加表单验证逻辑 |
|
|
|
formRef.value.validate().then((valid) => { |
|
|
|
if (valid) { |
|
|
|
if (title.value == '新增') { |
|
|
|
let params = {}; |
|
|
|
for (let i in form) { |
|
|
|
params[i] = form[i]; |
|
|
|
} |
|
|
|
add(params).then((_) => { |
|
|
|
message.success('新增成功'); |
|
|
|
visible.value = false; |
|
|
|
}); |
|
|
|
} else { |
|
|
|
let params = {}; |
|
|
|
for (let i in form) { |
|
|
|
params[i] = form[i]; |
|
|
|
} |
|
|
|
update(params).then((_) => { |
|
|
|
message.success('编辑成功'); |
|
|
|
visible.value = false; |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}; |
|
|
|
const closeModal = () => { |
|
|
|
formRef.value.resetFields(); |
|
|
|
visible.value = false; |
|
|
|
}; |
|
|
|
|
|
|
|
//规则 |
|
|
|
const rules = { |
|
|
|
projectName: [{ required: true, message: '请选择' }], |
|
|
|
inspectionPart: [{ required: true, message: '请输入' }], |
|
|
|
inspectionTime: [{ required: true, message: '请输入' }], |
|
|
|
platformOnlineRate: [{ required: true, message: '请输入' }], |
|
|
|
problemHandleDesc: [{ required: true, message: '请输入' }], |
|
|
|
inspectionStatus: [{ required: true, message: '请输入' }], |
|
|
|
}; |
|
|
|
return { |
|
|
|
visible, |
|
|
|
title, |
|
|
|
form, |
|
|
|
showModal, |
|
|
|
handleOk, |
|
|
|
attachmentList, |
|
|
|
inspectionPhotoList, |
|
|
|
projectNameOptions, |
|
|
|
inspectionReportTable, |
|
|
|
inspectionReportColumns, |
|
|
|
// attachmentList, |
|
|
|
// inspectionPhotoList, |
|
|
|
projectOptions, |
|
|
|
// inspectionReportTable, |
|
|
|
// inspectionReportColumns, |
|
|
|
formRef, |
|
|
|
rules, |
|
|
|
closeModal, |
|
|
|
}; |
|
|
|
}, |
|
|
|
}; |
|
|
|