xm-select-law-user-render.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <a-input v-bind="$attrs" :read-only="readOnly" @input="change" @click="selectDept" />
  3. </template>
  4. <script>
  5. import components from './_import-components/xm-select-law-user-render-import'
  6. import sdGroupPicker from '@/common/components/sd-group-picker.vue'
  7. import pickValues from '@/common/services/pick-values'
  8. export default {
  9. name: 'XmSelectLawUserRender',
  10. components,
  11. model: { prop: 'value', event: 'change' },
  12. props: {
  13. selectValue: {
  14. type: String,
  15. default: '',
  16. },
  17. },
  18. data() {
  19. return {
  20. readOnly: false,
  21. }
  22. },
  23. inject: {
  24. webflow: { default: () => {} },
  25. SdFormContext: { default: () => {} },
  26. },
  27. methods: {
  28. selectDept() {
  29. // 如果不是选择组织的值,则直接返回
  30. if (this.selectValue !== this.webflow.getFieldValue('OWNER_POSITION')) {
  31. this.readOnly = false
  32. return
  33. }
  34. this.readOnly = true
  35. pickValues(sdGroupPicker, {
  36. single: true,
  37. }).then((res) => {
  38. if (!res | (res && res.length === 0)) return
  39. this.SdFormContext.setFieldValue('USER_NAME', res[0].name)
  40. this.SdFormContext.setFieldValue('USER_CODE', res[0].code)
  41. this.SdFormContext.setFieldValue('USER_ID', res[0].code)
  42. this.SdFormContext.validateField('USER_NAME')
  43. })
  44. },
  45. change(e) {
  46. this.SdFormContext.setFieldValue('USER_NAME', e.target.value)
  47. this.SdFormContext.setFieldValue('USER_CODE', '')
  48. this.SdFormContext.setFieldValue('USER_ID', '')
  49. this.SdFormContext.validateField('USER_NAME')
  50. },
  51. },
  52. }
  53. </script>
  54. <style module lang="scss">
  55. @use '@/common/design' as *;
  56. .xmselinput {
  57. :global .ant-input {
  58. width: 70%;
  59. margin-right: 10px;
  60. }
  61. :global .ant-btn {
  62. width: auto;
  63. padding: 0 10px;
  64. }
  65. }
  66. </style>