add-dialog.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <!--
  2. * @Author: Liugh
  3. * @Date: 2021-05-19 16:09:07
  4. * @LastEditTime: 2021-05-20 11:13:49
  5. * @LastEditors: Do not edit
  6. * @FilePath: \auth-web\src\pages\data-auth-module\auth-object-manage\object-prop-manage\add-dialog.vue
  7. * @Description:
  8. -->
  9. <template>
  10. <main class="add-dialog">
  11. <dg-row class="property-wapper">
  12. <!-- 搜索栏 -->
  13. <search-bar :conditionForm="appConditonForm2" @submitSearch="receiveSearch"></search-bar>
  14. <!-- 表格 -->
  15. <new-table
  16. ref="table"
  17. :selection="true"
  18. :tableHeader="cardAgencylist"
  19. :tableUrl="tableUrl"
  20. :condition="condition"
  21. v-if="type !== 'service'"
  22. >
  23. </new-table>
  24. </dg-row>
  25. <div v-footer>
  26. <dg-button @click="handleClose">取消</dg-button>
  27. <dg-button type="primary" @click="handleSave">保存</dg-button>
  28. </div>
  29. </main>
  30. </template>
  31. <script>
  32. import { appRestApi } from '@/api/application';
  33. import { cardAgencylist, cardFunctionList, appConditonForm2 } from '../../auth-subject-manage/DataConfig';
  34. import { addRelateApp, getRelateIds } from '@/api/data-auth';
  35. import searchBar from '@/components/search-bar';
  36. import { searchOpt } from '@/mixins/page-opt';
  37. import newTable from '@/components/new-table';
  38. import _ from 'lodash';
  39. export default {
  40. name: 'add-dialog', // 组件名称
  41. props: {
  42. // 接收父组件的数据
  43. type: {
  44. type: String,
  45. default: 'application'
  46. },
  47. parentNode: Object
  48. },
  49. components: { searchBar, newTable }, // 注册局部组件
  50. mixins: [searchOpt],
  51. data() {
  52. // 组件内部参数
  53. return {
  54. // 参数名称及默认值
  55. cardFunctionList,
  56. cardAgencylist,
  57. tableUrl: appRestApi.table,
  58. otherParams: {
  59. attrBelongType: this.parentNode.attrBelongType,
  60. attrId: this.parentNode.id,
  61. attrType: 'OBJ'
  62. },
  63. appConditonForm2
  64. };
  65. },
  66. computed: {}, // 计算属性
  67. watch: {}, // 侦听器(扩展的计算属性)
  68. methods: {
  69. /**
  70. * 关闭
  71. */
  72. handleClose() {
  73. this.$emit('close');
  74. },
  75. /**
  76. * 添加
  77. */
  78. handleSave() {
  79. const params = {
  80. ...this.otherParams,
  81. relIds: this.$refs.table.newChooseArr.map((item) => item.id || item)
  82. };
  83. addRelateApp(params).then((res) => {
  84. this.$message.success('保存成功');
  85. this.$emit('success');
  86. });
  87. }
  88. },
  89. created() {
  90. },
  91. mounted() {
  92. getRelateIds(this.otherParams).then((res) => {
  93. this.$nextTick(() => {
  94. this.$refs.table.newChooseArr = res.data.content;
  95. })
  96. });
  97. }
  98. };
  99. </script>
  100. <style lang="scss" scoped></style>