dialog.edit.vue 26 KB

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