batchAddToEdbDialog.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <!-- 添加到指标库弹窗 -->
  3. <el-dialog
  4. :title="$t('Edb.Detail.batch_add_edb')"
  5. :visible.sync="isShow"
  6. :close-on-click-modal="false"
  7. :modal-append-to-body="false"
  8. @close="cancelHandle"
  9. width="1000px"
  10. top="5vh"
  11. v-dialogDrag
  12. center
  13. >
  14. <div class="add-dialog-wrap">
  15. <el-table :data="tableData" border height="500px">
  16. <el-table-column
  17. :label="$t('Edb.Detail.e_id')"
  18. align="center"
  19. prop="IndexCode"
  20. />
  21. <el-table-column
  22. :label="$t('Edb.Detail.e_name')"
  23. align="center"
  24. width="210px"
  25. >
  26. <template slot-scope="scope">
  27. <div class="name-cell">
  28. <el-input
  29. v-model="scope.row.IndexName"
  30. :placeholder="$t('Edb.InputHolderAll.input_name')"
  31. style="width: 100%; margin: 5px 0"
  32. :class="
  33. existNameArr.includes(scope.row.IndexName) && 'error-ipt'
  34. "
  35. />
  36. <div
  37. class="error"
  38. v-if="existNameArr.includes(scope.row.IndexName)"
  39. >
  40. <span>{{ $t("BloombergPage.add_edb_check_hint2") }}</span>
  41. </div>
  42. </div>
  43. </template>
  44. </el-table-column>
  45. <el-table-column
  46. :label="$t('Edb.Detail.e_unit')"
  47. align="center"
  48. width="150px"
  49. >
  50. <template slot-scope="scope">
  51. <selectUnit v-model="scope.row.Unit" />
  52. </template>
  53. </el-table-column>
  54. <el-table-column
  55. :label="$t('Edb.Detail.e_fre')"
  56. align="center"
  57. width="120px"
  58. >
  59. <template slot-scope="scope">
  60. <el-select
  61. v-model="scope.row.Frequency"
  62. :placeholder="$t('EtaBasePage.select_frequency')"
  63. >
  64. <el-option
  65. v-for="item in $parent.frequencyList"
  66. :key="item.val"
  67. :label="item.label"
  68. :value="item.val"
  69. >
  70. </el-option>
  71. </el-select>
  72. </template>
  73. </el-table-column>
  74. <el-table-column align="center" width="320px">
  75. <template
  76. slot="header"
  77. slot-scope="scope"
  78. style="
  79. display: flex;
  80. align-items: center;
  81. justify-content: space-between;
  82. "
  83. >
  84. <el-radio-group
  85. v-model="classifyType"
  86. @change="handleClassifyTypeChange"
  87. style="flex: 1; margin-right: 20px"
  88. >
  89. <el-radio :label="0" style="margin-right: 20px"
  90. ><!-- 分目录 -->{{
  91. $t("EtaBasePage.subdirectory_radio")
  92. }}</el-radio
  93. >
  94. <el-radio :label="1"
  95. ><!-- 同目录 -->{{
  96. $t("EtaBasePage.directory_radio")
  97. }}</el-radio
  98. >
  99. </el-radio-group>
  100. <el-cascader
  101. v-if="classifyType == 1"
  102. v-model="commonClassifyId"
  103. :options="classifyOpt"
  104. :props="levelProps"
  105. :placeholder="$t('Edb.InputHolderAll.input_menu')"
  106. :disabled="classifyType == 0"
  107. @change="handleClassifyChange()"
  108. style="width: 120px"
  109. />
  110. </template>
  111. <template slot-scope="{ row, $index }">
  112. <el-cascader
  113. v-model="row.ClassifyId"
  114. :options="classifyOpt"
  115. :props="levelProps"
  116. :placeholder="$t('Edb.InputHolderAll.input_menu')"
  117. :disabled="classifyType == 1"
  118. class="cascader-wrapper"
  119. />
  120. </template>
  121. </el-table-column>
  122. </el-table>
  123. </div>
  124. <div style="text-align: center; margin: 30px 0">
  125. <el-button @click="cancelHandle">{{ $t("Dialog.cancel_btn") }}</el-button>
  126. <el-button type="primary" @click="handleCheckName" :loading="saveLoading">
  127. {{ $t("ManualEdbListPage.add_tobase_btn") }}
  128. </el-button>
  129. </div>
  130. </el-dialog>
  131. </template>
  132. <script>
  133. import { dataBaseInterface } from "@/api/api.js";
  134. export default {
  135. props: {
  136. isShow: {
  137. type: Boolean,
  138. },
  139. list: {
  140. type: Array,
  141. default: () => [],
  142. },
  143. },
  144. data() {
  145. return {
  146. tableData: [],
  147. saveLoading: false,
  148. classifyType: 0,
  149. classifyOpt: [],
  150. commonClassifyId: 0,
  151. levelProps: {
  152. label: "ClassifyName",
  153. value: "ClassifyId",
  154. children: "Children",
  155. checkStrictly: true,
  156. emitPath: false,
  157. },
  158. existNameArr: [],
  159. };
  160. },
  161. watch: {
  162. isShow(nval) {
  163. if (!nval) return;
  164. this.initDialog();
  165. this.getClassifyOpt();
  166. this.tableData = this.list.map((_) => ({
  167. ..._,
  168. ClassifyId: 0,
  169. }));
  170. },
  171. },
  172. methods: {
  173. initDialog() {
  174. this.classifyType = 0;
  175. this.commonClassifyId = 0;
  176. this.existNameArr = [];
  177. },
  178. filterNodes(arr) {
  179. arr.length &&
  180. arr.forEach((item) => {
  181. item.Children.length && this.filterNodes(item.Children);
  182. if (!item.Children.length) {
  183. delete item.Children;
  184. }
  185. });
  186. },
  187. // 获取指标分类
  188. async getClassifyOpt() {
  189. const res = await dataBaseInterface.menuListV3();
  190. if (res.Ret !== 200) return;
  191. this.filterNodes(res.Data.AllNodes || []);
  192. this.classifyOpt = res.Data.AllNodes || [];
  193. },
  194. cancelHandle() {
  195. this.existNameArr = [];
  196. this.$emit("update:isShow", false);
  197. },
  198. // 同目录修改
  199. handleClassifyChange() {
  200. if (this.classifyType === 1) {
  201. this.tableData.forEach((item) => {
  202. item.ClassifyId = this.commonClassifyId;
  203. });
  204. }
  205. },
  206. handleClassifyTypeChange() {
  207. if (this.classifyType == 0) {
  208. this.commonClassifyId = 0;
  209. }
  210. },
  211. handleCheckName() {
  212. //重名校验
  213. this.existNameArr = [];
  214. this.$emit("handleCheckName", this.tableData);
  215. },
  216. setValue(key, value) {
  217. //用来处理抛出事件的existNameArr 与 saveLoading
  218. this[key] = value;
  219. },
  220. },
  221. };
  222. </script>
  223. <style lang="scss" scoped>
  224. .add-dialog-wrap {
  225. .name-cell {
  226. position: relative;
  227. .error {
  228. position: absolute;
  229. bottom: -16px;
  230. color: #f00;
  231. }
  232. }
  233. }
  234. </style>
  235. <style lang="scss">
  236. .add-dialog-wrap {
  237. .error-ipt .el-input__inner {
  238. border-color: #f00;
  239. }
  240. .el-cascader .el-input {
  241. width: 100%;
  242. }
  243. .el-table .cell {
  244. overflow: visible;
  245. }
  246. }
  247. </style>