field-sort-code.vue 3.8 KB

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