subjectClass.vue 8.4 KB

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