index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="实验室id" prop="subjectId">
  5. <el-input
  6. v-model="queryParams.subjectId"
  7. placeholder="请输入实验室id"
  8. clearable
  9. size="small"
  10. />
  11. </el-form-item>
  12. <el-form-item label="房间编号" prop="room">
  13. <el-input
  14. v-model="queryParams.room"
  15. placeholder="请输入房间编号"
  16. clearable
  17. size="small"
  18. />
  19. </el-form-item>
  20. <el-form-item label="楼层标识" prop="floorId">
  21. <el-input
  22. v-model="queryParams.floorId"
  23. placeholder="请输入楼层标识"
  24. clearable
  25. size="small"
  26. />
  27. </el-form-item>
  28. <el-form-item label="部门名称" prop="deptName">
  29. <el-input
  30. v-model="queryParams.deptName"
  31. placeholder="请输入部门名称"
  32. clearable
  33. size="small"
  34. />
  35. </el-form-item>
  36. <el-form-item label="部门id" prop="deptId">
  37. <el-input
  38. v-model="queryParams.deptId"
  39. placeholder="请输入部门id"
  40. clearable
  41. size="small"
  42. />
  43. </el-form-item>
  44. <el-form-item label="创建人" prop="userId">
  45. <el-input
  46. v-model="queryParams.userId"
  47. placeholder="请输入创建人"
  48. clearable
  49. size="small"
  50. />
  51. </el-form-item>
  52. <el-form-item label="实验室布局宽度" prop="layWidth">
  53. <el-input
  54. v-model="queryParams.layWidth"
  55. placeholder="请输入实验室布局宽度"
  56. clearable
  57. size="small"
  58. />
  59. </el-form-item>
  60. <el-form-item label="实验室布局高度" prop="layHeight">
  61. <el-input
  62. v-model="queryParams.layHeight"
  63. placeholder="请输入实验室布局高度"
  64. clearable
  65. size="small"
  66. />
  67. </el-form-item>
  68. <el-form-item label="实验室顺序" prop="layOrder">
  69. <el-input
  70. v-model="queryParams.layOrder"
  71. placeholder="请输入实验室顺序"
  72. clearable
  73. size="small"
  74. />
  75. </el-form-item>
  76. <el-form-item label="是否是实验室(1是,0是否)" prop="isSubject">
  77. <el-input
  78. v-model="queryParams.isSubject"
  79. placeholder="请输入是否是实验室(1是,0是否)"
  80. clearable
  81. size="small"
  82. />
  83. </el-form-item>
  84. <el-form-item>
  85. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  86. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  87. </el-form-item>
  88. </el-form>
  89. <el-row :gutter="10" class="mb8">
  90. <el-col :span="1.5">
  91. <el-button
  92. type="primary"
  93. plain
  94. icon="el-icon-plus"
  95. size="mini"
  96. @click="handleAdd"
  97. v-hasPermi="['laboratory:layout:add']"
  98. >新增</el-button>
  99. </el-col>
  100. <el-col :span="1.5">
  101. <el-button
  102. type="success"
  103. plain
  104. icon="el-icon-edit"
  105. size="mini"
  106. :disabled="single"
  107. @click="handleUpdate"
  108. v-hasPermi="['laboratory:layout:edit']"
  109. >修改</el-button>
  110. </el-col>
  111. <el-col :span="1.5">
  112. <el-button
  113. type="danger"
  114. plain
  115. icon="el-icon-delete"
  116. size="mini"
  117. :disabled="multiple"
  118. @click="handleDelete"
  119. v-hasPermi="['laboratory:layout:remove']"
  120. >删除</el-button>
  121. </el-col>
  122. <el-col :span="1.5">
  123. <el-button
  124. type="warning"
  125. plain
  126. icon="el-icon-download"
  127. size="mini"
  128. @click="handleExport"
  129. v-hasPermi="['laboratory:layout:export']"
  130. >导出</el-button>
  131. </el-col>
  132. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  133. </el-row>
  134. <el-table v-loading="loading" border :data="layoutList" @selection-change="handleSelectionChange">
  135. <el-table-column type="selection" width="55" align="center" />
  136. <el-table-column label="自增主键" align="left" prop="id" />
  137. <el-table-column label="实验室id" align="left" prop="subjectId" />
  138. <el-table-column label="房间编号" align="left" prop="room" />
  139. <el-table-column label="楼层标识" align="left" prop="floorId" />
  140. <el-table-column label="部门名称" align="left" prop="deptName" />
  141. <el-table-column label="部门id" align="left" prop="deptId" />
  142. <el-table-column label="创建人" align="left" prop="userId" />
  143. <el-table-column label="实验室布局宽度" align="left" prop="layWidth" />
  144. <el-table-column label="实验室布局高度" align="left" prop="layHeight" />
  145. <el-table-column label="实验室顺序" align="left" prop="layOrder" />
  146. <el-table-column label="是否是实验室(1是,0是否)" align="left" prop="isSubject" />
  147. <el-table-column label="备注" align="left" prop="remark" />
  148. <el-table-column label="操作" align="left" class-name="small-padding fixed-width" v-if="tableButtonType">
  149. <template slot-scope="scope">
  150. <div class="table-button-box">
  151. <p class="table-button-null"></p>
  152. <p class="table-button-p"
  153. @click="handleUpdate(scope.row)"
  154. v-hasPermi="['laboratory:layout:edit']">修改</p>
  155. <p class="table-button-p"
  156. @click="handleDelete(scope.row)"
  157. v-hasPermi="['laboratory:layout:remove']">删除</p>
  158. <p class="table-button-null"></p>
  159. </div>
  160. </template>
  161. </el-table-column>
  162. </el-table>
  163. <pagination
  164. v-show="total>0"
  165. :total="total"
  166. :page.sync="queryParams.pageNum"
  167. :limit.sync="queryParams.pageSize"
  168. @pagination="getList"
  169. />
  170. <!-- 添加或修改实验室布局对话框 -->
  171. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body
  172. :close-on-click-modal="false">
  173. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  174. <el-form-item label="实验室id" prop="subjectId">
  175. <el-input v-model="form.subjectId" placeholder="请输入实验室id" />
  176. </el-form-item>
  177. <el-form-item label="房间编号" prop="room">
  178. <el-input v-model="form.room" placeholder="请输入房间编号" />
  179. </el-form-item>
  180. <el-form-item label="楼层标识" prop="floorId">
  181. <el-input v-model="form.floorId" placeholder="请输入楼层标识" />
  182. </el-form-item>
  183. <el-form-item label="实验室布局宽度" prop="layWidth">
  184. <el-input v-model="form.layWidth" placeholder="请输入实验室布局宽度" />
  185. </el-form-item>
  186. <el-form-item label="实验室布局高度" prop="layHeight">
  187. <el-input v-model="form.layHeight" placeholder="请输入实验室布局高度" />
  188. </el-form-item>
  189. <el-form-item label="实验室顺序" prop="layOrder">
  190. <el-input v-model="form.layOrder" placeholder="请输入实验室顺序" />
  191. </el-form-item>
  192. <el-form-item label="是否是实验室(1是,0是否)" prop="isSubject">
  193. <el-input v-model="form.isSubject" placeholder="请输入是否是实验室(1是,0是否)" />
  194. </el-form-item>
  195. <el-form-item label="备注" prop="remark">
  196. <el-input v-model="form.remark" placeholder="请输入备注" />
  197. </el-form-item>
  198. </el-form>
  199. <div slot="footer" class="dialog-footer">
  200. <el-button @click="cancel">取 消</el-button>
  201. <el-button type="primary" @click="submitForm">确 定</el-button>
  202. </div>
  203. </el-dialog>
  204. </div>
  205. </template>
  206. <script>
  207. import { listLayout, getLayout, delLayout, addLayout, updateLayout } from "@/api/laboratory/layout";
  208. export default {
  209. name: "Layout",
  210. data() {
  211. return {
  212. tableButtonType:this.hasPermiDom(['laboratory:layout:edit','laboratory:layout:remove']),
  213. // 遮罩层
  214. loading: true,
  215. // 选中数组
  216. ids: [],
  217. // 非单个禁用
  218. single: true,
  219. // 非多个禁用
  220. multiple: true,
  221. // 显示搜索条件
  222. showSearch: true,
  223. // 总条数
  224. total: 0,
  225. // 实验室布局表格数据
  226. layoutList: [],
  227. // 弹出层标题
  228. title: "",
  229. // 是否显示弹出层
  230. open: false,
  231. // 查询参数
  232. queryParams: {
  233. pageNum: 1,
  234. pageSize:20,
  235. subjectId: null,
  236. room: null,
  237. floorId: null,
  238. deptName: null,
  239. deptId: null,
  240. userId: null,
  241. layWidth: null,
  242. layHeight: null,
  243. layOrder: null,
  244. isSubject: null,
  245. },
  246. // 表单参数
  247. form: {},
  248. // 表单校验
  249. rules: {
  250. }
  251. };
  252. },
  253. created() {
  254. this.getList();
  255. },
  256. methods: {
  257. /** 查询实验室布局列表 */
  258. getList() {
  259. this.loading = true;
  260. listLayout(this.queryParams).then( response => {
  261. this.layoutList = response.rows;
  262. this.total = response.total;
  263. this.loading = false;
  264. });
  265. },
  266. // 取消按钮
  267. cancel() {
  268. this.open = false;
  269. this.reset();
  270. },
  271. // 表单重置
  272. reset() {
  273. this.form = {
  274. id: null,
  275. subjectId: null,
  276. room: null,
  277. floorId: null,
  278. deptName: null,
  279. deptId: null,
  280. createTime: null,
  281. userId: null,
  282. createBy: null,
  283. updateTime: null,
  284. updateBy: null,
  285. layWidth: null,
  286. layHeight: null,
  287. layOrder: null,
  288. isSubject: null,
  289. remark: null
  290. };
  291. this.resetForm("form");
  292. },
  293. /** 搜索按钮操作 */
  294. handleQuery() {
  295. this.queryParams.pageNum = 1;
  296. this.getList();
  297. },
  298. /** 重置按钮操作 */
  299. resetQuery() {
  300. this.resetForm("queryForm");
  301. this.handleQuery();
  302. },
  303. // 多选框选中数据
  304. handleSelectionChange(selection) {
  305. this.ids = selection.map(item => item.id)
  306. this.single = selection.length!==1
  307. this.multiple = !selection.length
  308. },
  309. /** 新增按钮操作 */
  310. handleAdd() {
  311. this.reset();
  312. this.open = true;
  313. this.title = "添加实验室布局";
  314. },
  315. /** 修改按钮操作 */
  316. handleUpdate(row) {
  317. this.reset();
  318. const id = row.id || this.ids
  319. getLayout(id).then( response => {
  320. this.form = response.data;
  321. this.open = true;
  322. this.title = "修改实验室布局";
  323. });
  324. },
  325. /** 提交按钮 */
  326. submitForm() {
  327. this.$refs["form"].validate(valid => {
  328. if (valid) {
  329. if (this.form.id != null) {
  330. updateLayout(this.form).then( response => {
  331. this.msgSuccess("修改成功");
  332. this.open = false;
  333. this.getList();
  334. });
  335. } else {
  336. addLayout(this.form).then( response => {
  337. this.msgSuccess("新增成功");
  338. this.open = false;
  339. this.getList();
  340. });
  341. }
  342. }
  343. });
  344. },
  345. /** 删除按钮操作 */
  346. handleDelete(row) {
  347. const ids = row.id || this.ids;
  348. this.$confirm('确认删除实验室布局吗?', "警告", {
  349. confirmButtonText: "确定",
  350. cancelButtonText: "取消",
  351. type: "warning"
  352. }).then(function() {
  353. return delLayout(ids);
  354. }).then(() => {
  355. this.getList();
  356. this.msgSuccess("删除成功");
  357. }).catch(() => {});
  358. },
  359. /** 导出按钮操作 */
  360. handleExport() {
  361. this.download('laboratory/layout/export', {
  362. ...this.queryParams
  363. }, `laboratory_layout.xlsx`)
  364. }
  365. }
  366. };
  367. </script>