Commit 56ac7b78 by zhuxiaomei

app添加附件和预览

parent b9ba05d9
NODE_ENV=production NODE_ENV=production
VUE_APP_BASE_URL=http://api.dev.patzn.com:7000 VUE_APP_BASE_URL=http://192.168.0.155:7000
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
"axios": "^0.20.0", "axios": "^0.20.0",
"core-js": "^3.6.5", "core-js": "^3.6.5",
"dateformat": "^3.0.3", "dateformat": "^3.0.3",
"store2": "^2.7.0",
"vant": "^2.10.9", "vant": "^2.10.9",
"view-design": "^4.4.0", "view-design": "^4.4.0",
"vue": "^2.6.11", "vue": "^2.6.11",
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
/> />
<link rel="icon" href="<%= BASE_URL %>favicon.ico"> <link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>双随机抽样</title> <title>双随机抽样</title>
<script src="<%= BASE_URL %>js/mui.min.js"></script>
<script src="<%= BASE_URL %>js/back.js"></script>
</head> </head>
<body> <body>
<!--<noscript>--> <!--<noscript>-->
...@@ -17,7 +19,36 @@ ...@@ -17,7 +19,36 @@
<!--</noscript>--> <!--</noscript>-->
<div id="app"></div> <div id="app"></div>
<!-- built files will be auto injected --> <!-- built files will be auto injected -->
<script src="https://webapi.amap.com/maps?v=1.4.15&key=33d56f06483ab332151b14e85bbb8405"></script>
</body> </body>
<!-- 判断ios版本 -->
<script>
var str = navigator.userAgent.toLowerCase();
var ver = str.match(/cpu iphone os (.*?) like mac os/);
if (!ver) {//非IOS系统
// 引入fastclick文件
includeFastclickJsFile();
// alert('安卓')
} else {
// alert('ios')
console.log("你当前的Ios系统版本为:" + ver[1].replace(/_/g, "."));
if (parseInt(ver[1]) >= 11) {
//不必引入fastclick文件
} else {
// 引入fastclick文件
includeFastclickJsFile();
}
}
function includeFastclickJsFile() {
var oHead = document.getElementsByTagName('HEAD').item(0);
let fastclick = document.createElement("script");
fastclick.type = "text/javascript";
fastclick.src = "<%= BASE_URL %>/js/fastclick.js";
oHead.appendChild(fastclick);
}
</script>
<script src="https://webapi.amap.com/maps?v=1.4.15&key=33d56f06483ab332151b14e85bbb8405"></script>
</html> </html>
//取消浏览器的所有事件,使得active的样式在手机上正常生效
document.addEventListener('touchstart',function(){
return false;
},true);
document.addEventListener('plusready', function() {
var webview = plus.webview.currentWebview().setStyle({scrollIndicator:'none'});
plus.key.addEventListener('backbutton', function() {
webview.canBack(function(e) {
if(e.canBack) {
webview.back();
} else {
//webview.close(); //hide,quit
//plus.runtime.quit();
mui.plusReady(function() {
//首页返回键处理
//处理逻辑:1秒内,连续两次按返回键,则退出应用;
var first = null;
plus.key.addEventListener('backbutton', function() {
//首次按键,提示‘再按一次退出应用’
if (!first) {
first = new Date().getTime();
mui.toast('再按一次退出应用');
setTimeout(function() {
first = null;
}, 1000);
} else {
if (new Date().getTime() - first < 1500) {
plus.runtime.quit();
}
}
}, false);
});
}
})
});
// 关闭启动界面
plus.navigator.setStatusBarBackground('#00a0e9');
});
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
/**
* 配置文件
*/
export default {
service:'double-sampling',
webURL: process.env.process.env.VUE_APP_WEB_URL,
baseURL: process.env.process.env.VUE_APP_BASE_URL,
ssoURL: process.env.process.env.VUE_APP_SSO_URL,
}
...@@ -16,7 +16,18 @@ ...@@ -16,7 +16,18 @@
export default { export default {
name: "Index", name: "Index",
components: {}, components: {},
mounted() {
this._login()
},
methods: { methods: {
_login() {
if (this.$global.getToken) {
console.log('已登录')
} else {
//无权限的时候退出登录
this.$router.replace('/login');
}
},
_back() { _back() {
if (this.$route.meta.leftArrow !== false) { if (this.$route.meta.leftArrow !== false) {
this.$router.go(-1) this.$router.go(-1)
......
...@@ -69,12 +69,13 @@ ...@@ -69,12 +69,13 @@
}, },
methods: { methods: {
onSubmit(res) { onSubmit(res) {
console.log(res, 'login-info') // console.log(res, 'login-info')
this._login(res) this._login(res)
}, },
_login: async function (res) { _login: async function (res) {
let token = await sso.login(res) let token = await sso.login(res)
if (token) { if (token) {
console.log('token')
this.$global.setToken(token) this.$global.setToken(token)
if (this.checked) { if (this.checked) {
localStorage.setItem('username', this.formObj.username); localStorage.setItem('username', this.formObj.username);
...@@ -91,12 +92,14 @@ ...@@ -91,12 +92,14 @@
} }
this._getUserInfo(); this._getUserInfo();
} else { } else {
console.log('_inactivate')
//激活 //激活
this._inactivate(); this._inactivate();
} }
}, },
//获取用户信息 //获取用户信息
async _getUserInfo() { async _getUserInfo() {
console.log('_getUserInfo')
let user = await sysUser.getUserInfo(); let user = await sysUser.getUserInfo();
if (user) { if (user) {
this.$global.setLogin(user); this.$global.setLogin(user);
......
...@@ -383,6 +383,7 @@ ...@@ -383,6 +383,7 @@
</table-col> </table-col>
<table-col> <table-col>
<van-field <van-field
readonly
label-class="cus-field-class" label-class="cus-field-class"
label-width="50%" label-width="50%"
label-align="center" label-align="center"
......
...@@ -377,6 +377,7 @@ ...@@ -377,6 +377,7 @@
</table-col> </table-col>
<table-col> <table-col>
<van-field <van-field
readonly
label-class="cus-field-class" label-class="cus-field-class"
label-width="50%" label-width="50%"
label-align="center" label-align="center"
......
...@@ -19,9 +19,9 @@ ...@@ -19,9 +19,9 @@
</van-list> </van-list>
</van-pull-refresh> </van-pull-refresh>
</div> </div>
<div class="bottom-btn bottom-btn-two"> <div class="bottom-btn">
<van-button type="info" square @click="_goto('/sampling_list/file_upload')">添加附件</van-button> <van-button type="info" block @click="_goto('/sampling_list/file_upload')">添加附件</van-button>
<van-button type="primary" square @click="_uploadImg">添加图片</van-button> <!--<van-button type="primary" square @click="_uploadImg">添加图片</van-button>-->
</div> </div>
<van-image-preview v-model="showImg" :images="imgList"> <van-image-preview v-model="showImg" :images="imgList">
<!--<template #:index>第{{ index }}页</template>--> <!--<template #:index>第{{ index }}页</template>-->
...@@ -98,18 +98,13 @@ ...@@ -98,18 +98,13 @@
if (data.type.toLowerCase() === 'jpg' || data.type.toLowerCase() === 'png') { if (data.type.toLowerCase() === 'jpg' || data.type.toLowerCase() === 'png') {
this.showImg = true this.showImg = true
//预览图片 //预览图片
this.imgList[0] = this.$global.baseURL + '/drs/v1/sampling_summary_attachment/down?id=' + data.id; this.imgList[0] = this.$global.baseURL + '/drs/v1/sampling_summary_attachment/view?id=' + '&objectKey=' + data.objectKey;
console.log(this.imgList[0])
} else { } else {
//下载文件 //下载文件
let name = '';
if (data.remark === undefined) {
name = data.fileName;
} else {
name = data.remark;
}
this.$router.push({ this.$router.push({
path: '/sampling_list/file_down_load', path: '/sampling_list/file_download',
query: {fileName: name, id: data.id, ctime: data.ctime, remark: data.fileName} query: {fileName: data.fileName, id: data.id, ctime: data.ctime}
}) })
} }
}, },
...@@ -189,11 +184,12 @@ ...@@ -189,11 +184,12 @@
}, },
//上传 //上传
_submitImg(files) { _submitImg(files) {
var task = plus.uploader.createUpload(this.action, var task = plus.uploader.createUpload(this.action,
{method: "POST"}, {method: "POST"},
(t, status) => { //上传完成 (t, status) => { //上传完成
console.log(t, status) console.log(t, status)
this._search(); this._getData();
} }
); );
//单图片上传 //单图片上传
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
<div> <div>
<div style="margin:100px auto 10px auto;text-align: center"> <div style="margin:100px auto 10px auto;text-align: center">
<img src="../../../assets/file-down.png" height="100"> <img src="../../../assets/file-down.png" height="100">
<p style="margin:10px auto">{{name}}</p> <p style="margin:10px auto">{{fileName}}</p>
<p style="color:#aaa;"> {{ctime}}</p> <p style="color:#aaa;"> {{ctime}}</p>
</div> </div>
<div class="bottom-btn"> <div class="bottom-btn" style="padding: 20px">
<van-button block type="info" @click="_view">预览</van-button> <van-button block type="info" @click="_view">预览</van-button>
</div> </div>
...@@ -17,10 +17,9 @@ ...@@ -17,10 +17,9 @@
export default { export default {
data() { data() {
return { return {
name: '', fileName: '',
id: '', id: '',
ctime: '', ctime: '',
remark: ''
} }
}, },
mounted() { mounted() {
...@@ -28,12 +27,11 @@ ...@@ -28,12 +27,11 @@
}, },
methods: { methods: {
_getQuery() { _getQuery() {
this.name = this.$route.query.fileName; this.fileName = this.$route.query.fileName;
this.remark = this.$route.query.remark;
this.id = this.$route.query.id; this.id = this.$route.query.id;
this.ctime = this.$dateformat(parseInt(this.$route.query.ctime), 'yyyy/mm/dd'); this.ctime = this.$dateformat(this.$route.query.ctime,'yyyy/mm/dd');
}, },
//移动 //下载
_ok() { _ok() {
this.$toast.loading({ this.$toast.loading({
message: '下载中...', message: '下载中...',
...@@ -56,7 +54,7 @@ ...@@ -56,7 +54,7 @@
dtask.setRequestHeader('accessToken', localStorage.getItem('accessToken')); dtask.setRequestHeader('accessToken', localStorage.getItem('accessToken'));
dtask.start(); dtask.start();
}, },
//预览文档 //下载并预览文档
_view() { _view() {
//调用第三放程序打开指定文件(必须是本地路径) //调用第三放程序打开指定文件(必须是本地路径)
this.$toast.loading({ this.$toast.loading({
......
...@@ -17,5 +17,5 @@ export default [ ...@@ -17,5 +17,5 @@ export default [
{path: 'sampling_list_detail_net', component: SamplingListDetailNet, meta: {title: '抽样单详情-网络'}}, {path: 'sampling_list_detail_net', component: SamplingListDetailNet, meta: {title: '抽样单详情-网络'}},
{path: 'file', component: File, meta: {title: '附件'}}, {path: 'file', component: File, meta: {title: '附件'}},
{path: 'file_upload', component: FileUpload, meta: {title: '添加附件'}}, {path: 'file_upload', component: FileUpload, meta: {title: '添加附件'}},
{path: 'file_download', component: FileDownLoad, meta: {title: '下载附件'}}, {path: 'file_download', component: FileDownLoad, meta: {title: '预览附件'}},
] ]
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