Commit b8642b44 authored by 张烨's avatar 张烨
parents 4fbf5765 2dc0063d
import React, { useEffect, useState, useRef } from 'react';
import { Switch, Button, Message, Spin, Modal } from 'antd';
// import axios from 'axios';
import BaseForm from '@/components/BaseForm/index';
import { getApkNameAndDate } from '@/services/appConfig/api';
import { getApkNameAndDate, SaveMobileApk } from '@/services/appConfig/api';
import styles from './VersionPublish.less';
// const JSON_BASE = `${
// location.origin
// }/cityinterface/rest/services/filedownload.svc/download/BufFile/Mobile/APK/`;
export default () => {
const items = [
{
......@@ -41,29 +46,51 @@ export default () => {
],
formType: 'SINGLE_RADIO',
},
{
label: 'apk上传',
dataIndex: 'file',
rules: [
{
required: true,
message: '请上传对应的apk',
},
],
formType: 'IMGSHOP',
},
];
const formEntity = useRef(null);
const fileEntity = useRef(null);
const [loading, setLoading] = useState(true); // 显示请求的loading
const [showModal, setShowModal] = useState(false); // 显示更新的modal
const [fileData, setFileData] = useState({}); // 获取到的包名和更新时间
const [file, setFile] = useState({}); // 上传的文件
const [fileSuccess, setFileSuccess] = useState(false); // 本地文件是否成功
const [progress, setProgress] = useState(false); // 是否正在保存
// const uploadProps = {
// name: 'file',
// action: `${window.location.origin}${PUBLISH_SERVICE}/FileCenter/UploadSingleFile`,
// headers: {
// Authorization: 'Bearer ' + localStorage.getItem('token') || '',
// },
// onChange(info) {
// console.log(info)
// setFile(info.file);
// },
// };
const submitForm = () => {
console.log(formEntity);
const { validateFields } = formEntity.current;
validateFields()
.then(values => {
console.log(values);
const { describe, forceUpdate } = values;
const formData = new FormData();
formData.set('description', describe);
formData.set('isRefresh', !!forceUpdate);
formData.set('file', file);
setProgress(true);
SaveMobileApk(formData).then(res => {
console.log(res);
setProgress(false);
if (Number(res.code) === 200) {
Message.success('更新成功');
setShowModal(false);
init();
} else {
Message.error(res.msg);
}
});
})
.catch(res => {
const { errorFields, values } = res;
......@@ -75,22 +102,41 @@ export default () => {
formEntity.current = form;
};
useEffect(() => {
const handleFileChange = e => {
console.log(e.target.files);
setFile(e.target.files[0]);
setFileSuccess(true);
};
const handleUpload = () => {
fileEntity.current.click();
};
const init = () => {
getApkNameAndDate({})
.then(res => {
console.log(res);
const message = res.ResultMessage || '';
const [fileName, updateTime] = message.split(',');
const [fileName = '', updateTime] = message.split(',');
setFileData({
fileName,
updateTime,
});
setLoading(false);
// const index = fileName.lastIndexOf('.');
// axios
// .get(`${JSON_BASE}${fileName.slice(0, index)}.json`, {})
// .then(res => {
// console.log(res);
// });
})
.catch(err => {
Message.error(err);
setLoading(false);
});
};
useEffect(() => {
init();
}, []);
return (
......@@ -112,8 +158,8 @@ export default () => {
<div className={styles.row}>
<div className={styles.label}>下载地址:</div>
<div className="value">
<a href="https://example.com" target="_blank">
https://example.com
<a href="/MobileGCK/getApk" target="_blank">
{`/MobileGCK/getApk`}
</a>
</div>
</div>
......@@ -143,6 +189,27 @@ export default () => {
onOk={submitForm}
>
<BaseForm items={items} getForm={handleGetForm} />
<div className={styles.row}>
<div className={`${styles.label} ${styles.required}`}>
apk文件:
</div>
<input
ref={f => {
fileEntity.current = f;
}}
className={styles['file-item']}
type="file"
onChange={handleFileChange}
/>
<Button type="primary" onClick={handleUpload}>
{fileSuccess ? '上传成功' : '开始上传'}
</Button>
</div>
{progress && (
<div className={styles.loadingBox}>
<Spin />
</div>
)}
</Modal>
)}
</div>
......
......@@ -19,6 +19,44 @@
}
.label {
width: 100px;
display: flex;
align-items: center;
width: 80px;
flex-shrink: 0;
text-align: right;
color: rgba(0, 0, 0, 0.85);
font-size: 14px;
}
.required {
&::before {
display: inline-block;
margin-right: 4px;
color: #ff4d4f;
font-size: 14px;
font-family: SimSun, sans-serif;
line-height: 1;
content: '*';
}
}
.file-item {
display: none;
}
.ant-form-item:last-child {
margin-bottom: 0;
}
.loadingBox {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
background-color: rgba(0, 0, 0, 0.5);
z-index: 1000;
}
\ No newline at end of file
......@@ -1335,7 +1335,7 @@ const UserManage = () => {
}}
okText="确认"
cancelText="取消"
width="960px"
width="920px"
>
<Spin spinning={loading} tip="loading">
<Tabs defaultActiveKey="1" style={{ marginTop: '-16px' }}>
......
......@@ -107,6 +107,7 @@
padding-top: 6px;
.ant-tree-switcher{
line-height: 1;
margin-right: 0px !important;
color:#1890FF;
.ant-tree-switcher-line-icon{
margin-left: 5px;
......@@ -182,4 +183,8 @@
line-height: 1;
color:#1890FF;
}
.ant-checkbox-group .ant-checkbox-group-item {
margin-right: 0px !important;
min-width: 204px !important;
}
}
\ No newline at end of file
......@@ -19,6 +19,7 @@
.ant-tree-iconEle{
display: flex;
align-items: center;
width: 18px;
}
}
}
......@@ -63,6 +64,7 @@
.ant-tree-switcher{
display: flex;
align-items: center;
margin-right: -8px;
// color:#1890FF;
.ant-tree-switcher-line-icon{
// margin-left: 5px;
......
......@@ -107,3 +107,6 @@ export const getApkNameAndDate = params =>
`/Cityinterface/Services/CityServer_MobileBusiness/REST/BaseREST.svc/AppModifyTime`,
params,
);
// 上传apk版本信息以及apk包的接口
export const SaveMobileApk = params =>
post(`/Publish/OMS/FileCenter/SaveMobileApk`, params);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment