targetList.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. <template>
  2. <div class="dataEntry-container2">
  3. <div class="data-top-container">
  4. <!-- <el-button type="primary" size="medium" style="marginRight:20px;" @click="insertData(1)">录入数据</el-button>
  5. <el-button type="primary" size="medium" style="marginRight:20px;" @click="insertData(2)">新增指标</el-button>
  6. <el-button type="primary" size="medium" style="marginRight:20px;" @click="handleImport">导入数据</el-button>
  7. <el-button size="medium" @click="handleExport">导出数据</el-button> -->
  8. <el-button
  9. v-permission="permissionBtn.dataSourcePermission.manualData_add"
  10. type="primary"
  11. size="medium"
  12. @click="insertData(2)"
  13. ><!-- 新增指标 -->{{$t('ManualEdbListPage.add_edb_btn')}}</el-button>
  14. <!-- <el-button type="primary" size="medium" @click="handleImport">导入新指标</el-button> -->
  15. <el-input
  16. :placeholder="$t('ManualEdbListPage.ph_search')"
  17. v-model="search_txt"
  18. @input="searchHandle"
  19. style="maxWidth:260px;float:right">
  20. <i slot="prefix" class="el-input__icon el-icon-search"></i>
  21. </el-input>
  22. </div>
  23. <div class="data-bot-container">
  24. <div style="margin-bottom:30px">
  25. <el-cascader
  26. :options="fillterClassifyList"
  27. v-model="classify_id"
  28. :props="classifyProps"
  29. @change="classifyChange"
  30. :placeholder="$t('ManualEdbListPage.ph_classify')"
  31. :show-all-levels="false"
  32. style="maxWidth:240px;marginRight:30px;"
  33. clearable>
  34. </el-cascader>
  35. <el-select
  36. v-model="frequency"
  37. :placeholder="$t('Edb.InputHolderAll.input_fre')"
  38. @change="frequencyChange"
  39. style="maxWidth:240px;marginRight:30px;"
  40. clearable
  41. >
  42. <el-option
  43. v-for="item in frequencyList"
  44. :key="item.value"
  45. :label="item.label"
  46. :value="item.value">
  47. </el-option>
  48. </el-select>
  49. <el-date-picker
  50. v-model="date"
  51. type="daterange"
  52. :range-separator="$t('Common.to')"
  53. :start-placeholder="$t('ManualEdbListPage.ph_start_time')"
  54. :end-placeholder="$t('ManualEdbListPage.ph_end_time')"
  55. @change="dateChange"
  56. value-format="yyyy-MM-dd">
  57. </el-date-picker>
  58. </div>
  59. <!-- 展示表格 -->
  60. <el-table
  61. :data="tableData"
  62. v-loading="isShowloadding"
  63. :element-loading-text="$t('Table.data_loading')"
  64. :default-sort = "{prop: 'date', order: 'descending'}"
  65. border>
  66. <!-- 指标表格 -->
  67. <el-table-column
  68. prop="CreateDate"
  69. :label="$t('ManualEdbListPage.table_col_date')"
  70. sortable
  71. align="center">
  72. <template slot-scope="scope"> <span style="position: relative;">{{scope.row.CreateDate|formatTime}}<i v-if="scope.row.CreateDate.substr(0,10)===today" style="width:6px;height:6px;background:#FB5F5F;borderRadius:50%;position:absolute;right:-10px;top:-3px;"></i></span> </template>
  73. </el-table-column>
  74. <el-table-column
  75. prop="TradeCode"
  76. :label="$t('Edb.Detail.e_id')"
  77. align="center">
  78. <template slot-scope="scope"> <span>{{scope.row.TradeCode}}</span> </template>
  79. </el-table-column>
  80. <el-table-column
  81. prop="SecName"
  82. :label="$t('Edb.Detail.e_name')"
  83. align="center">
  84. <template slot-scope="scope"> <span>{{scope.row.SecName}}</span> </template>
  85. </el-table-column>
  86. <el-table-column
  87. prop="Frequency"
  88. :label="$t('Edb.Detail.e_fre')"
  89. align="center">
  90. <template slot-scope="scope"> <span>{{scope.row.Frequency}}</span> </template>
  91. </el-table-column>
  92. <el-table-column
  93. prop="ClassifyName"
  94. :label="$t('ManualEdbListPage.table_col_classify')"
  95. align="center">
  96. <template slot-scope="scope"> <span>{{scope.row.ClassifyName}}</span> </template>
  97. </el-table-column>
  98. <el-table-column
  99. prop="Unit"
  100. :label="$t('Edb.Detail.e_unit')"
  101. align="center">
  102. <template slot-scope="scope"> <span>{{scope.row.Unit}}</span> </template>
  103. </el-table-column>
  104. <el-table-column
  105. :label="$t('ManualEdbListPage.table_col_creator')"
  106. align="center">
  107. <template slot-scope="scope"> <span>{{scope.row.UserName}}</span> </template>
  108. </el-table-column>
  109. <el-table-column :label="$t('Table.column_operations')" align="center">
  110. <template slot-scope="scope">
  111. <div style="color:#4099ef; font-size:24px;">
  112. <span v-permission="permissionBtn.dataSourcePermission.manualData_add"
  113. class="editsty" @click="editHandle(scope.row)" style="marginRight:20px;">{{$t('Table.edit_btn')}}</span>
  114. <span v-permission="permissionBtn.dataSourcePermission.manualData_del"
  115. class="deletesty" @click="delHandle(scope.row)">{{$t('Table.delete_btn')}}</span>
  116. </div>
  117. </template>
  118. </el-table-column>
  119. <div slot="empty" style="lineHeight:25px;margin:20px 0;color:#95A9C5;">
  120. <tableNoData :text="$t('ManualEdbListPage.no_search_msg')" size="mini"/>
  121. </div>
  122. </el-table>
  123. <div class="toolbar">
  124. <el-pagination
  125. layout="total,prev,pager,next,jumper"
  126. background
  127. :current-page="page_no"
  128. @current-change="handleCurrentChange"
  129. :page-size="pageSize"
  130. @size-change="handleSizeChange"
  131. :total="total"
  132. style="float:right;">
  133. </el-pagination>
  134. </div>
  135. </div>
  136. <!-- 新增指标弹窗 -->
  137. <add-target
  138. ref="Atarget"
  139. :unitList="unitList"
  140. :formData="formData"
  141. :addTargetDefaultClassId="addTargetDefaultClassId"
  142. :dialogTitle="dialogTitle"
  143. :typeList="classifyList"
  144. :isShowdialog="isShowdialog"
  145. :is_editData="is_editData"
  146. @cancelHandle="cancelHandle"
  147. @changeForm="changeForm"
  148. @addOver="addOver">
  149. </add-target>
  150. <edit-target
  151. :unitList="unitList"
  152. :tab_act="tab_act"
  153. :typeList="classifyList"
  154. :editTitle="editTitle"
  155. :formData="editFormData"
  156. :edit_dataId="edit_dataId"
  157. :isShowedit="isShowedit"
  158. @cancelEdit="cancelEdit"
  159. @editDataOver="editDataOver"
  160. @changeEditForm="changeEditForm">
  161. </edit-target>
  162. <!-- 导入数据弹窗 -->
  163. <insertdata
  164. :isShowinsert="isShowinsert"
  165. @cancelHandle="cancelHandle"
  166. @importSuccess="importSuccess"
  167. source="targetList">
  168. </insertdata>
  169. </div>
  170. </template>
  171. <script>
  172. import addTarget from './components/addTarget';
  173. import insertdata from './components/insertData';
  174. import editTarget from './components/editTarget';
  175. import { dataInterence } from 'api/api.js';
  176. import http from "@/api/http.js";
  177. export default {
  178. name: "dataList",
  179. data() {
  180. return {
  181. today:http.dateFormatter(new Date(),false),
  182. dialogTitle:'录入数据',
  183. tabs:['录入数据','指标管理'],
  184. tab_act:1,
  185. isShowloadding:false,//loading
  186. classifyList:[],//分类列表
  187. fillterClassifyList:[],//筛选分类列表
  188. classifyProps:{
  189. label: "ClassifyName",
  190. value: "ClassifyId",
  191. children: "Child"
  192. },
  193. frequencyList:[
  194. {
  195. value: '日度',
  196. label: /* '日度' */this.$t('Edb.FreAll.day'),
  197. },
  198. {
  199. value: '周度',
  200. label: /* '周度' */this.$t('Edb.FreAll.week'),
  201. },
  202. {
  203. value: '旬度',
  204. label: /* '旬度' */this.$t('Edb.FreAll.dekad'),
  205. },
  206. {
  207. value: '月度',
  208. label: /* '月度' */this.$t('Edb.FreAll.month'),
  209. },
  210. {
  211. value: '季度',
  212. label: /* '季度' */ this.$t('Edb.FreAll.quarter'),
  213. },
  214. {
  215. value: '半年度',
  216. label: /* '半年度' */ this.$t('Edb.FreAll.month'),
  217. },
  218. {
  219. value: '年度',
  220. label: /* '年度' */ this.$t('Edb.FreAll.year'),
  221. }
  222. ],//频度列表
  223. tableData: [],
  224. total:1,//总条数
  225. page_no:1,//当前页
  226. pageSize:15,//每页条数
  227. date:'',
  228. frequency:'',//频度
  229. classify_id:0,//分类id
  230. search_txt:'',//关键字搜索
  231. isShowdialog:false,//显示新增指标
  232. isShowinsert:false,//导入弹窗
  233. formData:{
  234. type:'',
  235. date:http.dateFormatter(new Date(),false),//日期
  236. target:'',//指标
  237. value:'',//值
  238. frequency:'日度',//频度
  239. unit:'',//单位
  240. targetName:'',//指标名称
  241. trade_code:'',//指标标识
  242. up_week:'',//更新时间周
  243. up_time:'',//更新时间
  244. up_day:'',//更新时间日
  245. },//指标弹窗数据
  246. editFormData:{},//修改表单数据
  247. isShowedit:false,//显示编辑弹窗
  248. editTitle:'修改录入数据',
  249. is_editData:false,//是否是编辑数据
  250. edit_dataId:'',//编辑分类id
  251. unitList:[],//指标单位数据
  252. addTargetDefaultClassId:0,//新增指标时默认的分类id
  253. };
  254. },
  255. components: {
  256. addTarget,
  257. editTarget,
  258. insertdata
  259. },
  260. methods: {
  261. // 获取指标单位
  262. async getTargetUnitList(){
  263. let res=await dataInterence.getTargetUnitList()
  264. if(res.Ret===200){
  265. this.unitList=res.Data&&res.Data.map(item=>{
  266. return {value:item}
  267. })
  268. }
  269. },
  270. // 选择指标
  271. chooseType(e) {
  272. //console.log(e)
  273. },
  274. // 新增指标或录入数据
  275. insertData(type) {
  276. this.isShowdialog = true;
  277. this.dialogTitle = type===1?'录入数据':'新增指标';
  278. },
  279. // 隐藏弹框
  280. cancelHandle(bol) {
  281. if(bol === 1) {
  282. this.isShowdialog = false;
  283. this.$refs.Atarget.$refs.formD.resetFields();
  284. this.formData = {
  285. type:this.classifyList[0].Child[0].ClassifyName,
  286. date:http.dateFormatter(new Date(),false),//日期
  287. target:'',//指标
  288. value:'',//值
  289. frequency:'日度',//频度
  290. unit:'',//单位
  291. targetName:'',//指标名称
  292. trade_code:'',//指标标识
  293. up_week:'',//更新时间周
  294. up_time:'',//更新时间
  295. up_day:'',//更新时间日
  296. }
  297. }else {
  298. this.isShowinsert = false;
  299. }
  300. },
  301. // 重置条件
  302. init() {
  303. this.page_no = 1;//当前页
  304. this.pageSize = 15;//每页条数
  305. this.date = '';
  306. this.frequency = '';//频度
  307. this.classify_id = 0;//分类id
  308. this.search_txt = '';//关键字搜索
  309. },
  310. // 获取数据表格
  311. getTableData(tab = 1) {
  312. //取分类id
  313. let classify_id;
  314. if (this.classify_id instanceof Array) {
  315. let arr = JSON.parse(JSON.stringify(this.classify_id));
  316. classify_id = arr.pop();
  317. }else {
  318. classify_id = this.classify_id
  319. }
  320. let parmas = {
  321. CurrentIndex: this.page_no,
  322. PageSize: this.pageSize,
  323. StartDate: this.date ? this.date[0] : '',
  324. EndDate: this.date ? this.date[1] : '',
  325. Frequency: this.frequency,
  326. ClassifyId:classify_id,
  327. KeyWord: this.search_txt
  328. }
  329. // if(tab === 0) {
  330. //获取数据表格
  331. // this.isShowloadding = true;
  332. // dataInterence.getDatalist(parmas).then(res => {
  333. // // console.log(res)
  334. // if(res.Ret === 200 && res.data.list) {
  335. // this.tableData = res.data.list;
  336. // this.total = parseInt(res.data.total_num);
  337. // }
  338. // this.isShowloadding = false;
  339. // })
  340. // }else {
  341. // 获取指标表格
  342. this.isShowloadding = true;
  343. dataInterence.targetList(parmas).then(res => {
  344. if(res.Ret === 200 && res.Data.List) {
  345. this.tableData = res.Data.List;
  346. this.total = parseInt(res.Data.Paging.Totals);
  347. }else {
  348. this.tableData = []
  349. }
  350. this.isShowloadding = false;
  351. })
  352. // }
  353. },
  354. // 获取分类
  355. getClassify() {
  356. dataInterence.getClassify().then(res =>{
  357. if(res.Ret === 200 && res.Data.List) {
  358. this.classifyList = res.Data.List;
  359. // 默认分类第一个
  360. this.classifyList[0].Child.length&&this.classifyList[0].Child.forEach((item,index) => {
  361. if(index == 0) {
  362. this.formData.type = item.ClassifyName;
  363. let classify_id = item.ClassifyId;
  364. // sessionStorage.setItem('default_id',classify_id)
  365. this.addTargetDefaultClassId=classify_id
  366. }
  367. })
  368. //处理没有二级的一级菜单
  369. let arr = JSON.parse(JSON.stringify(res.Data.List));
  370. arr && arr.forEach((item,index) => {
  371. let obj = {}
  372. obj.ClassifyId = item.ClassifyId;
  373. obj.ClassifyName = item.ClassifyName;
  374. obj.ParentId = item.ParentId;
  375. if(item.Child && item.Child.length) {
  376. obj.Child = item.Child
  377. }
  378. this.fillterClassifyList.push(obj)
  379. });
  380. }
  381. })
  382. },
  383. // 修改表单指标分类
  384. changeForm(name) {
  385. //切换分类清空form
  386. this.$refs.Atarget.$refs.formD.resetFields();//重置校验
  387. this.formData = {
  388. type:name,
  389. date:http.dateFormatter(new Date(),false),//日期
  390. target:'',//指标
  391. value:'',//值
  392. frequency:'日度',//频度
  393. unit:'',//单位
  394. targetName:'',//指标名称
  395. trade_code:'',//指标标识
  396. up_week:'',//更新时间周
  397. up_time:'',//更新时间
  398. up_day:'',//更新时间日
  399. }
  400. },
  401. // 导入数据
  402. handleImport() {
  403. this.isShowinsert = true;
  404. },
  405. // 导入数据成功
  406. importSuccess() {
  407. this.isShowinsert = false;
  408. this.getTableData();
  409. },
  410. // 页码改变
  411. handleCurrentChange(page) {
  412. // console.log(e)
  413. this.page_no = page;
  414. // if(this.tab_act === 0) {
  415. // this.getTableData();
  416. // }else {
  417. this.getTableData(1);
  418. // }
  419. },
  420. // 页数改变
  421. handleSizeChange(size) {
  422. this.pageSize = size;
  423. // if(this.tab_act === 0) {
  424. // this.getTableData();
  425. // }else {
  426. this.getTableData(1);
  427. // }
  428. },
  429. // 日期改变
  430. dateChange() {
  431. // if(this.tab_act === 0) {
  432. // this.getTableData();
  433. // }else {
  434. this.page_no = 1;//当前页
  435. this.getTableData(1);
  436. // }
  437. },
  438. // 筛选分类改变
  439. classifyChange(e) {
  440. // console.log(this.classify_id,e)
  441. // if(this.tab_act === 0) {
  442. // this.getTableData();
  443. // }else {
  444. this.page_no = 1;//当前页
  445. this.getTableData(1);
  446. // }
  447. },
  448. // 频度改变
  449. frequencyChange() {
  450. // if(this.tab_act === 0) {
  451. // this.getTableData();
  452. // }else {
  453. this.page_no = 1;//当前页
  454. this.getTableData(1);
  455. // }
  456. },
  457. // 关键字搜索
  458. searchHandle() {
  459. // if(this.tab_act === 0) {
  460. // this.getTableData();
  461. // }else {
  462. this.page_no = 1;//当前页
  463. this.getTableData(1);
  464. // }
  465. },
  466. // 新增成功
  467. addOver(type) {
  468. this.$refs.Atarget.$refs.formD.resetFields();//重置校验
  469. this.formData = {
  470. type:type,
  471. date:http.dateFormatter(new Date(),false),//日期
  472. target:'',//指标
  473. value:'',//值
  474. frequency:'日度',//频度
  475. unit:'',//单位
  476. targetName:'',//指标名称
  477. trade_code:'',//指标标识
  478. up_week:'',//更新时间周
  479. up_time:'',//更新时间
  480. up_day:'',//更新时间日
  481. }
  482. this.isShowdialog=false
  483. this.getTableData();
  484. },
  485. // 编辑中修改分类
  486. changeEditForm(name,id) {
  487. this.$set(this.editFormData,'type',name);
  488. this.edit_dataId = id;
  489. },
  490. // 编辑
  491. editHandle(item) {
  492. this.isShowedit = true;
  493. this.edit_dataId = item.ClassifyId;
  494. let up_week,//更新时间周
  495. up_time,//更新时间
  496. up_day;
  497. // 处理更新时间
  498. if(item.NoticeTime) {
  499. if(item.Frequency === '日度' ) {
  500. up_week = '';
  501. up_time = item.NoticeTime;
  502. up_day = '';
  503. }else if(item.Frequency === '周度') {
  504. up_week = item.NoticeTime.substr(0,2);
  505. up_time = item.NoticeTime.substr(3);
  506. up_day = '';
  507. }else if(item.Frequency === '月度') {
  508. up_week = '';
  509. up_time = item.NoticeTime.substr(4);
  510. up_day = item.NoticeTime.substr(0,3);
  511. }else if(item.Frequency==='季度'){
  512. up_week = '';
  513. up_time = item.NoticeTime.substr(5);
  514. up_day = item.NoticeTime.substr(0,4);
  515. }else if(item.Frequency==='半年度'){
  516. up_week = '';
  517. up_time = item.NoticeTime.substr(5);
  518. up_day = item.NoticeTime.substr(0,4);
  519. }else if(item.Frequency==='年度'){
  520. up_week = '';
  521. up_time = item.NoticeTime.substr(4);
  522. up_day = item.NoticeTime.substr(0,3);
  523. }
  524. }else {
  525. up_week = '';
  526. up_time = '';
  527. up_day = '';
  528. }
  529. this.editTitle="编辑指标";
  530. this.editFormData = {
  531. type:item.ClassifyName,
  532. frequency:item.Frequency,
  533. unit:item.Unit,
  534. targetName:item.SecName,
  535. trade_code:item.TradeCode,
  536. up_week:up_week,//更新时间周
  537. up_time:up_time,//更新时间
  538. up_day:up_day,//更新时间日
  539. }
  540. // }
  541. },
  542. // 编辑数据成功
  543. editDataOver(tab=1) {
  544. // this.tab = tab;
  545. this.isShowedit = false;
  546. this.getTableData(tab);
  547. },
  548. // 取消编辑
  549. cancelEdit() {
  550. this.isShowedit = false;
  551. },
  552. // 删除指标
  553. delHandle(item) {
  554. console.log(item)
  555. // 删除前检测指标下是否有录入数据
  556. dataInterence.checkTarget({
  557. TradeCode:item.TradeCode
  558. }).then(res => {
  559. if(res.Data.Status===1){
  560. this.$message.error("该指标已加入指标库,不可删除")
  561. return
  562. }else{
  563. this.$confirm(
  564. res.Data.Status===0 ? this.$t('ManualEdbListPage.del_edb_msg') : this.$t('ManualEdbListPage.del_edb_rela_msg'),
  565. this.$t('Dialog.warn_tit'),{
  566. type:'warning'
  567. }).then(() => {
  568. dataInterence.delTarget({
  569. TradeCode:item.TradeCode
  570. }).then(res =>{
  571. if( res.Ret !== 200 ) return
  572. this.$message.success(/* '删除成功!' */this.$t('MsgPrompt.delete_msg'));
  573. this.getTableData();
  574. });
  575. }).catch(() => {});
  576. }
  577. })
  578. }
  579. },
  580. created() {
  581. // sessionStorage.removeItem('default_id')
  582. this.getClassify();
  583. this.getTargetUnitList()
  584. },
  585. mounted() {
  586. this.getTableData();
  587. }
  588. };
  589. </script>
  590. <style lang="scss">
  591. .dataEntry-container2 {
  592. // background: #fff;
  593. // box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);
  594. .data-top-container {
  595. padding: 21px 30px;
  596. background: #FFFFFF;
  597. border: 1px solid #ECECEC;
  598. border-radius: 4px;
  599. margin-bottom: 30px;
  600. // .type-list {
  601. // max-width: 100px;
  602. // }
  603. // .rigth-cont {
  604. // margin: 0 auto;
  605. // }
  606. // .bot-handle {
  607. // margin: 80px auto 0;
  608. // }
  609. }
  610. .data-bot-container {
  611. padding: 31px 30px;
  612. background: #FFFFFF;
  613. border: 1px solid #ECECEC;
  614. border-radius: 4px;
  615. .tabs-cont {
  616. display: flex;
  617. justify-content: space-around;
  618. align-items: center;
  619. margin-bottom: 60px;
  620. color: #1F2E4D;
  621. font-size: 16px;
  622. .tab-item {
  623. width: 20%;
  624. text-align: center;
  625. cursor: pointer;
  626. padding-bottom:10px;
  627. transition: all 0.3s;
  628. border-bottom: 2px solid transparent;
  629. &.act {
  630. border-bottom: 2px solid #5882EF;
  631. color: #5882EF;
  632. }
  633. }
  634. }
  635. }
  636. }
  637. </style>