index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <!--安全分级-->
  2. <template>
  3. <div class="app-container class-ified-page">
  4. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  5. <el-form-item label="分级名称" prop="classifiedName">
  6. <el-input
  7. v-model="queryParams.classifiedName"
  8. placeholder="请输入分级名称"
  9. clearable
  10. size="small"
  11. />
  12. </el-form-item>
  13. <el-form-item style="float: right;">
  14. <el-col :span="1.5">
  15. <p class="add-button-one-120"
  16. style="margin-right:20px;"
  17. @click="handleAdd"
  18. v-hasPermi="['laboratory:classified:add']"
  19. ><i class="el-icon-plus"></i>新增</p>
  20. </el-col>
  21. </el-form-item>
  22. <el-form-item>
  23. <p class="inquire-button-one" @click="handleQuery">查询</p>
  24. <p class="reset-button-one" @click="resetQuery">重置</p>
  25. </el-form-item>
  26. </el-form>
  27. <el-table v-loading="loading" border :data="classifiedList" @selection-change="handleSelectionChange">
  28. <!--<el-table-column type="selection" width="55" align="center" />-->
  29. <el-table-column label="自增id" align="left" prop="id" v-if="false"/>
  30. <el-table-column label="部门名称" align="left" prop="deptName" v-if="false"/>
  31. <el-table-column label="部门id" align="left" prop="deptId" v-if="false"/>
  32. <el-table-column label="创建人" align="left" prop="userId" v-if="false"/>
  33. <el-table-column label="分级名称" align="left" prop="classifiedName" />
  34. <el-table-column label="颜色" align="left" prop="classifiedColor" >
  35. <template slot-scope="scope">
  36. <p :style="'width:40px;height:23px;margin:0;backAnimation:'+scope.row.classifiedColor"></p>
  37. </template>
  38. </el-table-column>
  39. <el-table-column label="备注" align="left" prop="remark" />
  40. <el-table-column label="创建时间" align="left" prop="createTime" />
  41. <el-table-column label="操作" align="left" class-name="small-padding fixed-width" width="160" v-if="tableButtonType">
  42. <template slot-scope="scope">
  43. <div class="button-box">
  44. <p class="table-min-button"
  45. @click="handleUpdate(scope.row)"
  46. v-hasPermiAnd="['laboratory:classified:query','laboratory:classified:edit']"
  47. >修改</p>
  48. <p class="table-min-button"
  49. @click="handleDelete(scope.row)"
  50. v-hasPermi="['laboratory:classified:remove']"
  51. >删除</p>
  52. </div>
  53. </template>
  54. </el-table-column>
  55. </el-table>
  56. <pagination
  57. v-show="total>0"
  58. :total="total"
  59. :page.sync="queryParams.pageNum"
  60. :limit.sync="queryParams.pageSize"
  61. @pagination="getList"
  62. />
  63. <!-- 添加或修改安全分级对话框 -->
  64. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  65. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  66. <el-form-item label="分级名称" prop="classifiedName">
  67. <el-input v-model="form.classifiedName" maxlength="4" placeholder="请输入内容" />
  68. </el-form-item>
  69. <el-form-item label="颜色" prop="classifiedColor">
  70. <el-color-picker v-model="form.classifiedColor"></el-color-picker>
  71. </el-form-item>
  72. <el-form-item label="备注" prop="remark">
  73. <el-input v-model="form.remark" type="textarea" placeholder="请输入备注" />
  74. </el-form-item>
  75. </el-form>
  76. <div slot="footer" class="dialog-footer">
  77. <el-button type="primary" @click="submitForm">确 定</el-button>
  78. <el-button @click="cancel">取 消</el-button>
  79. </div>
  80. </el-dialog>
  81. </div>
  82. </template>
  83. <script>
  84. import {
  85. addClassified,
  86. delClassified,
  87. getClassified,
  88. listClassified,
  89. updateClassified
  90. } from "@/api/laboratory/classified";
  91. export default {
  92. name: "Classified",
  93. data() {
  94. return {
  95. tableButtonType:this.hasPermiDom(['laboratory:classified:query','laboratory:classified:edit','laboratory:classified:remove']),
  96. // 遮罩层
  97. loading: true,
  98. // 选中数组
  99. ids: [],
  100. // 非单个禁用
  101. single: true,
  102. // 非多个禁用
  103. multiple: true,
  104. // 显示搜索条件
  105. showSearch: true,
  106. // 总条数
  107. total: 0,
  108. // 安全分级表格数据
  109. classifiedList: [],
  110. // 弹出层标题
  111. title: "",
  112. // 是否显示弹出层
  113. open: false,
  114. // 查询参数
  115. queryParams: {
  116. pageNum: 1,
  117. pageSize:20,
  118. deptName: null,
  119. deptId: null,
  120. userId: null,
  121. classifiedName: null
  122. },
  123. // 表单参数
  124. form: {},
  125. // 表单校验
  126. rules: {
  127. classifiedName: [
  128. { required: true, message: "请输入分级名称", trigger: "blur" },
  129. { required: true, message: "请输入分级名称", validator: this.spaceJudgment, trigger: "blur" }
  130. ],
  131. classifiedColor: [
  132. { required: true, message: "请选择颜色", trigger: "blur" }
  133. ],
  134. }
  135. };
  136. },
  137. created() {
  138. this.getList();
  139. },
  140. methods: {
  141. /** 查询安全分级列表 */
  142. getList() {
  143. this.loading = true;
  144. listClassified(this.queryParams).then( response => {
  145. this.classifiedList = response.rows;
  146. this.total = response.total;
  147. this.loading = false;
  148. });
  149. },
  150. // 取消按钮
  151. cancel() {
  152. this.open = false;
  153. this.reset();
  154. },
  155. // 表单重置
  156. reset() {
  157. this.form = {
  158. id: null,
  159. deptName: null,
  160. deptId: null,
  161. createTime: null,
  162. userId: null,
  163. createBy: null,
  164. updateTime: null,
  165. updateBy: null,
  166. remark: null,
  167. classifiedName: null
  168. };
  169. this.resetForm("form");
  170. },
  171. /** 搜索按钮操作 */
  172. handleQuery() {
  173. this.queryParams.pageNum = 1;
  174. this.getList();
  175. },
  176. /** 重置按钮操作 */
  177. resetQuery() {
  178. // this.resetForm("queryForm");
  179. this.$set(this,'queryParams',{
  180. pageNum: 1,
  181. pageSize:20,
  182. classifiedName:"",
  183. });
  184. this.handleQuery();
  185. },
  186. // 多选框选中数据
  187. handleSelectionChange(selection) {
  188. this.ids = selection.map(item => item.id)
  189. this.single = selection.length!==1
  190. this.multiple = !selection.length
  191. },
  192. /** 新增按钮操作 */
  193. handleAdd() {
  194. this.reset();
  195. this.open = true;
  196. this.title = "添加安全分级";
  197. },
  198. /** 修改按钮操作 */
  199. handleUpdate(row) {
  200. this.reset();
  201. const id = row.id || this.ids
  202. getClassified(id).then( response => {
  203. this.form = response.data;
  204. this.open = true;
  205. this.title = "修改安全分级";
  206. });
  207. },
  208. /** 提交按钮 */
  209. submitForm() {
  210. this.$refs["form"].validate(valid => {
  211. if (valid) {
  212. if (this.form.id != null) {
  213. updateClassified(this.form).then( response => {
  214. this.msgSuccess("修改成功");
  215. this.open = false;
  216. this.getList();
  217. });
  218. } else {
  219. addClassified(this.form).then( response => {
  220. this.msgSuccess("新增成功");
  221. this.open = false;
  222. this.getList();
  223. });
  224. }
  225. }
  226. });
  227. },
  228. /** 删除按钮操作 */
  229. handleDelete(row) {
  230. const ids = row.id || this.ids;
  231. this.$confirm('是否确认删除安全分级编号为"' + ids + '"的数据项?', "警告", {
  232. confirmButtonText: "确定",
  233. cancelButtonText: "取消",
  234. type: "warning"
  235. }).then(function() {
  236. return delClassified(ids);
  237. }).then(() => {
  238. this.getList();
  239. this.msgSuccess("删除成功");
  240. }).catch(() => {});
  241. },
  242. /** 导出按钮操作 */
  243. handleExport() {
  244. this.download('laboratory/classified/export', {
  245. ...this.queryParams
  246. }, `laboratory_classified.xlsx`)
  247. }
  248. }
  249. };
  250. </script>
  251. <style scoped lang="scss">
  252. .class-ified-page {
  253. display: flex!important;
  254. flex-direction: column;
  255. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  256. padding:20px!important;
  257. .button-box{
  258. display: flex;
  259. width:190px;
  260. margin:0 auto;
  261. }
  262. }
  263. </style>