index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="10">
  4. <!--机构数据-->
  5. <el-col :span="4" :xs="24">
  6. <org-tree
  7. v-model="queryParams.orgId"
  8. @defaultKey="getDefaultKey"
  9. @checkChange="checkChange"
  10. @click="clickTreeNode"
  11. hangsheTree
  12. :defaultCheckSub="false"
  13. ></org-tree>
  14. </el-col>
  15. <el-col :span="20" :xs="24">
  16. <!-- 搜索条件 -->
  17. <div class="main-right-box">
  18. <div class="main-search-box">
  19. <el-form
  20. :model="queryParams"
  21. ref="search"
  22. size="small"
  23. :inline="true"
  24. v-show="showSearch"
  25. >
  26. <el-row>
  27. <el-form-item prop="checkType" label="任务类型">
  28. <el-select
  29. prop="checkType"
  30. label="任务类型"
  31. v-model="queryParams.checkType"
  32. placeholder="请选择任务类型"
  33. clearable
  34. >
  35. <el-option
  36. v-for="dict in dict.type.check_type"
  37. :key="dict.value"
  38. :label="dict.label"
  39. :value="dict.value"
  40. />
  41. </el-select>
  42. </el-form-item>
  43. <el-form-item
  44. prop="execOrgType"
  45. label="检查机构类型"
  46. v-if="false"
  47. >
  48. <el-select
  49. prop="execOrgType"
  50. label="检查机构类型"
  51. v-model="queryParams.execOrgType"
  52. placeholder="请选择检查机构类型"
  53. clearable
  54. >
  55. <el-option
  56. v-for="dict in dict.type.sys_org_type"
  57. :key="dict.value"
  58. :label="dict.label"
  59. :value="dict.value"
  60. />
  61. </el-select>
  62. </el-form-item>
  63. <el-form-item
  64. prop="checkOrgType"
  65. label="受检机构类型"
  66. v-if="false"
  67. >
  68. <el-select
  69. prop="checkOrgType"
  70. label="受检机构类型"
  71. v-model="queryParams.checkOrgType"
  72. placeholder="请选择受检机构类型"
  73. clearable
  74. >
  75. <el-option
  76. v-for="dict in dict.type.sys_org_type"
  77. :key="dict.value"
  78. :label="dict.label"
  79. :value="dict.value"
  80. />
  81. </el-select>
  82. </el-form-item>
  83. <el-form-item prop="checkRole" label="检查人员">
  84. <el-select
  85. @visible-change="getRolesByOrg"
  86. prop="checkRole"
  87. label="检查人员"
  88. v-model="queryParams.checkRole"
  89. placeholder="请选择用户角色"
  90. clearable
  91. >
  92. <el-option
  93. v-for="dict in resumptionRoles"
  94. :key="dict.index"
  95. :label="dict.roleName"
  96. :value="dict.id"
  97. />
  98. </el-select>
  99. </el-form-item>
  100. <el-form-item prop="planCycle" label="任务周期">
  101. <el-select
  102. prop="planCycle"
  103. label="任务周期"
  104. v-model="queryParams.planCycle"
  105. placeholder="请选择任务周期"
  106. clearable
  107. >
  108. <el-option
  109. v-for="item in dict.type.check_cycle"
  110. :key="item.value"
  111. :label="item.label"
  112. :value="item.value"
  113. >
  114. </el-option>
  115. </el-select>
  116. </el-form-item>
  117. <el-form-item prop="planStatus" label="任务状态">
  118. <el-select
  119. prop="planStatus"
  120. label="任务状态"
  121. v-model="queryParams.planStatus"
  122. placeholder="请选择任务状态"
  123. clearable
  124. >
  125. <el-option
  126. v-for="item in dict.type.check_status"
  127. :key="item.value"
  128. :label="item.label"
  129. :value="item.value"
  130. >
  131. </el-option>
  132. </el-select>
  133. </el-form-item>
  134. <el-form-item prop="planName" label="任务名称">
  135. <el-input
  136. v-model="queryParams.planName"
  137. :maxlength="50"
  138. name="planName"
  139. placeholder="请输入关键字"
  140. clearable
  141. />
  142. </el-form-item>
  143. </el-row>
  144. <el-row> </el-row>
  145. </el-form>
  146. <el-row :gutter="10">
  147. <el-col :span="1.5">
  148. <el-button
  149. type="primary"
  150. icon="el-icon-search"
  151. size="mini"
  152. @click="getList"
  153. >搜索</el-button
  154. >
  155. </el-col>
  156. <el-col :span="1.5">
  157. <el-button
  158. type="primary"
  159. icon="el-icon-refresh"
  160. size="mini"
  161. @click="resetQuery"
  162. >重置</el-button
  163. >
  164. </el-col>
  165. <el-col :span="1.5">
  166. <el-button
  167. type="primary"
  168. icon="el-icon-plus"
  169. size="mini"
  170. @click="handleAdd()"
  171. v-hasPermi="['core:checkplan:add']"
  172. >新增任务</el-button
  173. >
  174. </el-col>
  175. <right-toolbar
  176. :showSearch.sync="showSearch"
  177. @queryTable="getList"
  178. :columns="columns"
  179. ></right-toolbar>
  180. </el-row>
  181. </div>
  182. <el-table
  183. border
  184. height="596"
  185. size="small"
  186. v-loading="loading"
  187. :data="pageData"
  188. @selection-change="handleSelectionChange"
  189. row-key="id"
  190. :tree-props="{ children: 'children' }"
  191. >
  192. <el-table-column
  193. type="index"
  194. label="序号"
  195. align="center"
  196. width="80px"
  197. v-if="columns[0].visible"
  198. ></el-table-column>
  199. <el-table-column
  200. prop="planName"
  201. label="任务名称"
  202. width="250px"
  203. :show-overflow-tooltip="true"
  204. v-if="columns[1].visible"
  205. ></el-table-column>
  206. <el-table-column
  207. prop="checkType"
  208. label="任务类型"
  209. align="center"
  210. width="180px"
  211. v-if="columns[2].visible"
  212. >
  213. <template slot-scope="r"
  214. >{{ getLabel(dict.type.check_type, `${r.row.checkType}`) }}
  215. </template>
  216. </el-table-column>
  217. <el-table-column
  218. prop="planCreateOrgName"
  219. label="创建机构"
  220. align="center"
  221. width="180px"
  222. v-if="columns[3].visible"
  223. >
  224. </el-table-column>
  225. <el-table-column
  226. prop="planOfOrgName"
  227. label="行社名称"
  228. align="center"
  229. width="180px"
  230. v-if="columns[4].visible"
  231. >
  232. </el-table-column>
  233. <el-table-column
  234. prop="execOrgType"
  235. align="center"
  236. width="180px"
  237. label="检查主体"
  238. >
  239. <template slot-scope="r"
  240. >{{ getLabel(dict.type.sys_org_type, `${r.row.execOrgType}`) }}
  241. </template>
  242. </el-table-column>
  243. <el-table-column
  244. prop="typeNames"
  245. align="center"
  246. width="180px"
  247. label="受检机构"
  248. >
  249. <!-- <template slot-scope="r"
  250. >{{ getLabel(dict.type.sys_org_type, `${r.row.checkOrgType}`) }}
  251. </template> -->
  252. </el-table-column>
  253. <el-table-column
  254. prop="roleNames"
  255. align="center"
  256. width="180px"
  257. label="检查人员"
  258. v-if="columns[6].visible"
  259. >
  260. <template slot-scope="scope">
  261. <template v-for="item in splitRoleNames(scope.row.roleNames)">
  262. {{ item }}
  263. <br />
  264. </template> </template
  265. ></el-table-column>
  266. <el-table-column
  267. prop="planCycle"
  268. label="任务周期"
  269. align="center"
  270. width="180px"
  271. v-if="columns[6].visible"
  272. >
  273. <template slot-scope="r"
  274. >{{ getLabel(dict.type.check_cycle, `${r.row.planCycle}`) }}
  275. </template>
  276. </el-table-column>
  277. <el-table-column
  278. prop="count"
  279. label="任务次数"
  280. align="center"
  281. width="180px"
  282. v-if="columns[6].visible"
  283. ></el-table-column>
  284. <el-table-column
  285. prop="planStatus"
  286. label="任务状态"
  287. align="center"
  288. width="180px"
  289. v-if="columns[6].visible"
  290. >
  291. <template slot-scope="r"
  292. >{{ getLabel(dict.type.check_status, `${r.row.planStatus}`) }}
  293. </template>
  294. </el-table-column>
  295. <el-table-column
  296. prop="modifiedName"
  297. label="修改人"
  298. v-if="false"
  299. ></el-table-column>
  300. <el-table-column
  301. prop="updateTime"
  302. label="修改时间"
  303. width="80px"
  304. v-if="false"
  305. >
  306. <template slot-scope="scope">
  307. <span>{{
  308. formatTime(scope.row.updateTime, "YYYY-MM-DD")
  309. }}</span>
  310. </template>
  311. </el-table-column>
  312. <el-table-column
  313. label="操作"
  314. width="200"
  315. fixed="right"
  316. align="center"
  317. >
  318. <template slot-scope="r">
  319. <el-button
  320. type="text"
  321. size="mini"
  322. icon="el-icon-arrow-down"
  323. v-if="checkCanPublish(r.row)"
  324. @click="showDialogDistribute(r.row)"
  325. v-hasPermi="['core:checkplan:distribute']"
  326. >下发</el-button
  327. >
  328. <el-button
  329. type="text"
  330. size="mini"
  331. icon="el-icon-arrow-down"
  332. v-if="newcheckCanPublish(r.row)"
  333. @click="newshowDialogDistribute(r.row)"
  334. v-hasPermi="['core:checkplan:distribute']"
  335. >下发</el-button
  336. >
  337. <el-button
  338. type="text"
  339. icon="el-icon-top-left"
  340. size="mini"
  341. v-if="chehui(r.row)"
  342. @click="chhuile(r.row)"
  343. v-hasPermi="['core:checkplan:distribute']"
  344. >撤回</el-button
  345. >
  346. <el-button
  347. v-if="eqOrg(r.row)"
  348. size="mini"
  349. type="text"
  350. icon="el-icon-edit-outline"
  351. @click="onEdit(r.row.id)"
  352. v-hasPermi="['core:checkplan:edit']"
  353. >编辑</el-button
  354. >
  355. <el-button
  356. v-if="eqOrg2(r.row)"
  357. size="mini"
  358. type="text"
  359. icon="el-icon-delete"
  360. @click="onDel(r.row.id, r.row.planName)"
  361. v-hasPermi="['core:checkplan:remove']"
  362. >删除</el-button
  363. >
  364. </template>
  365. </el-table-column>
  366. </el-table>
  367. <pagination
  368. v-show="total > 0"
  369. :total="total"
  370. :page.sync="queryParams.pageNum"
  371. :limit.sync="queryParams.pageSize"
  372. @pagination="getList"
  373. />
  374. </div>
  375. </el-col>
  376. </el-row>
  377. <dialog-edit
  378. ref="editDialog"
  379. @success="getList()"
  380. :orgTypeOptions="dict.type.sys_org_type"
  381. :ruleTypeOptions="dict.type.rule_type"
  382. ></dialog-edit>
  383. <DialogDistribute ref="dialogDistribute" @select="sel"></DialogDistribute>
  384. </div>
  385. </template>
  386. <script>
  387. import DialogDistribute from "./distribute.vue";
  388. import OrgTree from "@/components/orgTree";
  389. import { mapState, mapMutations, mapGetters } from "vuex";
  390. import DialogEdit from "./dialog.edit";
  391. import * as api from "@/api/safetycheck/plan";
  392. import { statusOptions, getLabel } from "@/views/commonOption";
  393. import { listRole } from "@/api/system/role";
  394. export default {
  395. name: "resumptionplan",
  396. dicts: [
  397. "sys_org_type",
  398. "rule_type",
  399. "check_cycle",
  400. "check_status",
  401. "check_type",
  402. ],
  403. components: {
  404. DialogEdit,
  405. OrgTree,
  406. DialogDistribute,
  407. },
  408. data() {
  409. const { params, query } = this.$route;
  410. return {
  411. isShow: false,
  412. loading: false,
  413. ids: [],
  414. // 非单个停用
  415. single: true,
  416. // 非多个停用
  417. multiple: true,
  418. // 显示搜索条件
  419. showSearch: true,
  420. resumptionRoles: [],
  421. total: 0,
  422. queryParams: {
  423. id: null,
  424. planName: null,
  425. checkRole: null,
  426. planCycle: null,
  427. planCreateOrgId: null,
  428. checkType: null,
  429. planOfOrgId: null,
  430. execOrgType: null,
  431. checkOrgType: null,
  432. planStatus: null,
  433. pageSize: 10,
  434. pageNum: 1,
  435. checkSub: false,
  436. orgId: null,
  437. ...query,
  438. },
  439. pageData: [],
  440. // 列信息
  441. columns: [
  442. { key: 0, label: `序号`, visible: true },
  443. { key: 1, label: `计划名称`, visible: true },
  444. { key: 2, label: `计划类型`, visible: true },
  445. { key: 3, label: `计划创建机构`, visible: true },
  446. { key: 4, label: `计划所属机构`, visible: true },
  447. { key: 5, label: `履职机构类型`, visible: true },
  448. { key: 6, label: `履职角色`, visible: true },
  449. { key: 7, label: `履职周期`, visible: true },
  450. { key: 8, label: `履职次数`, visible: true },
  451. { key: 9, label: `履职时间`, visible: true },
  452. { key: 10, label: `修改人`, visible: true },
  453. { key: 11, label: `计划状态`, visible: true },
  454. ],
  455. };
  456. },
  457. props: {},
  458. watch: {},
  459. computed: {
  460. ...mapState([]),
  461. ...mapGetters(["orgId", "orgName"]),
  462. },
  463. methods: {
  464. ...mapMutations([]),
  465. //判断是否跟当前用户同机构
  466. eqOrg(row) {
  467. // console.log(row.planOfOrgId,"row.planOfOrgId");
  468. // console.log(this.orgId,"this.orgId");
  469. if (
  470. row != null &&
  471. row != undefined &&
  472. (row.planCreateOrgId == this.orgId ||
  473. (row.planOfOrgType == 3 && row.planOfOrgId == this.orgId))
  474. ) {
  475. return true;
  476. }
  477. return false;
  478. },
  479. eqOrg2(row) {
  480. // console.log(row.planCreateOrgId,"row.planCreateOrgId");
  481. // console.log(this.orgId,"this.orgId");
  482. if (
  483. row != null &&
  484. row != undefined &&
  485. row.planCreateOrgId == this.orgId &&
  486. row.planOfOrgId == this.orgId
  487. ) {
  488. return true;
  489. }
  490. return false;
  491. },
  492. newcheckCanPublish(row) {
  493. //如果计划所属机构类型为行社并且计划不为进行中并且计划创建机构为当前机构或者
  494. //计划状态为停用并且不属于子计划并且计划所属机构类型为省联社
  495. if (
  496. (row.planOfOrgType == 3 &&
  497. row.planStatus != 1 &&
  498. row.planCreateOrgId == this.orgId) ||
  499. (row.planStatus == 2 && row.parentId != -1 && row.planOfOrgType == 1) ||
  500. (row.planStatus != 1 && (row.execOrgType == 1 || row.execOrgType == 2))
  501. ) {
  502. return true;
  503. }
  504. return false;
  505. },
  506. newshowDialogDistribute(row) {
  507. this.$modal
  508. .confirm("是否下发!", "提示")
  509. .then(() => {
  510. // 用户点击了确认按钮
  511. console.log("执行操作...");
  512. this.loading = true;
  513. api
  514. .distributeCheHui(row.id)
  515. .then((response) => {
  516. // console.log(response, "then");
  517. if (response.data == 0) {
  518. this.loading = false;
  519. } else {
  520. this.getList();
  521. this.loading = false;
  522. }
  523. })
  524. .catch((response) => {
  525. // console.log(response, "catch");
  526. this.getList();
  527. this.loading = false;
  528. });
  529. })
  530. .catch(() => {
  531. // 用户点击了取消按钮
  532. console.log("取消操作...");
  533. });
  534. },
  535. //已完成下发的计划不显示下发按钮
  536. checkCanPublish(row) {
  537. // console.log(row.planOfOrgType == "1","row.planOfOrgType")
  538. // console.log(row.planOfOrgType == "1"&& row.distribute==null,"row.distribute")
  539. //如果计划所属机构为省联社并且计划下发状态为0并且计划检查机构类型不为省联社和办事处(只有一个无法下发)
  540. if (
  541. row.planOfOrgType == "1" &&
  542. row.distribute == 0 &&
  543. row.execOrgType != "1" &&
  544. row.execOrgType != "2"
  545. ) {
  546. return true;
  547. }
  548. return false;
  549. },
  550. splitRoleNames(val) {
  551. if (val != null && val != undefined) {
  552. return val.split(",");
  553. } else {
  554. return [];
  555. }
  556. // 使用逗号分割字符串,得到角色名称的数组
  557. },
  558. sel(selectList) {
  559. this.loading = true;
  560. api.distribute(selectList).then((response) => {
  561. this.getList();
  562. this.loading = false;
  563. });
  564. },
  565. getRolesByOrg() {
  566. let params = {
  567. // orgId:this.queryParams.orgId
  568. };
  569. listRole(params).then((res) => {
  570. // console.info(res);
  571. this.resumptionRoles = res.rows;
  572. });
  573. },
  574. getList() {
  575. this.loading = true;
  576. console.info(this.dict.type);
  577. api
  578. .list(this.queryParams)
  579. .then((response) => {
  580. this.pageData = response.rows;
  581. this.total = response.total;
  582. this.loading = false;
  583. })
  584. .catch(() => {
  585. this.loading = false;
  586. });
  587. },
  588. getDefaultKey(key) {
  589. this.queryParams.orgId = key;
  590. this.getList();
  591. },
  592. handleAdd(id, other = {}) {
  593. id = null;
  594. this.$refs.editDialog.show(id, other);
  595. },
  596. onEdit(id, other = {}) {
  597. this.$refs.editDialog.show(id, other);
  598. },
  599. //开始撤回
  600. chhuile(row) {
  601. this.$modal
  602. .confirm("撤回计划会清除本周期所有任务!", "提示")
  603. .then(() => {
  604. // 用户点击了确认按钮
  605. // console.log("执行操作...");
  606. this.loading = true;
  607. api.cheHui(row.id).then((response) => {
  608. this.getList();
  609. this.loading = false;
  610. });
  611. })
  612. .catch(() => {
  613. // 用户点击了取消按钮
  614. // console.log("取消操作...");
  615. });
  616. },
  617. //已下发的显示撤回
  618. chehui(row) {
  619. if (row.distribute == 1 && row.planCreateOrgId == this.orgId) {
  620. return true;
  621. }
  622. return false;
  623. },
  624. showDialogDistribute(row) {
  625. console.log(row, "qqq");
  626. this.$refs.dialogDistribute.show(row);
  627. },
  628. async onDel(id, name) {
  629. this.$modal
  630. .confirm('是否确认删除名称为"' + name + '"的数据项?')
  631. .then(() => {
  632. // 用户点击了确认按钮
  633. // console.log("执行操作...");
  634. this.loading = true;
  635. api
  636. .delelte(id)
  637. .then(() => {
  638. this.getList();
  639. this.loading = false;
  640. this.$modal.msgSuccess("删除成功");
  641. })
  642. .catch(() => {
  643. this.loading = false;
  644. });
  645. })
  646. .catch(() => {
  647. // 用户点击了取消按钮
  648. // console.log("取消操作...");
  649. });
  650. },
  651. // 多选框选中数据
  652. handleSelectionChange(selection) {
  653. this.ids = selection.map((item) => item.userId);
  654. this.single = selection.length != 1;
  655. this.multiple = !selection.length;
  656. },
  657. /** 重置按钮操作 */
  658. resetQuery() {
  659. this.resetForm("search");
  660. // this.queryParams.orgId = undefined;
  661. // this.$refs.tree.setCurrentKey(null);
  662. this.getList();
  663. },
  664. //单选框状态改变
  665. checkChange(state) {
  666. this.queryParams.checkSub = state;
  667. this.getList();
  668. },
  669. // 节点单击事件
  670. clickTreeNode(data) {
  671. this.queryParams.orgId = data.id;
  672. this.getList();
  673. },
  674. getStatusLabel(value) {
  675. return getLabel(statusOptions, value);
  676. },
  677. getLabel(options, value) {
  678. return getLabel(options, value);
  679. },
  680. //apimark//
  681. },
  682. mounted() {},
  683. };
  684. </script>
  685. <style lang="scss" scoped>
  686. .brand {
  687. }
  688. </style>