index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <template>
  2. <div class="app-container">
  3. <el-table border height="760" v-loading="loading" :data="safeLevelList" @selection-change="handleSelectionChange">
  4. <el-table-column label="安全等级" align="center" prop="levelName"/>
  5. <el-table-column label="风险等级" align="center" prop="riskLevel">
  6. <template slot-scope="scope">
  7. <dict-tag :options="dict.type.risk_level" :value="scope.row.riskLevel"/>
  8. </template>
  9. </el-table-column>
  10. <el-table-column label="得分区间:" align="center" prop="description"/>
  11. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  12. <template slot-scope="scope">
  13. <el-button
  14. size="mini"
  15. type="text"
  16. icon="el-icon-edit"
  17. @click="handleUpdate(scope.row)"
  18. v-hasPermi="['core.safetyIndex:safeLevel:edit']"
  19. >修改
  20. </el-button>
  21. <el-button
  22. size="mini"
  23. type="text"
  24. icon="el-icon-view"
  25. @click="handleDetail(scope.row)"
  26. v-hasPermi="['core.safetyIndex:safeLevel:edit']"
  27. >查看
  28. </el-button>
  29. </template>
  30. </el-table-column>
  31. </el-table>
  32. <pagination
  33. v-show="total>0"
  34. :total="total"
  35. :page.sync="queryParams.pageNum"
  36. :limit.sync="queryParams.pageSize"
  37. @pagination="getList"
  38. />
  39. <!-- 添加或修改安全等级配置对话框 -->
  40. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  41. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  42. <el-form-item label="等级名称" prop="levelName">
  43. <el-input v-model="form.levelName" placeholder="请输入安全等级名称" disabled/>
  44. </el-form-item>
  45. <el-form-item label="等级风险" prop="riskLevel">
  46. <el-select disabled style="width: 100%" v-model="form.riskLevel" placeholder="请选择等级风险">
  47. <el-option v-for="dict in dict.type.risk_level" :key="dict.value" :label="dict.label"
  48. :value="parseInt(dict.value)"></el-option>
  49. </el-select>
  50. </el-form-item>
  51. <el-form-item label="最小值" prop="minValue">
  52. <el-input-number style="width: 100%" :max="100" :min="0" :disabled="this.title=='查看安全等级配置'" v-model="form.minValue" placeholder="请输入最小值"/>
  53. </el-form-item>
  54. <el-form-item label="最大值" prop="maxValue">
  55. <el-input-number style="width: 100%" :max="100" :min="0" :disabled="this.title=='查看安全等级配置'" v-model="form.maxValue" placeholder="请输入最大值"/>
  56. </el-form-item>
  57. </el-form>
  58. <div slot="footer" class="dialog-footer">
  59. <el-button v-if="this.title!='查看安全等级配置'" type="primary" @click="submitForm">确 定</el-button>
  60. <el-button @click="cancel">取 消</el-button>
  61. </div>
  62. </el-dialog>
  63. </div>
  64. </template>
  65. <script>
  66. import {listSafeLevel, getSafeLevel, delSafeLevel, addSafeLevel, updateSafeLevel} from "@/api/core/safeLevel/safeLevel";
  67. export default {
  68. name: "SafeLevel",
  69. dicts: ["risk_level"],
  70. data() {
  71. return {
  72. // 遮罩层
  73. loading: true,
  74. // 选中数组
  75. ids: [],
  76. // 非单个停用
  77. single: true,
  78. // 非多个停用
  79. multiple: true,
  80. // 显示搜索条件
  81. showSearch: true,
  82. // 总条数
  83. total: 0,
  84. // 安全等级配置表格数据
  85. safeLevelList: [],
  86. // 弹出层标题
  87. title: "",
  88. // 是否显示弹出层
  89. open: false,
  90. // 查询参数
  91. queryParams: {
  92. pageNum: 1,
  93. pageSize: 10,
  94. levelName: null,
  95. minValue: null,
  96. maxValue: null,
  97. riskLevel: null,
  98. description: null
  99. },
  100. // 表单参数
  101. form: {},
  102. // 表单校验
  103. rules: {}
  104. };
  105. },
  106. created() {
  107. this.getList();
  108. },
  109. methods: {
  110. /** 查询安全等级配置列表 */
  111. getList() {
  112. this.loading = true;
  113. listSafeLevel(this.queryParams).then(response => {
  114. this.safeLevelList = response.rows;
  115. this.total = response.total;
  116. this.loading = false;
  117. });
  118. },
  119. // 取消按钮
  120. cancel() {
  121. this.open = false;
  122. this.reset();
  123. },
  124. // 表单重置
  125. reset() {
  126. this.form = {
  127. id: null,
  128. levelName: null,
  129. minValue: null,
  130. maxValue: null,
  131. riskLevel: null,
  132. description: null
  133. };
  134. this.resetForm("form");
  135. },
  136. /** 搜索按钮操作 */
  137. handleQuery() {
  138. this.queryParams.pageNum = 1;
  139. this.getList();
  140. },
  141. /** 重置按钮操作 */
  142. resetQuery() {
  143. this.resetForm("queryForm");
  144. this.handleQuery();
  145. },
  146. // 多选框选中数据
  147. handleSelectionChange(selection) {
  148. this.ids = selection.map(item => item.id)
  149. this.single = selection.length !== 1
  150. this.multiple = !selection.length
  151. },
  152. /** 新增按钮操作 */
  153. handleAdd() {
  154. this.reset();
  155. this.open = true;
  156. this.title = "添加安全等级配置";
  157. },
  158. /** 修改按钮操作 */
  159. handleUpdate(row) {
  160. this.reset();
  161. const id = row.id || this.ids
  162. getSafeLevel(id).then(response => {
  163. this.form = response.data;
  164. this.open = true;
  165. this.title = "修改安全等级配置";
  166. });
  167. },
  168. /** 查看按钮操作 */
  169. handleDetail(row){
  170. this.reset();
  171. const id = row.id || this.ids
  172. getSafeLevel(id).then(response => {
  173. this.form = response.data;
  174. this.open = true;
  175. this.title = "查看安全等级配置";
  176. });
  177. },
  178. /** 提交按钮 */
  179. submitForm() {
  180. this.$refs["form"].validate(valid => {
  181. if (valid) {
  182. console.log("this.form.minValue",this.form.minValue)
  183. console.log("this.form.maxValue",this.form.maxValue)
  184. if (this.form.minValue > this.form.maxValue) {
  185. this.$modal.msgError("最小值不能大于最大值");
  186. return;
  187. }
  188. if (this.form.minValue < 0 || this.form.maxValue < 0) {
  189. this.$modal.msgError("最小值或最大值不能小于0")
  190. return;
  191. }
  192. if (this.form.maxValue > 100) {
  193. this.$modal.msgError("最大值不能大于100");
  194. return;
  195. }
  196. if (this.form.id != null) {
  197. updateSafeLevel(this.form).then(response => {
  198. this.$modal.msgSuccess("修改成功");
  199. this.open = false;
  200. this.getList();
  201. });
  202. } else {
  203. addSafeLevel(this.form).then(response => {
  204. this.$modal.msgSuccess("新增成功");
  205. this.open = false;
  206. this.getList();
  207. });
  208. }
  209. }
  210. });
  211. },
  212. /** 删除按钮操作 */
  213. handleDelete(row) {
  214. const ids = row.id || this.ids;
  215. this.$modal.confirm('是否确认删除安全等级配置编号为"' + ids + '"的数据项?').then(function () {
  216. return delSafeLevel(ids);
  217. }).then(() => {
  218. this.getList();
  219. this.$modal.msgSuccess("删除成功");
  220. }).catch(() => {
  221. });
  222. },
  223. /** 导出按钮操作 */
  224. handleExport() {
  225. this.download('core.safetyindex/safeLevel/export', {
  226. ...this.queryParams
  227. }, `safeLevel_${new Date().getTime()}.xlsx`)
  228. }
  229. }
  230. };
  231. </script>