addTargetDiaBase.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <div class="addTargtDia-box" v-if="isAddTarget">
  3. <el-dialog :visible.sync="isAddTarget" :close-on-click-modal="false" :modal-append-to-body='false'
  4. @close="cancelHandle" custom-class="dialog" top="11vh" center width="1200px" v-dialogDrag>
  5. <div slot="title" style="display:flex;alignItems:center;">
  6. <img :src="$icons.add" style="color:#fff;width:16px;height:16px;marginRight:5px;">
  7. <span style="fontSize:16px;">添加指标</span>
  8. </div>
  9. <div class="dialog-top">
  10. <div>
  11. <span>数据来源</span>
  12. <el-select v-model="fromType" placeholder="请选择来源" style="width:240px;margin-left:10px" @change="changeTrade"
  13. :disabled="haveResult">
  14. <el-option v-for="item in fromArr" :key="item" :label="item" :value="item">
  15. </el-option>
  16. </el-select>
  17. </div>
  18. <el-input v-show="isCompanyCode" placeholder="公司ID" v-model="search_company_txt" style="maxWidth:340px;"
  19. @keyup.enter.native="searchHandle" :disabled="haveResult" clearable>
  20. <i slot="prefix" class="el-input__icon el-icon-search"></i>
  21. </el-input>
  22. <el-input placeholder="指标ID" v-model="search_txt" style="maxWidth:340px"
  23. @keyup.enter.native="searchHandle" :disabled="haveResult" clearable>
  24. <i slot="prefix" class="el-input__icon el-icon-search"></i>
  25. </el-input>
  26. </div>
  27. <div class="warn_txt" v-if="status === 1">
  28. 该数据已存在数据库,名称为:{{have_edbobj.edb_name}},目录为:{{ have_edbobj.warnTip }},如需重新添加,请删除原指标
  29. </div>
  30. <div class="warn_txt" v-else-if="status === 3">
  31. 该数据已存在数据库,名称为:{{have_edbobj.edb_name}},目录为:{{ have_edbobj.warnTip }}
  32. </div>
  33. <div class="no-auth" v-if="status === 3">
  34. 您当前暂无权限查看该指标,如需查看,请联系管理员
  35. </div>
  36. <div class="dialog-main" v-else>
  37. <el-table ref="Table" :data="tableData" highlight-current-row border
  38. :style="(status === 1 || !tableData.length) ? 'height:350px' : ''">
  39. <el-table-column v-for="item in tableColums" :key="item.label" :label="item.label" align="center">
  40. <template slot-scope="scope">
  41. <span v-if="item.key == 'StartDate' || item.key == 'EndDate'">{{ scope.row[item.key] |
  42. formatTime
  43. }}</span>
  44. <span v-else>{{ scope.row[item.key] }}</span>
  45. </template>
  46. </el-table-column>
  47. <div slot="empty" style="padding:40px 0 120px;">
  48. <tableNoData text="未搜索到该指标" size="mini"/>
  49. </div>
  50. </el-table>
  51. <ul class="value-ul" v-show="dataList.length && status === 2">
  52. <li class="value-item" v-for="(item, index) in dataList" :key="index">
  53. <span>{{ item.DataTime }}</span>
  54. <span style="min-width:200px;text-align:center;">{{ item.Value }}</span>
  55. </li>
  56. </ul>
  57. </div>
  58. <div class="dia-bot">
  59. <el-button type="primary" v-if="status === 2" @click="addTargtHandler" :disabled="!tableData.length">下一步
  60. </el-button>
  61. <el-button type="primary" v-else-if="[1,3].includes(status)" @click="cancelHandle">知道了</el-button>
  62. </div>
  63. </el-dialog>
  64. </div>
  65. </template>
  66. <script>
  67. import { dataBaseInterface } from '@/api/api.js'
  68. import { fromArr, fromCode } from './util';
  69. export default {
  70. name: '',
  71. props: {
  72. isAddTarget: {
  73. type: Boolean
  74. }
  75. },
  76. data() {
  77. return {
  78. search_txt: '',//搜素关键词 M001625518 M0001427
  79. fromType: 'wind',
  80. fromArr,
  81. fromCode,
  82. tableColums: [
  83. {
  84. label: '指标ID',
  85. key: 'EdbCode'
  86. },
  87. {
  88. label: '起始时间',
  89. key: 'StartDate'
  90. },
  91. {
  92. label: '终止时间',
  93. key: 'EndDate'
  94. },
  95. ],
  96. status: '',//指标状态
  97. tableData: [],
  98. dataList: [],
  99. add_params: {},
  100. haveResult: false,
  101. have_edbobj: {
  102. warnTip: '',//已存在提示文案
  103. edb_name: '',
  104. },
  105. isCompanyCode: false,
  106. search_company_txt: ''
  107. };
  108. },
  109. methods: {
  110. init() {
  111. this.fromType = 'wind'
  112. this.status = ''
  113. this.tableData = []
  114. this.dataList = []
  115. this.add_params = {}
  116. this.search_txt = '';
  117. this.haveResult = false;
  118. this.search_company_txt = '';
  119. this.isCompanyCode = false;
  120. },
  121. cancelHandle() {
  122. this.init();
  123. this.$emit('cancelHandle')
  124. },
  125. /* 搜索指标 */
  126. searchHandle: _.debounce(function () {
  127. console.info(this.fromType);
  128. console.info(this.search_company_txt);
  129. console.info(this.search_txt);
  130. if (this.fromType == "彭博财务") {
  131. if (!this.search_company_txt) {
  132. this.$message.warning('请输入公司ID')
  133. return
  134. }
  135. if (!this.search_txt) {
  136. this.$message.warning('请输入指标ID')
  137. return
  138. }
  139. } else {
  140. if (!this.search_txt) {
  141. this.$message.warning('请输入指标ID')
  142. return
  143. }
  144. }
  145. if (this.search_txt) {
  146. this.status = '';
  147. this.haveResult = true;
  148. this.loading = this.$loading({
  149. lock: true,
  150. target: '.dialog-main',
  151. text: '搜索数据中...',
  152. spinner: 'el-icon-loading',
  153. background: 'rgba(255, 255, 255, 0.8)'
  154. });
  155. dataBaseInterface.getTarget({
  156. Source: Number(this.fromCode.get(this.fromType)),
  157. EdbCode: this.search_txt,
  158. CompanyCode: this.search_company_txt
  159. }).then(res => {
  160. if (res.Ret === 200) {
  161. this.haveResult = false;
  162. //隆众指标和手工指标、交易所等将名称 频度 单位带到下一步
  163. let opther_params = ['9', '10', '11', '15', '16', '17', '18', '19', '20', '21', '26','38','41','57','60','71'].includes(this.fromCode.get(this.fromType)) ? {
  164. edb_name: res.Data.SearchItem.EdbName,
  165. unit: res.Data.SearchItem.Unit,
  166. frequency: res.Data.SearchItem.Frequency,
  167. } : {}
  168. this.add_params = {
  169. EdbCode: res.Data.SearchItem.EdbCode,
  170. EndDate: res.Data.SearchItem.EndDate,
  171. StartDate: res.Data.SearchItem.StartDate,
  172. Source: Number(this.fromCode.get(this.fromType)),
  173. ...opther_params
  174. }
  175. this.status = res.Data.Status;
  176. let classify_arr = res.Data.ClassifyList || [];
  177. let str = '';
  178. classify_arr.length && classify_arr.reverse().map((item) => str += item.ClassifyName + '/');
  179. //提示文案
  180. this.have_edbobj = {
  181. warnTip: [1,3].includes(res.Data.Status) ? str : '',//已存在提示文案
  182. edb_name: [1,3].includes(res.Data.Status) ? res.Data.SearchItem.EdbName : '',
  183. },
  184. this.tableData =
  185. res.Data.Status === 1 ? [res.Data.SearchItem]
  186. : res.Data.Status !== 1 && res.Data.SearchItem.DataList && res.Data.SearchItem.DataList.length
  187. ? [res.Data.SearchItem]
  188. : [];
  189. this.dataList = res.Data.SearchItem.DataList || [];
  190. this.$nextTick(() => {
  191. this.loading.close();
  192. this.tableData.length && this.$refs.Table.setCurrentRow(this.tableData[0]);
  193. })
  194. } else {
  195. this.haveResult = false;
  196. this.loading.close();
  197. this.status = '';
  198. this.tableData = [];
  199. this.dataList = [];
  200. }
  201. })
  202. } else {
  203. this.$message.warning('请输入指标ID')
  204. }
  205. }),
  206. addTargtHandler() {
  207. console.log(this.add_params);
  208. this.$parent.completeTargetHandle(this.add_params);
  209. },
  210. changeTrade(e) {
  211. if (e == "彭博财务") {
  212. this.isCompanyCode = true;
  213. } else {
  214. this.isCompanyCode = false;
  215. }
  216. this.search_txt = '';
  217. this.search_company_txt = '';
  218. this.loading && this.loading.close();
  219. },
  220. getTargetSource(){
  221. this.fromArr = []
  222. dataBaseInterface.getDataSource({IsBase:1}).then(res=>{
  223. if(res.Ret!==200) return
  224. if(res.Data){
  225. this.fromArr = res.Data.map(i=>{
  226. return i.SourceName
  227. })
  228. }
  229. })
  230. }
  231. },
  232. created() { },
  233. mounted() {
  234. this.getTargetSource()
  235. },
  236. }
  237. </script>
  238. <style lang='scss' scoped>
  239. .addTargtDia-box {
  240. .dialog-top {
  241. padding: 20px 30px;
  242. display: flex;
  243. justify-content: space-between;
  244. border: 1px solid #ECECEC;
  245. box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.05);
  246. }
  247. .warn_txt {
  248. font-size: 16px;
  249. color: #FF4E00;
  250. margin: 30px 0;
  251. text-align: center;
  252. }
  253. .dialog-main {
  254. margin-top: 20px;
  255. .value-ul {
  256. border: 1px solid #ECECEC;
  257. max-height: 320px;
  258. overflow-y: scroll;
  259. .value-item {
  260. color: #666;
  261. padding: 12px 0;
  262. display: flex;
  263. justify-content: space-around;
  264. }
  265. }
  266. }
  267. .dia-bot {
  268. margin: 60px 0;
  269. display: flex;
  270. justify-content: center;
  271. }
  272. .no-auth {
  273. width: 50%;
  274. padding: 40px;
  275. margin: 70px auto;
  276. text-align: center;
  277. background: #ECECEC;
  278. color: #FF4E00;
  279. border: 1px dashed #FF4E00;
  280. }
  281. }
  282. </style>