index.vue 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="10">
  4. <!--机构数据-->
  5. <!-- <el-col :span="4" :xs="24">
  6. <org-tree v-model="queryParams.belongOrgId" @defaultKey="getDefaultKey" @checkChange="checkChange"
  7. @click="clickTreeNode" hangsheTree :defaultCheckSub="false"></org-tree>
  8. </el-col> -->
  9. <!--搜索栏-->
  10. <el-col :span="24" :xs="24">
  11. <div class="main-right-box">
  12. <div class="main-search-box">
  13. <el-form
  14. :model="queryParams"
  15. ref="queryForm"
  16. size="small"
  17. :inline="true"
  18. v-show="showSearch"
  19. >
  20. <el-form-item label="行社名称">
  21. <org-tree
  22. v-model="queryParams.belongOrgId"
  23. @defaultKey="getDefaultKey"
  24. @checkChange="checkChange"
  25. @click="clickTreeNode"
  26. hangsheTree
  27. :defaultCheckSub="false"
  28. ref="orgTree"
  29. ></org-tree>
  30. </el-form-item>
  31. <el-form-item label="任务名称" prop="planName">
  32. <el-input
  33. v-model="queryParams.planName"
  34. placeholder="请输入关键字"
  35. clearable
  36. @keyup.enter.native="handleQuery"
  37. />
  38. </el-form-item>
  39. <el-form-item label="机构类型" prop="execOrgType">
  40. <el-select
  41. v-model="queryParams.execOrgType"
  42. placeholder="请选择机构类型"
  43. clearable
  44. >
  45. <el-option
  46. v-for="dict in dict.type.sys_org_type"
  47. :key="dict.value"
  48. :label="dict.label"
  49. :value="dict.value"
  50. />
  51. </el-select>
  52. </el-form-item>
  53. <el-form-item label="任务状态" prop="planStatus">
  54. <el-select
  55. v-model="queryParams.planStatus"
  56. placeholder="请选择任务状态"
  57. clearable
  58. >
  59. <el-option
  60. v-for="dict in dict.type.drill_plan_status"
  61. :key="dict.value"
  62. :label="dict.label"
  63. :value="dict.value"
  64. />
  65. </el-select>
  66. </el-form-item>
  67. <el-form-item label="任务周期" prop="planCycle">
  68. <el-select
  69. v-model="queryParams.planCycle"
  70. placeholder="请选择任务周期"
  71. clearable
  72. >
  73. <el-option
  74. v-for="dict in dict.type.drill_plan_cycle"
  75. :key="dict.value"
  76. :label="dict.label"
  77. :value="dict.value"
  78. />
  79. </el-select>
  80. </el-form-item>
  81. <!-- <el-form-item label="演练角色" prop="planRoleId">
  82. <el-select v-model="queryParams.planRoleId" placeholder="请选择演练角色" clearable>
  83. <el-option v-for="item in planRoleList" :key="item.roleId" :label="item.roleName"
  84. :value="item.roleId"></el-option>
  85. </el-select>
  86. </el-form-item>-->
  87. <!-- <el-form-item>
  88. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  89. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  90. </el-form-item> -->
  91. </el-form>
  92. <el-row :gutter="10">
  93. <el-col :span="1.5">
  94. <el-button
  95. type="primary"
  96. icon="el-icon-search"
  97. size="mini"
  98. @click="handleQuery"
  99. >搜索
  100. </el-button
  101. >
  102. </el-col>
  103. <el-col :span="1.5">
  104. <el-button
  105. type="primary"
  106. icon="el-icon-refresh"
  107. size="mini"
  108. @click="resetQuery"
  109. >重置
  110. </el-button
  111. >
  112. </el-col>
  113. <el-col :span="1.5">
  114. <el-button
  115. type="primary"
  116. icon="el-icon-plus"
  117. size="mini"
  118. @click="handleAdd"
  119. v-hasPermi="['core:drillPlan:add']"
  120. >新增任务
  121. </el-button>
  122. </el-col>
  123. <right-toolbar
  124. :showSearch.sync="showSearch"
  125. @queryTable="getList"
  126. ></right-toolbar>
  127. </el-row>
  128. </div>
  129. <el-table
  130. height="646"
  131. border
  132. size="small"
  133. :data="planList"
  134. @selection-change="handleSelectionChange"
  135. row-key="id"
  136. :tree-props="{ children: 'children' }"
  137. >
  138. <el-table-column label="序号" align="center" width="60" prop="no"/>
  139. <el-table-column
  140. label="任务名称"
  141. align="center"
  142. prop="planName"
  143. :show-overflow-tooltip="true"
  144. />
  145. <el-table-column
  146. label="创建机构"
  147. align="center"
  148. width="220"
  149. prop="createOrgName"
  150. />
  151. <el-table-column
  152. label="行社名称"
  153. align="center"
  154. width="220"
  155. prop="belongOrgName"
  156. />
  157. <el-table-column
  158. label="机构类型"
  159. align="center"
  160. width="120"
  161. prop="execOrgType"
  162. >
  163. <template slot-scope="scope">
  164. <dict-tag
  165. :options="dict.type.sys_org_type"
  166. :value="scope.row.execOrgType"
  167. />
  168. </template>
  169. </el-table-column>
  170. <el-table-column
  171. label="任务周期"
  172. align="center"
  173. width="120"
  174. prop="planCycle"
  175. >
  176. <template slot-scope="scope">
  177. <dict-tag
  178. :options="dict.type.drill_plan_cycle"
  179. :value="scope.row.planCycle"
  180. />
  181. </template>
  182. </el-table-column>
  183. <el-table-column
  184. label="任务次数"
  185. align="center"
  186. width="120"
  187. prop="execTimes"
  188. />
  189. <el-table-column
  190. label="任务状态"
  191. align="center"
  192. width="120"
  193. prop="planStatus"
  194. >
  195. <template slot-scope="scope">
  196. <dict-tag
  197. :options="dict.type.drill_plan_status"
  198. :value="scope.row.planStatus"
  199. />
  200. </template>
  201. </el-table-column>
  202. <!-- <el-table-column label="备注" align="center" prop="remark"/> -->
  203. <!-- <el-table-column label="修改人" align="center" width="100" prop="updateBy"/> -->
  204. <el-table-column
  205. label="操作"
  206. align="center"
  207. fixed="right"
  208. width="200"
  209. class-name="small-padding fixed-width"
  210. >
  211. <template slot-scope="scope">
  212. <el-button
  213. v-if="checkCanPublish(scope.row)"
  214. size="mini"
  215. type="text"
  216. icon="el-icon-arrow-down"
  217. @click="handlePublish(scope.row)"
  218. v-hasPermi="['core:drillPlan:publish']"
  219. >下发
  220. </el-button>
  221. <el-button
  222. v-if="checkCanRevocation(scope.row)"
  223. size="mini"
  224. type="text"
  225. icon="el-icon-top-left"
  226. @click="handleRevocation(scope.row)"
  227. v-hasPermi="['core:plan:edit']"
  228. >撤回
  229. </el-button>
  230. <el-button
  231. v-if="checkCanEdit(scope.row)"
  232. size="mini"
  233. type="text"
  234. icon="el-icon-edit-outline"
  235. @click="handleUpdate(scope.row)"
  236. v-hasPermi="['core:drillPlan:edit']"
  237. >编辑
  238. </el-button>
  239. <el-button
  240. v-if="checkCanDel(scope.row)"
  241. size="mini"
  242. type="text"
  243. icon="el-icon-delete"
  244. @click="handleDelete(scope.row)"
  245. v-hasPermi="['core:drillPlan:remove']"
  246. >删除
  247. </el-button>
  248. </template>
  249. </el-table-column>
  250. </el-table>
  251. <pagination
  252. :total="total"
  253. :page.sync="queryParams.pageNum"
  254. :limit.sync="queryParams.pageSize"
  255. @pagination="getList"
  256. />
  257. </div>
  258. </el-col>
  259. </el-row>
  260. <!-- 添加或修改教育培训计划对话框 -->
  261. <DialogCom
  262. :title="title"
  263. :visible.sync="open"
  264. :before-close="closeDialog"
  265. :close="cancel"
  266. width="850px"
  267. height="800px"
  268. append-to-body
  269. >
  270. <el-form ref="form" :model="form" :rules="rules" label-width="110px">
  271. <el-row>
  272. <el-col :span="24">
  273. <el-form-item label="任务名称" prop="planName">
  274. <el-input
  275. v-model="form.planName"
  276. placeholder="请输入任务名称"
  277. maxlength="50"
  278. />
  279. </el-form-item>
  280. </el-col>
  281. <!-- <el-col :span="12">
  282. <el-form-item label="演练类型" prop="category">
  283. <el-select style="width: 100%" v-model="form.category" placeholder="请选择演练类型" @change="drillTypeSelected()">
  284. <el-option v-for="dict in dict.type.core_drill_category" :key="dict.value" :label="dict.label"
  285. :value="parseInt(dict.value)"></el-option>
  286. </el-select>
  287. </el-form-item>
  288. </el-col>-->
  289. </el-row>
  290. <el-row>
  291. <el-col :span="12">
  292. <el-form-item label="任务周期" prop="planCycle">
  293. <el-select
  294. v-model="form.planCycle"
  295. placeholder="请选择任务周期"
  296. style="width: 100%"
  297. :disabled="tableDisable()"
  298. >
  299. <el-option
  300. v-for="dict in dict.type.drill_plan_cycle"
  301. :key="dict.value"
  302. :label="dict.label"
  303. :value="parseInt(dict.value)"
  304. ></el-option>
  305. </el-select>
  306. </el-form-item>
  307. </el-col>
  308. <el-col :span="12">
  309. <el-form-item label="任务次数" prop="execTimes">
  310. <template>
  311. <el-input-number
  312. :disabled="tableDisable()"
  313. style="width: 100%"
  314. v-model="form.execTimes"
  315. :min="1"
  316. :max="10"
  317. ></el-input-number>
  318. </template>
  319. </el-form-item>
  320. </el-col>
  321. </el-row>
  322. <el-row>
  323. <el-col :span="12" v-show="form.planCycle == 0">
  324. <el-form-item prop="startDate" label="开始日期">
  325. <el-date-picker
  326. :disabled="tableDisable()"
  327. style="width: 100%"
  328. v-model="form.startDate"
  329. @change="startDateChanged"
  330. :picker-options="startDatepickerOptions"
  331. align="right"
  332. type="date"
  333. placeholder="选择开始日期"
  334. >
  335. </el-date-picker>
  336. </el-form-item>
  337. </el-col>
  338. <el-col :span="12" v-show="form.planCycle == 0">
  339. <el-form-item prop="endDate" label="结束日期">
  340. <el-date-picker
  341. :disabled="tableDisable()"
  342. style="width: 100%"
  343. v-model="form.endDate"
  344. :picker-options="endDatepickerOptions"
  345. align="right"
  346. type="date"
  347. placeholder="选择结束日期"
  348. >
  349. </el-date-picker>
  350. </el-form-item>
  351. </el-col>
  352. </el-row>
  353. <el-row>
  354. <!-- <el-col :span="12" v-show="showBuildTaskNow()">
  355. <el-form-item label="立即生效" prop="buildTaskNow">
  356. <el-checkbox v-model="form.buildTaskNow">
  357. 默认从下个周期...
  358. <el-popover placement="top-start" title="" width="200" trigger="hover"
  359. content="默认从下个周期生成任务,勾选后从当前周期立即生成任务">
  360. <i class="el-icon-warning-outline change-icon" slot="reference"></i>
  361. </el-popover>
  362. </el-checkbox>
  363. <el-checkbox v-model="form.buildTaskNow">
  364. 默认从下个周期生成任务,
  365. <br />
  366. 勾选后从当前周期立即生成任务
  367. </el-checkbox>
  368. </el-form-item>
  369. </el-col>
  370. <el-col :span="12">
  371. <el-form-item label="机构类型" prop="execOrgType">
  372. <el-select
  373. v-model="form.execOrgType"
  374. placeholder="请选择执行机构类型"
  375. @change="execOrgTypeChanged()"
  376. style="width: 100%"
  377. >
  378. <el-option
  379. v-for="dict in dict.type.sys_org_type"
  380. :key="dict.value"
  381. :label="dict.label"
  382. :value="parseInt(dict.value)"
  383. ></el-option>
  384. </el-select>
  385. </el-form-item>
  386. </el-col>-->
  387. <el-col :span="12">
  388. <el-form-item label="机构类型" prop="execOrgType">
  389. <el-select
  390. :disabled="tableDisable()"
  391. style="width: 100%"
  392. v-model="form.execOrgType"
  393. placeholder="请选择机构类型"
  394. @change="execOrgTypeChanged()"
  395. >
  396. <el-option
  397. v-for="dict in getUserOrgType"
  398. :key="dict.value"
  399. :label="dict.label"
  400. :value="parseInt(dict.value)"
  401. ></el-option>
  402. </el-select>
  403. </el-form-item>
  404. </el-col>
  405. <!-- <el-row>
  406. <el-col :span="12">
  407. <el-form-item label="演练角色" prop="planRoleId">
  408. <el-select v-model="form.planRoleId" placeholder="请选择" multiple style="width:100%">
  409. <el-option v-for="item in roleList" :key="item.id" :label="item.name" :value="item.id"></el-option>
  410. </el-select>
  411. </el-form-item>
  412. </el-col>
  413. <el-col :span="12">
  414. <el-form-item v-if="this.form.id" label="计划状态" prop="planStatus">
  415. <el-select v-model="form.planStatus" placeholder="请选择计划状态" style="width: 100%;">
  416. <el-option v-for="dict in dict.type.drill_plan_status" :key="dict.value" :label="dict.label"
  417. :value="parseInt(dict.value)"></el-option>
  418. </el-select>
  419. </el-form-item>
  420. </el-col>
  421. </el-row>-->
  422. <el-col :span="12">
  423. <el-form-item
  424. v-show="form.execOrgType"
  425. label="演练机构"
  426. prop="planExecOrgIdList"
  427. >
  428. <org-tree-select
  429. :disabled="tableDisable()"
  430. v-model="form.planExecOrgIdList"
  431. :queryData="form.execOrgType"
  432. ref="orgTreeSelect"
  433. :enabledCheckOrgTypes="form.execOrgType"
  434. :disable="true"
  435. >
  436. </org-tree-select>
  437. </el-form-item>
  438. </el-col>
  439. </el-row>
  440. <el-row>
  441. <el-col :span="24">
  442. <el-form-item label="备注" prop="remark">
  443. <el-input v-model="form.remark" placeholder="请输入备注" :disabled="tableDisable()"/>
  444. </el-form-item>
  445. </el-col>
  446. </el-row>
  447. <el-row>
  448. <el-col :span="12">
  449. <el-form-item label="上传文件" prop="fileList">
  450. <K-file-upload
  451. :disabled="tableDisable()"
  452. ref="upload"
  453. :defaultValue="formFileListDefualtValue"
  454. v-model="form.fileList"
  455. />
  456. </el-form-item>
  457. </el-col>
  458. </el-row>
  459. </el-form>
  460. <div slot="footer" class="dialog-footer">
  461. <el-button type="primary" @click="submitForm">确 定</el-button>
  462. <el-button @click="cancel">取 消</el-button>
  463. </div>
  464. </DialogCom>
  465. <DialogThreeState ref="DialogThreeState"></DialogThreeState>
  466. <!-- <DialogSelectFile
  467. ref="DialogSelectFile"
  468. :defaultSelect=defaultSelect
  469. @select="fileSelected"
  470. :orgId="orgId"
  471. ></DialogSelectFile> -->
  472. </div>
  473. </template>
  474. <script>
  475. import {
  476. addPlan,
  477. delPlan,
  478. getPlan,
  479. listPlan,
  480. listPlanRole,
  481. publishPlan,
  482. roleList,
  483. updatePlan,
  484. revocationPlan,
  485. } from "@/api/core/drill/drillPlan";
  486. import tableList from "@/mixins/tableList";
  487. import OrgTree from "@/components/orgTree/orgQuerySelector.vue";
  488. import {deptTreeSelect} from "@/api/system/public";
  489. import KFileUpload from "@/components/K-FileUpload/index.vue";
  490. // import DialogSelectFile from "./dialog.select.file.vue";
  491. import OrgTreeSelect from "@/components/orgTreeSelect";
  492. import dayjs from "dayjs";
  493. import {mapGetters} from "vuex";
  494. import DialogThreeState from "@/components/message/threeStateMessageBox.vue";
  495. export default {
  496. name: "Plan",
  497. dicts: [
  498. "sys_org_type",
  499. "drill_plan_status",
  500. "drill_plan_cycle",
  501. "core_drill_category",
  502. ],
  503. components: {OrgTree, KFileUpload, OrgTreeSelect, DialogThreeState},
  504. mixins: [tableList],
  505. data() {
  506. return {
  507. // 遮罩层
  508. loading: true,
  509. // 选中数组
  510. ids: [],
  511. // 非单个停用
  512. single: true,
  513. // 非多个停用
  514. multiple: true,
  515. // 显示搜索条件
  516. showSearch: true,
  517. // 总条数
  518. total: 0,
  519. // 教育培训计划表格数据
  520. planList: [],
  521. // 弹出层标题
  522. title: "",
  523. // 是否显示弹出层
  524. open: false,
  525. isUnfold: false,
  526. defaultSelect: [],
  527. orgId: null,
  528. // 查询参数
  529. queryParams: {
  530. execOrgType: null,
  531. planCycle: null,
  532. planStatus: null,
  533. planRoleId: null,
  534. planName: null,
  535. checkSub: false,
  536. pageNum: 1,
  537. pageSize: 10,
  538. belongOrgId: null,
  539. },
  540. formFileListDefualtValue: [],
  541. // 表单参数
  542. form: {},
  543. // 表单校验
  544. rules: {
  545. planName: [
  546. {required: true, message: "任务名称不能为空", trigger: "blur"},
  547. ],
  548. planCycle: [
  549. {required: true, message: "任务周期不能为空", trigger: "blur"},
  550. ],
  551. execTimes: [
  552. {required: true, message: "任务次数不能为空", trigger: "blur"},
  553. ],
  554. category: [
  555. {required: true, message: "演练类型不能为空", trigger: "blur"},
  556. ],
  557. execOrgType: [
  558. {required: true, message: "机构类型不能为空", trigger: "blur"},
  559. ],
  560. // planRoleId: [
  561. // {required: true, message: "演练角色不能为空", trigger: "blur"}
  562. // ],
  563. },
  564. planRoleList: [],
  565. roleList: [],
  566. //修改新增中的机构树
  567. deptOptions: [],
  568. startDatepickerOptions: {
  569. disabledDate(time) {
  570. const date = new Date();
  571. date.setTime(date.getTime() - 3600 * 1000 * 24);
  572. return time.getTime() < date;
  573. },
  574. },
  575. endDatepickerOptions: {
  576. disabledDate: this.disabledDate,
  577. },
  578. };
  579. },
  580. created() {
  581. this.getList();
  582. //this.initPlanRoleList();
  583. this.orgId = this.$store.getters.orgId;
  584. },
  585. computed: {
  586. getUserOrgType() {
  587. let tempArray = [];
  588. this.dict.type.sys_org_type.forEach((x) => {
  589. if (Number(x.value) >= this.$store.getters.orgType && (x.value != 7 && x.value != 8)) {
  590. tempArray.push(x);
  591. }
  592. });
  593. // console.log("computed getUserOrgType",tempArry);
  594. return tempArray;
  595. },
  596. },
  597. methods: {
  598. /** 查询预案演练计划列表 */
  599. getList() {
  600. this.loading = true;
  601. listPlan(this.queryParams).then((response) => {
  602. this.planList = response.rows;
  603. this.total = response.total;
  604. this.loading = false;
  605. });
  606. },
  607. delayFlush(time) {
  608. setTimeout(() => {
  609. this.getList()
  610. }, time)
  611. },
  612. //初始化与计划相关的角色信息
  613. initPlanRoleList() {
  614. listPlanRole({}).then((response) => {
  615. this.planRoleList = response.data;
  616. });
  617. },
  618. //初始化所有角色数据
  619. initRoleList(query) {
  620. this.form.planRoleId = [];
  621. roleList(query).then((response) => {
  622. this.roleList = response.data;
  623. });
  624. },
  625. startDateChanged(time) {
  626. if (this.form.startDate > this.form.endDate) {
  627. this.form.endDate = this.form.startDate;
  628. }
  629. },
  630. disabledDate(time) {
  631. //小于开始日期禁止选择
  632. let startDate = new Date();
  633. startDate.setTime(startDate.getTime() - 3600 * 1000 * 24);
  634. if (this.form.startDate) {
  635. startDate = new Date(
  636. this.formatTime(this.form.startDate, "YYYY-MM-DD")
  637. );
  638. startDate.setTime(startDate.getTime() - 3600 * 1000 * 24);
  639. }
  640. return time.getTime() < new Date(startDate).getTime();
  641. },
  642. //已完成下发的计划不显示下发按钮
  643. checkCanPublish(row) {
  644. if (
  645. row.issue == 0 &&
  646. row.standard == 1 &&
  647. (row.planStatus == 0 || row.planStatus == 2) &&
  648. this.checkCanEdit(row)
  649. ) {
  650. return true;
  651. }
  652. return false;
  653. },
  654. //撤回按钮
  655. checkCanRevocation(row) {
  656. return row.planStatus == 1 && row.standard == 1 && this.checkCanEdit(row);
  657. },
  658. //所属机构为当前用户登录机构时才显示 “编辑、删除”按钮
  659. checkCanEdit(row) {
  660. console.log("checkCanEdit", this.$store.getters.orgId, row.belongOrgId)
  661. return (
  662. row.belongOrgId == this.$store.getters.orgId && row.createOrgId == this.$store.getters.orgId
  663. );
  664. },
  665. checkCanDel(row) {
  666. // console.log("checkCanEdit",this.$store.getters.orgId,row)
  667. // 计划仅能够通过删除标准计划来删除
  668. /* return (row.belongOrgId == this.$store.getters.orgId || row.createOrgId == this.$store.getters.orgId)
  669. && (row.issue != 1 || (row.issue == 1 && row.done != 1))*/
  670. return (
  671. (row.standard == 1 || row.standard == 2) && /*row.done != 1 &&*/
  672. this.checkCanEdit(row)
  673. );
  674. },
  675. //省联社下发的计划不显示“删除”按钮
  676. checkCreateByTopOrg(row) {
  677. return row.createByTopOrg !== 1;
  678. },
  679. execOrgTypeChanged(row) {
  680. this.$refs["orgTreeSelect"].clear();
  681. // this.initRoleList(this.form.execOrgType);
  682. // this.form.planExecOrgIdList = [];
  683. },
  684. showBuildTaskNow() {
  685. //如果是新增的情况下
  686. if (!this.form.id) {
  687. return this.form.planCycle != 0;
  688. } else {
  689. //如果是编辑的情况下,判断是否是标准计划
  690. /*if (this.form.standard==1){
  691. return this.form.planCycle != 0&&this.form.issue == 0
  692. }*/
  693. return this.form.planStatus == 0 && this.form.planCycle != 0;
  694. }
  695. },
  696. /** 查询机构树数据 */
  697. getDeptTree() {
  698. deptTreeSelect().then((response) => {
  699. this.deptOptions = response.data;
  700. });
  701. },
  702. // 取消按钮
  703. cancel() {
  704. this.open = false;
  705. this.reset();
  706. this.$refs["orgTreeSelect"].clear();
  707. this.$refs["upload"].clearFiles();
  708. },
  709. closeDialog() {
  710. this.cancel();
  711. },
  712. // 表单重置
  713. reset() {
  714. this.form = {
  715. id: null,
  716. planName: null,
  717. planCycle: null,
  718. execTimes: null,
  719. planStatus: null,
  720. execOrgType: null,
  721. planExecOrgIdList: null,
  722. startDate: null,
  723. endDate: null,
  724. buildTaskNow: null,
  725. remark: null,
  726. planRoleId: null,
  727. fileList: null,
  728. standard: null,
  729. category: null,
  730. checkSub: true,
  731. done: null,
  732. };
  733. this.resetForm("form");
  734. },
  735. getDefaultKey(key) {
  736. this.queryParams.belongOrgId = key;
  737. this.getList();
  738. },
  739. //单选框状态改变
  740. checkChange(state) {
  741. this.queryParams.checkSub = state;
  742. this.handleQuery();
  743. },
  744. // 节点单击事件
  745. clickTreeNode(data) {
  746. //this.initPlanRoleList();
  747. this.queryParams.belongOrgId = data.id;
  748. this.handleQuery();
  749. },
  750. /** treeSelect组件自定义数据*/
  751. tenantIdnormalizer(node, instanceId) {
  752. if (node.children && !node.children.length) {
  753. delete node.children;
  754. }
  755. return {
  756. id: node.id,
  757. label: node.name,
  758. children: node.children,
  759. };
  760. },
  761. /** 搜索按钮操作 */
  762. handleQuery() {
  763. this.queryParams.pageNum = 1;
  764. this.getList();
  765. },
  766. /** 重置按钮操作 */
  767. resetQuery() {
  768. this.resetForm("queryForm");
  769. this.queryParams.belongOrgId = this.$store.getters.orgId;
  770. this.queryParams.checkSub = false;
  771. this.$refs["orgTree"].setCheckSub(this.queryParams.checkSub)
  772. this.handleQuery();
  773. },
  774. // 多选框选中数据
  775. handleSelectionChange(selection) {
  776. this.ids = selection.map((item) => item.id);
  777. this.single = selection.length !== 1;
  778. this.multiple = !selection.length;
  779. },
  780. /** 新增按钮操作 */
  781. handleAdd() {
  782. //this.initRoleList();
  783. this.getDeptTree();
  784. this.reset();
  785. this.open = true;
  786. this.title = "新增演练任务";
  787. },
  788. /** 修改按钮操作 */
  789. handleUpdate(row) {
  790. // this.initRoleList();
  791. this.getDeptTree();
  792. this.reset();
  793. const id = row.id || this.ids;
  794. getPlan(id).then((response) => {
  795. this.form = response.data;
  796. this.formFileListDefualtValue = this.form.fileList;
  797. this.open = true;
  798. this.title = "编辑演练任务";
  799. });
  800. },
  801. drillTypeSelected() {
  802. if (this.form.category == 0) {
  803. this.form.planCycle = 4;
  804. this.form.execTimes = 1;
  805. this.form.execOrgType = 4;
  806. }
  807. if (this.form.category == 1) {
  808. this.form.planCycle = 6;
  809. this.form.execTimes = 2;
  810. this.form.execOrgType = 4;
  811. }
  812. },
  813. /** 提交按钮 */
  814. submitForm() {
  815. if (dayjs(this.form.startDate).isAfter(dayjs(this.form.endDate))) {
  816. this.$message.error("开始时间不能大于结束时间!");
  817. return;
  818. }
  819. this.$refs["form"].validate((valid) => {
  820. if (valid) {
  821. let request = {...this.form};
  822. console.log("request", request);
  823. if (this.form.planExecOrgIdList) {
  824. const list = Array.isArray(this.form.planExecOrgIdList)
  825. ? this.form.planExecOrgIdList
  826. : [this.form.planExecOrgIdList];
  827. request.planExecOrgIdList = list;
  828. } else {
  829. request.planExecOrgIdList = [];
  830. }
  831. if (request.id != null) {
  832. let msg = "";
  833. if (this.form.planStatus == 1) {
  834. if (this.form.done == 1) {
  835. msg = "因存在已完成任务,本次修改内容将从下周期生效";
  836. } else {
  837. msg = "因不存在已完成任务,本次修改内容将立即生效";
  838. }
  839. } else {
  840. msg = "是否确认修改?";
  841. }
  842. this.$modal
  843. .confirm(msg)
  844. .then(function () {
  845. return updatePlan(request);
  846. })
  847. .then(() => {
  848. this.$modal.msgSuccess("编辑成功");
  849. this.open = false;
  850. this.getList();
  851. this.$refs["upload"].clearFiles();
  852. })
  853. .catch(() => {
  854. });
  855. } else {
  856. addPlan(request).then((response) => {
  857. this.$modal.msgSuccess("新增成功");
  858. this.open = false;
  859. this.getList();
  860. this.$refs["upload"].clearFiles();
  861. });
  862. }
  863. }
  864. });
  865. },
  866. /** 删除按钮操作 */
  867. handleDelete(row) {
  868. let msg = "";
  869. if (row.planStatus == 0) {
  870. msg = '是否确认删除名称为"' + row.planName + '"的任务?';
  871. } else if (row.planStatus == 1) {
  872. if (row.planCycle == 1) {
  873. msg = "本次删除将强制删除今日所有任务?";
  874. } else {
  875. msg = "本次删除将强制删除当前任务时间及以后所有任务";
  876. }
  877. } else if (row.planStatus == 2) {
  878. if (row.planCycle == 1) {
  879. msg = "本次删除将强制删除今日所有任务";
  880. } else {
  881. msg = "本次删除将强制删除当前任务时间及以后所有任务";
  882. }
  883. }
  884. const ids = row.id || this.ids;
  885. this.$modal
  886. .confirm(msg)
  887. .then(function () {
  888. return delPlan(ids);
  889. })
  890. .then(() => {
  891. this.getList();
  892. this.$modal.msgSuccess("删除成功");
  893. })
  894. .catch(() => {
  895. });
  896. },
  897. /** 下发计划 */
  898. handlePublish(row) {
  899. let msg = "";
  900. if (row.planCycle == 0) {
  901. this.$modal
  902. .confirm("无周期任务下发将会立即生成任务,是否确认下发?", {
  903. confirmButtonText: "确定",
  904. canelButtonText: "取消",
  905. })
  906. .then(() => {
  907. publishPlan(row.id, 1);
  908. this.delayFlush(200);
  909. });
  910. } else {
  911. if (row.planStatus == 0) {
  912. msg = "请选择下发后立即生成或下周期生成任务?";
  913. this.$refs["DialogThreeState"].show(
  914. msg,
  915. (state) => {
  916. if (state == 0 || state == 1) {
  917. publishPlan(row.id, state);
  918. this.delayFlush(200);
  919. }
  920. },
  921. {
  922. yesText: "立即生成",//1
  923. noText: "下周期",//0
  924. cancelText: "取消",
  925. }
  926. );
  927. } else if (row.planStatus == 2) {
  928. this.$modal
  929. .confirm("因存在已完成任务,是否确定从下周期生成任务", {
  930. confirmButtonText: "确定",
  931. canelButtonText: "取消",
  932. })
  933. .then(() => {
  934. publishPlan(row.id, 0);
  935. this.delayFlush(200);
  936. });
  937. }
  938. }
  939. },
  940. //撤回计划
  941. handleRevocation(row) {
  942. if (row.id != null) {
  943. let msg = "";
  944. //无周期
  945. if (row.planCycle == 0) {
  946. if (row.done == 1) {
  947. msg = '因存在已完成任务,无周期任务不允许撤回,如需删除下发任务请点击"删除"';
  948. this.$alert(msg, '系统提示', {
  949. confirmButtonText: "确认"
  950. })
  951. return
  952. } else {
  953. msg = "因不存在已完成任务,撤回后将删除所有生成任务";
  954. }
  955. } else {
  956. //有周期
  957. if (row.done == 1) {
  958. msg =
  959. "因存在已完成任务,撤回后下周期起将不再生成任务";
  960. } else {
  961. msg = "因不存在已完成任务,撤回后将删除所有生成任务";
  962. }
  963. }
  964. this.$modal
  965. .confirm(msg)
  966. .then(function () {
  967. return revocationPlan(row.id);
  968. })
  969. .then(() => {
  970. this.$modal.msgSuccess("撤回成功");
  971. this.getList();
  972. })
  973. .catch(() => {
  974. });
  975. }
  976. },
  977. /** 导出按钮操作 */
  978. handleExport() {
  979. this.download(
  980. "system/plan/export",
  981. {
  982. ...this.queryParams,
  983. },
  984. `plan_${new Date().getTime()}.xlsx`
  985. );
  986. },
  987. tableDisable() {
  988. return this.form.planStatus == 1;
  989. },
  990. // showSelectFile() {
  991. // this.$refs["DialogSelectFile"].show();
  992. // },
  993. getMsgStr(row, type) {
  994. let str = "是否确认" + type + "该任务?";
  995. if (row.standard == 1) {
  996. str = "此操作将会影响所有行社任务," + str;
  997. }
  998. return str;
  999. },
  1000. fileSelected(list) {
  1001. console.log("fileSelected", list);
  1002. if (!list) return;
  1003. list.forEach((x) => {
  1004. this.form.fileList = this.form.fileList.concat(x.fileList);
  1005. });
  1006. },
  1007. },
  1008. };
  1009. </script>