index.vue 33 KB

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