dialog.select.point.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. align="center"
  50. prop="itemName"
  51. label="检查项"
  52. min-width="40%"
  53. ></el-table-column>
  54. <el-table-column
  55. 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. align="center"
  66. prop="areaName"
  67. label="检查区域"
  68. min-width="20%"
  69. ></el-table-column>
  70. <!-- <el-table-column align="center" prop="nfcName"
  71. label="采集点"
  72. width="120"></el-table-column>-->
  73. </template>
  74. </g-search-table>
  75. </div>
  76. <div slot="footer" class="dialog-footer">
  77. <el-button type="primary" @click="onSubmit">确定</el-button>
  78. <el-button @click="onHide">关闭</el-button>
  79. </div>
  80. </DialogCom>
  81. </template>
  82. <script>
  83. import GSearchTable from "@/components/table/gx.search.table.vue";
  84. import { ruleListForOrg } from "@/api/safetycheck/rule.js";
  85. export default {
  86. components: { GSearchTable },
  87. data() {
  88. return {
  89. isShow: false,
  90. selectList: [],
  91. ruleList: [],
  92. selectRuleId: null,
  93. search: this.emptySearch(),
  94. prevOrgType: [],
  95. };
  96. },
  97. computed: {},
  98. watch: {},
  99. props: {
  100. orgType: {
  101. type: Array,
  102. isRequired: true,
  103. },
  104. },
  105. methods: {
  106. show(defaultSelect) {
  107. this.isShow = true;
  108. if (defaultSelect && defaultSelect.map) {
  109. this.selectList = defaultSelect.map((s) => ({ id: s }));
  110. }
  111. },
  112. onHide() {
  113. this.isShow = false;
  114. },
  115. opened() {
  116. if (
  117. this.prevOrgType.length == this.orgType.length &&
  118. !this.prevOrgType.find((t) => !this.orgType.includes[t])
  119. ) {
  120. this.search.itemName = null;
  121. if (this.search.ruleId && this.search.ruleId.length > 0) {
  122. this.getList();
  123. }
  124. } else {
  125. this.search = this.emptySearch();
  126. ruleListForOrg({ orgType: this.orgType }).then((r) => {
  127. this.ruleList = r.data;
  128. this.prevOrgType = this.orgType;
  129. this.getList();
  130. });
  131. }
  132. },
  133. closed() {
  134. this.$refs.st.dataList = [];
  135. },
  136. onSelect(item) {
  137. this.selectList = item;
  138. },
  139. onKeyChanged() {
  140. this.getList();
  141. },
  142. onRuleChanged() {
  143. this.getList();
  144. },
  145. onSubmit() {
  146. let s = this.selectList;
  147. this.$emit("select", this.selectList);
  148. this.onHide();
  149. },
  150. emptySearch() {
  151. return {
  152. ruleId: [],
  153. itemName: null,
  154. };
  155. },
  156. getList() {
  157. if (!this.ruleList || this.ruleList.length === 0) {
  158. return;
  159. }
  160. if (this.selectRuleId) {
  161. this.search.ruleId = [this.selectRuleId];
  162. } else {
  163. this.search.ruleId = this.ruleList.map((r) => r.id);
  164. }
  165. this.$refs.st.search();
  166. },
  167. },
  168. mounted() {},
  169. };
  170. </script>
  171. <style lang="scss" scoped>
  172. .el-dialog-div {
  173. overflow: auto;
  174. margin-bottom: 20px;
  175. }
  176. .dialog-footer {
  177. margin-top: 20px;
  178. }
  179. </style>