ReadOnly.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <a-form-item :label="$t('cloudenv.read_only')">
  3. <a-switch
  4. :checkedChildren="$t('cloudenv.text_84')"
  5. :unCheckedChildren="$t('cloudenv.text_85')"
  6. v-decorator="decorators.read_only" />
  7. <div slot="extra">
  8. {{ $t('cloudenv.read_only_extra') }}
  9. </div>
  10. </a-form-item>
  11. </template>
  12. <script>
  13. export default {
  14. name: 'ReadOnly',
  15. props: {
  16. checked: {
  17. type: Boolean,
  18. default: false,
  19. },
  20. form: {
  21. type: Object,
  22. },
  23. cloneData: {
  24. type: Object,
  25. default: () => ({}),
  26. },
  27. },
  28. data () {
  29. return {
  30. decorators: {
  31. read_only: [
  32. 'read_only',
  33. {
  34. initialValue: this.cloneData.read_only || false,
  35. valuePropName: 'checked',
  36. },
  37. ],
  38. },
  39. }
  40. },
  41. watch: {
  42. checked: {
  43. handler: function (val) {
  44. this.$nextTick(() => {
  45. if (this.form) {
  46. this.form.fc.setFieldsValue({
  47. read_only: val,
  48. })
  49. }
  50. })
  51. },
  52. immediate: true,
  53. },
  54. },
  55. }
  56. </script>