index.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <el-dialog
  3. title="添加规则事项"
  4. :visible.sync="dialogVisible"
  5. :destroy-on-close="true"
  6. append-to-body
  7. width="70%"
  8. :before-close="handleClose"
  9. >
  10. <el-table
  11. ref="multipleTable"
  12. :data="ruleItem"
  13. tooltip-effect="dark"
  14. style="width: 100%; overflow: auto"
  15. height="80vh"
  16. border
  17. @selection-change="handleSelectionChange"
  18. :header-cell-style="{ background: '#F0F3F3' }"
  19. >
  20. <el-table-column type="selection" width="55" align="center">
  21. </el-table-column>
  22. <el-table-column :label="labelTitle + '事项'" prop="name" />
  23. <el-table-column :label="labelTitle + '内容'" prop="content" />
  24. <el-table-column :label="labelTitle + '标准'" prop="norm" />
  25. </el-table>
  26. <div slot="footer" class="dialog-footer">
  27. <el-button size="small" @click="submit" type="primary">提 交</el-button>
  28. <el-button size="small" @click="handleClose">关 闭</el-button>
  29. </div>
  30. </el-dialog>
  31. </template>
  32. <script>
  33. import { getDetail, getCode } from '@/api/ruleManagement/matter';
  34. export default {
  35. props: {
  36. selectedMatter: {
  37. type: Array,
  38. default: () => []
  39. },
  40. labelTitle: {
  41. type: String,
  42. default: '巡点检'
  43. }
  44. },
  45. data() {
  46. return {
  47. dialogVisible: false,
  48. ruleItem: [],
  49. multipleSelection: []
  50. };
  51. },
  52. methods: {
  53. handleClose() {
  54. this.dialogVisible = false;
  55. this.$refs.multipleTable.clearSelection();
  56. },
  57. open() {
  58. this.multipleSelection = [];
  59. this.dialogVisible = true;
  60. this.$nextTick(() => {
  61. this.selectedMatter.map((item) => {
  62. this.ruleItem.forEach((c) => {
  63. if (item.id === c.id) {
  64. this.$refs.multipleTable.toggleRowSelection(c, true);
  65. }
  66. });
  67. });
  68. });
  69. },
  70. // 封装 - 获取规则下面的详情数据及事项
  71. async _getMatterRulesDetails(val) {
  72. const res = await getDetail(val);
  73. this.ruleItem = res.ruleItems;
  74. },
  75. submit() {
  76. if (!this.multipleSelection.length) {
  77. return this.$message.error('请选择事项!');
  78. }
  79. this.$emit('submit', this.multipleSelection);
  80. this.handleClose();
  81. },
  82. handleSelectionChange(val) {
  83. this.multipleSelection = val;
  84. }
  85. }
  86. };
  87. </script>
  88. <style scoped>
  89. .tree-col {
  90. border: 1px solid #e6ebf5;
  91. margin-right: 10px;
  92. width: 20%;
  93. padding: 0 !important;
  94. height: 100%;
  95. overflow: auto;
  96. }
  97. </style>