2025-08-25 10:08:30 +08:00
|
|
|
|
import React, { useEffect, useState } from 'react'
|
|
|
|
|
|
import { message, Checkbox, Radio } from "antd/lib/index";
|
|
|
|
|
|
import { getPropertyData, guid, extendInclude, extendRule, getDataFieldValue, setDataFieldValue, initFilter, empty, onBeforeSaveHandleRecordLog, Format } from "../../utils/common";
|
|
|
|
|
|
import { connect } from 'dva';
|
|
|
|
|
|
import moment from 'moment';
|
|
|
|
|
|
import config from "../../config.js"
|
|
|
|
|
|
import { Button, Row, Col, Form, Input, Upload, Icon, Modal, Spin } from 'antd';
|
|
|
|
|
|
import storage from '../../utils/storage'
|
|
|
|
|
|
import MD5 from "js-md5"
|
|
|
|
|
|
// import PlvVideoUpload from "@polyv/vod-upload-js-sdk/vod-upload-js-sdk.min.js";
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @return {string}
|
|
|
|
|
|
*/
|
|
|
|
|
|
// 编辑 事故事件调查结果填报
|
|
|
|
|
|
export default {
|
|
|
|
|
|
|
|
|
|
|
|
onBeforeEdit: ({ isNew, login, stateData, data, setFieldEditable, getFieldValue, dispatch, ListCheckRiskArea, setFieldValueByBatch, setFieldVisible, setFieldValue }) => {
|
|
|
|
|
|
if (!isNew) {
|
|
|
|
|
|
setFieldEditable("CODE", false)
|
|
|
|
|
|
if (stateData.NAME != undefined && stateData.NAME != null && stateData.ISLOCAL == true && stateData.NAME.length > 0) {
|
|
|
|
|
|
setFieldEditable("Nav_Files", false)
|
|
|
|
|
|
}
|
|
|
|
|
|
if (stateData.ISLOCAL == false) {
|
|
|
|
|
|
setFieldEditable("Nav_Files", false)
|
|
|
|
|
|
}
|
|
|
|
|
|
// if (stateData.Nav_Files) {
|
|
|
|
|
|
// getFieldValue("Nav_Files", stateData.Nav_Files)
|
|
|
|
|
|
// }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-26 13:49:45 +08:00
|
|
|
|
// //import PlvVideoUpload from "@polyv/vod-upload-js-sdk/vod-upload-js-sdk.min.js"; //此处插入 如果直接导入 发布会报错
|
|
|
|
|
|
// const script = document.createElement('script');
|
|
|
|
|
|
// script.src = 'https://player.polyv.net/resp/vod-upload-js-sdk/latest/vod-upload-js-sdk.min.js';
|
|
|
|
|
|
// document.body.appendChild(script);
|
2025-08-25 10:08:30 +08:00
|
|
|
|
},
|
|
|
|
|
|
handleRenderHeadControl(params) {
|
2025-12-26 13:49:45 +08:00
|
|
|
|
if (params.colConfig.field === 'Nav_Files') {
|
2025-08-25 10:08:30 +08:00
|
|
|
|
//重写 使只上传视频 并且控制按钮不可操作
|
|
|
|
|
|
const Tenant = storage('lacal').getItem('Tenant').val;
|
|
|
|
|
|
var isEditFile = true//默认显示编辑按钮
|
|
|
|
|
|
var isShowFile = false//默认文件显示
|
|
|
|
|
|
//如果显示 本地文件 isShowFile true isEditFile false
|
|
|
|
|
|
if (params.record.ISLOCAL == true && params.record.Nav_Files != null && params.record.Nav_Files.length > 0) {
|
|
|
|
|
|
isEditFile = false
|
|
|
|
|
|
isShowFile = true
|
|
|
|
|
|
}
|
|
|
|
|
|
// if (params.record.Nav_Files && params.record.Nav_Files.length > 0) {
|
|
|
|
|
|
// params.record['Files'] = params.record.Nav_Files
|
|
|
|
|
|
// }
|
|
|
|
|
|
//上传到本地服务器
|
|
|
|
|
|
const uploadSopProps = {
|
|
|
|
|
|
accept: '.flv,.avi,.mpg,.mp4,.wmv,.mov,.3gp,.asf',
|
|
|
|
|
|
name: 'file',
|
2025-12-26 13:49:45 +08:00
|
|
|
|
action: config.serviceHost('api/PF/File/UploadVideo'),//UploadFile 方法分开 以免影响
|
2025-08-25 10:08:30 +08:00
|
|
|
|
data: { OrgId: params.login.OrgId },
|
|
|
|
|
|
fileList: params.record['Files'],//Files Nav_Files
|
|
|
|
|
|
headers: {
|
|
|
|
|
|
Tenant: Tenant,
|
2025-12-26 13:49:45 +08:00
|
|
|
|
PBN: "VIDEO"
|
2025-08-25 10:08:30 +08:00
|
|
|
|
},
|
|
|
|
|
|
onChange(info) {
|
|
|
|
|
|
params.record['Files'] = [...info.fileList];
|
|
|
|
|
|
// params.saveRowRecord(params.record);
|
|
|
|
|
|
// params.record.NAME = info.file.name;
|
|
|
|
|
|
// if (info.file.status !== 'uploading') {
|
|
|
|
|
|
// }
|
|
|
|
|
|
if (info.file.status === 'removed') {
|
|
|
|
|
|
if (info.file.response && info.file.response.file) {
|
|
|
|
|
|
info.file.response.file.IS_DELETED = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (info.file.status === 'done') {
|
|
|
|
|
|
let uploadFiles = [...info.fileList]
|
|
|
|
|
|
if (uploadFiles) {
|
|
|
|
|
|
let navFiles = [];
|
|
|
|
|
|
var IMG_FILE_ID = ''
|
|
|
|
|
|
var FILE_PATH = ''
|
|
|
|
|
|
uploadFiles.forEach(t => {
|
|
|
|
|
|
if (t.response) {
|
2025-12-26 13:49:45 +08:00
|
|
|
|
if (t.response.IsSuccessful) {
|
|
|
|
|
|
//附件信息赋值给数据库对象,多个附件需要遍历附件信息
|
|
|
|
|
|
IMG_FILE_ID = t.response.Data.imgFileID
|
|
|
|
|
|
FILE_PATH = t.response.Data.imgFilePath
|
|
|
|
|
|
navFiles.push({
|
|
|
|
|
|
FILE_DB_ID: params.record.ID,
|
|
|
|
|
|
ORG_ID: params.record.ORG_ID,
|
|
|
|
|
|
IMG_FILE_ID: IMG_FILE_ID, //附件表文件名称
|
|
|
|
|
|
ID: t.response.file ? t.uid : guid()//标记ID
|
|
|
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
|
|
|
message.error(`${info.file.name} 上传失败!报错详情:` + t.response.ErrorMessage);
|
|
|
|
|
|
}
|
2025-08-25 10:08:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const temps = [];
|
|
|
|
|
|
temps.push({ field: 'Nav_Files', value: navFiles })
|
|
|
|
|
|
temps.push({ field: 'IMG_FILE_ID', value: IMG_FILE_ID })
|
|
|
|
|
|
temps.push({ field: 'FILE_PATH', value: FILE_PATH })
|
|
|
|
|
|
temps.push({ field: 'NAME', value: info.file.name })
|
|
|
|
|
|
params.setFieldValueByBatch(temps);
|
2025-12-26 13:49:45 +08:00
|
|
|
|
// params.setFieldEditable("NAME", false)//让可修改
|
2025-08-25 10:08:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
// params.setFieldEditable("ISLOCAL", false)
|
|
|
|
|
|
message.success(`${info.file.name} 上传成功`);
|
|
|
|
|
|
} else if (info.file.status === 'error') {
|
|
|
|
|
|
message.error(`${info.file.name} 上传失败!`);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (info.file.status != 'done') {
|
|
|
|
|
|
//上传成功回调不处理数据赋值
|
|
|
|
|
|
const temps2 = [];
|
|
|
|
|
|
temps2.push({ field: 'Nav_Files', value: params.record['Files'] })
|
|
|
|
|
|
temps2.push({ field: 'NAME', value: info.file.name })
|
|
|
|
|
|
params.setFieldValueByBatch(temps2);
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
};
|
|
|
|
|
|
return <>
|
|
|
|
|
|
<div className="ant-col ant-col-lg-12 ant-col-xxl-8">
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<div className="ant-col ant-col-24 ant-form-item-label">
|
|
|
|
|
|
<label>
|
2025-12-26 13:49:45 +08:00
|
|
|
|
<span>上传本地视频</span>
|
2025-08-25 10:08:30 +08:00
|
|
|
|
</label>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div className="ant-col ant-col-18 ant-form-item-control-wrapper">
|
|
|
|
|
|
{/* {isShowFile && <Attachment disabled={false} value={"附件上传"} colConfig={params.colConfig} record={params.record} />} */}
|
|
|
|
|
|
{isShowFile && <Input type="file" style={{ height: '39px' }} key="keyI1" disabled={true} />}
|
|
|
|
|
|
{isShowFile && <a key="keyA21" href={config.picServerHost + params.record.FILE_PATH} target="_blank">{params.record.NAME}</a>}
|
|
|
|
|
|
{isEditFile && <Upload {...uploadSopProps}>
|
|
|
|
|
|
<Button disabled={(params.record.NAME == null || params.record.NAME.length == 0) ? false : true}>
|
2025-12-26 13:49:45 +08:00
|
|
|
|
<Icon type="upload" />上传视频(如果视频较大,请耐心等待上传完毕再保存)
|
2025-08-25 10:08:30 +08:00
|
|
|
|
</Button>
|
|
|
|
|
|
</Upload>}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</>
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
}
|