运维管理平台前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

398 lines
12 KiB

2 months ago
<template>
2 months ago
<a-modal v-model:open="visible" title="工单上报" @ok="handleOk" width="70%" @cancel="closeModal">
<a-form :model="form" layout="vertical" ref="formRef" :rules="rules">
2 months ago
<a-row :gutter="[16, 16]">
<a-col :span="24">
<a-form-item label="所属项目" name="projectName">
<a-select
v-model:value="form.projectName"
:options="projectNameOptions"
placeholder="请选择"
2 months ago
@change="projectNameChange"
2 months ago
:fieldNames="{
label: 'projectName',
value: 'projectName',
options: 'options',
}"
/>
</a-form-item>
</a-col>
</a-row>
2 months ago
<a-row :gutter="[16, 16]">
<a-col :span="24">
<a-form-item label="所属合同" name="contractName">
<a-select
v-model:value="form.contractName"
:options="contractNameOptions"
placeholder="请选择"
:disabled="!form.projectName"
:fieldNames="{
label: 'contractName',
value: 'contractName',
options: 'options',
}"
/>
</a-form-item>
</a-col>
</a-row>
2 months ago
<a-row :gutter="[16, 16]">
<a-col :span="12">
<a-form-item label="是否事故" name="isAccident">
<a-radio-group v-model:value="form.isAccident">
<a-radio :value="1"></a-radio>
<a-radio :value="0"></a-radio>
</a-radio-group>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="报修人员" name="repairer">
<a-input v-model:value="form.repairer" />
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="[16, 16]">
<a-col :span="12">
2 months ago
<a-form-item label="响应级别" name="responseLevel">
2 months ago
<a-select v-model:value="form.responseLevel" :options="responseLevelOptions" />
</a-form-item>
</a-col>
<a-col :span="12">
2 months ago
<a-form-item label="响应时限" name="responseTime">
2 months ago
<a-input v-model:value="form.responseTime" />
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="[16, 16]">
<a-col :span="12">
<a-form-item label="故障大类" name="faultCategory">
<a-select
v-model:value="form.faultCategory"
:options="[{ value: '前端' }, { value: '后端' }]"
/>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="故障小类" name="faultSubcategory">
<a-select
v-model:value="form.faultSubcategory"
:options="faultSubcategoryOptions"
:fieldNames="{
label: 'typeName',
value: 'id',
options: 'options',
}"
/>
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="[16, 16]">
<a-col :span="12">
<a-form-item label="所属机构" name="organizationName">
2 months ago
<a-select
v-model:value="form.organizationName"
:options="organizationNameOptions"
:fieldNames="{
label: 'organizationName',
value: 'organizationName',
options: 'options',
}"
/>
2 months ago
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="故障地点" name="faultLocation">
<a-select
v-model:value="form.faultLocation"
:options="faultLocationOptions"
@change="faultLocationChange"
/>
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="[16, 16]">
<a-col :span="24">
<div id="amapContainer" style="width: 100%; height: 500px"></div>
</a-col>
</a-row>
<a-row :gutter="[16, 16]">
<a-col :span="24">
<a-form-item label="故障描述" name="faultDescription">
<a-textarea v-model:value="form.faultDescription" :rows="4" />
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="[16, 16]">
<a-col :span="24">
1 month ago
<a-form-item label="故障图片" name="attachments">
2 months ago
<a-upload
1 month ago
v-model:file-list="fileLists"
:action="`${apiUrl}/resource/oss/upload`"
:headers="headers"
@change="handleChange"
2 months ago
>
<a-button type="primary"> 上传 </a-button>
</a-upload>
1 month ago
</a-form-item>
2 months ago
</a-col>
</a-row>
<a-row :gutter="[16, 16]">
<a-col :span="12">
<a-form-item label="是否派遣" name="isDispatched">
<a-radio-group v-model:value="form.isDispatched">
<a-radio :value="1"></a-radio>
<a-radio :value="0"></a-radio>
</a-radio-group>
</a-form-item>
</a-col>
<a-col :span="12" v-if="form.isDispatched == 1">
<a-form-item label="维护要求" name="maintenanceRequirement">
<a-select
v-model:value="form.maintenanceRequirement"
:options="maintenanceRequirementOptions"
/>
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="[16, 16]" v-if="form.isDispatched == 1">
<a-col :span="24">
<a-form-item label="派遣意见" name="dispatchOpinion">
<a-textarea v-model:value="form.dispatchOpinion" :rows="4" />
</a-form-item>
</a-col>
</a-row>
</a-form>
</a-modal>
</template>
<script>
import { reactive, ref } from 'vue';
2 months ago
import {
getInfo,
getSubcategoryType,
workOrderAdd,
getProjectInfo,
getOrganizationType,
getContractNamesByProjectName,
} from './api';
2 months ago
import { message } from 'ant-design-vue';
import AMapLoader from '@amap/amap-jsapi-loader';
1 month ago
import { getToken } from '@/utils/auth';
import { useGlobSetting } from '@/hooks/setting';
2 months ago
export default {
setup() {
const visible = ref(false);
const form = reactive({
projectName: '',
2 months ago
contractName: null,
2 months ago
isAccident: null,
repairer: '',
responseTime: '',
responseLevel: '',
faultCategory: null,
faultSubcategory: null,
organizationName: '',
faultLocation: '',
faultDescription: '',
1 month ago
attachments: null,
2 months ago
isDispatched: null,
maintenanceRequirement: null,
dispatchOpinion: '',
longitude: '',
latitude: '',
});
//下拉框
2 months ago
const projectNameOptions = ref([]);
const getProjectNameOptions = async () => {
2 months ago
const res = await getProjectInfo();
2 months ago
projectNameOptions.value = res;
};
const projectNameChange = async (val) => {
const res = await getContractNamesByProjectName({ projectName: val });
contractNameOptions.value = res;
};
const contractNameOptions = ref([]);
const organizationNameOptions = ref([]);
const getOrganizationNameOptions = async () => {
2 months ago
const res = await getOrganizationType();
2 months ago
organizationNameOptions.value = res.rows;
};
2 months ago
const responseLevelOptions = [
{
value: 0,
label: '常规',
},
{
value: 1,
label: '紧急',
},
{
value: 2,
label: '特级',
},
];
const maintenanceRequirementOptions = [
{
value: 1,
label: '新增',
},
];
const faultLocationOptions = [
{
value: '1',
label: 'a',
latitude: '29.8537459',
longitude: '121.5591519',
},
{
value: '2',
label: 'b',
latitude: '29.8572957 ',
longitude: '121.5611743',
},
{
value: '3',
label: 'c',
latitude: '29.8537459',
longitude: '121.5591519',
},
];
const faultLocationChange = (val) => {
const obj = faultLocationOptions.find((i) => {
return (i.value = val);
});
2 months ago
form.longitude = obj.longitude;
form.latitude = obj.latitude;
2 months ago
initMap(obj.longitude, obj.latitude, obj.organizationName);
};
const faultSubcategoryOptions = ref([]);
const getFaultSubcategoryOptions = async () => {
const res = await getSubcategoryType();
faultSubcategoryOptions.value = res.rows;
};
const showModal = () => {
visible.value = true;
2 months ago
getFaultSubcategoryOptions();
getProjectNameOptions();
getOrganizationNameOptions();
2 months ago
};
const handleOk = () => {
2 months ago
formRef.value.validate().then((valid) => {
if (valid) {
let params = {};
for (let i in form) {
params[i] = form[i];
}
workOrderAdd(params).then((_) => {
message.success('操作成功');
1 month ago
closeModal();
2 months ago
});
}
2 months ago
});
};
//地图
const map = ref(null);
const initMap = async (longitude, latitude, organizationName) => {
try {
// 加载高德地图 JavaScript API
await AMapLoader.load({
key: '786a2e7cc6d4be5ba1d6174a0aa10f2b',
version: '2.0',
plugins: [],
});
// 初始化地图
map.value = new AMap.Map('amapContainer', {
zoom: 17,
center: [longitude, latitude],
});
// 添加标记(可选)
const marker = new AMap.Marker({
position: new AMap.LngLat(longitude, latitude),
title: organizationName,
});
const markerList = [marker];
map.value.add(markerList);
} catch (error) {
console.error('加载高德地图失败:', error);
}
};
2 months ago
const closeModal = () => {
formRef.value.resetFields();
1 month ago
fileLists.value=[]
2 months ago
visible.value = false;
1 month ago
map.value?.destroy();
2 months ago
};
const formRef = ref();
const rules = {
projectName: [{ required: true, message: '请选择' }],
contractName: [{ required: true, message: '请选择' }],
isAccident: [{ required: true, message: '请选择' }],
repairer: [{ required: true, message: '请输入' }],
faultLocation: [{ required: true, message: '请输入' }],
organizationName: [{ required: true, message: '请选择' }],
responseTime: [{ required: true, message: '请输入' }],
responseLevel: [{ required: true, message: '请选择' }],
faultCategory: [{ required: true, message: '请选择' }],
faultSubcategory: [{ required: true, message: '请选择' }],
1 month ago
faultDescription: [{ required: true, message: '请输入' }],
2 months ago
isDispatched: [{ required: true, message: '请选择' }],
};
1 month ago
//上传功能
const fileLists = ref([]);
const globSetting = useGlobSetting();
const { apiUrl, clientId } = globSetting;
const handleChange = (info) => {
if (info.fileList.length > 0) {
form.attachments = [];
info.fileList.forEach((i) => {
if (i.status == 'done') {
form.attachments.push({
url: i.response?.data.url || i.url,
name: i.response?.data.fileName || i.name,
});
}
});
} else {
form.attachments = null;
}
console.log(fileLists);
};
2 months ago
return {
visible,
form,
showModal,
handleOk,
responseLevelOptions,
maintenanceRequirementOptions,
faultSubcategoryOptions,
faultLocationOptions,
projectNameOptions,
2 months ago
contractNameOptions,
2 months ago
organizationNameOptions,
2 months ago
faultLocationChange,
2 months ago
projectNameChange,
closeModal,
formRef,
rules,
1 month ago
apiUrl,
headers: {
Authorization: 'Bearer ' + getToken(),
clientId,
},
handleChange,
fileLists,
2 months ago
};
},
};
</script>
<style scoped>
/* 可选样式调整 */
.ant-modal-body {
max-width: 600px;
margin: 0 auto;
}
</style>