index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="名称" prop="name">
  5. <el-input
  6. v-model="queryParams.name"
  7. placeholder="请输入名称"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item>
  13. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  14. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  15. </el-form-item>
  16. </el-form>
  17. <el-row :gutter="10" class="mb8">
  18. <el-col :span="1.5">
  19. <el-button
  20. type="primary"
  21. size="mini"
  22. @click="handleAdd"
  23. v-hasPermi="['manage:preHandleResult:add']"
  24. >选择预处理数据</el-button>
  25. </el-col>
  26. <el-col :span="1.5">
  27. <el-button
  28. type="success"
  29. size="mini"
  30. :disabled="single"
  31. @click="handleUpdate"
  32. v-hasPermi="['manage:performanceMonitorModel:edit']"
  33. >处理数据</el-button>
  34. </el-col>
  35. <el-col :span="1.5">
  36. <el-button
  37. type="warning"
  38. plain
  39. icon="el-icon-download"
  40. size="mini"
  41. @click="handleExport"
  42. v-hasPermi="['manage:preHandleResult:export']"
  43. >导出</el-button>
  44. </el-col>
  45. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  46. </el-row>
  47. <el-table v-loading="loading" :data="preHandleResultList" @selection-change="handleSelectionChange">
  48. <el-table-column type="selection" width="55" align="center" />
  49. <el-table-column label="源数据文件名称" align="center" prop="sourceName" />
  50. <el-table-column label="处理后文件名称" align="center" prop="name" />
  51. <el-table-column label="处理方式" align="center" prop="type" />
  52. <el-table-column label="备注" align="center" prop="remark"/>
  53. <el-table-column label="处理后结果列表" align="center" />
  54. </el-table>
  55. <pagination
  56. v-show="total>0"
  57. :total="total"
  58. :page.sync="queryParams.pageNum"
  59. :limit.sync="queryParams.pageSize"
  60. @pagination="getList"
  61. />
  62. <!-- 添加或修改数据预处理结果对话框 -->
  63. <el-dialog :title="title" :visible.sync="open" :close-on-click-modal="false" width="500px" append-to-body>
  64. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  65. <el-form-item label="文件名" prop="name">
  66. <el-select v-model="form.name" placeholder="请选择要处理的数据" style="width:100%">
  67. <el-option
  68. v-for="item in sourceDataList"
  69. :key="item.name"
  70. :label="item.name"
  71. :value="item.name">
  72. </el-option>
  73. </el-select>
  74. </el-form-item>
  75. <el-form-item label="预处理模式" prop="name">
  76. <el-select v-model="form.type" placeholder="请选择要执行的模式" style="width:100%">
  77. <el-option
  78. v-for="item in handleList"
  79. :key="item.name"
  80. :label="item.name"
  81. :value="item.name">
  82. </el-option>
  83. </el-select>
  84. </el-form-item>
  85. <el-form-item label="备注" prop="remark">
  86. <el-input v-model="form.remark" placeholder="请输入备注" />
  87. </el-form-item>
  88. </el-form>
  89. <div slot="footer" class="dialog-footer">
  90. <el-button type="primary" @click="submitForm" :loading="butLoading">{{butText}}</el-button>
  91. <el-button @click="cancel">取 消</el-button>
  92. </div>
  93. </el-dialog>
  94. <!-- 手动处理数据的弹框 -->
  95. <el-dialog :title="title" :visible.sync="handOpen" :close-on-click-modal="false" :fullscreen="true" append-to-body>
  96. <el-input
  97. type="textarea"
  98. :rows="12"
  99. placeholder="请输入内容"
  100. v-model="textarea">
  101. </el-input>
  102. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  103. <el-form-item label="备注" prop="remark">
  104. <el-input v-model="form.remark" placeholder="请输入备注" />
  105. </el-form-item>
  106. </el-form>
  107. <div slot="footer" class="dialog-footer">
  108. <el-button type="primary" @click="submitForm">确 定</el-button>
  109. <el-button @click="handOpen = !handOpen">取 消</el-button>
  110. </div>
  111. </el-dialog>
  112. </div>
  113. </template>
  114. <script>
  115. import { listPreHandleResult, getPreHandleResult, delPreHandleResult, addPreHandleResult, updatePreHandleResult } from "@/api/manage/preHandleResult";
  116. import { listAnalyzeResult } from "@/api/manage/analyzeResult";
  117. export default {
  118. name: "PreHandleResult",
  119. data() {
  120. return {
  121. // 按钮加载
  122. butLoading: false,
  123. // 按钮显示文本
  124. butText: "开始分析",
  125. // 需要预处理的源数据列表
  126. sourceDataList:[],
  127. // 当前选择的数据
  128. currentSelection: [],
  129. textarea: '0101010101010111010',
  130. handleList: [
  131. {name: '异常值剔除', value: 1},
  132. {name: '确实值补全', value: 2}
  133. ],
  134. handleList2: [
  135. {name: '手动处理', value: 1},
  136. {name: '调用异常模型', value: 2}
  137. ],
  138. // 遮罩层
  139. loading: true,
  140. // 选中数组
  141. ids: [],
  142. // 非单个禁用
  143. single: true,
  144. // 非多个禁用
  145. multiple: true,
  146. // 显示搜索条件
  147. showSearch: true,
  148. // 总条数
  149. total: 0,
  150. // 数据预处理结果表格数据
  151. preHandleResultList: [],
  152. // 弹出层标题
  153. title: "",
  154. // 是否显示弹出层
  155. open: false,
  156. // 是否显示弹出层
  157. handOpen: false,
  158. // 查询参数
  159. queryParams: {
  160. pageNum: 1,
  161. pageSize: 10,
  162. },
  163. // 表单参数
  164. form: {},
  165. // 表单校验
  166. rules: {
  167. isDelete: [
  168. { required: true, message: "数据是否删除不能为空", trigger: "blur" }
  169. ],
  170. }
  171. };
  172. },
  173. created() {
  174. this.getList();
  175. this.getSourceDataList();
  176. },
  177. methods: {
  178. getSourceDataList() {
  179. // listAnalyzeResult(this.queryParams).then(response => {
  180. // this.sourceDataList = response.rows;
  181. // });
  182. this.sourceDataList = JSON.parse(localStorage.getItem("data-analyze")) || [];
  183. },
  184. /** 查询数据预处理结果列表 */
  185. getList() {
  186. this.loading = true;
  187. // listPreHandleResult(this.queryParams).then(response => {
  188. // this.preHandleResultList = response.rows;
  189. // this.total = response.total;
  190. // this.loading = false;
  191. // });
  192. this.preHandleResultList = JSON.parse(localStorage.getItem("pro-data-analyze")) || [];
  193. console.log(this.preHandleResultLists);
  194. this.total = this.preHandleResultList?.length || 0;
  195. this.loading = false;
  196. },
  197. // 取消按钮
  198. cancel() {
  199. this.open = false;
  200. this.reset();
  201. },
  202. // 表单重置
  203. reset() {
  204. this.form = {
  205. name: null,
  206. type: null,
  207. remark: null
  208. };
  209. this.resetForm("form");
  210. },
  211. /** 搜索按钮操作 */
  212. handleQuery() {
  213. this.queryParams.pageNum = 1;
  214. this.getList();
  215. },
  216. /** 重置按钮操作 */
  217. resetQuery() {
  218. this.resetForm("queryForm");
  219. this.handleQuery();
  220. },
  221. // 多选框选中数据
  222. handleSelectionChange(selection) {
  223. this.ids = selection.map(item => item.id)
  224. this.single = selection.length!==1
  225. this.multiple = !selection.length
  226. this.currentSelection = selection
  227. },
  228. /** 新增按钮操作 */
  229. handleAdd() {
  230. this.handleList = this.handleList
  231. this.reset();
  232. this.open = true;
  233. this.title = "数据处理";
  234. },
  235. /** 修改按钮操作 */
  236. handleUpdate() {
  237. console.log(this.currentSelection[0]);
  238. this.form.name = this.currentSelection[0].sourceName;
  239. this.form.remark = null;
  240. this.form.type = null;
  241. this.handleList = this.handleList2
  242. // this.form = this.currentSelection[0] || {}
  243. // getPreHandleResult(id).then(response => {
  244. // this.form = response.data;
  245. this.open = true;
  246. this.title = "处理数据";
  247. // });
  248. },
  249. /** 提交按钮 */
  250. submitForm() {
  251. if (this.form.type == '手动处理') {
  252. this.handOpen = true
  253. this.open = false;
  254. return
  255. }
  256. this.butLoading = true;
  257. this.butText = "分析中...";
  258. setTimeout(() => {
  259. // 服务获取文件
  260. let dataObj = {
  261. name: `处理后数据_${new Date().getTime()}.xlsx`,
  262. sourceName: this.form.name,
  263. type: this.form.type,
  264. remark: this.form.remark,
  265. };
  266. let data = JSON.parse(localStorage.getItem("pro-data-analyze")) || [];
  267. data.push(dataObj);
  268. localStorage.setItem("pro-data-analyze", JSON.stringify(data));
  269. this.getList();
  270. // 保存指定路径
  271. this.butLoading = false;
  272. this.butText = "开始解析";
  273. this.$modal.msgSuccess("解析成功");
  274. this.open = false;
  275. }, 1000);
  276. // this.$refs["form"].validate(valid => {
  277. // if (valid) {
  278. // if (this.form.id != null) {
  279. // updatePreHandleResult(this.form).then(response => {
  280. // this.$modal.msgSuccess("修改成功");
  281. // this.open = false;
  282. // this.getList();
  283. // });
  284. // } else {
  285. // addPreHandleResult(this.form).then(response => {
  286. // this.$modal.msgSuccess("新增成功");
  287. // this.open = false;
  288. // this.getList();
  289. // });
  290. // }
  291. // }
  292. // });
  293. },
  294. /** 删除按钮操作 */
  295. handleDelete(row) {
  296. const ids = row.id || this.ids;
  297. this.$modal.confirm('是否确认删除数据预处理结果编号为"' + ids + '"的数据项?').then(function() {
  298. return delPreHandleResult(ids);
  299. }).then(() => {
  300. this.getList();
  301. this.$modal.msgSuccess("删除成功");
  302. }).catch(() => {});
  303. },
  304. /** 导出按钮操作 */
  305. handleExport() {
  306. this.download('manage/preHandleResult/export', {
  307. ...this.queryParams
  308. }, `preHandleResult_${new Date().getTime()}.xlsx`)
  309. }
  310. }
  311. };
  312. </script>