427e8c911bcec44f83dd65a2b9184b1c40c3e9ec.svn-base 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928
  1. <template>
  2. <a-modal
  3. title="cron表达式"
  4. :width="modalWidth"
  5. :visible="visible"
  6. :confirmLoading="confirmLoading"
  7. @ok="handleSubmit"
  8. @cancel="close"
  9. cancelText="关闭">
  10. <div class="card-container">
  11. <a-tabs type="card">
  12. <a-tab-pane key="1" type="card">
  13. <span slot="tab"><a-icon type="schedule" /> 秒</span>
  14. <a-radio-group v-model="result.second.cronEvery">
  15. <a-row>
  16. <a-radio value="1">每一秒钟</a-radio>
  17. </a-row>
  18. <a-row>
  19. <a-radio value="2">每隔
  20. <a-input-number size="small" v-model="result.second.incrementIncrement" :min="1" :max="59"></a-input-number>
  21. 秒执行 从
  22. <a-input-number size="small" v-model="result.second.incrementStart" :min="0" :max="59"></a-input-number>
  23. 秒开始
  24. </a-radio>
  25. </a-row>
  26. <a-row>
  27. <a-radio value="3">具体秒数(可多选)</a-radio>
  28. <a-select style="width:354px;" size="small" mode="multiple" v-model="result.second.specificSpecific">
  29. <a-select-option v-for="(val,index) in 60" :key="index" :value="index">{{ index }}</a-select-option>
  30. </a-select>
  31. </a-row>
  32. <a-row>
  33. <a-radio value="4">周期从
  34. <a-input-number size="small" v-model="result.second.rangeStart" :min="1" :max="59"></a-input-number>
  35. 到
  36. <a-input-number size="small" v-model="result.second.rangeEnd" :min="0" :max="59"></a-input-number>
  37. 秒
  38. </a-radio>
  39. </a-row>
  40. </a-radio-group>
  41. </a-tab-pane>
  42. <a-tab-pane key="2">
  43. <span slot="tab"><a-icon type="schedule" />分</span>
  44. <div class="tabBody">
  45. <a-radio-group v-model="result.minute.cronEvery">
  46. <a-row>
  47. <a-radio value="1">每一分钟</a-radio>
  48. </a-row>
  49. <a-row>
  50. <a-radio value="2">每隔
  51. <a-input-number size="small" v-model="result.minute.incrementIncrement" :min="1" :max="60"></a-input-number>
  52. 分执行 从
  53. <a-input-number size="small" v-model="result.minute.incrementStart" :min="0" :max="59"></a-input-number>
  54. 分开始
  55. </a-radio>
  56. </a-row>
  57. <a-row>
  58. <a-radio value="3">具体分钟数(可多选)</a-radio>
  59. <a-select style="width:340px;" size="small" mode="multiple" v-model="result.minute.specificSpecific">
  60. <a-select-option v-for="(val,index) in Array(60)" :key="index" :value="index"> {{ index }}</a-select-option>
  61. </a-select>
  62. </a-row>
  63. <a-row>
  64. <a-radio value="4">周期从
  65. <a-input-number size="small" v-model="result.minute.rangeStart" :min="1" :max="60"></a-input-number>
  66. 到
  67. <a-input-number size="small" v-model="result.minute.rangeEnd" :min="0" :max="59"></a-input-number>
  68. 分
  69. </a-radio>
  70. </a-row>
  71. </a-radio-group>
  72. </div>
  73. </a-tab-pane>
  74. <a-tab-pane key="3">
  75. <span slot="tab"><a-icon type="schedule" /> 时</span>
  76. <div class="tabBody">
  77. <a-radio-group v-model="result.hour.cronEvery">
  78. <a-row>
  79. <a-radio value="1">每一小时</a-radio>
  80. </a-row>
  81. <a-row>
  82. <a-radio value="2">每隔
  83. <a-input-number size="small" v-model="result.hour.incrementIncrement" :min="0" :max="23"></a-input-number>
  84. 小时执行 从
  85. <a-input-number size="small" v-model="result.hour.incrementStart" :min="0" :max="23"></a-input-number>
  86. 小时开始
  87. </a-radio>
  88. </a-row>
  89. <a-row>
  90. <a-radio class="long" value="3">具体小时数(可多选)</a-radio>
  91. <a-select style="width:340px;" size="small" mode="multiple" v-model="result.hour.specificSpecific">
  92. <a-select-option v-for="(val,index) in Array(24)" :key="index" >{{ index }}</a-select-option>
  93. </a-select>
  94. </a-row>
  95. <a-row>
  96. <a-radio value="4">周期从
  97. <a-input-number size="small" v-model="result.hour.rangeStart" :min="0" :max="23"></a-input-number>
  98. 到
  99. <a-input-number size="small" v-model="result.hour.rangeEnd" :min="0" :max="23"></a-input-number>
  100. 小时
  101. </a-radio>
  102. </a-row>
  103. </a-radio-group>
  104. </div>
  105. </a-tab-pane>
  106. <a-tab-pane key="4">
  107. <span slot="tab"><a-icon type="schedule" /> 天</span>
  108. <div class="tabBody">
  109. <a-radio-group v-model="result.day.cronEvery">
  110. <a-row>
  111. <a-radio value="1">每一天</a-radio>
  112. </a-row>
  113. <a-row>
  114. <a-radio value="2">每隔
  115. <a-input-number size="small" v-model="result.week.incrementIncrement" :min="1" :max="7"></a-input-number>
  116. 周执行 从
  117. <a-select size="small" v-model="result.week.incrementStart">
  118. <a-select-option v-for="(val,index) in Array(7)" :key="index" :value="index+1">{{ weekDays[index] }}</a-select-option>
  119. </a-select>
  120. 开始
  121. </a-radio>
  122. </a-row>
  123. <a-row>
  124. <a-radio value="3">每隔
  125. <a-input-number size="small" v-model="result.day.incrementIncrement" :min="1" :max="31"></a-input-number>
  126. 天执行 从
  127. <a-input-number size="small" v-model="result.day.incrementStart" :min="1" :max="31"></a-input-number>
  128. 天开始
  129. </a-radio>
  130. </a-row>
  131. <a-row>
  132. <a-radio class="long" value="4">具体星期几(可多选)</a-radio>
  133. <a-select style="width:340px;" size="small" mode="multiple" v-model="result.week.specificSpecific">
  134. <a-select-option v-for="(val,index) in Array(7)" :key="index" :value="index+1">{{ weekDays[index] }}</a-select-option>
  135. </a-select>
  136. </a-row>
  137. <a-row>
  138. <a-radio class="long" value="5">具体天数(可多选)</a-radio>
  139. <a-select style="width:354px;" size="small" mode="multiple" v-model="result.day.specificSpecific">
  140. <a-select-option v-for="(val,index) in Array(31)" :key="index" :value="index+1">{{ index+1 }}</a-select-option>
  141. </a-select>
  142. </a-row>
  143. <a-row>
  144. <a-radio value="6">在这个月的最后一天</a-radio>
  145. </a-row>
  146. <a-row>
  147. <a-radio value="7">在这个月的最后一个工作日</a-radio>
  148. </a-row>
  149. <a-row>
  150. <a-radio value="8">在这个月的最后一个
  151. <a-select size="small" v-model="result.day.cronLastSpecificDomDay">
  152. <a-select-option v-for="(val,index) in Array(7)" :key="index" :value="index+1">{{ weekDays[index] }}</a-select-option>
  153. </a-select>
  154. </a-radio>
  155. </a-row>
  156. <a-row>
  157. <a-radio value="9">
  158. 在本月底前
  159. <a-input-number size="small" v-model="result.day.cronDaysBeforeEomMinus" :min="1" :max="31"></a-input-number>
  160. 天
  161. </a-radio>
  162. </a-row>
  163. <a-row>
  164. <a-radio value="10">最近的工作日(周一至周五)至本月
  165. <a-input-number size="small" v-model="result.day.cronDaysNearestWeekday" :min="1" :max="31"></a-input-number>
  166. 日
  167. </a-radio>
  168. </a-row>
  169. <a-row>
  170. <a-radio value="11">在这个月的第
  171. <a-input-number size="small" v-model="result.week.cronNthDayNth" :min="1" :max="5"></a-input-number>
  172. 个
  173. <a-select size="small" v-model="result.week.cronNthDayDay">
  174. <a-select-option v-for="(val,index) in Array(7)" :key="index" :value="index+1">{{ weekDays[index] }}</a-select-option>
  175. </a-select>
  176. </a-radio>
  177. </a-row>
  178. </a-radio-group>
  179. </div>
  180. </a-tab-pane>
  181. <a-tab-pane key="5">
  182. <span slot="tab"><a-icon type="schedule" /> 月</span>
  183. <div class="tabBody">
  184. <a-radio-group v-model="result.month.cronEvery">
  185. <a-row>
  186. <a-radio value="1">每一月</a-radio>
  187. </a-row>
  188. <a-row>
  189. <a-radio value="2">每隔
  190. <a-input-number size="small" v-model="result.month.incrementIncrement" :min="0" :max="12"></a-input-number>
  191. 月执行 从
  192. <a-input-number size="small" v-model="result.month.incrementStart" :min="0" :max="12"></a-input-number>
  193. 月开始
  194. </a-radio>
  195. </a-row>
  196. <a-row>
  197. <a-radio class="long" value="3">具体月数(可多选)</a-radio>
  198. <a-select style="width:354px;" size="small" filterable mode="multiple" v-model="result.month.specificSpecific">
  199. <a-select-option v-for="(val,index) in Array(12)" :key="index" :value="index+1">{{ index+1 }}</a-select-option>
  200. </a-select>
  201. </a-row>
  202. <a-row>
  203. <a-radio value="4">从
  204. <a-input-number size="small" v-model="result.month.rangeStart" :min="1" :max="12"></a-input-number>
  205. 到
  206. <a-input-number size="small" v-model="result.month.rangeEnd" :min="1" :max="12"></a-input-number>
  207. 月之间的每个月
  208. </a-radio>
  209. </a-row>
  210. </a-radio-group>
  211. </div>
  212. </a-tab-pane>
  213. <a-tab-pane key="6">
  214. <span slot="tab"><a-icon type="schedule" /> 年</span>
  215. <div class="tabBody">
  216. <a-radio-group v-model="result.year.cronEvery">
  217. <a-row>
  218. <a-radio value="1">每一年</a-radio>
  219. </a-row>
  220. <a-row>
  221. <a-radio value="2">每隔
  222. <a-input-number size="small" v-model="result.year.incrementIncrement" :min="1" :max="99"></a-input-number>
  223. 年执行 从
  224. <a-input-number size="small" v-model="result.year.incrementStart" :min="2019" :max="2119"></a-input-number>
  225. 年开始
  226. </a-radio>
  227. </a-row>
  228. <a-row>
  229. <a-radio class="long" value="3">具体年份(可多选)</a-radio>
  230. <a-select style="width:354px;" size="small" filterable mode="multiple" v-model="result.year.specificSpecific">
  231. <a-select-option v-for="(val,index) in Array(100)" :key="index" :value="2019+index">{{ 2019+index }}</a-select-option>
  232. </a-select>
  233. </a-row>
  234. <a-row>
  235. <a-radio value="4">从
  236. <a-input-number size="small" v-model="result.year.rangeStart" :min="2019" :max="2119"></a-input-number>
  237. 到
  238. <a-input-number size="small" v-model="result.year.rangeEnd" :min="2019" :max="2119"></a-input-number>
  239. 年之间的每一年
  240. </a-radio>
  241. </a-row>
  242. </a-radio-group>
  243. </div>
  244. </a-tab-pane>
  245. </a-tabs>
  246. <div class="bottom">
  247. <span class="value">{{this.cron }}</span>
  248. </div>
  249. </div>
  250. </a-modal>
  251. </template>
  252. <script>
  253. export default {
  254. name:'VueCron',
  255. props:['data'],
  256. data(){
  257. return {
  258. visible: false,
  259. confirmLoading:false,
  260. size:'large',
  261. weekDays:['天','一','二','三','四','五','六'].map(val=>'星期'+val),
  262. result: {
  263. second:{},
  264. minute:{},
  265. hour:{},
  266. day:{},
  267. week:{},
  268. month:{},
  269. year:{}
  270. },
  271. defaultValue: {
  272. second:{
  273. cronEvery:'',
  274. incrementStart:3,
  275. incrementIncrement:5,
  276. rangeStart:1,
  277. rangeEnd:0,
  278. specificSpecific:[],
  279. },
  280. minute:{
  281. cronEvery:'',
  282. incrementStart:3,
  283. incrementIncrement:5,
  284. rangeStart:1,
  285. rangeEnd:'0',
  286. specificSpecific:[],
  287. },
  288. hour:{
  289. cronEvery:'',
  290. incrementStart:3,
  291. incrementIncrement:5,
  292. rangeStart:'0',
  293. rangeEnd:'0',
  294. specificSpecific:[],
  295. },
  296. day:{
  297. cronEvery:'',
  298. incrementStart:1,
  299. incrementIncrement:'1',
  300. rangeStart:'',
  301. rangeEnd:'',
  302. specificSpecific:[],
  303. cronLastSpecificDomDay:1,
  304. cronDaysBeforeEomMinus:1,
  305. cronDaysNearestWeekday:1,
  306. },
  307. week:{
  308. cronEvery:'',
  309. incrementStart:1,
  310. incrementIncrement:1,
  311. specificSpecific:[],
  312. cronNthDayDay:1,
  313. cronNthDayNth:1,
  314. },
  315. month:{
  316. cronEvery:'',
  317. incrementStart:3,
  318. incrementIncrement:5,
  319. rangeStart:1,
  320. rangeEnd:1,
  321. specificSpecific:[],
  322. },
  323. year:{
  324. cronEvery:'',
  325. incrementStart:2017,
  326. incrementIncrement:1,
  327. rangeStart:2019,
  328. rangeEnd: 2019,
  329. specificSpecific:[],
  330. },
  331. label:''
  332. }
  333. }
  334. },
  335. computed: {
  336. modalWidth(){
  337. return 608;
  338. },
  339. secondsText() {
  340. let seconds = '';
  341. let cronEvery=this.result.second.cronEvery||'';
  342. switch (cronEvery.toString()){
  343. case '1':
  344. seconds = '*';
  345. break;
  346. case '2':
  347. seconds = this.result.second.incrementStart+'/'+this.result.second.incrementIncrement;
  348. break;
  349. case '3':
  350. this.result.second.specificSpecific.map(val=> {seconds += val+','});
  351. seconds = seconds.slice(0, -1);
  352. break;
  353. case '4':
  354. seconds = this.result.second.rangeStart+'-'+this.result.second.rangeEnd;
  355. break;
  356. }
  357. return seconds;
  358. },
  359. minutesText() {
  360. let minutes = '';
  361. let cronEvery=this.result.minute.cronEvery||'';
  362. switch (cronEvery.toString()){
  363. case '1':
  364. minutes = '*';
  365. break;
  366. case '2':
  367. minutes = this.result.minute.incrementStart+'/'+this.result.minute.incrementIncrement;
  368. break;
  369. case '3':
  370. this.result.minute.specificSpecific.map(val=> {
  371. minutes += val+','
  372. });
  373. minutes = minutes.slice(0, -1);
  374. break;
  375. case '4':
  376. minutes = this.result.minute.rangeStart+'-'+this.result.minute.rangeEnd;
  377. break;
  378. }
  379. return minutes;
  380. },
  381. hoursText() {
  382. let hours = '';
  383. let cronEvery=this.result.hour.cronEvery||'';
  384. switch (cronEvery.toString()){
  385. case '1':
  386. hours = '*';
  387. break;
  388. case '2':
  389. hours = this.result.hour.incrementStart+'/'+this.result.hour.incrementIncrement;
  390. break;
  391. case '3':
  392. this.result.hour.specificSpecific.map(val=> {
  393. hours += val+','
  394. });
  395. hours = hours.slice(0, -1);
  396. break;
  397. case '4':
  398. hours = this.result.hour.rangeStart+'-'+this.result.hour.rangeEnd;
  399. break;
  400. }
  401. return hours;
  402. },
  403. daysText() {
  404. let days='';
  405. let cronEvery=this.result.day.cronEvery||'';
  406. switch (cronEvery.toString()){
  407. case '1':
  408. break;
  409. case '2':
  410. case '4':
  411. case '11':
  412. days = '?';
  413. break;
  414. case '3':
  415. days = this.result.day.incrementStart+'/'+this.result.day.incrementIncrement;
  416. break;
  417. case '5':
  418. this.result.day.specificSpecific.map(val=> {
  419. days += val+','
  420. });
  421. days = days.slice(0, -1);
  422. break;
  423. case '6':
  424. days = "L";
  425. break;
  426. case '7':
  427. days = "LW";
  428. break;
  429. case '8':
  430. days = this.result.day.cronLastSpecificDomDay + 'L';
  431. break;
  432. case '9':
  433. days = 'L-' + this.result.day.cronDaysBeforeEomMinus;
  434. break;
  435. case '10':
  436. days = this.result.day.cronDaysNearestWeekday+"W";
  437. break
  438. }
  439. return days;
  440. },
  441. weeksText() {
  442. let weeks = '';
  443. let cronEvery=this.result.day.cronEvery||'';
  444. switch (cronEvery.toString()){
  445. case '1':
  446. case '3':
  447. case '5':
  448. weeks = '?';
  449. break;
  450. case '2':
  451. weeks = this.result.week.incrementStart+'/'+this.result.week.incrementIncrement;
  452. break;
  453. case '4':
  454. this.result.week.specificSpecific.map(val=> {
  455. weeks += val+','
  456. });
  457. weeks = weeks.slice(0, -1);
  458. break;
  459. case '6':
  460. case '7':
  461. case '8':
  462. case '9':
  463. case '10':
  464. weeks = "?";
  465. break;
  466. case '11':
  467. weeks = this.result.week.cronNthDayDay+"#"+this.result.week.cronNthDayNth;
  468. break;
  469. }
  470. return weeks;
  471. },
  472. monthsText() {
  473. let months = '';
  474. let cronEvery=this.result.month.cronEvery||'';
  475. switch (cronEvery.toString()){
  476. case '1':
  477. months = '*';
  478. break;
  479. case '2':
  480. months = this.result.month.incrementStart+'/'+this.result.month.incrementIncrement;
  481. break;
  482. case '3':
  483. this.result.month.specificSpecific.map(val=> {
  484. months += val+','
  485. });
  486. months = months.slice(0, -1);
  487. break;
  488. case '4':
  489. months = this.result.month.rangeStart+'-'+this.result.month.rangeEnd;
  490. break;
  491. }
  492. return months;
  493. },
  494. yearsText() {
  495. let years = '';
  496. let cronEvery=this.result.year.cronEvery||'';
  497. switch (cronEvery.toString()){
  498. case '1':
  499. years = '*';
  500. break;
  501. case '2':
  502. years = this.result.year.incrementStart+'/'+this.result.year.incrementIncrement;
  503. break;
  504. case '3':
  505. this.result.year.specificSpecific.map(val=> {
  506. years += val+','
  507. });
  508. years = years.slice(0, -1);
  509. break;
  510. case '4':
  511. years = this.result.year.rangeStart+'-'+this.result.year.rangeEnd;
  512. break;
  513. }
  514. return years;
  515. },
  516. cron(){
  517. return `${this.secondsText||'*'} ${this.minutesText||'*'} ${this.hoursText||'*'} ${this.daysText||'*'} ${this.monthsText||'*'} ${this.weeksText||'?'} ${this.yearsText||'*'}`
  518. },
  519. },
  520. watch:{
  521. visible:{
  522. handler() {
  523. // if(this.data){
  524. // //this. result = Object.keys(this.data.value).length>0?this.deepCopy(this.data.value):this.deepCopy(this.defaultValue);
  525. // //this.result = Object.keys(this.data.value).length>0?clone(this.data.value):clone(this.defaultValue);
  526. // //this.result = Object.keys(this.data.value).length>0?clone(JSON.parse(this.data.value)):clone(this.defaultValue);
  527. // this.result = Object.keys(this.data.value).length>0?JSON.parse(this.data.value):JSON.parse(JSON.stringify(this.defaultValue));
  528. // }else{
  529. // //this.result = this.deepCopy(this.defaultValue);
  530. // //this.result = clone(this.defaultValue);
  531. // this.result = JSON.parse(JSON.stringify(this.defaultValue));
  532. // }
  533. let label = this.data;
  534. if(label){
  535. this.secondsReverseExp(label)
  536. this.minutesReverseExp(label);
  537. this.hoursReverseExp(label);
  538. this.daysReverseExp(label);
  539. this.daysReverseExp(label);
  540. this.monthsReverseExp(label);
  541. this.yearReverseExp(label);
  542. JSON.parse(JSON.stringify(label));
  543. }else {
  544. this.result = JSON.parse(JSON.stringify(this.defaultValue));
  545. }
  546. }
  547. }
  548. },
  549. methods: {
  550. show(){
  551. this.visible = true;
  552. // console.log('secondsReverseExp',this.secondsReverseExp(this.data));
  553. // console.log('minutesReverseExp',this.minutesReverseExp(this.data));
  554. // console.log('hoursReverseExp',this.hoursReverseExp(this.data));
  555. // console.log('daysReverseExp',this.daysReverseExp(this.data));
  556. // console.log('monthsReverseExp',this.monthsReverseExp(this.data));
  557. // console.log('yearReverseExp',this.yearReverseExp(this.data));
  558. },
  559. handleSubmit(){
  560. this.$emit('ok',this.cron);
  561. this.close();
  562. this.visible = false;
  563. },
  564. close(){
  565. this.visible = false;
  566. },
  567. secondsReverseExp(seconds) {
  568. let val = seconds.split(" ")[0];
  569. //alert(val);
  570. let second = {
  571. cronEvery:'',
  572. incrementStart:3,
  573. incrementIncrement:5,
  574. rangeStart:1,
  575. rangeEnd:0,
  576. specificSpecific:[]
  577. };
  578. switch (true) {
  579. case val.includes('*'):
  580. second.cronEvery = '1';
  581. break;
  582. case val.includes('/'):
  583. second.cronEvery = '2';
  584. second.incrementStart = val.split('/')[0];
  585. second.incrementIncrement = val.split('/')[1];
  586. break;
  587. case val.includes(','):
  588. second.cronEvery = '3';
  589. second.specificSpecific = val.split(',').map(Number).sort();
  590. break;
  591. case val.includes('-'):
  592. second.cronEvery = '4';
  593. second.rangeStart = val.split('-')[0];
  594. second.rangeEnd = val.split('-')[1];
  595. break;
  596. default:
  597. second.cronEvery = '1';
  598. }
  599. this.result.second = second;
  600. },
  601. minutesReverseExp(minutes) {
  602. let val = minutes.split(" ")[1];
  603. let minute = {
  604. cronEvery:'',
  605. incrementStart:3,
  606. incrementIncrement:5,
  607. rangeStart:1,
  608. rangeEnd:0,
  609. specificSpecific:[],
  610. }
  611. switch (true) {
  612. case val.includes('*'):
  613. minute.cronEvery = '1';
  614. break;
  615. case val.includes('/'):
  616. minute.cronEvery = '2';
  617. minute.incrementStart = val.split('/')[0];
  618. minute.incrementIncrement = val.split('/')[1];
  619. break;
  620. case val.includes(','):
  621. minute.cronEvery = '3';
  622. minute.specificSpecific = val.split(',').map(Number).sort();
  623. break;
  624. case val.includes('-'):
  625. minute.cronEvery = '4';
  626. minute.rangeStart = val.split('-')[0];
  627. minute.rangeEnd = val.split('-')[1];
  628. break;
  629. default:
  630. minute.cronEvery = '1';
  631. }
  632. this.result.minute = minute;
  633. },
  634. hoursReverseExp(hours) {
  635. let val = hours.split(" ")[2];
  636. let hour ={
  637. cronEvery:'',
  638. incrementStart:3,
  639. incrementIncrement:5,
  640. rangeStart:1,
  641. rangeEnd:'0',
  642. specificSpecific:[],
  643. };
  644. switch (true) {
  645. case val.includes('*'):
  646. hour.cronEvery = '1';
  647. break;
  648. case val.includes('/'):
  649. hour.cronEvery = '2';
  650. hour.incrementStart = val.split('/')[0];
  651. hour.incrementIncrement = val.split('/')[1];
  652. break;
  653. case val.includes(','):
  654. hour.cronEvery = '3';
  655. hour.specificSpecific = val.split(',').map(Number).sort();
  656. break;
  657. case val.includes('-'):
  658. hour.cronEvery = '4';
  659. hour.rangeStart = val.split('-')[0];
  660. hour.rangeEnd = val.split('-')[1];
  661. break;
  662. default:
  663. hour.cronEvery = '1';
  664. }
  665. this.result.hour = hour;
  666. },
  667. daysReverseExp(cron) {
  668. let days = cron.split(" ")[3];
  669. let weeks = cron.split(" ")[5];
  670. let day ={
  671. cronEvery:'',
  672. incrementStart:1,
  673. incrementIncrement:1,
  674. rangeStart:1,
  675. rangeEnd:1,
  676. specificSpecific:[],
  677. cronLastSpecificDomDay:1,
  678. cronDaysBeforeEomMinus:1,
  679. cronDaysNearestWeekday:1,
  680. };
  681. let week = {
  682. cronEvery:'',
  683. incrementStart:1,
  684. incrementIncrement:1,
  685. specificSpecific:[],
  686. cronNthDayDay:1,
  687. cronNthDayNth:'1',
  688. };
  689. if (!days.includes('?')) {
  690. switch (true) {
  691. case days.includes('*'):
  692. day.cronEvery = '1';
  693. break;
  694. case days.includes('?'):
  695. // 2、4、11
  696. break;
  697. case days.includes('/'):
  698. day.cronEvery = '3';
  699. day.incrementStart = days.split('/')[0];
  700. day.incrementIncrement = days.split('/')[1];
  701. break;
  702. case days.includes(','):
  703. day.cronEvery = '5';
  704. day.specificSpecific = days.split(',').map(Number).sort();
  705. // day.specificSpecific.forEach(function (value, index) {
  706. // day.specificSpecific[index] = value -1;
  707. // });
  708. break;
  709. case days.includes('LW'):
  710. day.cronEvery = '7';
  711. break;
  712. case days.includes('L-'):
  713. day.cronEvery = '9';
  714. day.cronDaysBeforeEomMinus = days.split('L-')[1];
  715. break;
  716. case days.includes('L'):
  717. //alert(days);
  718. if(days.len == 1){
  719. day.cronEvery = '6';
  720. day.cronLastSpecificDomDay = '1';
  721. }
  722. else
  723. {
  724. day.cronEvery = '8';
  725. day.cronLastSpecificDomDay = Number(days.split('L')[0]);
  726. }
  727. break;
  728. case days.includes('W'):
  729. day.cronEvery = '10';
  730. day.cronDaysNearestWeekday = days.split('W')[0];
  731. break;
  732. default:
  733. day.cronEvery = '1';
  734. }
  735. }else {
  736. switch (true){
  737. case weeks.includes('/'):
  738. day.cronEvery = '2';
  739. week.incrementStart = weeks.split("/")[0];
  740. week.incrementIncrement = weeks.split("/")[1];
  741. break;
  742. case weeks.includes(','):
  743. day.cronEvery = '4';
  744. week.specificSpecific = weeks.split(',').map(Number).sort();
  745. break;
  746. case '#':
  747. day.cronEvery = '11';
  748. week.cronNthDayDay = weeks.split("#")[0];
  749. week.cronNthDayNth = weeks.split("#")[1];
  750. break;
  751. default:
  752. day.cronEvery = '1';
  753. week.cronEvery = '1';
  754. }
  755. }
  756. this.result.day = day;
  757. this.result.week = week;
  758. },
  759. monthsReverseExp(cron) {
  760. let months = cron.split(" ")[4];
  761. let month = {
  762. cronEvery:'',
  763. incrementStart:3,
  764. incrementIncrement:5,
  765. rangeStart:1,
  766. rangeEnd:1,
  767. specificSpecific:[],
  768. };
  769. switch (true){
  770. case months.includes('*'):
  771. month.cronEvery = '1';
  772. break;
  773. case months.includes('/'):
  774. month.cronEvery = '2';
  775. month.incrementStart = months.split('/')[0];
  776. month.incrementIncrement = months.split('/')[1];
  777. break;
  778. case months.includes(','):
  779. month.cronEvery = '3';
  780. month.specificSpecific = months.split(',').map(Number).sort();
  781. break;
  782. case months.includes('-'):
  783. month.cronEvery = '4';
  784. month.rangeStart = months.split('-')[0];
  785. month.rangeEnd = months.split('-')[1];
  786. break;
  787. default:
  788. month.cronEvery = '1';
  789. }
  790. this.result.month = month;
  791. },
  792. yearReverseExp(cron) {
  793. let years = cron.split(" ")[6];
  794. let year = {
  795. cronEvery:'',
  796. incrementStart:3,
  797. incrementIncrement:5,
  798. rangeStart:2019,
  799. rangeEnd:2019,
  800. specificSpecific:[],
  801. };
  802. switch (true){
  803. case years.includes('*'):
  804. year.cronEvery = '1';
  805. break;
  806. case years.includes('/'):
  807. year.cronEvery = '2';
  808. year.incrementStart = years.split('/')[0];
  809. year.incrementIncrement = years.split('/')[1];
  810. break;
  811. case years.includes(','):
  812. year.cronEvery = '3';
  813. year.specificSpecific = years.split(',').map(Number).sort();
  814. break;
  815. case years.includes('-'):
  816. year.cronEvery = '4';
  817. year.rangeStart = years.split('-')[0];
  818. year.rangeEnd = years.split('-')[1];
  819. break;
  820. default:
  821. year.cronEvery = '1';
  822. }
  823. this.result.year = year;
  824. }
  825. }
  826. }
  827. </script>
  828. <style lang="less">
  829. .card-container {
  830. background: #fff;
  831. overflow: hidden;
  832. padding: 12px;
  833. position: relative;
  834. width: 100%;
  835. .ant-tabs{
  836. border:1px solid #e6ebf5;
  837. padding: 0;
  838. .ant-tabs-bar {
  839. margin: 0;
  840. outline: none;
  841. border-bottom: none;
  842. .ant-tabs-nav-container{
  843. margin: 0;
  844. .ant-tabs-tab {
  845. padding: 0 24px!important;
  846. background-color: #f5f7fa!important;
  847. margin-right: 0px!important;
  848. border-radius: 0;
  849. line-height: 38px;
  850. border: 1px solid transparent!important;
  851. border-bottom: 1px solid #e6ebf5!important;
  852. }
  853. .ant-tabs-tab-active.ant-tabs-tab{
  854. color: #409eff;
  855. background-color: #fff!important;
  856. border-right:1px solid #e6ebf5!important;
  857. border-left:1px solid #e6ebf5!important;
  858. border-bottom:1px solid #fff!important;
  859. font-weight: normal;
  860. transition:none!important;
  861. }
  862. }
  863. }
  864. .ant-tabs-tabpane{
  865. padding: 15px;
  866. .ant-row{
  867. margin: 10px 0;
  868. }
  869. .ant-select,.ant-input-number{
  870. width: 100px;
  871. }
  872. }
  873. }
  874. }
  875. </style>
  876. <style lang="less" scoped>
  877. .container-widthEn{
  878. width: 755px;
  879. }
  880. .container-widthCn{
  881. width: 608px;
  882. }
  883. .language{
  884. text-align: center;
  885. position: absolute;
  886. right: 13px;
  887. top: 13px;
  888. border: 1px solid transparent;
  889. height: 40px;
  890. line-height: 38px;
  891. font-size: 16px;
  892. color: #409eff;
  893. z-index: 1;
  894. background: #f5f7fa;
  895. outline: none;
  896. width: 47px;
  897. border-bottom: 1px solid #e6ebf5;
  898. border-radius: 0;
  899. }
  900. .card-container{
  901. .bottom{
  902. display: flex;
  903. justify-content: center;
  904. padding: 10px 0 0 0;
  905. .cronButton{
  906. margin: 0 10px;
  907. line-height: 40px;
  908. }
  909. }
  910. }
  911. .tabBody{
  912. .a-row{
  913. margin: 10px 0;
  914. .long{
  915. .a-select{
  916. width:354px;
  917. }
  918. }
  919. .a-input-number{
  920. width: 110px;
  921. }
  922. }
  923. }
  924. </style>