manage.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <a-card title="算子管理" >
  3. <table-pro
  4. :service="OperatorController.page"
  5. :serviceParams="{aiName}"
  6. :columns="columns"
  7. ref="tableProDom"
  8. @add="openModal"
  9. >
  10. <template #search >
  11. <a-space>
  12. <input-tsx v-model:value="aiName" placeholder="请输入算子名称" />
  13. <a-button type="primary" @click="search" >搜索</a-button>
  14. </a-space>
  15. </template>
  16. <template #render="{column, record}" >
  17. <template v-if="column.key === 'action'" >
  18. <a-space>
  19. <a @click="updateName(record)" >更改名称</a>
  20. <a @click="pushVersion(record)" >新增版本</a>
  21. <a-popconfirm
  22. title="确实要删除吗?"
  23. ok-text="确定"
  24. cancel-text="取消"
  25. @confirm="delOperator(record)"
  26. >
  27. <a >删除</a>
  28. </a-popconfirm>
  29. </a-space>
  30. </template>
  31. </template>
  32. </table-pro>
  33. </a-card>
  34. <modal-pro
  35. width="800px"
  36. :label="state.modalType === 'add' ? '创建算子' :'修改名称' "
  37. :open="state.visible"
  38. @cancel="closeModal"
  39. @ok="submit"
  40. >
  41. <a-form style="width: 100%;" :labelCol="{span: 3}" :wrapperCol="{span: 14}" >
  42. <a-form-item label="算子ID" v-if="state.modalType === 'add'" v-bind="validateInfos.aiId" extra="仅支持小写字母、数字、中划线,64字符以内,小写字母开头" >
  43. <InputTsx allowClear placeholder="请输入算子ID" v-model:value="operatorState.aiId" />
  44. </a-form-item>
  45. <a-form-item label="算子名称" v-bind="validateInfos.aiName" >
  46. <InputTsx allowClear placeholder="请输入算子名称" v-model:value="operatorState.aiName" />
  47. </a-form-item>
  48. <a-form-item label="算子类型" v-if="state.modalType === 'add'" v-bind="validateInfos.aiModelType" >
  49. <a-select
  50. ref="select"
  51. v-model:value="operatorState.aiModelType"
  52. style="width: 120px"
  53. >
  54. <a-select-option v-for="item in state.type" :key="item.code" :value="item.code">{{item.name}}</a-select-option>
  55. </a-select>
  56. </a-form-item>
  57. </a-form>
  58. </modal-pro>
  59. </template>
  60. <script lang='ts' setup >
  61. import { OperatorController } from '@/controller'
  62. import { onMounted, reactive, ref } from 'vue'
  63. import { Form } from 'ant-design-vue'
  64. import { InputTsx, SelectTsx } from '@/components/MicroComponents'
  65. import { useRouter } from 'vue-router'
  66. const useForm = Form.useForm
  67. const router = useRouter()
  68. const aiName = ref('')
  69. const tableProDom = ref()
  70. const columns = [
  71. {
  72. title: '算子ID',
  73. dataIndex: 'aiId',
  74. key: 'aiId'
  75. },
  76. {
  77. title: '算子名称',
  78. dataIndex: 'aiName',
  79. key: 'aiName'
  80. },
  81. {
  82. title: '来源',
  83. dataIndex: 'aiSourceType',
  84. key: 'aiSourceType'
  85. },
  86. {
  87. title: '业务类型',
  88. dataIndex: 'aiModelType',
  89. key: 'aiModelType'
  90. },
  91. {
  92. title: '最近版本',
  93. dataIndex: 'recentlyAiVersion',
  94. key: 'recentlyAiVersion'
  95. },
  96. {
  97. title: '操作',
  98. dataIndex: 'action',
  99. key: 'action'
  100. }
  101. ]
  102. const state = reactive<{
  103. visible: boolean,
  104. type: {code: string; name: string;}[],
  105. updateNameVisible: boolean,
  106. modalType: 'add' | 'update'
  107. }>({
  108. visible: false,
  109. updateNameVisible: false,
  110. type: [],
  111. modalType: 'add'
  112. })
  113. const operatorState = reactive<CVS.Operator>({
  114. aiId: '',
  115. aiName: '',
  116. aiModelType: null
  117. })
  118. const { resetFields, validate, validateInfos } = useForm(operatorState, {
  119. aiId: [{ required: true, message: '请填写aiId' }],
  120. aiName: [{ required: true, message: '请填写算子名称' }],
  121. aiModelType: [{ required: true, message: '请选择算子类型' }]
  122. })
  123. const submit = () => {
  124. validate().then(async () => {
  125. state.modalType === 'add' ? await OperatorController.add(operatorState) : await OperatorController.upadteName(operatorState.id! as unknown as string, operatorState.aiName)
  126. closeModal()
  127. tableProDom.value.reload()
  128. }).catch(() => {})
  129. }
  130. const delOperator = async (record) => {
  131. await OperatorController.del(record.id)
  132. tableProDom.value.reload()
  133. }
  134. const search = () => {
  135. tableProDom.value.reload()
  136. }
  137. const closeModal = () => {
  138. state.visible = false
  139. }
  140. const openModal = () => {
  141. state.visible = true
  142. state.modalType = 'add'
  143. resetFields({})
  144. }
  145. const getOperatorType = async () => {
  146. state.type = await OperatorController.type()
  147. }
  148. const updateName = async (record) => {
  149. const data = await OperatorController.byId(record.id)
  150. resetFields(data)
  151. state.modalType = 'update'
  152. state.visible = true
  153. }
  154. const pushVersion = (record) => {
  155. router.push({ path: '/cvs/operator/version', query: { aiId: record.id } })
  156. }
  157. onMounted(() => {
  158. getOperatorType()
  159. })
  160. </script>
  161. <style lang='less' scoped >
  162. </style>