template elasticsearch6备注

本文介绍了一个用于Elasticsearch的模板配置文件template_event.json的具体内容。该模板定义了名为event的数据索引模板,设置了索引分片数量、副本数量,并详细说明了各种字段类型及其映射规则。

 

###install.sh脚本

ES_TEMPLATE_DIR=/home/xlj/elasticsearch-6.2.3/config/template_event.json


if test -f $ES_TEMPLATE_DIR ; then
echo "generate event template ..."
curl  -H "Content-Type: application/json"  -XPUT http://192.168.101.198:9201/_template/template_event -d "$(cat $ES_TEMPLATE_DIR)"
echo "generate event template done ..."
fi

###具体内容template_event.json

{

    "order": 0,
    "template": "event*",
    "settings": {
        "index": {
            "number_of_shards": "10",
            "number_of_replicas": "1"
        }
    },
    "mappings": {
"event": {
"_all": {
"enabled": false
},
"properties": {
"@timestamp": {
"type": "date"
},
"@version": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"Reason": {
"type": "keyword"
},
"access_name": {
"type": "keyword"
},
"access_path": {
"type": "keyword"
},
"act": {
"type": "keyword"
},
"action": {
"type": "keyword"
},
"addr": {
"type": "keyword"
},
"addr_type": {
"type": "keyword"
},
"alarm_sample": {
"type": "keyword"
},
"alarm_sip": {
"type": "keyword"
},
"alarm_state": {
"type": "keyword"
},
"app_protocol": {
"type": "keyword"
},
"app_type": {
"type": "keyword"
},
"attack_confidence": {
"type": "keyword"
},
"attack_signature": {
"type": "keyword"
},
"attackment_md5": {
"type": "keyword"
},
"attackment_mime_type": {
"type": "keyword"
},
"attackment_name": {
"type": "keyword"
},
"backdoor_class": {
"type": "keyword"
},
"backdoor_hash": {
"type": "keyword"
},
"backdoor_name": {
"type": "keyword"
},
"browser": {
"type": "keyword"
},
"bytes": {
"type": "keyword"
},
"cast_type": {
"type": "keyword"
},
"cert": {
"type": "keyword"
},
"client_os": {
"type": "keyword"
},
"cmd": {
"type": "keyword"
},
"cname": {
"type": "keyword"
},
"cnnvd": {
"type": "keyword"
},
"cnvd": {
"type": "keyword"
},
"collect_type": {
"type": "keyword"
},
"collector_address": {
"type": "ip"
},
"cookie": {
"type": "keyword"
},
"count": {
"type": "keyword"
},
"cpu": {
"type": "long"
},
"cve": {
"type": "keyword"
},
"cvss": {
"type": "keyword"
},
"data": {
"type": "keyword"
},
"db_name": {
"type": "keyword"
},
"db_type": {
"type": "keyword"
},
"dev": {
"type": "keyword"
},
"dev_address": {
"type": "ip"
},
"dev_asset_id": {
"type": "keyword"
},
"dev_asset_type_id": {
"type": "keyword"
},
"dev_name": {
"type": "keyword"
},
"dev_type": {
"type": "keyword"
},
"dns_type": {
"type": "keyword"
},
"down_payload": {
"type": "keyword"
},
"downlink_length": {
"type": "keyword"
},
"dproc": {
"type": "keyword"
},
"dst_address": {
"type": "ip"
},
"dst_as": {
"type": "long"
},
"dst_asset_business_id": {
"type": "keyword"
},
"dst_asset_department_id": {
"type": "keyword"
},
"dst_asset_domain_id": {
"type": "keyword"
},
"dst_asset_id": {
"type": "keyword"
},
"dst_asset_location_id": {
"type": "keyword"
},
"dst_asset_type_id": {
"type": "keyword"
},
"dst_city": {
"type": "keyword"
},
"dst_country": {
"type": "keyword"
},
"dst_country_code": {
"type": "keyword"
},
"dst_domain": {
"type": "long"
},
"dst_filepath": {
"type": "keyword"
},
"dst_geo": {
"type": "geo_point"
},
"dst_lat": {
"type": "keyword"
},
"dst_lng": {
"type": "keyword"
},
"dst_mac": {
"type": "keyword"
},
"dst_mask": {
"type": "keyword"
},
"dst_name": {
"type": "keyword"
},
"dst_nat_address": {
"type": "ip"
},
"dst_nat_port": {
"type": "long"
},
"dst_port": {
"type": "long"
},
"dst_province": {
"type": "keyword"
},
"dst_sec_domain": {
"type": "keyword"
},
"dst_url": {
"type": "keyword"
},
"duration": {
"type": "long"
},
"duration_time": {
"type": "long"
},
"employee_account": {
"type": "keyword"
},
"employee_city": {
"type": "keyword"
},
"employee_company": {
"type": "keyword"
},
"employee_department": {
"type": "keyword"
},
"employee_name": {
"type": "keyword"
},
"employee_number": {
"type": "keyword"
},
"employee_role": {
"type": "keyword"
},
"employee_work_city": {
"type": "keyword"
},
"employee_work_num": {
"type": "keyword"
},
"end_time": {
"type": "date"
},
"event_content": {
"type": "keyword"
},
"event_digest": {
"type": "keyword"
},
"event_level": {
"type": "long"
},
"event_name": {
"type": "keyword"
},
"event_sub_type": {
"type": "text"
},
"event_type": {
"type": "keyword"
},
"event_uuid": {
"type": "keyword"
},
"file_dir": {
"type": "keyword"
},
"file_md5": {
"type": "keyword"
},
"file_type": {
"type": "keyword"
},
"filename": {
"type": "keyword"
},
"first_time": {
"type": "date"
},
"group_name": {
"type": "keyword"
},
"host_md5": {
"type": "keyword"
},
"host_name": {
"type": "keyword"
},
"id": {
"type": "keyword"
},
"identity_verification": {
"type": "keyword"
},
"in_if": {
"type": "keyword"
},
"index_type": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"input": {
"type": "keyword"
},
"ioc": {
"type": "keyword"
},
"kafka": {
"properties": {
"consumer_group": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"key": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"offset": {
"type": "long"
},
"partition": {
"type": "long"
},
"topic": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
"login_date": {
"type": "date"
},
"login_type": {
"type": "long"
},
"mail_subject": {
"type": "keyword"
},
"malcode_class": {
"type": "keyword"
},
"malcode_hash": {
"type": "keyword"
},
"malcode_name": {
"type": "keyword"
},
"maldns_class": {
"type": "keyword"
},
"maldomain_class": {
"type": "keyword"
},
"malip_class": {
"type": "keyword"
},
"malurl_class": {
"type": "keyword"
},
"malware_confidence": {
"type": "keyword"
},
"malware_detection_engine": {
"type": "keyword"
},
"malware_file_length": {
"type": "keyword"
},
"malware_file_md5_hash": {
"type": "keyword"
},
"malware_file_name": {
"type": "keyword"
},
"malware_virus_name": {
"type": "keyword"
},
"mem": {
"type": "long"
},
"merge_count": {
"type": "long"
},
"method": {
"type": "keyword"
},
"mid": {
"type": "keyword"
},
"mime_type": {
"type": "keyword"
},
"module_name": {
"type": "keyword"
},
"monitor_value": {
"type": "long"
},
"monitoring_value": {
"type": "long"
},
"msg": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"net_protocol": {
"type": "keyword"
},
"next_hop": {
"type": "ip"
},
"nid": {
"type": "keyword"
},
"normal_id": {
"type": "keyword"
},
"occur_time": {
"type": "date"
},
"operating_system": {
"type": "keyword"
},
"operation": {
"type": "keyword"
},
"operation_object": {
"type": "keyword"
},
"origin": {
"type": "keyword"
},
"original_level": {
"type": "keyword"
},
"original_log": {
"type": "keyword"
},
"original_type": {
"type": "keyword"
},
"out_if": {
"type": "keyword"
},
"output": {
"type": "keyword"
},
"owasp": {
"type": "keyword"
},
"pol": {
"type": "keyword"
},
"pri": {
"type": "long"
},
"process_md5": {
"type": "keyword"
},
"process_name": {
"type": "keyword"
},
"process_path": {
"type": "keyword"
},
"product": {
"type": "keyword"
},
"program_name": {
"type": "keyword"
},
"protocol": {
"type": "keyword"
},
"pt": {
"type": "keyword"
},
"pt_subtype": {
"type": "keyword"
},
"receive_byte": {
"type": "long"
},
"receive_file_size": {
"type": "long"
},
"receive_mail": {
"type": "keyword"
},
"receive_package": {
"type": "long"
},
"receive_time": {
"type": "date"
},
"recept_time": {
"type": "long"
},
"referer": {
"type": "keyword"
},
"reliability": {
"type": "long"
},
"reply_code": {
"type": "keyword"
},
"request_Method": {
"type": "keyword"
},
"request_arg": {
"type": "keyword"
},
"request_cookie": {
"type": "keyword"
},
"request_msg": {
"type": "keyword"
},
"request_time": {
"type": "date"
},
"response": {
"type": "keyword"
},
"result": {
"type": "keyword"
},
"ret": {
"type": "keyword"
},
"ret_code": {
"type": "keyword"
},
"rule_desc": {
"type": "keyword"
},
"rule_id": {
"type": "keyword"
},
"rule_name": {
"type": "keyword"
},
"rule_state": {
"type": "keyword"
},
"rule_type": {
"type": "keyword"
},
"sa_da": {
"type": "keyword"
},
"sa_sp_ap_da_dp": {
"type": "keyword"
},
"send_byte": {
"type": "long"
},
"send_file_size": {
"type": "long"
},
"send_mail": {
"type": "keyword"
},
"send_package": {
"type": "long"
},
"seq": {
"type": "keyword"
},
"serial_num": {
"type": "keyword"
},
"server_name": {
"type": "keyword"
},
"server_os": {
"type": "keyword"
},
"service_name": {
"type": "keyword"
},
"service_type": {
"type": "keyword"
},
"session": {
"type": "keyword"
},
"session_id": {
"type": "keyword"
},
"sign": {
"type": "keyword"
},
"sql_info": {
"type": "keyword"
},
"src_address": {
"type": "ip"
},
"src_as": {
"type": "long"
},
"src_asset_business_id": {
"type": "keyword"
},
"src_asset_department_id": {
"type": "keyword"
},
"src_asset_domain_id": {
"type": "keyword"
},
"src_asset_id": {
"type": "keyword"
},
"src_asset_location_id": {
"type": "keyword"
},
"src_asset_type_id": {
"type": "keyword"
},
"src_city": {
"type": "keyword"
},
"src_country": {
"type": "keyword"
},
"src_country_code": {
"type": "keyword"
},
"src_domain": {
"type": "long"
},
"src_filepath": {
"type": "keyword"
},
"src_geo": {
"type": "geo_point"
},
"src_lat": {
"type": "keyword"
},
"src_lng": {
"type": "keyword"
},
"src_mac": {
"type": "keyword"
},
"src_mask": {
"type": "keyword"
},
"src_name": {
"type": "keyword"
},
"src_nat_address": {
"type": "ip"
},
"src_nat_port": {
"type": "long"
},
"src_port": {
"type": "long"
},
"src_province": {
"type": "keyword"
},
"src_sec_domain": {
"type": "keyword"
},
"src_url": {
"type": "keyword"
},
"standby_address1": {
"type": "ip"
},
"standby_address2": {
"type": "ip"
},
"standby_address3": {
"type": "ip"
},
"standby_address4": {
"type": "ip"
},
"standby_address5": {
"type": "ip"
},
"standby_char1": {
"type": "keyword"
},
"standby_char10": {
"type": "keyword"
},
"standby_char2": {
"type": "keyword"
},
"standby_char3": {
"type": "keyword"
},
"standby_char4": {
"type": "keyword"
},
"standby_char5": {
"type": "keyword"
},
"standby_char6": {
"type": "keyword"
},
"standby_char7": {
"type": "keyword"
},
"standby_char8": {
"type": "keyword"
},
"standby_char9": {
"type": "keyword"
},
"standby_double1": {
"type": "long"
},
"standby_double2": {
"type": "long"
},
"standby_double3": {
"type": "long"
},
"standby_double4": {
"type": "long"
},
"standby_double5": {
"type": "long"
},
"standby_number1": {
"type": "long"
},
"standby_number10": {
"type": "long"
},
"standby_number2": {
"type": "long"
},
"standby_number3": {
"type": "long"
},
"standby_number4": {
"type": "long"
},
"standby_number5": {
"type": "long"
},
"standby_number6": {
"type": "long"
},
"standby_number7": {
"type": "long"
},
"standby_number8": {
"type": "long"
},
"standby_number9": {
"type": "long"
},
"standby_time1": {
"type": "date"
},
"standby_time2": {
"type": "date"
},
"standby_time3": {
"type": "date"
},
"standby_time4": {
"type": "date"
},
"standby_time5": {
"type": "date"
},
"status": {
"type": "keyword"
},
"status_code": {
"type": "long"
},
"stream_direction": {
"type": "keyword"
},
"subtype": {
"type": "keyword"
},
"system": {
"type": "keyword"
},
"systype": {
"type": "keyword"
},
"tcp_byte": {
"type": "keyword"
},
"tcp_flags": {
"type": "keyword"
},
"threat_info": {
"type": "keyword"
},
"threat_rule_id": {
"type": "keyword"
},
"ti_ip": {
"type": "keyword"
},
"ti_ua": {
"type": "keyword"
},
"time": {
"type": "keyword"
},
"tos": {
"type": "keyword"
},
"trail": {
"type": "keyword"
},
"tran_protocol": {
"type": "long"
},
"trans_protocol": {
"type": "long"
},
"trojans_class": {
"type": "keyword"
},
"trojans_hash": {
"type": "keyword"
},
"trojans_name": {
"type": "keyword"
},
"type": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"udp_byte": {
"type": "keyword"
},
"up_payload": {
"type": "keyword"
},
"update_time": {
"type": "keyword"
},
"uplink_length": {
"type": "keyword"
},
"uri_md5": {
"type": "keyword"
},
"url": {
"type": "keyword"
},
"usb_number": {
"type": "keyword"
},
"usb_type": {
"type": "keyword"
},
"user_account": {
"type": "keyword"
},
"user_agent": {
"type": "keyword"
},
"user_focus": {
"type": "keyword"
},
"user_name": {
"type": "keyword"
},
"uuid": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"vendor": {
"type": "keyword"
},
"version": {
"type": "keyword"
},
"virus_class": {
"type": "keyword"
},
"virus_hash": {
"type": "keyword"
},
"virus_name": {
"type": "keyword"
},
"virus_path": {
"type": "keyword"
},
"virus_type": {
"type": "keyword"
},
"visitor_mark": {
"type": "keyword"
},
"vul_class": {
"type": "keyword"
},
"vul_hash": {
"type": "keyword"
},
"vul_name": {
"type": "keyword"
},
"work_site": {
"type": "keyword"
},
"worm_class": {
"type": "keyword"
},
"worm_hash": {
"type": "keyword"
},
"worm_name": {
"type": "keyword"
},
"xff": {
"type": "keyword"
}
}
}
},
    "aliases": {}
}

<template> <div class="pdi-edit-container"> <div class="language-switcher" v-show="route.params.code"> <el-button @click="changeLanguage('en_US')">English</el-button> <el-button @click="changeLanguage('zh_CN')">中文</el-button> <el-button @click="changeLanguage('es_MX')">Español</el-button> </div> <!-- 设备信息 --> <CustomerInfo ref="customerInfo" :customer="formData.customer" :is-not-check="isNotCheck" /> <!-- 检测项 --> <InspectionItems ref="inspectionItems" :items="formData.inspectionItems" :is-not-check="isNotCheck" /> <!-- 图片上传 --> <PdiImageUpload ref="imageUpload" v-model:image-map="formData.imageMap" :initial-data="formData.imageMap" :is-not-check="isNotCheck" /> <!-- 签名选项复选框 - 只显示可选的签名复选框 --> <el-checkbox v-model="checkedCarrier" :disabled="!isNotCheck" v-show="signatureConfig.carrierOptional"> {{ $t('inspectionManagement.carrierSignature') }} </el-checkbox> <!-- 签名区域 --> <!-- 仓库签名 --> <div v-show="signatureConfig.showWarehouse"> <template v-if="photo.warehouseKeeperSignatureImg"> <h2>{{ $t('inspectionManagement.warehouseKeeperSignature') }}</h2> <!-- <ImagePreview width="95%" :height="200" :src="photo.warehouseKeeperSignatureImg" /> --> <el-image width="95%" style="height: 200px;" :src="photo.warehouseKeeperSignatureImg" /> </template> <template v-else> <CustomerSignature ref="warehouseSignature" :title="$t('inspectionManagement.warehouseKeeperSignature')" :initial-image="formData.signatures.warehouse" @upload-success="handleWarehouseSignature" @clear-success="handleClearWarehouse" @touchstart="handleSignatureTouchStart"/> </template> </div> <!-- 检查人签名 --> <div v-show="signatureConfig.showInspector"> <template v-if="photo.inspectedSignatureImg"> <h2>{{ $t('inspectionManagement.inspectorSignature') }}</h2> <!-- <ImagePreview width="95%" :height="200" :src="photo.inspectedSignatureImg" /> --> <el-image width="95%" style="height: 200px;" :src="photo.inspectedSignatureImg" /> </template> <template v-else> <CustomerSignature ref="inspectedSignature" :title="$t('inspectionManagement.inspectorSignature')" :initial-image="formData.signatures.inspector" @upload-success="handleInspectorSignature" @clear-success="handleClearInspector" @touchstart="handleSignatureTouchStart"/> </template> </div> <!-- 承运人签名 --> <div v-show="signatureConfig.showCarrier && (signatureConfig.carrierRequired || checkedCarrier)"> <template v-if="photo.carrierSignatureImg"> <h2>{{ $t('inspectionManagement.carrierSignature') }}</h2> <!-- <ImagePreview width="95%" :height="200" :src="photo.carrierSignatureImg" /> --> <el-image width="95%" style="height: 200px;" :src="photo.carrierSignatureImg" /> </template> <template v-else> <CustomerSignature ref="carrierSignature" :title="$t('inspectionManagement.carrierSignature')" :initial-image="formData.signatures.carrier" @upload-success="handleCarrierSignature" @clear-success="handleClearCarrier" @touchstart="handleSignatureTouchStart"/> </template> </div> <!-- 客户签名 --> <div v-show="signatureConfig.showCustomer"> <template v-if="photo.customerSignatureImg"> <h2>{{ $t('inspectionManagement.customerSignature') }}</h2> <!-- <ImagePreview width="95%" :height="200" :src="photo.customerSignatureImg" /> --> <el-image width="95%" style="height: 200px;" :src="photo.customerSignatureImg" /> </template> <template v-else> <CustomerSignature ref="customerSignature" :title="$t('inspectionManagement.customerSignature')" :initial-image="formData.signatures.customer" @upload-success="handleCustomerSignature" @clear-success="handleClearCustomer" :code="route.params.code" @touchstart="handleSignatureTouchStart"/> </template> </div> <!-- 提交按钮 --> <div class="submit-btn"> <el-button type="primary" @click="handleSubmit" v-show="submitButton" :loading="buttonLoading">{{ $t('systemOperations.submitDocument') }}</el-button> <!-- <el-checkbox v-model="checkedPopLink" style="margin-left: 10px; bottom: 0;" v-show="showPopLinkFlag&&!checkedCustomer">{{ $t('inspectionManagement.generateLink') }}</el-checkbox> --> </div> <!-- 添加Checklist检测弹窗 --> <el-dialog v-model="pdiDialogVisible" :title="$t('inspectionManagement.customerSignature')" width="500px"> <el-form> <el-form-item :title="$t('inspectionManagement.customerSignature')"> <el-input v-model="pdiUrl" readonly class="copy-input"> <template #append> <el-button icon="DocumentCopy" @click="copyPDIUrl" :title="$t('systemOperations.copy')" /> </template> </el-input> </el-form-item> </el-form> <template #footer> <el-button @click="pdiDialogVisible = false">{{ $t('systemOperations.close') }}</el-button> </template> </el-dialog> </div> </template> <script setup> import { ref, reactive, onMounted, computed, watch } from 'vue' import { useRoute } from 'vue-router' import { getPdiCheck, updatePdiCheck, completePdiCheck, customerSignAuthPdiCheck, getPdiCheckByCode, getNoNeedLoginCode } from '@/api/lease/pdiCheck'; import CustomerInfo from './components/CustomerInfo.vue' import InspectionItems from './components/InspectionItems.vue' import PdiImageUpload from './components/pdiImageUpload.vue' import CustomerSignature from './components/CustomerSignature.vue' import { LanguageDefaultValues } from '@/enums/LanguageDefaultValues' import copy from '@/utils/copy' import { fa, tr } from 'element-plus/es/locale/index.mjs'; import { useI18n } from 'vue-i18n'; import { useAppStore } from '@/store/modules/app'; const buttonLoading = ref(false) const appStore = useAppStore(); const { t,locale } = useI18n(); const route = useRoute() const router = useRouter(); const devicePdiId = route.params.devicePdiId // 获取子组件引用 const customerInfo = ref(null); // 触摸处理函数 const handleSignatureTouchStart = () => { // 让小时表输入框失去焦点 customerInfo.value?.hoursInputRef?.blur(); }; // 根据allocateBillStatus配置签名显示逻辑 const signatureConfig = computed(() => { const status = formData.customer.allocateBillStatus; console.log('allocateBillStatus',status); switch(status) { case '11': // 待出库检查 - 仓管(固定)+ 检查人(固定) return { showWarehouse: true, // 显示仓管(固定) showInspector: true, // 显示检查人(固定) showCarrier: false, // 不显示承运人 showCustomer: false, // 不显示客户 carrierRequired: false, // 承运人不是必需的 carrierOptional: false // 承运人不可选 }; case '12': // 待入场检查 - 检查人(固定)+ 承运人(固定)+ 客户(固定) return { showWarehouse: false, // 不显示仓管 showInspector: true, // 显示检查人(固定) showCarrier: true, // 显示承运人(固定) showCustomer: true, // 显示客户(固定) carrierRequired: true, // 承运人是必需的 carrierOptional: false // 承运人不可选(固定显示) }; case '13': // 待退场检查 - 检查人(固定)+ 承运人(可选)+ 客户(固定) return { showWarehouse: false, // 不显示仓管 showInspector: true, // 显示检查人(固定) showCarrier: true, // 显示承运人(可选) showCustomer: true, // 显示客户(固定) carrierRequired: false, // 承运人不是必需的 carrierOptional: true // 承运人可选 }; case '14': // 待整备检查 - 仓管(固定)+ 检查人(固定) return { showWarehouse: true, // 显示仓管(固定) showInspector: true, // 显示检查人(固定) showCarrier: false, // 不显示承运人 showCustomer: false, // 不显示客户 carrierRequired: false, // 承运人不是必需的 carrierOptional: false // 承运人不可选 }; default: // 默认配置 return { showWarehouse: false, showInspector: true, showCarrier: false, showCustomer: false, carrierRequired: false, carrierOptional: false }; } }); const photo = reactive({ warehouseKeeperSignatureImg: '', carrierSignatureImg: '', customerSignatureImg: '', inspectedSignatureImg: '' }); const billStatus = ref(null) const isNotCheck = ref(false); const submitButton = ref(true) const checkedCarrier = ref(false) // 只用于可选的承运人 const checkedPopLink = ref(false) const showPopLinkFlag = ref(true) const pdiUrl = ref('') const pdiDialogVisible = ref(false); // 表单数据结构 const formData = reactive({ sourceBillType: '', billType: '', vehicleId: '', customer: { license: '', vin: '', vehicleSelfCode: '', hours: '', coordinate: '', billNo: '', allocateBillStatus: '', // 关键字段:分配单状态 sourceBillNo: '', allocateBillStatusNameL: [], billType:'', billTypeL:[], billDate: new Date().toISOString().split('T')[0], }, inspectionItems: [], imageMap: { front: [], back: [], left: [], right: [], pipeline: [], oil: [], battery: [], other: [] }, signatures: { carrier: '', customer: '', warehouse: '', inspector: '', } }) // 字段映射表 const FIELD_MAPPING = { 'inspectionManagement.vehicleKeys': { field: 'vehicleKey', remark: 'vehicleKeyRemark' }, 'inspectionManagement.hydraulicOilLevel': { field: 'hydraulicOilLevel', remark: 'hydraulicOilLevelRemark' }, 'inspectionManagement.lampCover': { field: 'lampshade', remark: 'lampshadeRemark' }, 'inspectionManagement.horn': { field: 'horn', remark: 'hornRemark' }, 'inspectionManagement.batteryLiquidPosition': { field: 'batteryElectricFluid', remark: 'batteryElectricFluidRemark' }, 'inspectionManagement.gantry': { field: 'gantry', remark: 'gantryRemark' }, 'inspectionManagement.headlight': { field: 'headlight', remark: 'headlightRemark' }, 'inspectionManagement.brakeOilLevel': { field: 'brakeOilLevel', remark: 'brakeOilLevelRemark' }, 'inspectionManagement.rearviewMirror': { field: 'rearviewMirror', remark: 'rearviewMirrorRemark' }, 'inspectionManagement.fireExtinguisher': { field: 'fireExtinguisher', remark: 'fireExtinguisherRemark' }, 'inspectionManagement.battery': { field: 'battery', remark: 'batteryRemark' }, 'inspectionManagement.batteryConnection': { field: 'batteryConnection', remark: 'batteryConnectionRemark' }, 'inspectionManagement.machineCircuitConnection': { field: 'wholeMachineCircuitConnection', remark: 'wholeMachineCircuitConnectionRemark' }, 'inspectionManagement.reverseAlarm': { field: 'reverseAlarm', remark: 'reverseAlarmRemark' }, 'inspectionManagement.hydraulicSteering': { field: 'hydraulicSteering', remark: 'hydraulicSteeringRemark' }, 'inspectionManagement.brakePedal': { field: 'brakePedal', remark: 'brakePedalRemark' }, 'inspectionManagement.handBrakeLever': { field: 'handBrakeLever', remark: 'handBrakeLeverRemark' }, 'inspectionManagement.controlHandleCheck': { field: 'controlHandleCheck', remark: 'controlHandleCheckRemark' }, 'inspectionManagement.forkTiltCheck': { field: 'forkTiltCheck', remark: 'forkTiltCheckRemark' }, 'inspectionManagement.forkLiftCheck': { field: 'forkLiftCheck', remark: 'forkLiftCheckRemark' }, 'inspectionManagement.lubricantInspection': { field: 'lubricantInspection', remark: 'lubricantInspectionRemark' }, 'inspectionManagement.tires': { field: 'tires', remark: 'tiresRemark' }, 'inspectionManagement.workLights': { field: 'workLights', remark: 'workLightsRemark' }, 'inspectionManagement.rearTurnSignal': { field: 'rearTurnSignal', remark: 'rearTurnSignalRemark' }, 'inspectionManagement.frontTurnSignal': { field: 'frontTurnSignal', remark: 'frontTurnSignalRemark' }, 'inspectionManagement.seatBelt': { field: 'seatBelt', remark: 'seatBeltRemark' }, 'inspectionManagement.bodyDamage': { field: 'bodyDamage', remark: 'bodyDamageRemark' }, 'inspectionManagement.hoses': { field: 'hoses', remark: 'hosesRemark' }, 'inspectionManagement.batteryAspect': { field: 'batteryAspect', remark: 'batteryAspectRemark' }, 'inspectionManagement.seat': { field: 'seat', remark: 'seatRemark' }, 'inspectionManagement.forks': { field: 'forks', remark: 'forksRemark' }, 'inspectionManagement.stickers': { field: 'stickers', remark: 'stickersRemark' }, 'inspectionManagement.steeringWheel': { field: 'steeringWheel', remark: 'steeringWheelRemark' }, 'inspectionManagement.engineCleaning': { field: 'engineCleaning', remark: 'engineCleaningRemark' }, 'inspectionManagement.generalCleaning': { field: 'generalCleaning', remark: 'generalCleaningRemark' }, 'inspectionManagement.fuel': { field: 'fuel', remark: 'fuelRemark' }, } // 处理签名上传 const handleCarrierSignature = (data) => { formData.signatures.carrier = data.ossId } const handleCustomerSignature = (data) => { formData.signatures.customer = data.ossId } const handleWarehouseSignature = (data) => { formData.signatures.warehouse = data.ossId } const handleInspectorSignature = (data) => { formData.signatures.inspector = data.ossId } // 处理签名清空 const handleClearWarehouse = () => { formData.signatures.warehouse = '' } const handleClearInspector = () => { formData.signatures.inspector = '' } const handleClearCarrier = () => { formData.signatures.carrier = '' } const handleClearCustomer = () => { formData.signatures.customer = '' } const copyPDIUrl = async () => { copy(pdiUrl.value) } // 图片字段映射表 const IMAGE_FIELD_MAPPING = { front: 'frontImg', back: 'backImg', left: 'leftImg', right: 'rightImg', pipeline: 'conduitImg', oil: 'fluidImg', battery: 'electricityImg', fuel: 'fuelImg', other: 'otherImg' } // 提交处理 const handleSubmit = async () => { buttonLoading.value = true try { if(!formData.customer.hours){ ElMessage.error(`${t('equipmentManagement.currentHourMeterReading')}`) buttonLoading.value = false return } // 根据配置校验签名 const config = signatureConfig.value; // 校验固定显示的签名 if (config.showWarehouse && !formData.signatures.warehouse) { ElMessage.error(`${t('inspectionManagement.warehouseKeeperSignature')}`) buttonLoading.value = false return } if (config.showInspector && !formData.signatures.inspector) { ElMessage.error(`${t('inspectionManagement.inspectorSignature')}`) buttonLoading.value = false return } if (config.showCustomer && !formData.signatures.customer) { ElMessage.error(`${t('inspectionManagement.customerSignature')}`) buttonLoading.value = false return } // 校验承运人签名(固定必需或可选已勾选的情况) if (config.showCarrier && config.carrierRequired && !formData.signatures.carrier) { ElMessage.error(`${t('inspectionManagement.carrierSignature')}`) buttonLoading.value = false return } if (config.showCarrier && config.carrierOptional && checkedCarrier.value && !formData.signatures.carrier) { ElMessage.error(`${t('inspectionManagement.carrierSignature')}`) buttonLoading.value = false return } // 构造请求数据 const postData = { billId: devicePdiId, billNo: formData.customer.billNo, vehicleId: formData.vehicleId, hmrNow: formData.customer.hours, coordinate: formData.customer.coordinate, sourceBillType: formData.sourceBillType, billType: formData.billType, billDate: `${formData.customer.billDate} 00:00:00`, remark: LanguageDefaultValues, // 检测项数据 ...formData.inspectionItems.reduce((acc, item) => { const mapping = FIELD_MAPPING[item.name] acc[mapping.field] = item.selected acc[mapping.remark] = item.comment return acc }, {}), // 图片数据 ...Object.entries(formData.imageMap).reduce((acc, [key, images]) => { const fieldName = IMAGE_FIELD_MAPPING[key]; if (!fieldName) return acc; if (typeof images === 'string' && images) { acc[fieldName] = images; } else if (Array.isArray(images) && images.length > 0) { const ids = images.map(img => img.id || '').filter(Boolean); if (ids.length > 0) { acc[fieldName] = ids.join(','); } } return acc; }, {}), // 签名数据 - 根据配置决定是否提交 warehouseKeeperSignatureImg: config.showWarehouse ? formData.signatures.warehouse : '', inspectedSignatureImg: config.showInspector ? formData.signatures.inspector : '', customerSignatureImg: config.showCustomer ? formData.signatures.customer : '', carrierSignatureImg: (config.showCarrier && (config.carrierRequired || checkedCarrier.value)) ? formData.signatures.carrier : '' } if (billStatus.value === '0') { const res1 = await completePdiCheck(postData) if (res1.code === 200) { ElMessage.success(t('systemOperations.operationSuccessful')) buttonLoading.value = false submitButton.value = false showPopLinkFlag.value = false const code = res1.data if (code) { pdiUrl.value = `${window.location.origin}${router.resolve({ name: 'editPDICheck', params: { devicePdiId, code } }).href}` if(!config.showCustomer && checkedPopLink.value){ pdiDialogVisible.value = true } } } } else if (billStatus.value === '1') { const code1 = route.params.code const res2 = await customerSignAuthPdiCheck(postData, code1) if (res2.code === 200) { ElMessage.success(t('systemOperations.operationSuccessful')) buttonLoading.value = false submitButton.value = false showPopLinkFlag.value = false } } buttonLoading.value = false } catch (error) { console.error('提交失败:', error) buttonLoading.value = false ElMessage.error(t('systemOperations.operationFailed'))//操作失败 } } // 初始化可选签名复选框状态 const initOptionalSignatures = () => { const config = signatureConfig.value; // 只初始化可选的承运人复选框,默认勾选 if (config.carrierOptional) { checkedCarrier.value = true; // 如果已有签名数据,根据实际情况设置 if (billStatus.value === '1' || billStatus.value === '2') { checkedCarrier.value = !!formData.signatures.carrier; } } } // 初始化数据 const loadData = async () => { proxy?.$modal.loading(''); try { let res = {}; if (route.params.code) { res = await getPdiCheckByCode(devicePdiId, route.params.code); } else { res = await getPdiCheck(devicePdiId) } const { code, data } = { ...res }; if (code !== 200) return billStatus.value = data.billStatus isNotCheck.value = data.billStatus === '0' if (data.billStatus == '1'|| data.billStatus == '2') { submitButton.value = false } formData.sourceBillType = data.sourceBillType formData.billType = data.billType formData.vehicleId = data.vehicleVo?.vehicleId // 签名图片URL photo.warehouseKeeperSignatureImg = data.warehouseKeeperSignatureImgUrl; photo.carrierSignatureImg = data.carrierSignatureImgUrl; photo.customerSignatureImg = data.customerSignatureImgUrl; photo.inspectedSignatureImg = data.inspectedSignatureImgUrl; // 客户信息 - 重要:设置allocateBillStatus formData.customer = { license: data.vehicleVo?.vehiclePlate || '', vin: data.vehicleVo?.vinNumber || '', vehicleSelfCode: data.vehicleVo?.vehicleSelfCode || '', billDate: data.billDate || new Date().toISOString().split('T')[0], hours: data.hmrNow || '', coordinate: data.coordinate || '', billNo: data.billNo, allocateBillStatus: data.allocateBillStatus, // 关键字段 allocateBillStatusNameL: data.allocateBillStatusNameL, sourceBillNo: data.sourceBillNo||'', billType: data.billType||'', billTypeL: data.billTypeL||[], } console.log('formData.customer', formData.customer); // 初始化检测项 formData.inspectionItems = Object.keys(FIELD_MAPPING).map(name => { const mapping = FIELD_MAPPING[name] return { name, selected: data[mapping.field] || '0', comment: data[mapping.remark] || '' } }) // 初始化图片数据 const initImageMap = (key, urls) => { return urls?.split(',').filter(Boolean).map(url => ({ url })) || [] } formData.imageMap = { front: initImageMap('front', data.frontImgUrl), back: initImageMap('back', data.backImgUrl), left: initImageMap('left', data.leftImgUrl), right: initImageMap('right', data.rightImgUrl), pipeline: initImageMap('pipeline', data.conduitImgUrl), oil: initImageMap('oil', data.fluidImgUrl), battery: initImageMap('battery', data.electricityImgUrl), fuel: initImageMap('fuel', data.fuelImgUrl), other: initImageMap('other', data.otherImgUrl) } // 签名数据 formData.signatures = { carrier: data.carrierSignatureImgUrl || '', customer: data.customerSignatureImgUrl || '', warehouse: data.warehouseKeeperSignatureImgUrl || '', inspector: data.inspectedSignatureImgUrl || '' } // 数据加载完成后初始化可选签名 initOptionalSignatures(); } catch (error) { console.error('数据加载失败:', error) } proxy?.$modal.closeLoading(); } const changeLanguage = (lang) => { localStorage.setItem('language', lang) locale.value = lang } // 监听allocateBillStatus变化,重新初始化可选签名 watch(() => formData.customer.allocateBillStatus, () => { initOptionalSignatures(); }, { immediate: false }) // 生命周期 onMounted(async () => { await loadData() }) const { proxy } = getCurrentInstance(); const closeSelectedTag = () => { proxy?.$tab.closePage(route); }; </script> <style scoped> .pdi-edit-container { max-width: 1200px; margin: 20px auto; padding: 20px; } .submit-btn { margin-top: 30px; text-align: center; } </style> ------------------ <template> <el-card class="inspection-items"> <h2>{{$t('synthesize.inspectionItem')}}</h2> <div v-for="(item, index) in items" :key="index" class="inspection-item"> <el-form :model="item" label-width="auto"> <div class="form-item-container"> <el-form-item :label="$t(item.name)" class="radio-group-item"> <el-radio-group v-model="item.selected" :disabled="!isNotCheck"> <el-radio value="0">{{$t('inspectionManagement.normal')}}</el-radio> <el-radio value="1">{{$t('inspectionManagement.abnormal')}}</el-radio> </el-radio-group> </el-form-item> <el-form-item v-if="item.selected !== '0'" :label="$t('commonFields.remarks')" class="remark-item" > <el-input v-model="item.comment" :placeholder="$t('commonFields.remarks')" :disabled="!isNotCheck" /> </el-form-item> </div> </el-form> </div> </el-card> </template> <script> export default { props: { items: { type: Array, required: true }, isNotCheck: false } }; </script> <style scoped> .inspection-items { margin-bottom: 20px; } .inspection-item { margin-bottom: 15px; } /* 新增移动端适配 */ @media screen and (max-width: 768px) { .inspection-item :deep(.el-form-item) { flex-direction: column; align-items: flex-start; } .inspection-item :deep(.el-form-item__label) { width: 100% !important; text-align: left; margin-bottom: 8px; padding-right: 0; float: none; } .inspection-item :deep(.el-form-item__content) { width: 100%; margin-left: 0 !important; } .radio-group-item :deep(.el-radio-group) { display: flex; flex-direction: column; gap: 8px; } .radio-group-item :deep(.el-radio) { margin-right: 0; } .remark-item :deep(.el-input) { width: 100%; } } /* 优化间距 */ .form-item-container { display: flex; flex-direction: column; gap: 12px; } .inspection-item { margin-bottom: 20px; padding: 12px; background: #f8f9fa; border-radius: 8px; } </style> 这里的检查项是怎么出来的
最新发布
08-16
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值