Commit 51b9b2c8 by zhuxiaomei

附件

parent 52c4d8af
......@@ -2430,6 +2430,11 @@
"integrity": "sha1-3TeelPDbgxCwgpH51kwyCXZmF/0=",
"dev": true
},
"async-validator": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/async-validator/-/async-validator-3.4.0.tgz",
"integrity": "sha512-VrFk4eYiJAWKskEz115iiuCf9O0ftnMMPXrOFMqyzGH2KxO7YwncKyn/FgOOP+0MDHMfXL7gLExagCutaZGigA=="
},
"asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npm.taobao.org/asynckit/download/asynckit-0.4.0.tgz",
......@@ -2513,6 +2518,16 @@
"object.assign": "^4.1.0"
}
},
"babel-plugin-import": {
"version": "1.13.1",
"resolved": "https://registry.npmjs.org/babel-plugin-import/-/babel-plugin-import-1.13.1.tgz",
"integrity": "sha512-2Ohk36qvQAZr2sNXVwOgBFH7/ZQH0lL6igPj6lNIhk5t0uORneeAvHnohClCWbaogUhKGJxAiwbPhymZXPGQiQ==",
"dev": true,
"requires": {
"@babel/helper-module-imports": "^7.0.0",
"@babel/runtime": "^7.0.0"
}
},
"balanced-match": {
"version": "1.0.0",
"resolved": "https://registry.npm.taobao.org/balanced-match/download/balanced-match-1.0.0.tgz",
......@@ -2586,6 +2601,11 @@
"integrity": "sha1-3DQxT05nkxgJP8dgJyUl+UvyXBY=",
"dev": true
},
"batch-processor": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/batch-processor/-/batch-processor-1.0.0.tgz",
"integrity": "sha1-dclcMrdI4IUNEMKxaPa9vpiRrOg="
},
"bcrypt-pbkdf": {
"version": "1.0.2",
"resolved": "https://registry.npm.taobao.org/bcrypt-pbkdf/download/bcrypt-pbkdf-1.0.2.tgz",
......@@ -4577,6 +4597,14 @@
"integrity": "sha1-WL8XSZ3m7faX4UQgF9hWm84NMBo=",
"dev": true
},
"element-resize-detector": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/element-resize-detector/-/element-resize-detector-1.2.1.tgz",
"integrity": "sha512-BdFsPepnQr9fznNPF9nF4vQ457U/ZJXQDSNF1zBe7yaga8v9AdZf3/NElYxFdUh7SitSGt040QygiTo6dtatIw==",
"requires": {
"batch-processor": "1.0.0"
}
},
"elliptic": {
"version": "6.5.3",
"resolved": "https://registry.npm.taobao.org/elliptic/download/elliptic-6.5.3.tgz?cache=0&sync_timestamp=1592492844326&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Felliptic%2Fdownload%2Felliptic-6.5.3.tgz",
......@@ -6711,6 +6739,11 @@
}
}
},
"js-calendar": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/js-calendar/-/js-calendar-1.2.3.tgz",
"integrity": "sha512-dAA1/Zbp4+c5E+ARCVTIuKepXsNLzSYfzvOimiYD4S5eeP9QuplSHLcdhfqFSwyM1o1u6ku6RRRCyaZ0YAjiBw=="
},
"js-message": {
"version": "1.0.5",
"resolved": "https://registry.npm.taobao.org/js-message/download/js-message-1.0.5.tgz",
......@@ -7080,6 +7113,11 @@
"integrity": "sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4=",
"dev": true
},
"lodash.throttle": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/lodash.throttle/-/lodash.throttle-4.1.1.tgz",
"integrity": "sha1-wj6RtxAkKscMN/HhzaknTMOb8vQ="
},
"lodash.transform": {
"version": "4.6.0",
"resolved": "https://registry.npm.taobao.org/lodash.transform/download/lodash.transform-4.6.0.tgz",
......@@ -8247,6 +8285,11 @@
"ts-pnp": "^1.1.6"
}
},
"popper.js": {
"version": "1.16.1",
"resolved": "https://registry.npmjs.org/popper.js/-/popper.js-1.16.1.tgz",
"integrity": "sha512-Wb4p1J4zyFTbM+u6WuO4XstYx4Ky9Cewe4DWrel7B0w6VVICvPwdOpotjzcf6eD8TsckVnIMNONQyPIUFOUbCQ=="
},
"portfinder": {
"version": "1.0.28",
"resolved": "https://registry.npm.taobao.org/portfinder/download/portfinder-1.0.28.tgz?cache=0&sync_timestamp=1596018172434&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fportfinder%2Fdownload%2Fportfinder-1.0.28.tgz",
......@@ -10556,6 +10599,11 @@
"integrity": "sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q=",
"dev": true
},
"tinycolor2": {
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/tinycolor2/-/tinycolor2-1.4.2.tgz",
"integrity": "sha512-vJhccZPs965sV/L2sU4oRQVAos0pQXwsvTLkWYdqJ+a8Q5kPFzJTuOFwy7UniPli44NKQGAglksjvOcpo95aZA=="
},
"tmp": {
"version": "0.0.33",
"resolved": "https://registry.npm.taobao.org/tmp/download/tmp-0.0.33.tgz",
......@@ -11009,6 +11057,11 @@
"integrity": "sha1-sj5DWK+oogL+ehAK8fX4g/AgB+4=",
"dev": true
},
"v-click-outside-x": {
"version": "3.7.1",
"resolved": "https://registry.npmjs.org/v-click-outside-x/-/v-click-outside-x-3.7.1.tgz",
"integrity": "sha512-WmUgmcIXr9clVpm1AYS/FgHtcDicfnfoxgQCNg4O6vfk9GVnxA0vSqO321ogUo0b7czYTidj7fQENvWFMWOkUg=="
},
"v8-compile-cache": {
"version": "2.1.1",
"resolved": "https://registry.npm.taobao.org/v8-compile-cache/download/v8-compile-cache-2.1.1.tgz?cache=0&sync_timestamp=1590871780233&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fv8-compile-cache%2Fdownload%2Fv8-compile-cache-2.1.1.tgz",
......@@ -11059,6 +11112,28 @@
"extsprintf": "^1.2.0"
}
},
"view-design": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/view-design/-/view-design-4.4.0.tgz",
"integrity": "sha512-2+xbda6/USUm9Pn+D25NPsIBg7XVhkFC90Ycs0GcFQ4AHZ1QRwDGOj0PGA3eeL4yuVpigdDfmwmNJAoczYXlPA==",
"requires": {
"async-validator": "^3.3.0",
"deepmerge": "^2.2.1",
"element-resize-detector": "^1.2.0",
"js-calendar": "^1.2.3",
"lodash.throttle": "^4.1.1",
"popper.js": "^1.14.6",
"tinycolor2": "^1.4.1",
"v-click-outside-x": "^3.7.1"
},
"dependencies": {
"deepmerge": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-2.2.1.tgz",
"integrity": "sha512-R9hc1Xa/NOBi9WRVUWg19rl1UB7Tt4kuPd+thNJgFZoxXsTz7ncaPaeIm+40oSGuP33DfMb4sZt1QIGiJzC4EA=="
}
}
},
"vm-browserify": {
"version": "1.1.2",
"resolved": "https://registry.npm.taobao.org/vm-browserify/download/vm-browserify-1.1.2.tgz",
......
......@@ -12,6 +12,7 @@
"core-js": "^3.6.5",
"dateformat": "^3.0.3",
"vant": "^2.10.9",
"view-design": "^4.4.0",
"vue": "^2.6.11",
"vue-navigation": "^1.1.4",
"vue-router": "^3.4.6",
......@@ -23,6 +24,7 @@
"@vue/cli-plugin-eslint": "^4.5.0",
"@vue/cli-service": "^4.5.0",
"babel-eslint": "^10.1.0",
"babel-plugin-import": "^1.13.1",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"less": "^3.12.2",
......
......@@ -16,6 +16,9 @@ import Vant from 'vant';
import 'vant/lib/index.css';
Vue.use(Vant);
import ViewUI from 'view-design';
import 'view-design/dist/styles/iview.css';
Vue.use(ViewUI);
import '@/styles/main.less'
......
......@@ -41,6 +41,9 @@
<van-swipe-cell v-for="item in resultList" :key="item.id">
<div class="result-item" @click="_tapItem(item)" v-touch:longtap="_longtapHandler">
<van-checkbox :name="item.id" shape="square" v-if="showCheck"></van-checkbox>
<div @click.stop="_goFile(item.id)" style="margin:20px auto;color:#00a0e9">
查看附件
</div>
<div>抽样单编号:{{item.samplingNum}}</div>
<div>抽样日期:{{item.samplingDate?$dateformat(item.samplingDate,'yyyy-mm-dd'):''}}</div>
<div>生产者名称:{{item.proName}}</div>
......@@ -48,7 +51,6 @@
<div>被抽样单位名称:{{item.testedName}}</div>
<div>地点:{{item.placeName}}</div>
<div>货架:{{item.shelfName}}</div>
<p @click.stop="_goFile(item.id)" style="margin:20px auto">附件:</p>
</div>
<template #right>
<van-button square type="info" text="编辑" class="swipe-cell-btn"
......@@ -88,7 +90,7 @@
placeName: '',
shelfName: '',
},
key:'',
key: '',
showPopup: true,
showCheck: false,
checkListValue: [],
......@@ -141,7 +143,7 @@
planId: this.planId,
...this.formObj//todo 简单查询的关键字
};
if(this.key){
if (this.key) {
data.samplingNum = this.key
}
return this.$serializeForm(data)
......
......@@ -23,6 +23,9 @@
<van-button type="info" block @click="_goto('/sampling/file_upload')">添加附件</van-button>
<van-button type="info" block @click="_uploadImg">添加图片</van-button>
</div>
<van-image-preview v-model="showImg" :images="imgList">
<!--<template #:index>第{{ index }}页</template>-->
</van-image-preview>
</div>
</template>
......@@ -32,20 +35,11 @@
export default {
data() {
return {
title: '附件',
noDataTitle: '相关附件',
resultList: [],
page: 1,
rows: 20,
contractId: '',
showPrompt: false,
height: '',
imgList: [{
src: '',
}],
preview: false,
fileRename: '',
tempData: {},
planId: '',
imgList: [''],
loading: false,//加载中...
finished: false,//没有更多数据
refreshing: false,//刷新中...
......@@ -53,12 +47,12 @@
fileId: '',
//上传图片路径:
action: '',
isApp: true
showImg: false
}
},
mounted() {
this.contractId = this.$route.query.contractId;
this.action = this.$global.baseURL + '/drs/v1/sampling_plan_attachment/' + this.contractId;
this.planId = this.$route.query.planId;
this.action = this.$global.baseURL + '/drs/v1/sampling_plan_attachment/upload?planId=' + this.planId;
this._getData();
},
methods: {
......@@ -70,7 +64,7 @@
let data = {
page: this.page,
rows: this.rows,
contractId: this.contractId
planId: this.planId
};
return this.$serializeForm(data)
},
......@@ -87,49 +81,24 @@
this.page = this.page + 1;
this._getData()
},
//关闭图片
_close() {
this.imgList[0].src = '';
},
//路由跳转
_goto(next) {
let data = {contractId: this.contractId};
let data = {planId: this.planId};
this.$router.push({path: next, query: data})
},
_resultChange(msg) {
if (this.$store.state.samplingPlanAttachment.success) {
this.$vux.toast.show({
type: 'text',
width: '10em',
text: msg,
});
this._search();
_del: async function (id) {
let result = await samplingPlanAttachment.deleteByIds({id: id})
if (result) {
this.$toast('删除成功!')
this._refresh()
}
},
_del(id) {
let flag = this.$route.query.flag;
let data = {};
if (flag === undefined) {
//只可以删除自己上传的附件
data = {id: id, flag: 1};
} else {
//可以删除全部
data = {id: id};
}
this.$store.dispatch('samplingPlanAttachment/deleteByIds', data).then(() => {
this._resultChange('删除成功');
});
},
_addResult() {
this.showPrompt = true;
},
//下载附件
_download(data) {
this.tempData = data;
if (data.type.toLowerCase() === 'jpg' || data.type.toLowerCase() === 'png') {
this.showImg = true
//预览图片
this.imgList[0].src = this.$global.baseURL + '/drs/v1/sampling_plan_attachment/down?id=' + data.id + '&objectKey=' + data.objectKey;
this.$refs.previewer.show(0);
this.imgList[0] = this.$global.baseURL + '/drs/v1/sampling_plan_attachment/down?id=' + data.id;
} else {
//下载文件
let name = '';
......@@ -139,33 +108,13 @@
name = data.remark;
}
this.$router.push({
path: '/sampling/file_down_load',
query: {fileName: name, id: this.tempData.id, ctime: this.tempData.ctime, remark: data.fileName}
path: '/sampling_list/file_down_load',
query: {fileName: name, id: data.id, ctime: data.ctime, remark: data.fileName}
})
}
},
//文件重命名
_reName(data) {
this.fileRename = data.fileName;
this.preview = true;
this.fileId = data.id;
},
_cancel() {
this.preview = false;
},
_ok() {
this.preview = false;
let tempData = {
id: this.fileId,
remark: this.fileRename
};
this.$store.dispatch('samplingPlanAttachment/fileSetName', tempData).then(() => {
this._resultChange('修改成功');
});
},
/****************************************上传图片*************************************************/
_uploadImg() {
this.showPrompt = false;
plus.nativeUI.actionSheet({
title: "选择图片",
cancel: "取消",
......@@ -230,7 +179,7 @@
files = [{key: 'imgUpload' + i, path: zip.target}];
this._submitImg(files);
}, (error) => {
console.log('压缩失败',error)
console.log('压缩失败', error)
});
}
......@@ -248,8 +197,8 @@
}
);
//单图片上传
let tempData = files[0];
task.addFile(tempData.path, {key: tempData.key});
let imgData = files[0];
task.addFile(imgData.path, {key: imgData.key});
task.setRequestHeader('accessToken', localStorage.getItem('accessToken'));
task.start();
},
......
<template>
<div>
<div style="margin:100px auto 10px auto;text-align: center">
<!--<img src="../../../../static/image/file-down.png" height="100">-->
<img src="../../../assets/file-down.png" height="100">
<p style="margin:10px auto">{{name}}</p>
<p style="color:#aaa;"> {{ctime}}</p>
</div>
<div>
<!--<div class="edit-btn down-btn" @click="_webOk" style="margin-bottom: 15px" v-if="osName === 'web' ">下载</div>-->
<!--<div class="edit-btn down-btn" @click="_ok" style="margin-bottom: 15px">下载</div>-->
<div class="edit-btn down-btn" @click="_view" style="margin-bottom: 15px">预览</div>
<div class="bottom-btn">
<van-button block type="info" @click="_view">预览</van-button>
</div>
</div>
</template>
......@@ -18,7 +17,6 @@
export default {
data() {
return {
title: '下载附件',
name: '',
id: '',
ctime: '',
......@@ -34,93 +32,47 @@
this.remark = this.$route.query.remark;
this.id = this.$route.query.id;
this.ctime = this.$dateformat(parseInt(this.$route.query.ctime), 'yyyy/mm/dd');
// this.osName = localStorage.getItem('osName');
},
//移动
_ok() {
this.$vux.loading.show({
text: '下载中...',
width: '10em',
show: true
this.$toast.loading({
message: '下载中...',
forbidClick: true,
});
var dtask = plus.downloader.createDownload(
this.$global.baseURL + '/env/v1/env_contract_attachment/download/' + this.id,
this.$global.baseURL + '/drs/v1/sampling_plan_attachment/down?id=' + this.id,
{}, (d, status) => {
// 下载完成
if (status == 200) {
this.$vux.loading.hide();
this.$vux.toast.show({
type: 'text',
width: '15em',
text: '下载到' + d.filename,
time: 2000
});
this.$toast.clear();
this.$toast.success({message: '下载到' + d.filename, duration: 4000});
this.$router.go(-1);
} else {
this.$vux.loading.hide();
this.$vux.toast.show({
type: 'warn',
width: '10em',
text: '下载失败',
});
this.$toast.clear();
this.$toast.error('下载失败');
}
});
dtask.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
dtask.setRequestHeader('accessToken', localStorage.getItem('accessToken'));
dtask.start();
},
//浏览器
// _webOk() {
// var request = new XMLHttpRequest();
// request.open("GET", this.$global.baseURL + '/env/v1/env_contract_attachment/download/' + this.id);
// request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
// request.setRequestHeader("accessToken", localStorage.getItem('accessToken'));
// request.responseType = 'arraybuffer';
// request.onload = function (e) {
// var a = document.createElement("a");
// document.body.appendChild(a);
// a.style = "display: none";
// var blob = new Blob([this.response], {type: "octet/stream"}),
// url = window.URL.createObjectURL(blob);
// a.href = url;
// a.download = this.remark;
// a.click();
// window.URL.revokeObjectURL(url);
// };
// request.send();
// },
//预览文档
_view() {
// this.$store.dispatch('EnvContractAttachment/preview', this.id).then(() => {
// let result = this.$store.state.EnvContractAttachment.list;
// if (result !== undefined) {
// //使用内置Webview窗口打开URL
// plus.webview.open(this.$global.baseURL + '/print/v1/oos?key=' + result.objectKey, this.id, {
// 'popGesture': 'hide', //侧滑返回
// 'backButtonAutoControl': 'hide', //控制按键返回
// 'additionalHttpHeaders': {accessToken: localStorage.getItem('accessToken')}
// });
// }
// });
//调用第三放程序打开指定文件(必须是本地路径)
this.$vux.loading.show({
text: '加载中...',
width: '10em',
show: true
this.$toast.loading({
message: '加载中...',
forbidClick: true,
});
var dtask = plus.downloader.createDownload(
this.$global.baseURL + '/env/v1/env_contract_attachment/download/' + this.id, {}, (d, status) => {
this.$global.baseURL + '/drs/v1/sampling_plan_attachment/down?id=' + this.id, {}, (d, status) => {
if (status == 200) {
plus.runtime.openFile(d.filename);//cn.wps.moffice_eng-----wps的包名
}
this.$vux.loading.hide();
this.$toast.clear();
});
dtask.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
dtask.setRequestHeader('accessToken', localStorage.getItem('accessToken'));
dtask.start();
},
}
}
......
......@@ -12,7 +12,7 @@
:with-credentials="true"
:show-upload-list="false"
>
<img :src="url" height="100">
<img src="../../../assets/file-add.png" height="100">
</Upload>
</div>
<p style="margin:10px auto">请选择附件上传</p>
......@@ -21,18 +21,11 @@
</template>
<script>
import Global from '../../../api/config'
export default {
data() {
return {
title: '附件',
//合同id
contractId: '',
url: './static/image/file-add.png',
files: [],
planId: '',
action: '',
osName: '',
dataObj: {
file: '',
},
......@@ -44,33 +37,25 @@
},
methods: {
_getQuery() {
this.contractId = this.$route.query.contractId;
this.action = Global.baseURL + '/env/v1/env_contract_attachment/' + this.contractId;
this.planId = this.$route.query.planId;
this.action = this.$global.baseURL + '/drs/v1/sampling_plan_attachment/upload?planId=' + this.planId;
this.headers = {'accessToken': localStorage.getItem('accessToken')};
},
_resultChange(msg) {
this.$vux.toast.show({
type: 'text',
width: '10em',
text: msg,
});
},
//web
_beupload(file) {
this.dataObj.file = file.name;
this.$vux.loading.show({
text: '上传中...',
width: '10em',
show: true
this.$toast.loading({
message: '加载中...',
forbidClick: true,
});
},
_handelsuccess(response) { //上传成功
this.$vux.loading.hide();
this.$toast.clear();
if (response.success) {
this._resultChange('上传成功');
this.$toast('上传成功');
this.$router.go(-1);
} else {
this._resultChange('上传失败');
this.$toast('上传失败');
}
},
}
......
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