Commit 8ef9f69cc132b9eb773f4e6577a39af111c64cdb

Authored by zhangdaiscott
1 parent 2e22880e

JSelectBizComponent columns 建议开放customRender等方法类配置 #3203

定时任务表达式,”星期“一栏错误 issues/I4IFWX
ant-design-vue-jeecg/src/components/jeecg/JEasyCron/EasyCron.vue
... ... @@ -144,8 +144,12 @@ export default {
144 144 const v = this.cronValue_c
145 145 if (this.hideYear || this.hideSecond) return v
146 146 const vs = v.split(' ')
  147 + if (vs.length >= 6) {
  148 + // 转成 Quartz 的规则
  149 + vs[5] = this.convertWeekToQuartz(vs[5])
  150 + }
147 151 return vs.slice(0, vs.length - 1).join(' ')
148   - }
  152 + },
149 153 },
150 154 watch: {
151 155 cronValue(newVal, oldVal) {
... ... @@ -226,6 +230,37 @@ export default {
226 230 if (values.length > i) this.year = values[i]
227 231 this.assignInput()
228 232 },
  233 + // Quartz 的规则:
  234 + // 1 = 周日,2 = 周一,3 = 周二,4 = 周三,5 = 周四,6 = 周五,7 = 周六
  235 + convertWeekToQuartz(week) {
  236 + let convert = (v) => {
  237 + if (v === '0') {
  238 + return '1'
  239 + }
  240 + if (v === '1') {
  241 + return '0'
  242 + }
  243 + return (Number.parseInt(v) - 1).toString()
  244 + }
  245 + // 匹配示例 1-7 or 1/7
  246 + let patten1 = /^([0-7])([-/])([0-7])$/
  247 + // 匹配示例 1,4,7
  248 + let patten2 = /^([0-7])(,[0-7])+$/
  249 + if (/^[0-7]$/.test(week)) {
  250 + return convert(week)
  251 + } else if (patten1.test(week)) {
  252 + return week.replace(patten1, ($0, before, separator, after) => {
  253 + if (separator === '/') {
  254 + return convert(before) + separator + after
  255 + } else {
  256 + return convert(before) + separator + convert(after)
  257 + }
  258 + })
  259 + } else if (patten2.test(week)) {
  260 + return week.split(',').map(v => convert(v)).join(',')
  261 + }
  262 + return week
  263 + },
229 264 calTriggerList: simpleDebounce(function () {
230 265 this.calTriggerListInner()
231 266 }, 500),
... ...
ant-design-vue-jeecg/src/components/jeecg/JEasyCron/tabs/week.vue
... ... @@ -51,14 +51,14 @@ import mixin from './mixin'
51 51 import { replaceWeekName, WEEK_MAP_EN } from './const.js'
52 52  
53 53 const WEEK_MAP = {
54   - '周一': 1,
55   - '周二': 2,
56   - '周三': 3,
57   - '周四': 4,
58   - '周五': 5,
59   - '周六': 6,
  54 + '周一': 2,
  55 + '周二': 3,
  56 + '周三': 4,
  57 + '周四': 5,
  58 + '周五': 6,
  59 + '周六': 7,
60 60 // 按照国人习惯,将周日放到每周的最后一天
61   - '周日': 7,
  61 + '周日': 1,
62 62 }
63 63  
64 64 export default {
... ...
ant-design-vue-jeecg/src/components/jeecgbiz/JSelectBizComponent/JSelectBizComponentModal.vue
... ... @@ -62,8 +62,9 @@
62 62 import { getAction } from '@/api/manage'
63 63 import Ellipsis from '@/components/Ellipsis'
64 64 import { JeecgListMixin } from '@/mixins/JeecgListMixin'
65   - import { cloneObject, pushIfNotExist } from '@/utils/util'
  65 + import { pushIfNotExist } from '@/utils/util'
66 66 import JSelectBizQueryItem from './JSelectBizQueryItem'
  67 + import {cloneDeep} from 'lodash'
67 68  
68 69 export default {
69 70 name: 'JSelectBizComponentModal',
... ... @@ -177,11 +178,24 @@
177 178 computed: {
178 179 // 表头
179 180 innerColumns() {
180   - let columns = cloneObject(this.columns)
  181 + let columns = cloneDeep(this.columns)
181 182 columns.forEach(column => {
182 183 // 给所有的列加上过长裁剪
183 184 if (this.ellipsisLength !== -1) {
184   - column.customRender = (text) => this.renderEllipsis(text)
  185 + // JSelectBizComponent columns 建议开放customRender等方法类配置
  186 + // https://github.com/jeecgboot/jeecg-boot/issues/3203
  187 + let myCustomRender = column.customRender
  188 + column.customRender = (text, record, index) => {
  189 + let value = text
  190 + if (typeof myCustomRender === 'function') {
  191 + // noinspection JSVoidFunctionReturnValueUsed
  192 + value = myCustomRender(text, record, index)
  193 + }
  194 + if (typeof value === 'string') {
  195 + return this.renderEllipsis(value)
  196 + }
  197 + return value
  198 + }
185 199 }
186 200 })
187 201 return columns
... ... @@ -192,7 +206,7 @@
192 206 deep: true,
193 207 immediate: true,
194 208 handler(val) {
195   - this.innerValue = cloneObject(val)
  209 + this.innerValue = cloneDeep(val)
196 210 this.selectedRowKeys = []
197 211 this.valueWatchHandler(val)
198 212 this.queryOptionsByValue(val)
... ...