UpdateOrgField.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <el-dialog
  3. :title="`更新${fieldObj[field]}`"
  4. :visible="visible"
  5. :width="dialogWidth"
  6. :close-on-click-modal="false"
  7. @close="handleClose"
  8. >
  9. <template v-if="['name'].includes(field)">
  10. <el-input v-model="stringValue" type="text" />
  11. </template>
  12. <template v-if="['memo'].includes(field)">
  13. <el-input v-model="stringValue" type="textarea" :autosize="{ minRows: 4 }" maxlength="1500" show-word-limit />
  14. </template>
  15. <template v-if="['use_end_date_book_edit', 'use_end_date_book_store'].includes(field)">
  16. <el-date-picker
  17. v-model="stringValue"
  18. type="date"
  19. placeholder="选择日期"
  20. format="yyyy-MM-dd"
  21. value-format="yyyy-MM-dd"
  22. />
  23. </template>
  24. <template v-if="['user_count_max', 'project_count_max', 'speech_engine_lave_can_use_count'].includes(field)">
  25. <el-input v-model="stringValue" type="number" />
  26. </template>
  27. <div slot="footer">
  28. <el-button @click="handleClose">取消</el-button>
  29. <el-button type="primary" @click="confirm">确定</el-button>
  30. </div>
  31. </el-dialog>
  32. </template>
  33. <script>
  34. export default {
  35. name: 'UpdateOrgField',
  36. props: {
  37. field: {
  38. type: String,
  39. required: true,
  40. },
  41. value: {
  42. type: [String, Number, Array, Object],
  43. required: true,
  44. },
  45. orgId: {
  46. type: String,
  47. required: true,
  48. },
  49. visible: {
  50. type: Boolean,
  51. default: false,
  52. },
  53. },
  54. data() {
  55. return {
  56. fieldObj: {
  57. name: '名称',
  58. user_count_max: '最大用户量',
  59. project_count_max: '最大项目量',
  60. speech_engine_lave_can_use_count: '语音引擎剩余可用次数',
  61. use_end_date_book_edit: '教材编辑使用期限',
  62. use_end_date_book_store: '教材仓库使用期限',
  63. memo: '备注',
  64. },
  65. stringValue: this.value,
  66. };
  67. },
  68. computed: {
  69. dialogWidth() {
  70. if (['use_end_date_book_edit', 'use_end_date_book_store'].includes(this.field)) {
  71. return '260px';
  72. }
  73. return '550px';
  74. },
  75. },
  76. watch: {
  77. value(newVal) {
  78. this.stringValue = newVal;
  79. if (['use_end_date_book_edit', 'use_end_date_book_store'].includes(this.field)) {
  80. const date = new Date();
  81. this.stringValue = newVal === '0-00-00' ? `${date.getFullYear()}-${date.getMonth()}-${date.getDay()}` : newVal;
  82. }
  83. },
  84. },
  85. methods: {
  86. handleClose() {
  87. this.$emit('update:visible', false);
  88. },
  89. confirm() {
  90. this.$emit('updateOrgFieldValue', this.field, this.stringValue);
  91. this.handleClose();
  92. },
  93. },
  94. };
  95. </script>
  96. <style lang="scss" scoped></style>