index.vue 14 KB

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