dialog.edit.vue 22 KB

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