dialog.edit.vue 30 KB

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