index.vue 19 KB

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