ExtraSettings.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <el-form ref="formRef" :model="modelData" label-width="120px" class="mt-20px">
  3. <el-form-item class="mb-20px">
  4. <template #label>
  5. <el-text size="large" tag="b">提交人权限</el-text>
  6. </template>
  7. <div class="flex flex-col">
  8. <el-checkbox v-model="modelData.allowCancelRunningProcess" label="允许撤销审批中的申请" />
  9. <div class="ml-22px">
  10. <el-text type="info"> 第一个审批节点通过后,提交人仍可撤销申请 </el-text>
  11. </div>
  12. </div>
  13. </el-form-item>
  14. <el-form-item v-if="modelData.processIdRule" class="mb-20px">
  15. <template #label>
  16. <el-text size="large" tag="b">流程编码</el-text>
  17. </template>
  18. <div class="flex flex-col">
  19. <div>
  20. <el-input
  21. v-model="modelData.processIdRule.prefix"
  22. class="w-130px!"
  23. placeholder="前缀"
  24. :disabled="!modelData.processIdRule.enable"
  25. >
  26. <template #prepend>
  27. <el-checkbox v-model="modelData.processIdRule.enable" />
  28. </template>
  29. </el-input>
  30. <el-select
  31. v-model="modelData.processIdRule.infix"
  32. class="w-130px! ml-5px"
  33. placeholder="中缀"
  34. :disabled="!modelData.processIdRule.enable"
  35. >
  36. <el-option
  37. v-for="item in timeOptions"
  38. :key="item.value"
  39. :label="item.label"
  40. :value="item.value"
  41. />
  42. </el-select>
  43. <el-input
  44. v-model="modelData.processIdRule.postfix"
  45. class="w-80px! ml-5px"
  46. placeholder="后缀"
  47. :disabled="!modelData.processIdRule.enable"
  48. />
  49. <el-input-number
  50. v-model="modelData.processIdRule.length"
  51. class="w-120px! ml-5px"
  52. :min="5"
  53. :disabled="!modelData.processIdRule.enable"
  54. />
  55. </div>
  56. <div class="ml-22px" v-if="modelData.processIdRule.enable">
  57. <el-text type="info"> 编码示例:{{ numberExample }} </el-text>
  58. </div>
  59. </div>
  60. </el-form-item>
  61. </el-form>
  62. </template>
  63. <script setup lang="ts">
  64. import dayjs from 'dayjs'
  65. const modelData = defineModel<any>()
  66. const timeOptions = ref([
  67. {
  68. value: 'NULL', // TODO @lesan:用 '' 会好会更好一点哈。
  69. label: '无'
  70. },
  71. {
  72. value: 'DAY',
  73. label: '精确到日'
  74. },
  75. {
  76. value: 'HOUR',
  77. label: '精确到时'
  78. },
  79. {
  80. value: 'MINUTE',
  81. label: '精确到分'
  82. },
  83. {
  84. value: 'SECOND',
  85. label: '精确到秒'
  86. }
  87. ])
  88. const numberExample = computed(() => {
  89. if (modelData.value.processIdRule.enable) {
  90. let infix = ''
  91. switch (modelData.value.processIdRule.infix) {
  92. case 'DAY':
  93. infix = dayjs().format('YYYYMMDD')
  94. break
  95. case 'HOUR':
  96. infix = dayjs().format('YYYYMMDDHH')
  97. break
  98. case 'MINUTE':
  99. infix = dayjs().format('YYYYMMDDHHmm')
  100. break
  101. case 'SECOND':
  102. infix = dayjs().format('YYYYMMDDHHmmss')
  103. break
  104. default:
  105. break
  106. }
  107. return (
  108. modelData.value.processIdRule.prefix +
  109. infix +
  110. modelData.value.processIdRule.postfix +
  111. '1'.padStart(modelData.value.processIdRule.length - 1, '0')
  112. )
  113. } else {
  114. return ''
  115. }
  116. })
  117. /** 兼容以前未配置更多设置的流程 */
  118. const initData = () => {
  119. if (!modelData.value.processIdRule) {
  120. modelData.value.processIdRule = {
  121. enable: false,
  122. prefix: '',
  123. infix: '',
  124. postfix: '',
  125. length: 5
  126. }
  127. }
  128. }
  129. defineExpose({ initData })
  130. </script>