dialog.edit.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  1. <template>
  2. <div class="rule-type">
  3. <DialogCom
  4. @colse="onHide"
  5. :title="id ? '编辑履职计划' : '新增履职计划'"
  6. :visible.sync="isShow"
  7. width="1500px"
  8. >
  9. <div class="page-body">
  10. <el-form
  11. :model="formData"
  12. :rules="formDataRules"
  13. size="small"
  14. ref="form"
  15. label-position="right"
  16. label-width="130px"
  17. label-prefix=":"
  18. >
  19. <el-row>
  20. <el-col :span="6">
  21. <el-form-item prop="planName" label="计划名称:">
  22. <el-input
  23. v-model.trim="formData.planName"
  24. :maxlength="50"
  25. name="planName"
  26. placeholder="请输入计划名称"
  27. clearable
  28. />
  29. </el-form-item>
  30. </el-col>
  31. <el-col :span="6">
  32. <el-form-item prop="planType" label="计划类型:">
  33. <el-select
  34. :disabled="isChildren()"
  35. @change="changeData"
  36. label="计划类型"
  37. v-model="formData.planType"
  38. placeholder="请选择计划类型"
  39. clearable
  40. >
  41. <el-option
  42. v-for="dict in dict.type.resumption_plan_type"
  43. :key="dict.value"
  44. :label="dict.label"
  45. :value="dict.value"
  46. >
  47. </el-option>
  48. </el-select>
  49. </el-form-item>
  50. </el-col>
  51. <el-col :span="6">
  52. <el-form-item prop="planCycle" label="履职周期:">
  53. <el-select
  54. @change="changeBuildTime"
  55. :disabled="isChildren()"
  56. prop="planCycle"
  57. label="履职周期"
  58. v-model="formData.planCycle"
  59. placeholder="请选择履职周期"
  60. clearable
  61. >
  62. <el-option
  63. v-for="item in dict.type.resumption_plan_cycle"
  64. :key="item.value"
  65. :label="item.label"
  66. :value="item.value"
  67. >
  68. </el-option>
  69. </el-select>
  70. <el-form-item>
  71. <div class="form-item-comment">
  72. 下次任务生成时间{{ buildTime }}
  73. </div>
  74. </el-form-item>
  75. </el-form-item>
  76. </el-col>
  77. <!-- <el-col :span="6">
  78. <el-form-item prop="planStatus" label="计划状态:"> -->
  79. <!-- <el-select
  80. :disabled="getDistributePlanStatus()"
  81. prop="planStatus"
  82. label="计划状态"
  83. v-model="formData.planStatus"
  84. placeholder="请选择计划状态"
  85. clearable
  86. >
  87. <el-option
  88. v-for="item in dict.type.resumption_plan_status"
  89. :key="item.value"
  90. :label="item.label"
  91. :value="item.value"
  92. >
  93. </el-option>
  94. </el-select> -->
  95. <!-- <el-switch
  96. v-model="formData.planStatus"
  97. active-value="1"
  98. inactive-value="0"
  99. ></el-switch> -->
  100. <!-- </el-form-item> -->
  101. <!-- </el-col> -->
  102. <el-col :span="6" v-if="id ? false : true">
  103. <el-form-item prop="tempBuildTaskNow" label="立即生效:" >
  104. <el-checkbox
  105. v-model="tempBuildTaskNow"
  106. size="medium"
  107. @change="handleCheckboxChange"
  108. >默认从下个周期生成任务,<br>勾选后从当前周期立即生成任务</el-checkbox
  109. >
  110. </el-form-item>
  111. </el-col>
  112. </el-row>
  113. <el-row>
  114. <el-col :span="6">
  115. <el-form-item prop="execOrgType" label="履职机构类型:">
  116. <el-select
  117. :disabled="isChildren()"
  118. label="履职机构类型"
  119. v-model="formData.execOrgType"
  120. placeholder="请选择履职机构类型"
  121. @change="onOrgTypeChanged"
  122. clearable
  123. >
  124. <el-option
  125. v-for="item in dict.type.sys_org_type"
  126. :key="item.value"
  127. :label="item.label"
  128. :value="item.value"
  129. >
  130. </el-option>
  131. </el-select>
  132. </el-form-item>
  133. </el-col>
  134. <el-col :span="6">
  135. <el-form-item prop="roleList" label="履职角色:">
  136. <el-select
  137. @visible-change="onOrgTypeChanged"
  138. :disabled="isChildren()"
  139. label="履职角色"
  140. v-model="formData.roleList"
  141. placeholder="请选择履职角色"
  142. multiple
  143. filterable
  144. @change="handleRolesChange"
  145. >
  146. <el-option
  147. v-for="item in resumptionRoles"
  148. :key="item.id"
  149. :label="item.name"
  150. :value="item.id"
  151. >
  152. </el-option>
  153. </el-select>
  154. </el-form-item>
  155. </el-col>
  156. <el-col :span="6">
  157. <el-form-item prop="planExec" label="履职时间:">
  158. <el-select
  159. :disabled="isChildren()"
  160. label="履职时间"
  161. v-model="formData.planExec"
  162. placeholder="请选择履职时间"
  163. clearable
  164. >
  165. <el-option
  166. v-for="item in dict.type.resumption_plan_exec"
  167. :key="item.value"
  168. :label="item.label"
  169. :value="item.value"
  170. >
  171. </el-option>
  172. </el-select>
  173. </el-form-item>
  174. </el-col>
  175. <el-col :span="6">
  176. <el-form-item prop="count" label="履职次数:" v-if="false">
  177. <el-input-number
  178. :disabled="getPlanExec()"
  179. style="margin-left: 10px"
  180. v-model="formData.count"
  181. controls-position="right"
  182. @change="handleChange"
  183. :min="1"
  184. :max="9"
  185. ></el-input-number>
  186. </el-form-item>
  187. </el-col>
  188. </el-row>
  189. <el-form-item prop="note" label="备注">
  190. <el-input
  191. :disabled="isChildren()"
  192. v-model="formData.note"
  193. :maxlength="255"
  194. clearable
  195. placeholder="请输入备注"
  196. />
  197. </el-form-item>
  198. </el-form>
  199. <el-button @click="openSelect">新增履职内容</el-button>
  200. <el-table :data="tableData" style="width: 100%" height="400px">
  201. <el-table-column label="是否扫描">
  202. <template v-slot="{ row }">
  203. <el-switch
  204. v-model="row.pointScan"
  205. active-text="是"
  206. inactive-text="否"
  207. >
  208. </el-switch>
  209. </template>
  210. </el-table-column>
  211. <el-table-column label="必完成项">
  212. <template v-slot="{ row }">
  213. <el-switch
  214. v-model="row.required"
  215. active-text="是"
  216. inactive-text="否"
  217. >
  218. </el-switch>
  219. </template>
  220. </el-table-column>
  221. <el-table-column prop="ruleName" label="履职内容库">
  222. </el-table-column>
  223. <el-table-column prop="itemName" label="履职项"> </el-table-column>
  224. <el-table-column prop="pointName" label="履职内容"> </el-table-column>
  225. <el-table-column prop="areaName" label="履职区域"> </el-table-column>
  226. <el-table-column prop="areaName" label="操作">
  227. <template v-slot="{ row }">
  228. <el-button
  229. v-if="getshenglianshe()"
  230. type="text"
  231. @click="removeRow(row)"
  232. >删除</el-button
  233. >
  234. </template>
  235. </el-table-column>
  236. </el-table>
  237. </div>
  238. <div slot="footer" class="dialog-footer">
  239. <el-button @click="onHide">取消</el-button>
  240. <el-button type="primary" @click="onSubmit">确定</el-button>
  241. </div>
  242. </DialogCom>
  243. <DialogSelect
  244. ref="DialogSelect"
  245. :orgType="formData.execOrgType"
  246. @select="onSelect"
  247. ></DialogSelect>
  248. </div>
  249. </template>
  250. <script>
  251. import dayjs from "dayjs";
  252. import { mapGetters } from "vuex";
  253. import * as api from "@/api/resumption/plan";
  254. import { statusOptions } from "./../../commonOption";
  255. import { findAllRole } from "@/api/system/role";
  256. import DialogSelect from "@/views/resumption/ruleManager/dialog.select.point.vue";
  257. export default {
  258. dicts: [
  259. "resumption_plan_type",
  260. "resumption_plan_cycle",
  261. "resumption_org_type",
  262. "resumption_plan_status",
  263. "sys_org_type",
  264. "resumption_plan_exec",
  265. ],
  266. data() {
  267. // const params = this.$route.params;
  268. // let o1=options;
  269. // let o=statusOptions;
  270. // debugger
  271. return {
  272. buildTime: null,
  273. isSubmitting: false,
  274. defaultSelect: [],
  275. selectedValues: [],
  276. resumptionRoles: [],
  277. planName: null,
  278. tempBuildTaskNow:false,
  279. planType: null,
  280. planCycle: null,
  281. planStatus: null,
  282. execOrgType: null,
  283. roleNames: null,
  284. planExec: null,
  285. count: 0,
  286. description: null,
  287. propItem: "",
  288. propList: [
  289. {
  290. label: "是否扫描",
  291. prop: "pointScan",
  292. },
  293. {
  294. label: "itemId",
  295. prop: "itemId",
  296. },
  297. {
  298. label: "必完成项",
  299. prop: "required",
  300. },
  301. {
  302. label: "履职内容库",
  303. prop: "pointName",
  304. },
  305. {
  306. label: "履职项",
  307. prop: "itemName",
  308. },
  309. {
  310. label: "履职内容",
  311. prop: "itemDesc",
  312. },
  313. {
  314. label: "履职区域",
  315. prop: "areaName",
  316. },
  317. {
  318. label: "操作",
  319. prop: "lc-component",
  320. component: "el-button",
  321. },
  322. ],
  323. row: "",
  324. tableData: [],
  325. id: null,
  326. isShow: false,
  327. formData: {},
  328. formDataRules: {
  329. planName: [{ required: true, message: "请输入计划名称" }],
  330. planType: [{ required: true, message: "请选择计划类型" }],
  331. planCycle: [{ required: true, message: "请选择履职周期" }],
  332. planStatus: [{ required: true, message: "请选择计划状态" }],
  333. execOrgType: [{ required: true, message: "请选择履职机构类型" }],
  334. roleList: [{ required: true, message: "请选择履职角色" ,trigger: "change"}],
  335. planExec: [{ required: true, message: "请选择履职时间" }],
  336. count: [{ required: true, message: "请选择履职次数" }],
  337. },
  338. statusOptions: statusOptions,
  339. };
  340. },
  341. props: {
  342. orgTypeOptions: {
  343. type: Array,
  344. },
  345. ruleTypeOptions: {
  346. type: Array,
  347. },
  348. },
  349. watch: {},
  350. computed: {
  351. ...mapGetters(["orgId", "orgName"]),
  352. },
  353. methods: {
  354. changeBuildTime() {
  355. console.log(this.formData.planCycle, "this.formData.planCycle");
  356. const dateObj = new Date(); // 获取当前时间对象
  357. switch (this.formData.planCycle) {
  358. case "2":
  359. dateObj.setDate(dateObj.getDate() + 1);
  360. const year = dateObj.getFullYear(); // 获取年份
  361. const month = String(dateObj.getMonth() + 1).padStart(2, "0"); // 获取月份,并补齐两位数
  362. const day = String(dateObj.getDate()).padStart(2, "0"); // 获取日期,并补齐两位数
  363. this.buildTime = `${year}-${month}-${day}`; // 将年月日拼接并赋值给变量
  364. break;
  365. case "3":
  366. // 获取下一周的第一天日期
  367. const nextWeekFirstDay = dayjs().add(1, "week").startOf("week");
  368. // 格式化日期为你想要的格式
  369. const formattedNextWeekFirstDay =
  370. nextWeekFirstDay.format("YYYY-MM-DD");
  371. this.buildTime = formattedNextWeekFirstDay;
  372. break;
  373. case "4":
  374. // 获取下个月的第一天日期
  375. const nextMonthFirstDay = dayjs().add(1, "month").startOf("month");
  376. // 格式化日期为你想要的格式
  377. const formattedNextMonthFirstDay =
  378. nextMonthFirstDay.format("YYYY-MM-DD");
  379. this.buildTime = formattedNextMonthFirstDay;
  380. break;
  381. case "5":
  382. const year2 = dateObj.getFullYear(); // 获取年份
  383. const month2 = String(dateObj.getMonth() + 1).padStart(2, "0"); // 获取月份,并补齐两位数
  384. const day2 = String(dateObj.getDate()).padStart(2, "0"); // 获取日期,并补齐两位数
  385. var month3=month2;
  386. month3++;
  387. for(var i=0;i<12;i++)
  388. {
  389. if(month3==1||month3==4||month3==7||month3==10){
  390. continue;
  391. }
  392. if(month3==13){
  393. month3=1;
  394. }
  395. month3++;
  396. }
  397. this.buildTime = `${year2}-${month3}-${day2}`;
  398. break;
  399. }
  400. },
  401. //是否子计划判断
  402. isChildren() {
  403. if (
  404. this.formData.distributePlanStatus != null ||
  405. this.id == null ||
  406. this.formData.children == null
  407. ) {
  408. return false;
  409. } else return true;
  410. },
  411. //省联社履职内容不能删除
  412. getshenglianshe() {
  413. if (
  414. this.formData.planCreateOrgType != null &&
  415. this.formData.planCreateOrgType == 1 &&
  416. this.formData.distributePlanStatus != null
  417. ) {
  418. return false;
  419. } else return true;
  420. },
  421. //选择计划类型修改联动框
  422. changeData() {
  423. //判断计划类型
  424. switch (this.formData.planType) {
  425. //如果是 营业前安全检查
  426. case "1":
  427. //周期
  428. this.formData.planCycle = "2";
  429. //机构类型
  430. this.formData.execOrgType = "4";
  431. this.getRolesByOrg();
  432. //角色
  433. this.formData.roleList = ["122"];
  434. //履职时间
  435. this.formData.planExec = "2";
  436. //履职次数
  437. this.formData.count = 1;
  438. //履职内容
  439. this.tableData = null;
  440. break;
  441. //如果是 营业期间安全管理
  442. case "2":
  443. //周期
  444. this.formData.planCycle = "2";
  445. //机构类型
  446. this.formData.execOrgType = "4";
  447. this.getRolesByOrg();
  448. //角色
  449. this.formData.roleList = ["122"];
  450. //履职时间
  451. this.formData.planExec = "3";
  452. //履职次数
  453. this.formData.count = 1;
  454. //履职内容
  455. this.tableData = null;
  456. break;
  457. //如果是 营业终了安全管理
  458. case "3":
  459. //周期
  460. this.formData.planCycle = "2";
  461. //机构类型
  462. this.formData.execOrgType = "4";
  463. this.getRolesByOrg();
  464. //角色
  465. this.formData.roleList = ["122"];
  466. //履职时间
  467. this.formData.planExec = "4";
  468. //履职次数
  469. this.formData.count = 1;
  470. //履职内容
  471. this.tableData = null;
  472. break;
  473. //如果是 “110”入侵报警系统测试
  474. case "4":
  475. //周期
  476. this.formData.planCycle = "4";
  477. //机构类型
  478. this.formData.execOrgType = "4";
  479. this.getRolesByOrg();
  480. //角色
  481. this.formData.roleList = ["122"];
  482. //履职时间
  483. this.formData.planExec = "1";
  484. //履职次数
  485. this.formData.count = 1;
  486. //履职内容
  487. this.tableData = null;
  488. break;
  489. //如果是 备用电源维护
  490. case "5":
  491. //周期
  492. this.formData.planCycle = "4";
  493. //机构类型
  494. this.formData.execOrgType = "4";
  495. this.getRolesByOrg();
  496. //角色
  497. this.formData.roleList = ["122"];
  498. //履职时间
  499. this.formData.planExec = "1";
  500. //履职次数
  501. this.formData.count = 1;
  502. //履职内容
  503. this.tableData = null;
  504. break;
  505. //如果是 离行式自助银行巡检
  506. case "6":
  507. //周期
  508. this.formData.planCycle = "2";
  509. //机构类型
  510. this.formData.execOrgType = "5";
  511. this.getRolesByOrg();
  512. //角色
  513. this.formData.roleList = ["129"];
  514. //履职时间
  515. this.formData.planExec = "1";
  516. //履职次数
  517. this.formData.count = 1;
  518. //履职内容
  519. this.tableData = null;
  520. break;
  521. //如果是 非营业时间安全管理
  522. case "7":
  523. //周期
  524. this.formData.planCycle = "2";
  525. //机构类型
  526. this.formData.execOrgType = "4";
  527. this.getRolesByOrg();
  528. //角色
  529. this.formData.roleList = ["143"];
  530. //履职时间
  531. this.formData.planExec = "5";
  532. //履职次数
  533. this.formData.count = 1;
  534. //履职内容
  535. this.tableData = null;
  536. break;
  537. }
  538. },
  539. //当时间为全天或者营业中才显示
  540. getPlanExec() {
  541. if (
  542. this.formData.planExec == null ||
  543. this.formData.planExec == 2 ||
  544. this.formData.planExec == 4
  545. ) {
  546. return true;
  547. } else return false;
  548. },
  549. getDistributePlanStatus() {
  550. // console.log(this.formData.distributePlanStatus, "distributePlanStatus");
  551. if (this.formData.distributePlanStatus == 1) {
  552. return true;
  553. } else return false;
  554. },
  555. reset() {
  556. return {
  557. planName: null,
  558. planType: null,
  559. planCycle: null,
  560. planStatus: null,
  561. execOrgType: null,
  562. roleNames: null,
  563. description: null,
  564. tableData: null,
  565. itemList: null,
  566. planExec: null,
  567. count: 0,
  568. note: null,
  569. planCreateOrgId: null,
  570. planCreateOrgName: null,
  571. roleList: [],
  572. distributePlanStatus: null,
  573. planCreateOrgType: null,
  574. buildTaskNow: 0,
  575. };
  576. },
  577. handleCheckboxChange() {
  578. this.formData.buildTaskNow=this.tempBuildTaskNow?1:0;
  579. },
  580. getRolesByOrg() {
  581. if (this.formData.execOrgType != null) {
  582. let params = {
  583. orgType: this.formData.execOrgType,
  584. };
  585. findAllRole(params).then((res) => {
  586. // console.info(res);
  587. this.resumptionRoles = res.data;
  588. });
  589. }
  590. },
  591. handleChange(value) {
  592. console.log(value);
  593. this.count = value;
  594. },
  595. async refresh(id, other) {
  596. this.formData = id ? (await api.get(id)).data : this.reset(other);
  597. if (this.formData.execOrgType) {
  598. this.getRolesByOrg();
  599. }
  600. },
  601. onSelect(selectList) {
  602. console.log(selectList);
  603. if (this.tableData == null) {
  604. this.tableData = [];
  605. }
  606. let selectedIds = selectList.map((i) => i.id);
  607. this.tableData = this.tableData.filter((d) => selectedIds.includes(d.id));
  608. for (let i = 0; i < selectList.length; i++) {
  609. let item = selectList[i];
  610. let exist = this.tableData.find((d) => d.id == item.id);
  611. if (!exist) {
  612. let tem = {
  613. pointScan: !item.pointScan,
  614. required: !item.required,
  615. ruleName: item.ruleName,
  616. itemName: item.itemName,
  617. pointName: item.pointName,
  618. areaName: item.areaName,
  619. itemId: item.itemId,
  620. id: item.id,
  621. };
  622. this.tableData.push(tem);
  623. }
  624. }
  625. },
  626. onOrgTypeChanged() {
  627. this.formData.roleList =[];
  628. this.tableData = [];
  629. this.getRolesByOrg();
  630. },
  631. async show(id, other = {}) {
  632. this.tempBuildTaskNow=false;
  633. this.buildTime=null;
  634. this.id = id;
  635. this.tableData = null;
  636. this.formData.itemList = null;
  637. await this.refresh(id, other);
  638. console.log(id);
  639. if (id !== undefined) {
  640. await api.get(id).then((res) => {
  641. console.log(res, "res");
  642. this.tableData = res.data.itemList;
  643. });
  644. }
  645. this.isShow = true;
  646. },
  647. removeRow(row) {
  648. this.$modal
  649. .confirm("是否确认删除?")
  650. .then(function () {})
  651. .then(() => {
  652. this.tableData = this.tableData.filter((item) => item !== row);
  653. this.$modal.msgSuccess("删除成功");
  654. });
  655. // this.tableData.splice(index, 1);
  656. },
  657. // 事件
  658. onHide() {
  659. this.isShow = false;
  660. this.formData = this.reset();
  661. this.$refs.form.resetFields();
  662. },
  663. getIteamF() {
  664. // if(this.id==null){
  665. // this.defaultSelect=[];
  666. // return;
  667. // }
  668. // api.getPointIds(this.id).then((res) => {
  669. // this.defaultSelect = res.data;
  670. // });
  671. if (!this.tableData) {
  672. return [];
  673. } else {
  674. console.log();
  675. return this.tableData.map((d) => d.id);
  676. }
  677. },
  678. openSelect() {
  679. this.$refs.DialogSelect.show(this.getIteamF());
  680. },
  681. onSubmit() {
  682. this.$refs.form.validate(async (isValidate) => {
  683. this.formData.planStatus=0;
  684. this.isSubmitting = true;
  685. // this.formData.note = this.formData.description;
  686. this.formData.planCreateOrgId = this.orgId;
  687. this.formData.planCreateOrgName = this.orgName;
  688. if (!isValidate) return;
  689. this.formData.itemList = this.tableData == null ? [] : this.tableData;
  690. //新需求,自动填充角色
  691. if (
  692. this.formData.roleList != null &&
  693. this.formData.roleList.length > 0 &&
  694. this.selectedValues.length == 0
  695. ) {
  696. this.formData.roleList.forEach((item) => {
  697. this.selectedValues.push(item);
  698. });
  699. }
  700. this.formData.roleList =
  701. this.selectedValues.length == 0 ? null : this.selectedValues;
  702. await api.update(this.formData);
  703. this.isSubmitting = false;
  704. this.$emit("success");
  705. this.onHide();
  706. });
  707. },
  708. handleRolesChange(val) {
  709. this.selectedValues = val.toString().split(",");
  710. },
  711. // 事件
  712. //apimark//
  713. },
  714. mounted() {},
  715. components: { DialogSelect },
  716. };
  717. </script>
  718. <style lang="scss" scoped>
  719. .brand_info {
  720. .el-form {
  721. width: 600px;
  722. padding-top: 40px;
  723. }
  724. }
  725. .form-item-comment {
  726. font-size: 12px;
  727. color: #999;
  728. height: 10px;
  729. }
  730. </style>