dialog.edit.vue 16 KB

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