index.vue 30 KB

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