kpi-job-form.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <audit-form-top-banner :handel-save-form="saveForm" :form-data="mode" @handelSaveForm="saveForm">
  3. <sd-detail-form
  4. ref="docform"
  5. form-id="kpiJobInfo"
  6. page-id="kpi/job/kpiJobInfo"
  7. :record-id="this.$route.query.record ? parseInt(this.$route.query.record) : null"
  8. :class="$style.form"
  9. :read-only="!saveFlag"
  10. @close="close(true)"
  11. @saved="saved"
  12. @sdFormReady="sdFormReady"
  13. >
  14. <template v-slot="{ model, fields }">
  15. <table>
  16. <tr>
  17. <td style="padding-left:5px;border:none">
  18. <audit-advanced-group
  19. :expand="basicExpand"
  20. :expand-str="'basicExpand'"
  21. :group-label="'基本信息'"
  22. tablestyle="''"
  23. @changedClick="changedClick"
  24. ></audit-advanced-group>
  25. </td>
  26. </tr>
  27. </table>
  28. <table v-show="basicExpand">
  29. <tr>
  30. <td class="ant-form-item-label ant-form-item-label" :class="$style.firstTd"></td>
  31. <td class="ant-form-item-control-wrapper" :class="$style.firstTd"></td>
  32. <td class="ant-form-item-label ant-form-item-label" :class="$style.firstTd"></td>
  33. <td class="ant-form-item-control-wrapper" :class="$style.firstTd"></td>
  34. <sd-form-item-td name="id" label="ID" :colspan="3" :hidden="true"> </sd-form-item-td>
  35. </tr>
  36. <tr>
  37. <!-- 时间维度 -->
  38. <sd-form-item-td name="jobFrequency" label="时间维度" :colspan="3"> </sd-form-item-td>
  39. </tr>
  40. <tr>
  41. <!-- 执行规则 -->
  42. <sd-form-item-td name="jobCron" :colspan="3">
  43. <template v-slot:read-and-edit>
  44. <a-input v-model="model.jobCron" @click="fnShowCron"></a-input>
  45. </template>
  46. </sd-form-item-td>
  47. </tr>
  48. <tr>
  49. <!-- 是否启用 -->
  50. <sd-form-item-td name="jobStatus" :colspan="3" label="是否启用"> </sd-form-item-td>
  51. </tr>
  52. <tr>
  53. <!-- 备注 -->
  54. <sd-form-item-td name="remark" :colspan="3">
  55. <a-textarea v-model="model.remark" :rows="3" />
  56. </sd-form-item-td>
  57. </tr>
  58. </table>
  59. <!-- cron选择组件 -->
  60. <a-modal
  61. width="600px"
  62. title="表达式"
  63. :footer="null"
  64. :visible="showCron"
  65. @cancel="handleCancel"
  66. >
  67. <vcrontab
  68. v-model="croninput"
  69. :expression="croninput"
  70. @hide="showCron = false"
  71. @fill="crontabFill"
  72. ></vcrontab>
  73. </a-modal>
  74. </template>
  75. </sd-detail-form>
  76. </audit-form-top-banner>
  77. </template>
  78. <script>
  79. import vcrontab from 'vcrontab'
  80. import axios from '@/common/services/axios-instance'
  81. import crossWindowWatcher from '@/common/services/cross-window-watcher'
  82. import { message } from '@/common/one-ui'
  83. import auditFormTopBanner from '@product/iam/components/audit-form-top-banner'
  84. import auditAdvancedGroup from '@product/iam/components/audit-advanced-group'
  85. import auditAdvancedGroupMixins from '@product/iam/components/audit-advanced-group-mixins'
  86. import KpiService from '../kpi-service'
  87. import components from './_import-components/kpi-job-form-import'
  88. import 'element-ui/lib/theme-chalk/index.css'
  89. export default {
  90. name: 'KpiJobForm',
  91. metaInfo: {
  92. title: '指标定时任务表单',
  93. },
  94. components: {
  95. ...components,
  96. auditAdvancedGroup,
  97. auditFormTopBanner,
  98. vcrontab,
  99. },
  100. mixins: [auditAdvancedGroupMixins],
  101. data() {
  102. return {
  103. configOptions: [], // 转换配置列表
  104. croninput: '',
  105. showCron: false,
  106. mode: null,
  107. saveFlag: true,
  108. basicExpand: true,
  109. etlConfigOptions: [],
  110. }
  111. },
  112. mounted() {
  113. const ini = setInterval(() => {
  114. if (this.$refs.docform) {
  115. this.croninput = this.$refs.docform.getFieldValue('jobCron')
  116. clearInterval(ini)
  117. }
  118. }, 200)
  119. },
  120. methods: {
  121. fnShowCron() {
  122. this.showCron = true
  123. },
  124. handleCancel(e) {
  125. this.showCron = !this.showCron
  126. },
  127. crontabFill(value) {
  128. // 确定后回传的值
  129. this.croninput = value
  130. this.$refs.docform.setFieldValue('jobCron', value)
  131. },
  132. configChange(val, option) {
  133. this.$refs.docform.setFieldValue('configId', Number(option.data.key))
  134. },
  135. // 页面加载完成后
  136. sdFormReady() {
  137. this.mode = this.$refs.docform.formData.mode
  138. // this.croninput = this.$refs.docform.getFieldValue('jobCron')
  139. },
  140. // 保存
  141. saveForm() {
  142. var jobFrequency = this.$refs.docform.getFieldValue('jobFrequency')
  143. var jobCron = this.$refs.docform.getFieldValue('jobCron')
  144. var id = this.$refs.docform.getFieldValue('id')
  145. const params = {
  146. id: id,
  147. jobFrequency: jobFrequency,
  148. jobCron: jobCron,
  149. }
  150. KpiService.hasJobFrequency(params).then((res) => {
  151. if (res) {
  152. message.error('该时间维度已存在,请重新选择!')
  153. } else {
  154. this.$refs.docform.validateFields().then(() => {
  155. message.success('保存成功').then(() => {
  156. this.$refs.docform.saveBtnClick()
  157. })
  158. })
  159. }
  160. })
  161. },
  162. saved() {
  163. this.close(true)
  164. },
  165. close(flag) {
  166. crossWindowWatcher.notifyChange(this.$route.fullPath, flag)
  167. window.close()
  168. },
  169. },
  170. }
  171. </script>
  172. <style module lang="scss">
  173. @use '@/common/design' as *;
  174. @import '@/webflow/sd-flow-form.scss';
  175. .connect-btn {
  176. float: right;
  177. font-weight: 400;
  178. font-size: 16px;
  179. top: 8px;
  180. cursor: pointer;
  181. margin-right: 10px;
  182. }
  183. .first-td {
  184. border: none !important;
  185. padding: 0;
  186. }
  187. </style>