index.vue 10 KB

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