form.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <template>
  2. <el-dialog
  3. :title="title"
  4. :visible.sync="dialogOpen"
  5. width="1000px"
  6. :close-on-click-modal="false"
  7. append-to-body
  8. @opened="initData"
  9. @close="handleCancel"
  10. >
  11. <el-form ref="form" :model="formData" :rules="rules" label-width="100px">
  12. <el-form-item label="任务名称" prop="name">
  13. <el-input v-model="formData.name" placeholder="请输入任务名称" />
  14. </el-form-item>
  15. <el-form-item label="模型类型" prop="type" @change="queryModels">
  16. <el-select
  17. v-model="queryFrom.modelType"
  18. placeholder="请选择模型类型"
  19. clearable
  20. >
  21. <el-option
  22. v-for="dict in dict.type.biz_model_type"
  23. :key="dict.value"
  24. :label="dict.label"
  25. :value="dict.value"
  26. />
  27. </el-select>
  28. </el-form-item>
  29. <el-form-item label="模型类型" prop="type" @change="queryModels">
  30. <el-select
  31. v-model="queryFrom.modelTypet"
  32. placeholder="请选择模型种类"
  33. clearable
  34. >
  35. <el-option
  36. v-for="dict in dict.type.model_tepe_t"
  37. :key="dict.value"
  38. :label="dict.label"
  39. :value="dict.value"
  40. />
  41. </el-select>
  42. </el-form-item>
  43. <el-form-item label="模型" prop="modelId">
  44. <el-select v-model="formData.modelId" placeholder="请选择模型" @change="onModelChange">
  45. <el-option
  46. v-for="item in faultPhysicalOptions"
  47. :key="item.modelId"
  48. :label="item.modelName"
  49. :value="item.modelId"
  50. >
  51. </el-option>
  52. </el-select>
  53. </el-form-item>
  54. <el-form-item v-if="formData.modelId && modelType" label="模型参数">
  55. <dynamic-parameter-form :model-typedisbale="modelType==='0'" :config-data="initialData" @submit="handleSubmitDataList" />
  56. </el-form-item>
  57. <el-form-item label="说明" prop="remark">
  58. <el-input
  59. v-model="formData.remark"
  60. type="textarea"
  61. placeholder="请输入内容"
  62. />
  63. </el-form-item>
  64. </el-form>
  65. <div slot="footer" class="dialog-footer">
  66. <el-button type="primary" @click="handleSubmit">确 定</el-button>
  67. <el-button @click="handleCancel">取 消</el-button>
  68. </div>
  69. </el-dialog>
  70. </template>
  71. <script>
  72. import DynamicParameterForm from '@/views/dataGen/DynamicParameterForm.vue'
  73. import {
  74. addDdAlgorithm,
  75. updateDdAlgorithm,
  76. fileCopys
  77. } from "@/api/test/ddAlgorithm";
  78. import { getFaultPhysicalOptions } from '@/api/model/faultPhysical'
  79. import {getFaultPhysical} from "@/api/model/faultPhysical";
  80. import { addData } from '@/api/data/data'
  81. export default {
  82. components:{
  83. DynamicParameterForm
  84. },
  85. computed: {
  86. title() {
  87. if (this.options === 'add') {
  88. return '添加功能验证';
  89. }
  90. if (this.options === 'edit') {
  91. return '修改功能验证';
  92. }
  93. return '';
  94. },
  95. },
  96. props: {
  97. value: {
  98. type: Boolean,
  99. default: false
  100. },
  101. dataInfo: {
  102. type: Object,
  103. default: null
  104. },
  105. options: {
  106. type: String,
  107. default: 'add'
  108. },
  109. dataOptions: {
  110. type: Array,
  111. default: () => []
  112. },
  113. },
  114. dicts: ["biz_model_type","param_type","model_tepe_t"],
  115. data() {
  116. return {
  117. queryFrom:{
  118. modelType:'',
  119. modelTypet:'',
  120. modelAttribution:1
  121. },
  122. faultPhysicalOptions:[],
  123. //指定文件上传路径
  124. customPath:"",
  125. formData: {
  126. apiPath:null,
  127. id: null,
  128. name: null,
  129. modelId: null,
  130. dataId: null,
  131. truthLabels: null,
  132. testLabels: null,
  133. remark: null,
  134. startTime: null,
  135. endTime: null,
  136. createBy: null,
  137. createTime: null,
  138. updateBy: null,
  139. updateTime: null,
  140. },
  141. initialData:[],
  142. modelType:null,
  143. selectedModel:{},
  144. fileForm:{},
  145. rules: {},
  146. dialogOpen: false
  147. };
  148. },
  149. model: {
  150. prop: 'value',
  151. event: 'callback'
  152. },
  153. watch: {
  154. value(newVal) {
  155. this.dialogOpen = newVal;
  156. }
  157. },
  158. methods: {
  159. queryModels(){
  160. console.log('111111',this.queryFrom)
  161. getFaultPhysicalOptions(this.queryFrom).then(resp => {
  162. this.faultPhysicalOptions = resp.data || [];
  163. console.log(this.faultPhysicalOptions)
  164. });
  165. },
  166. onModelChange(modelId){
  167. //获取模型参数详情
  168. getFaultPhysical(modelId).then(rest => {
  169. this.initialData = rest.data.configData;
  170. this.modelType=rest.data.modelAttribution;
  171. this.formData.modelId = rest.data.modelId;
  172. console.log('modelDataParams',rest.data.modelAttribution)
  173. });
  174. console.log(this.selectedModel)
  175. },
  176. handleSubmitDataList(data) {
  177. this.formData.postApiData = JSON.stringify(data);
  178. this.formData.bizParams= JSON.stringify(data);
  179. console.log('submit', this.formData)
  180. },
  181. handleUploadSuccess(datas){
  182. console.log('handleChildData',datas);
  183. const fileData= {
  184. fileName : datas.fileName,
  185. filelocalPath : datas.filelocalPath,
  186. modelPath:this.selectedModel.modelPath
  187. }
  188. const addDataform={
  189. name:'验证数据',
  190. type:'3',
  191. fileName:datas.fileName,
  192. fileSize:datas.fileSize,
  193. fileSizeBytes:datas.fileSizeBytes,
  194. fileSuffix:datas.fileSuffix,
  195. filelocalPath:datas.filelocalPath,
  196. filePath:datas.filelocalPath+'\\'+datas.fileName,
  197. }
  198. addData(addDataform);
  199. console.log('fileData',fileData)
  200. fileCopys(fileData);
  201. this.formData.outputPath = this.selectedModel.modelPath
  202. },
  203. initData() {
  204. this.queryModels();
  205. if (this.options!== 'add') {
  206. this.formData = { ...this.dataInfo };
  207. }
  208. },
  209. handleSubmit() {
  210. this.$refs["form"].validate((valid) => {
  211. if (valid) {
  212. if (this.formData.id != null) {
  213. updateDdAlgorithm(this.formData).then((response) => {
  214. this.$modal.msgSuccess("修改成功");
  215. this.handleCancel();
  216. });
  217. } else {
  218. addDdAlgorithm(this.formData).then((response) => {
  219. this.$modal.msgSuccess("新增成功");
  220. this.handleCancel();
  221. });
  222. }
  223. }
  224. });
  225. },
  226. handleCancel() {
  227. this.formData = {
  228. id: null,
  229. name: null,
  230. modelId: null,
  231. dataId: null,
  232. truthLabels: null,
  233. testLabels: null,
  234. remark: null,
  235. startTime: null,
  236. endTime: null,
  237. createBy: null,
  238. createTime: null,
  239. updateBy: null,
  240. updateTime: null,
  241. };
  242. this.$emit('callback', false);
  243. }
  244. }
  245. };
  246. </script>