peng.peng
2 years ago
20 changed files with 707 additions and 520 deletions
@ -1,78 +1,253 @@ |
|||||
'use strict'; |
'use strict'; |
||||
|
const { Pool } = require('pg'); |
||||
|
const moment = require('moment') |
||||
|
|
||||
|
|
||||
const latestMetadata = require('../../controllers/latestMetadata'); |
const latestMetadata = require('../../controllers/latestMetadata'); |
||||
|
|
||||
module.exports = function (app, router, opts) { |
module.exports = function (app, router, opts) { |
||||
app.fs.api.logAttr['GET/resource-catalog'] = { content: '获取资源目录', visible: false }; |
app.fs.api.logAttr['GET/resource-catalog'] = { content: '获取资源目录', visible: false }; |
||||
router.get('/resource-catalog', latestMetadata.getResourceCatalog); |
router.get('/resource-catalog', latestMetadata.getResourceCatalog); |
||||
|
|
||||
app.fs.api.logAttr['POST/resource-catalog'] = { content: '新建资源目录', visible: true }; |
|
||||
router.post('/resource-catalog', latestMetadata.postResourceCatalog); |
|
||||
|
|
||||
app.fs.api.logAttr['PUT/resource-catalog/:id'] = { content: '修改资源目录', visible: true }; |
|
||||
router.put('/resource-catalog/:id', latestMetadata.putResourceCatalog); |
|
||||
|
|
||||
app.fs.api.logAttr['DEL/resource-catalog/:id'] = { content: '删除资源目录', visible: true }; |
|
||||
router.delete('/resource-catalog/:id', latestMetadata.delResourceCatalog); |
|
||||
|
|
||||
app.fs.api.logAttr['GET/metadata/databases'] = { content: '获取库表元数据列表', visible: false }; |
|
||||
router.get('/metadata/databases', latestMetadata.getMetadataDatabases); |
|
||||
|
|
||||
app.fs.api.logAttr['GET/metadata/files'] = { content: '获取文件元数据列表', visible: false }; |
|
||||
router.get('/metadata/files', latestMetadata.getMetadataFiles); |
|
||||
|
|
||||
app.fs.api.logAttr['GET/metadata/restapis'] = { content: '获取接口元数据列表', visible: false }; |
|
||||
router.get('/metadata/restapis', latestMetadata.getMetadataRestapis); |
|
||||
|
|
||||
app.fs.api.logAttr['GET/metadata/models'] = { content: '获取元数据模型', visible: false }; |
|
||||
router.get('/metadata/models', latestMetadata.getMetadataModels); |
|
||||
|
|
||||
app.fs.api.logAttr['POST/metadata/databases'] = { content: '新建库表元数据', visible: true }; |
|
||||
router.post('/metadata/databases', latestMetadata.postMetadataDatabases); |
|
||||
|
|
||||
app.fs.api.logAttr['PUT/metadata/databases/:id'] = { content: '修改库表元数据', visible: true }; |
|
||||
router.put('/metadata/databases/:id', latestMetadata.putMetadataDatabases); |
|
||||
|
|
||||
app.fs.api.logAttr['DEL/metadata/databases/:id'] = { content: '删除库表元数据', visible: true }; |
|
||||
router.delete('/metadata/databases/:id', latestMetadata.delMetadataDatabases); |
|
||||
|
|
||||
app.fs.api.logAttr['GET/metadata/databases/:id'] = { content: '获取库表元数据基本信息', visible: false }; |
|
||||
router.get('/metadata/databases/:id', latestMetadata.getMetadataDatabasesById); |
|
||||
|
|
||||
app.fs.api.logAttr['POST/tag/metadata'] = { content: '打标元数据', visible: true }; |
|
||||
router.post('/tag/metadata', latestMetadata.postTagMetadata); |
|
||||
|
|
||||
app.fs.api.logAttr['GET/tag/metadata/:id'] = { content: '获取元数据已打标数据', visible: true }; |
|
||||
router.get('/tag/metadata/:id', latestMetadata.getTagMetadata); |
|
||||
|
|
||||
app.fs.api.logAttr['POST/resource-consumption/applications'] = { content: '申请资源', visible: true }; |
|
||||
router.post('/resource-consumption/applications', latestMetadata.postMetadataResourceApplications); |
|
||||
|
|
||||
app.fs.api.logAttr['GET/resource-consumption/applications'] = { content: '获取元数据资源申请记录', visible: true }; |
|
||||
router.get('/resource-consumption/applications', latestMetadata.getMetadataResourceApplications); |
|
||||
|
|
||||
app.fs.api.logAttr['POST/metadata/files'] = { content: '新建文件元数据', visible: true }; |
|
||||
router.post('/metadata/files', latestMetadata.postMetadataFiles); |
|
||||
|
|
||||
app.fs.api.logAttr['PUT/metadata/files/:id'] = { content: '修改文件元数据', visible: true }; |
app.fs.api.logAttr['POST/resource-catalog'] = { content: '新建资源目录', visible: true }; |
||||
router.put('/metadata/files/:id', latestMetadata.putMetadataFiles); |
router.post('/resource-catalog', latestMetadata.postResourceCatalog); |
||||
|
|
||||
app.fs.api.logAttr['DEL/metadata/files/:id'] = { content: '删除文件元数据', visible: true }; |
app.fs.api.logAttr['PUT/resource-catalog/:id'] = { content: '修改资源目录', visible: true }; |
||||
router.delete('/metadata/files/:id', latestMetadata.delMetadataFiles); |
router.put('/resource-catalog/:id', latestMetadata.putResourceCatalog); |
||||
|
|
||||
app.fs.api.logAttr['POST/metadata/restapis'] = { content: '新建接口元数据', visible: true }; |
|
||||
router.post('/metadata/restapis', latestMetadata.postMetadataRestapis); |
|
||||
|
|
||||
app.fs.api.logAttr['PUT/metadata/restapis/:id'] = { content: '修改接口元数据', visible: true }; |
app.fs.api.logAttr['DEL/resource-catalog/:id'] = { content: '删除资源目录', visible: true }; |
||||
router.put('/metadata/restapis/:id', latestMetadata.putMetadataRestapis); |
router.delete('/resource-catalog/:id', latestMetadata.delResourceCatalog); |
||||
|
|
||||
app.fs.api.logAttr['DEL/metadata/restapis/:id'] = { content: '删除接口元数据', visible: true }; |
app.fs.api.logAttr['GET/metadata/databases'] = { content: '获取库表元数据列表', visible: false }; |
||||
router.delete('/metadata/restapis/:id', latestMetadata.delMetadataRestapis); |
router.get('/metadata/databases', latestMetadata.getMetadataDatabases); |
||||
|
|
||||
app.fs.api.logAttr['GET/listStructuredData'] = { content: '获取对表的库与字段信息', visible: true }; |
app.fs.api.logAttr['GET/metadata/files'] = { content: '获取文件元数据列表', visible: false }; |
||||
router.get('/listStructuredData', latestMetadata.listStructuredData); |
router.get('/metadata/files', latestMetadata.getMetadataFiles); |
||||
|
|
||||
|
app.fs.api.logAttr['GET/metadata/restapis'] = { content: '获取接口元数据列表', visible: false }; |
||||
|
router.get('/metadata/restapis', latestMetadata.getMetadataRestapis); |
||||
|
|
||||
|
app.fs.api.logAttr['GET/metadata/models'] = { content: '获取元数据模型', visible: false }; |
||||
|
router.get('/metadata/models', latestMetadata.getMetadataModels); |
||||
|
|
||||
|
app.fs.api.logAttr['POST/metadata/databases'] = { content: '新建库表元数据', visible: true }; |
||||
|
router.post('/metadata/databases', latestMetadata.postMetadataDatabases); |
||||
|
|
||||
|
app.fs.api.logAttr['PUT/metadata/databases/:id'] = { content: '修改库表元数据', visible: true }; |
||||
|
router.put('/metadata/databases/:id', latestMetadata.putMetadataDatabases); |
||||
|
|
||||
|
app.fs.api.logAttr['DEL/metadata/databases/:id'] = { content: '删除库表元数据', visible: true }; |
||||
|
router.delete('/metadata/databases/:id', latestMetadata.delMetadataDatabases); |
||||
|
|
||||
|
app.fs.api.logAttr['GET/metadata/databases/:id'] = { content: '获取库表元数据基本信息', visible: false }; |
||||
|
router.get('/metadata/databases/:id', latestMetadata.getMetadataDatabasesById); |
||||
|
|
||||
|
app.fs.api.logAttr['POST/tag/metadata'] = { content: '打标元数据', visible: true }; |
||||
|
router.post('/tag/metadata', latestMetadata.postTagMetadata); |
||||
|
|
||||
|
app.fs.api.logAttr['GET/tag/metadata/:id'] = { content: '获取元数据已打标数据', visible: true }; |
||||
|
router.get('/tag/metadata/:id', latestMetadata.getTagMetadata); |
||||
|
|
||||
|
app.fs.api.logAttr['POST/resource-consumption/applications'] = { content: '申请资源', visible: true }; |
||||
|
router.post('/resource-consumption/applications', latestMetadata.postMetadataResourceApplications); |
||||
|
|
||||
|
app.fs.api.logAttr['GET/resource-consumption/applications'] = { content: '获取元数据资源申请记录', visible: true }; |
||||
|
router.get('/resource-consumption/applications', latestMetadata.getMetadataResourceApplications); |
||||
|
|
||||
|
app.fs.api.logAttr['POST/metadata/files'] = { content: '新建文件元数据', visible: true }; |
||||
|
router.post('/metadata/files', latestMetadata.postMetadataFiles); |
||||
|
|
||||
|
app.fs.api.logAttr['PUT/metadata/files/:id'] = { content: '修改文件元数据', visible: true }; |
||||
|
router.put('/metadata/files/:id', latestMetadata.putMetadataFiles); |
||||
|
|
||||
|
app.fs.api.logAttr['DEL/metadata/files/:id'] = { content: '删除文件元数据', visible: true }; |
||||
|
router.delete('/metadata/files/:id', latestMetadata.delMetadataFiles); |
||||
|
|
||||
|
app.fs.api.logAttr['POST/metadata/restapis'] = { content: '新建接口元数据', visible: true }; |
||||
|
router.post('/metadata/restapis', latestMetadata.postMetadataRestapis); |
||||
|
|
||||
|
app.fs.api.logAttr['PUT/metadata/restapis/:id'] = { content: '修改接口元数据', visible: true }; |
||||
|
router.put('/metadata/restapis/:id', latestMetadata.putMetadataRestapis); |
||||
|
|
||||
|
app.fs.api.logAttr['DEL/metadata/restapis/:id'] = { content: '删除接口元数据', visible: true }; |
||||
|
router.delete('/metadata/restapis/:id', latestMetadata.delMetadataRestapis); |
||||
|
|
||||
|
app.fs.api.logAttr['GET/listStructuredData'] = { content: '获取对表的库与字段信息', visible: true }; |
||||
|
router.get('/listStructuredData', latestMetadata.listStructuredData); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
app.fs.api.logAttr['POST/publishing/services'] = { content: '发布REST服务', visible: true }; |
||||
|
router.post('/publishing/services', async (ctx) => { |
||||
|
const data = ctx.request.body; |
||||
|
opts.exclude.push({ p: data.url, o: 'GET' }); |
||||
|
router.get(data.url, async (ctx) => { |
||||
|
let message = "获取库表元数据列表失败" |
||||
|
try { |
||||
|
const models = ctx.fs.dc.models; |
||||
|
const { token } = ctx.query; |
||||
|
|
||||
|
if (!token) { |
||||
|
message = '缺少访问令牌' |
||||
|
throw '' |
||||
|
} else { |
||||
|
let tokens |
||||
|
let findOne = await models.RestfulApi.findOne({ |
||||
|
where: { url: data.url, method: data.method }, |
||||
|
order: [["id", "desc"]], |
||||
|
include: [{ |
||||
|
model: models.ResourceConsumption, |
||||
|
}], |
||||
|
distinct: true |
||||
|
}); |
||||
|
|
||||
|
findOne && findOne.resourceConsumptions.map(s => { |
||||
|
if (!tokens && s.token) { |
||||
|
tokens = s.token |
||||
|
} |
||||
|
}) |
||||
|
if (tokens && tokens == token) { |
||||
|
if (findOne.enabled) { |
||||
|
const pool = new Pool({ |
||||
|
user: ctx.fs.dc.orm.config.username, |
||||
|
host: ctx.fs.dc.orm.config.host, |
||||
|
database: findOne.table, |
||||
|
password: ctx.fs.dc.orm.config.password, |
||||
|
port: ctx.fs.dc.orm.config.port, |
||||
|
}) |
||||
|
const client = await pool.connect() |
||||
|
const res = await client.query(findOne.conditions, []) |
||||
|
await models.RestfulApiRecord.create({ |
||||
|
restServiceId: findOne.id, |
||||
|
visitTime: moment().format('YYYY-MM-DD HH:mm:ss'), |
||||
|
token: tokens |
||||
|
}) |
||||
|
ctx.status = 200; |
||||
|
ctx.body = res; |
||||
|
} else { |
||||
|
message = '该REST服务被禁用' |
||||
|
throw '' |
||||
|
} |
||||
|
|
||||
|
} else { |
||||
|
message = '该服务令牌错误' |
||||
|
throw '' |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} catch (error) { |
||||
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
||||
|
ctx.status = 400; |
||||
|
ctx.body = { |
||||
|
"message": message |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
let message = "发布REST服务失败" |
||||
|
try { |
||||
|
const models = ctx.fs.dc.models; |
||||
|
const data = ctx.request.body; |
||||
|
const { method, url } = data |
||||
|
|
||||
|
|
||||
|
const postOne = await models.RestfulApi.findOne({ where: { method: method, url: url } }); |
||||
|
if (postOne) { |
||||
|
message = '路由和请求方式重复' |
||||
|
throw '' |
||||
|
} |
||||
|
|
||||
|
await models.RestfulApi.create(data) |
||||
|
|
||||
|
ctx.body = { message: '发布REST服务成功' } |
||||
|
ctx.status = 200; |
||||
|
|
||||
|
} catch (error) { |
||||
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
||||
|
ctx.status = 400; |
||||
|
ctx.body = { |
||||
|
"message": message |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
async function release (apps, opts) { |
||||
|
|
||||
|
const models = apps.fs.dc.models; |
||||
|
|
||||
|
const list = await models.RestfulApi.findAll({ |
||||
|
order: [["id", "desc"]], |
||||
|
include: [{ |
||||
|
model: models.ResourceConsumption, |
||||
|
}], |
||||
|
distinct: true |
||||
|
}) || [] |
||||
|
list.map(v => { |
||||
|
|
||||
|
opts.exclude.push({ p: v.url, o: 'GET' }); |
||||
|
router.get(v.url, async (ctx) => { |
||||
|
let message = "获取库表元数据列表失败" |
||||
|
try { |
||||
|
const { token } = ctx.query; |
||||
|
|
||||
|
if (!token) { |
||||
|
message = '缺少访问令牌' |
||||
|
throw '' |
||||
|
} else { |
||||
|
let tokens |
||||
|
v.resourceConsumptions.map(s => { |
||||
|
if (!tokens && s.token) { |
||||
|
tokens = s.token |
||||
|
} |
||||
|
}) |
||||
|
if (tokens && tokens == token) { |
||||
|
if (v.enabled) { |
||||
|
const pool = new Pool({ |
||||
|
user: ctx.fs.dc.orm.config.username, |
||||
|
host: ctx.fs.dc.orm.config.host, |
||||
|
database: v.table, |
||||
|
password: ctx.fs.dc.orm.config.password, |
||||
|
port: ctx.fs.dc.orm.config.port, |
||||
|
}) |
||||
|
const client = await pool.connect() |
||||
|
const res = await client.query(v.conditions, []) |
||||
|
await models.RestfulApiRecord.create({ |
||||
|
restServiceId: v.id, |
||||
|
visitTime: moment().format('YYYY-MM-DD HH:mm:ss'), |
||||
|
token: tokens |
||||
|
}) |
||||
|
|
||||
|
ctx.status = 200; |
||||
|
ctx.body = res; |
||||
|
} else { |
||||
|
message = '该REST服务被禁用' |
||||
|
throw '' |
||||
|
} |
||||
|
|
||||
|
} else { |
||||
|
message = '该服务令牌错误' |
||||
|
throw '' |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} catch (error) { |
||||
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
||||
|
ctx.status = 400; |
||||
|
ctx.body = { |
||||
|
"message": message |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
}) |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
release(app, opts) |
||||
|
|
||||
app.fs.api.logAttr['POST/publishing/services'] = { content: '发布REST服务', visible: true }; |
|
||||
router.post('/publishing/services', latestMetadata.publishingServices); |
|
||||
|
|
||||
}; |
}; |
@ -0,0 +1,88 @@ |
|||||
|
import React, { useEffect, useState } from 'react' |
||||
|
import { connect } from 'react-redux'; |
||||
|
import moment from 'moment'; |
||||
|
import { UploadLocal } from '$components'; |
||||
|
|
||||
|
|
||||
|
import { Tabs, Form, Input, DatePicker, Button, Modal, Select, Tag } from 'antd'; |
||||
|
|
||||
|
|
||||
|
function EditModal ({ loading, parent, user, actions, editData = {}, dispatch, close, success, viewDetails }) { |
||||
|
|
||||
|
const { dataService } = actions |
||||
|
const [lookFiold, setLookFiold] = useState([]); |
||||
|
const [interfaceName, setInterfaceName] = useState() |
||||
|
|
||||
|
useEffect(() => { |
||||
|
setInterfaceName(editData?.name); |
||||
|
dispatch(dataService.getLookField({ table: editData?.table, fields: editData?.fields })).then(res => { |
||||
|
if (res.success) { |
||||
|
setLookFiold(res.payload.data) |
||||
|
} |
||||
|
}) |
||||
|
}, []) |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
return <> |
||||
|
<Modal title={viewDetails ? '查看REST服务详情' : "编辑REST服务"} open={true} width={600} |
||||
|
onOk={e => { |
||||
|
if (viewDetails) { |
||||
|
close() |
||||
|
} else { |
||||
|
dispatch(dataService.postServiceManagement({ |
||||
|
id: editData.id, name: interfaceName, enabled: editData?.enabled |
||||
|
})).then(res => { |
||||
|
if (res.success) { |
||||
|
close() |
||||
|
success() |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
}} |
||||
|
onCancel={() => { |
||||
|
close() |
||||
|
}} |
||||
|
> |
||||
|
<div style={{ display: 'flex' }}>接口名称: |
||||
|
<Input style={{ width: 180 }} value={interfaceName} disabled={viewDetails} onChange={e => { |
||||
|
setInterfaceName(e.target.value) |
||||
|
}} /></div> |
||||
|
<div style={{ display: 'flex', margin: '10px 0' }}>接口路由: |
||||
|
<Input style={{ width: 180 }} value={editData?.url} disabled={true} /> |
||||
|
</div> |
||||
|
<div style={{ margin: '10px 0 10px 0' }} >接口类型: |
||||
|
<Input style={{ width: 180 }} value={editData?.method} disabled={true} /> |
||||
|
</div> |
||||
|
<div style={{ display: 'flex' }}>返回值: |
||||
|
<div style={{ display: 'flex', width: 400, flexDirection: 'column', alignItems: 'center' }}> |
||||
|
<div style={{ display: 'flex' }}> |
||||
|
<div style={{ width: 120, border: '1px solid #dcc', textAlign: 'center' }}>名称</div> |
||||
|
<div style={{ width: 120, border: '1px solid #dcc', textAlign: 'center' }}>意义</div> |
||||
|
<div style={{ width: 120, border: '1px solid #dcc', textAlign: 'center' }}>说明</div> |
||||
|
</div> |
||||
|
{lookFiold?.metadataDatabases?.map((s, index) => { |
||||
|
return <div key={'lookFiold' + index} style={{ display: 'flex' }}> |
||||
|
<div style={{ width: 120, border: '1px solid #dcc', textAlign: 'center' }}>{s.code}</div> |
||||
|
<div style={{ width: 120, border: '1px solid #dcc', textAlign: 'center' }}>{s.name}</div> |
||||
|
<div style={{ width: 120, border: '1px solid #dcc', textAlign: 'center' }}>{s.description}</div> |
||||
|
</div> |
||||
|
})} |
||||
|
</div> |
||||
|
</div> |
||||
|
</Modal > |
||||
|
|
||||
|
</> |
||||
|
} |
||||
|
function mapStateToProps (state) { |
||||
|
const { global, auth, resourceCatalog } = state; |
||||
|
return { |
||||
|
user: auth.user, |
||||
|
actions: global.actions, |
||||
|
clientHeight: global.clientHeight, |
||||
|
// resourceCatalog: resourceCatalog?.data || [],
|
||||
|
// isRequesting: resourceCatalog.isRequesting
|
||||
|
}; |
||||
|
} |
||||
|
export default connect(mapStateToProps)(EditModal) |
@ -1,118 +0,0 @@ |
|||||
import React, { useEffect, useState } from 'react' |
|
||||
import { connect } from 'react-redux'; |
|
||||
import moment from 'moment'; |
|
||||
import { UploadLocal } from '$components'; |
|
||||
|
|
||||
|
|
||||
import { Tabs, Form, Input, DatePicker, Button, Modal, Select, Tag } from 'antd'; |
|
||||
|
|
||||
|
|
||||
function FileModal ({ loading, parent, user, actions, editData = {}, dispatch, close, success,remove }) { |
|
||||
|
|
||||
const { dataQuality } = actions |
|
||||
const [tabsKey, setTabsKey] = useState("stay") |
|
||||
const [query, setQuery] = useState({ page: 0, limit: 10 }); |
|
||||
const [proTableList, setProTableList] = useState({ rows: [], count: 0 }); |
|
||||
const [approve, setApprove] = useState() |
|
||||
|
|
||||
const [form] = Form.useForm(); |
|
||||
const [editUrl, setEditUrl] = useState([]); |
|
||||
useEffect(() => { |
|
||||
|
|
||||
}, []) |
|
||||
|
|
||||
|
|
||||
|
|
||||
const vsjunct = (params) => { |
|
||||
if (params.length) { |
|
||||
let appendix = [] |
|
||||
for (let p of params) { |
|
||||
appendix.push({ |
|
||||
fName: p.name, |
|
||||
size: p.size, |
|
||||
fileSize: p.size, |
|
||||
storageUrl: p.storageUrl,//必须有storageUrl
|
|
||||
}) |
|
||||
} |
|
||||
setEditUrl(appendix) |
|
||||
} else { |
|
||||
setEditUrl([]) |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
return <> |
|
||||
<Modal title="标准文档上传" open={true} width={600} |
|
||||
onOk={e => { |
|
||||
form.validateFields().then(v => { |
|
||||
dispatch(dataQuality.postStandardDocs({ |
|
||||
...v, |
|
||||
path: v?.files[0]?.url, docName: v?.files[0]?.name, |
|
||||
folder: parent || null, |
|
||||
})).then(res => { |
|
||||
if (res.success) { |
|
||||
close() |
|
||||
success() |
|
||||
} |
|
||||
}) |
|
||||
}) |
|
||||
}} |
|
||||
onCancel={() => { |
|
||||
if (form.getFieldValue('files') && form.getFieldValue('files').length) { |
|
||||
remove(form.getFieldValue('files')[0]?.url) |
|
||||
} |
|
||||
close() |
|
||||
}} |
|
||||
> |
|
||||
<Form |
|
||||
style={{ marginLeft: 20 }} |
|
||||
form={form} |
|
||||
onValuesChange={v => { |
|
||||
|
|
||||
}} |
|
||||
autoComplete="off" |
|
||||
labelCol={{ span: 4 }} wrapperCol={{ span: 20 }} |
|
||||
> |
|
||||
<Form.Item label="标准类型" name="standardType" rules={[{ required: true, message: '请选择标准类型' }]}> |
|
||||
<Select style={{ width: 200, }} allowClear |
|
||||
options={[{ value: '国家标准', label: '国家标准', }, { value: '行业标准', label: '行业标准', }, { value: '地方标准', label: '地方标准', },]} |
|
||||
/> |
|
||||
</Form.Item> |
|
||||
<Form.Item label="标签" name="tags" > |
|
||||
<Input allowClear placeholder='请输入标签' maxLength={50} style={{ width: 300, marginRight: 16 }} /> |
|
||||
</Form.Item> |
|
||||
<Form.Item |
|
||||
label='文件' |
|
||||
name='files' |
|
||||
key='files' |
|
||||
rules={[{ required: true, message: '文件不可为空' }]}> |
|
||||
<UploadLocal |
|
||||
// addNew={editData.add || !editData.record.files.length}
|
|
||||
isLocal={true} |
|
||||
maxFilesNum={1} |
|
||||
maxFileSize={40} |
|
||||
onChange={vsjunct} |
|
||||
fileTypes={["jpg", "png", "gif", "txt", "doc", "docx", "pdf", "xls", "xlsx", "zip", "rar"]} |
|
||||
value={editUrl} |
|
||||
// fileList={editData.record.files || []}
|
|
||||
/> |
|
||||
</Form.Item> |
|
||||
<Form.Item style={{ marginLeft: 42 }} key='tip'> |
|
||||
<Tag color="orange">文件大小不超过40MB,开放资源包含多个文件,建议将文件进行压缩,形成压缩包再上传</Tag> |
|
||||
<Tag color="orange">支持的文件格式:jpg,png,gif,txt,doc,docx,pdf,xsl,xlsx,zip,rar</Tag> |
|
||||
</Form.Item> |
|
||||
</Form> |
|
||||
</Modal > |
|
||||
|
|
||||
</> |
|
||||
} |
|
||||
function mapStateToProps (state) { |
|
||||
const { global, auth, resourceCatalog } = state; |
|
||||
return { |
|
||||
user: auth.user, |
|
||||
actions: global.actions, |
|
||||
clientHeight: global.clientHeight, |
|
||||
// resourceCatalog: resourceCatalog?.data || [],
|
|
||||
// isRequesting: resourceCatalog.isRequesting
|
|
||||
}; |
|
||||
} |
|
||||
export default connect(mapStateToProps)(FileModal) |
|
@ -1,66 +0,0 @@ |
|||||
import React, { useEffect, useState } from 'react' |
|
||||
import { connect } from 'react-redux'; |
|
||||
import moment from 'moment'; |
|
||||
import { v4 as uuidv4 } from 'uuid' |
|
||||
|
|
||||
import { Tabs, Form, Input, DatePicker, Button, Modal, Radio } from 'antd'; |
|
||||
|
|
||||
|
|
||||
function GroupModal ({ loading, parent, user, actions, dispatch, close, success, }) { |
|
||||
|
|
||||
const { dataQuality } = actions |
|
||||
|
|
||||
const [form] = Form.useForm(); |
|
||||
useEffect(() => { |
|
||||
|
|
||||
}, []) |
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
return <> |
|
||||
<Modal title="新建分组" open={true} |
|
||||
onOk={e => { |
|
||||
form.validateFields().then(v => { |
|
||||
dispatch(dataQuality.postStandardDocFolders({ |
|
||||
...v, |
|
||||
parent: parent || null, |
|
||||
})).then(res => { |
|
||||
if (res.success) { |
|
||||
close() |
|
||||
success() |
|
||||
} |
|
||||
}) |
|
||||
}) |
|
||||
}} |
|
||||
onCancel={() => { |
|
||||
close() |
|
||||
}} |
|
||||
> |
|
||||
<Form |
|
||||
style={{ marginLeft: 20 }} |
|
||||
form={form} |
|
||||
onValuesChange={v => { |
|
||||
|
|
||||
}} |
|
||||
autoComplete="off" |
|
||||
> |
|
||||
<Form.Item label="名称" name="name" rules={[{ required: true, message: '请输入分组名称,最多50字', max: 50 },]}> |
|
||||
<Input allowClear placeholder='请输入分组名称' style={{ width: 300, }} /> |
|
||||
</Form.Item> |
|
||||
</Form> |
|
||||
</Modal > |
|
||||
|
|
||||
</> |
|
||||
} |
|
||||
function mapStateToProps (state) { |
|
||||
const { global, auth, resourceCatalog } = state; |
|
||||
return { |
|
||||
user: auth.user, |
|
||||
actions: global.actions, |
|
||||
clientHeight: global.clientHeight, |
|
||||
// resourceCatalog: resourceCatalog?.data || [],
|
|
||||
// isRequesting: resourceCatalog.isRequesting
|
|
||||
}; |
|
||||
} |
|
||||
export default connect(mapStateToProps)(GroupModal) |
|
@ -0,0 +1,79 @@ |
|||||
|
import React, { useEffect, useState } from 'react'; |
||||
|
import { connect } from 'react-redux'; |
||||
|
import { Modal, Input, Form } from 'antd'; |
||||
|
const { TextArea } = Input; |
||||
|
const ResourceModal = (props) => { |
||||
|
const { actions, dispatch, success, close, editData, user } = props; |
||||
|
|
||||
|
const { dataService, metadataManagement } = actions |
||||
|
|
||||
|
const [form] = Form.useForm(); |
||||
|
useEffect(() => { |
||||
|
}, []); |
||||
|
const handleOk = () => { |
||||
|
form.validateFields().then(values => { |
||||
|
if (success) { |
||||
|
dispatch(metadataManagement.postMetadataResourceApplications({ |
||||
|
...values, |
||||
|
resourceType: '数据服务', |
||||
|
applyBy: user?.id, |
||||
|
approveState: '审批中', |
||||
|
restServiceId: editData?.id |
||||
|
})).then(res => { |
||||
|
if (res.success) { |
||||
|
success() |
||||
|
close() |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
const validatorNull = (rule, value, getFieldValue, validateFields, label) => { |
||||
|
if (!value || !value.trim().length) { |
||||
|
return Promise.reject(new Error(`${label}不可空字符串`)); |
||||
|
} |
||||
|
return Promise.resolve(); |
||||
|
} |
||||
|
return ( |
||||
|
<Modal title={'申请资源'} open={true} destroyOnClose |
||||
|
okText='确定' width={800} |
||||
|
onOk={() => handleOk(null)} |
||||
|
onCancel={()=>close()}> |
||||
|
<Form form={form} labelCol={{ span: 6 }} wrapperCol={{ span: 18 }} initialValues={editData.record || {}}> |
||||
|
<Form.Item |
||||
|
label='资源名称' |
||||
|
name='resourceName' |
||||
|
rules={[{ required: true, message: '资源名称不可空' }]}> |
||||
|
<Input style={{ width: '90%' }} /> |
||||
|
</Form.Item> |
||||
|
<Form.Item |
||||
|
label='申请人' |
||||
|
name='applyByName' |
||||
|
rules={[{ required: true, message: '申请人不可空' }]}> |
||||
|
<Input style={{ width: '90%' }} /> |
||||
|
</Form.Item> |
||||
|
<Form.Item |
||||
|
label='需求描述' |
||||
|
name='requirements' |
||||
|
rules={[{ required: true, message: '' }, { max: 255, message: `需求描述不超过255个字符` }, |
||||
|
({ getFieldValue, validateFields }) => ({ |
||||
|
validator (_, value) { return validatorNull(_, value, getFieldValue, validateFields, '需求描述') } |
||||
|
})]}> |
||||
|
<TextArea rows={4} style={{ width: '90%' }} placeholder={`请输入需求描述`} /> |
||||
|
</Form.Item> |
||||
|
</Form> |
||||
|
</Modal > |
||||
|
) |
||||
|
} |
||||
|
|
||||
|
function mapStateToProps (state) { |
||||
|
const { global, auth, resourceCatalog } = state; |
||||
|
return { |
||||
|
user: auth.user, |
||||
|
actions: global.actions, |
||||
|
clientHeight: global.clientHeight, |
||||
|
// resourceCatalog: resourceCatalog?.data || [],
|
||||
|
// isRequesting: resourceCatalog.isRequesting
|
||||
|
}; |
||||
|
} |
||||
|
export default connect(mapStateToProps)(ResourceModal) |
@ -1,104 +0,0 @@ |
|||||
import React, { useEffect, useState } from 'react' |
|
||||
import { connect } from 'react-redux'; |
|
||||
import moment from 'moment'; |
|
||||
import { v4 as uuidv4 } from 'uuid' |
|
||||
|
|
||||
import { Tabs, Form, Input, DatePicker, Button, Modal, Radio, Select, TreeSelect } from 'antd'; |
|
||||
const { TextArea } = Input; |
|
||||
const { Option, OptGroup } = Select; |
|
||||
function RuleModal ({ loading, parent, user, actions, dispatch, close, success, treeList, editData }) { |
|
||||
|
|
||||
const { dataQuality } = actions |
|
||||
const [tabsKey, setTabsKey] = useState("stay") |
|
||||
const [query, setQuery] = useState({ page: 0, limit: 10 }); |
|
||||
const [proTableList, setProTableList] = useState({ rows: [], count: 0 }); |
|
||||
const [approve, setApprove] = useState() |
|
||||
|
|
||||
const [form] = Form.useForm(); |
|
||||
useEffect(() => { |
|
||||
|
|
||||
}, []) |
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
return <> |
|
||||
<Modal title={editData?.id ? '编辑业务规则' : "新建业务规则"} open={true} |
|
||||
onOk={e => { |
|
||||
form.validateFields().then(v => { |
|
||||
// console.log(v);
|
|
||||
dispatch(dataQuality.postBusinessRules({ |
|
||||
...v, id: editData?.id |
|
||||
})).then(res => { |
|
||||
if (res.success) { |
|
||||
close() |
|
||||
success() |
|
||||
} |
|
||||
}) |
|
||||
}) |
|
||||
}} |
|
||||
onCancel={() => { |
|
||||
close() |
|
||||
}} |
|
||||
> |
|
||||
<Form |
|
||||
style={{ marginLeft: 20 }} |
|
||||
form={form} |
|
||||
onValuesChange={v => { |
|
||||
|
|
||||
}} |
|
||||
autoComplete="off" |
|
||||
labelCol={{ span: 4 }} wrapperCol={{ span: 20 }} |
|
||||
> |
|
||||
<Form.Item label="名称" name="name" initialValue={editData?.name} rules={[{ required: true, message: '请输入分组名称,最多50字', max: 50}]}> |
|
||||
<Input allowClear placeholder='请输入分组名称' style={{ width: 300 }} /> |
|
||||
</Form.Item> |
|
||||
<Form.Item label="描述" name="description" initialValue={editData?.description} rules={[{ required: true, message: '请输入分组名称' }]}> |
|
||||
<TextArea allowClear autoSize={{ minRows: 2 }} placeholder='描述' style={{ width: 300, }} /> |
|
||||
</Form.Item> |
|
||||
<Form.Item label="问题类型" name="problemType" initialValue={editData?.problemType} rules={[{ required: true, message: '请输入分组名称' }]}> |
|
||||
<Select style={{ width: 300, }} placeholder='问题类型' |
|
||||
options={[{ value: '一致性', label: '一致性', }, { value: '准确性', label: '准确性', }, { value: '完整性', label: '完整性', }, { value: '有效性', label: '有效性', }, { value: '及时性', label: '及时性', }, { value: '规范性', label: '规范性', },]} |
|
||||
/> |
|
||||
</Form.Item> |
|
||||
<Form.Item label="问题级别" name="problemLevel" initialValue={editData?.problemLevel} rules={[{ required: true, message: '请输入分组名称' }]}> |
|
||||
<Select style={{ width: 300, }} placeholder='问题级别' |
|
||||
options={[{ value: '一般', label: '一般', }, { value: '重要', label: '重要', }, { value: '严重', label: '严重', },]} |
|
||||
/> |
|
||||
</Form.Item> |
|
||||
<Form.Item label="制定依据" name="ruleBasis" initialValue={editData?.ruleBasis} rules={[{ required: true, message: '请输入分组名称' }]}> |
|
||||
<TreeSelect |
|
||||
showSearch |
|
||||
style={{ |
|
||||
width: 300, |
|
||||
}} |
|
||||
// value={}
|
|
||||
dropdownStyle={{ |
|
||||
maxHeight: 300, |
|
||||
overflow: 'auto', |
|
||||
}} |
|
||||
placeholder="" |
|
||||
allowClear |
|
||||
treeDefaultExpandAll |
|
||||
// onChange={onChange}
|
|
||||
treeData={treeList || []} |
|
||||
/> |
|
||||
</Form.Item> |
|
||||
</Form> |
|
||||
</Modal > |
|
||||
|
|
||||
</> |
|
||||
} |
|
||||
function mapStateToProps (state) { |
|
||||
const { global, auth, resourceCatalog } = state; |
|
||||
return { |
|
||||
user: auth.user, |
|
||||
actions: global.actions, |
|
||||
clientHeight: global.clientHeight, |
|
||||
// resourceCatalog: resourceCatalog?.data || [],
|
|
||||
// isRequesting: resourceCatalog.isRequesting
|
|
||||
}; |
|
||||
} |
|
||||
export default connect(mapStateToProps)(RuleModal) |
|
Loading…
Reference in new issue