test.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <!--
  2. 服务资源管理
  3. @Author: linqian
  4. @Date: 2021-05-17 13:53
  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. <basic-table
  14. ref="table"
  15. :tableHeader="tableHeader"
  16. :tableUrl="tableUrl"
  17. :condition="condition"
  18. :tableOptList="tableOptList"
  19. @submitTableOpt="receviceOpt"
  20. >
  21. </basic-table>
  22. </div>
  23. </template>
  24. <script>
  25. import searchBar from '@/components/search-bar';
  26. import operateBar from '@/components/operate-bar';
  27. import basicTable from '@/pages/common/new-table';
  28. import { conditionForm, pageOptList, tableOptList, tableHeader, editForm } from './DataConfig';
  29. import { searchOpt, importOpt, syncOpt, detailOpt, addEditOpt } from '@/mixins/page-opt';
  30. import * as Api from "@/api/ser-resource-manage";
  31. import { serviceImportUrl } from "@/api/import";
  32. import { authSerSyncUrl } from "@/api/sync";
  33. import editFormLayer from "./edit-form.vue"
  34. const labelWidth = '180px';
  35. const area = ['900px', '600px'];
  36. export default {
  37. components: {
  38. searchBar,
  39. operateBar,
  40. basicTable
  41. },
  42. mixins: [searchOpt, addEditOpt, detailOpt, importOpt, syncOpt],
  43. data() {
  44. return {
  45. conditionForm,
  46. pageOptList,
  47. tableOptList,
  48. tableHeader,
  49. tableUrl: Api.tableUrl,
  50. };
  51. },
  52. computed: {},
  53. methods: {
  54. /**
  55. * 接收操作事件
  56. */
  57. async receviceOpt(type, row) {
  58. const otherParams = {
  59. config: editForm,
  60. labelWidth,
  61. area
  62. };
  63. if (type == '修改') {
  64. const detailInfo = await this.getDetail(row.id);
  65. this.handleOpenEditForm('编辑', 'update', { ...otherParams, detailInfo });
  66. } else if (type == '新增') {
  67. this.handleOpenEditForm('新增', 'add', {...otherParams, content: editFormLayer });
  68. } else if (type == '详情') {
  69. this.handleViewDetail(row.id, otherParams);
  70. } else if (type == '删除') {
  71. this.handleDelete(row);
  72. } else if (type == '导入') {
  73. this.handleImport(serviceImportUrl, 'serviceResource');
  74. } else if (type == '同步') {
  75. this.handleSync(authSerSyncUrl);
  76. }
  77. },
  78. /**
  79. * 删除
  80. */
  81. handleDelete(row) {
  82. this.$dgConfirm(`是否确认删除该条应用!`, '提示', {}).then(() => {
  83. Api.del(row.id).then((res) => {
  84. this.$message.success(res);
  85. this.handleSearch();
  86. });
  87. });
  88. },
  89. /**
  90. * 获取详情
  91. */
  92. getDetail(id) {
  93. return new Promise((resolve) => {
  94. Api.detail(id).then((res) => {
  95. resolve(res);
  96. });
  97. });
  98. },
  99. /**
  100. * @description: 保存表单
  101. * @param { 表单数据 } form
  102. * @param { 新增还是编辑 } type
  103. * @param { 弹框 } layer
  104. */
  105. saveForm(form, type, layer) {
  106. const api = type == 'update' ? 'update' : 'save';
  107. Api[api](form)
  108. .then((res) => {
  109. this.$message.success('保存成功!');
  110. layer.close(layer.dialogIndex);
  111. this.handleSearch();
  112. })
  113. .catch((error) => {
  114. this.$message.error(error);
  115. });
  116. }
  117. },
  118. created() {},
  119. mounted() {}
  120. };
  121. </script>
  122. <style lang='scss'>
  123. </style>