index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  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="object">
  5. <el-input
  6. v-model="queryParams.object"
  7. placeholder="请输入监测对象"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item label="监测参数" prop="parameter">
  13. <el-input
  14. v-model="queryParams.parameter"
  15. placeholder="请输入监测参数"
  16. clearable
  17. @keyup.enter.native="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item label="状态条件" prop="stateCondition">
  21. <el-input
  22. v-model="queryParams.stateCondition"
  23. placeholder="请输入状态条件"
  24. clearable
  25. @keyup.enter.native="handleQuery"
  26. />
  27. </el-form-item>
  28. <el-form-item label="取值方法" prop="valueMethod">
  29. <el-input
  30. v-model="queryParams.valueMethod"
  31. placeholder="请输入取值方法"
  32. clearable
  33. @keyup.enter.native="handleQuery"
  34. />
  35. </el-form-item>
  36. <el-form-item label="警戒值" prop="alarmValue">
  37. <el-input
  38. v-model="queryParams.alarmValue"
  39. placeholder="请输入警戒值"
  40. clearable
  41. @keyup.enter.native="handleQuery"
  42. />
  43. </el-form-item>
  44. <el-form-item label="门限值" prop="thresholdValue">
  45. <el-input
  46. v-model="queryParams.thresholdValue"
  47. placeholder="请输入门限值"
  48. clearable
  49. @keyup.enter.native="handleQuery"
  50. />
  51. </el-form-item>
  52. <el-form-item>
  53. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  54. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  55. </el-form-item>
  56. </el-form>
  57. <el-row :gutter="10" class="mb8">
  58. <el-col :span="1.5">
  59. <el-button
  60. type="primary"
  61. plain
  62. icon="el-icon-plus"
  63. size="mini"
  64. @click="handleAdd"
  65. v-hasPermi="['manage:performanceMonitorModel:add']"
  66. >新增</el-button>
  67. </el-col>
  68. <el-col :span="1.5">
  69. <el-button
  70. type="danger"
  71. plain
  72. icon="el-icon-delete"
  73. size="mini"
  74. :disabled="multiple"
  75. @click="handleDelete"
  76. v-hasPermi="['manage:performanceMonitorModel:remove']"
  77. >删除</el-button>
  78. </el-col>
  79. <el-col :span="1.5">
  80. <el-button
  81. type="warning"
  82. plain
  83. icon="el-icon-download"
  84. size="mini"
  85. @click="handleExport"
  86. v-hasPermi="['manage:performanceMonitorModel:export']"
  87. >导出</el-button>
  88. </el-col>
  89. <el-col :span="1.5">
  90. <el-button type="primary" icon="el-icon-upload2" size="mini" @click="handleImport"
  91. v-hasPermi="['manage:performanceMonitorModel:export']">导入</el-button>
  92. </el-col>
  93. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  94. </el-row>
  95. <el-table v-loading="loading" border :data="performanceMonitorModelList" @selection-change="handleSelectionChange">
  96. <el-table-column type="selection" width="55" align="center" />
  97. <el-table-column label="监测对象" align="center" prop="object" />
  98. <el-table-column label="监测参数" align="center" prop="parameter" />
  99. <el-table-column label="状态条件" align="center" prop="stateCondition" />
  100. <el-table-column label="取值方法" align="center" prop="valueMethod" />
  101. <el-table-column label="警戒值" align="center" prop="alarmValue" />
  102. <el-table-column label="门限值" align="center" prop="thresholdValue" />
  103. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  104. <template slot-scope="scope">
  105. <el-button
  106. size="mini"
  107. type="text"
  108. icon="el-icon-edit"
  109. @click="handleUpdate(scope.row)"
  110. v-hasPermi="['manage:performanceMonitorModel:edit']"
  111. >修改</el-button>
  112. </template>
  113. </el-table-column>
  114. </el-table>
  115. <pagination
  116. v-show="total>0"
  117. :total="total"
  118. :page.sync="queryParams.pageNum"
  119. :limit.sync="queryParams.pageSize"
  120. @pagination="getList"
  121. />
  122. <!-- 添加或修改性能监测模型信息对话框 -->
  123. <el-dialog :title="title" :visible.sync="open" :close-on-click-modal="false" width="500px" append-to-body>
  124. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  125. <el-form-item label="监测对象" prop="object">
  126. <el-input v-model="form.object" placeholder="请输入监测对象" />
  127. </el-form-item>
  128. <el-form-item label="监测参数" prop="parameter">
  129. <el-input v-model="form.parameter" placeholder="请输入监测参数" />
  130. </el-form-item>
  131. <el-form-item label="状态条件" prop="stateCondition">
  132. <el-input v-model="form.stateCondition" placeholder="请输入状态条件" />
  133. </el-form-item>
  134. <el-form-item label="取值方法" prop="valueMethod">
  135. <el-input v-model="form.valueMethod" placeholder="请输入取值方法" />
  136. </el-form-item>
  137. <el-form-item label="警戒值" prop="alarmValue">
  138. <el-input v-model="form.alarmValue" placeholder="请输入警戒值" />
  139. </el-form-item>
  140. <el-form-item label="门限值" prop="thresholdValue">
  141. <el-input v-model="form.thresholdValue" placeholder="请输入门限值" />
  142. </el-form-item>
  143. </el-form>
  144. <div slot="footer" class="dialog-footer">
  145. <el-button type="primary" @click="submitForm">确 定</el-button>
  146. <el-button @click="cancel">取 消</el-button>
  147. </div>
  148. </el-dialog>
  149. <!-- 导入对话框 -->
  150. <el-dialog :title="upload.title" :visible.sync="upload.open" :close-on-click-modal="false" width="400px" append-to-body>
  151. <el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers"
  152. :action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading"
  153. :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
  154. <i class="el-icon-upload"></i>
  155. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  156. <div class="el-upload__tip text-center" slot="tip">
  157. <div class="el-upload__tip" slot="tip">
  158. <el-checkbox v-model="upload.updateSupport" />
  159. 是否更新已经存在的性能监测模型
  160. </div>
  161. <span>仅允许导入xls、xlsx格式文件。</span>
  162. <el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline"
  163. @click="importTemplate">下载模板</el-link>
  164. </div>
  165. </el-upload>
  166. <div slot="footer" class="dialog-footer">
  167. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  168. <el-button @click="upload.open = false">取 消</el-button>
  169. </div>
  170. </el-dialog>
  171. </div>
  172. </template>
  173. <script>
  174. import { listPerformanceMonitorModel, getPerformanceMonitorModel, delPerformanceMonitorModel, addPerformanceMonitorModel, updatePerformanceMonitorModel } from "@/api/manage/performanceMonitorModel";
  175. import { getToken } from '@/utils/auth'
  176. export default {
  177. name: "PerformanceMonitorModel",
  178. data() {
  179. return {
  180. // 遮罩层
  181. loading: true,
  182. // 选中数组
  183. ids: [],
  184. // 非单个禁用
  185. single: true,
  186. // 非多个禁用
  187. multiple: true,
  188. // 显示搜索条件
  189. showSearch: true,
  190. // 总条数
  191. total: 0,
  192. // 性能监测模型信息表格数据
  193. performanceMonitorModelList: [],
  194. // 弹出层标题
  195. title: "",
  196. // 是否显示弹出层
  197. open: false,
  198. // 查询参数
  199. queryParams: {
  200. pageNum: 1,
  201. pageSize: 10,
  202. object: null,
  203. parameter: null,
  204. stateCondition: null,
  205. valueMethod: null,
  206. alarmValue: null,
  207. thresholdValue: null,
  208. },
  209. upload: {
  210. title: '',
  211. // 是否显示弹出层
  212. open: false,
  213. // 是否禁用上传
  214. isUploading: false,
  215. // 设置上传的请求头部
  216. headers: { Authorization: 'Bearer ' + getToken() },
  217. // 是否更新已存在数据
  218. updateSupport: 0,
  219. // 上传的地址
  220. url: process.env.VUE_APP_BASE_API + '/manage/falseAlarmRestrainModel/import',
  221. },
  222. // 表单参数
  223. form: {},
  224. // 表单校验
  225. rules: {
  226. }
  227. };
  228. },
  229. created() {
  230. this.getList();
  231. },
  232. methods: {
  233. /** 查询性能监测模型信息列表 */
  234. getList() {
  235. this.loading = true;
  236. listPerformanceMonitorModel(this.queryParams).then(response => {
  237. this.performanceMonitorModelList = response.rows;
  238. this.total = response.total;
  239. this.loading = false;
  240. });
  241. },
  242. // 取消按钮
  243. cancel() {
  244. this.open = false;
  245. this.reset();
  246. },
  247. // 表单重置
  248. reset() {
  249. this.form = {
  250. id: null,
  251. object: null,
  252. parameter: null,
  253. stateCondition: null,
  254. valueMethod: null,
  255. alarmValue: null,
  256. thresholdValue: null,
  257. };
  258. this.resetForm("form");
  259. },
  260. /** 搜索按钮操作 */
  261. handleQuery() {
  262. this.queryParams.pageNum = 1;
  263. this.getList();
  264. },
  265. /** 重置按钮操作 */
  266. resetQuery() {
  267. this.resetForm("queryForm");
  268. this.handleQuery();
  269. },
  270. // 多选框选中数据
  271. handleSelectionChange(selection) {
  272. this.ids = selection.map(item => item.id)
  273. this.single = selection.length!==1
  274. this.multiple = !selection.length
  275. },
  276. /** 新增按钮操作 */
  277. handleAdd() {
  278. this.reset();
  279. this.open = true;
  280. this.title = "添加性能监测模型信息";
  281. },
  282. /** 修改按钮操作 */
  283. handleUpdate(row) {
  284. this.reset();
  285. const id = row.id || this.ids
  286. getPerformanceMonitorModel(id).then(response => {
  287. this.form = response.data;
  288. this.open = true;
  289. this.title = "修改性能监测模型信息";
  290. });
  291. },
  292. /** 提交按钮 */
  293. submitForm() {
  294. this.$refs["form"].validate(valid => {
  295. if (valid) {
  296. if (this.form.id != null) {
  297. updatePerformanceMonitorModel(this.form).then(response => {
  298. this.$modal.msgSuccess("修改成功");
  299. this.open = false;
  300. this.getList();
  301. });
  302. } else {
  303. addPerformanceMonitorModel(this.form).then(response => {
  304. this.$modal.msgSuccess("新增成功");
  305. this.open = false;
  306. this.getList();
  307. });
  308. }
  309. }
  310. });
  311. },
  312. /** 删除按钮操作 */
  313. handleDelete(row) {
  314. const ids = row.id || this.ids;
  315. this.$modal.confirm('是否确认删除性能监测模型信息编号为"' + ids + '"的数据项?').then(function() {
  316. return delPerformanceMonitorModel(ids);
  317. }).then(() => {
  318. this.getList();
  319. this.$modal.msgSuccess("删除成功");
  320. }).catch(() => {});
  321. },
  322. /** 导入按钮操作 */
  323. handleImport() {
  324. this.upload.title = '性能监测模型导入'
  325. this.upload.open = true
  326. },
  327. submitFileForm() {
  328. this.$refs.upload.submit()
  329. },
  330. // 文件上传中处理
  331. handleFileUploadProgress(event, file, fileList) {
  332. this.upload.isUploading = true
  333. },
  334. // 文件上传成功处理
  335. handleFileSuccess(response, file, fileList) {
  336. if (response.code !== 200) {
  337. this.$modal.msgError(response.msg)
  338. return
  339. }
  340. this.upload.open = false
  341. this.upload.isUploading = false
  342. this.$refs.upload.clearFiles()
  343. this.$alert(
  344. "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
  345. response.msg +
  346. '</div>',
  347. '导入结果',
  348. { dangerouslyUseHTMLString: true }
  349. )
  350. this.getList()
  351. },
  352. /** 下载模板操作 */
  353. importTemplate() {
  354. this.download(
  355. '/manage/performanceMonitorModel/importTemplate',
  356. {},
  357. `performanceMonitorModel_template_${new Date().getTime()}.xlsx`
  358. )
  359. },
  360. /** 导出按钮操作 */
  361. handleExport() {
  362. this.download('manage/performanceMonitorModel/export', {
  363. ...this.queryParams
  364. }, `performanceMonitorModel_${new Date().getTime()}.xlsx`)
  365. }
  366. }
  367. };
  368. </script>