dialog.edit.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943
  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" v-loading="loading">
  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="cannotEditName()"
  23. v-model.trim="formData.planName"
  24. :maxlength="50"
  25. name="planName"
  26. placeholder="请输入任务名称"
  27. clearable
  28. style="width: 217px"
  29. />
  30. </el-form-item>
  31. </el-col>
  32. <el-col :span="6">
  33. <el-form-item prop="checkType" label="任务类型:">
  34. <el-select
  35. @change="changeData"
  36. :disabled="cannotEdit()"
  37. label="任务类型"
  38. v-model="formData.checkType"
  39. placeholder="请选择任务类型"
  40. clearable
  41. >
  42. <el-option
  43. v-for="dict in dict.type.check_type"
  44. :key="dict.value"
  45. :label="dict.label"
  46. :value="dict.value"
  47. >
  48. </el-option>
  49. </el-select>
  50. </el-form-item>
  51. </el-col>
  52. <el-col :span="6">
  53. <el-form-item prop="planCycle" label="任务周期:">
  54. <el-select
  55. :disabled="cannotEdit()"
  56. prop="planCycle"
  57. label="任务周期"
  58. v-model="formData.planCycle"
  59. placeholder="请选择任务周期"
  60. clearable
  61. >
  62. <el-option
  63. v-for="item in dict.type.check_cycle"
  64. :key="item.value"
  65. :label="item.label"
  66. :value="item.value"
  67. >
  68. </el-option>
  69. </el-select>
  70. </el-form-item>
  71. </el-col>
  72. <el-col :span="6">
  73. <el-form-item
  74. prop="startDate"
  75. label="开始时间:"
  76. v-if="formData.planCycle == 6"
  77. >
  78. <el-date-picker
  79. :disabled="cannotEdit()"
  80. v-model="formData.startDate"
  81. style="width: 217px"
  82. value-format="yyyy-MM-dd 00:00:00"
  83. placeholder="请选择开始时间"
  84. type="date"
  85. :clearable="false"
  86. :picker-options="datepickerOptions"
  87. ></el-date-picker>
  88. </el-form-item>
  89. </el-col>
  90. <el-col :span="6">
  91. <el-form-item
  92. prop="endDate"
  93. label="结束时间:"
  94. v-if="formData.planCycle == 6"
  95. >
  96. <el-date-picker
  97. :disabled="cannotEdit()"
  98. v-model="formData.endDate"
  99. style="width: 217px"
  100. value-format="yyyy-MM-dd 23:59:59"
  101. placeholder="请选择结束时间"
  102. type="date"
  103. :clearable="false"
  104. :picker-options="datepickerOptions"
  105. ></el-date-picker>
  106. </el-form-item>
  107. </el-col>
  108. <el-col :span="6">
  109. <el-form-item prop="execOrgType" label="检查主体类型:">
  110. <el-select
  111. :disabled="cannotEdit()"
  112. @change="cleanExecOrgList"
  113. prop="execOrgType"
  114. v-model="formData.execOrgType"
  115. placeholder="请选择检查主体类型"
  116. clearable
  117. >
  118. <el-option
  119. v-for="item in orgTypeOptions"
  120. :key="item.value"
  121. :label="item.label"
  122. :value="parseInt(item.value)"
  123. >
  124. </el-option>
  125. </el-select>
  126. </el-form-item>
  127. </el-col>
  128. <!-- </el-row> -->
  129. <!-- <el-row> -->
  130. <el-col :span="6">
  131. <el-form-item prop="roleIds" label="检查人员:">
  132. <el-select
  133. :disabled="cannotEdit()"
  134. v-model="formData.roleIds"
  135. placeholder="请选择检查人员"
  136. multiple
  137. filterable
  138. collapse-tags
  139. @change="handleRolesChange"
  140. >
  141. <el-option
  142. v-for="item in planRoles"
  143. :key="item.id"
  144. :label="item.roleName"
  145. :value="item.id"
  146. >
  147. </el-option>
  148. </el-select>
  149. </el-form-item>
  150. </el-col>
  151. <el-col :span="6">
  152. <el-form-item prop="checkOrgTypes" label="受检机构类型:">
  153. <el-select
  154. :disabled="cannotEdit()"
  155. @change="cleanCheckOrgList"
  156. prop="checkOrgTypes"
  157. label="受检机构类型"
  158. v-model="formData.checkOrgTypes"
  159. placeholder="请选择受检机构类型"
  160. clearable
  161. multiple
  162. collapse-tags
  163. >
  164. <el-option
  165. v-for="item in orgTypeOptions"
  166. :key="item.value"
  167. :label="item.label"
  168. :value="item.value"
  169. >
  170. </el-option>
  171. </el-select>
  172. </el-form-item>
  173. </el-col>
  174. <el-col :span="6">
  175. <el-form-item prop="count" label="任务次数:">
  176. <el-input-number
  177. :disabled="cannotEdit()"
  178. v-model="formData.count"
  179. controls-position="right"
  180. @change="handleChange"
  181. :min="parentCount"
  182. :max="9"
  183. ></el-input-number>
  184. </el-form-item>
  185. </el-col>
  186. <el-col :span="6">
  187. <el-form-item :span="6" prop="execOrgIds" label="检查主体">
  188. <org-tree-select
  189. :disabled="cannotEdit()"
  190. v-model="formData.execOrgIds"
  191. class="org-selector"
  192. :queryData="parseInt(formData.execOrgType)"
  193. ref="execorgTreeSelect"
  194. :enabledCheckOrgTypes="parseInt(formData.execOrgType)"
  195. :disable="true"
  196. >
  197. </org-tree-select>
  198. </el-form-item>
  199. </el-col>
  200. <el-col :span="6">
  201. <el-form-item :span="6" prop="checkOrgIds" label="受检机构">
  202. <org-tree-select
  203. :disabled="cannotEdit()"
  204. v-model="formData.checkOrgIds"
  205. class="org-selector"
  206. ref="checkorgTreeSelect"
  207. :queryData="
  208. formData.checkOrgTypes == null ||
  209. formData.checkOrgTypes.length > 1
  210. ? null
  211. : parseInt(formData.checkOrgTypes[0])
  212. "
  213. :enabledCheckOrgTypes="
  214. formData.checkOrgTypes.map((t) => parseInt(t))
  215. "
  216. :disable="true"
  217. >
  218. </org-tree-select>
  219. </el-form-item>
  220. </el-col>
  221. <!-- <el-col :span="6"> -->
  222. <!-- <el-form-item prop="planStatus" label="计划状态"> -->
  223. <!-- <el-select
  224. label="计划状态"
  225. v-model="formData.planStatus"
  226. placeholder="请选择计划状态"
  227. clearable
  228. >
  229. <el-option
  230. v-for="item in dict.type.check_status"
  231. :key="item.value"
  232. :label="item.label"
  233. :value="item.value"
  234. >
  235. </el-option>
  236. </el-select> -->
  237. <!-- <el-switch
  238. v-model="formData.planStatus"
  239. active-value="1"
  240. inactive-value="2"
  241. ></el-switch> -->
  242. <!-- </el-form-item> -->
  243. <!-- </el-col> -->
  244. </el-row>
  245. <el-form-item :span="6" prop="description" label="备注">
  246. <el-input
  247. :disabled="cannotEdit()"
  248. v-model="formData.description"
  249. :maxlength="255"
  250. clearable
  251. />
  252. </el-form-item>
  253. </el-form>
  254. <el-button
  255. @click="openSelect"
  256. v-if="formData.id == null || formData.planOfOrgId == orgId"
  257. ><span class="requiredlabel">选择检查内容</span>
  258. </el-button>
  259. <el-button
  260. @click="deleteSelected"
  261. v-if="formData.id == null || formData.planOfOrgId == orgId"
  262. >批量删除</el-button
  263. >
  264. <el-table
  265. :data="tableData"
  266. style="width: 100%; margin-top: 15px"
  267. height="400px"
  268. border
  269. @selection-change="handleSelectionChange"
  270. >
  271. <el-table-column
  272. type="selection"
  273. align="center"
  274. :selectable="handleSelectable"
  275. ></el-table-column>
  276. <el-table-column label="是否扫描" align="center">
  277. <template v-slot="{ row }">
  278. <el-switch
  279. :disabled="!getshenglianshe(row)"
  280. v-model="row.pointScan"
  281. active-text="是"
  282. inactive-text="否"
  283. >
  284. </el-switch>
  285. </template>
  286. </el-table-column>
  287. <el-table-column label="必完成项" align="center">
  288. <template v-slot="{ row }">
  289. <el-switch
  290. :disabled="!getshenglianshe(row)"
  291. v-model="row.required"
  292. active-text="是"
  293. inactive-text="否"
  294. >
  295. </el-switch>
  296. </template>
  297. </el-table-column>
  298. <el-table-column
  299. prop="ruleName"
  300. label="检查手册"
  301. align="center"
  302. show-overflow-tooltip
  303. >
  304. </el-table-column>
  305. <el-table-column prop="itemName" label="检查项" align="center">
  306. </el-table-column>
  307. <el-table-column
  308. prop="pointName"
  309. label="检查内容"
  310. width="300px"
  311. align="center"
  312. >
  313. <template slot-scope="scope">
  314. <pre>{{ scope.row.pointName }}</pre>
  315. </template>
  316. </el-table-column>
  317. <el-table-column prop="areaName" label="检查区域" align="center">
  318. </el-table-column>
  319. <el-table-column prop="areaName" label="操作" align="center">
  320. <template v-slot="{ row }">
  321. <el-button
  322. v-if="
  323. getshenglianshe(row) &&
  324. (formData.Id == null || formData.planOfOrgId == orgId)
  325. "
  326. type="text"
  327. @click="removeRow(row)"
  328. >删除</el-button
  329. >
  330. </template>
  331. </el-table-column>
  332. </el-table>
  333. </div>
  334. <div
  335. v-if="formData.planCycle == 6 && formData.taskHasCompleted == 1"
  336. slot="footer"
  337. class="dialog-footer"
  338. >
  339. <span>存在已完成任务,无周期任务如需修改,请删除后重新下发。</span>
  340. <el-button @click="onHide">关闭</el-button>
  341. </div>
  342. <div v-else slot="footer" class="dialog-footer">
  343. <el-button type="primary" @click="onSubmit">确定</el-button>
  344. <el-button @click="onHide">取消</el-button>
  345. </div>
  346. </DialogCom>
  347. <DialogSelect
  348. ref="DialogSelect"
  349. :defaultSelect="defaultSelect"
  350. :orgType="formData.checkOrgTypes"
  351. @select="onSelect"
  352. ></DialogSelect>
  353. </div>
  354. </template>
  355. <script>
  356. import OrgTreeSelect from "@/components/orgTreeSelect";
  357. import { mapGetters } from "vuex";
  358. import orgDropDown from "@/components/orgTree/orgDropDown.vue";
  359. import OrgTree from "@/components/orgTree";
  360. import korgTree from "@/components/k-orgTree";
  361. import * as api from "@/api/safetycheck/plan";
  362. import { statusOptions } from "@/views/commonOption";
  363. import { findAllRole, findRoleByType } from "@/api/system/role";
  364. import { getLabel } from "@/views/commonOption";
  365. import DialogSelect from "@/views/safetycheck/ruleManager/dialog.select.point.vue";
  366. import dayjs from "dayjs";
  367. export default {
  368. dicts: [
  369. "sys_org_type",
  370. "check_type",
  371. "check_cycle",
  372. "check_status",
  373. "point_data_source",
  374. ],
  375. data() {
  376. return {
  377. loading: false,
  378. parentCount: 1,
  379. defaultSelect: [],
  380. selectedValues: [],
  381. planRoles: [],
  382. planName: null,
  383. planType: null,
  384. planCycle: null,
  385. planStatus: null,
  386. execOrgType: null,
  387. roleNames: null,
  388. planExec: null,
  389. defbuildTaskNow: false,
  390. count: 0,
  391. description: null,
  392. selectedRows: [],
  393. propItem: "",
  394. row: "",
  395. tableData: [],
  396. deptOptions: [],
  397. id: null,
  398. isShow: false,
  399. formData: this.reset(),
  400. formDataRules: {
  401. planName: [{ required: true, message: "请输入任务名称" }],
  402. checkType: [{ required: true, message: "请选择任务类型" }],
  403. planCycle: [{ required: true, message: "请选择任务周期" }],
  404. execOrgType: [{ required: true, message: "请选择检查主体类型" }],
  405. roleList: [{ required: true, message: "请选择检查人员" }],
  406. planExec: [{ required: true, message: "请选择计划时间" }],
  407. count: [{ required: true, message: "请选择任务次数" }],
  408. checkOrgTypes: [{ required: true, message: "请选择受检机构类型" }],
  409. roleIds: [{ required: true, message: "请选择检查人员" }],
  410. startDate: [{ required: true, message: "请选择开始时间" }],
  411. endDate: [{ required: true, message: "请选择结束时间" }],
  412. },
  413. statusOptions: statusOptions,
  414. datepickerOptions: {
  415. disabledDate(time) {
  416. const date = new Date();
  417. date.setTime(date.getTime() - 3600 * 1000 * 24);
  418. return time.getTime() < date;
  419. },
  420. },
  421. };
  422. },
  423. props: {
  424. orgTypeOptions: {
  425. type: Array,
  426. },
  427. ruleTypeOptions: {
  428. type: Array,
  429. },
  430. },
  431. watch: {},
  432. computed: {
  433. ...mapGetters(["orgId", "orgName"]),
  434. },
  435. methods: {
  436. //选择计划类型修改联动框
  437. changeData() {
  438. //判断计划类型
  439. switch (this.formData.checkType) {
  440. //如果是 【定期检查】全省农信系统安全检查
  441. case "1":
  442. //周期
  443. this.formData.planCycle = "5";
  444. //机构类型
  445. this.formData.execOrgType = 1;
  446. this.getRolesByOrg();
  447. //角色
  448. this.formData.roleIds = ["116"];
  449. this.selectedValues = ["116"];
  450. //检查次数
  451. this.formData.count = 1;
  452. //检查内容
  453. this.tableData = null;
  454. break;
  455. //如果是 【定期检查】办事处辖区安全检查
  456. case "2":
  457. //周期
  458. this.formData.planCycle = "5";
  459. //机构类型
  460. this.formData.execOrgType = 2;
  461. this.getRolesByOrg();
  462. //角色
  463. this.formData.roleIds = ["118"];
  464. this.selectedValues = ["118"];
  465. //检查次数
  466. this.formData.count = 2;
  467. //检查内容
  468. this.tableData = null;
  469. break;
  470. //如果是 【定期检查】营业网点安全保卫检查
  471. case "3":
  472. //周期
  473. this.formData.planCycle = "2";
  474. //机构类型
  475. this.formData.execOrgType = 4;
  476. this.getRolesByOrg();
  477. //角色
  478. this.formData.roleIds = ["121"];
  479. this.selectedValues = ["121"];
  480. this.formData.checkOrgTypes = ["4"];
  481. //检查次数
  482. this.formData.count = 3;
  483. //检查内容
  484. this.tableData = null;
  485. break;
  486. //如果是 【定期检查】行社全面安全检查
  487. case "4":
  488. //周期
  489. this.formData.planCycle = "5";
  490. //机构类型
  491. this.formData.execOrgType = 3;
  492. this.getRolesByOrg();
  493. //角色
  494. this.formData.roleIds = ["120"];
  495. this.selectedValues = ["120"];
  496. //检查次数
  497. this.formData.count = 2;
  498. //检查内容
  499. this.tableData = null;
  500. break;
  501. //如果是 【不定期检查】阶段性检查
  502. case "5":
  503. //周期
  504. this.formData.planCycle = "6";
  505. //机构类型
  506. this.formData.execOrgType = null;
  507. //角色
  508. this.formData.roleIds = [];
  509. //检查次数
  510. this.formData.count = 1;
  511. //检查内容
  512. this.tableData = null;
  513. break;
  514. //如果是 【不定期检查】专项检查
  515. case "6":
  516. //周期
  517. this.formData.planCycle = "6";
  518. //机构类型
  519. this.formData.execOrgType = null;
  520. //角色
  521. this.formData.roleIds = [];
  522. //检查次数
  523. this.formData.count = 1;
  524. //检查内容
  525. this.tableData = null;
  526. break;
  527. //如果是 其他
  528. case "7":
  529. //周期
  530. this.formData.planCycle = null;
  531. //机构类型
  532. this.formData.execOrgType = null;
  533. //角色
  534. this.formData.roleIds = [];
  535. //检查次数
  536. this.formData.count = 1;
  537. this.formData.checkOrgTypes = [];
  538. //检查内容
  539. this.tableData = null;
  540. break;
  541. }
  542. // this.changeBuildTime();
  543. },
  544. isbuildTaskNow() {
  545. if (
  546. (this.formData.planCreateOrgId == this.orgId &&
  547. this.formData.hasEdit != 1) ||
  548. (this.formData.planOfOrgType != 3 && this.formData.hasEdit != 1) ||
  549. (this.id == null &&
  550. (this.id == null ||
  551. this.id == undefined ||
  552. this.formData.planStatus == 0))
  553. ) {
  554. return false;
  555. } else return true;
  556. },
  557. handleSelectable(row) {
  558. // 在这里根据特定条件判断是否停用多选框行
  559. return this.getshenglianshe(row); // 返回 true 停用,返回 false 不停用
  560. },
  561. // 监听行选中事件,将选中的行数据存入 selectedRows 数组中
  562. handleSelectionChange(selection) {
  563. // console.log(selection, "selection");
  564. this.selectedRows = selection;
  565. },
  566. deleteSelected() {
  567. // 在这里执行批量删除操作,使用 this.selectedRows 数组中的数据
  568. // console.log("删除选中的数据:", this.selectedRows);
  569. // 从数据数组中移除选中的行数据
  570. this.tableData = this.tableData.filter(
  571. (row) => !this.selectedRows.includes(row)
  572. );
  573. // 清空选中的行数据
  574. this.selectedRows = [];
  575. },
  576. //省联社内容不能删除
  577. getshenglianshe(row) {
  578. if (row.ofOrgId == this.orgId) {
  579. return true;
  580. } else return false;
  581. },
  582. //编辑内容判断
  583. cannotEdit() {
  584. //停用和使用中的任务,只能编辑名称和履职内容
  585. if (this.formData.planStatus == null) {
  586. return false;
  587. }
  588. if (this.formData.planCycle == 6 && this.formData.taskHasCompleted == 1) {
  589. return true;
  590. }
  591. if (this.formData.planOfOrgId != this.orgId) {
  592. return true;
  593. }
  594. let r = !(this.formData.planStatus == 0);
  595. return r;
  596. },
  597. //只能编辑创建机构和所属机构是自己的
  598. cannotEditName() {
  599. if (this.formData.planStatus == null) {
  600. return false;
  601. }
  602. if (this.formData.planCycle == 6 && this.formData.taskHasCompleted == 1) {
  603. return true;
  604. }
  605. let r =
  606. this.formData.planOfOrgId != this.orgId ||
  607. this.formData.planCreateOrgId != this.orgId;
  608. return r;
  609. },
  610. NowBuild() {
  611. //如果新增或者是草稿状态的立即生效的编辑
  612. // if (
  613. // this.formData.planCycle != 6 &&
  614. // (this.id == null ||
  615. // this.id == undefined ||
  616. // (this.defbuildTaskNow && this.formData.planStatus == 0))
  617. // )
  618. if (
  619. this.formData.planCycle != 6 &&
  620. (this.id == null ||
  621. this.id == undefined ||
  622. this.formData.planStatus == 0)
  623. )
  624. // if (
  625. // this.formData.planCycle != 6
  626. // )
  627. return true;
  628. else return false;
  629. },
  630. getLabel(options, value) {
  631. return getLabel(options, value);
  632. },
  633. cleanExecOrgList() {
  634. this.execOrgIds = null;
  635. this.formData.execOrgList = [];
  636. this.formData.roleIds = [];
  637. this.formData.execOrgIds = [];
  638. this.getRolesByOrg();
  639. },
  640. cleanCheckOrgList() {
  641. this.checkOrgIds = null;
  642. this.formData.checkOrgList = [];
  643. this.formData.checkOrgIds = [];
  644. this.tableData = [];
  645. },
  646. tenantIdnormalizer(node, instanceId) {
  647. if (node.children && !node.children.length) {
  648. delete node.children;
  649. }
  650. return {
  651. id: node.id,
  652. label: node.name,
  653. children: node.children,
  654. };
  655. },
  656. handleCheckboxChange() {},
  657. reset() {
  658. return {
  659. planName: null,
  660. planType: null,
  661. planCycle: null,
  662. planStatus: null,
  663. execOrgType: null,
  664. roleNames: null,
  665. count: null,
  666. description: null,
  667. tableData: null,
  668. itemList: null,
  669. planExec: null,
  670. count: 0,
  671. note: null,
  672. planCreateOrgId: null,
  673. planCreateOrgName: null,
  674. roleList: null,
  675. roleIds: null,
  676. execOrg: null,
  677. checkOrg: null,
  678. buildTaskNow: false,
  679. checkOrgList: [],
  680. execOrgList: [],
  681. rulePointList: null,
  682. checkOrgIds: null,
  683. execOrgIds: null,
  684. rulePointIds: null,
  685. checkOrgTypes: [],
  686. checkType: null,
  687. startDate: null,
  688. endDate: null,
  689. };
  690. },
  691. getRolesByOrg() {
  692. console.log(this.formData.execOrgType, "this.formData.execOrgType");
  693. // let params = {
  694. // orgType: null,
  695. // };
  696. if (
  697. this.formData.execOrgType != null &&
  698. this.formData.execOrgType != undefined &&
  699. this.formData.execOrgType != ""
  700. ) {
  701. findRoleByType(this.formData.execOrgType).then((res) => {
  702. console.log(res, "res");
  703. this.planRoles = res;
  704. });
  705. }
  706. },
  707. handleChange(value) {
  708. this.count = value;
  709. },
  710. async refresh(id, other) {
  711. if (id != null && id != undefined) {
  712. await api.get(id).then((res) => {
  713. this.defbuildTaskNow = res.data.buildTaskNow;
  714. this.parentCount = res.data.parentCount;
  715. this.formData = res.data;
  716. this.formData.planCycle = this.formData.planCycle + "";
  717. this.tableData = res.data.rulePointList;
  718. if (this.formData.execOrgType) {
  719. this.formData.roleIds = this.formData.roleList.map(
  720. (role) => role.id
  721. );
  722. this.formData.checkOrgTypes = this.formData.checkOrgTypeList.map(
  723. (type) => type.typeId.toString()
  724. );
  725. this.formData.execOrgIds = this.formData.execOrgList.map(
  726. (org) => org.id
  727. );
  728. this.formData.checkOrgIds = this.formData.checkOrgList.map(
  729. (org) => org.id
  730. );
  731. this.getRolesByOrg();
  732. }
  733. });
  734. } else {
  735. this.formData.id = null;
  736. this.formData.planName = null;
  737. this.formData.planType = null;
  738. this.formData.planCycle = null;
  739. this.formData.planStatus = null;
  740. this.formData.execOrgType = null;
  741. this.formData.checkOrgTypes = [];
  742. this.formData.checkType = null;
  743. this.formData.roleNames = null;
  744. this.formData.count = null;
  745. this.formData.description = null;
  746. this.formData.tableData = null;
  747. this.formData.itemList = null;
  748. this.formData.planExec = null;
  749. this.formData.count = 0;
  750. this.formData.note = null;
  751. this.formData.planCreateOrgId = null;
  752. this.formData.planCreateOrgName = null;
  753. this.formData.roleList = null;
  754. this.formData.roleIds = null;
  755. this.formData.execOrg = null;
  756. this.formData.checkOrg = null;
  757. this.formData.buildTaskNow = false;
  758. this.formData.checkOrgList = [];
  759. this.formData.execOrgList = [];
  760. this.formData.rulePointList = null;
  761. this.formData.checkOrgIds = null;
  762. this.formData.execOrgIds = null;
  763. this.formData.rulePointIds = null;
  764. this.formData.distributePlanStatus = null;
  765. }
  766. },
  767. onSelect(selectList) {
  768. console.log(selectList, "selectList");
  769. for (let i = 0; i < selectList.length; i++) {
  770. let tem = {
  771. ofOrgId: this.orgId,
  772. pointScan: selectList[i].pointScan,
  773. required: !selectList[i].required,
  774. ruleName: selectList[i].ruleName,
  775. itemName: selectList[i].itemName,
  776. pointName: selectList[i].pointName,
  777. areaName: selectList[i].areaName,
  778. itemId: selectList[i].itemId,
  779. id: selectList[i].id,
  780. businessType: selectList[i].businessType,
  781. };
  782. if (this.tableData == null) {
  783. this.tableData = [];
  784. }
  785. if (tem.itemName != null && tem.itemName != undefined) {
  786. this.tableData.push(tem);
  787. }
  788. }
  789. },
  790. async show(id, other = {}) {
  791. this.id = id;
  792. this.tableData = null;
  793. this.formData.execOrgIds = [];
  794. this.formData.checkOrgIds = [];
  795. this.formData.itemList = {};
  796. await this.refresh(id, other);
  797. this.getRolesByOrg();
  798. this.isShow = true;
  799. },
  800. removeRow(row) {
  801. this.$modal
  802. .confirm("是否确认删除?")
  803. .then(function () {})
  804. .then(() => {
  805. this.tableData = this.tableData.filter((item) => item !== row);
  806. this.$modal.msgSuccess("删除成功");
  807. });
  808. // this.tableData = this.tableData.filter((item) => item !== row);
  809. },
  810. // 事件
  811. onHide() {
  812. this.isShow = false;
  813. },
  814. getIteamF() {
  815. // if (this.id == null) {
  816. // this.defaultSelect = [];
  817. // return;
  818. // }else{
  819. // api.getPointIds(this.id).then((res) => {
  820. // this.defaultSelect = res.data;
  821. // });
  822. // }
  823. if (!this.tableData) {
  824. return [];
  825. } else {
  826. return this.tableData.map((d) => d.id);
  827. }
  828. },
  829. openSelect() {
  830. if (
  831. this.formData.checkOrgTypes == null ||
  832. this.formData.checkOrgTypes.length === 0
  833. ) {
  834. this.$modal.alert("请先选择受检机构类型");
  835. return;
  836. }
  837. this.$refs.DialogSelect.show(this.getIteamF());
  838. },
  839. onSubmit() {
  840. this.$refs.form.validate(async (isValidate) => {
  841. if (!isValidate) return;
  842. // console.log(this.formData.hasEdit,"this.formData.hasEdit")
  843. this.formData.planCreateOrgId = this.orgId;
  844. this.formData.planCreateOrgName = this.orgName;
  845. this.formData.rulePointList =
  846. this.tableData == null ? [] : this.tableData;
  847. if (
  848. this.formData.planCycle == "6" &&
  849. dayjs(this.formData.endDate).isBefore(this.formData.startDate)
  850. ) {
  851. this.$message.info("开始时间不能晚于结束时间");
  852. return;
  853. }
  854. if(this.formData.rulePointList.length==0){
  855. this.$message.info("请选择检查内容");
  856. return;
  857. }
  858. this.loading = true;
  859. if (this.formData.planStatus == 1) {
  860. let msg;
  861. let imme;
  862. if (this.formData.taskHasCompleted == 1) {
  863. imme = false;
  864. msg = "因存在已完成任务,本次修改内容将从下周期生效。";
  865. } else {
  866. imme = true;
  867. msg = "因不存在已完成任务,本次修改内容将立即生成。";
  868. }
  869. this.$modal
  870. .confirm(msg)
  871. .then(() => {
  872. this.update(this.formData, imme);
  873. })
  874. .catch(() => {
  875. this.loading = false;
  876. });
  877. } else if (this.formData.planStatus == 2) {
  878. this.update(this.formData, false);
  879. } else {
  880. this.update(this.formData, false);
  881. }
  882. });
  883. },
  884. async update(data, immediateEffect) {
  885. await api
  886. .add(data, immediateEffect)
  887. .then((data) => {
  888. this.isSubmitting = false;
  889. this.loading = false;
  890. this.$emit("success");
  891. this.onHide();
  892. })
  893. .catch((err) => {
  894. this.loading = false;
  895. // console.log(err,"err")
  896. });
  897. },
  898. handleRolesChange(val) {
  899. this.selectedValues = val.toString().split(",");
  900. },
  901. // 事件
  902. //apimark//
  903. },
  904. mounted() {},
  905. components: { DialogSelect, orgDropDown, OrgTree, korgTree, OrgTreeSelect },
  906. };
  907. </script>
  908. <style lang="scss" scoped>
  909. .brand_info {
  910. .el-form {
  911. width: 600px;
  912. padding-top: 40px;
  913. }
  914. }
  915. .checkbox-wrapper .el-checkbox {
  916. display: flex;
  917. align-items: center;
  918. }
  919. .org-selector {
  920. ::v-deep .tags-box {
  921. width: calc(100% - 13px) !important;
  922. }
  923. }
  924. </style>