dialog.edit.vue 22 KB

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