dialog.edit.vue 28 KB

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