dialog.edit.vue 19 KB

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