index.vue 14 KB

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