dialog.edit.vue 19 KB

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