distribute.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <el-dialog
  3. title="选择下发机构状态"
  4. :visible.sync="isShow"
  5. class="g-dialog-select-safe-check"
  6. :close-on-click-modal="false"
  7. width="700px"
  8. top="10vh"
  9. append-to-body
  10. >
  11. <div class="el-dialog-div">
  12. <el-row :gutter="10" class="mb8">
  13. <el-col :span="1.5">
  14. <el-input
  15. size="mini"
  16. v-model="filterName"
  17. placeholder="按机构名称过滤"
  18. @input="filterbyOrgName"
  19. clearable
  20. ></el-input>
  21. </el-col>
  22. <el-col :span="1.5">
  23. <el-button
  24. type="primary"
  25. plain
  26. size="mini"
  27. @click="handleAllStatus('1')"
  28. >全部启用</el-button
  29. >
  30. </el-col>
  31. <el-col :span="1.5">
  32. <el-button
  33. type="danger"
  34. plain
  35. size="mini"
  36. @click="handleAllStatus('0')"
  37. >全部禁用</el-button
  38. >
  39. </el-col>
  40. </el-row>
  41. <el-table :data="tableData" height="400px">
  42. <el-table-column type="index" label="序号" width="80"></el-table-column>
  43. <el-table-column prop="orgName" label="机构名称"></el-table-column>
  44. <el-table-column prop="status" label="计划状态" width="150px">
  45. <template slot-scope="r">
  46. <el-switch
  47. v-model="r.row.status"
  48. active-text="启用"
  49. inactive-text="禁用"
  50. active-value="1"
  51. inactive-value="0"
  52. active-color="#008CD6"
  53. inactive-color="#ff4949"
  54. >
  55. </el-switch>
  56. </template>
  57. </el-table-column>
  58. </el-table>
  59. </div>
  60. <div slot="footer" class="dialog-footer">
  61. <el-button @click="onHide">关闭</el-button>
  62. <el-button type="primary" @click="onSubmit">确定</el-button>
  63. </div>
  64. </el-dialog>
  65. </template>
  66. <script>
  67. import { listByTypes } from "@/api/system/org.js";
  68. export default {
  69. components: {},
  70. data() {
  71. return {
  72. isShow: false,
  73. info: this.emptyInfo(),
  74. tableData: [],
  75. filterName: null,
  76. };
  77. },
  78. computed: {},
  79. watch: {},
  80. props: {
  81. defaultSelect: {
  82. type: Array,
  83. },
  84. orgType: {
  85. type: String,
  86. },
  87. },
  88. methods: {
  89. show(plan) {
  90. this.isShow = true;
  91. this.info.id = plan.id;
  92. listByTypes({
  93. orgId: plan.planCreateOrgId,
  94. orgTypes: ["3"],
  95. }).then((r) => {
  96. this.info.orgAndStatus = r.data.map((d) => {
  97. return { orgId: d.id, orgName: d.shortName, status: "1" };
  98. });
  99. this.tableData = this.info.orgAndStatus;
  100. });
  101. },
  102. handleAllStatus(status) {
  103. this.tableData.forEach((element) => {
  104. element.status = status;
  105. });
  106. },
  107. filterbyOrgName(val) {
  108. if (!val || !val.trim()) {
  109. this.tableData = this.info.orgAndStatus;
  110. } else {
  111. this.tableData = this.info.orgAndStatus.filter(
  112. (o) => o.orgName.indexOf(val) >= 0
  113. );
  114. }
  115. },
  116. onHide() {
  117. this.info = this.emptyInfo();
  118. this.isShow = false;
  119. },
  120. onSubmit() {
  121. console.info(this.info);
  122. this.$emit("select", this.info);
  123. this.onHide();
  124. },
  125. emptyInfo() {
  126. return {
  127. id: null, //计划id
  128. orgAndStatus: [], //机构及状态
  129. };
  130. },
  131. },
  132. mounted() {},
  133. };
  134. </script>
  135. <style lang="scss" scoped>
  136. .el-dialog-div {
  137. overflow: auto;
  138. }
  139. </style>