deviceList.vue 15 KB

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