dialog.edit.vue 28 KB

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