index.vue 12 KB

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