replaceDialog.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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('Edb.InputHolderAll.input_name_orid')"
  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. :disabled="!item.HaveOperaAuth"
  48. >
  49. <edbDetailPopover :info="item">
  50. <div slot="reference">
  51. <img
  52. :src="$icons.lock_ico2"
  53. width="18"
  54. height="18"
  55. style="vertical-align:middle"
  56. v-if="!item.HaveOperaAuth"
  57. />
  58. {{$parent.currentLang==='en'?(item.EdbNameEn||item.EdbName):item.EdbName}}
  59. </div>
  60. </edbDetailPopover>
  61. </el-option>
  62. </el-select>
  63. </el-form-item>
  64. <el-form-item :label="$t('EtaBasePage.replace')" prop="newEdb">
  65. <el-select
  66. v-model="formData.newEdb"
  67. v-loadMore="searchLoad"
  68. :filterable="!formData.newEdb"
  69. remote
  70. clearable
  71. :placeholder="$t('Edb.InputHolderAll.input_name_orid')"
  72. style="width: 440px"
  73. :remote-method="searchHandle"
  74. @click.native="inputFocusHandle"
  75. @blur="search_have_more = false"
  76. >
  77. <i slot="prefix" class="el-input__icon el-icon-search"/>
  78. <el-option
  79. v-for="item in searchOptions"
  80. :key="item.EdbInfoId"
  81. :label="$parent.currentLang==='en'?(item.EdbNameEn||item.EdbName):item.EdbName"
  82. :value="item.EdbInfoId"
  83. >
  84. <edbDetailPopover :info="item">
  85. <div slot="reference">{{$parent.currentLang==='en'?(item.EdbNameEn||item.EdbName):item.EdbName}}</div>
  86. </edbDetailPopover>
  87. </el-option>
  88. </el-select>
  89. </el-form-item>
  90. </el-form>
  91. <div class="dia-bot">
  92. <el-button
  93. type="primary"
  94. style="margin-right: 20px"
  95. @click="saveHandle"
  96. ><!-- 全部替换 -->{{$t('EtaBasePage.replace_all')}}</el-button
  97. >
  98. <el-button type="primary" plain @click="cancelHandle"><!-- 取消 -->{{$t('Dialog.cancel_btn')}}</el-button>
  99. </div>
  100. <p class="tip">{{$t('EtaBasePage.replace_tip')}}</p>
  101. </el-dialog>
  102. </template>
  103. <script>
  104. import { dataBaseInterface } from '@/api/api.js';
  105. export default {
  106. props: {
  107. isShow: {
  108. type: Boolean,
  109. },
  110. },
  111. data() {
  112. return {
  113. formData: {
  114. oldEdb:'',
  115. newEdb: ''
  116. },
  117. formRules: {
  118. oldEdb:[
  119. { required: true, message: this.$t('EtaBasePage.input_origin_vaild'), trigger: 'blur' },
  120. ],
  121. newEdb:[
  122. { required: true, message: this.$t('EtaBasePage.input_replace_vaild'), trigger: 'blur' },
  123. ],
  124. },
  125. allOptions: [],
  126. searchOptions:[],//搜索到的筛选列表
  127. searchOptions2:[],//搜索到的筛选列表
  128. search_page: 1,
  129. search_have_more: false,
  130. current_search:'',
  131. };
  132. },
  133. methods: {
  134. cancelHandle() {
  135. this.$refs.diaForm.resetFields();
  136. this.searchOptions = [];
  137. this.$emit('cancel');
  138. },
  139. /* 搜索 */
  140. searchHandle(query) {
  141. this.search_page = 1;
  142. this.current_search = query;
  143. this.searchApi(this.current_search);
  144. },
  145. /* 聚焦获取当前检索 */
  146. inputFocusHandle(e) {
  147. this.search_page = 1;
  148. this.current_search = e.target.value;
  149. this.searchApi(this.current_search);
  150. },
  151. searchApi(query,page=1) {
  152. dataBaseInterface.targetSearchByPage({
  153. KeyWord:query,
  154. CurrentIndex: page
  155. }).then(res => {
  156. if(res.Ret !== 200) return
  157. const { List,Paging } = res.Data;
  158. this.search_have_more = page < Paging.Pages;
  159. this.searchOptions = page === 1 ? List : this.searchOptions.concat(List);
  160. })
  161. },
  162. searchLoad() {
  163. if(!this.search_have_more) return;
  164. this.searchApi(this.current_search,++this.search_page)
  165. },
  166. saveHandle() {
  167. this.$refs.diaForm.validate((valid) => {
  168. if (valid) {
  169. this.$confirm(this.$t('EtaBasePage.replace_success_msg'), '提示', {
  170. confirmButtonText: '是',
  171. cancelButtonText: '否',
  172. type: 'warning'
  173. }).then(() => {
  174. dataBaseInterface.edbReplace({
  175. NewEdbInfoId: this.formData.newEdb,
  176. OldEdbInfoId: this.formData.oldEdb,
  177. })
  178. this.cancelHandle();
  179. })
  180. }
  181. });
  182. },
  183. },
  184. created() {},
  185. mounted() {},
  186. };
  187. </script>
  188. <style lang="scss">
  189. .replace-dialog {
  190. .el-form-item__content {
  191. margin-left: 0;
  192. }
  193. .el-input {
  194. width: 80%;
  195. }
  196. .dia-bot {
  197. margin: 52px 0 50px;
  198. display: flex;
  199. justify-content: center;
  200. }
  201. .tip {
  202. margin-bottom: 30px;
  203. }
  204. }
  205. </style>