risk-dept-sgtx-mixins.vue 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <script>
  2. import components from './_import-components/risk-dept-sgtx-mixins-import'
  3. export default {
  4. name: 'RiskDeptSgtxMixins',
  5. components,
  6. data() {
  7. return {
  8. // ======手动录入主送单位======
  9. ModalForm: {
  10. orgName: '', // 单位名称
  11. },
  12. currentEntryField: '', // 当前录入的表单字段
  13. ModalVisible: false,
  14. OrgNameData: [],
  15. flow: 'flow',
  16. }
  17. },
  18. methods: {
  19. // 手动录入按钮点击
  20. manualEntry(fieldName, flow) {
  21. this.ModalForm.orgName = ''
  22. this.currentEntryField = fieldName
  23. this.flow = flow
  24. this.ModalVisible = true
  25. },
  26. // 手动录入表单提交
  27. ModalHandleOk() {
  28. let flow = this.$refs[this.flow]
  29. if (flow.getFieldValue === undefined) {
  30. flow = flow.$refs.form
  31. }
  32. const mainSendOrgArr = flow.getFieldValue(this.currentEntryField)
  33. ? flow.getFieldValue(this.currentEntryField)
  34. : []
  35. const OrgName = this.ModalForm.orgName
  36. // 手工输入多个主送部门用逗号分隔开
  37. if (OrgName.includes(',') || OrgName.includes(',')) {
  38. const str = OrgName.split(/[,+,]/g)
  39. this.OrgNameData = []
  40. str.map((item) => {
  41. const sjs = Math.floor(Math.random() * 100000)
  42. this.OrgNameData.push({
  43. type: 'GROUP',
  44. name: item,
  45. text: item,
  46. code: sjs+"_sd",
  47. id: sjs+"_sd",
  48. attrNames: [],
  49. })
  50. })
  51. if (this.ModalForm.orgName.trim()) {
  52. // 去空格判断
  53. const newData = [...mainSendOrgArr, ...this.OrgNameData]
  54. flow.setFieldValue(this.currentEntryField, newData)
  55. flow.validateField(this.currentEntryField)
  56. if(this.changecompetentDept !== undefined && typeof this.changecompetentDept === 'function') this.changecompetentDept(newData)
  57. }
  58. } else {
  59. if (this.ModalForm.orgName.trim()) {
  60. const sjs = Math.floor(Math.random() * 100000)
  61. // 去空格判断
  62. const newData = [
  63. ...mainSendOrgArr,
  64. {
  65. type: 'GROUP',
  66. name: this.ModalForm.orgName.trim(),
  67. text: this.ModalForm.orgName.trim(),
  68. code: sjs+"_sd",
  69. id: sjs+"_sd",
  70. attrNames: [],
  71. },
  72. ]
  73. flow.setFieldValue(this.currentEntryField, newData)
  74. flow.validateField(this.currentEntryField)
  75. if(this.changecompetentDept !== undefined && typeof this.changecompetentDept === 'function') this.changecompetentDept(newData)
  76. }
  77. }
  78. this.ModalVisible = false
  79. },
  80. },
  81. }
  82. </script>