index.vue 8.4 KB

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