index.vue 13 KB

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