organizationMerge.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <m-dialog title="同级机构合并" ref="dialog" @sure="onSure">
  3. <m-form :items="formItems" v-model="formValues" v-loading="loading">
  4. <template #organizationName>
  5. <el-tag>{{ formValues.organizationName }}</el-tag>
  6. </template>
  7. </m-form>
  8. </m-dialog>
  9. </template>
  10. <script>
  11. import { getOrganizationByType, margeOrganization } from '@/api/system'
  12. export default {
  13. name: 'organizationMerge',
  14. data () {
  15. return {
  16. items: [],
  17. formValues: {},
  18. loading: false
  19. }
  20. },
  21. computed: {
  22. formItems () {
  23. return [
  24. {
  25. label: '当前机构',
  26. prop: 'organizationName'
  27. },
  28. {
  29. label: '目标机构',
  30. prop: 'slaveOrganizationNos',
  31. type: 'select',
  32. options: {
  33. filterable: true,
  34. placeholder: '请选择被合并的机构',
  35. multiple: true,
  36. items: this.items,
  37. labelText: 'organizationName',
  38. labelValue: 'organizationNo'
  39. }
  40. }
  41. ]
  42. }
  43. },
  44. methods: {
  45. async open (item) {
  46. this.formValues.organizationName = item.name
  47. this.formValues.masterOrganizationNo = item.value
  48. this.formValues.slaveOrganizationNos = []
  49. this.$refs.dialog.open()
  50. try {
  51. const { data } = await getOrganizationByType({
  52. entity: {
  53. organizationCategory: item.organization.organizationCategory
  54. },
  55. page: {
  56. current: 1,
  57. size: 1000
  58. }
  59. })
  60. this.items = data.records.filter(e => e.organizationNo !== item.value)
  61. } catch (error) {
  62. this.$message.error(error)
  63. } finally {
  64. this.loading = false
  65. }
  66. },
  67. async onSure () {
  68. this.loading = true
  69. const { masterOrganizationNo, slaveOrganizationNos } = this.formValues
  70. try {
  71. await margeOrganization({
  72. masterOrganizationNo,
  73. slaveOrganizationNos
  74. })
  75. this.$message.success('合并成功')
  76. this.$refs.dialog.close()
  77. this.$emit('refresh')
  78. } catch (error) {
  79. this.$message.error(error)
  80. } finally {
  81. this.loading = false
  82. }
  83. }
  84. }
  85. }
  86. </script>
  87. <style lang="scss" scoped>
  88. </style>