index.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="10">
  4. <!-- <el-col :span="4" :xs="24">
  5. <org-tree v-model="queryParams.orgId" @defaultOrg="getDefaultOrg" @checkChange="checkChange"
  6. @click="clickTreeNode"></org-tree>
  7. </el-col> -->
  8. <el-col :span="24" :xs="24">
  9. <div class="main-right-box">
  10. <div class="main-search-box">
  11. <el-form
  12. :model="queryParams"
  13. ref="queryForm"
  14. size="small"
  15. :inline="true"
  16. v-show="showSearch"
  17. >
  18. <el-form-item label="受训机构">
  19. <org-tree
  20. v-model="queryParams.orgId"
  21. @defaultOrg="getDefaultOrg"
  22. @checkChange="checkChange"
  23. @click="clickTreeNode"
  24. :defaultCheckSub="true"
  25. ref="orgTree"
  26. ></org-tree>
  27. </el-form-item>
  28. <el-form-item label="任务名称" prop="title">
  29. <el-input
  30. v-model="queryParams.title"
  31. placeholder="请输入关键字"
  32. clearable
  33. maxlength="50"
  34. @keyup.enter.native="handleQuery"
  35. />
  36. </el-form-item>
  37. <el-form-item label="任务进度" prop="status">
  38. <el-select
  39. v-model="queryParams.status"
  40. placeholder="请选择任务进度"
  41. clearable
  42. >
  43. <el-option
  44. v-for="dict in dict.type.edu_training_do_status"
  45. :key="dict.value"
  46. :label="dict.label"
  47. :value="dict.value"
  48. />
  49. </el-select>
  50. </el-form-item>
  51. <!-- <el-form-item label="任务时间" prop="rangen">
  52. <el-date-picker
  53. v-model="queryParams.range"
  54. type="daterange"
  55. value-format="yyyy-MM-dd"
  56. placeholder="请选择任务时间段">
  57. </el-date-picker>
  58. </el-form-item> -->
  59. <el-form-item class="searchTitle" label="任务时间">
  60. <DataRangePicker
  61. v-model="queryParams.range"
  62. key="daterange"
  63. type="daterange"
  64. :clearable="timeClearable"
  65. />
  66. </el-form-item>
  67. <!-- <el-form-item label="培训类型" prop="type">
  68. <el-select v-model="queryParams.type" placeholder="请选择培训类型" clearable>
  69. <el-option
  70. v-for="dict in dict.type.edu_type"
  71. :key="dict.value"
  72. :label="dict.label"
  73. :value="dict.value"
  74. />
  75. </el-select>
  76. </el-form-item>-->
  77. <!-- <el-form-item>
  78. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  79. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  80. <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddTask">临时登记</el-button>
  81. <el-button type="primary" icon="el-icon-download" size="mini" @click="handleExport">导出数据</el-button>
  82. </el-form-item> -->
  83. </el-form>
  84. <el-row :gutter="10">
  85. <el-col :span="1.5">
  86. <el-button
  87. type="primary"
  88. icon="el-icon-search"
  89. size="mini"
  90. @click="handleQuery"
  91. >搜索</el-button
  92. >
  93. </el-col>
  94. <el-col :span="1.5">
  95. <el-button
  96. type="primary"
  97. icon="el-icon-refresh"
  98. size="mini"
  99. @click="resetQuery"
  100. >重置</el-button
  101. >
  102. </el-col>
  103. <el-col :span="1.5">
  104. <el-button
  105. type="primary"
  106. icon="el-icon-plus"
  107. size="mini"
  108. v-hasPermi="['core:eduTask:edit']"
  109. @click="handleAddTask"
  110. >临时登记</el-button
  111. >
  112. </el-col>
  113. <el-col :span="1.5">
  114. <el-button
  115. type="primary"
  116. icon="el-icon-download"
  117. size="mini"
  118. @click="handleExport"
  119. >导出数据</el-button
  120. >
  121. </el-col>
  122. <!-- <el-col :span="1.5">
  123. <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
  124. v-hasPermi="['core:plan:edit']">修改
  125. </el-button>
  126. </el-col>
  127. <el-col :span="1.5">
  128. <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
  129. v-hasPermi="['core:plan:remove']">删除
  130. </el-button>
  131. </el-col>
  132. <el-col :span="1.5">
  133. <el-button
  134. type="warning"
  135. plain
  136. icon="el-icon-download"
  137. size="mini"
  138. @click="handleExport"
  139. v-hasPermi="['core:plan:export']"
  140. >导出
  141. </el-button>
  142. </el-col>-->
  143. <right-toolbar
  144. :showSearch.sync="showSearch"
  145. @queryTable="getList"
  146. ></right-toolbar>
  147. </el-row>
  148. </div>
  149. <el-table
  150. border
  151. height="646"
  152. size="small"
  153. v-loading="loading"
  154. :data="eduTaskList"
  155. @selection-change="handleSelectionChange"
  156. >
  157. <el-table-column type="index" label="序号" align="center" width="60" prop="no">
  158. <template slot-scope="scope">
  159. {{
  160. (queryParams.pageNum - 1) * queryParams.pageSize +
  161. scope.$index +
  162. 1
  163. }}
  164. </template>
  165. </el-table-column>
  166. <el-table-column
  167. label="任务名称"
  168. align="center"
  169. width="315"
  170. prop="title"
  171. />
  172. <el-table-column
  173. label="地区"
  174. width="115"
  175. align="center"
  176. prop="affiliatedArea"
  177. />
  178. <el-table-column
  179. label="行社名称"
  180. width="315"
  181. align="center"
  182. prop="affiliatedBank"
  183. />
  184. <el-table-column
  185. label="受训机构"
  186. width="315"
  187. align="center"
  188. prop="orgName"
  189. />
  190. <el-table-column
  191. label="任务进度"
  192. align="center"
  193. prop="status"
  194. width="150"
  195. >
  196. <template slot-scope="scope">
  197. <dict-tag
  198. :options="dict.type.edu_training_do_status"
  199. :value="scope.row.status"
  200. />
  201. </template>
  202. </el-table-column>
  203. <!-- <el-table-column label="开始时间" align="center" prop="startDate" width="180">
  204. </el-table-column>
  205. <el-table-column label="截止时间" align="center" prop="endDate" width="180"></el-table-column> -->
  206. <el-table-column label="任务时间" align="center" width="300">
  207. <template slot-scope="scope">
  208. {{
  209. scope.row.startDate
  210. ? dayjs(scope.row.startDate).format("YYYY年MM月DD日") +
  211. " ~ " +
  212. dayjs(scope.row.endDate).format("YYYY年MM月DD日")
  213. : ""
  214. }}
  215. </template>
  216. </el-table-column>
  217. <!-- <el-table-column label="培训时间" align="center" prop="trainingStartDateTime" width="300">
  218. <template slot-scope="scope">
  219. {{
  220. scope.row.trainingStartDateTime
  221. ? (scope.row.trainingStartDateTime + " ~ " + scope.row.trainingEndDateTime) : ''
  222. }}
  223. </template>
  224. </el-table-column>-->
  225. <!-- <el-table-column label="培训角色" width="180" align="center" >
  226. <template slot-scope="scope">
  227. <template v-if="scope.row.taskRoleNameList ">
  228. <el-tag size="mini" type="success" v-for="(item, index) in (scope.row.taskRoleNameList || '').split(',')"
  229. :key="index">
  230. {{ item }}
  231. </el-tag>
  232. </template>
  233. </template>
  234. </el-table-column> -->
  235. <!-- <el-table-column label="培训类型" width="180" align="center" >
  236. <template slot-scope="scope">
  237. <dict-tag :options="dict.type.edu_type" :value="scope.row.type"/>
  238. </template>
  239. </el-table-column>
  240. <el-table-column label="主持人" width="140" align="center" prop="hostName" />-->
  241. <el-table-column
  242. label="操作"
  243. align="center"
  244. class-name="small-padding fixed-width"
  245. width="350"
  246. >
  247. <template slot-scope="scope">
  248. <el-button
  249. size="mini"
  250. type="text"
  251. icon="el-icon-view"
  252. @click="handleDetail(scope.row,scope.row.id,false)"
  253. v-hasPermi="['core:eduTask:list']"
  254. >详情
  255. </el-button>
  256. <!-- <el-button
  257. size="mini"
  258. type="text"
  259. icon="el-icon-edit"
  260. v-if="isSignature(scope.row)"
  261. @click="handleDetail(scope.row,scope.row.id,true)"
  262. >签名
  263. </el-button>-->
  264. <el-button
  265. size="mini"
  266. type="text"
  267. icon="el-icon-document-add"
  268. v-if="canPerform(scope.row)"
  269. @click="handleRecorded(scope.row.id)"
  270. v-hasPermi="['core:eduTask:edit']"
  271. >任务登记
  272. </el-button>
  273. <el-button
  274. size="mini"
  275. type="text"
  276. icon="el-icon-delete"
  277. v-if="canDelete(scope.row)"
  278. @click="handleDelete(scope.row.id)"
  279. v-hasPermi="['core:eduTask:remove']"
  280. >删除
  281. </el-button>
  282. <el-button
  283. icon="el-icon-document"
  284. type="text"
  285. size="mini"
  286. v-if="scope.row.pdfUrl"
  287. @click="onDown(scope.row.pdfUrl)"
  288. >培训登记簿
  289. </el-button>
  290. </template>
  291. </el-table-column>
  292. </el-table>
  293. <pagination
  294. v-show="total > 0"
  295. :total="total"
  296. :page.sync="queryParams.pageNum"
  297. :limit.sync="queryParams.pageSize"
  298. @pagination="getList"
  299. />
  300. </div>
  301. </el-col>
  302. </el-row>
  303. <dialog-info ref="infoDialog" @success="handleQuery(true)"></dialog-info>
  304. <dialog-perform
  305. ref="performDialog"
  306. @success="handleQuery(true)"
  307. ></dialog-perform>
  308. <dialog-new-task
  309. ref="newTaskDialog"
  310. @success="handleQuery(true)"
  311. ></dialog-new-task>
  312. </div>
  313. </template>
  314. <script>
  315. import {
  316. listEduTask,
  317. addEduTask,
  318. recordEduTask,
  319. delEduTask,
  320. } from "@/api/core/edu/eduTask";
  321. import DataRangePicker from "@/components/dateTime/daterange.picker.vue";
  322. import OrgTree from "@/components/orgTree/orgQuerySelector.vue";
  323. import DialogInfo from "./dialog.info";
  324. import DialogPerform from "./dialog.perform";
  325. import DialogNewTask from "./dialog.newTask";
  326. import dayjs from "dayjs";
  327. import tableList from "@/mixins/tableList";
  328. import { mapGetters } from "vuex";
  329. export default {
  330. name: "EduTask",
  331. dicts: ["edu_type", "edu_training_do_status"],
  332. components: {
  333. DialogInfo,
  334. DialogPerform,
  335. OrgTree,
  336. DialogNewTask,
  337. DataRangePicker,
  338. },
  339. mixins: [tableList],
  340. data() {
  341. return {
  342. // 遮罩层
  343. loading: true,
  344. // 选中数组
  345. ids: [],
  346. // 非单个停用
  347. single: true,
  348. // 非多个停用
  349. multiple: true,
  350. // 显示搜索条件
  351. showSearch: true,
  352. // 总条数
  353. total: 0,
  354. // 教育任务表格数据
  355. eduTaskList: [],
  356. timeClearable: true,
  357. // 弹出层标题
  358. title: "",
  359. // 是否显示弹出层
  360. open: false,
  361. // 查询参数
  362. queryParams: {
  363. pageNum: 1,
  364. pageSize: 10,
  365. checkSub: true,
  366. title: null,
  367. orgId: this.$store.getters.orgId,
  368. type: null,
  369. status: null,
  370. range: [],
  371. },
  372. // 表单参数
  373. form: {},
  374. // 表单校验
  375. rules: {
  376. orgId: [{ required: true, message: "机构不能为空", trigger: "blur" }],
  377. },
  378. selectedOrgName: null,
  379. };
  380. },
  381. beforeRouteEnter(to,from,next){
  382. console.log(from,'to')
  383. if(from.path === '/home'){
  384. next(vm=>{
  385. vm.queryParams.status = to.query.status;
  386. })
  387. }else {
  388. next()
  389. }
  390. },
  391. mounted() {
  392. this.getList();
  393. },
  394. computed: {
  395. ...mapGetters(["orgId", "orgName", "userId"]),
  396. },
  397. methods: {
  398. dayjs,
  399. /** 查询教育任务列表 */
  400. getList() {
  401. this.loading = true;
  402. listEduTask(this.queryParams).then((response) => {
  403. this.eduTaskList = response.rows;
  404. this.total = response.total;
  405. this.loading = false;
  406. });
  407. },
  408. // 取消按钮
  409. cancel() {
  410. this.open = false;
  411. this.reset();
  412. },
  413. // 表单重置
  414. reset() {
  415. this.form = {
  416. range: [],
  417. title: null,
  418. type: null,
  419. status: null,
  420. };
  421. this.resetForm("form");
  422. },
  423. /** 搜索按钮操作 */
  424. handleQuery() {
  425. this.queryParams.pageNum = 1;
  426. this.getList();
  427. },
  428. /** 重置按钮操作 */
  429. /** 重置按钮操作 */
  430. resetQuery() {
  431. this.clearQueryForm();
  432. this.handleQuery();
  433. },
  434. clearQueryForm() {
  435. this.queryParams.title = null;
  436. this.queryParams.status = null;
  437. this.queryParams.range = [new Date(),new Date()];
  438. this.queryParams.orgId = this.orgId;
  439. this.selectedOrgName = this.orgName;
  440. this.queryParams.checkSub = true;
  441. this.$refs["orgTree"].setCheckSub(this.queryParams.checkSub)
  442. },
  443. //单选框状态改变
  444. checkChange(state) {
  445. this.queryParams.checkSub = state;
  446. this.handleQuery();
  447. },
  448. getDefaultOrg(org) {
  449. this.queryParams.orgId = org.id;
  450. this.selectedOrgName = org.shortName;
  451. this.getList();
  452. },
  453. // 节点单击事件
  454. clickTreeNode(data) {
  455. this.queryParams.orgId = data.id;
  456. this.selectedOrgName = data.shortName;
  457. this.handleQuery();
  458. },
  459. // 多选框选中数据
  460. handleSelectionChange(selection) {
  461. this.ids = selection.map((item) => item.id);
  462. this.single = selection.length !== 1;
  463. this.multiple = !selection.length;
  464. },
  465. /** 新增按钮操作 */
  466. handleAdd() {
  467. this.reset();
  468. this.open = true;
  469. this.title = "添加教育任务";
  470. },
  471. /** 删除按钮操作 */
  472. handleDelete(id) {
  473. this.$modal
  474. .confirm("删除后不可恢复,是否确认删除该任务?")
  475. .then(function () {
  476. return delEduTask(id);
  477. })
  478. .then(() => {
  479. this.$modal.msgSuccess("删除成功");
  480. this.getList();
  481. })
  482. .catch(() => {});
  483. },
  484. /** 修改按钮操作 */
  485. handleDetail(row,id,isSignType) {
  486. console.log("this.$refs", this.$refs["infoDialog"]);
  487. this.$refs["infoDialog"].show(id, false, isSignType,{});
  488. // this.reset();
  489. // const id = row.id || this.ids
  490. // getEduTask(id).then(response => {
  491. // this.form = response.data;
  492. // this.open = true;
  493. // this.title = "修改教育任务";
  494. // });
  495. },
  496. /** 培训登记按钮操作 */
  497. handleRecorded(id) {
  498. this.$refs["performDialog"].show(id, {});
  499. },
  500. handleAddTask(id) {
  501. this.$refs["newTaskDialog"].show(id, {});
  502. },
  503. /** 导出按钮操作 */
  504. handleExport() {
  505. if (this.total==null || this.total===0){
  506. this.$modal.alert("暂无可用数据导出");
  507. return;
  508. }
  509. if (this.total>50000){
  510. this.$modal.alert("导出数据超过5万条,请缩小查询范围后重试");
  511. return;
  512. }
  513. this.download(
  514. "core/eduTask/export",
  515. {
  516. ...this.queryParams,
  517. },
  518. `${
  519. this.selectedOrgName
  520. }-${this.$tab.getCurrentTabName()}-${dayjs().format("YYYYMMDD")}.xlsx`
  521. );
  522. },
  523. canPerform(row) {
  524. console.log("row.status", row.status);
  525. if (row.status != 0 && row.status != 4) return false;
  526. let isCur = row.orgId == this.$store.getters.orgId;
  527. let isOver = this.isNotOverOrUnStart(row);
  528. return isCur && isOver;
  529. /*let flag = 0;
  530. if(!row.taskRoleList) return false;
  531. row.taskRoleList.forEach((taskRole) => {
  532. this.$store.getters.roleList.forEach((role) => {
  533. if (taskRole.roleId == role.roleId) {
  534. flag = 1;
  535. }
  536. });
  537. });
  538. return (flag == 1) && isOver;*/
  539. },
  540. canDelete(row) {
  541. //本机构用户可以删除
  542. return row.orgId == this.$store.getters.orgId && !row.planId;
  543. },
  544. isNotOverOrUnStart(row) {
  545. const currentTime = dayjs().startOf("day"); // 获取当前时间,并将时分秒部分设置为00时00分00秒
  546. const startDate = dayjs(row.startDate).startOf("day"); // 转换开始时间为 Moment.js 对象,并将时分秒部分设置为00时00分00秒
  547. const endDate = dayjs(row.endDate).startOf("day"); // 转换结束时间为 Moment.js 对象,并将时分秒部分设置为00时00分00秒
  548. return !(currentTime < startDate || currentTime > endDate);
  549. },
  550. async onDown(pdfUrl) {
  551. window.open(pdfUrl);
  552. },
  553. //判断是否展示签名按钮
  554. // isSignature(list) {
  555. // let falg = false
  556. // let timefalg = false
  557. // //value1 当前登陆用户ID
  558. // //当前时间再时间范围内且签名是待签名状态且签名列表存在当前登录人未签名的情况才可以进行签名
  559. // if (list.startDate && list.endDate && list.status == 1) {
  560. // let date = new Date().getTime()
  561. // let startDate = Date.parse(new Date(list.startDate));// Date.parse(new Date(list.startDate))
  562. // let endDate = Date.parse(new Date(list.endDate));// Date.parse(new Date(list.endDate))
  563. //
  564. // if (date >= startDate && date <= endDate) {
  565. // console.log(list.id, 'ssss')
  566. // timefalg = true
  567. // }
  568. // if (!list.planId) {
  569. // timefalg = true
  570. // }
  571. // }
  572. // if (list.userList && list.userList.length > 0) {
  573. // list.userList.forEach(item => {
  574. // if (this.userId == item.userId && item.sign === 0 && item.type == 1) {
  575. // falg = true
  576. // }
  577. // })
  578. // }
  579. //
  580. // if (falg && timefalg) {
  581. // return true
  582. // }
  583. // },
  584. },
  585. };
  586. </script>