dialog.edit.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  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.execOrgIds"
  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.checkOrgIds"
  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="businessType" label="数据来源">
  232. <template slot-scope="r">
  233. {{
  234. getLabel(dict.type.point_data_source, `${r.row.businessType}`)
  235. }}
  236. </template>
  237. </el-table-column>
  238. <el-table-column prop="areaName" label="操作">
  239. <template v-slot="{ row }">
  240. <el-button type="text" @click="removeRow(row)">删除</el-button>
  241. </template>
  242. </el-table-column>
  243. </el-table>
  244. </div>
  245. <div slot="footer" class="dialog-footer">
  246. <el-button @click="onHide">取消</el-button>
  247. <el-button type="primary" @click="onSubmit">确定</el-button>
  248. </div>
  249. </el-dialog>
  250. <DialogSelect
  251. ref="DialogSelect"
  252. :defaultSelect="defaultSelect"
  253. :orgType="formData.checkOrgType"
  254. @select="onSelect"
  255. ></DialogSelect>
  256. </div>
  257. </template>
  258. <script>
  259. import OrgTreeSelect from "@/components/orgTreeSelect";
  260. import { mapGetters } from "vuex";
  261. import orgDropDown from "@/components/orgTree/orgDropDown.vue";
  262. import OrgTree from "@/components/orgTree";
  263. import korgTree from "@/components/k-orgTree";
  264. import * as api from "@/api/safetycheck/plan";
  265. import { statusOptions } from "@/views/commonOption";
  266. import { findAllRole } from "@/api/system/role";
  267. import { getLabel } from "@/views/commonOption";
  268. import DialogSelect from "@/views/safetycheck/ruleManager/dialog.select.point.vue";
  269. export default {
  270. dicts: ["sys_org_type", "check_type", "check_cycle", "check_status","point_data_source"],
  271. data() {
  272. return {
  273. defaultSelect: [],
  274. selectedValues: [],
  275. planRoles: [],
  276. planName: null,
  277. planType: null,
  278. planCycle: null,
  279. planStatus: null,
  280. execOrgType: null,
  281. roleNames: null,
  282. planExec: null,
  283. count: 0,
  284. description: null,
  285. propItem: "",
  286. row: "",
  287. tableData: [],
  288. deptOptions: [],
  289. id: null,
  290. isShow: false,
  291. formData: this.reset(),
  292. formDataRules: {
  293. planName: [{ required: true, message: "请输入计划名称" }],
  294. planType: [{ required: true, message: "请选择计划类型" }],
  295. planCycle: [{ required: true, message: "请选择计划周期" }],
  296. planStatus: [{ required: true, message: "请选择计划状态" }],
  297. execOrgType: [{ required: true, message: "请选择计划角色" }],
  298. roleList: [{ required: true, message: "请选择计划角色" }],
  299. planExec: [{ required: true, message: "请选择计划时间" }],
  300. count: [{ required: true, message: "请选择计划次数" }],
  301. },
  302. statusOptions: statusOptions,
  303. };
  304. },
  305. props: {
  306. orgTypeOptions: {
  307. type: Array,
  308. },
  309. ruleTypeOptions: {
  310. type: Array,
  311. },
  312. },
  313. watch: {},
  314. computed: {
  315. ...mapGetters(["orgId", "orgName"]),
  316. },
  317. methods: {
  318. getLabel(options, value) {
  319. return getLabel(options, value);
  320. },
  321. cleanExecOrgList() {
  322. this.execOrgIds = null;
  323. this.formData.execOrgList = [];
  324. },
  325. cleanCheckOrgList() {
  326. this.checkOrgIds = null;
  327. this.formData.checkOrgList = [];
  328. },
  329. tenantIdnormalizer(node, instanceId) {
  330. if (node.children && !node.children.length) {
  331. delete node.children;
  332. }
  333. return {
  334. id: node.id,
  335. label: node.name,
  336. children: node.children,
  337. };
  338. },
  339. handleCheckboxChange() {
  340. },
  341. reset() {
  342. return {
  343. planName: null,
  344. planType: null,
  345. planCycle: null,
  346. planStatus: null,
  347. execOrgType: null,
  348. roleNames: null,
  349. count: null,
  350. description: null,
  351. tableData: null,
  352. itemList: null,
  353. planExec: null,
  354. count: 0,
  355. note: null,
  356. planCreateOrgId: null,
  357. planCreateOrgName: null,
  358. roleList: null,
  359. roleIds: null,
  360. execOrg: null,
  361. checkOrg: null,
  362. buildTaskNow: false,
  363. checkOrgList: [],
  364. execOrgList: [],
  365. rulePointList: null,
  366. checkOrgIds: null,
  367. execOrgIds: null,
  368. rulePointIds: null,
  369. };
  370. },
  371. getRolesByOrg() {
  372. let params = {
  373. orgType: null,
  374. };
  375. findAllRole(params).then((res) => {
  376. this.planRoles = res.data;
  377. });
  378. },
  379. handleChange(value) {
  380. this.count = value;
  381. },
  382. async refresh(id, other) {
  383. if(id!=null&&id!=undefined){
  384. await api.get(id).then(res=>{
  385. this.formData =res.data;
  386. this.formData.buildTaskNow
  387. this.tableData = res.data.rulePointList;
  388. if (this.formData.execOrgType) {
  389. this.formData.roleIds = this.formData.roleList.map((role) => role.id);
  390. this.formData.execOrgIds = this.formData.execOrgList.map(
  391. (org) => org.id
  392. );
  393. this.formData.checkOrgIds = this.formData.checkOrgList.map(
  394. (org) => org.id
  395. );
  396. this.getRolesByOrg();
  397. }
  398. })
  399. }else{
  400. this.formData.planName= null;
  401. this.formData.planType= null;
  402. this.formData.planCycle= null;
  403. this.formData.planStatus= null;
  404. this.formData.execOrgType= null;
  405. this.formData.roleNames= null;
  406. this.formData.count= null;
  407. this.formData.description= null;
  408. this.formData.tableData= null;
  409. this.formData.itemList= null;
  410. this.formData.planExec= null;
  411. this.formData.count= 0;
  412. this.formData.note= null;
  413. this.formData.planCreateOrgId= null;
  414. this.formData.planCreateOrgName= null;
  415. this.formData.roleList= null;
  416. this.formData.roleIds= null;
  417. this.formData.execOrg= null;
  418. this.formData.checkOrg= null;
  419. this.formData.buildTaskNow= false;
  420. this.formData.checkOrgList= [];
  421. this.formData.execOrgList= [];
  422. this.formData.rulePointList= null;
  423. this.formData.checkOrgIds= null;
  424. this.formData.execOrgIds= null;
  425. this.formData.rulePointIds= null;
  426. }
  427. },
  428. onSelect(selectList) {
  429. for (let i = 0; i < selectList.length; i++) {
  430. let tem = {
  431. pointScan: !selectList[i].pointScan,
  432. required: !selectList[i].required,
  433. ruleName: selectList[i].ruleName,
  434. itemName: selectList[i].itemName,
  435. pointName: selectList[i].pointName,
  436. areaName: selectList[i].areaName,
  437. itemId: selectList[i].itemId,
  438. id: selectList[i].id,
  439. businessType:selectList[i].businessType,
  440. };
  441. if (this.tableData == null) {
  442. this.tableData = [];
  443. }
  444. this.tableData.push(tem);
  445. }
  446. },
  447. async show(id, other = {}) {
  448. this.id = id;
  449. this.tableData = null;
  450. this.formData.itemList = {};
  451. await this.refresh(id, other);
  452. this.getRolesByOrg();
  453. this.isShow = true;
  454. },
  455. removeRow(row) {
  456. this.tableData = this.tableData.filter((item) => item !== row);
  457. },
  458. // 事件
  459. onHide() {
  460. this.isShow = false;
  461. },
  462. getIteamF() {
  463. // if (this.id == null) {
  464. // this.defaultSelect = [];
  465. // return;
  466. // }else{
  467. // api.getPointIds(this.id).then((res) => {
  468. // this.defaultSelect = res.data;
  469. // });
  470. // }
  471. if (!this.tableData) {
  472. return [];
  473. } else {
  474. return this.tableData.map((d) => d.id);
  475. }
  476. },
  477. openSelect() {
  478. this.$refs.DialogSelect.show(this.getIteamF());
  479. },
  480. onSubmit() {
  481. this.$refs.form.validate(async (isValidate) => {
  482. this.formData.planCreateOrgId = this.orgId;
  483. this.formData.planCreateOrgName = this.orgName;
  484. if (!isValidate) return;
  485. this.formData.rulePointList = this.tableData == null ? [] : this.tableData;
  486. this.formData.roleList = null;
  487. this.formData.roleIds =
  488. this.selectedValues.length == 0 ? null : this.selectedValues;
  489. await api.add(this.formData);
  490. this.$emit("success");
  491. this.onHide();
  492. });
  493. },
  494. handleRolesChange(val) {
  495. this.selectedValues = val.toString().split(",");
  496. },
  497. // 事件
  498. //apimark//
  499. },
  500. mounted() {},
  501. components: { DialogSelect, orgDropDown, OrgTree, korgTree, OrgTreeSelect },
  502. };
  503. </script>
  504. <style lang="scss" scoped>
  505. .brand_info {
  506. .el-form {
  507. width: 600px;
  508. padding-top: 40px;
  509. }
  510. }
  511. </style>