index.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="20">
  4. <el-col :span="4" :xs="24">
  5. <org-tree v-model="queryParams.orgId" @defaultKey="getDefaultKey" @checkChange="checkChange"
  6. @click="clickTreeNode" businessTree></org-tree>
  7. </el-col>
  8. <el-col :span="20" :xs="24">
  9. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
  10. <el-form-item label="培训主题" prop="title">
  11. <el-input
  12. v-model="queryParams.title"
  13. placeholder="请输入培训主题"
  14. clearable
  15. @keyup.enter.native="handleQuery"
  16. />
  17. </el-form-item>
  18. <el-form-item label="培训进度" prop="status">
  19. <el-select v-model="queryParams.status" placeholder="请选择培训进度" clearable>
  20. <el-option
  21. v-for="dict in dict.type.edu_task_status"
  22. :key="dict.value"
  23. :label="dict.label"
  24. :value="dict.value"
  25. />
  26. </el-select>
  27. </el-form-item>
  28. <el-form-item label="计划时间" prop="rangen">
  29. <el-date-picker
  30. v-model="queryParams.range"
  31. type="daterange"
  32. value-format="yyyy-MM-dd"
  33. placeholder="请选择开始日期">
  34. </el-date-picker>
  35. </el-form-item>
  36. <!-- <el-form-item label="培训类型" prop="type">
  37. <el-select v-model="queryParams.type" placeholder="请选择培训类型" clearable>
  38. <el-option
  39. v-for="dict in dict.type.edu_type"
  40. :key="dict.value"
  41. :label="dict.label"
  42. :value="dict.value"
  43. />
  44. </el-select>
  45. </el-form-item>-->
  46. <el-form-item>
  47. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  48. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  49. </el-form-item>
  50. </el-form>
  51. <el-table
  52. border
  53. height="600"
  54. size="small" v-loading="loading" :data="eduTaskList" @selection-change="handleSelectionChange">
  55. <el-table-column label="序号" align="center" prop="no" />
  56. <el-table-column label="培训主题" width="200" align="left" prop="title" />
  57. <el-table-column label="培训机构" width="200" align="left" prop="orgName" />
  58. <el-table-column label="开始时间" align="center" prop="startDate" width="180">
  59. </el-table-column>
  60. <el-table-column label="截止时间" align="center" prop="endDate" width="180"></el-table-column>
  61. <el-table-column label="培训进度" align="center" prop="status" >
  62. <template slot-scope="scope">
  63. <dict-tag :options="dict.type.edu_task_status" :value="scope.row.status"/>
  64. </template>
  65. </el-table-column>
  66. <el-table-column label="培训登记时间" align="center" prop="trainingStartDateTime" width="180">
  67. </el-table-column>
  68. <!-- <el-table-column label="培训角色" width="180" align="center" >
  69. <template slot-scope="scope">
  70. <template v-if="scope.row.taskRoleNameList ">
  71. <el-tag size="mini" type="success" v-for="(item, index) in (scope.row.taskRoleNameList || '').split(',')"
  72. :key="index">
  73. {{ item }}
  74. </el-tag>
  75. </template>
  76. </template>
  77. </el-table-column> -->
  78. <!-- <el-table-column label="培训类型" width="180" align="center" >
  79. <template slot-scope="scope">
  80. <dict-tag :options="dict.type.edu_type" :value="scope.row.type"/>
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="主持人" width="140" align="center" prop="hostName" />-->
  84. <el-table-column label="操作" fixed="right" width="120px" align="center" class-name="small-padding fixed-width">
  85. <template slot-scope="scope">
  86. <el-button
  87. size="mini"
  88. type="text"
  89. icon="el-icon-view"
  90. @click="handleDetail(scope.row.id)"
  91. v-hasPermi="['core:eduTask:list']"
  92. >详情</el-button>
  93. <el-button
  94. size="mini"
  95. type="text"
  96. icon="el-icon-document-add"
  97. v-if="canPerform(scope.row)"
  98. @click="handleRecorded(scope.row.id)"
  99. v-hasPermi="['core:eduTask:remove']"
  100. >培训登记</el-button>
  101. <el-button type="text" v-if="scope.row.pdfUrl" @click="onDown(scope.row.pdfUrl)"
  102. >培训登记簿
  103. </el-button>
  104. </template>
  105. </el-table-column>
  106. </el-table>
  107. <pagination
  108. v-show="total>0"
  109. :total="total"
  110. :page.sync="queryParams.pageNum"
  111. :limit.sync="queryParams.pageSize"
  112. @pagination="getList"
  113. />
  114. </el-col>
  115. </el-row>
  116. <dialog-info ref="infoDialog" @success="handleQuery(true)"></dialog-info>
  117. <dialog-perform ref="performDialog" @success="handleQuery(true)"></dialog-perform>
  118. </div>
  119. </template>
  120. <script>
  121. import { listEduTask, getEduTask, delEduTask, addEduTask, updateEduTask } from "@/api/core/edu/eduTask";
  122. import OrgTree from "@/components/orgTree";
  123. import DialogInfo from "./dialog.info";
  124. import DialogPerform from "./dialog.perform";
  125. import dayjs from "dayjs";
  126. export default {
  127. name: "EduTask",
  128. dicts: ['edu_task_status', 'edu_type'],
  129. components: {
  130. DialogInfo,
  131. DialogPerform,
  132. OrgTree
  133. },
  134. data() {
  135. return {
  136. // 遮罩层
  137. loading: true,
  138. // 选中数组
  139. ids: [],
  140. // 非单个禁用
  141. single: true,
  142. // 非多个禁用
  143. multiple: true,
  144. // 显示搜索条件
  145. showSearch: true,
  146. // 总条数
  147. total: 0,
  148. // 教育任务表格数据
  149. eduTaskList: [],
  150. // 弹出层标题
  151. title: "",
  152. // 是否显示弹出层
  153. open: false,
  154. // 查询参数
  155. queryParams: {
  156. pageNum: 1,
  157. pageSize: 10,
  158. checkSub:true,
  159. title: null,
  160. orgId: this.$store.getters.orgId,
  161. type: null,
  162. status: null,
  163. range: null,
  164. },
  165. // 表单参数
  166. form: {},
  167. // 表单校验
  168. rules: {
  169. orgId: [
  170. { required: true, message: "机构不能为空", trigger: "blur" }
  171. ],
  172. }
  173. };
  174. },
  175. created() {
  176. this.getList();
  177. },
  178. methods: {
  179. /** 查询教育任务列表 */
  180. getList() {
  181. this.loading = true;
  182. listEduTask(this.queryParams).then(response => {
  183. this.eduTaskList = response.rows;
  184. this.total = response.total;
  185. this.loading = false;
  186. });
  187. },
  188. // 取消按钮
  189. cancel() {
  190. this.open = false;
  191. this.reset();
  192. },
  193. // 表单重置
  194. reset() {
  195. this.form = {
  196. range:[],
  197. title: null,
  198. type: null,
  199. status : null,
  200. };
  201. this.resetForm("form");
  202. },
  203. /** 搜索按钮操作 */
  204. handleQuery() {
  205. this.queryParams.pageNum = 1;
  206. this.getList();
  207. },
  208. /** 重置按钮操作 */
  209. resetQuery() {
  210. this.resetForm("queryForm");
  211. this.handleQuery();
  212. },
  213. //单选框状态改变
  214. checkChange(state) {
  215. this.queryParams.checkSub = state;
  216. this.handleQuery();
  217. },
  218. getDefaultKey(key) {
  219. this.queryParams.orgId = key;
  220. this.getList();
  221. },
  222. // 节点单击事件
  223. clickTreeNode(data) {
  224. this.queryParams.orgId = data.id;
  225. this.handleQuery();
  226. },
  227. // 多选框选中数据
  228. handleSelectionChange(selection) {
  229. this.ids = selection.map(item => item.id)
  230. this.single = selection.length!==1
  231. this.multiple = !selection.length
  232. },
  233. /** 新增按钮操作 */
  234. handleAdd() {
  235. this.reset();
  236. this.open = true;
  237. this.title = "添加教育任务";
  238. },
  239. /** 修改按钮操作 */
  240. handleDetail(id) {
  241. console.log("this.$refs",this.$refs["infoDialog"])
  242. this.$refs["infoDialog"].show(id,{});
  243. // this.reset();
  244. // const id = row.id || this.ids
  245. // getEduTask(id).then(response => {
  246. // this.form = response.data;
  247. // this.open = true;
  248. // this.title = "修改教育任务";
  249. // });
  250. },
  251. /** 提交按钮 */
  252. submitForm() {
  253. this.$refs["form"].validate(valid => {
  254. if (valid) {
  255. if (this.form.id != null) {
  256. updateEduTask(this.form).then(response => {
  257. this.$modal.msgSuccess("修改成功");
  258. this.open = false;
  259. this.getList();
  260. });
  261. } else {
  262. addEduTask(this.form).then(response => {
  263. this.$modal.msgSuccess("新增成功");
  264. this.open = false;
  265. this.getList();
  266. });
  267. }
  268. }
  269. });
  270. },
  271. /** 培训登记按钮操作 */
  272. handleRecorded(id) {
  273. this.$refs["performDialog"].show(id,{});
  274. },
  275. /** 导出按钮操作 */
  276. handleExport() {
  277. this.download('system/eduTask/export', {
  278. ...this.queryParams
  279. }, `eduTask_${new Date().getTime()}.xlsx`)
  280. },
  281. canPerform(row) {
  282. // debugger
  283. let flag = 0;
  284. if(row.status>0) return false;
  285. if(!row.taskRoleList) return false;
  286. let isOver =this.isNotOverOrUnStart(row);
  287. row.taskRoleList.forEach((taskRole) => {
  288. this.$store.getters.roleList.forEach((role) => {
  289. if (taskRole.roleId == role.roleId) {
  290. flag = 1;
  291. }
  292. });
  293. });
  294. return (flag == 1) && isOver;
  295. },
  296. isNotOverOrUnStart(row) {
  297. const currentTime = dayjs().startOf('day'); // 获取当前时间,并将时分秒部分设置为00时00分00秒
  298. const startDate = dayjs(row.startDate).startOf('day'); // 转换开始时间为 Moment.js 对象,并将时分秒部分设置为00时00分00秒
  299. const endDate = dayjs(row.endDate).startOf('day'); // 转换结束时间为 Moment.js 对象,并将时分秒部分设置为00时00分00秒
  300. return !(currentTime < startDate || currentTime > endDate);
  301. },
  302. async onDown(pdfUrl) {
  303. window.open(pdfUrl);
  304. },
  305. }
  306. };
  307. </script>