index.vue 18 KB

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