dialog.edit.vue 27 KB

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