replaceDialog.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <el-dialog
  3. :visible.sync="isShow"
  4. :close-on-click-modal="false"
  5. :modal-append-to-body="false"
  6. :append-to-body="true"
  7. @close="cancelHandle"
  8. custom-class="replace-dialog"
  9. center
  10. v-dialogDrag
  11. width="600px"
  12. >
  13. <div slot="title" style="display: flex; align-items: center">
  14. <img
  15. :src="$icons.editicon"
  16. style="color: #fff; width: 16px; height: 16px; marginright: 5px"
  17. />
  18. <span style="font-size: 16px">&nbsp;<!-- 替换指标 -->{{$t('EtaBasePage.replace_edb_btn')}}</span>
  19. </div>
  20. <el-form
  21. ref="diaForm"
  22. class="form-cont"
  23. label-position="left"
  24. label-width="120px"
  25. :model="formData"
  26. :rules="formRules"
  27. >
  28. <el-form-item :label="$t('EtaBasePage.origin_edb')" prop="oldEdb">
  29. <el-select
  30. v-model="formData.oldEdb"
  31. v-loadMore="searchLoad"
  32. :filterable="!formData.oldEdb"
  33. remote
  34. clearable
  35. :placeholder="$t('EtaBasePage.search_placeholder')"
  36. style="width: 440px"
  37. :remote-method="searchHandle"
  38. @click.native="inputFocusHandle"
  39. @blur="search_have_more = false"
  40. >
  41. <i slot="prefix" class="el-input__icon el-icon-search"></i>
  42. <el-option
  43. v-for="item in searchOptions"
  44. :key="item.EdbInfoId"
  45. :label="$parent.currentLang==='en'?(item.EdbNameEn||item.EdbName):item.EdbName"
  46. :value="item.EdbInfoId"
  47. >
  48. <edbDetailPopover :info="item">
  49. <div slot="reference">{{$parent.currentLang==='en'?(item.EdbNameEn||item.EdbName):item.EdbName}}</div>
  50. </edbDetailPopover>
  51. </el-option>
  52. </el-select>
  53. </el-form-item>
  54. <el-form-item :label="$t('EtaBasePage.replace')" prop="newEdb">
  55. <el-select
  56. v-model="formData.newEdb"
  57. v-loadMore="searchLoad"
  58. :filterable="!formData.newEdb"
  59. remote
  60. clearable
  61. :placeholder="$t('EtaBasePage.search_placeholder')"
  62. style="width: 440px"
  63. :remote-method="searchHandle"
  64. @click.native="inputFocusHandle"
  65. @blur="search_have_more = false"
  66. >
  67. <i slot="prefix" class="el-input__icon el-icon-search"/>
  68. <el-option
  69. v-for="item in searchOptions"
  70. :key="item.EdbInfoId"
  71. :label="$parent.currentLang==='en'?(item.EdbNameEn||item.EdbName):item.EdbName"
  72. :value="item.EdbInfoId"
  73. >
  74. <edbDetailPopover :info="item">
  75. <div slot="reference">{{$parent.currentLang==='en'?(item.EdbNameEn||item.EdbName):item.EdbName}}</div>
  76. </edbDetailPopover>
  77. </el-option>
  78. </el-select>
  79. </el-form-item>
  80. </el-form>
  81. <div class="dia-bot">
  82. <el-button
  83. type="primary"
  84. style="margin-right: 20px"
  85. @click="saveHandle"
  86. ><!-- 全部替换 -->{{$t('EtaBasePage.replace_all')}}</el-button
  87. >
  88. <el-button type="primary" plain @click="cancelHandle"><!-- 取消 -->{{$t('Dialog.cancel_btn')}}</el-button>
  89. </div>
  90. <p class="tip">{{$t('EtaBasePage.replace_tip')}}</p>
  91. </el-dialog>
  92. </template>
  93. <script>
  94. import { dataBaseInterface } from '@/api/api.js';
  95. export default {
  96. props: {
  97. isShow: {
  98. type: Boolean,
  99. },
  100. },
  101. data() {
  102. return {
  103. formData: {
  104. oldEdb:'',
  105. newEdb: ''
  106. },
  107. formRules: {
  108. oldEdb:[
  109. { required: true, message: this.$t('EtaBasePage.input_origin_vaild'), trigger: 'blur' },
  110. ],
  111. newEdb:[
  112. { required: true, message: this.$t('EtaBasePage.input_replace_vaild'), trigger: 'blur' },
  113. ],
  114. },
  115. allOptions: [],
  116. searchOptions:[],//搜索到的筛选列表
  117. searchOptions2:[],//搜索到的筛选列表
  118. search_page: 1,
  119. search_have_more: false,
  120. current_search:'',
  121. };
  122. },
  123. methods: {
  124. cancelHandle() {
  125. this.$refs.diaForm.resetFields();
  126. this.searchOptions = [];
  127. this.$emit('cancel');
  128. },
  129. /* 搜索 */
  130. searchHandle(query) {
  131. this.search_page = 1;
  132. this.current_search = query;
  133. this.searchApi(this.current_search);
  134. },
  135. /* 聚焦获取当前检索 */
  136. inputFocusHandle(e) {
  137. this.search_page = 1;
  138. this.current_search = e.target.value;
  139. this.searchApi(this.current_search);
  140. },
  141. searchApi(query,page=1) {
  142. dataBaseInterface.targetSearchByPage({
  143. KeyWord:query,
  144. CurrentIndex: page
  145. }).then(res => {
  146. if(res.Ret !== 200) return
  147. const { List,Paging } = res.Data;
  148. this.search_have_more = page < Paging.Pages;
  149. this.searchOptions = page === 1 ? List : this.searchOptions.concat(List);
  150. })
  151. },
  152. searchLoad() {
  153. if(!this.search_have_more) return;
  154. this.searchApi(this.current_search,++this.search_page)
  155. },
  156. saveHandle() {
  157. this.$refs.diaForm.validate((valid) => {
  158. if (valid) {
  159. this.$confirm(this.$t('EtaBasePage.replace_success_msg'), '提示', {
  160. confirmButtonText: '是',
  161. cancelButtonText: '否',
  162. type: 'warning'
  163. }).then(() => {
  164. dataBaseInterface.edbReplace({
  165. NewEdbInfoId: this.formData.newEdb,
  166. OldEdbInfoId: this.formData.oldEdb,
  167. })
  168. this.cancelHandle();
  169. })
  170. }
  171. });
  172. },
  173. },
  174. created() {},
  175. mounted() {},
  176. };
  177. </script>
  178. <style lang="scss">
  179. .replace-dialog {
  180. .el-form-item__content {
  181. margin-left: 0;
  182. }
  183. .el-input {
  184. width: 80%;
  185. }
  186. .dia-bot {
  187. margin: 52px 0 50px;
  188. display: flex;
  189. justify-content: center;
  190. }
  191. .tip {
  192. margin-bottom: 30px;
  193. }
  194. }
  195. </style>