dialog.edit.vue 17 KB

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