index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. <template>
  2. <div class="app-container">
  3. <el-row>
  4. <!--用户数据-->
  5. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
  6. <el-form-item label="考试名称" prop="userName">
  7. <el-input
  8. v-model="queryParams.userName"
  9. placeholder="请输入考试名称"
  10. clearable
  11. style="width: 150px"
  12. @keyup.enter.native="handleQuery"
  13. />
  14. </el-form-item>
  15. <el-form-item label="考试时间">
  16. <el-date-picker
  17. v-model="dateRange"
  18. style="width: 240px"
  19. value-format="yyyy-MM-dd"
  20. type="daterange"
  21. range-separator="-"
  22. start-placeholder="开始日期"
  23. end-placeholder="结束日期"
  24. ></el-date-picker>
  25. </el-form-item>
  26. <el-form-item label="模拟器型号" prop="simType">
  27. <el-select
  28. v-model="queryParams.simType"
  29. placeholder="模拟器型号"
  30. clearable
  31. style="width: 240px"
  32. @keyup.enter.native="handleQuery"
  33. >
  34. <el-option
  35. v-for="dict in dict.type.sim_sim_type"
  36. :key="dict.value"
  37. :label="dict.label"
  38. :value="dict.value"
  39. />
  40. </el-select>
  41. </el-form-item>
  42. <el-form-item label="考试状态" prop="status">
  43. <el-select
  44. v-model="queryParams.status"
  45. placeholder="考试状态"
  46. clearable
  47. style="width: 150px"
  48. >
  49. <el-option
  50. v-for="dict in dict.type.sys_normal_disable"
  51. :key="dict.value"
  52. :label="dict.label"
  53. :value="dict.value"
  54. />
  55. </el-select>
  56. </el-form-item>
  57. <el-form-item>
  58. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  59. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  60. </el-form-item>
  61. </el-form>
  62. <el-row :gutter="10" class="mb8">
  63. <!-- <el-col :span="1.5">
  64. <el-button
  65. type="primary"
  66. plain
  67. icon="el-icon-plus"
  68. size="mini"
  69. @click="handleAdd"
  70. v-hasPermi="['simulator:task:add']"
  71. >新增</el-button>
  72. </el-col>
  73. <el-col :span="1.5">
  74. <el-button
  75. type="success"
  76. plain
  77. icon="el-icon-edit"
  78. size="mini"
  79. :disabled="single"
  80. @click="handleUpdate"
  81. v-hasPermi="['simulator:user:edit']"
  82. >修改</el-button>
  83. </el-col>
  84. <el-col :span="1.5">
  85. <el-button
  86. type="danger"
  87. plain
  88. icon="el-icon-delete"
  89. size="mini"
  90. :disabled="multiple"
  91. @click="handleDelete"
  92. v-hasPermi="['simulator:user:remove']"
  93. >删除</el-button>
  94. </el-col> -->
  95. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
  96. </el-row>
  97. <el-table v-loading="loading" :data="userList" @selection-change="handleSelectionChange">
  98. <el-table-column type="selection" width="50" align="center" />
  99. <el-table-column label="考试名称" align="center" key="userName" prop="userName" v-if="columns[0].visible" :show-overflow-tooltip="true" />
  100. <el-table-column label="考试时间" align="center" key="kaoshiTime" prop="kaoshiTime" v-if="columns[1].visible" :show-overflow-tooltip="true" />
  101. <el-table-column label="模拟器型号" align="center" key="simType" prop="simType" v-if="columns[2].visible" :show-overflow-tooltip="true" >
  102. <template slot-scope="scope">
  103. <dict-tag class="text-navy" :options="dict.type.sim_sim_type" :value="scope.row.simType"/>
  104. </template>
  105. </el-table-column>
  106. <el-table-column label="创建老师" align="center" key="creater" prop="creater" v-if="columns[3].visible" :show-overflow-tooltip="true" />
  107. <el-table-column label="考试状态" align="center" key="status" v-if="columns[4].visible">
  108. <template slot-scope="scope">
  109. <el-switch
  110. v-model="scope.row.status"
  111. active-value="0"
  112. inactive-value="1"
  113. @change="handleStatusChange(scope.row)"
  114. ></el-switch>
  115. </template>
  116. </el-table-column>
  117. <el-table-column
  118. label="操作"
  119. align="center"
  120. width="160"
  121. class-name="small-padding fixed-width"
  122. >
  123. <template slot-scope="scope">
  124. <el-button
  125. size="mini"
  126. type="text"
  127. icon="el-icon-thumb"
  128. @click="handleInto(scope.row)"
  129. >进入</el-button>
  130. </template>
  131. </el-table-column>
  132. </el-table>
  133. <pagination
  134. v-show="total>0"
  135. :total="total"
  136. :page.sync="queryParams.pageNum"
  137. :limit.sync="queryParams.pageSize"
  138. @pagination="getList"
  139. />
  140. </el-row>
  141. <!-- 添加或修改用户配置对话框 -->
  142. <el-dialog :title="title" :visible.sync="open" width="70%" append-to-body>
  143. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  144. <el-row>
  145. <el-col :span="12">
  146. <el-form-item label="型号">
  147. <!-- v-model="form.monitype" -->
  148. <el-select v-model="selectedEquip" placeholder="请选择模拟器型号">
  149. <el-option
  150. value="请选择"
  151. >请选择</el-option>
  152. <el-option
  153. v-for="dict in dict.type.sim_equip_type"
  154. :key="dict.value"
  155. :label="dict.label"
  156. :value="dict.value"
  157. ></el-option>
  158. </el-select>
  159. </el-form-item>
  160. </el-col>
  161. <el-col :span="12">
  162. <el-form-item label="任务名称" prop="userName">
  163. <el-input placeholder="请输入任务名称" maxlength="30" />
  164. </el-form-item>
  165. </el-col>
  166. <div style="text-align: right;">
  167. <el-button @click="toggleSelection(tableData)">选择全部</el-button>
  168. <el-button @click="toggleSelection()">取消选择</el-button>
  169. </div>
  170. </el-row>
  171. <el-table
  172. :data="tableData" border ref="multipleTable" @selection-change="handleSelectionRow"
  173. :span-method="objectSpanMethod"
  174. style="width:100%;text-align:center;margin-left:10px; margin-top:10px">
  175. <el-table-column
  176. prop="xinghao"
  177. label="型号">
  178. </el-table-column>
  179. <el-table-column
  180. prop="xianxiang"
  181. label="故障现象">
  182. </el-table-column>
  183. <el-table-column
  184. prop="name"
  185. label="故障部位">
  186. </el-table-column>
  187. <el-table-column
  188. type="selection" prop="ids"
  189. label="ID"
  190. width="55"></el-table-column>
  191. </el-table>
  192. </el-form>
  193. <div slot="footer" class="dialog-footer">
  194. <el-button type="primary" @click="submitForm">确 定</el-button>
  195. <el-button @click="cancel">取 消</el-button>
  196. </div>
  197. </el-dialog>
  198. </div>
  199. </template>
  200. <style>
  201. .el-table__header tr th .cell{
  202. text-align: center;
  203. }
  204. .el-table__row .cell {
  205. text-align: center;
  206. }
  207. /* .el-form-item__label{
  208. width: 85px !important;
  209. } */
  210. </style>
  211. <script>
  212. import { listUser,getUserProfile} from "@/api/system/user";
  213. import { examStudentList,examStudentGet} from "@/api/sim/exam";
  214. import { getToken } from "@/utils/auth";
  215. export default {
  216. name: "Exam",
  217. dicts: ['sim_sim_type'],
  218. data() {
  219. return {
  220. user: {},
  221. multipleSelection: [],
  222. selectedEquip:'',
  223. tableData:[],
  224. // 遮罩层
  225. loading: true,
  226. // 选中数组
  227. ids: [],
  228. // 非单个禁用
  229. single: true,
  230. // 非多个禁用
  231. multiple: true,
  232. // 显示搜索条件
  233. showSearch: true,
  234. // 总条数
  235. total: 0,
  236. // 用户表格数据
  237. userList: null,
  238. // 弹出层标题
  239. title: "",
  240. // 部门树选项
  241. deptOptions: undefined,
  242. // 是否显示弹出层
  243. open: false,
  244. //自检弹出框
  245. zijianopen:false,
  246. // 部门名称
  247. deptName: undefined,
  248. // 默认密码
  249. initPassword: undefined,
  250. // 日期范围
  251. dateRange: [],
  252. // 岗位选项
  253. postOptions: [],
  254. // 角色选项
  255. roleOptions: [],
  256. // 表单参数
  257. form: {},
  258. defaultProps: {
  259. children: "children",
  260. label: "label"
  261. },
  262. // 查询参数
  263. queryParams: {
  264. pageNum: 1,
  265. pageSize: 10,
  266. userName: undefined,
  267. phonenumber: undefined,
  268. status: undefined,
  269. deptId: undefined
  270. },
  271. // 列信息
  272. columns: [
  273. { key: 0, label: `考试名称`, visible: true },
  274. { key: 1, label: `考试时间`, visible: true },
  275. { key: 2, label: `模拟器类型`, visible: true },
  276. { key: 3, label: `考试状态`, visible: true },
  277. { key: 4, label: `创建老师`, visible: true },
  278. ],
  279. // 表单校验
  280. rules: {
  281. }
  282. };
  283. },
  284. watch: {
  285. // 根据名称筛选部门树
  286. deptName(val) {
  287. this.$refs.tree.filter(val);
  288. },
  289. },
  290. created() {
  291. this.getList();
  292. //this.getDeptTree();
  293. this.getConfigKey("sys.user.initPassword").then(response => {
  294. this.initPassword = response.msg;
  295. });
  296. },
  297. methods: {
  298. objectSpanMethod({ row, column, rowIndex, columnIndex }) {
  299. // console.log(this.selectedEquip+'@@@')
  300. //第一列型号
  301. if(columnIndex === 0) {
  302. if(this.selectedEquip==2){
  303. if(rowIndex==0){
  304. return { rowspan: 13, colspan: 1 };
  305. }
  306. return { rowspan: 0, colspan: 0 };
  307. }else if(this.selectedEquip==3){
  308. if(rowIndex==0){
  309. return { rowspan: 16, colspan: 1 };
  310. }
  311. return { rowspan: 0, colspan: 0};
  312. }else{
  313. if(rowIndex==0){
  314. return { rowspan: 11, colspan: 1 };
  315. }else if(rowIndex==11){
  316. return { rowspan: 13, colspan: 1 };
  317. }else if(rowIndex==24){
  318. return { rowspan: 16, colspan: 1 };
  319. }else{
  320. return { rowspan: 0, colspan: 0 };
  321. }
  322. }
  323. }
  324. //第二列故障现象
  325. if(columnIndex === 1) {
  326. if(this.selectedEquip==2){
  327. // console.log(rowIndex+'####')
  328. if(rowIndex<9 && rowIndex % 2 === 0){
  329. return { rowspan: 2, colspan: 1 };
  330. }else if((rowIndex>9&&rowIndex<13)){
  331. return { rowspan: 1, colspan: 1 };
  332. }else{
  333. return { rowspan: 0, colspan: 0 };
  334. }
  335. }else if(this.selectedEquip==3){
  336. if(rowIndex<7 && rowIndex % 2 === 0){
  337. return { rowspan: 2, colspan: 1 };
  338. }else if((rowIndex==8)){
  339. return { rowspan: 3, colspan: 1 };
  340. }else if(rowIndex==11){
  341. return { rowspan: 2, colspan: 1 };
  342. }else if(rowIndex>12 && rowIndex<16){
  343. return { rowspan: 1, colspan: 1 };
  344. }else{
  345. return { rowspan: 0, colspan: 0 };
  346. }
  347. }else{
  348. if(rowIndex<7 && rowIndex % 2 === 0){
  349. return { rowspan: 2, colspan: 1 };
  350. }else if((rowIndex>7&&rowIndex<11) || (rowIndex>20&&rowIndex<24) || (rowIndex>36)){
  351. return { rowspan: 1, colspan: 1 };
  352. }else if((rowIndex==35) || (rowIndex>10 && rowIndex<20) && rowIndex % 2 === 1){
  353. return { rowspan: 2, colspan: 1 };
  354. }else if(rowIndex>23 && rowIndex<32 && rowIndex % 2 === 0){
  355. return { rowspan: 2, colspan: 1 };
  356. }else if(rowIndex==32){
  357. return { rowspan: 3, colspan: 1 };
  358. }else{
  359. return { rowspan: 0, colspan: 0 };
  360. }
  361. }
  362. }
  363. //故障部位 和 选择
  364. if(columnIndex === 2 || columnIndex === 3){
  365. //return { rowspan: 1, colspan: 1 };
  366. }
  367. },
  368. objectSpanMethod1({ row, column, rowIndex, columnIndex }) {
  369. //第二列故障现象
  370. if(columnIndex === 0) {
  371. if(rowIndex<7 && rowIndex % 2 === 0){
  372. return { rowspan: 2, colspan: 1 };
  373. }else if((rowIndex>7&&rowIndex<11) || (rowIndex>20&&rowIndex<24) || (rowIndex>36)){
  374. return { rowspan: 1, colspan: 1 };
  375. }else if((rowIndex==35) || (rowIndex>10 && rowIndex<20) && rowIndex % 2 === 1){
  376. return { rowspan: 2, colspan: 1 };
  377. }else if(rowIndex>23 && rowIndex<32 && rowIndex % 2 === 0){
  378. return { rowspan: 2, colspan: 1 };
  379. }else if(rowIndex==32){
  380. return { rowspan: 3, colspan: 1 };
  381. }else{
  382. return { rowspan: 0, colspan: 0 };
  383. }
  384. }
  385. },
  386. // 根据选择的option获取新的数据
  387. // getNewTableData(option) {
  388. // // 逻辑处理返回新的数据数组
  389. // return [
  390. // // ...新数据
  391. // ];
  392. // },
  393. toggleSelection(rows) {
  394. if (rows) {
  395. rows.forEach(row => {
  396. this.$refs.multipleTable.toggleRowSelection(row);
  397. console.log(row.ids+'###')
  398. console.log(row.name+'@@@')
  399. });
  400. } else {
  401. this.$refs.multipleTable.clearSelection();
  402. }
  403. },
  404. handleSelectionRow(val) {
  405. this.multipleSelection = val;
  406. },
  407. /** 查询用户列表 */
  408. getList() {
  409. this.loading = true;
  410. getUserProfile().then(response => {
  411. this.user = response.data;
  412. console.log(response.data.userId)
  413. });
  414. console.log(this.user.userId);
  415. console.log('this.user.userId');
  416. examStudentList(this.user.userId).then(response => {
  417. //将返回值注释
  418. this.userList = response.rows;
  419. this.total = response.total;
  420. this.loading = false;
  421. }
  422. );
  423. },
  424. /** 查询部门下拉树结构 */
  425. getDeptTree() {
  426. deptTreeSelect().then(response => {
  427. this.deptOptions = response.data;
  428. });
  429. },
  430. // 筛选节点
  431. filterNode(value, data) {
  432. if (!value) return true;
  433. return data.label.indexOf(value) !== -1;
  434. },
  435. // 节点单击事件
  436. handleNodeClick(data) {
  437. this.queryParams.deptId = data.id;
  438. this.handleQuery();
  439. },
  440. // 用户状态修改
  441. handleStatusChange(row) {
  442. let text = row.status === "0" ? "启用" : "停用";
  443. this.$modal.confirm('确认要"' + text + '""' + row.userName + '"用户吗?').then(function() {
  444. return changeUserStatus(row.userId, row.status);
  445. }).then(() => {
  446. this.$modal.msgSuccess(text + "成功");
  447. }).catch(function() {
  448. row.status = row.status === "0" ? "1" : "0";
  449. });
  450. },
  451. //清除故障
  452. clearFaultChange(row,number,nametext){
  453. console.log()
  454. // console.log(nametext+'###')
  455. // console.log(row[nametext]+'@@@')
  456. // console.log(row.name1+'@@@')
  457. let text1 = '清除所有模拟器故障';
  458. console.log(nametext + '###name1');
  459. if(nametext != 'all'){
  460. text1 = '清除'+ number +'号坐席模拟器故障';
  461. }
  462. this.$modal.confirm('确认要"' + text1 + '"吗?').then(function() {
  463. // return changeUserStatus(row.userId, row.status);
  464. }).then(() => {
  465. this.$modal.msgSuccess(text1 + "成功");
  466. }).catch(function() {
  467. // row.status = row.status === "0" ? "1" : "0";
  468. });
  469. },
  470. // 取消按钮
  471. cancel() {
  472. this.open = false;
  473. this.zijianopen = false;
  474. this.reset();
  475. },
  476. // 表单重置
  477. reset() {
  478. this.form = {
  479. userId: undefined,
  480. deptId: undefined,
  481. userName: undefined,
  482. password: undefined,
  483. phonenumber: undefined,
  484. email: undefined,
  485. sex: undefined,
  486. status: "0",
  487. remark: undefined,
  488. postIds: [],
  489. roleIds: []
  490. };
  491. this.resetForm("form");
  492. },
  493. /** 搜索按钮操作 */
  494. handleQuery() {
  495. this.queryParams.pageNum = 1;
  496. this.getList();
  497. },
  498. /** 重置按钮操作 */
  499. resetQuery() {
  500. this.dateRange = [];
  501. this.resetForm("queryForm");
  502. this.queryParams.deptId = undefined;
  503. this.$refs.tree.setCurrentKey(null);
  504. this.handleQuery();
  505. },
  506. // 多选框选中数据
  507. handleSelectionChange(selection) {
  508. this.ids = selection.map(item => item.userId);
  509. this.single = selection.length != 1;
  510. this.multiple = !selection.length;
  511. },
  512. // 更多操作触发
  513. handleCommand(command, row) {
  514. switch (command) {
  515. case "handleResetPwd":
  516. this.handleResetPwd(row);
  517. break;
  518. case "handleAuthRole":
  519. this.handleAuthRole(row);
  520. break;
  521. default:
  522. break;
  523. }
  524. },
  525. /** 新增按钮操作 */
  526. handleAdd() {
  527. this.reset();
  528. getUser().then(response => {
  529. this.postOptions = response.posts;
  530. this.roleOptions = response.roles;
  531. this.open = true;
  532. this.title = "新增训练任务";
  533. this.form.password = this.initPassword;
  534. });
  535. },
  536. /* 故障设置自检 **/
  537. handleInspect() {
  538. //this.reset();
  539. getUser().then(response => {
  540. //this.postOptions = response.posts;
  541. //this.roleOptions = response.roles;
  542. this.zijianopen = true;
  543. this.title = "故障设置自检";
  544. });
  545. },
  546. /** 修改按钮操作 */
  547. handleUpdate(row) {
  548. this.reset();
  549. const userId = row.userId || this.ids;
  550. getUser(userId).then(response => {
  551. this.form = response.data;
  552. this.postOptions = response.posts;
  553. this.roleOptions = response.roles;
  554. this.$set(this.form, "postIds", response.postIds);
  555. this.$set(this.form, "roleIds", response.roleIds);
  556. this.open = true;
  557. this.title = "修改用户";
  558. this.form.password = "";
  559. });
  560. },
  561. /** 重置密码按钮操作 */
  562. handleResetPwd(row) {
  563. this.$prompt('请输入"' + row.userName + '"的新密码', "提示", {
  564. confirmButtonText: "确定",
  565. cancelButtonText: "取消",
  566. closeOnClickModal: false,
  567. inputPattern: /^.{5,20}$/,
  568. inputErrorMessage: "用户密码长度必须介于 5 和 20 之间",
  569. inputValidator: (value) => {
  570. if (/<|>|"|'|\||\\/.test(value)) {
  571. return "不能包含非法字符:< > \" ' \\\ |"
  572. }
  573. },
  574. }).then(({ value }) => {
  575. resetUserPwd(row.userId, value).then(response => {
  576. this.$modal.msgSuccess("修改成功,新密码是:" + value);
  577. });
  578. }).catch(() => {});
  579. },
  580. /** 进入操作 */
  581. handleInto: function(row) {
  582. const userId = row.userId;
  583. console.log(userId)
  584. this.$router.push("/people/exam-exam1/examid/" + userId);
  585. },
  586. /** 提交按钮 */
  587. submitForm: function() {
  588. this.$refs["form"].validate(valid => {
  589. if (valid) {
  590. if (this.form.userId != undefined) {
  591. updateUser(this.form).then(response => {
  592. this.$modal.msgSuccess("修改成功");
  593. this.open = false;
  594. this.getList();
  595. });
  596. } else {
  597. addUser(this.form).then(response => {
  598. this.$modal.msgSuccess("新增成功");
  599. this.open = false;
  600. this.getList();
  601. });
  602. }
  603. }
  604. });
  605. },
  606. /** 删除按钮操作 */
  607. handleDelete(row) {
  608. const userIds = row.userId || this.ids;
  609. this.$modal.confirm('是否确认删除用户编号为"' + userIds + '"的数据项?').then(function() {
  610. return delUser(userIds);
  611. }).then(() => {
  612. this.getList();
  613. this.$modal.msgSuccess("删除成功");
  614. }).catch(() => {});
  615. },
  616. //训练任务下发
  617. handleIssued(row) {
  618. const userIds = row.userId || this.ids;
  619. this.$modal.confirm('是否确定编号为"' + userIds + '"的训练任务?').then(function() {
  620. //return delUser(userIds);
  621. }).then(() => {
  622. this.getList();
  623. this.$modal.msgSuccess("删除成功");
  624. }).catch(() => {});
  625. },
  626. /** 导出按钮操作 */
  627. handleExport() {
  628. this.download('simulator/user/export', {
  629. ...this.queryParams
  630. }, `user_${new Date().getTime()}.xlsx`)
  631. },
  632. /** 导入按钮操作 */
  633. handleImport() {
  634. this.upload.title = "用户导入";
  635. this.upload.open = true;
  636. },
  637. /** 下载模板操作 */
  638. importTemplate() {
  639. this.download('simulator/user/importTemplate', {
  640. }, `user_template_${new Date().getTime()}.xlsx`)
  641. },
  642. // 文件上传中处理
  643. handleFileUploadProgress(event, file, fileList) {
  644. this.upload.isUploading = true;
  645. },
  646. // 文件上传成功处理
  647. handleFileSuccess(response, file, fileList) {
  648. this.upload.open = false;
  649. this.upload.isUploading = false;
  650. this.$refs.upload.clearFiles();
  651. this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
  652. this.getList();
  653. },
  654. // 提交上传文件
  655. submitFileForm() {
  656. this.$refs.upload.submit();
  657. }
  658. }
  659. };
  660. </script>