index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="开始日期" prop="startDate">
  5. <el-date-picker clearable size="small" style="width: 200px"
  6. v-model="queryParams.startDate"
  7. type="date"
  8. value-format="yyyy-MM-dd"
  9. placeholder="选择开始日期">
  10. </el-date-picker>
  11. </el-form-item>
  12. <el-form-item label="学习时长min" prop="learnTime">
  13. <el-input
  14. v-model="queryParams.learnTime"
  15. placeholder="请输入学习时长min"
  16. clearable
  17. size="small"
  18. @keyup.enter.native="handleQuery"
  19. />
  20. </el-form-item>
  21. <el-form-item>
  22. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  23. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  24. </el-form-item>
  25. </el-form>
  26. <el-row :gutter="10" class="mb8">
  27. <el-col :span="1.5">
  28. <el-button
  29. type="primary"
  30. icon="el-icon-plus"
  31. size="mini"
  32. @click="handleAdd"
  33. >新增</el-button>
  34. </el-col>
  35. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  36. </el-row>
  37. <el-table v-loading="loading" :data="deviceList" @selection-change="handleSelectionChange" :height="clientHeight" border>
  38. <el-table-column type="selection" width="55" align="center" />
  39. <el-table-column label="开始日期" align="center" prop="startDate" width="100">
  40. <template slot-scope="scope">
  41. <span>{{ parseTime(scope.row.startDate, '{y}-{m}-{d}') }}</span>
  42. </template>
  43. </el-table-column>
  44. <el-table-column label="参培人" align="center" prop="name" width="100">
  45. </el-table-column>
  46. <el-table-column label="培训课程" align="center" prop="trainingbcc.course" width="500">
  47. </el-table-column>
  48. <el-table-column label="是否为补培人员" align="center" prop="supplementary" :show-overflow-tooltip="true">
  49. <template v-slot="scope">
  50. <span v-if="scope.row.supplementary == 0" size="small" type="success">否</span>
  51. <span v-else-if="scope.row.supplementary == 1" size="small" type="info">是</span>
  52. </template>
  53. </el-table-column>
  54. <el-table-column label="学习状态" align="center" prop="learnState" :show-overflow-tooltip="true">
  55. <template v-slot="scope">
  56. <el-tag v-if="scope.row.learnState == 1" size="small" type="success">已完成</el-tag>
  57. <el-tag v-else-if="scope.row.learnState == 0" size="small" type="info">未完成</el-tag>
  58. </template>
  59. </el-table-column>
  60. <el-table-column label="考试状态" align="center" prop="examState" :show-overflow-tooltip="true">
  61. <template v-slot="scope">
  62. <el-tag v-if="scope.row.examState == 1" size="small" type="success">合格</el-tag>
  63. <el-tag v-else-if="scope.row.examState == 0" size="small" type="info">未完成</el-tag>
  64. </template>
  65. </el-table-column>
  66. <el-table-column label="学习时长min" align="center" prop="learnTime" :show-overflow-tooltip="true"/>
  67. <el-table-column label="操作" align="center" fixed="right" width="120" class-name="small-padding fixed-width">
  68. <template slot-scope="scope">
  69. <el-button
  70. size="mini"
  71. type="text"
  72. icon="el-icon-view"
  73. @click="openFileDialog(scope.row)"
  74. >学习</el-button>
  75. <el-button
  76. size="mini"
  77. type="text"
  78. icon="el-icon-edit"
  79. @click="hanldeExam(scope.row)"
  80. >考试</el-button>
  81. </template>
  82. </el-table-column>
  83. </el-table>
  84. <pagination
  85. v-show="total>0"
  86. :total="total"
  87. :page.sync="queryParams.pageNum"
  88. :limit.sync="queryParams.pageSize"
  89. @pagination="getList"
  90. />
  91. <!-- 添加或修改人员-装置级培训关系对话框 -->
  92. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  93. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  94. <el-form-item label="人员员工号" prop="staffId">
  95. <el-input v-model="form.staffId" placeholder="请输入人员员工号" />
  96. </el-form-item>
  97. <el-form-item label="装置级培训ID" prop="regularId">
  98. <el-input v-model="form.regularId" placeholder="请输入装置级培训ID" />
  99. </el-form-item>
  100. <el-form-item label="开始日期" prop="startDate">
  101. <el-date-picker clearable size="small" style="width: 200px"
  102. v-model="form.startDate"
  103. type="date"
  104. value-format="yyyy-MM-dd"
  105. placeholder="选择开始日期">
  106. </el-date-picker>
  107. </el-form-item>
  108. <el-form-item label="备注" prop="remarks">
  109. <el-input v-model="form.remarks" placeholder="请输入备注" />
  110. </el-form-item>
  111. <el-form-item label="删除状态" prop="delFlag">
  112. <el-input v-model="form.delFlag" placeholder="请输入删除状态" />
  113. </el-form-item>
  114. <el-form-item label="创建人" prop="createrCode">
  115. <el-input v-model="form.createrCode" placeholder="请输入创建人" />
  116. </el-form-item>
  117. <el-form-item label="创建时间" prop="createdate">
  118. <el-date-picker clearable size="small" style="width: 200px"
  119. v-model="form.createdate"
  120. type="date"
  121. value-format="yyyy-MM-dd"
  122. placeholder="选择创建时间">
  123. </el-date-picker>
  124. </el-form-item>
  125. <el-form-item label="修改人" prop="updaterCode">
  126. <el-input v-model="form.updaterCode" placeholder="请输入修改人" />
  127. </el-form-item>
  128. <el-form-item label="修改时间" prop="updatedate">
  129. <el-date-picker clearable size="small" style="width: 200px"
  130. v-model="form.updatedate"
  131. type="date"
  132. value-format="yyyy-MM-dd"
  133. placeholder="选择修改时间">
  134. </el-date-picker>
  135. </el-form-item>
  136. <el-form-item label="是否为补培人员" prop="supplementary">
  137. <el-input v-model="form.supplementary" placeholder="请输入是否为补培人员" />
  138. </el-form-item>
  139. <el-form-item label="学习状态" prop="learnState">
  140. <el-input v-model="form.learnState" placeholder="请输入学习状态" />
  141. </el-form-item>
  142. <el-form-item label="考试状态" prop="examState">
  143. <el-input v-model="form.examState" placeholder="请输入考试状态" />
  144. </el-form-item>
  145. <el-form-item label="考试ID" prop="examId">
  146. <el-input v-model="form.examId" placeholder="请输入考试ID" />
  147. </el-form-item>
  148. <el-form-item label="学习时长min" prop="learnTime">
  149. <el-input v-model="form.learnTime" placeholder="请输入学习时长min" />
  150. </el-form-item>
  151. <el-form-item label="归属部门" prop="deptId">
  152. <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门" />
  153. </el-form-item>
  154. </el-form>
  155. <div slot="footer" class="dialog-footer">
  156. <el-button type="primary" @click="submitForm">确 定</el-button>
  157. <el-button @click="cancel">取 消</el-button>
  158. </div>
  159. </el-dialog>
  160. <!-- 用户导入对话框 -->
  161. <el-dialog :visible.sync="file.open" width="30%" append-to-body>
  162. <el-descriptions class="margin-top" title="学习资料" :column="1" size="" border>
  163. <el-descriptions-item label-style="width:180px">
  164. <template slot="label">
  165. <i class="el-icon-user"></i>
  166. 资料名
  167. </template>
  168. {{ file.data.fileName }}
  169. </el-descriptions-item>
  170. <el-descriptions-item label-style="width:180px">
  171. <template slot="label">
  172. <i class="el-icon-mobile-phone"></i>
  173. 学习进度
  174. </template>
  175. <el-progress :text-inside="true" :stroke-width="20" :percentage="getCountTime()"
  176. status="success"></el-progress>
  177. </el-descriptions-item>
  178. <el-descriptions-item label-style="width:180px">
  179. <template slot="label">
  180. <i class="el-icon-mobile-phone"></i>
  181. 应学习时长(分)
  182. </template>
  183. {{ file.data.timerNeed }}
  184. </el-descriptions-item>
  185. <el-descriptions-item label-style="width:180px">
  186. <template slot="label">
  187. <i class="el-icon-mobile-phone"></i>
  188. 已学习时长(分)
  189. </template>
  190. {{ file.data.timer }}
  191. </el-descriptions-item>
  192. </el-descriptions>
  193. <el-button
  194. class="mt10"
  195. type="primary"
  196. icon="el-icon-video-play"
  197. @click="handleStudy(file.data)"
  198. >开始学习
  199. </el-button>
  200. </el-dialog>
  201. <el-dialog :close-on-click-modal="false" element-loading-background="rgba(0,0,0,0.2)"
  202. v-dialogDrag :title="pdf.title"
  203. :visible.sync="pdf.open" width="1300px" height="800px" :center="true" append-to-body
  204. @close="handleClose">
  205. <div style="margin-top: -30px">
  206. <iframe id="iFrame" class="iframe-html" :src="pdf.pdfUrl" frameborder="0" width="100%" height="700px"
  207. v-if="ppt"></iframe>
  208. </div>
  209. </el-dialog>
  210. </div>
  211. </template>
  212. <script>
  213. import { listDevice, getDevice,updateDeviceLearnTime, delDevice, addDevice, updateDevice, exportDevice, importTemplate} from "@/api/training/bccdevice";
  214. import { treeselect } from "@/api/system/dept";
  215. import { getToken } from "@/utils/auth";
  216. import Treeselect from "@riophae/vue-treeselect";
  217. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  218. import {updateFirstLearnTime} from "@/api/training/bccnew/firstplan";
  219. var timer = null;
  220. export default {
  221. name: "Device",
  222. components: { Treeselect },
  223. data() {
  224. return {
  225. file: {
  226. open: false,
  227. data: {}
  228. },
  229. // 遮罩层
  230. loading: true,
  231. // 选中数组
  232. ids: [],
  233. // 非单个禁用
  234. single: true,
  235. // 非多个禁用
  236. multiple: true,
  237. // 显示搜索条件
  238. showSearch: false,
  239. // 总条数
  240. total: 0,
  241. // 人员-装置级培训关系表格数据
  242. deviceList: [],
  243. // 弹出层标题
  244. title: "",
  245. // 部门树选项
  246. deptOptions: undefined,
  247. clientHeight:300,
  248. pdf: {
  249. title: '',
  250. pdfUrl: '',
  251. numPages: null,
  252. open: false,
  253. pageNum: 1,
  254. pageTotalNum: 1,
  255. loadedRatio: 0,
  256. loadingFlash: false,
  257. },
  258. // 是否显示弹出层
  259. open: false,
  260. // 用户导入参数
  261. upload: {
  262. // 是否显示弹出层(用户导入)
  263. open: false,
  264. // 弹出层标题(用户导入)
  265. title: "",
  266. // 是否禁用上传
  267. isUploading: false,
  268. // 是否更新已经存在的用户数据
  269. updateSupport: 0,
  270. // 设置上传的请求头部
  271. headers: { Authorization: "Bearer " + getToken() },
  272. // 上传的地址
  273. url: process.env.VUE_APP_BASE_API + "/training/device/importData"
  274. },
  275. // 查询参数
  276. queryParams: {
  277. pageNum: 1,
  278. pageSize: 20,
  279. staffId: null,
  280. regularId: null,
  281. startDate: null,
  282. remarks: null,
  283. createrCode: null,
  284. createdate: null,
  285. updaterCode: null,
  286. updatedate: null,
  287. supplementary: null,
  288. learnState: null,
  289. examState: null,
  290. examId: null,
  291. learnTime: null
  292. },
  293. // 表单参数
  294. form: {},
  295. // 表单校验
  296. rules: {
  297. }
  298. };
  299. },
  300. watch: {
  301. // 根据名称筛选部门树
  302. deptName(val) {
  303. this.$refs.tree.filter(val);
  304. }
  305. },
  306. created() {
  307. //设置表格高度对应屏幕高度
  308. this.$nextTick(() => {
  309. this.clientHeight = document.body.clientHeight -250
  310. })
  311. this.getList();
  312. this.getTreeselect();
  313. },
  314. methods: {
  315. /** 查询人员-装置级培训关系列表 */
  316. getList() {
  317. this.loading = true;
  318. listDevice(this.queryParams).then(response => {
  319. this.deviceList = response.rows;
  320. this.total = response.total;
  321. this.loading = false;
  322. });
  323. },
  324. /** 查询部门下拉树结构 */
  325. getTreeselect() {
  326. treeselect().then(response => {
  327. this.deptOptions = response.data;
  328. });
  329. },
  330. // 取消按钮
  331. cancel() {
  332. this.open = false;
  333. this.reset();
  334. },
  335. // 表单重置
  336. reset() {
  337. this.form = {
  338. id: null,
  339. staffId: null,
  340. regularId: null,
  341. startDate: null,
  342. remarks: null,
  343. delFlag: null,
  344. createrCode: null,
  345. createdate: null,
  346. updaterCode: null,
  347. updatedate: null,
  348. supplementary: null,
  349. learnState: null,
  350. examState: null,
  351. examId: null,
  352. learnTime: null
  353. };
  354. this.resetForm("form");
  355. },
  356. /** 搜索按钮操作 */
  357. handleQuery() {
  358. this.queryParams.pageNum = 1;
  359. this.getList();
  360. },
  361. /** 重置按钮操作 */
  362. resetQuery() {
  363. this.resetForm("queryForm");
  364. this.handleQuery();
  365. },
  366. // 多选框选中数据
  367. handleSelectionChange(selection) {
  368. this.ids = selection.map(item => item.id)
  369. this.single = selection.length!==1
  370. this.multiple = !selection.length
  371. },
  372. hanldeExam(row){
  373. this.$router.push({ name: 'paper', params: { examId: row.examId }})
  374. },
  375. /** 新增按钮操作 */
  376. handleAdd() {
  377. this.reset();
  378. this.open = true;
  379. this.title = "添加人员-装置级培训关系";
  380. },
  381. /** 修改按钮操作 */
  382. handleUpdate(row) {
  383. this.reset();
  384. const id = row.id || this.ids
  385. getDevice(id).then(response => {
  386. this.form = response.data;
  387. this.open = true;
  388. this.title = "修改人员-装置级培训关系";
  389. });
  390. },
  391. /** 提交按钮 */
  392. submitForm() {
  393. this.$refs["form"].validate(valid => {
  394. if (valid) {
  395. if (this.form.id != null) {
  396. updateDevice(this.form).then(response => {
  397. this.msgSuccess("修改成功");
  398. this.open = false;
  399. this.getList();
  400. });
  401. } else {
  402. addDevice(this.form).then(response => {
  403. this.msgSuccess("新增成功");
  404. this.open = false;
  405. this.getList();
  406. });
  407. }
  408. }
  409. });
  410. },
  411. openFileDialog(row) {
  412. this.file.open = true;
  413. this.file.data = row.trainingbcc
  414. console.log(row)
  415. if (row.learnTime === '' || row.learnTime == null) {
  416. this.file.data.learnTime = 0
  417. }
  418. if (row.trainingbcc.timerNeed === '' || row.trainingbcc.timerNeed == null) {
  419. this.file.data.trainingbcc.timerNeed = 0
  420. }
  421. console.log(this.file.data)
  422. },
  423. handleStudy(row) {
  424. //office预览
  425. this.pdf.loadingFlash = true
  426. this.pdf.open = true
  427. this.pdf.title = row.fileName
  428. this.pdf.pdfUrl = ""
  429. this.ppt = true
  430. //如果是PDF等直接可以打开的就不调接口,否则调用接口
  431. if (row.fileName!=null && row.fileName.endsWith('pdf')) {
  432. this.pdf.pdfUrl = process.env.VUE_APP_BASE_API + '/pdf/web/viewer.html?file=' + process.env.VUE_APP_BASE_API + row.fileUrl
  433. this.loadingFlash = false
  434. }
  435. let _this = this;
  436. timer = window.setInterval(function () {
  437. updateDeviceLearnTime(row).then(res => {
  438. })
  439. }, 60000);
  440. },
  441. handleClose() {
  442. window.clearInterval(timer);
  443. this.getList();
  444. },
  445. getCountTime() {
  446. if (this.file.data.timerNeed === 0)
  447. return 0;
  448. return (this.file.data.timer / this.file.data.timerNeed * 100).toFixed(2)
  449. },
  450. /** 删除按钮操作 */
  451. handleDelete(row) {
  452. const ids = row.id || this.ids;
  453. this.$confirm('是否确认删除?', "警告", {
  454. confirmButtonText: "确定",
  455. cancelButtonText: "取消",
  456. type: "warning"
  457. }).then(function() {
  458. return delDevice(ids);
  459. }).then(() => {
  460. this.getList();
  461. this.msgSuccess("删除成功");
  462. })
  463. },
  464. /** 导出按钮操作 */
  465. handleExport() {
  466. const queryParams = this.queryParams;
  467. this.$confirm('是否确认导出所有人员-装置级培训关系数据项?', "警告", {
  468. confirmButtonText: "确定",
  469. cancelButtonText: "取消",
  470. type: "warning"
  471. }).then(function() {
  472. return exportDevice(queryParams);
  473. }).then(response => {
  474. this.download(response.msg);
  475. })
  476. },
  477. /** 导入按钮操作 */
  478. handleImport() {
  479. this.upload.title = "用户导入";
  480. this.upload.open = true;
  481. },
  482. /** 下载模板操作 */
  483. importTemplate() {
  484. importTemplate().then(response => {
  485. this.download(response.msg);
  486. });
  487. },
  488. // 文件上传中处理
  489. handleFileUploadProgress(event, file, fileList) {
  490. this.upload.isUploading = true;
  491. },
  492. // 文件上传成功处理
  493. handleFileSuccess(response, file, fileList) {
  494. this.upload.open = false;
  495. this.upload.isUploading = false;
  496. this.$refs.upload.clearFiles();
  497. this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
  498. this.getList();
  499. },
  500. // 提交上传文件
  501. submitFileForm() {
  502. this.$refs.upload.submit();
  503. }
  504. }
  505. };
  506. </script>