index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701
  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. icon="el-icon-arrow-down"
  322. v-if="checkCanPublish(r.row)"
  323. @click="showDialogDistribute(r.row)"
  324. v-hasPermi="['core:checkplan:distribute']"
  325. >下发</el-button
  326. >
  327. <el-button
  328. type="text"
  329. icon="el-icon-arrow-down"
  330. v-if="newcheckCanPublish(r.row)"
  331. @click="newshowDialogDistribute(r.row)"
  332. v-hasPermi="['core:checkplan:distribute']"
  333. >下发</el-button
  334. >
  335. <el-button
  336. type="text"
  337. icon="el-icon-top-left"
  338. v-if="chehui(r.row)"
  339. @click="chhuile(r.row)"
  340. v-hasPermi="['core:checkplan:distribute']"
  341. >撤回</el-button
  342. >
  343. <el-button
  344. v-if="eqOrg(r.row)"
  345. type="text"
  346. icon="el-icon-edit-outline"
  347. @click="onEdit(r.row.id)"
  348. v-hasPermi="['core:checkplan:edit']"
  349. >编辑</el-button
  350. >
  351. <el-button
  352. v-if="eqOrg2(r.row)"
  353. type="text"
  354. icon="el-icon-delete"
  355. @click="onDel(r.row.id, r.row.planName)"
  356. v-hasPermi="['core:checkplan:remove']"
  357. >删除</el-button
  358. >
  359. </template>
  360. </el-table-column>
  361. </el-table>
  362. <pagination
  363. v-show="total > 0"
  364. :total="total"
  365. :page.sync="queryParams.pageNum"
  366. :limit.sync="queryParams.pageSize"
  367. @pagination="getList"
  368. />
  369. </div>
  370. </el-col>
  371. </el-row>
  372. <dialog-edit
  373. ref="editDialog"
  374. @success="getList()"
  375. :orgTypeOptions="dict.type.sys_org_type"
  376. :ruleTypeOptions="dict.type.rule_type"
  377. ></dialog-edit>
  378. <DialogDistribute ref="dialogDistribute" @select="sel"></DialogDistribute>
  379. </div>
  380. </template>
  381. <script>
  382. import DialogDistribute from "./distribute.vue";
  383. import OrgTree from "@/components/orgTree";
  384. import { mapState, mapMutations, mapGetters } from "vuex";
  385. import DialogEdit from "./dialog.edit";
  386. import * as api from "@/api/safetycheck/plan";
  387. import { statusOptions, getLabel } from "@/views/commonOption";
  388. import { listRole } from "@/api/system/role";
  389. export default {
  390. name: "resumptionplan",
  391. dicts: [
  392. "sys_org_type",
  393. "rule_type",
  394. "check_cycle",
  395. "check_status",
  396. "check_type",
  397. ],
  398. components: {
  399. DialogEdit,
  400. OrgTree,
  401. DialogDistribute,
  402. },
  403. data() {
  404. const { params, query } = this.$route;
  405. return {
  406. isShow: false,
  407. loading: false,
  408. ids: [],
  409. // 非单个停用
  410. single: true,
  411. // 非多个停用
  412. multiple: true,
  413. // 显示搜索条件
  414. showSearch: true,
  415. resumptionRoles: [],
  416. total: 0,
  417. queryParams: {
  418. id: null,
  419. planName: null,
  420. checkRole: null,
  421. planCycle: null,
  422. planCreateOrgId: null,
  423. checkType: null,
  424. planOfOrgId: null,
  425. execOrgType: null,
  426. checkOrgType: null,
  427. planStatus: null,
  428. pageSize: 10,
  429. pageNum: 1,
  430. checkSub: false,
  431. orgId: null,
  432. ...query,
  433. },
  434. pageData: [],
  435. // 列信息
  436. columns: [
  437. { key: 0, label: `序号`, visible: true },
  438. { key: 1, label: `计划名称`, visible: true },
  439. { key: 2, label: `计划类型`, visible: true },
  440. { key: 3, label: `计划创建机构`, visible: true },
  441. { key: 4, label: `计划所属机构`, visible: true },
  442. { key: 5, label: `履职机构类型`, visible: true },
  443. { key: 6, label: `履职角色`, visible: true },
  444. { key: 7, label: `履职周期`, visible: true },
  445. { key: 8, label: `履职次数`, visible: true },
  446. { key: 9, label: `履职时间`, visible: true },
  447. { key: 10, label: `修改人`, visible: true },
  448. { key: 11, label: `计划状态`, visible: true },
  449. ],
  450. };
  451. },
  452. props: {},
  453. watch: {},
  454. computed: {
  455. ...mapState([]),
  456. ...mapGetters(["orgId", "orgName"]),
  457. },
  458. methods: {
  459. ...mapMutations([]),
  460. //判断是否跟当前用户同机构
  461. eqOrg(row) {
  462. // console.log(row.planOfOrgId,"row.planOfOrgId");
  463. // console.log(this.orgId,"this.orgId");
  464. if (
  465. row != null &&
  466. row != undefined &&
  467. (row.planCreateOrgId == this.orgId ||
  468. (row.planOfOrgType == 3 && row.planOfOrgId == this.orgId))
  469. ) {
  470. return true;
  471. }
  472. return false;
  473. },
  474. eqOrg2(row) {
  475. // console.log(row.planCreateOrgId,"row.planCreateOrgId");
  476. // console.log(this.orgId,"this.orgId");
  477. if (
  478. row != null &&
  479. row != undefined &&
  480. row.planCreateOrgId == this.orgId &&
  481. row.planOfOrgId == this.orgId
  482. ) {
  483. return true;
  484. }
  485. return false;
  486. },
  487. newcheckCanPublish(row) {
  488. //如果计划所属机构类型为行社并且计划不为进行中并且计划创建机构为当前机构或者
  489. //计划状态为停用并且不属于子计划并且计划所属机构类型为省联社
  490. if (
  491. (row.planOfOrgType == 3 &&
  492. row.planStatus != 1 &&
  493. row.planCreateOrgId == this.orgId) ||
  494. (row.planStatus == 2 && row.parentId != -1 && row.planOfOrgType == 1) ||
  495. (row.planStatus != 1 && (row.execOrgType == 1 || row.execOrgType == 2))
  496. ) {
  497. return true;
  498. }
  499. return false;
  500. },
  501. newshowDialogDistribute(row) {
  502. this.$modal
  503. .confirm("是否下发!", "提示")
  504. .then(() => {
  505. // 用户点击了确认按钮
  506. console.log("执行操作...");
  507. this.loading = true;
  508. api
  509. .distributeCheHui(row.id)
  510. .then((response) => {
  511. // console.log(response, "then");
  512. if (response.data == 0) {
  513. this.loading = false;
  514. } else {
  515. this.getList();
  516. this.loading = false;
  517. }
  518. })
  519. .catch((response) => {
  520. // console.log(response, "catch");
  521. this.getList();
  522. this.loading = false;
  523. });
  524. })
  525. .catch(() => {
  526. // 用户点击了取消按钮
  527. console.log("取消操作...");
  528. });
  529. },
  530. //已完成下发的计划不显示下发按钮
  531. checkCanPublish(row) {
  532. // console.log(row.planOfOrgType == "1","row.planOfOrgType")
  533. // console.log(row.planOfOrgType == "1"&& row.distribute==null,"row.distribute")
  534. //如果计划所属机构为省联社并且计划下发状态为0并且计划检查机构类型不为省联社和办事处(只有一个无法下发)
  535. if (
  536. row.planOfOrgType == "1" &&
  537. row.distribute == 0 &&
  538. row.execOrgType != "1" &&
  539. row.execOrgType != "2"
  540. ) {
  541. return true;
  542. }
  543. return false;
  544. },
  545. splitRoleNames(val) {
  546. if (val != null && val != undefined) {
  547. return val.split(",");
  548. } else {
  549. return [];
  550. }
  551. // 使用逗号分割字符串,得到角色名称的数组
  552. },
  553. sel(selectList) {
  554. this.loading = true;
  555. api.distribute(selectList).then((response) => {
  556. this.getList();
  557. this.loading = false;
  558. });
  559. },
  560. getRolesByOrg() {
  561. let params = {
  562. // orgId:this.queryParams.orgId
  563. };
  564. listRole(params).then((res) => {
  565. // console.info(res);
  566. this.resumptionRoles = res.rows;
  567. });
  568. },
  569. getList() {
  570. this.loading = true;
  571. console.info(this.dict.type);
  572. api
  573. .list(this.queryParams)
  574. .then((response) => {
  575. this.pageData = response.rows;
  576. this.total = response.total;
  577. this.loading = false;
  578. })
  579. .catch(() => {
  580. this.loading = false;
  581. });
  582. },
  583. getDefaultKey(key) {
  584. this.queryParams.orgId = key;
  585. this.getList();
  586. },
  587. handleAdd(id, other = {}) {
  588. id = null;
  589. this.$refs.editDialog.show(id, other);
  590. },
  591. onEdit(id, other = {}) {
  592. this.$refs.editDialog.show(id, other);
  593. },
  594. //开始撤回
  595. chhuile(row) {
  596. this.$modal
  597. .confirm("撤回计划会清除本周期所有任务!", "提示")
  598. .then(() => {
  599. // 用户点击了确认按钮
  600. // console.log("执行操作...");
  601. this.loading = true;
  602. api.cheHui(row.id).then((response) => {
  603. this.getList();
  604. this.loading = false;
  605. });
  606. })
  607. .catch(() => {
  608. // 用户点击了取消按钮
  609. // console.log("取消操作...");
  610. });
  611. },
  612. //已下发的显示撤回
  613. chehui(row) {
  614. if (row.distribute == 1 && row.planCreateOrgId == this.orgId) {
  615. return true;
  616. }
  617. return false;
  618. },
  619. showDialogDistribute(row) {
  620. console.log(row, "qqq");
  621. this.$refs.dialogDistribute.show(row);
  622. },
  623. async onDel(id, name) {
  624. this.$modal
  625. .confirm('是否确认删除名称为"' + name + '"的数据项?')
  626. .then(() => {
  627. // 用户点击了确认按钮
  628. // console.log("执行操作...");
  629. this.loading = true;
  630. api
  631. .delelte(id)
  632. .then(() => {
  633. this.getList();
  634. this.loading = false;
  635. this.$modal.msgSuccess("删除成功");
  636. })
  637. .catch(() => {
  638. this.loading = false;
  639. });
  640. })
  641. .catch(() => {
  642. // 用户点击了取消按钮
  643. // console.log("取消操作...");
  644. });
  645. },
  646. // 多选框选中数据
  647. handleSelectionChange(selection) {
  648. this.ids = selection.map((item) => item.userId);
  649. this.single = selection.length != 1;
  650. this.multiple = !selection.length;
  651. },
  652. /** 重置按钮操作 */
  653. resetQuery() {
  654. this.resetForm("search");
  655. // this.queryParams.orgId = undefined;
  656. // this.$refs.tree.setCurrentKey(null);
  657. this.getList();
  658. },
  659. //单选框状态改变
  660. checkChange(state) {
  661. this.queryParams.checkSub = state;
  662. this.getList();
  663. },
  664. // 节点单击事件
  665. clickTreeNode(data) {
  666. this.queryParams.orgId = data.id;
  667. this.getList();
  668. },
  669. getStatusLabel(value) {
  670. return getLabel(statusOptions, value);
  671. },
  672. getLabel(options, value) {
  673. return getLabel(options, value);
  674. },
  675. //apimark//
  676. },
  677. mounted() {},
  678. };
  679. </script>
  680. <style lang="scss" scoped>
  681. .brand {
  682. }
  683. </style>