targetList.vue 17 KB

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