index.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826
  1. <template>
  2. <div class="app-container apkfile">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
  4. <el-form-item label="关键字" prop="subName" label-width="95px">
  5. <el-input
  6. v-model="queryParams.searchValue"
  7. placeholder="实验室名称/设备名称/版本名称"
  8. clearable
  9. size="small"
  10. />
  11. </el-form-item>
  12. <el-form-item label="设备类型" prop="onepcType" label-width="75px">
  13. <el-select v-model="queryParams.onepcType" placeholder="请选择设备类型" clearable size="small">
  14. <el-option label="管控一体机" value="1" />
  15. <el-option label="考试一体机" value="2" />
  16. </el-select>
  17. </el-form-item>
  18. <el-form-item label="状态" prop="logStatus" label-width="45px">
  19. <el-select v-model="queryParams.logStatus" placeholder="请选择状态" clearable size="small">
  20. <el-option label="安装成功" value="1" />
  21. <el-option label="安装失败" value="0" />
  22. <el-option label="安装中" value="2" />
  23. <el-option label="上传成功" value="3" />
  24. </el-select>
  25. </el-form-item>
  26. <el-form-item style="float: right;">
  27. <el-col :span="1.5">
  28. <p class="add-button-one-90"
  29. @click="handleAdd"
  30. v-hasPermi="['laboratory:apkfile:add']"
  31. >批量升级</p>
  32. </el-col>
  33. <!-- <el-col :span="1.5">-->
  34. <!-- <p class="add-button-one-90"-->
  35. <!-- style="margin-left:10px;"-->
  36. <!-- @click="upPage"-->
  37. <!-- v-hasPermi="['laboratory:apkfile:add']"-->
  38. <!-- >上传APK</p>-->
  39. <!-- </el-col>-->
  40. </el-form-item>
  41. <el-form-item>
  42. <p class="inquire-button-one" @click="handleQuery">查询</p>
  43. <p class="reset-button-one" @click="resetQuery">重置</p>
  44. </el-form-item>
  45. </el-form>
  46. <el-table v-loading="loading" :data="logList">
  47. <el-table-column label="所属实验室" align="left" prop="subName" />
  48. <el-table-column label="设备名称" align="left" prop="hardName" />
  49. <el-table-column label="设备类型" align="left" prop="onepcType" >
  50. <template slot-scope="scope">
  51. <p>{{scope.row.onepcType==1?'管控一体机':(scope.row.onepcType==2?'考试一体机':'')}}</p>
  52. </template>
  53. </el-table-column>
  54. <el-table-column label="版本名称" align="left" prop="versionName" />
  55. <el-table-column label="版本编号" align="left" prop="version" />
  56. <el-table-column label="状态" align="left" prop="logStatus" >
  57. <template slot-scope="scope">
  58. <p>{{scope.row.logStatus==0?'安装失败':(scope.row.logStatus==1?'安装成功':(scope.row.logStatus==2?'安装中':(scope.row.logStatus==3?'上传成功':'')))}}</p>
  59. </template>
  60. </el-table-column>
  61. <el-table-column label="创建时间" align="left" prop="createTime" />
  62. <el-table-column label="操作" align="left" class-name="small-padding fixed-width">
  63. <template slot-scope="scope">
  64. <div class="button-box">
  65. <p class="table-button-one-90"
  66. @click="handleUpdate(scope.row)"
  67. v-hasPermi="['laboratory:apkfile:edit']"
  68. ><i class="el-icon-edit-outline"></i>修改</p>
  69. </div>
  70. </template>
  71. </el-table-column>
  72. </el-table>
  73. <pagination :page-sizes="[20, 30, 40, 50]"
  74. v-show="total>0"
  75. :total="total"
  76. layout="total, prev, pager, next, sizes, jumper"
  77. :page.sync="queryParams.pageNum"
  78. :limit.sync="queryParams.pageSize"
  79. @pagination="getList"
  80. />
  81. <!-- 批量升级 -->
  82. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  83. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  84. <el-form-item label="院系" prop="deptId" v-if="!form.id">
  85. <el-select v-model="form.deptId" placeholder="请选择院系" @change="handleNodeClick">
  86. <el-option
  87. v-for="dict in deptOptions"
  88. :key="dict.deptId"
  89. :label="dict.deptName"
  90. :value="dict.deptId"
  91. ></el-option>
  92. </el-select>
  93. </el-form-item>
  94. <el-form-item label="实验室" prop="subjectId" v-if="!form.id">
  95. <el-select v-model="form.subjectId" multiple placeholder="请选择实验室">
  96. <el-option
  97. v-for="item in subjectOptions"
  98. :key="item.subjectId"
  99. :label="item.name"
  100. :value="item.subjectId">
  101. </el-option>
  102. </el-select>
  103. </el-form-item>
  104. <el-form-item label="实验室" v-if="form.id" style="width:297px;">
  105. <el-input
  106. v-model="form.subName"
  107. disabled
  108. placeholder=""
  109. clearable
  110. />
  111. </el-form-item>
  112. <el-form-item label="设备类型" prop="onepcType2" style="width:297px;" v-if="!form.id">
  113. <el-select v-model="form.onepcType2" placeholder="请选择设备类型" @change="handleNodeClick2">
  114. <el-option v-for="dict in onepcTypeList" :key="dict.id" :label="dict.name" :value="dict.id" ></el-option>
  115. </el-select>
  116. </el-form-item>
  117. <el-form-item label="设备名称" v-if="form.id" style="width:297px;">
  118. <el-input
  119. v-model="form.hardName"
  120. disabled
  121. placeholder=""
  122. clearable
  123. />
  124. </el-form-item>
  125. <el-form-item label="设备类型" prop="onepcType" v-if="form.id" style="width:297px;">
  126. <el-select v-model="form.onepcType" disabled placeholder="请选择设备类型" @change="handleNodeClick">
  127. <el-option v-for="dict in onepcTypeList" :key="dict.id" :label="dict.name" :value="dict.id" ></el-option>
  128. </el-select>
  129. </el-form-item>
  130. <el-form-item label="安装包" prop="apkId">
  131. <el-select v-model="form.apkId" placeholder="请选择安装包">
  132. <el-option
  133. v-for="item in apkIdOptions"
  134. :key="item.apkId"
  135. :label="item.versionName"
  136. :value="item.apkId">
  137. </el-option>
  138. </el-select>
  139. </el-form-item>
  140. </el-form>
  141. <div slot="footer" class="dialog-footer">
  142. <el-button type="primary" @click="submitForm">确 定</el-button>
  143. <el-button @click="cancel">取 消</el-button>
  144. </div>
  145. </el-dialog>
  146. <!--上传APK-->
  147. <el-dialog title="上传APK" class="dialog-up-data-box" :visible.sync="openUp" v-if="openUp" width="570px" append-to-body>
  148. <div class="dialog-up-data-min-box scrollbar-box">
  149. <el-form v-loading="loading" :rules="apkRules" :model="upForm" ref="upForm" :inline="true" v-show="showSearch">
  150. <el-form-item label="版本名称" prop="versionName" label-width="90px">
  151. <el-input
  152. v-model="upForm.versionName"
  153. maxLength="20"
  154. placeholder="请输入版本名称"
  155. clearable
  156. style="width: 300px"
  157. />
  158. </el-form-item>
  159. <el-form-item label="版本编号" prop="version" label-width="90px">
  160. <el-input
  161. v-model="upForm.version"
  162. maxLength="20"
  163. placeholder="请输入版本编号"
  164. clearable
  165. style="width: 300px"
  166. />
  167. </el-form-item>
  168. <el-form-item label="版本描述" prop="version" label-width="90px">
  169. <el-input
  170. type="textarea"
  171. v-model="upForm.apkInfo"
  172. maxLength="1000"
  173. placeholder="请输入版本描述"
  174. clearable
  175. style="width: 300px"
  176. />
  177. </el-form-item>
  178. <el-form-item label="类型" prop="onepcType" style="display: block" label-width="90px">
  179. <el-radio v-model="upForm.onepcType" label="1">管控一体机</el-radio>
  180. <el-radio v-model="upForm.onepcType" label="2">考试一体机</el-radio>
  181. </el-form-item>
  182. <el-form-item label="安装包" prop="apkFileUpload" label-width="90px">
  183. <uploader
  184. :autoStart="false"
  185. :options="options"
  186. ref="uploader"
  187. :file-list="fileList"
  188. :file-status-text="statusText"
  189. class="uploader-example"
  190. @file-complete="fileComplete"
  191. @complete="complete"
  192. @file-success="fileSuccess"
  193. @files-added="filesAdded">
  194. <uploader-unsupport></uploader-unsupport>
  195. <uploader-drop>
  196. <i class="el-icon-upload"></i>
  197. <div class="el-upload__text">将文件拖到此处,或 <uploader-btn :single="true" :attrs="attrs">点击上传</uploader-btn></div>
  198. </uploader-drop>
  199. <div class="text-box" v-if="fileData.name">
  200. <p>{{fileData.name}}</p>
  201. <p>{{fileData.size}}</p>
  202. <p>{{fileData.text}}</p>
  203. </div>
  204. <!-- <uploader-list></uploader-list> -->
  205. <!--<uploader-files></uploader-files>-->
  206. </uploader>
  207. </el-form-item>
  208. <!--<el-form-item label="安装包" prop="apkFileUpload" label-width="90px">-->
  209. <!--<el-upload-->
  210. <!--style="margin:0 auto;width:120px;"-->
  211. <!--class="avatar-uploader"-->
  212. <!--:action="uploadImgUrl"-->
  213. <!--accept="application/vnd.android.package-archive"-->
  214. <!--:show-file-list="false"-->
  215. <!--:on-progress="progressUp"-->
  216. <!--:on-success="handleAvatarSuccess"-->
  217. <!--:on-error="errorUp"-->
  218. <!--:headers="headers"-->
  219. <!--:before-upload="beforeAvatarUpload">-->
  220. <!--<img v-if="upForm.apkFileUpload" src="@/assets/ZDimages/icon_apk.png">-->
  221. <!--<i v-if="!upForm.apkFileUpload" class="el-icon-plus avatar-uploader-icon" style="height:40px;line-height:40px;width:40px;text-align: center"></i>-->
  222. <!--</el-upload>-->
  223. <!--</el-form-item>-->
  224. </el-form>
  225. </div>
  226. <div slot="footer" class="dialog-footer">
  227. <el-button type="primary" @click="submitFormUp">确 定</el-button>
  228. <el-button @click="cancelUp">取 消</el-button>
  229. </div>
  230. <!--<div v-loading="loading">-->
  231. <!--<el-table :data="apkLogList">-->
  232. <!--<el-table-column label="版本名称" align="left" prop="versionName" />-->
  233. <!--<el-table-column label="版本编号" align="left" prop="version" />-->
  234. <!--<el-table-column label="上传时间" align="left" prop="createTime" />-->
  235. <!--</el-table>-->
  236. <!--<pagination-->
  237. <!--style="height:50px;"-->
  238. <!--v-show="apkTotal>0"-->
  239. <!--:total="apkTotal"-->
  240. <!--:page.sync="apkQueryParams.pageNum"-->
  241. <!--:limit.sync="apkQueryParams.pageSize"-->
  242. <!--@pagination="apkGetList"-->
  243. <!--/>-->
  244. <!--</div>-->
  245. </el-dialog>
  246. </div>
  247. </template>
  248. <script>
  249. import { listLog, getLog, delLog, addLog, updateLog, getApkUploadList,apkFileAddApkLog,updateApkLog,getApkUploadListByLimit,addApkUpload } from "@/api/laboratory/apkfile";
  250. import { subjectDictList } from "@/api/laboratory/record";
  251. import { listDepartments } from "@/api/system/dept";
  252. import { getToken } from "@/utils/auth";
  253. import axios from "axios";
  254. import SparkMD5 from "spark-md5";
  255. let httpHeader=window.location.href.split('://')[0]+'://'
  256. export default {
  257. name: "Log",
  258. data() {
  259. return {
  260. // 上传相关
  261. uploadImgUrl: this.uploadUrl(), // 上传的图片服务器地址
  262. headers: {
  263. Authorization: "Bearer " + getToken()
  264. },
  265. // 遮罩层
  266. loading: true,
  267. // 选中数组
  268. ids: [],
  269. // 非单个禁用
  270. single: true,
  271. // 非多个禁用
  272. multiple: true,
  273. // 显示搜索条件
  274. showSearch: true,
  275. // 总条数
  276. total: 0,
  277. // apk需要对应升级的日志表格数据
  278. logList: [],
  279. // 弹出层标题
  280. title: "",
  281. // 是否显示弹出层
  282. open: false,
  283. // 查询参数
  284. queryParams: {
  285. pageNum: 1,
  286. pageSize:20,
  287. searchValue: null,
  288. onepcHardwareNum: null,
  289. apkUploadId: null,
  290. logStatus: null,
  291. onepcType: null,
  292. },
  293. // 表单参数
  294. form: {},
  295. // 表单校验
  296. rules: {
  297. deptId: [
  298. { required: true, message: "请选择院系", trigger: "blur" }
  299. ],
  300. apkId: [
  301. { required: true, message: "分类名称不能为空", trigger: "blur" }
  302. ],
  303. onepcType2: [
  304. { required: true, message: "设备类型不能为空", trigger: "blur" }
  305. ],
  306. },
  307. // 院系列表
  308. deptOptions: [],
  309. onepcTypeList:[
  310. {id:1,name:"管控一体机",},
  311. {id:2,name:"考试一体机",}
  312. ],
  313. //实验室列表
  314. subjectOptions: [],
  315. //文件列表
  316. fileList:[],
  317. options: {
  318. target: httpHeader+this.judgmentNetworkReturnAddress()+"/base/file/upload/chunk",
  319. // 开启服务端分片校验功能
  320. testChunks: true,
  321. single: true,
  322. fileParameterName: 'file',
  323. headers: {
  324. Authorization: "Bearer " + getToken()
  325. },
  326. parseTimeRemaining: function (timeRemaining, parsedTimeRemaining) {
  327. return parsedTimeRemaining
  328. .replace(/\syears?/, "年")
  329. .replace(/\days?/, "天")
  330. .replace(/\shours?/, "小时")
  331. .replace(/\sminutes?/, "分钟")
  332. .replace(/\sseconds?/, "秒");
  333. },
  334. // // 服务器分片校验函数
  335. checkChunkUploadedByResponse: (chunk, message) => {
  336. const result = JSON.parse(message);
  337. if (result.data.skipUpload) {
  338. this.skip = true;
  339. return true;
  340. }
  341. return (result.data.uploaded || []).indexOf(chunk.offset + 1) >= 0;
  342. },
  343. },
  344. // 上传页面开关
  345. openUp:false,
  346. //apk列表
  347. apkIdOptions:[],
  348. //apk 列表查询参数
  349. apkQueryParams: {
  350. pageNum: 1,
  351. pageSize:20,
  352. },
  353. //上传数据
  354. upForm:{},
  355. // apk上传表单校验
  356. apkRules: {
  357. versionName: [
  358. { required: true, message: "请输入版本名称", trigger: "blur" }
  359. ],
  360. version: [
  361. { required: true, message: "请输入版本编号", trigger: "blur" },
  362. { required: true, message: "只能输入数字", validator: this.isNum, trigger: "blur" },
  363. ],
  364. onepcType: [
  365. { required: true, message: "请选择版本类型", trigger: "blur" }
  366. ],
  367. apkFileUpload: [
  368. { required: true, message: "请上传安装包", trigger: "blur" }
  369. ],
  370. },
  371. attrs: {
  372. accept: [".apk"]
  373. },
  374. statusText: {
  375. success: "上传成功",
  376. error: "上传出错了",
  377. uploading: "上传中...",
  378. paused: "暂停中...",
  379. waiting: "等待中...",
  380. cmd5: "计算文件MD5中...",
  381. },
  382. fileData:{},
  383. };
  384. },
  385. created() {
  386. this.getList();
  387. },
  388. methods: {
  389. //版本管理页面开关
  390. upPage(){
  391. this.apkGetList();
  392. this.$set(this,'upForm',{});
  393. this.$set(this,'fileData',{});
  394. this.openUp = true;
  395. },
  396. //apk列表获取
  397. apkGetList() {
  398. this.loading = true;
  399. listLog(this.queryParams).then( response => {
  400. this.apkLogList = response.rows;
  401. this.apkTotal = response.total;
  402. this.loading = false;
  403. });
  404. },
  405. //开始上传
  406. progressUp(event, file, fileList){
  407. this.loading = true;
  408. },
  409. //上传成功
  410. handleAvatarSuccess(res, file,index) {
  411. this.upForm.apkFileUpload = res.data.url;
  412. this.loading = false;
  413. this.$forceUpdate()
  414. },
  415. //上传失败
  416. errorUp(err, file, fileList){
  417. this.loading = false;
  418. },
  419. //上传检查
  420. beforeAvatarUpload(file) {
  421. let type = false;
  422. if (file.type == 'application/vnd.android.package-archive') {
  423. type = true;
  424. }else{
  425. this.$message.error('只能上传APK格式文件');
  426. type = false;
  427. }
  428. console.log('file',file);
  429. return type;
  430. },
  431. // 新增/编辑节点单击事件
  432. handleNodeClick(data) {
  433. this.form.deptId = data;
  434. this.getSubjectDictList(data);
  435. },
  436. // 新增/编辑节点单击事件
  437. handleNodeClick2(data) {
  438. this.$set(this.form, 'apkId', '')
  439. let params = {};
  440. if(data){
  441. params.onepcType = data;
  442. }
  443. console.log("params",params)
  444. getApkUploadList(params).then(response => {
  445. this.$set(this, 'apkIdOptions', response.data)
  446. });
  447. },
  448. /** 查询院系列表 */
  449. getDeptList() {
  450. listDepartments().then(response => {
  451. this.$set(this, 'deptOptions', response.data)
  452. });
  453. },
  454. /** 查询apk列表 */
  455. getApkUploadList(row) {
  456. let params = {};
  457. if(row){
  458. params.onepcType = row.onepcType;
  459. }
  460. console.log("params",params)
  461. getApkUploadList(params).then(response => {
  462. this.$set(this, 'apkIdOptions', response.data)
  463. });
  464. },
  465. /** 查询实验室字典列表 */
  466. getSubjectDictList (deptId) {
  467. this.subjectOptions = null;
  468. this.loading = true;
  469. let params = {};
  470. params.deptId = deptId;
  471. subjectDictList(params).then(response => {
  472. this.form.subjectId = [];
  473. for(let i=0;i<response.data.length;i++){
  474. response.data[i].subjectId = response.data[i].id;
  475. }
  476. this.subjectOptions = response.data;
  477. this.loading = false;
  478. });
  479. },
  480. /** 查询apk需要对应升级的日志列表 */
  481. getList() {
  482. this.loading = true;
  483. listLog(this.queryParams).then( response => {
  484. this.logList = response.rows;
  485. this.total = response.total;
  486. this.loading = false;
  487. });
  488. },
  489. // 取消按钮
  490. cancel() {
  491. this.open = false;
  492. },
  493. // 取消按钮
  494. cancelUp() {
  495. if (this.loading){
  496. return
  497. }
  498. this.fileList=[];
  499. // this.$refs.uploader.files = [];
  500. // this.$refs.uploader.fileList = [];
  501. //this.$refs.uploader.allRemove();
  502. this.fileData = {};
  503. this.openUp = false;
  504. },
  505. // 表单重置
  506. reset() {
  507. this.form = {
  508. id: null,
  509. onepcHardwareNum: null,
  510. apkUploadId: null,
  511. logStatus: 0,
  512. createBy: null,
  513. createTime: null,
  514. updateBy: null,
  515. updateTime: null,
  516. remark: null
  517. };
  518. this.resetForm("form");
  519. },
  520. /** 搜索按钮操作 */
  521. handleQuery() {
  522. this.queryParams.pageNum = 1;
  523. this.getList();
  524. },
  525. /** 重置按钮操作 */
  526. resetQuery() {
  527. this.queryParams.searchValue='';
  528. this.resetForm("queryForm");
  529. this.handleQuery();
  530. },
  531. /** 新增按钮操作 */
  532. handleAdd() {
  533. this.form = {
  534. deptId:"",
  535. subjectId:[],
  536. apkId:"",
  537. };
  538. this.open = true;
  539. this.getDeptList();
  540. this.getApkUploadList();
  541. this.subjectOptions = [];
  542. this.title = "批量升级";
  543. },
  544. /** 修改按钮操作 */
  545. handleUpdate(row) {
  546. this.getApkUploadList(row);
  547. this.form = row;
  548. this.open = true;
  549. this.title = "修改";
  550. },
  551. //上传apk提交按钮
  552. submitFormUp(){
  553. if(this.loading){
  554. return
  555. }
  556. this.$refs["upForm"].validate(valid => {
  557. if (valid) {
  558. let obj = {
  559. versionName:this.upForm.versionName,
  560. version:this.upForm.version,
  561. apkInfo:this.upForm.apkInfo,
  562. onepcType:this.upForm.onepcType,
  563. apkFileUpload:this.upForm.apkFileUpload,
  564. };
  565. addApkUpload(obj).then( response => {
  566. this.msgSuccess("新增成功");
  567. this.openUp = false;
  568. this.upForm = {};
  569. this.fileList=[];
  570. // this.$refs.uploader.files = [];
  571. // this.$refs.uploader.fileList = [];
  572. // this.$refs.uploader.cancel()
  573. this.fileData = {};
  574. });
  575. }
  576. });
  577. },
  578. /** 提交按钮 */
  579. submitForm() {
  580. this.$refs["form"].validate(valid => {
  581. if (valid) {
  582. if (this.form.id != null) {
  583. let obj = {
  584. id:this.form.id,
  585. apkId:this.form.apkId,
  586. };
  587. updateApkLog(obj).then( response => {
  588. this.msgSuccess("修改成功");
  589. this.open = false;
  590. this.getList();
  591. });
  592. } else {
  593. let obj = {
  594. deptId:this.form.deptId,
  595. apkId:this.form.apkId,
  596. onepcType:this.form.onepcType2,
  597. };
  598. if(this.form.subjectId[0]){
  599. obj.subId = this.form.subjectId
  600. }else{
  601. obj.subId = null
  602. }
  603. apkFileAddApkLog(obj).then( response => {
  604. this.msgSuccess("新增成功");
  605. this.open = false;
  606. this.getList();
  607. });
  608. }
  609. }
  610. });
  611. },
  612. /** 删除按钮操作 */
  613. handleDelete(row) {
  614. const ids = row.id || this.ids;
  615. this.$confirm('是否确认删除?', "警告", {
  616. confirmButtonText: "确定",
  617. cancelButtonText: "取消",
  618. type: "warning"
  619. }).then(function() {
  620. return delLog(ids);
  621. }).then(() => {
  622. this.getList();
  623. this.msgSuccess("删除成功");
  624. }).catch(() => {});
  625. },
  626. /** 导出按钮操作 */
  627. handleExport() {
  628. this.download('laboratory/apkfile/export', {
  629. ...this.queryParams
  630. }, `laboratory_log.xlsx`)
  631. },
  632. fileSuccess(rootFile, file, response, chunk) {
  633. const result = JSON.parse(response);
  634. if (result.code == 200 && !this.skip) {
  635. axios.post(httpHeader+this.judgmentNetworkReturnAddress()+"/base/file/upload/merge", {
  636. identifier: file.uniqueIdentifier,
  637. filename: file.name,
  638. totalChunks: chunk.offset,
  639. },{
  640. headers: {
  641. Authorization: "Bearer " + getToken()
  642. }
  643. }).then((res) => {
  644. if (res.data.code==200) {
  645. this.upForm.apkFileUpload=res.data.data;
  646. } else {
  647. console.log(res);
  648. }
  649. }).catch(function (error) {
  650. console.log(error);
  651. });
  652. } else {
  653. console.log("上传成功,不需要合并");
  654. }
  655. if (this.skip) {
  656. this.skip = false;
  657. }
  658. },
  659. fileComplete(rootFile) {
  660. // 一个根文件(文件夹)成功上传完成。
  661. this.fileName=rootFile.name;
  662. this.fileSize=rootFile.size;
  663. console.log("rootFile",rootFile)
  664. this.fileData = {
  665. name:rootFile.name,
  666. size:(parseInt(rootFile._prevUploadedSize/1024)/1024).toFixed(2)+'MB',
  667. text:"上传完成"
  668. }
  669. },
  670. complete(file) {
  671. console.log("complete file:",file)
  672. // 上传完毕。
  673. },
  674. filesAdded(file, fileList, event) {
  675. this.fileData = {
  676. name:file[0].name,
  677. size:"",
  678. text:"上传中..."
  679. }
  680. console.log("file",file)
  681. console.log("fileList",fileList)
  682. console.log("event",event)
  683. // this.$refs.uploader.fileList = [];
  684. // this.$refs.uploader.files = [];
  685. this.fileList=[];
  686. file.forEach((e) => {
  687. this.fileList.push(e);
  688. this.computeMD5(e);
  689. });
  690. },
  691. computeMD5(file) {
  692. let fileReader = new FileReader();
  693. let time = new Date().getTime();
  694. let blobSlice = File.prototype.slice || File.prototype.mozSlice || File.prototype.webkitSlice;
  695. let currentChunk = 0;
  696. const chunkSize = 1024 * 1024;
  697. let chunks = Math.ceil(file.size / chunkSize);
  698. let spark = new SparkMD5.ArrayBuffer();
  699. // 文件状态设为"计算MD5"
  700. file.cmd5 = true; //文件状态为“计算md5...”
  701. file.pause();
  702. loadNext();
  703. fileReader.onload = (e) => {
  704. spark.append(e.target.result);
  705. if (currentChunk < chunks) {
  706. currentChunk++;
  707. loadNext();
  708. // 实时展示MD5的计算进度
  709. } else {
  710. let md5 = spark.end();
  711. spark.destroy(); //释放缓存
  712. file.uniqueIdentifier = md5; //将文件md5赋值给文件唯一标识
  713. file.cmd5 = false; //取消计算md5状态
  714. file.resume(); //开始上传
  715. }
  716. };
  717. fileReader.onerror = function () {
  718. this.error(`文件${file.name}读取出错,请检查该文件`);
  719. file.cancel();
  720. };
  721. function loadNext() {
  722. let start = currentChunk * chunkSize;
  723. let end = start + chunkSize >= file.size ? file.size : start + chunkSize;
  724. fileReader.readAsArrayBuffer(blobSlice.call(file.file, start, end));
  725. }
  726. },
  727. allStart() {
  728. this.fileList.map((e) => {
  729. if (e.paused) {
  730. e.resume();
  731. }
  732. });
  733. },
  734. allStop() {
  735. this.fileList.map((e) => {
  736. if (!e.paused) {
  737. e.pause();
  738. }
  739. });
  740. },
  741. allRemove() {
  742. this.fileList.map((e) => {
  743. e.cancel();
  744. });
  745. this.fileList = [];
  746. },
  747. }
  748. };
  749. </script>
  750. <style scoped lang="scss">
  751. .apkfile {
  752. display: flex!important;
  753. flex-direction: column;
  754. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  755. padding:20px 20px 20px!important;
  756. .button-box{
  757. width:90px;
  758. display: flex;
  759. margin:0 auto;
  760. }
  761. }
  762. </style>
  763. <style lang="scss">
  764. .dialog-up-data-box{
  765. .text-box{
  766. width:360px;
  767. display: flex;
  768. p:nth-child(1){
  769. width:200px;
  770. display:block;
  771. overflow:hidden;
  772. text-overflow:ellipsis;
  773. white-space:nowrap;
  774. }
  775. p:nth-child(2){
  776. width:100px;
  777. text-align: center;
  778. }
  779. p:nth-child(3){
  780. width:60px;
  781. text-align: right;
  782. }
  783. }
  784. .dialog-up-data-min-box{
  785. height:500px;
  786. }
  787. .uploader-drop{
  788. width:360px;
  789. .el-icon-upload{
  790. color:#0183FA;
  791. display: block;
  792. font-size:78px;
  793. width:78px;
  794. height:78px;
  795. margin:0 auto;
  796. }
  797. .el-upload__text{
  798. width:210px;
  799. margin:0 auto;
  800. }
  801. .uploader-btn{
  802. border:none;
  803. color:#0183FA;
  804. }
  805. }
  806. .uploader-files{
  807. width:360px;
  808. }
  809. }
  810. </style>