index.vue 27 KB

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