index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <div class="main pa-3">
  3. <m-filter :option="filter" @search="handleSearch" />
  4. <m-table
  5. class="mt-3"
  6. :loading="loading"
  7. :headers="headers"
  8. :items="items"
  9. :show-select="false"
  10. :is-tools="false"
  11. :disable-sort="true"
  12. :total="total"
  13. :page-info="pageInfo"
  14. @pageHandleChange="pageHandleChange"
  15. >
  16. <template #name="{ item }">
  17. <tool-tip :text="item.name" :width="200"></tool-tip>
  18. </template>
  19. <template #remark="{ item }">
  20. <tool-tip :text="item.remark" :width="200"></tool-tip>
  21. </template>
  22. <template #status="{ item }">
  23. <span :class="statusMsg[item.status] + '--text'">
  24. {{ taskStatus.find(e => e.value === item.status)?.label }}
  25. </span>
  26. </template>
  27. <template #actions="{ item }">
  28. <v-btn text color="success" @click="handleSchedule(item)">
  29. 调度
  30. </v-btn>
  31. <v-btn :disabled="!+item.status" text color="success" @click="handleRun(item)">
  32. 执行
  33. </v-btn>
  34. <v-btn text color="success" @click="handleRunSelf(item)">
  35. <v-progress-circular
  36. v-if="item.loading"
  37. indeterminate
  38. :size="18"
  39. width="2"
  40. style="margin-right: 6px"
  41. ></v-progress-circular>
  42. <v-icon v-else left>mdi-play</v-icon>
  43. 手动执行
  44. </v-btn>
  45. </template>
  46. </m-table>
  47. <m-dialog :visible.sync="showSchedule" title="调度" @submit="handleDispatch" body-style="overflow-y: visible !important">
  48. <data-dispatch
  49. ref="dispatch"
  50. v-if="showSchedule"
  51. :updater="updater"
  52. />
  53. </m-dialog>
  54. </div>
  55. </template>
  56. <script>
  57. import ToolTip from '@/components/Tooltip'
  58. import MFilter from '@/components/Filter'
  59. import MTable from '@/components/List/table'
  60. import MDialog from '@/components/Dialog'
  61. import DataDispatch from './components/dataDispatch'
  62. import { getDataFactoryList } from '@/api/productionLine'
  63. import {
  64. // productionLineBasePage,
  65. // productionLineBaseDetail,
  66. dataFactoryDictList,
  67. productionLineBaseStart,
  68. productionLineBaseDispatch
  69. } from '@/api/dataFactory'
  70. import { api } from '@/api/dataGovernance'
  71. export default {
  72. name: 'production-line-dispatch',
  73. components: { MTable, MFilter, ToolTip, MDialog, DataDispatch },
  74. data () {
  75. return {
  76. statusMsg: ['grey', 'blue', 'green', 'orange', 'red'],
  77. showSchedule: false,
  78. filter: {
  79. list: [
  80. { type: 'textField', value: null, label: '名称', key: 'name' },
  81. { type: 'autocomplete', value: null, label: '状态', key: 'status', items: [] }
  82. ]
  83. },
  84. show: false,
  85. loading: false,
  86. headers: [
  87. { text: '名称', value: 'name' },
  88. { text: '状态', value: 'status' },
  89. { text: '更新时间', value: 'updateTime' },
  90. { text: '创建时间', value: 'createTime' },
  91. { text: '备注', value: 'remark' },
  92. { text: '操作', value: 'actions' }
  93. ],
  94. items: [],
  95. pageInfo: {
  96. size: 10,
  97. current: 1
  98. },
  99. total: 0,
  100. query: {
  101. name: null
  102. },
  103. dispatchData: null,
  104. taskStatus: [],
  105. log: {
  106. info: null,
  107. drawer: false
  108. }
  109. }
  110. },
  111. created () {
  112. this.getDict()
  113. this.init()
  114. },
  115. computed: {
  116. updater () {
  117. if (!this.dispatchData) return null
  118. return this.dispatchData.updater
  119. }
  120. },
  121. methods: {
  122. async init () {
  123. this.loading = true
  124. try {
  125. const { data } = await getDataFactoryList({ ...this.query, ...this.pageInfo })
  126. this.items = data.records.map(e => {
  127. return {
  128. ...e,
  129. loading: false
  130. }
  131. })
  132. this.total = data.total
  133. } catch (error) {
  134. this.$snackbar.error(error)
  135. } finally {
  136. this.loading = false
  137. }
  138. },
  139. async getDict () {
  140. try {
  141. const { data } = await dataFactoryDictList({ type: 'production_line_run_status' })
  142. this.taskStatus = data[0].itemList
  143. this.filter.list.find(e => e.key === 'status').items = data[0].itemList
  144. } catch (error) {
  145. this.$snackbar.error(error)
  146. }
  147. },
  148. handleSearch (val) {
  149. Object.assign(this.query, val)
  150. this.pageInfo.current = 1
  151. this.init()
  152. },
  153. // 调度
  154. async handleSchedule ({ id }) {
  155. try {
  156. // const { data } = await productionLineBaseDetail({ id })
  157. // this.dispatchData = data
  158. this.showSchedule = true
  159. } catch (error) {
  160. this.$snackbar.error(error)
  161. }
  162. },
  163. async handleDispatch () {
  164. const obj = this.$refs.dispatch.getValue()
  165. Object.assign(obj, {
  166. id: this.dispatchData.id
  167. })
  168. try {
  169. await productionLineBaseDispatch(obj)
  170. this.$snackbar.success('操作成功')
  171. this.init()
  172. } catch (error) {
  173. this.$snackbar.error(error)
  174. } finally {
  175. this.showSchedule = false
  176. }
  177. },
  178. async handleRun ({ id }) {
  179. try {
  180. await productionLineBaseStart({ id })
  181. this.$snackbar.success('启动成功')
  182. } catch (error) {
  183. this.$snackbar.error(error)
  184. }
  185. },
  186. // 手动执行
  187. async handleRunSelf (item) {
  188. if (item.loading === true) {
  189. return
  190. }
  191. const { id } = item
  192. // const { id, type } = Object.values(item.nodeProperty).pop()
  193. item.loading = true
  194. await this.handleRunResource(id)
  195. // if (type === 'data_resource') {
  196. // await this.handleRunResource(id)
  197. // }
  198. // if (type === 'data_model') {
  199. // await this.sourceModelTrain(id)
  200. // }
  201. // if (type === 'readUnstructuredResource') {
  202. // await this.handleRunUnstructuredResource(id)
  203. // }
  204. item.loading = false
  205. },
  206. // 结构化 运行
  207. async handleRunResource (id) {
  208. try {
  209. await api.productionLineDispatch({ id })
  210. this.$snackbar.success('执行成功')
  211. } catch (error) {
  212. this.$snackbar.error(error)
  213. }
  214. },
  215. // 非结构化运行
  216. async handleRunUnstructuredResource (id) {
  217. try {
  218. await api.runUnstructuredMetadata({ id })
  219. this.$snackbar.success('执行成功')
  220. } catch (error) {
  221. this.$snackbar.error(error)
  222. }
  223. },
  224. // 大模型训练
  225. async sourceModelTrain (id) {
  226. try {
  227. const { data } = await api.getResourceDetails({ id })
  228. // 执行训练
  229. const { data: ddl } = await api.getDDL({ id })
  230. if (!ddl.DDL) {
  231. this.$snackbar.error('不存在DDL,执行尚未结束,请稍后再试')
  232. return
  233. }
  234. await api.setDDLTrain({
  235. ddl: ddl.DDL.replace(/\n/g, ''),
  236. documentation: `our definition of ${data.resource_en} is ${data.resource}`
  237. })
  238. this.$snackbar.success('操作成功')
  239. } catch (error) {
  240. this.$snackbar.error(error)
  241. }
  242. },
  243. pageHandleChange (index) {
  244. this.pageInfo.current = index
  245. this.init()
  246. }
  247. }
  248. }
  249. </script>
  250. <style lang="scss" scoped>
  251. .main {
  252. width: 100%;
  253. height: 100%;
  254. background: #FFF;
  255. }
  256. </style>