deviceList.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  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="班组" prop="team">
  13. <el-select v-model="queryParams.team" placeholder="请选择班组" clearable size="small" style="width: 200px">
  14. <el-option
  15. v-for="dict in teamOptions"
  16. :key="dict.dictValue"
  17. :label="dict.dictLabel"
  18. :value="dict.dictValue"
  19. />
  20. </el-select>
  21. </el-form-item>
  22. <el-form-item label="学习时长min" prop="learnTime">
  23. <el-input
  24. v-model="queryParams.learnTime"
  25. placeholder="请输入学习时长min"
  26. clearable
  27. size="small"
  28. @keyup.enter.native="handleQuery"
  29. />
  30. </el-form-item>
  31. <el-form-item label="完成时间" prop="finishDate">
  32. <el-date-picker clearable size="small" style="width: 200px"
  33. v-model="queryParams.finishDate"
  34. type="date"
  35. value-format="yyyy-MM-dd"
  36. placeholder="选择完成时间">
  37. </el-date-picker>
  38. </el-form-item>
  39. <el-form-item>
  40. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  41. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  42. </el-form-item>
  43. </el-form>
  44. <el-row :gutter="10" class="mb8">
  45. <el-col :span="1.5">
  46. <el-button
  47. type="success"
  48. icon="el-icon-edit"
  49. size="mini"
  50. :disabled="single"
  51. @click="handleUpdate"
  52. v-hasPermi="['training:training:edit']"
  53. >{{ $t('修改') }}</el-button>
  54. </el-col>
  55. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  56. </el-row>
  57. <el-table v-loading="loading" :data="deviceList" @selection-change="handleSelectionChange" :height="clientHeight" border>
  58. <el-table-column type="selection" width="55" align="center" />
  59. <el-table-column label="开始日期" align="center" prop="startDate" width="100">
  60. <template slot-scope="scope">
  61. <span>{{ parseTime(scope.row.startDate, '{y}-{m}-{d}') }}</span>
  62. </template>
  63. </el-table-column>
  64. <el-table-column label="完成时间" align="center" prop="finishDate" width="100">
  65. <template slot-scope="scope">
  66. <span>{{ parseTime(scope.row.finishDate, '{y}-{m}-{d}') }}</span>
  67. </template>
  68. </el-table-column>
  69. <el-table-column label="培训课程" align="center" prop="trainingbcc.course" width="300">
  70. </el-table-column>
  71. <el-table-column label="参培人" align="center" prop="name" width="100">
  72. </el-table-column>
  73. <el-table-column label="班组" align="center" prop="team" width="100">
  74. <template slot-scope="scope">
  75. <span>{{ selectDictLabel(teamOptions, scope.row.team) }}</span>
  76. </template>
  77. </el-table-column>
  78. <el-table-column label="是否为补培人员" align="center" width="120" prop="supplementary" :show-overflow-tooltip="true">
  79. <template v-slot="scope">
  80. <span v-if="scope.row.supplementary == 0" size="small" type="success">否</span>
  81. <span v-else-if="scope.row.supplementary == 1" size="small" type="info">是</span>
  82. </template>
  83. </el-table-column>
  84. <el-table-column label="学习状态" align="center" prop="learnState" width="100" :show-overflow-tooltip="true">
  85. <template v-slot="scope">
  86. <el-tag v-if="scope.row.learnState == 1" size="small" type="success">已完成</el-tag>
  87. <el-tag v-else-if="scope.row.learnState == 0" size="small" type="info">未完成</el-tag>
  88. </template>
  89. </el-table-column>
  90. <el-table-column label="需学习时长min" align="center" prop="trainingbcc.timerNeed" width="120" :show-overflow-tooltip="true"/>
  91. <el-table-column label="已学习时长min" align="center" prop="learnTime" width="120" :show-overflow-tooltip="true"/>
  92. <el-table-column label="考试状态" align="center" prop="examState" width="100" :show-overflow-tooltip="true">
  93. <template v-slot="scope">
  94. <el-tag v-if="scope.row.examState == 1" size="small" type="success">合格</el-tag>
  95. <el-tag v-else-if="scope.row.examState == 0" size="small" type="info">未完成</el-tag>
  96. <el-tag v-else-if="scope.row.examState == -1" size="small" type="danger">不合格</el-tag>
  97. <el-tag v-else-if="scope.row.examState == 3" size="small" type="danger">待订正</el-tag>
  98. </template>
  99. </el-table-column>
  100. <el-table-column label="考试次数" align="center" prop="examNum" :show-overflow-tooltip="true"/>
  101. <el-table-column label="操作" align="center" fixed="right" width="120" class-name="small-padding fixed-width">
  102. <template slot-scope="scope">
  103. <el-button
  104. size="mini"
  105. type="text"
  106. icon="el-icon-edit"
  107. @click="hanldeExamPaper(scope.row)"
  108. >考试成绩</el-button>
  109. </template>
  110. </el-table-column>
  111. </el-table>
  112. <pagination
  113. v-show="total>0"
  114. :total="total"
  115. :page.sync="queryParams.pageNum"
  116. :limit.sync="queryParams.pageSize"
  117. @pagination="getList"
  118. />
  119. <!-- 添加或修改人员-装置级培训关系对话框 -->
  120. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  121. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  122. <el-form-item label="人员员工号" prop="staffId">
  123. <el-input v-model="form.staffId" placeholder="请输入人员员工号" />
  124. </el-form-item>
  125. <el-form-item label="开始日期" prop="startDate">
  126. <el-date-picker clearable size="small" style="width: 200px"
  127. v-model="form.startDate"
  128. type="date"
  129. value-format="yyyy-MM-dd"
  130. placeholder="选择开始日期">
  131. </el-date-picker>
  132. </el-form-item>
  133. <el-form-item label="完成时间" prop="finishDate">
  134. <el-date-picker clearable size="small" style="width: 200px"
  135. v-model="form.finishDate"
  136. type="date"
  137. value-format="yyyy-MM-dd"
  138. placeholder="选择完成时间">
  139. </el-date-picker>
  140. </el-form-item>
  141. <el-form-item label="备注" prop="remarks">
  142. <el-input v-model="form.remarks" placeholder="请输入备注" />
  143. </el-form-item>
  144. <el-form-item label="是否为补培人员" prop="supplementary">
  145. <el-select v-model="form.supplementary" placeholder="是否为补培人员 ">
  146. <el-option label="否" value="0" />
  147. <el-option label="是" value="1" />
  148. </el-select>
  149. </el-form-item>
  150. </el-form>
  151. <div slot="footer" class="dialog-footer">
  152. <el-button type="primary" @click="submitForm">确 定</el-button>
  153. <el-button @click="cancel">取 消</el-button>
  154. </div>
  155. </el-dialog>
  156. <!-- 用户导入对话框 -->
  157. <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  158. <el-upload
  159. ref="upload"
  160. :limit="1"
  161. accept=".xlsx, .xls"
  162. :headers="upload.headers"
  163. :action="upload.url + '?updateSupport=' + upload.updateSupport"
  164. :disabled="upload.isUploading"
  165. :on-progress="handleFileUploadProgress"
  166. :on-success="handleFileSuccess"
  167. :auto-upload="false"
  168. drag
  169. >
  170. <i class="el-icon-upload"></i>
  171. <div class="el-upload__text">
  172. 将文件拖到此处,或
  173. <em>点击上传</em>
  174. </div>
  175. <div class="el-upload__tip" slot="tip">
  176. <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据
  177. <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
  178. </div>
  179. <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
  180. </el-upload>
  181. <div slot="footer" class="dialog-footer">
  182. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  183. <el-button @click="upload.open = false">取 消</el-button>
  184. </div>
  185. </el-dialog>
  186. <el-dialog v-if="detailOpen" :visible.sync="detailOpen" title="考试明细" width="60%" append-to-body>
  187. <div class="el-dialog-div">
  188. <my-paper-list :exam-id="examId" :user-id="userId" :staff-id ="staffId" :device-id="deviceId" />
  189. </div>
  190. </el-dialog>
  191. </div>
  192. </template>
  193. <script>
  194. import { listDevice, getDevice, delDevice, addDevice, updateDevice, exportDevice, importTemplate} from "@/api/training/bccdevice";
  195. import { treeselect } from "@/api/system/dept";
  196. import { getToken } from "@/utils/auth";
  197. import Treeselect from "@riophae/vue-treeselect";
  198. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  199. import MyPaperList from '@/views/training/elearn/userExam/paper'
  200. export default {
  201. name: "Device",
  202. components: { Treeselect,MyPaperList },
  203. data() {
  204. return {
  205. // 遮罩层
  206. loading: true,
  207. // 选中数组
  208. ids: [],
  209. // 非单个禁用
  210. single: true,
  211. // 非多个禁用
  212. multiple: true,
  213. // 显示搜索条件
  214. showSearch: false,
  215. // 总条数
  216. total: 0,
  217. // 人员-装置级培训关系表格数据
  218. deviceList: [],
  219. // 弹出层标题
  220. title: "",
  221. // 部门树选项
  222. deptOptions: undefined,
  223. clientHeight:300,
  224. // 是否显示弹出层
  225. open: false,
  226. detailOpen:false,
  227. examId: null,
  228. staffId: null,
  229. deviceId: null,
  230. // 用户导入参数
  231. upload: {
  232. // 是否显示弹出层(用户导入)
  233. open: false,
  234. // 弹出层标题(用户导入)
  235. title: "",
  236. // 是否禁用上传
  237. isUploading: false,
  238. // 是否更新已经存在的用户数据
  239. updateSupport: 0,
  240. // 设置上传的请求头部
  241. headers: { Authorization: "Bearer " + getToken() },
  242. // 上传的地址
  243. url: process.env.VUE_APP_BASE_API + "/training/device/importData"
  244. },
  245. // 查询参数
  246. queryParams: {
  247. pageNum: 1,
  248. pageSize: 20,
  249. staffId: null,
  250. regularId: null,
  251. startDate: null,
  252. team: null,
  253. remarks: null,
  254. createrCode: null,
  255. createdate: null,
  256. updaterCode: null,
  257. updatedate: null,
  258. supplementary: null,
  259. learnState: null,
  260. examState: null,
  261. examId: null,
  262. learnTime: null,
  263. finishDate: null
  264. },
  265. // 表单参数
  266. form: {},
  267. // 表单校验
  268. rules: {
  269. },
  270. // 班组选项
  271. teamOptions: []
  272. };
  273. },
  274. watch: {
  275. // 根据名称筛选部门树
  276. deptName(val) {
  277. this.$refs.tree.filter(val);
  278. }
  279. },
  280. created() {
  281. this.queryParams.regularId = this.$route.params.id
  282. //设置表格高度对应屏幕高度
  283. this.$nextTick(() => {
  284. this.clientHeight = document.body.clientHeight -250
  285. })
  286. this.getList();
  287. this.getTreeselect();
  288. this.getTeamOptions();
  289. },
  290. methods: {
  291. /** 查询人员-装置级培训关系列表 */
  292. getList() {
  293. this.loading = true;
  294. listDevice(this.queryParams).then(response => {
  295. this.deviceList = response.rows;
  296. this.total = response.total;
  297. this.loading = false;
  298. });
  299. },
  300. /** 查询部门下拉树结构 */
  301. getTreeselect() {
  302. treeselect().then(response => {
  303. this.deptOptions = response.data;
  304. });
  305. },
  306. /** 获取班组选项 */
  307. getTeamOptions() {
  308. // 获取班组字典数据
  309. this.getDicts("TEAM_DIVIDE").then(response => {
  310. this.teamOptions = response.data;
  311. });
  312. },
  313. // 取消按钮
  314. cancel() {
  315. this.open = false;
  316. this.reset();
  317. },
  318. // 表单重置
  319. reset() {
  320. this.form = {
  321. id: null,
  322. staffId: null,
  323. regularId: null,
  324. startDate: null,
  325. finishDate: null,
  326. remarks: null,
  327. delFlag: null,
  328. createrCode: null,
  329. createdate: null,
  330. updaterCode: null,
  331. updatedate: null,
  332. supplementary: null,
  333. learnState: null,
  334. examState: null,
  335. examId: null,
  336. learnTime: null
  337. };
  338. this.resetForm("form");
  339. },
  340. /** 搜索按钮操作 */
  341. handleQuery() {
  342. this.queryParams.pageNum = 1;
  343. this.getList();
  344. },
  345. /** 重置按钮操作 */
  346. resetQuery() {
  347. this.resetForm("queryForm");
  348. this.handleQuery();
  349. },
  350. // 多选框选中数据
  351. handleSelectionChange(selection) {
  352. this.ids = selection.map(item => item.id)
  353. this.single = selection.length!==1
  354. this.multiple = !selection.length
  355. },
  356. hanldeExam(row){
  357. this.$router.push({ name: 'paper', params: { examId: row.examId }})
  358. },
  359. /** 新增按钮操作 */
  360. handleAdd() {
  361. this.reset();
  362. this.open = true;
  363. this.title = "添加人员-装置级培训关系";
  364. },
  365. /** 修改按钮操作 */
  366. handleUpdate(row) {
  367. this.reset();
  368. const id = row.id || this.ids
  369. getDevice(id).then(response => {
  370. this.form = response.data;
  371. this.open = true;
  372. this.title = "修改人员-装置级培训关系";
  373. });
  374. },
  375. /** 提交按钮 */
  376. submitForm() {
  377. this.$refs["form"].validate(valid => {
  378. if (valid) {
  379. if (this.form.id != null) {
  380. updateDevice(this.form).then(response => {
  381. this.msgSuccess("修改成功");
  382. this.open = false;
  383. this.getList();
  384. });
  385. } else {
  386. addDevice(this.form).then(response => {
  387. this.msgSuccess("新增成功");
  388. this.open = false;
  389. this.getList();
  390. });
  391. }
  392. }
  393. });
  394. },
  395. /** 删除按钮操作 */
  396. handleDelete(row) {
  397. const ids = row.id || this.ids;
  398. this.$confirm('是否确认删除?', "警告", {
  399. confirmButtonText: "确定",
  400. cancelButtonText: "取消",
  401. type: "warning"
  402. }).then(function() {
  403. return delDevice(ids);
  404. }).then(() => {
  405. this.getList();
  406. this.msgSuccess("删除成功");
  407. })
  408. },
  409. /** 导出按钮操作 */
  410. handleExport() {
  411. const queryParams = this.queryParams;
  412. this.$confirm('是否确认导出所有人员-装置级培训关系数据项?', "警告", {
  413. confirmButtonText: "确定",
  414. cancelButtonText: "取消",
  415. type: "warning"
  416. }).then(function() {
  417. return exportDevice(queryParams);
  418. }).then(response => {
  419. this.download(response.msg);
  420. })
  421. },
  422. /** 导入按钮操作 */
  423. handleImport() {
  424. this.upload.title = "用户导入";
  425. this.upload.open = true;
  426. },
  427. /** 下载模板操作 */
  428. importTemplate() {
  429. importTemplate().then(response => {
  430. this.download(response.msg);
  431. });
  432. },
  433. // 文件上传中处理
  434. handleFileUploadProgress(event, file, fileList) {
  435. this.upload.isUploading = true;
  436. },
  437. // 文件上传成功处理
  438. handleFileSuccess(response, file, fileList) {
  439. this.upload.open = false;
  440. this.upload.isUploading = false;
  441. this.$refs.upload.clearFiles();
  442. this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
  443. this.getList();
  444. },
  445. // 提交上传文件
  446. submitFileForm() {
  447. this.$refs.upload.submit();
  448. },
  449. hanldeExamPaper(row) {
  450. this.examId = row.trainingbcc.examId
  451. this.staffId = row.staffId
  452. this.deviceId = row.id // 将id作为deviceId传递
  453. this.detailOpen = true
  454. }
  455. }
  456. };
  457. </script>