form.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <m-dialog title="分润认领" ref="dialog" @sure="onSure">
  3. <m-form ref="form" :items="formItems" v-model="formValues" v-loading="loading"></m-form>
  4. </m-dialog>
  5. </template>
  6. <script>
  7. import { mapGetters } from 'vuex'
  8. export default {
  9. name: 'ClaimForm',
  10. data () {
  11. return {
  12. formValues: {
  13. serialNumber: null,
  14. unifiedCertificationNumber: null,
  15. organizationNo: null,
  16. employeeProfitSharingRatio: null
  17. },
  18. itemData: {},
  19. filterLoading: false,
  20. loading: false,
  21. items: []
  22. }
  23. },
  24. computed: {
  25. ...mapGetters(['organizationTree']),
  26. organizationItems () {
  27. if (this.organizationTree.length > 0) {
  28. return this.organizationTree[0].child
  29. }
  30. return []
  31. },
  32. formItems () {
  33. return [
  34. {
  35. label: '所属机构',
  36. prop: 'organizationNo',
  37. type: 'cascader',
  38. rules: [
  39. { required: true, message: '请选择所属机构', trigger: 'change' }
  40. ],
  41. options: {
  42. ref: 'organizationNo',
  43. filterable: true,
  44. clearable: true,
  45. placeholder: '请选择所属机构',
  46. options: this.organizationItems,
  47. showAllLevels: false,
  48. props: {
  49. emitPath: false,
  50. checkStrictly: true,
  51. value: 'organizationNo',
  52. label: 'organizationName',
  53. children: 'child'
  54. }
  55. },
  56. handles: {
  57. change: (v) => {
  58. const nodes = this.$refs.form.$refs.organizationNo.getCheckedNodes()
  59. console.log(nodes[0].data.organizationNo, '选中机构编码')
  60. // this.formValues.organizationNo = nodes[0].data.organizationNo
  61. // this.formValues.organizationName = nodes[0].data.organizationName
  62. }
  63. }
  64. },
  65. {
  66. label: '分润员工',
  67. prop: 'unifiedCertificationNumber',
  68. type: 'select',
  69. options: {
  70. placeholder: '请选择分润员工',
  71. filterable: true,
  72. remote: true,
  73. labelText: 'employeeName',
  74. labelValue: 'personnelCode',
  75. valueKey: 'personnelCode',
  76. defaultFirstOption: true,
  77. loading: this.filterLoading,
  78. items: []
  79. },
  80. // handles: {
  81. // change: (v) => {
  82. // const item = this.items.find(e => e.personnelCode === v)
  83. // this.formValues.employeeName = item.employeeName
  84. // this.formValues.employeeCode = item.personnelCode
  85. // }
  86. // },
  87. rules: [
  88. { required: true, message: '请选择分润员工', trigger: 'change' }
  89. ]
  90. }
  91. // employeeProfitSharingRatio
  92. ]
  93. }
  94. },
  95. methods: {
  96. async open (item) {
  97. console.log(item, '分润认领')
  98. this.loading = true
  99. this.$refs.dialog.open()
  100. // if (!item) {
  101. // this.itemData = {}
  102. // this.formValues = {
  103. // employeeCode: null,
  104. // employeeName: null,
  105. // organizationNo: null,
  106. // organizationName: null
  107. // }
  108. // } else {
  109. // await this.remoteMethod(item.employeeName)
  110. // this.itemData = item
  111. // this.formValues = {
  112. // employeeCode: item.employeeCode,
  113. // organizationName: item.organizationName,
  114. // organizationNo: item.organizationNo,
  115. // employeeName: item.employeeName
  116. // }
  117. // }
  118. this.formValues.serialNumber = item.serialNumber
  119. this.$nextTick(() => {
  120. this.$refs.form.clearValidate()
  121. this.loading = false
  122. })
  123. },
  124. onSure () {
  125. this.$refs.form.validate(async valid => {
  126. if (!valid) {
  127. return
  128. }
  129. console.log(this.formValues, 'submit')
  130. // this.loading = true
  131. // try {
  132. // await saveAllocationConfig({
  133. // performanceSalaryManageEmployeeId: this.itemData.performanceSalaryManageEmployeeId,
  134. // ...this.formValues
  135. // })
  136. // this.$refs.dialog.close()
  137. // this.$message.success('操作成功')
  138. // this.$emit('success')
  139. // } catch (error) {
  140. // this.$message.error(error)
  141. // } finally {
  142. // this.loading = false
  143. // }
  144. })
  145. }
  146. }
  147. }
  148. </script>
  149. <style lang="scss" scoped>
  150. </style>