dialog.edit.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  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.trim="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="checkType" label="检查类型:">
  32. <el-select
  33. :disabled="isChildren()"
  34. label="检查类型"
  35. v-model="formData.checkType"
  36. placeholder="请选择检查类型"
  37. clearable
  38. >
  39. <el-option
  40. v-for="dict in dict.type.check_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
  52. :disabled="isChildren()"
  53. prop="planCycle"
  54. label="检查周期"
  55. v-model="formData.planCycle"
  56. placeholder="请选择检查周期"
  57. clearable
  58. >
  59. <el-option
  60. v-for="item in dict.type.check_cycle"
  61. :key="item.value"
  62. :label="item.label"
  63. :value="item.value"
  64. >
  65. </el-option>
  66. </el-select>
  67. </el-form-item>
  68. </el-col>
  69. <el-col :span="6" v-if="id ? false : true">
  70. <el-form-item
  71. prop="buildTaskNow"
  72. label="立即生效:"
  73. v-if="NowBuild()"
  74. >
  75. <el-checkbox
  76. :disabled="isChildren()"
  77. v-model="formData.buildTaskNow"
  78. size="medium"
  79. @change="handleCheckboxChange"
  80. >默认从下个周期生成任务,<br />勾选后从当前周期立即生成任务</el-checkbox
  81. >
  82. </el-form-item>
  83. </el-col>
  84. <el-col :span="6">
  85. <el-form-item
  86. prop="startDate"
  87. label="开始时间:"
  88. v-if="formData.planCycle == 6"
  89. >
  90. <el-date-picker
  91. :disabled="isChildren()"
  92. v-model="formData.startDate"
  93. style="width: 240px"
  94. value-format="yyyy-MM-dd 00:00:00"
  95. placeholder="请选择开始时间"
  96. type="date"
  97. :clearable="false"
  98. ></el-date-picker>
  99. </el-form-item>
  100. </el-col>
  101. <el-col :span="6">
  102. <el-form-item
  103. prop="endDate"
  104. label="结束时间:"
  105. v-if="formData.planCycle == 6"
  106. >
  107. <el-date-picker
  108. :disabled="isChildren()"
  109. v-model="formData.endDate"
  110. style="width: 240px"
  111. value-format="yyyy-MM-dd 23:59:59"
  112. placeholder="请选择结束时间"
  113. type="date"
  114. :clearable="false"
  115. ></el-date-picker>
  116. </el-form-item>
  117. </el-col>
  118. <el-col :span="6">
  119. <el-form-item prop="execOrgType" label="检查机构类型:">
  120. <el-select
  121. :disabled="isChildren()"
  122. @change="cleanExecOrgList"
  123. prop="execOrgType"
  124. label="检查机构类型"
  125. v-model="formData.execOrgType"
  126. placeholder="请选择检查机构类型"
  127. clearable
  128. >
  129. <el-option
  130. v-for="item in dict.type.sys_org_type"
  131. :key="item.value"
  132. :label="item.label"
  133. :value="item.value"
  134. >
  135. </el-option>
  136. </el-select>
  137. </el-form-item>
  138. </el-col>
  139. <!-- </el-row> -->
  140. <!-- <el-row> -->
  141. <el-col :span="6">
  142. <el-form-item prop="roleIds" label="检查角色:">
  143. <el-select
  144. :disabled="isChildren()"
  145. label="检查角色"
  146. v-model="formData.roleIds"
  147. placeholder="请选择检查角色"
  148. multiple
  149. filterable
  150. @change="handleRolesChange"
  151. >
  152. <el-option
  153. v-for="item in planRoles"
  154. :key="item.id"
  155. :label="item.roleName"
  156. :value="item.id"
  157. >
  158. </el-option>
  159. </el-select>
  160. </el-form-item>
  161. </el-col>
  162. <el-col :span="6">
  163. <el-form-item prop="checkOrgType" label="受检机构类型:">
  164. <el-select
  165. :disabled="isChildren()"
  166. @change="cleanCheckOrgList"
  167. prop="checkOrgType"
  168. label="受检机构类型"
  169. v-model="formData.checkOrgType"
  170. placeholder="请选择受检机构类型"
  171. clearable
  172. >
  173. <el-option
  174. v-for="item in dict.type.sys_org_type"
  175. :key="item.value"
  176. :label="item.label"
  177. :value="item.value"
  178. >
  179. </el-option>
  180. </el-select>
  181. </el-form-item>
  182. </el-col>
  183. <el-col :span="6">
  184. <el-form-item prop="count" label="检查次数:">
  185. <el-input-number
  186. style="margin-left: 10px"
  187. v-model="formData.count"
  188. controls-position="right"
  189. @change="handleChange"
  190. :min="parentCount"
  191. :max="9"
  192. ></el-input-number>
  193. </el-form-item>
  194. </el-col>
  195. </el-row>
  196. <el-row>
  197. <el-col :span="6">
  198. <el-form-item :span="6" prop="execOrgIds" label="检查机构">
  199. <org-tree-select
  200. :disabled="isChildren()"
  201. v-model="formData.execOrgIds"
  202. :queryData="parseInt(formData.execOrgType)"
  203. ref="execorgTreeSelect"
  204. :enabledCheckOrgTypes="parseInt(formData.execOrgType)"
  205. :disable="true"
  206. >
  207. </org-tree-select>
  208. </el-form-item>
  209. </el-col>
  210. <el-col :span="6">
  211. <el-form-item :span="6" prop="checkOrgIds" label="受检机构">
  212. <org-tree-select
  213. :disabled="isChildren()"
  214. v-model="formData.checkOrgIds"
  215. :queryData="parseInt(formData.checkOrgType)"
  216. ref="checkorgTreeSelect"
  217. :enabledCheckOrgTypes="parseInt(formData.checkOrgType)"
  218. :disable="true"
  219. >
  220. </org-tree-select>
  221. </el-form-item>
  222. </el-col>
  223. <!-- <el-col :span="6"> -->
  224. <!-- <el-form-item prop="planStatus" label="计划状态"> -->
  225. <!-- <el-select
  226. label="计划状态"
  227. v-model="formData.planStatus"
  228. placeholder="请选择计划状态"
  229. clearable
  230. >
  231. <el-option
  232. v-for="item in dict.type.check_status"
  233. :key="item.value"
  234. :label="item.label"
  235. :value="item.value"
  236. >
  237. </el-option>
  238. </el-select> -->
  239. <!-- <el-switch
  240. v-model="formData.planStatus"
  241. active-value="1"
  242. inactive-value="2"
  243. ></el-switch> -->
  244. <!-- </el-form-item> -->
  245. <!-- </el-col> -->
  246. </el-row>
  247. <el-form-item :span="6" prop="description" label="备注">
  248. <el-input
  249. :disabled="isChildren()"
  250. v-model="formData.description"
  251. :maxlength="255"
  252. clearable
  253. />
  254. </el-form-item>
  255. </el-form>
  256. <el-button @click="openSelect">新增检查内容</el-button>
  257. <el-table :data="tableData" style="width: 100%" height="400px">
  258. <el-table-column label="是否扫描">
  259. <template v-slot="{ row }">
  260. <el-switch
  261. :disabled="!getshenglianshe(row)"
  262. v-model="row.pointScan"
  263. active-text="是"
  264. inactive-text="否"
  265. >
  266. </el-switch>
  267. </template>
  268. </el-table-column>
  269. <el-table-column label="必完成项">
  270. <template v-slot="{ row }">
  271. <el-switch
  272. :disabled="!getshenglianshe(row)"
  273. v-model="row.required"
  274. active-text="是"
  275. inactive-text="否"
  276. >
  277. </el-switch>
  278. </template>
  279. </el-table-column>
  280. <el-table-column
  281. prop="ruleName"
  282. label="
  283. "
  284. >
  285. </el-table-column>
  286. <el-table-column prop="itemName" label="检查项"> </el-table-column>
  287. <el-table-column prop="pointName" label="检查内容" width="300px">
  288. <template slot-scope="scope">
  289. <pre>{{ scope.row.pointName }}</pre>
  290. </template>
  291. </el-table-column>
  292. <el-table-column v-if="false" prop="ofOrgId" label="所属机构id">
  293. </el-table-column>
  294. <el-table-column prop="areaName" label="检查区域"> </el-table-column>
  295. <el-table-column prop="businessType" label="数据来源">
  296. <template slot-scope="r">
  297. {{
  298. getLabel(dict.type.point_data_source, `${r.row.businessType}`)
  299. }}
  300. </template>
  301. </el-table-column>
  302. <el-table-column prop="areaName" label="操作">
  303. <template v-slot="{ row }">
  304. <el-button
  305. v-if="getshenglianshe(row)"
  306. type="text"
  307. @click="removeRow(row)"
  308. >删除</el-button
  309. >
  310. </template>
  311. </el-table-column>
  312. </el-table>
  313. </div>
  314. <div slot="footer" class="dialog-footer">
  315. <el-button @click="onHide">取消</el-button>
  316. <el-button type="primary" @click="onSubmit">确定</el-button>
  317. </div>
  318. </DialogCom>
  319. <DialogSelect
  320. ref="DialogSelect"
  321. :defaultSelect="defaultSelect"
  322. :orgType="formData.checkOrgType"
  323. @select="onSelect"
  324. ></DialogSelect>
  325. </div>
  326. </template>
  327. <script>
  328. import OrgTreeSelect from "@/components/orgTreeSelect";
  329. import { mapGetters } from "vuex";
  330. import orgDropDown from "@/components/orgTree/orgDropDown.vue";
  331. import OrgTree from "@/components/orgTree";
  332. import korgTree from "@/components/k-orgTree";
  333. import * as api from "@/api/safetycheck/plan";
  334. import { statusOptions } from "@/views/commonOption";
  335. import { findAllRole, findRoleByType } from "@/api/system/role";
  336. import { getLabel } from "@/views/commonOption";
  337. import DialogSelect from "@/views/safetycheck/ruleManager/dialog.select.point.vue";
  338. export default {
  339. dicts: [
  340. "sys_org_type",
  341. "check_type",
  342. "check_cycle",
  343. "check_status",
  344. "point_data_source",
  345. ],
  346. data() {
  347. return {
  348. parentCount: 1,
  349. defaultSelect: [],
  350. selectedValues: [],
  351. planRoles: [],
  352. planName: null,
  353. planType: null,
  354. planCycle: null,
  355. planStatus: null,
  356. execOrgType: null,
  357. roleNames: null,
  358. planExec: null,
  359. count: 0,
  360. description: null,
  361. propItem: "",
  362. row: "",
  363. tableData: [],
  364. deptOptions: [],
  365. id: null,
  366. isShow: false,
  367. formData: this.reset(),
  368. formDataRules: {
  369. planName: [{ required: true, message: "请输入计划名称" }],
  370. checkType: [{ required: true, message: "请选择检查类型" }],
  371. planCycle: [{ required: true, message: "请选择检查周期" }],
  372. execOrgType: [{ required: true, message: "请选择检查机构类型" }],
  373. roleList: [{ required: true, message: "请选择检查角色" }],
  374. planExec: [{ required: true, message: "请选择计划时间" }],
  375. count: [{ required: true, message: "请选择计划次数" }],
  376. checkOrgType: [{ required: true, message: "请选择受检机构类型" }],
  377. roleIds: [{ required: true, message: "请选择检查角色" }],
  378. },
  379. statusOptions: statusOptions,
  380. };
  381. },
  382. props: {
  383. orgTypeOptions: {
  384. type: Array,
  385. },
  386. ruleTypeOptions: {
  387. type: Array,
  388. },
  389. },
  390. watch: {},
  391. computed: {
  392. ...mapGetters(["orgId", "orgName"]),
  393. },
  394. methods: {
  395. //省联社内容不能删除
  396. getshenglianshe(row) {
  397. if (row.ofOrgId == this.orgId) {
  398. return true;
  399. } else return false;
  400. },
  401. //编辑内容判断
  402. isChildren() {
  403. // console.log(this.formData.distributePlanStatus,"distributePlanStatus")
  404. //计划所属机构id等于当前机构id并且不存在已完成或者已逾期或者
  405. //计划所属机构类型不等于行社并且不存在已完成或者已逾期或者
  406. //新增
  407. if (
  408. (this.formData.planCreateOrgId == this.orgId &&
  409. this.formData.hasEdit != 1) ||
  410. (this.formData.planOfOrgType != 3 && this.formData.hasEdit != 1) ||
  411. this.id == null
  412. ) {
  413. return false;
  414. } else return true;
  415. },
  416. NowBuild() {
  417. if (this.formData.planCycle == 6) return false;
  418. else return true;
  419. },
  420. getLabel(options, value) {
  421. return getLabel(options, value);
  422. },
  423. cleanExecOrgList() {
  424. this.execOrgIds = null;
  425. this.formData.execOrgList = [];
  426. this.formData.roleIds = [];
  427. this.formData.execOrgIds = [];
  428. this.getRolesByOrg();
  429. },
  430. cleanCheckOrgList() {
  431. this.checkOrgIds = null;
  432. this.formData.checkOrgList = [];
  433. this.formData.checkOrgIds = [];
  434. },
  435. tenantIdnormalizer(node, instanceId) {
  436. if (node.children && !node.children.length) {
  437. delete node.children;
  438. }
  439. return {
  440. id: node.id,
  441. label: node.name,
  442. children: node.children,
  443. };
  444. },
  445. handleCheckboxChange() {},
  446. reset() {
  447. return {
  448. planName: null,
  449. planType: null,
  450. planCycle: null,
  451. planStatus: null,
  452. execOrgType: null,
  453. roleNames: null,
  454. count: null,
  455. description: null,
  456. tableData: null,
  457. itemList: null,
  458. planExec: null,
  459. count: 0,
  460. note: null,
  461. planCreateOrgId: null,
  462. planCreateOrgName: null,
  463. roleList: null,
  464. roleIds: null,
  465. execOrg: null,
  466. checkOrg: null,
  467. buildTaskNow: false,
  468. checkOrgList: [],
  469. execOrgList: [],
  470. rulePointList: null,
  471. checkOrgIds: null,
  472. execOrgIds: null,
  473. rulePointIds: null,
  474. checkOrgType: null,
  475. checkType: null,
  476. startDate: null,
  477. endDate: null,
  478. };
  479. },
  480. getRolesByOrg() {
  481. // let params = {
  482. // orgType: null,
  483. // };
  484. findRoleByType(this.formData.execOrgType).then((res) => {
  485. console.log(res, "res");
  486. this.planRoles = res;
  487. });
  488. },
  489. handleChange(value) {
  490. this.count = value;
  491. },
  492. async refresh(id, other) {
  493. if (id != null && id != undefined) {
  494. await api.get(id).then((res) => {
  495. this.parentCount = res.data.parentCount;
  496. this.formData = res.data;
  497. this.formData.buildTaskNow;
  498. this.tableData = res.data.rulePointList;
  499. if (this.formData.execOrgType) {
  500. this.formData.roleIds = this.formData.roleList.map(
  501. (role) => role.id
  502. );
  503. this.formData.execOrgIds = this.formData.execOrgList.map(
  504. (org) => org.id
  505. );
  506. this.formData.checkOrgIds = this.formData.checkOrgList.map(
  507. (org) => org.id
  508. );
  509. this.getRolesByOrg();
  510. }
  511. });
  512. } else {
  513. this.formData.id = null;
  514. this.formData.planName = null;
  515. this.formData.planType = null;
  516. this.formData.planCycle = null;
  517. this.formData.planStatus = null;
  518. this.formData.execOrgType = null;
  519. this.formData.checkOrgType = null;
  520. this.formData.checkType = null;
  521. this.formData.roleNames = null;
  522. this.formData.count = null;
  523. this.formData.description = null;
  524. this.formData.tableData = null;
  525. this.formData.itemList = null;
  526. this.formData.planExec = null;
  527. this.formData.count = 0;
  528. this.formData.note = null;
  529. this.formData.planCreateOrgId = null;
  530. this.formData.planCreateOrgName = null;
  531. this.formData.roleList = null;
  532. this.formData.roleIds = null;
  533. this.formData.execOrg = null;
  534. this.formData.checkOrg = null;
  535. this.formData.buildTaskNow = false;
  536. this.formData.checkOrgList = [];
  537. this.formData.execOrgList = [];
  538. this.formData.rulePointList = null;
  539. this.formData.checkOrgIds = null;
  540. this.formData.execOrgIds = null;
  541. this.formData.rulePointIds = null;
  542. this.formData.distributePlanStatus = null;
  543. }
  544. },
  545. onSelect(selectList) {
  546. // console.log(selectList,"selectList");
  547. for (let i = 0; i < selectList.length; i++) {
  548. let tem = {
  549. ofOrgId: this.orgId,
  550. pointScan: selectList[i].pointScan,
  551. required: !selectList[i].required,
  552. ruleName: selectList[i].ruleName,
  553. itemName: selectList[i].itemName,
  554. pointName: selectList[i].pointName,
  555. areaName: selectList[i].areaName,
  556. itemId: selectList[i].itemId,
  557. id: selectList[i].id,
  558. businessType: selectList[i].businessType,
  559. };
  560. if (this.tableData == null) {
  561. this.tableData = [];
  562. }
  563. this.tableData.push(tem);
  564. }
  565. },
  566. async show(id, other = {}) {
  567. this.id = id;
  568. this.tableData = null;
  569. this.formData.execOrgIds = [];
  570. this.formData.checkOrgIds = [];
  571. this.formData.itemList = {};
  572. await this.refresh(id, other);
  573. this.getRolesByOrg();
  574. this.isShow = true;
  575. },
  576. removeRow(row) {
  577. this.tableData = this.tableData.filter((item) => item !== row);
  578. },
  579. // 事件
  580. onHide() {
  581. this.isShow = false;
  582. },
  583. getIteamF() {
  584. // if (this.id == null) {
  585. // this.defaultSelect = [];
  586. // return;
  587. // }else{
  588. // api.getPointIds(this.id).then((res) => {
  589. // this.defaultSelect = res.data;
  590. // });
  591. // }
  592. if (!this.tableData) {
  593. return [];
  594. } else {
  595. return this.tableData.map((d) => d.id);
  596. }
  597. },
  598. openSelect() {
  599. this.$refs.DialogSelect.show(this.getIteamF());
  600. },
  601. onSubmit() {
  602. this.$refs.form.validate(async (isValidate) => {
  603. this.formData.planCreateOrgId = this.orgId;
  604. this.formData.planCreateOrgName = this.orgName;
  605. this.formData.planStatus = 0;
  606. if (!isValidate) return;
  607. this.formData.rulePointList =
  608. this.tableData == null ? [] : this.tableData;
  609. this.formData.roleList = null;
  610. this.formData.roleIds =
  611. this.selectedValues.length == 0 ? null : this.selectedValues;
  612. await api.add(this.formData);
  613. this.$emit("success");
  614. this.onHide();
  615. });
  616. },
  617. handleRolesChange(val) {
  618. this.selectedValues = val.toString().split(",");
  619. },
  620. // 事件
  621. //apimark//
  622. },
  623. mounted() {},
  624. components: { DialogSelect, orgDropDown, OrgTree, korgTree, OrgTreeSelect },
  625. };
  626. </script>
  627. <style lang="scss" scoped>
  628. .brand_info {
  629. .el-form {
  630. width: 600px;
  631. padding-top: 40px;
  632. }
  633. }
  634. </style>