8aac85643fda9c802063a528e81c89ec8b6ab8f4.svn-base 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <a-modal
  3. :title="title"
  4. :width="800"
  5. :visible="visible"
  6. :confirmLoading="confirmLoading"
  7. @ok="handleOk"
  8. @cancel="handleCancel"
  9. okText="保存并安排任务"
  10. cancelText="关闭">
  11. <a-spin :spinning="confirmLoading">
  12. <a-form-model ref="form" :model="model" :rules="validatorRules">
  13. <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="任务类名" prop="jobClassName" hasFeedback >
  14. <a-input placeholder="请输入任务类名" v-model="model.jobClassName" />
  15. </a-form-model-item>
  16. <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="Cron表达式" prop="cronExpression">
  17. <!-- <j-cron v-model="model.cronExpression"/>-->
  18. <j-easy-cron v-model="model.cronExpression" />
  19. </a-form-model-item>
  20. <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="参数" prop="parameter" >
  21. <a-textarea placeholder="请输入参数" :rows="5" v-model="model.parameter" />
  22. </a-form-model-item>
  23. <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="描述" prop="description">
  24. <a-textarea placeholder="请输入描述" :rows="3" v-model="model.description" />
  25. </a-form-model-item>
  26. <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="状态" prop="status">
  27. <j-dict-select-tag type="radioButton" v-model="model.status" dictCode="quartz_status"/>
  28. </a-form-model-item>
  29. </a-form-model>
  30. </a-spin>
  31. </a-modal>
  32. </template>
  33. <script>
  34. import { httpAction } from '@/api/manage'
  35. // import JCron from "@/components/jeecg/JCron";
  36. import cronValidator from "@/components/jeecg/JEasyCron/validator";
  37. export default {
  38. name: "QuartzJobModal",
  39. components: {
  40. // JCron,
  41. },
  42. data () {
  43. return {
  44. title:"操作",
  45. buttonStyle: 'solid',
  46. visible: false,
  47. model: {},
  48. labelCol: {
  49. xs: { span: 24 },
  50. sm: { span: 5 },
  51. },
  52. wrapperCol: {
  53. xs: { span: 24 },
  54. sm: { span: 16 },
  55. },
  56. cron: {
  57. label: '',
  58. value: ''
  59. },
  60. confirmLoading: false,
  61. validatorRules: {
  62. cronExpression: [
  63. {required: true, message: '请输入cron表达式!'},
  64. {validator: cronValidator,}
  65. ],
  66. jobClassName: [{required: true, message: '请输入任务类名!'}]
  67. },
  68. url: {
  69. add: "/sys/quartzJob/add",
  70. edit: "/sys/quartzJob/edit",
  71. },
  72. }
  73. },
  74. created () {
  75. },
  76. methods: {
  77. add() {
  78. // 统一设置默认值
  79. this.edit({
  80. cronExpression: '* * * * * ? *',
  81. status: 0,
  82. })
  83. },
  84. edit (record) {
  85. this.visible = true;
  86. this.$nextTick(() => {
  87. this.$refs.form.resetFields()
  88. this.model = Object.assign({}, record)
  89. })
  90. },
  91. close () {
  92. this.$emit('close');
  93. this.visible = false;
  94. },
  95. handleOk () {
  96. const that = this;
  97. // 触发表单验证
  98. this.$refs.form.validate((ok, err) => {
  99. if (ok) {
  100. that.confirmLoading = true;
  101. let httpurl = '';
  102. let method = '';
  103. if(!this.model.id){
  104. httpurl+=this.url.add;
  105. method = 'post';
  106. }else{
  107. httpurl+=this.url.edit;
  108. //method = 'put';
  109. method = 'post';
  110. }
  111. console.log('提交参数',this.model)
  112. httpAction(httpurl,this.model,method).then((res)=>{
  113. if(res.success){
  114. that.$message.success(res.message);
  115. that.$emit('ok');
  116. that.close();
  117. }else{
  118. that.$message.warning(res.message);
  119. }
  120. }).finally(() => {
  121. that.confirmLoading = false;
  122. })
  123. }
  124. })
  125. },
  126. handleCancel () {
  127. this.close()
  128. },
  129. }
  130. }
  131. </script>
  132. <style scoped>
  133. </style>