data-level.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <!--
  2. 数据分级表码列表
  3. @Author: linqian
  4. @Date: 2021-03-31 15:30:11
  5. -->
  6. <template>
  7. <div>
  8. <!-- 搜索栏 -->
  9. <search-bar :conditionForm="conditionForm" @submitSearch="receiveSearch"></search-bar>
  10. <!-- 操作栏 -->
  11. <operate-bar :pageOptList="pageOptList" @submitPageOpt="receviceOpt"></operate-bar>
  12. <!-- 表格 -->
  13. <new-table
  14. ref="table"
  15. :tableHeader="dataLevelTableHeader"
  16. :tableUrl="dataLevelTableUrl"
  17. :condition="condition"
  18. :tableOptList="tableOptList"
  19. @submitTableOpt="receviceOpt"
  20. >
  21. </new-table>
  22. </div>
  23. </template>
  24. <script>
  25. import { dataLevelTableUrl, delDataLevel, getDataLevelDetail, saveDataLevel } from '@/api/data-auth';
  26. import { dataLevelSyncUrl } from '@/api/sync';
  27. import { dataLevelImportUrl } from '@/api/import';
  28. import searchBar from '@/components/search-bar';
  29. import operateBar from '@/components/operate-bar';
  30. import newTable from '@/pages/common/new-table';
  31. import { searchOpt, importOpt, syncOpt, addEditOpt } from '@/mixins/page-opt';
  32. import { dataLevelTableHeader, tableOptList, pageOptList, dataLevelForm } from './DataConfig';
  33. const area = ['500px', '400px'];
  34. const labelWidth = '100px';
  35. export default {
  36. components: { searchBar, operateBar, newTable },
  37. mixins: [searchOpt, importOpt, syncOpt, addEditOpt],
  38. data() {
  39. return {
  40. dataLevelTableUrl,
  41. dataLevelTableHeader,
  42. tableOptList: tableOptList.slice(1, 3),
  43. pageOptList,
  44. conditionForm: [
  45. {
  46. label: '数据分级',
  47. name: 'levelName',
  48. op: 'like',
  49. value: '',
  50. component: 'ElInput'
  51. }
  52. ]
  53. };
  54. },
  55. computed: {},
  56. methods: {
  57. async receviceOpt(opt, row) {
  58. const otherParams = {
  59. config: dataLevelForm,
  60. labelWidth,
  61. area
  62. };
  63. if (opt == '新增') {
  64. this.handleOpenEditForm('新增', 'add', otherParams);
  65. } else if (opt == '修改') {
  66. const detailInfo = await this.getDetail(row.id);
  67. this.handleOpenEditForm('编辑', 'update', { ...otherParams, detailInfo });
  68. } else if (opt == '删除') {
  69. this.handleDelete(row);
  70. } else if (opt == '同步') {
  71. this.handleSync(dataLevelSyncUrl);
  72. } else if (opt == '导入') {
  73. this.handleImport(dataLevelImportUrl, 'dataLevel', '数据分级表码导入');
  74. }
  75. },
  76. /**
  77. * 删除
  78. */
  79. handleDelete(row) {
  80. this.$dgConfirm(`是否确定删除这条数据!`, '提示', {}).then(() => {
  81. delDataLevel(row.id).then((res) => {
  82. this.$message.success('删除成功!');
  83. this.handleSearch();
  84. });
  85. });
  86. },
  87. /**
  88. * 获取详情
  89. */
  90. getDetail(id) {
  91. return new Promise((resolve) => {
  92. getDataLevelDetail(id).then((res) => {
  93. resolve(res.data.content);
  94. });
  95. });
  96. },
  97. /**
  98. * @description: 保存表单
  99. * @param { 表单数据 } form
  100. * @param { 新增还是编辑 } type
  101. * @param { 弹框 } layer
  102. */
  103. saveForm(form, type, layer) {
  104. saveDataLevel(form)
  105. .then((res) => {
  106. this.$message.success('保存成功!');
  107. layer.close(layer.dialogIndex);
  108. this.handleSearch();
  109. })
  110. .catch((error) => {
  111. this.$message.error(error);
  112. });
  113. }
  114. },
  115. created() {},
  116. mounted() {}
  117. };
  118. </script>
  119. <style lang='scss' scoped>
  120. @import url('./index.scss');
  121. </style>