batchFwAddIndicsDia.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. <template>
  2. <!-- 批量添加至指标库 -->
  3. <el-dialog
  4. :visible.sync="isOpenDialog"
  5. :close-on-click-modal="false"
  6. :modal-append-to-body="false"
  7. top="5vh"
  8. :title="$t('SteelChemicalPage.batch_add_edb_btn')"
  9. @close="$emit('close')"
  10. custom-class="batch-add-edb-dia"
  11. center
  12. width="70%"
  13. v-dialogDrag
  14. >
  15. <div class="dialog-container">
  16. <div class="select-box">
  17. <el-cascader v-model="searchClassify"
  18. :options="classifyList"
  19. :props="{
  20. children:'Child',
  21. label:'ClassifyName',
  22. value:'ClassifyId',
  23. multiple:true,
  24. emitPath:false
  25. }"
  26. :placeholder="$t('Edb.InputHolderAll.input_classify')"
  27. @change="getEdbList"
  28. ></el-cascader>
  29. <el-select
  30. v-model="frequency"
  31. @change="filterChange"
  32. clearable
  33. >
  34. <el-option v-for="item in frequencyOptions" :key="item.val" :label="item.label" :value="item.val"/>
  35. </el-select>
  36. <el-input style="width:240px;" v-model="searchName"
  37. :placeholder="$t('Edb.InputHolderAll.input_name_orid')"
  38. prefix-icon="el-icon-search"
  39. @input="getEdbList"
  40. />
  41. </div>
  42. <div class="select-table">
  43. <el-table :data="edbList" border
  44. :row-class-name="tableRowClassName"
  45. @selection-change="handleSelectionChange"
  46. v-loading="tableLoading">
  47. <el-table-column type="selection" width="55" align="center"></el-table-column>
  48. <el-table-column :label="$t('Edb.Detail.e_id')" align="center" width="120" prop="edbId"></el-table-column>
  49. <el-table-column :label="$t('Table.edb_name')" align="center">
  50. <template slot-scope="{row}">
  51. <el-input v-model="row.edbName" :placeholder="$t('Table.edb_name')"></el-input>
  52. </template>
  53. </el-table-column>
  54. <el-table-column :label="$t('Edb.Detail.e_fre')" align="center" width="140">
  55. <template slot-scope="{row}">
  56. <el-select
  57. v-model="row.frequency"
  58. :placeholder="$t('CustomAnalysisPage.select_frequency')"
  59. clearable>
  60. <el-option
  61. v-for="item in frequencyArr"
  62. :key="item.value"
  63. :label="item.label"
  64. :value="item.value">
  65. </el-option>
  66. </el-select>
  67. </template>
  68. </el-table-column>
  69. <el-table-column :label="$t('Edb.Detail.e_unit')" align="center" width="140">
  70. <template slot-scope="{row}">
  71. <selectUnit v-model="row.unit" />
  72. </template>
  73. </el-table-column>
  74. <!-- 操作 -->
  75. <el-table-column align="center">
  76. <template slot="header" slot-scope="{row}">
  77. <!-- <span>{{$t('EtaBasePage.catalogue_directory')}}</span> -->
  78. <el-radio-group v-model="classifyType" @change="handleClassifyTypeChange">
  79. <el-radio :label="1" style="margin-right:5px"><!-- 分目录 -->{{$t('EtaBasePage.subdirectory_radio')}}</el-radio>
  80. <el-radio :label="2"><!-- 同目录 -->{{$t('EtaBasePage.directory_radio')}}</el-radio>
  81. </el-radio-group>
  82. <el-cascader v-if="classifyType===2" v-model="selectClassify"
  83. :options="edbClassifyList"
  84. :props="{
  85. label: 'ClassifyName',
  86. value: 'ClassifyId',
  87. children: 'Children',
  88. checkStrictly: true,
  89. emitPath:false
  90. }"
  91. :placeholder="$t('SteelChemicalPage.batch_add_placeholder')"
  92. >
  93. </el-cascader>
  94. </template>
  95. <template slot-scope="{row,$index}">
  96. <el-cascader
  97. v-model="row.classify"
  98. :options="edbClassifyList"
  99. :props="{
  100. label: 'ClassifyName',
  101. value: 'ClassifyId',
  102. children: 'Children',
  103. checkStrictly: true,
  104. emitPath:false
  105. }"
  106. :placeholder="$t('SteelChemicalPage.batch_add_placeholder')"
  107. style="width:100%;"
  108. :disabled="classifyType===2"
  109. ></el-cascader>
  110. </template>
  111. </el-table-column>
  112. <div class="no-data" slot="empty">
  113. <tableNoData :text="$t('Table.prompt_slogan')"/>
  114. </div>
  115. </el-table>
  116. </div>
  117. </div>
  118. <div class="footer-container" slot="footer">
  119. <el-button type="primary" plain @click="$emit('close')">{{ $t('Dialog.cancel_btn') }}</el-button>
  120. <el-button type="primary" @click="handleAddEdb" :loading="btnloading">{{ $t('ManualEdbListPage.add_tobase_btn') }}</el-button>
  121. </div>
  122. <!-- 操作提示弹窗 -->
  123. <el-dialog
  124. :title="$t('BloombergPage.operation_prompt')"
  125. :visible.sync="isHintDiaShow"
  126. :close-on-click-modal="false"
  127. :modal-append-to-body="false"
  128. @close="handleCloseDia"
  129. width="578px"
  130. v-dialogDrag
  131. center>
  132. <div class="hint-dialog-wrap">
  133. <p style="margin-bottom: 20px;">{{ hintText }}</p>
  134. <ul>
  135. <li v-for="(item,index) in hintList" :key="index" class="hint-item" @click="gotoEdbDetail(item)">
  136. {{ index+1 }}、{{ item.IndexName }}({{ item.IndexCode }})
  137. </li>
  138. </ul>
  139. </div>
  140. <div style="text-align: center;margin-bottom: 30px;">
  141. <el-button type="primary" @click="handleCloseDia">{{$t('Dialog.known')}}</el-button>
  142. </div>
  143. </el-dialog>
  144. </el-dialog>
  145. </template>
  146. <script>
  147. import { fwmtInterface } from "@/api/modules/thirdBaseApi";
  148. import { dataBaseInterface } from '@/api/api.js';
  149. import selectUnit from '@/components/selectUnit.vue';
  150. import { frequencySelectList } from '@/utils/defaultOptions';
  151. export default {
  152. components:{ selectUnit },
  153. props:{
  154. isOpenDialog:{
  155. type:Boolean,
  156. default:false
  157. }
  158. },
  159. watch:{
  160. isOpenDialog(newval){
  161. if(newval){
  162. this.initDia()
  163. }
  164. }
  165. },
  166. data() {
  167. return {
  168. classifyList:[],//钢联化工数据库的目录
  169. searchName:'',
  170. searchClassify:'',
  171. classifyType:1,//1分目录 2同目录
  172. selectClassify:'',
  173. frequencyArr:frequencySelectList(),
  174. edbList:[
  175. /* {
  176. edbId:'123456',
  177. edbName:'指标名称指标名称',
  178. frequency:'日度',
  179. unit:'吨',
  180. classify:'',
  181. isHighlight:false
  182. }, */
  183. ],
  184. tableLoading:false,
  185. edbClassifyList:[],//指标库目录
  186. selectEdbList:[],//勾选的指标
  187. isHintDiaShow:false,
  188. hintList:[],
  189. hintText:'',
  190. btnloading:false,
  191. frequency: '',
  192. frequencyOptions: [
  193. { label:'日度',val: '日度' },
  194. { label:'周度',val: '周度' },
  195. { label:'旬度',val: '旬度' },
  196. { label:'月度',val: '月度' },
  197. { label:'季度',val: '季度' },
  198. { label:'半年度',val: '半年度' },
  199. { label:'年度',val: '年度' },
  200. ]
  201. };
  202. },
  203. methods: {
  204. tableRowClassName({row}){
  205. return row.isHighlight?'highlight-row':''
  206. },
  207. initDia(){
  208. this.getClassifyList()
  209. this.getClassifyOpt()
  210. this.searchClassify = ''
  211. this.searchName = ''
  212. this.edbList = []
  213. this.selectEdbList = []
  214. this.selectClassify=''
  215. this.btnloading=false
  216. },
  217. //获取钢联化工数据库目录
  218. getClassifyList(){
  219. fwmtInterface.classifyList().then((res) => {
  220. if(res.Ret!==200) return
  221. this.classifyList = res.Data||[]
  222. })
  223. },
  224. filterNodes(arr) {
  225. arr.length &&
  226. arr.forEach((item) => {
  227. item.Children.length && this.filterNodes(item.Children);
  228. if (!item.Children.length) {
  229. delete item.Children;
  230. }
  231. });
  232. },
  233. // 获取指标分类列表
  234. async getClassifyOpt(){
  235. const res=await dataBaseInterface.menuListV3()
  236. if (res.Ret !== 200) return
  237. this.filterNodes(res.Data.AllNodes||[]);
  238. this.edbClassifyList = res.Data.AllNodes || [];
  239. },
  240. //获取对应目录下的钢联化工指标
  241. getEdbList(){
  242. //每一次筛选项改变清空选择框
  243. this.selectEdbList = []
  244. this.classifyType = 1
  245. //tableData
  246. this.tableLoading = true
  247. fwmtInterface.searchEdbBatch({
  248. ClassifyIds: Array.isArray(this.searchClassify)?this.searchClassify.join(','):'',
  249. Keyword:this.searchName||'',
  250. Frequencies: this.frequency,
  251. }).then(res=>{
  252. this.tableLoading = false
  253. if(res.Ret!==200) return
  254. this.edbList = res.Data?res.Data.List.map(item=>{
  255. return {
  256. edbId:item.IndexCode||'',
  257. edbName:item.IndexName||'',
  258. frequency:item.Frequency||'',
  259. unit:item.Unit||'',
  260. classify:'',
  261. isHighlight:false
  262. }
  263. }):[]
  264. })
  265. },
  266. filterChange(item) {
  267. console.log(item);
  268. this.frequency = item
  269. this.getEdbList()
  270. },
  271. handleSelectionChange(val){
  272. this.selectEdbList = val
  273. },
  274. handleAddEdb(){
  275. //校验所选指标
  276. if(!this.selectEdbList.length){
  277. return this.$message.warning(this.$t('Edb.InputHolderAll.input_select_edb'))
  278. }
  279. if(this.selectEdbList.length>30){
  280. return this.$message.warning(this.$t('SteelChemicalPage.batch_add_max_msg'))
  281. }
  282. //校验所选指标信息是否完整
  283. if(this.classifyType===2&&!this.selectClassify){
  284. return this.$message.warning(this.$t('CustomAnalysisPage.select_appropriate_category'))
  285. }
  286. //重置tableData的高亮
  287. this.edbList.forEach(i=>i.isHighlight=false)
  288. let messageList = [] //有问题的列表
  289. this.selectEdbList.forEach((item)=>{
  290. item.isHighlight=false
  291. if(!this.checkEdbData(item)){
  292. item.isHighlight = true
  293. messageList.push(item)
  294. }
  295. })
  296. //message轻提示 同时标出不完整的行
  297. if(messageList.length){
  298. return this.$message.warning(/* '部分指标信息未填写完整,请检查' */this.$t('SteelChemicalPage.batch_add_hint1'))
  299. }
  300. this.btnloading = true
  301. //添加检测
  302. fwmtInterface.batchAddEdbCheck({
  303. IndexCodes:this.selectEdbList.map(i=>i.edbId)
  304. }).then(res=>{
  305. if(res.Ret!==200) return (this.btnloading=false)
  306. const edbList = res.Data||[]
  307. // const afterAddList = this.selectEdbList.filter(i =>
  308. // edbList.find(s=>s.IndexCode === i.edbId)
  309. // ) //已添加进指标库的指标
  310. const beforeAddList = this.selectEdbList.filter(i =>
  311. !edbList.some((item) => i.edbId === item.IndexCode)
  312. ) //需要添加进指标库的指标
  313. //已选择的指标均添加进指标库 弹窗提示
  314. if(!beforeAddList.length){
  315. return this.showHintDialog('all',edbList)
  316. }
  317. this.batchAddEdb(edbList,beforeAddList)
  318. // //剩余指标进行重名校验
  319. // this.batchNameCheck(afterAddList,beforeAddList)
  320. })
  321. },
  322. //重名检测
  323. // batchNameCheck(afterAddList,beforeAddList){
  324. // const indexCodeList = beforeAddList.map(i=>i.IndexCode)
  325. // let checkList = []
  326. // indexCodeList.forEach(i=>{
  327. // const item = this.selectEdbList.find(s=>s.edbId===i)
  328. // item&&checkList.push(item)
  329. // })
  330. // fwmtInterface.batchCheckEdbName(checkList.map(i=>{
  331. // return {
  332. // EdbCode:i.edbId,
  333. // EdbName:i.edbName,
  334. // Frequency:i.frequency
  335. // }
  336. // })).then(res=>{
  337. // if(res.Ret!==200) return (this.btnloading=false)
  338. // const checkedList = res.Data.filter(i=>i.Exist)
  339. // if(checkedList.length){
  340. // checkedList.forEach(i=>{
  341. // const item = this.selectEdbList.find(s=>s.edbId===i.EdbCode)
  342. // item&&(item.isHighlight = true)
  343. // })
  344. // return this.$message.warning(/* '部分指标名称已存在,请重新填写' */this.$t('SteelChemicalPage.batch_add_hint2'))&&(this.btnloading=false)
  345. // }else{
  346. // //通过重名校验后添加进指标库
  347. // this.batchAddEdb(afterAddList,checkList)
  348. // }
  349. // })
  350. // },
  351. checkEdbData(edbData){
  352. return edbData.edbName&&edbData.frequency&&edbData.unit&&(this.classifyType===1?edbData.classify:true)
  353. },
  354. //显示操作提示弹窗
  355. showHintDialog(type,list){
  356. this.btnloading = false
  357. this.isHintDiaShow = true
  358. console.log(list);
  359. this.hintList = list
  360. this.hintText = type==='all'
  361. ?this.$t('YsDataPage.haved_all_msg') //本次添加的指标均已在指标库中,请勿重复添加!
  362. :this.$t('YsDataPage.haved_some_msg') //指标库中已存在以下指标,会自动过滤!
  363. },
  364. //添加进指标库
  365. batchAddEdb(afterAddList=[],checkList){
  366. //checkList
  367. fwmtInterface.addIndex(checkList.map(i=>{
  368. return {
  369. EdbCode:i.edbId,
  370. EdbName:i.edbName,
  371. Unit:i.unit,
  372. Frequency:i.frequency,
  373. ClassifyId:this.classifyType===1?Number(i.classify):Number(this.selectClassify),
  374. }
  375. })).then(res=>{
  376. if(res.Ret!==200) return (this.btnloading=false)
  377. const checkedList = res.Data ? res.Data.filter(i=>i.Exist) : []
  378. if(checkedList.length){
  379. checkedList.forEach(i=>{
  380. const item = this.selectEdbList.find(s=>s.edbId===i.EdbCode)
  381. item&&(item.isHighlight = true)
  382. })
  383. return this.$message.warning(/* '部分指标名称已存在,请重新填写' */this.$t('SteelChemicalPage.batch_add_hint2'))&&(this.btnloading=false)
  384. }else{
  385. //若afterAddList有值 弹窗提示部分指标已加入
  386. if(afterAddList.length){
  387. this.showHintDialog('',afterAddList)
  388. }else{
  389. this.$message.success(this.$t('MsgPrompt.add_msg2'))
  390. this.$emit('close')
  391. }
  392. }
  393. })
  394. },
  395. //跳转至指标库
  396. gotoEdbDetail(data){
  397. const {classify_id,edb_info_id,unique_code} = data||{}
  398. const href = this.$router.resolve({
  399. path:'/database',
  400. query:{
  401. code:unique_code,
  402. id:edb_info_id,
  403. classifyId:classify_id,
  404. }
  405. }).href
  406. window.open(href,"_blank")
  407. },
  408. handleCloseDia(){
  409. //两个弹窗都关掉
  410. this.isHintDiaShow=false
  411. this.$emit('close')
  412. }
  413. },
  414. };
  415. </script>
  416. <style lang="scss">
  417. .batch-add-edb-dia{
  418. .dialog-container{
  419. .el-input{
  420. width:100%;
  421. }
  422. .el-table .highlight-row{
  423. background-color:#fef0f0 !important;
  424. }
  425. }
  426. }
  427. </style>
  428. <style scoped lang="scss">
  429. .batch-add-edb-dia{
  430. .dialog-container{
  431. .select-box{
  432. margin-bottom:20px;
  433. }
  434. .select-table{
  435. max-height:600px;
  436. overflow-y:auto;
  437. }
  438. }
  439. .hint-dialog-wrap{
  440. padding-bottom:30px;
  441. .hint-item{
  442. cursor: pointer;
  443. margin-bottom: 10px;
  444. &:hover{
  445. color:#409EFF;
  446. text-decoration: underline;
  447. }
  448. }
  449. }
  450. }
  451. </style>