addTargetDiaBase.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759
  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="custom-dialog fit-screen-dialog" top="5vh" center width="85vw" 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. <template v-if="wsdAddStep==1">
  10. <div class="dialog-top">
  11. <div>
  12. <span>数据来源</span>
  13. <el-select v-model="fromType" placeholder="请选择来源" style="width:240px;margin-left:10px" @change="changeTrade"
  14. :disabled="haveResult">
  15. <el-option v-for="item in fromArr" :key="item" :label="item" :value="item">
  16. </el-option>
  17. </el-select>
  18. <el-select v-model="fromDatabase" placeholder="请选择数据库" style="width:240px;margin-left:10px" @change="changeDatabase"
  19. :disabled="haveResult" v-if="fromType=='wind'">
  20. <el-option v-for="item in databaseType" :key="item.value" :label="item.label" :value="item.value">
  21. </el-option>
  22. </el-select>
  23. </div>
  24. <el-input v-show="isCompanyCode" placeholder="公司ID" v-model="search_company_txt" style="maxWidth:340px;"
  25. @keyup.enter.native="searchHandle" :disabled="haveResult" clearable>
  26. <i slot="prefix" class="el-input__icon el-icon-search"></i>
  27. </el-input>
  28. <el-input placeholder="指标ID" v-model="search_txt" style="maxWidth:300px" v-if="!(this.fromType=='wind' && this.fromDatabase=='1')"
  29. @keyup.enter.native="searchHandle" :disabled="haveResult" clearable>
  30. <i slot="prefix" class="el-input__icon el-icon-search"></i>
  31. </el-input>
  32. </div>
  33. <template v-if="this.fromType=='wind' && this.fromDatabase=='1'">
  34. <div class="wsd-index-box">
  35. <el-input placeholder="请输入证券代码" v-model.trim="securityCodeText" class="wsd-index-input" @blur="codeInputBlur('security')"></el-input>
  36. <div class="wsd-code-row">
  37. <div class="wsd-code-item" v-for="item in securityCode" :key="item">
  38. <div class="wsd-code-item-text">{{ item }}</div>
  39. <img src="~@/assets/img/icons/close_icon_black.png" @click="deleteCode('security',item)" />
  40. </div>
  41. </div>
  42. <div class="wsd-index-code">
  43. <el-input placeholder="请输入指标代码" v-model.trim="indexCodeText" class="wsd-index-input" @blur="codeInputBlur('index')"></el-input>
  44. <div class="index-code-hint">Wind金融终端输入“CG”会弹出代码生成器,可在代码生成器上获取其他指标的代码</div>
  45. </div>
  46. <el-checkbox-group v-model="indexCodeSelected">
  47. <el-checkbox :label="item.value" v-for="item in indexCodeArr" :key="item.value">{{ item.label }}</el-checkbox>
  48. </el-checkbox-group>
  49. <div class="wsd-code-row" style="margin-top: -10px;">
  50. <div class="wsd-code-item" v-for="item in indexCode" :key="item">
  51. <div class="wsd-code-item-text">{{ item }}</div>
  52. <img src="~@/assets/img/icons/close_icon_black.png" @click="deleteCode('index',item)" />
  53. </div>
  54. </div>
  55. </div>
  56. <div class="dia-bot">
  57. <el-button type="primary" @click="wsdNextHandle" :disabled="!isCodeComplete" style="width: 120px;">下一步
  58. </el-button>
  59. </div>
  60. </template>
  61. <template v-else>
  62. <div class="warn_txt" v-if="status === 1">
  63. 该数据已存在数据库,名称为:{{have_edbobj.edb_name}},目录为:{{ have_edbobj.warnTip }},如需重新添加,请删除原指标
  64. </div>
  65. <div class="warn_txt" v-else-if="status === 3">
  66. 该数据已存在数据库,名称为:{{have_edbobj.edb_name}},目录为:{{ have_edbobj.warnTip }}
  67. </div>
  68. <div class="no-auth" v-if="status === 3">
  69. 您当前暂无权限查看该指标,如需查看,请联系管理员
  70. </div>
  71. <div class="dialog-main" v-else>
  72. <el-table ref="Table" :data="tableData" highlight-current-row border
  73. :style="(status === 1 || !tableData.length) ? 'height:350px' : ''">
  74. <el-table-column v-for="item in tableColums" :key="item.label" :label="item.label" align="center">
  75. <template slot-scope="scope">
  76. <span v-if="item.key == 'StartDate' || item.key == 'EndDate'">{{ scope.row[item.key] |
  77. formatTime
  78. }}</span>
  79. <span v-else>{{ scope.row[item.key] }}</span>
  80. </template>
  81. </el-table-column>
  82. <div slot="empty" style="padding:40px 0 120px;">
  83. <tableNoData text="未搜索到该指标" size="mini"/>
  84. </div>
  85. </el-table>
  86. <ul class="value-ul" v-show="dataList.length && status === 2">
  87. <li class="value-item" v-for="(item, index) in dataList" :key="index">
  88. <span>{{ item.DataTime }}</span>
  89. <span style="min-width:200px;text-align:center;">{{ item.Value }}</span>
  90. </li>
  91. </ul>
  92. </div>
  93. <div class="dia-bot">
  94. <el-button type="primary" v-if="status === 2" @click="addTargtHandler" :disabled="!tableData.length">下一步
  95. </el-button>
  96. <el-button type="primary" v-else-if="[1,3].includes(status)" @click="cancelHandle">知道了</el-button>
  97. </div>
  98. </template>
  99. </template>
  100. <template v-else>
  101. <div class="edb-table-preview">
  102. <table width="auto" border="0">
  103. <thead>
  104. <tr v-for="(item, index) in edbTableHeadKey" :key="item">
  105. <td class="sticky" style="left: 0;text-align: center;">
  106. {{ edbTableHeadData.get(item) }}
  107. </td>
  108. <td v-for="(data, sub_index) in edbIndexDatas" :key="sub_index" :colspan="2">
  109. <template v-if="item === 'Catalogue'">
  110. <el-cascader :options="options" v-model="data[item]" placeholder="请选择所属目录"
  111. size="mini" :props="{label: 'ClassifyName',
  112. value: 'ClassifyId',
  113. children: 'Children',
  114. checkStrictly: true}">
  115. </el-cascader>
  116. </template>
  117. <template v-else-if="item === 'Unit'">
  118. <el-autocomplete
  119. v-model.trim="data[item]"
  120. :fetch-suggestions="querySearchUnit"
  121. placeholder="请输入单位"
  122. suffix-icon="el-icon-arrow-down"
  123. size="mini"
  124. ></el-autocomplete>
  125. </template>
  126. <template v-else-if="item === 'Frequency'">
  127. <el-select v-model="data[item]" placeholder="请选择频度" size="mini">
  128. <el-option :label="item" :value="item"
  129. v-for="item in frequencyArr" :key="item"></el-option>
  130. </el-select>
  131. </template>
  132. <template v-else-if="item === 'SecName'">
  133. <el-input v-model.trim="data[item]" placeholder="请输入指标名称" size="mini"></el-input>
  134. </template>
  135. <template v-else>
  136. <div style="padding: 0 7px;">{{ data[item] }}</div>
  137. </template>
  138. </td>
  139. </tr>
  140. </thead>
  141. <tbody>
  142. <tr v-for="(item,index) in edbIndexDatas[0].DataList.length" :key="index">
  143. <td :rowspan="edbIndexDatas[0].DataList.length" v-if="index==0"
  144. class="sticky" style="left: 0;text-align: center;">
  145. 数据详情
  146. </td>
  147. <template v-for="(item1,index1) in edbIndexDatas.length">
  148. <td>{{ edbIndexDatas[index1].DataList[index].Dt }}</td>
  149. <td>{{ edbIndexDatas[index1].DataList[index].Close }}</td>
  150. </template>
  151. </tr>
  152. </tbody>
  153. </table>
  154. </div>
  155. <div class="dia-bot">
  156. <el-button @click="wsdPrevHandle" style="width: 120px;">上一步</el-button>
  157. <el-button type="primary" @click="wsdSaveHandle" style="width: 120px;margin-left: 50px;">保存</el-button>
  158. </div>
  159. </template>
  160. </el-dialog>
  161. <el-dialog :visible.sync="checkFailShow" :close-on-click-modal="false" :modal-append-to-body='false'
  162. width="600px" title="操作提示">
  163. <div class="check-fail-box">
  164. <div>
  165. <div style="margin-bottom: 20px;">指标库中已存在以下指标,请勿重新输入!</div>
  166. <div v-for="(item,index) in existIndexList">
  167. {{ index+1+'、'+item }}
  168. </div>
  169. </div>
  170. <div class="check-fail-button">
  171. <el-button type="primary" @click="checkFailShow=false" style="width: 120px;">知道了</el-button>
  172. </div>
  173. </div>
  174. </el-dialog>
  175. </div>
  176. </template>
  177. <script>
  178. import { dataBaseInterface,dataInterence } from '@/api/api.js'
  179. import { fromArr, fromCode ,frequencyArr} from './util';
  180. export default {
  181. name: '',
  182. props: {
  183. isAddTarget: {
  184. type: Boolean
  185. }
  186. },
  187. computed:{
  188. isCodeComplete(){
  189. return this.securityCode.length>0 && (this.indexCode.length>0 || this.indexCodeSelected.length>0)
  190. }
  191. },
  192. data() {
  193. return {
  194. search_txt: '',//搜素关键词 M001625518 M0001427
  195. fromType: 'wind',
  196. fromDatabase:'1',
  197. fromArr,
  198. indexCodeSelected:[],
  199. indexCodeArr:[
  200. {value:1,label:"前收盘价"},
  201. {value:'open',label:"开盘价"},
  202. {value:3,label:"最高价"},
  203. {value:4,label:"最低价"},
  204. {value:'close',label:"收盘价"},
  205. {value:6,label:"结算价"},
  206. {value:7,label:"成交量"},
  207. {value:8,label:"成交额"},
  208. {value:9,label:"涨跌幅"},
  209. {value:10,label:"振幅"},
  210. {value:11,label:"换手率"},
  211. {value:12,label:"持仓量"},
  212. {value:13,label:"持仓额"},
  213. ], // 常用的指标代码
  214. databaseType:[
  215. {value:'0',label:'经济数据库'},
  216. {value:'1',label:'日期序列'}
  217. ],
  218. wsdAddStep:1,
  219. fromCode,
  220. tableColums: [
  221. {
  222. label: '指标ID',
  223. key: 'EdbCode'
  224. },
  225. {
  226. label: '起始时间',
  227. key: 'StartDate'
  228. },
  229. {
  230. label: '终止时间',
  231. key: 'EndDate'
  232. },
  233. ],
  234. status: '',//指标状态
  235. tableData: [],
  236. dataList: [],
  237. add_params: {},
  238. haveResult: false,
  239. have_edbobj: {
  240. warnTip: '',//已存在提示文案
  241. edb_name: '',
  242. },
  243. isCompanyCode: false,
  244. search_company_txt: '',
  245. securityCodeText:"",
  246. securityCode:[],
  247. indexCodeText:'',
  248. indexCode:[],
  249. edbIndexDatas:[
  250. {Catalogue:'',Unit:"",Frequency:'日度',SecName:'CU2403收盘价',SecurityCode:'CU2403.SHF',IndexCode:'close',
  251. DataList:[{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},
  252. {Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},
  253. {Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"}]},
  254. {Catalogue:'',Unit:"",Frequency:'日度',SecName:'CU2403收盘价',SecurityCode:'CU2403.SHF',IndexCode:'close',
  255. DataList:[{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},
  256. {Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},
  257. {Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"}]},
  258. {Catalogue:'',Unit:"",Frequency:'日度',SecName:'CU2403收盘价',SecurityCode:'CU2403.SHF',IndexCode:'close',
  259. DataList:[{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},
  260. {Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},
  261. {Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"}]},
  262. {Catalogue:'',Unit:"",Frequency:'日度',SecName:'CU2403收盘价',SecurityCode:'CU2403.SHF',IndexCode:'close',
  263. DataList:[{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},
  264. {Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},
  265. {Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"}]},
  266. {Catalogue:'',Unit:"",Frequency:'日度',SecName:'CU2403收盘价',SecurityCode:'CU2403.SHF',IndexCode:'close',
  267. DataList:[{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},
  268. {Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},
  269. {Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"}]},
  270. {Catalogue:'',Unit:"",Frequency:'日度',SecName:'CU2403收盘价',SecurityCode:'CU2403.SHF',IndexCode:'close',
  271. DataList:[{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},
  272. {Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},
  273. {Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"}]}
  274. ],
  275. edbTableHeadKey: [
  276. "Catalogue",
  277. "Unit",
  278. "Frequency",
  279. "SecName",
  280. "SecurityCode",
  281. "IndexCode",
  282. ],
  283. edbTableHeadData:new Map([
  284. ["Catalogue", "所属目录"],
  285. ["Unit", "单位"],
  286. ["Frequency", "频度"],
  287. ["SecName", "指标名称"],
  288. ["SecurityCode", "证券代码"],
  289. ["IndexCode", "指标代码"],
  290. ]),
  291. options:[],
  292. unitList:[],
  293. frequencyArr,
  294. checkFailShow:false,
  295. existIndexList:[]
  296. };
  297. },
  298. watch:{
  299. isAddTarget(newVal){
  300. if(newVal){
  301. this.getTargetSource()
  302. this.getMenu()
  303. this.getTargetUnitList()
  304. }
  305. }
  306. },
  307. methods: {
  308. init() {
  309. this.fromType = 'wind'
  310. this.fromDatabase='0'
  311. this.wsdAddStep=1
  312. this.status = ''
  313. this.tableData = []
  314. this.dataList = []
  315. this.add_params = {}
  316. this.search_txt = '';
  317. this.haveResult = false;
  318. this.search_company_txt = '';
  319. this.isCompanyCode = false;
  320. },
  321. cancelHandle() {
  322. this.init();
  323. this.$emit('cancelHandle')
  324. },
  325. /* 搜索指标 */
  326. searchHandle: _.debounce(function () {
  327. console.info(this.fromType);
  328. console.info(this.search_company_txt);
  329. console.info(this.search_txt);
  330. if (this.fromType == "彭博财务") {
  331. if (!this.search_company_txt) {
  332. this.$message.warning('请输入公司ID')
  333. return
  334. }
  335. if (!this.search_txt) {
  336. this.$message.warning('请输入指标ID')
  337. return
  338. }
  339. } else {
  340. if (!this.search_txt) {
  341. this.$message.warning('请输入指标ID')
  342. return
  343. }
  344. }
  345. if (this.search_txt) {
  346. this.status = '';
  347. this.haveResult = true;
  348. this.loading = this.$loading({
  349. lock: true,
  350. target: '.dialog-main',
  351. text: '搜索数据中...',
  352. spinner: 'el-icon-loading',
  353. background: 'rgba(255, 255, 255, 0.8)'
  354. });
  355. dataBaseInterface.getTarget({
  356. Source: Number(this.fromCode.get(this.fromType)),
  357. EdbCode: this.search_txt,
  358. CompanyCode: this.search_company_txt
  359. }).then(res => {
  360. if (res.Ret === 200) {
  361. this.haveResult = false;
  362. //隆众指标和手工指标、交易所等将名称 频度 单位带到下一步
  363. 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)) ? {
  364. edb_name: res.Data.SearchItem.EdbName,
  365. unit: res.Data.SearchItem.Unit,
  366. frequency: res.Data.SearchItem.Frequency,
  367. } : {}
  368. let jy_params = Number(this.fromCode.get(this.fromType))>1000?{
  369. edb_name:res.Data.SearchItem.EdbName,
  370. unit:res.Data.SearchItem.Unit,
  371. frequency:frequencyArr.includes(res.Data.SearchItem.Frequency)?res.Data.SearchItem.Frequency:''
  372. }:{}
  373. this.add_params = {
  374. EdbCode: res.Data.SearchItem.EdbCode,
  375. EndDate: res.Data.SearchItem.EndDate,
  376. StartDate: res.Data.SearchItem.StartDate,
  377. Source: Number(this.fromCode.get(this.fromType)),
  378. ...opther_params,
  379. ...jy_params
  380. }
  381. this.status = res.Data.Status;
  382. let classify_arr = res.Data.ClassifyList || [];
  383. let str = '';
  384. classify_arr.length && classify_arr.reverse().map((item) => str += item.ClassifyName + '/');
  385. //提示文案
  386. this.have_edbobj = {
  387. warnTip: [1,3].includes(res.Data.Status) ? str : '',//已存在提示文案
  388. edb_name: [1,3].includes(res.Data.Status) ? res.Data.SearchItem.EdbName : '',
  389. },
  390. this.tableData =
  391. res.Data.Status === 1 ? [res.Data.SearchItem]
  392. : res.Data.Status !== 1 && res.Data.SearchItem.DataList && res.Data.SearchItem.DataList.length
  393. ? [res.Data.SearchItem]
  394. : [];
  395. this.dataList = res.Data.SearchItem.DataList || [];
  396. this.$nextTick(() => {
  397. this.loading.close();
  398. this.tableData.length && this.$refs.Table.setCurrentRow(this.tableData[0]);
  399. })
  400. } else {
  401. this.haveResult = false;
  402. this.loading.close();
  403. this.status = '';
  404. this.tableData = [];
  405. this.dataList = [];
  406. }
  407. })
  408. } else {
  409. this.$message.warning('请输入指标ID')
  410. }
  411. }),
  412. addTargtHandler() {
  413. console.log(this.add_params);
  414. this.$parent.completeTargetHandle(this.add_params);
  415. },
  416. changeTrade(e) {
  417. if (e == "彭博财务") {
  418. this.isCompanyCode = true;
  419. } else {
  420. this.isCompanyCode = false;
  421. }
  422. if(this.fromDatabase=='1'){
  423. this.changeDatabase('0')
  424. }
  425. this.search_txt = '';
  426. this.search_company_txt = '';
  427. this.loading && this.loading.close();
  428. },
  429. changeDatabase(e){
  430. this.fromDatabase=e
  431. this.securityCodeText=""
  432. this.securityCode=[]
  433. this.indexCodeText=''
  434. this.indexCode=[]
  435. this.indexCodeSelected=[]
  436. },
  437. getTargetSource(){
  438. this.fromArr = []
  439. this.fromCode = []
  440. dataBaseInterface.getDataSource({IsBase:1}).then(res=>{
  441. if(res.Ret!==200) return
  442. if(res.Data){
  443. this.fromArr = res.Data.map(i=>{
  444. return i.SourceName
  445. })
  446. this.fromCode = new Map(res.Data.map(i=>{
  447. return [i.SourceName,i.EdbSourceId]
  448. }))
  449. }
  450. })
  451. },
  452. codeInputBlur(type){
  453. if(type == 'security'){
  454. if(!this.securityCodeText) return
  455. if(!(this.securityCode.length<5)){
  456. this.$message.warning('证券代码一次最多输入5个')
  457. this.securityCodeText=''
  458. return
  459. }
  460. this.securityCode=Array.from(new Set([...this.securityCode,...this.securityCodeText.split(',')])).filter(Boolean)
  461. if(this.securityCode.length>5){
  462. this.securityCode = this.securityCode.slice(0,5)
  463. this.$message.warning('证券代码一次最多输入5个')
  464. }
  465. this.securityCodeText=''
  466. }else if(type == 'index'){
  467. if(!this.indexCodeText) return
  468. this.indexCode=Array.from(new Set([...this.indexCode,...this.indexCodeText.split(',')]))
  469. this.indexCodeText=''
  470. }
  471. },
  472. deleteCode(type,code){
  473. if(type == 'security'){
  474. this.securityCode = this.securityCode.filter(it => it!=code)
  475. }else if(type == 'index'){
  476. this.indexCode = this.indexCode.filter(it => it!=code)
  477. }
  478. },
  479. /* 获取目录结构 */
  480. getMenu() {
  481. dataBaseInterface.menuListV3().then(res => {
  482. if(res.Ret === 200) {
  483. this.filterNodes(res.Data.AllNodes||[]);
  484. this.options = res.Data.AllNodes || [];
  485. }
  486. })
  487. },
  488. // 递归改变目录结构
  489. filterNodes(arr) {
  490. arr.length && arr.forEach(item => {
  491. item.Children.length && this.filterNodes(item.Children)
  492. if(!item.Children.length) {
  493. item.Children=null
  494. }
  495. })
  496. },
  497. // 获取指标单位
  498. async getTargetUnitList(){
  499. let res=await dataInterence.getTargetUnitList()
  500. if(res.Ret===200){
  501. this.unitList=res.Data&&res.Data.map(item=>{
  502. return {value:item}
  503. })
  504. }
  505. },
  506. //搜索单位
  507. querySearchUnit(queryString, cb){
  508. let results = queryString ? this.unitList.filter(item=>item.value.indexOf(queryString) === 0) : this.unitList;
  509. // 调用 callback 返回建议列表的数据
  510. cb(results);
  511. },
  512. wsdNextHandle(){
  513. this.getMenu()
  514. setTimeout(()=>{
  515. console.log(this.securityCode,this.indexCode,this.indexCodeSelected,'wsdNextHandle',
  516. [...this.securityCode,...this.indexCodeSelected].join(','));
  517. // return
  518. if(this.isCodeComplete){
  519. let params={
  520. Source:Number(this.fromCode.get(this.fromType)),
  521. SubSource:this.fromDatabase,
  522. EdbCode:this.indexCode.join(','),
  523. StockCode:this.securityCode.join(',')
  524. }
  525. console.log(params,'params');
  526. dataBaseInterface.edbExistCheck(params).then(res=>{
  527. console.log(res);
  528. if(res.Ret == 200){
  529. if(res.Data.IndexExist){
  530. console.log('重复');
  531. this.existIndexList=[]
  532. let ExistEdbCodeArr=['close','open']
  533. let ExistStockCodeArr=['CU2403.SHF','FD78ES.FF']
  534. let text=''
  535. ExistStockCodeArr.map(item =>{
  536. ExistEdbCodeArr.map(item1 =>{
  537. let isCommon = this.indexCodeArr.find(it => it.value == item1)
  538. if(isCommon){
  539. text=`${item}${isCommon.label}(wsd${item}${isCommon.value})`
  540. }else{
  541. text=`${item}${item1}(wsd${item}${item1})`
  542. }
  543. this.existIndexList.push(text)
  544. })
  545. })
  546. this.checkFailShow=true
  547. }else{
  548. // this.wsdAddStep=2
  549. console.log('没有重复');
  550. }
  551. }
  552. })
  553. }
  554. },50)
  555. },
  556. wsdPrevHandle(){
  557. this.wsdAddStep=1
  558. },
  559. wsdSaveHandle(){
  560. let flag = this.edbIndexDatas.some(it => {
  561. console.log(it,'ittititti');
  562. return (!it.Catalogue) || (!it.Unit) || (!it.Frequency) || (!it.SecName)
  563. })
  564. if(flag){
  565. this.$message.warning("指标信息未填写完整")
  566. return
  567. }
  568. // TODO: 保存接口对接
  569. this.$message.success("添加指标成功")
  570. // { code:res.Data.UniqueCode,id:res.Data.EdbInfoId,classifyId:params.ClassifyId }
  571. this.$emit('addSuccessHandle')
  572. this.$emit('cancelHandle')
  573. }
  574. },
  575. created() { },
  576. mounted() {
  577. //this.getTargetSource()
  578. },
  579. }
  580. </script>
  581. <style lang="scss">
  582. .addTargtDia-box {
  583. .custom-dialog{
  584. max-width: 1200px !important;
  585. min-width: 1000px;
  586. .el-checkbox{
  587. margin-right: 20px;
  588. margin-bottom: 16px;
  589. }
  590. .edb-table-preview{
  591. border-right: 1px solid #dcdfe6;
  592. border-bottom: 1px solid #dcdfe6;
  593. .el-cascader{
  594. width: 100%;
  595. }
  596. .el-autocomplete{
  597. width: 100%;
  598. }
  599. .el-select{
  600. width: 100%;
  601. }
  602. .el-input{
  603. width: 100%;
  604. input{
  605. border: none;
  606. padding-left: 7px;
  607. font-size: 14px;
  608. }
  609. }
  610. }
  611. }
  612. }
  613. </style>
  614. <style lang='scss' scoped>
  615. .addTargtDia-box {
  616. .dialog-top {
  617. padding: 20px 30px;
  618. display: flex;
  619. justify-content: space-between;
  620. border: 1px solid #ECECEC;
  621. box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.05);
  622. }
  623. .wsd-index-box{
  624. padding-top: 20px;
  625. .wsd-index-code{
  626. display: flex;
  627. align-items: center;
  628. margin-bottom: 15px;
  629. .index-code-hint{
  630. color: #C0C4CC;
  631. font-size: 15px;
  632. }
  633. }
  634. .wsd-code-row{
  635. margin-top: 10px;
  636. min-height: 60px;
  637. display: flex;
  638. align-items: center;
  639. flex-wrap: wrap;
  640. .wsd-code-item{
  641. height: 40px;
  642. background-color: #EBEFF6;
  643. display: flex;
  644. align-items: center;
  645. margin-right: 10px;
  646. padding: 10px;
  647. box-sizing: border-box;
  648. margin-bottom: 10px;
  649. .wsd-code-item-text{
  650. color: #333333;
  651. margin-right: 10px;
  652. }
  653. img{
  654. height: 16px;
  655. width: 16px;
  656. cursor: pointer;
  657. }
  658. }
  659. }
  660. .wsd-index-input{
  661. width: 400px;
  662. margin-right: 10px;
  663. }
  664. }
  665. .warn_txt {
  666. font-size: 16px;
  667. color: #FF4E00;
  668. margin: 30px 0;
  669. text-align: center;
  670. }
  671. .dialog-main {
  672. margin-top: 20px;
  673. .value-ul {
  674. border: 1px solid #ECECEC;
  675. max-height: 320px;
  676. overflow-y: scroll;
  677. .value-item {
  678. color: #666;
  679. padding: 12px 0;
  680. display: flex;
  681. justify-content: space-around;
  682. }
  683. }
  684. }
  685. .dia-bot {
  686. margin: 30px 0;
  687. display: flex;
  688. justify-content: center;
  689. }
  690. .no-auth {
  691. width: 50%;
  692. padding: 40px;
  693. margin: 70px auto;
  694. text-align: center;
  695. background: #ECECEC;
  696. color: #FF4E00;
  697. border: 1px dashed #FF4E00;
  698. }
  699. // 预览表格
  700. .sticky {
  701. position: sticky;
  702. border-right: 1px solid #dcdfe6;
  703. z-index: 10;
  704. }
  705. .edb-table-preview {
  706. overflow: auto;
  707. height: calc(100% - 124px);
  708. &::-webkit-scrollbar {
  709. width: 5px !important;
  710. }
  711. table {
  712. border-color: #dcdfe6;
  713. border-bottom: 1px solid #dcdfe6;
  714. border-right: 1px solid #dcdfe6;
  715. border-collapse: separate;
  716. }
  717. thead {
  718. position: sticky;
  719. z-index: 2;
  720. top: 0;
  721. }
  722. td {
  723. min-width: 100px;
  724. max-width: 100px;
  725. height: 30px;
  726. // text-align: center;
  727. color: #333;
  728. box-sizing: border-box;
  729. padding: 0 5px;
  730. background-color: #fff;
  731. border-top: 1px solid #dcdfe6;
  732. border-left: 1px solid #dcdfe6;
  733. }
  734. }
  735. .check-fail-box{
  736. padding: 0 0 15px 40px;
  737. color: #333333;
  738. .check-fail-button{
  739. margin-top: 80px;
  740. display: flex;
  741. justify-content: flex-end;
  742. }
  743. }
  744. }
  745. </style>