index.vue 13 KB

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