add-appser-dialog.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <main class="add-dialog">
  3. <dg-row class="property-wapper">
  4. <!-- 搜索栏 -->
  5. <search-bar :conditionForm="conditionForm" @submitSearch="receiveSearch"></search-bar>
  6. <!-- 表格 -->
  7. <new-table
  8. ref="table"
  9. :selection="true"
  10. :tableHeader="tableHeader"
  11. :tableUrl="tableUrl[attrBelongType]"
  12. :condition="condition"
  13. @selection-change="handleSelectChange"
  14. >
  15. </new-table>
  16. </dg-row>
  17. <div v-footer>
  18. <dg-button @click="handleClose">取消</dg-button>
  19. <dg-button type="primary" @click="handleSave">保存</dg-button>
  20. </div>
  21. </main>
  22. </template>
  23. <script>
  24. import { relateSourceTableHeader, relateSourceCondition } from '../../auth-subject-manage/DataConfig';
  25. import { addAttrRelateSource, ObjNotRelAppTableUrl, ObjNotRelServiceTableUrl } from '@/api/data-auth';
  26. import searchBar from '@/components/search-bar';
  27. import { searchOpt } from '@/mixins/page-opt';
  28. import newTable from '@/components/new-table';
  29. export default {
  30. name: 'add-dialog',
  31. props: {
  32. attrBelongType: String,
  33. parentNode: Object
  34. },
  35. components: { searchBar, newTable },
  36. mixins: [searchOpt],
  37. data() {
  38. const vm = this;
  39. return {
  40. tableHeader: relateSourceTableHeader[vm.attrBelongType],
  41. tableUrl: {
  42. APP: ObjNotRelAppTableUrl,
  43. SER: ObjNotRelServiceTableUrl
  44. },
  45. conditionForm: [
  46. ...relateSourceCondition[vm.attrBelongType],
  47. {
  48. name: 'attrId',
  49. value: this.parentNode.id
  50. }
  51. ],
  52. condition: {
  53. attrId: {
  54. value: this.parentNode.id,
  55. op: '='
  56. }
  57. },
  58. selectList: []
  59. };
  60. },
  61. computed: {}, // 计算属性
  62. watch: {}, // 侦听器(扩展的计算属性)
  63. methods: {
  64. /**
  65. * 关闭
  66. */
  67. handleClose() {
  68. this.$emit('close');
  69. },
  70. handleSelectChange(selection) {
  71. this.selectList = this.$lodash.cloneDeep(selection);
  72. },
  73. /**
  74. * 添加
  75. */
  76. handleSave() {
  77. const params = {
  78. attrId: this.parentNode.id,
  79. relList: this.selectList.map((item) => {
  80. return {
  81. id: item.id,
  82. code: this.attrBelongType == 'APP' ? item.applyCode : item.serviceCode
  83. };
  84. })
  85. };
  86. addAttrRelateSource(params).then((res) => {
  87. this.$message.success('保存成功');
  88. this.$emit('success');
  89. });
  90. }
  91. },
  92. created() {},
  93. mounted() {
  94. }
  95. };
  96. </script>
  97. <style lang="scss" scoped></style>