index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  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. ></org-tree>
  13. </el-col>
  14. <el-col :span="20" :xs="24">
  15. <!-- 搜索条件 -->
  16. <el-form
  17. :model="queryParams"
  18. ref="search"
  19. size="small"
  20. :inline="true"
  21. v-show="showSearch"
  22. label-width="100px"
  23. >
  24. <el-form-item prop="execOrgType" label="检查机构类型">
  25. <el-select
  26. prop="execOrgType"
  27. label="检查机构类型"
  28. v-model="queryParams.execOrgType"
  29. placeholder="请选择检查机构类型"
  30. clearable
  31. >
  32. <el-option
  33. v-for="dict in dict.type.sys_org_type"
  34. :key="dict.value"
  35. :label="dict.label"
  36. :value="dict.value"
  37. />
  38. </el-select>
  39. </el-form-item>
  40. <el-form-item prop="checkOrgType" label="受检机构类型">
  41. <el-select
  42. prop="checkOrgType"
  43. label="受检机构类型"
  44. v-model="queryParams.checkOrgType"
  45. placeholder="请选择受检机构类型"
  46. clearable
  47. >
  48. <el-option
  49. v-for="dict in dict.type.sys_org_type"
  50. :key="dict.value"
  51. :label="dict.label"
  52. :value="dict.value"
  53. />
  54. </el-select>
  55. </el-form-item>
  56. <el-form-item prop="checkRole" label="检查角色">
  57. <el-select
  58. @visible-change="getRolesByOrg"
  59. prop="checkRole"
  60. label="检查角色"
  61. v-model="queryParams.checkRole"
  62. placeholder="请选择检查角色"
  63. clearable
  64. >
  65. <el-option
  66. v-for="dict in resumptionRoles"
  67. :key="dict.index"
  68. :label="dict.roleName"
  69. :value="dict.id"
  70. />
  71. </el-select>
  72. </el-form-item>
  73. <el-form-item prop="planCycle" label="检查周期">
  74. <el-select
  75. prop="planCycle"
  76. label="检查周期"
  77. v-model="queryParams.planCycle"
  78. placeholder="请选择检查周期"
  79. clearable
  80. >
  81. <el-option
  82. v-for="item in dict.type.check_cycle"
  83. :key="item.value"
  84. :label="item.label"
  85. :value="item.value"
  86. >
  87. </el-option>
  88. </el-select>
  89. </el-form-item>
  90. <el-form-item prop="planName" label="计划名称">
  91. <el-input
  92. v-model="queryParams.planName"
  93. :maxlength="50"
  94. name="planName"
  95. placeholder="请输入"
  96. clearable
  97. />
  98. </el-form-item>
  99. <el-form-item prop="planStatus" label="计划状态">
  100. <!-- <el-select
  101. prop="planStatus"
  102. label="计划状态"
  103. v-model="queryParams.planStatus"
  104. placeholder="请选择计划状态"
  105. clearable
  106. >
  107. <el-option
  108. v-for="item in dict.type.check_status"
  109. :key="item.value"
  110. :label="item.label"
  111. :value="item.value"
  112. >
  113. </el-option>
  114. </el-select> -->
  115. <el-switch v-model="queryParams.planStatus" active-value="1" inactive-value="2"></el-switch>
  116. </el-form-item>
  117. <el-form-item>
  118. <el-button
  119. type="primary"
  120. icon="el-icon-search"
  121. size="mini"
  122. @click="getList"
  123. >搜索</el-button
  124. >
  125. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
  126. >重置</el-button
  127. >
  128. </el-form-item>
  129. </el-form>
  130. <!-- 按纽 -->
  131. <el-row :gutter="10" class="mb8">
  132. <el-col :span="1.5">
  133. <el-button
  134. type="primary"
  135. plain
  136. icon="el-icon-plus"
  137. size="mini"
  138. @click="handleAdd()"
  139. v-hasPermi="['core:checkplan:add']"
  140. >新增计划</el-button
  141. >
  142. </el-col>
  143. <right-toolbar
  144. :showSearch.sync="showSearch"
  145. @queryTable="getList"
  146. :columns="columns"
  147. ></right-toolbar>
  148. </el-row>
  149. <el-table
  150. v-loading="loading"
  151. :data="pageData"
  152. @selection-change="handleSelectionChange"
  153. row-key="id"
  154. :tree-props="{ children: 'children' }"
  155. >
  156. <el-table-column
  157. prop="index"
  158. label="序号"
  159. width="80px"
  160. v-if="columns[0].visible"
  161. ></el-table-column>
  162. <el-table-column
  163. prop="planName"
  164. label="计划名称"
  165. v-if="columns[1].visible"
  166. ></el-table-column>
  167. <el-table-column
  168. prop="planOfOrgName"
  169. label="计划所属机构"
  170. v-if="columns[4].visible"
  171. >
  172. </el-table-column>
  173. <el-table-column
  174. prop="planCreateOrgName"
  175. label="计划创建机构"
  176. v-if="columns[3].visible"
  177. >
  178. </el-table-column>
  179. <el-table-column
  180. prop="checkType"
  181. label="检查类型"
  182. v-if="columns[2].visible"
  183. >
  184. <template slot-scope="r"
  185. >{{
  186. getLabel(dict.type.check_type, `${r.row.checkType}`)
  187. }}
  188. </template>
  189. </el-table-column>
  190. <el-table-column
  191. prop="execOrgType"
  192. label="检查机构类型"
  193. v-if="columns[2].visible"
  194. >
  195. <template slot-scope="r"
  196. >{{
  197. getLabel(dict.type.sys_org_type, `${r.row.execOrgType}`)
  198. }}
  199. </template>
  200. </el-table-column>
  201. <el-table-column
  202. prop="checkOrgType"
  203. label="受检机构类型"
  204. width="120px"
  205. v-if="columns[6].visible"
  206. >
  207. <template slot-scope="r"
  208. >{{ getLabel(dict.type.sys_org_type, `${r.row.checkOrgType}`) }}
  209. </template>
  210. </el-table-column>
  211. <el-table-column
  212. prop="roleNames"
  213. label="检查角色"
  214. v-if="columns[6].visible"
  215. >
  216. <template slot-scope="scope">
  217. <template v-for="item in splitRoleNames(scope.row.roleNames)">
  218. {{ item }}
  219. <br />
  220. </template>
  221. </template></el-table-column>
  222. <el-table-column
  223. prop="planCycle"
  224. label="检查周期"
  225. width="80px"
  226. v-if="columns[6].visible"
  227. >
  228. <template slot-scope="r"
  229. >{{
  230. getLabel(dict.type.check_cycle, `${r.row.planCycle}`)
  231. }}
  232. </template>
  233. </el-table-column>
  234. <el-table-column
  235. prop="count"
  236. label="检查次数"
  237. v-if="columns[6].visible"
  238. ></el-table-column>
  239. <el-table-column
  240. prop="planStatus"
  241. label="状态"
  242. width="80px"
  243. v-if="columns[6].visible"
  244. >
  245. <template slot-scope="r"
  246. >{{
  247. getLabel(dict.type.check_status, `${r.row.planStatus}`)
  248. }}
  249. </template>
  250. </el-table-column>
  251. <el-table-column
  252. prop="modifiedName"
  253. label="修改人"
  254. v-if="columns[6].visible"
  255. ></el-table-column>
  256. <el-table-column
  257. prop="updateTime"
  258. label="修改时间"
  259. width="80px"
  260. v-if="columns[6].visible"
  261. >
  262. <template slot-scope="scope">
  263. <span>{{ formatTime(scope.row.updateTime,"YYYY-MM-DD") }}</span>
  264. </template>
  265. </el-table-column>
  266. <el-table-column label="操作">
  267. <template slot-scope="r">
  268. <el-button
  269. size="mini"
  270. type="text"
  271. icon="el-icon-edit"
  272. @click="onEdit(r.row.id)"
  273. v-hasPermi="['core:checkplan:edit']"
  274. >修改</el-button
  275. >
  276. <el-button
  277. size="mini"
  278. type="text"
  279. icon="el-icon-delete"
  280. @click="onDel(r.row.id, r.row.planName)"
  281. v-hasPermi="['core:checkplan:remove']"
  282. >删除</el-button
  283. >
  284. <el-button
  285. size="mini"
  286. type="text"
  287. icon="el-icon-delete"
  288. v-if="checkCanPublish(r.row)"
  289. @click="showDialogDistribute(r.row)"
  290. v-hasPermi="['core:checkplan:distribute']"
  291. >下发</el-button>
  292. </template>
  293. </el-table-column>
  294. </el-table>
  295. <pagination
  296. v-show="total > 0"
  297. :total="total"
  298. :page.sync="queryParams.pageNum"
  299. :limit.sync="queryParams.pageSize"
  300. @pagination="getList"
  301. />
  302. </el-col>
  303. </el-row>
  304. <dialog-edit
  305. ref="editDialog"
  306. @success="getList()"
  307. :orgTypeOptions="dict.type.sys_org_type"
  308. :ruleTypeOptions="dict.type.rule_type"
  309. ></dialog-edit>
  310. <DialogDistribute ref="dialogDistribute" @select="sel"></DialogDistribute>
  311. </div>
  312. </template>
  313. <script>
  314. import DialogDistribute from "@/views/resumption/plan/distribute.vue";
  315. import OrgTree from "@/components/orgTree";
  316. import { mapState, mapMutations } from "vuex";
  317. import DialogEdit from "./dialog.edit";
  318. import * as api from "@/api/safetycheck/plan";
  319. import { statusOptions, getLabel } from "@/views/commonOption";
  320. import { listRole } from "@/api/system/role";
  321. export default {
  322. name: "resumptionplan",
  323. dicts: [
  324. "sys_org_type",
  325. "rule_type",
  326. "check_cycle","check_status","check_type"
  327. ],
  328. components: {
  329. DialogEdit,
  330. OrgTree,
  331. DialogDistribute,
  332. },
  333. data() {
  334. const { params, query } = this.$route;
  335. return {
  336. isShow: false,
  337. loading: false,
  338. ids: [],
  339. // 非单个禁用
  340. single: true,
  341. // 非多个禁用
  342. multiple: true,
  343. // 显示搜索条件
  344. showSearch: true,
  345. resumptionRoles: [],
  346. total: 0,
  347. queryParams: {
  348. id: null,
  349. planName: null,
  350. checkRole: null,
  351. planCycle: null,
  352. planCreateOrgId: null,
  353. checkType: null,
  354. planOfOrgId: null,
  355. execOrgType: null,
  356. checkOrgType:null,
  357. planStatus:null,
  358. pageSize:10,
  359. pageNum:1,
  360. checkSub:false,
  361. orgId:null,
  362. ...query,
  363. },
  364. pageData: [],
  365. // 列信息
  366. columns: [
  367. { key: 0, label: `序号`, visible: true },
  368. { key: 1, label: `计划名称`, visible: true },
  369. { key: 2, label: `计划类型`, visible: true },
  370. { key: 3, label: `计划创建机构`, visible: true },
  371. { key: 4, label: `计划所属机构`, visible: true },
  372. { key: 5, label: `履职机构类型`, visible: true },
  373. { key: 6, label: `履职角色`, visible: true },
  374. { key: 7, label: `履职周期`, visible: true },
  375. { key: 8, label: `履职次数`, visible: true },
  376. { key: 9, label: `履职时间`, visible: true },
  377. { key: 10, label: `修改人`, visible: true },
  378. { key: 11, label: `计划状态`, visible: true },
  379. ],
  380. };
  381. },
  382. props: {},
  383. watch: {},
  384. computed: {
  385. ...mapState([]),
  386. },
  387. methods: {
  388. ...mapMutations([]),
  389. //已完成下发的计划不显示下发按钮
  390. checkCanPublish(row) {
  391. console.log(row.planOfOrgType,"row.planOfOrgType")
  392. console.log(row.planOfOrgType == "1"&& row.children.length == 0,"row.children.length")
  393. if (row.planOfOrgType == "1"&& row.children.length == 0) {
  394. console.log("1111")
  395. return true
  396. }
  397. return false;
  398. },
  399. splitRoleNames(val) {
  400. if(val!=null&&val!=undefined){
  401. return val.split(',');
  402. }else{
  403. return [];
  404. }
  405. // 使用逗号分割字符串,得到角色名称的数组
  406. },
  407. sel(selectList){
  408. this.loading = true;
  409. api.distribute(selectList).then((response) => {
  410. this.getList();
  411. this.loading = false;
  412. })
  413. },
  414. getRolesByOrg() {
  415. let params = {
  416. // orgId:this.queryParams.orgId
  417. };
  418. listRole(params).then((res) => {
  419. // console.info(res);
  420. this.resumptionRoles = res.rows;
  421. });
  422. },
  423. getList() {
  424. this.loading = true;
  425. console.info(this.dict.type);
  426. api
  427. .list(this.queryParams)
  428. .then((response) => {
  429. this.pageData = response.rows;
  430. this.total = response.total;
  431. this.loading = false;
  432. })
  433. .catch(() => {
  434. this.loading = false;
  435. });
  436. },
  437. getDefaultKey(key) {
  438. this.queryParams.orgId = key;
  439. this.getList();
  440. },
  441. handleAdd(id, other = {}) {
  442. id=null;
  443. this.$refs.editDialog.show(id, other);
  444. },
  445. onEdit(id, other = {}) {
  446. this.$refs.editDialog.show(id, other);
  447. },
  448. showDialogDistribute(row){
  449. this.$refs.dialogDistribute.show(row);
  450. },
  451. async onDel(id, name) {
  452. this.$modal
  453. .confirm('是否确认删除名称为"' + name + '"的数据项?')
  454. .then(function () {
  455. return api.delelte(id);
  456. })
  457. .then(() => {
  458. this.getList();
  459. this.$modal.msgSuccess("删除成功");
  460. })
  461. .catch(() => {});
  462. // await api.delelte(id);
  463. // this.getList();
  464. },
  465. // 多选框选中数据
  466. handleSelectionChange(selection) {
  467. this.ids = selection.map((item) => item.userId);
  468. this.single = selection.length != 1;
  469. this.multiple = !selection.length;
  470. },
  471. /** 重置按钮操作 */
  472. resetQuery() {
  473. this.resetForm("search");
  474. // this.queryParams.orgId = undefined;
  475. // this.$refs.tree.setCurrentKey(null);
  476. this.getList();
  477. },
  478. //单选框状态改变
  479. checkChange(state) {
  480. this.queryParams.checkSub = state;
  481. this.getList();
  482. },
  483. // 节点单击事件
  484. clickTreeNode(data) {
  485. this.queryParams.orgId = data.id;
  486. this.getList();
  487. },
  488. getStatusLabel(value) {
  489. return getLabel(statusOptions, value);
  490. },
  491. getLabel(options, value) {
  492. return getLabel(options, value);
  493. },
  494. //apimark//
  495. },
  496. mounted() {},
  497. };
  498. </script>
  499. <style lang="scss" scoped>
  500. .brand {
  501. }
  502. </style>