design-inputnode-config1.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. <template>
  2. <el-dialog
  3. :title="'数据输入'"
  4. :close-on-click-modal="false"
  5. :visible.sync="visible"
  6. >
  7. <el-form
  8. :model="dataForm"
  9. ref="dataForm"
  10. @keyup.enter.native="dataFormSubmit()"
  11. label-width="160px"
  12. >
  13. <el-form-item label="静态数据集文件" prop="st_dataListurl">
  14. <el-select v-model="st_dataListvalue" multiple placeholder="请选择">
  15. <el-option
  16. v-for="item in st_dataList"
  17. :key="item.datasetName"
  18. :label="item.datasetName"
  19. :value="item.datasetName"
  20. >
  21. </el-option>
  22. </el-select>
  23. </el-form-item>
  24. <el-form-item label="动态数据集文件" prop="dy_dataListurl">
  25. <!-- 选择 dataset -->
  26. <el-select v-model="dy_dataListvalue" multiple placeholder="请选择">
  27. <el-option
  28. v-for="item in dy_dataList"
  29. :key="item.datasetName"
  30. :label="item.datasetName"
  31. :value="item.datasetName"
  32. >
  33. </el-option>
  34. </el-select>
  35. </el-form-item>
  36. <el-form-item label="文件" size="mini">
  37. <el-upload
  38. class="upload-demo"
  39. action="#"
  40. :on-preview="handlePreview"
  41. :on-remove="handleRemove"
  42. :before-remove="beforeRemove" multiple
  43. :limit="10"
  44. :on-exceed="handleExceed"
  45. :on-change="fileChange"
  46. :file-list="fileList"
  47. >
  48. <el-button size="small" type="primary">点击上传</el-button>
  49. </el-upload>
  50. </el-form-item>
  51. <!-- <el-form-item label="形式">
  52. <el-select v-model="dataForm.form" placeholder="选择算法形式">
  53. <el-option v-for="data in forms" :key="data.value" :label="data.label" :value="data.value">
  54. </el-option>
  55. </el-select>
  56. </el-form-item>
  57. <el-form-item label="描述信息" prop="remark">
  58. <el-input type="textarea" :autosize="{ minRows: 4, maxRows: 6}" placeholder="请输入内容" v-model="dataForm.remark">
  59. </el-input>
  60. </el-form-item> -->
  61. </el-form>
  62. <span slot="footer" class="dialog-footer">
  63. <el-button @click="visible = false">取消</el-button>
  64. <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
  65. </span>
  66. </el-dialog>
  67. </template>
  68. <script>
  69. import { MessageBox } from 'element-ui'
  70. import { Message } from "element-ui"
  71. export default {
  72. data() {
  73. return {
  74. visible: false,
  75. // 获取所有类别列表
  76. categoryList: [],
  77. dataForm: {
  78. id: 0,
  79. modelName: "",
  80. // 本模板的类别
  81. categoryId: 1,
  82. form: null,
  83. remark: "",
  84. datasetName: "",
  85. st_dataListurl: [{ datasetName: "" }],
  86. dy_dataListurl: [{ datasetName: "" }],
  87. },
  88. textarea2: "",
  89. forms: [
  90. {
  91. label: "传统算法",
  92. value: 1,
  93. },
  94. {
  95. label: "智能算法",
  96. value: 2,
  97. },
  98. ],
  99. dataRule: {
  100. modelName: [
  101. { required: true, message: "用户名不能为空", trigger: "blur" },
  102. ],
  103. // email: [
  104. // { required: true, message: "邮箱不能为空", trigger: "blur" },
  105. // { validator: validateEmail, trigger: "blur" },
  106. // ],
  107. // mobile: [
  108. // { required: true, message: "手机号不能为空", trigger: "blur" },
  109. // { validator: validateMobile, trigger: "blur" },
  110. // ],
  111. // codes: [
  112. // { required: true, message: "代码文件不能为空", trigger: "blur" },
  113. // ],
  114. },
  115. // 数据集文件选择
  116. st_dataList: [{ datasetName: "" }],
  117. dy_dataList: [{ datasetName: "" }],
  118. //选择器 值
  119. st_dataListvalue: [],
  120. dy_dataListvalue: [],
  121. // 包含文件名与url
  122. st_dataListmap: [],
  123. dy_dataListmap: [],
  124. externalfilemap: [], //外部上传文件最终 包含文件名和url
  125. //外部文件 上传
  126. fileList: [],
  127. //包含所有文件
  128. allfilemap: [{},],
  129. cell: null,
  130. pageIndex: 1,
  131. pageSize: 100,
  132. st_totalPage: 0,
  133. dy_totalPage: 0,
  134. datasetName: "",
  135. userID: this.$store.state.user.id, // 用户编号
  136. };
  137. },
  138. methods: {
  139. init(cell) {
  140. this.visible = true;
  141. this.$http({
  142. url: this.$http.adornUrl("/dataset/list"),
  143. method: "get",
  144. params: this.$http.adornParams({
  145. currentUserId: this.userID,
  146. page: this.pageIndex,
  147. limit: this.pageSize,
  148. datasetName: this.datasetName,
  149. }),
  150. }).then(({ data }) => {
  151. if (data && data.code === 0) {
  152. this.st_dataList = data.page.list;
  153. this.st_totalPage = data.page.totalCount;
  154. // this.statusunique = this.unique(data.page.list);
  155. } else {
  156. this.st_dataList = [];
  157. this.totalPage = 0;
  158. }
  159. // this.dataListLoading = false;
  160. });
  161. this.$http({
  162. url: this.$http.adornUrl("/datasetdy/list"),
  163. method: "get",
  164. params: this.$http.adornParams({
  165. currentUserId: this.userID,
  166. page: this.pageIndex,
  167. limit: this.pageSize,
  168. datasetName: this.datasetName,
  169. }),
  170. }).then(({ data }) => {
  171. if (data && data.code === 0) {
  172. this.dy_dataList = data.page.list;
  173. this.dy_totalPage = data.page.totalCount;
  174. // this.statusunique = this.unique(data.page.list);
  175. } else {
  176. this.dy_dataList = [];
  177. this.totalPage = 0;
  178. }
  179. // this.dataListLoading = false;
  180. });
  181. this.cell = cell;
  182. this.st_dataListvalue = cell.getData().st_dataListvalue;
  183. this.dy_dataListvalue = cell.getData().dy_dataListvalue;
  184. this.fileList = cell.getData().fileList;
  185. this.allfilemap = cell.getData().allfilemap;
  186. },
  187. // 表单提交
  188. dataFormSubmit() {
  189. this.$refs["dataForm"].validate((valid) => {
  190. if (valid) {
  191. //处理选择的 静态数据集或者动态数据集
  192. console.log(this.st_dataListvalue);
  193. console.log(this.dy_dataListvalue);
  194. this.st_dataListmap = [];
  195. this.dy_dataListmap = [];
  196. this.externalfilemap = [];
  197. this.allfilemap = [];
  198. // for (itemname of this.st_dataListvalue)
  199. for (var i = 0; i < this.st_dataListvalue.length; i++) {
  200. const stdatasetname = this.st_dataListvalue[i];
  201. this.$http({
  202. url: this.$http.adornUrl("/dataset/downloadDataset"),
  203. method: "get",
  204. params: this.$http.adornParams({
  205. datasetName: this.st_dataListvalue[i] + ".csv",
  206. }),
  207. }).then(({ data }) => {
  208. if (data && data.code === 0) {
  209. // window.location.href = data.downloadUrl;
  210. var fileitem = {};
  211. fileitem["name"] = stdatasetname;
  212. fileitem["bucketname"] = "dataset";
  213. fileitem["fileurl"] = data.downloadUrl;
  214. // console.log("data.downloadUrl")
  215. // console.log(data.downloadUrl)
  216. this.st_dataListmap.push(fileitem);
  217. //this.st_dataListmap.push({"name":stdatasetname,"bucketname":"dataset","fileurl":data.downloadUrl});
  218. this.allfilemap.push(fileitem);
  219. //this.allfilemap.push({"name":stdatasetname,"bucketname":"dataset","fileurl":data.downloadUrl});
  220. // celldata.allfilemap = this.allfilemap;
  221. } else {
  222. // this.$message.error("下载失败");
  223. }
  224. });
  225. }
  226. for (var j = 0; j < this.dy_dataListvalue.length; j++) {
  227. const dydatasetname = this.dy_dataListvalue[j];
  228. this.$http({
  229. url: this.$http.adornUrl("/dataset/downloadDataset"),
  230. method: "get",
  231. params: this.$http.adornParams({
  232. datasetName: this.dy_dataListvalue[j] + ".csv",
  233. }),
  234. }).then(({ data }) => {
  235. if (data && data.code === 0) {
  236. // window.location.href = data.downloadUrl;
  237. var fileitem = {};
  238. fileitem["name"] = dydatasetname;
  239. fileitem["bucketname"] = "dydataset";
  240. fileitem["fileurl"] = data.downloadUrl;
  241. this.dy_dataListmap.push(fileitem);
  242. //this.dy_dataListmap.push({"name":dydatasetname,"bucketname":"dydataset","fileurl":data.downloadUrl});
  243. //this.allfilemap.push({"name":dydatasetname,"bucketname":"dydataset","fileurl":data.downloadUrl});
  244. this.allfilemap.push(fileitem);
  245. // celldata.allfilemap = this.allfilemap;
  246. } else {
  247. // this.$message.error("下载失败");
  248. }
  249. });
  250. }
  251. //处理外部上传的数据
  252. let formData = new FormData();
  253. this.fileList.forEach((file) => {
  254. formData.append("file", file.raw);
  255. });
  256. if (formData != null) {
  257. var jsonfileurl = {};
  258. this.$http({
  259. url: this.$http.adornUrl("/visi/visiworkflow/saveinputfile"),
  260. method: "post",
  261. data: formData,
  262. }).then(({ data }) => {
  263. if (data && data.code === 0) {
  264. jsonfileurl = data.jsonfileurl;
  265. // myJson = { name: "phpernote", password: "1111" };
  266. for (var val in jsonfileurl) {
  267. // alert(val + " " + myJson[val]); //输出如:name
  268. var fileitem = {};
  269. fileitem["name"] = val;
  270. fileitem["bucketname"] = "visiarguartifact";
  271. fileitem["fileurl"] = jsonfileurl[val];
  272. this.externalfilemap.push(fileitem);
  273. this.allfilemap.push(fileitem);
  274. // celldata.allfilemap = this.allfilemap;
  275. }
  276. console.log();
  277. } else {
  278. this.$message.error(data.msg);
  279. }
  280. });
  281. // .then(({ data }) => {
  282. // if (data && data.code === 0) {
  283. // this.$message({
  284. // message: "操作成功",
  285. // type: "success",
  286. // duration: 1500,
  287. // onClose: () => {
  288. // this.visible = false;
  289. // // this.$emit("refreshDataList");
  290. // console.log("filemap");
  291. // console.log(this.st_dataListmap);
  292. // console.log(this.dy_dataListmap);
  293. // console.log(this.externalfilemap)
  294. // console.log(this.allfilemap);
  295. // },
  296. // });
  297. // } else {
  298. // this.$message.error(data.msg);
  299. // }
  300. // });
  301. }
  302. this.visible = false;
  303. // this.$emit("refreshDataList");
  304. // console.log("filemap");
  305. // console.log(this.st_dataListmap);
  306. // console.log(this.dy_dataListmap);
  307. // console.log(this.externalfilemap);
  308. // console.log(this.allfilemap);
  309. var celldata = this.cell.getData();
  310. celldata.st_dataListvalue = this.st_dataListvalue;
  311. celldata.dy_dataListvalue = this.dy_dataListvalue;
  312. celldata.fileList = this.fileList;
  313. celldata.allfilemap = this.allfilemap;
  314. // this.$emit("refreshinputnode",this.cell,this.st_dataListvalue,this.dy_dataListvalue,this.fileList,this.allfilemap);
  315. this.$emit("refreshinputnode",this.cell,celldata);
  316. }
  317. });
  318. },
  319. // 以下4个函数是文件上传功能的
  320. handleRemove(file, fileList) {
  321. console.log(file, fileList);
  322. },
  323. handlePreview(file) {
  324. console.log(file);
  325. },
  326. handleExceed(files, fileList) {
  327. this.$message.warning(
  328. `当前限制选择 3 个文件,本次选择了 ${files.length} 个文件,共选择了 ${
  329. files.length + fileList.length
  330. } 个文件`
  331. );
  332. },
  333. beforeRemove(file, fileList) {
  334. return MessageBox.confirm(`确定移除 ${file.name}?`);
  335. },
  336. // 文件改变时
  337. fileChange(file, fileList) {
  338. this.fileList = fileList;
  339. this.fileList.push(file);
  340. },
  341. },
  342. };
  343. </script>
  344. <style>
  345. .el-form-item .el-select {
  346. width: 100%;
  347. }
  348. .el-form-item .el-input {
  349. width: 100%;
  350. }
  351. </style>