dialog.select.point.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <DialogCom
  3. title="选择检查内容"
  4. :visible.sync="isShow"
  5. class="g-dialog-select-safe-check"
  6. width="55%"
  7. top="10vh"
  8. append-to-body
  9. @close="closed"
  10. @opened="opened"
  11. >
  12. <div class="el-dialog-div">
  13. <g-search-table
  14. ref="st"
  15. url="/core/safetycheck/ruleItem/pointSelectionPage"
  16. method="post"
  17. :search-data="search"
  18. :manual="true"
  19. :pageable="true"
  20. :select="true"
  21. :select-default="selectList"
  22. :drag="false"
  23. @select="onSelect"
  24. >
  25. <!-- 搜索 -->
  26. <template slot="searchs">
  27. <el-form-item prop="key" label="关键字">
  28. <el-input
  29. v-model="search.key"
  30. maxlength="50"
  31. placeholder="请输入检查项或检查内容"
  32. @changed="onKeyChanged"
  33. ></el-input>
  34. </el-form-item>
  35. <el-form-item prop="selectRuleId" label="检查手册">
  36. <el-select v-model="selectRuleId" clearable @change="onRuleChanged">
  37. <el-option
  38. v-for="item in ruleList"
  39. :value="item.id"
  40. :key="item.id"
  41. :label="item.name"
  42. ></el-option>
  43. </el-select>
  44. </el-form-item>
  45. </template>
  46. <!-- 表格 -->
  47. <template slot="columns">
  48. <el-table-column
  49. header-align="center"
  50. prop="itemName"
  51. label="检查项"
  52. min-width="40%"
  53. ></el-table-column>
  54. <el-table-column
  55. header-align="center"
  56. label="检查内容"
  57. prop="pointName"
  58. min-width="40%"
  59. >
  60. <template slot-scope="scope">
  61. <pre>{{ scope.row.pointName }}</pre>
  62. </template>
  63. </el-table-column>
  64. <el-table-column
  65. header-align="center"
  66. align="center"
  67. prop="areaName"
  68. label="检查区域"
  69. min-width="20%"
  70. ></el-table-column>
  71. <!-- <el-table-column header-align="center" prop="nfcName"
  72. label="采集点"
  73. width="120"></el-table-column>-->
  74. </template>
  75. </g-search-table>
  76. </div>
  77. <div slot="footer" class="dialog-footer">
  78. <el-button type="primary" @click="onSubmit">确定</el-button>
  79. <el-button @click="onHide">关闭</el-button>
  80. </div>
  81. </DialogCom>
  82. </template>
  83. <script>
  84. import GSearchTable from "@/components/table/gx.search.table.vue";
  85. import { ruleListForOrg } from "@/api/safetycheck/rule.js";
  86. export default {
  87. components: { GSearchTable },
  88. data() {
  89. return {
  90. isShow: false,
  91. selectList: [],
  92. ruleList: [],
  93. selectRuleId: null,
  94. search: this.emptySearch(),
  95. prevOrgType: [],
  96. };
  97. },
  98. computed: {},
  99. watch: {},
  100. props: {
  101. orgType: {
  102. type: Array,
  103. isRequired: true,
  104. },
  105. },
  106. methods: {
  107. show(defaultSelect) {
  108. this.isShow = true;
  109. if (defaultSelect && defaultSelect.map) {
  110. this.selectList = defaultSelect.map((s) => ({ id: s }));
  111. }
  112. },
  113. onHide() {
  114. this.isShow = false;
  115. },
  116. opened() {
  117. if (
  118. this.prevOrgType.length == this.orgType.length &&
  119. !this.prevOrgType.find((t) => !this.orgType.includes[t])
  120. ) {
  121. this.search.itemName = null;
  122. if (this.search.ruleId && this.search.ruleId.length > 0) {
  123. this.getList();
  124. }
  125. } else {
  126. this.search = this.emptySearch();
  127. ruleListForOrg({ orgType: this.orgType }).then((r) => {
  128. this.ruleList = r.data;
  129. this.prevOrgType = this.orgType;
  130. this.getList();
  131. });
  132. }
  133. },
  134. closed() {
  135. this.$refs.st.dataList = [];
  136. },
  137. onSelect(item) {
  138. this.selectList = item;
  139. },
  140. onKeyChanged() {
  141. this.getList();
  142. },
  143. onRuleChanged() {
  144. this.getList();
  145. },
  146. onSubmit() {
  147. let s = this.selectList;
  148. this.$emit("select", this.selectList);
  149. this.onHide();
  150. },
  151. emptySearch() {
  152. return {
  153. ruleId: [],
  154. itemName: null,
  155. };
  156. },
  157. getList() {
  158. if (!this.ruleList || this.ruleList.length === 0) {
  159. return;
  160. }
  161. if (this.selectRuleId) {
  162. this.search.ruleId = [this.selectRuleId];
  163. } else {
  164. this.search.ruleId = this.ruleList.map((r) => r.id);
  165. }
  166. this.$refs.st.search();
  167. },
  168. },
  169. mounted() {},
  170. };
  171. </script>
  172. <style lang="scss" scoped>
  173. .el-dialog-div {
  174. overflow: auto;
  175. margin-bottom: 20px;
  176. }
  177. .dialog-footer {
  178. margin-top: 20px;
  179. }
  180. </style>