index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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="材料名称" prop="materialName">
  5. <el-input
  6. v-model="queryParams.materialName"
  7. placeholder="请输入材料名称"
  8. clearable
  9. size="small"
  10. />
  11. </el-form-item>
  12. <el-form-item label="配置表关联id" prop="configureId">
  13. <el-input
  14. v-model="queryParams.configureId"
  15. placeholder="请输入配置表关联id"
  16. clearable
  17. size="small"
  18. />
  19. </el-form-item>
  20. <el-form-item>
  21. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  22. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  23. </el-form-item>
  24. </el-form>
  25. <el-row :gutter="10" class="mb8">
  26. <el-col :span="1.5">
  27. <el-button
  28. type="primary"
  29. plain
  30. icon="el-icon-plus"
  31. size="mini"
  32. @click="handleAdd"
  33. v-hasPermi="['laboratory:material:add']"
  34. >新增</el-button>
  35. </el-col>
  36. <el-col :span="1.5">
  37. <el-button
  38. type="success"
  39. plain
  40. icon="el-icon-edit"
  41. size="mini"
  42. :disabled="single"
  43. @click="handleUpdate"
  44. v-hasPermi="['laboratory:material:edit']"
  45. >修改</el-button>
  46. </el-col>
  47. <el-col :span="1.5">
  48. <el-button
  49. type="danger"
  50. plain
  51. icon="el-icon-delete"
  52. size="mini"
  53. :disabled="multiple"
  54. @click="handleDelete"
  55. v-hasPermi="['laboratory:material:remove']"
  56. >删除</el-button>
  57. </el-col>
  58. <el-col :span="1.5">
  59. <el-button
  60. type="warning"
  61. plain
  62. icon="el-icon-download"
  63. size="mini"
  64. @click="handleExport"
  65. v-hasPermi="['laboratory:material:export']"
  66. >导出</el-button>
  67. </el-col>
  68. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  69. </el-row>
  70. <el-table v-loading="loading" border :data="materialList" @selection-change="handleSelectionChange">
  71. <el-table-column type="selection" width="55" align="center" />
  72. <el-table-column label="主键id" align="left" prop="id" />
  73. <el-table-column label="材料名称" align="left" prop="materialName" />
  74. <el-table-column label="配置表关联id" align="left" prop="configureId" />
  75. <el-table-column label="备注" align="left" prop="remark" />
  76. <el-table-column label="操作" align="left" class-name="small-padding fixed-width" v-if="tableButtonType">
  77. <template slot-scope="scope">
  78. <el-button
  79. size="mini"
  80. type="text"
  81. icon="el-icon-edit"
  82. @click="handleUpdate(scope.row)"
  83. v-hasPermi="['laboratory:material:edit']"
  84. >修改</el-button>
  85. <el-button
  86. size="mini"
  87. type="text"
  88. icon="el-icon-delete"
  89. @click="handleDelete(scope.row)"
  90. v-hasPermi="['laboratory:material:remove']"
  91. >删除</el-button>
  92. </template>
  93. </el-table-column>
  94. </el-table>
  95. <pagination
  96. v-show="total>0"
  97. :total="total"
  98. layout="total, prev, pager, next, sizes, jumper"
  99. :page.sync="queryParams.pageNum"
  100. :limit.sync="queryParams.pageSize"
  101. @pagination="getList"
  102. />
  103. <!-- 添加或修改安全准入资格材料对话框 -->
  104. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  105. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  106. <el-form-item label="材料名称" prop="materialName">
  107. <el-input v-model="form.materialName" placeholder="请输入材料名称" />
  108. </el-form-item>
  109. <el-form-item label="配置表关联id" prop="configureId">
  110. <el-input v-model="form.configureId" placeholder="请输入配置表关联id" />
  111. </el-form-item>
  112. <el-form-item label="备注" prop="remark">
  113. <el-input v-model="form.remark" placeholder="请输入备注" />
  114. </el-form-item>
  115. </el-form>
  116. <div slot="footer" class="dialog-footer">
  117. <el-button @click="cancel">取 消</el-button>
  118. <el-button type="primary" @click="submitForm">确 定</el-button>
  119. </div>
  120. </el-dialog>
  121. </div>
  122. </template>
  123. <script>
  124. import { listMaterial, getMaterial, delMaterial, addMaterial, updateMaterial } from "@/api/laboratory/material";
  125. export default {
  126. name: "Material",
  127. data() {
  128. return {
  129. tableButtonType:this.hasPermiDom(['laboratory:material:edit','laboratory:material:remove']),
  130. // 遮罩层
  131. loading: true,
  132. // 选中数组
  133. ids: [],
  134. // 非单个禁用
  135. single: true,
  136. // 非多个禁用
  137. multiple: true,
  138. // 显示搜索条件
  139. showSearch: true,
  140. // 总条数
  141. total: 0,
  142. // 安全准入资格材料表格数据
  143. materialList: [],
  144. // 弹出层标题
  145. title: "",
  146. // 是否显示弹出层
  147. open: false,
  148. // 查询参数
  149. queryParams: {
  150. pageNum: 1,
  151. pageSize:20,
  152. materialName: null,
  153. configureId: null,
  154. },
  155. // 表单参数
  156. form: {},
  157. // 表单校验
  158. rules: {
  159. }
  160. };
  161. },
  162. created() {
  163. this.getList();
  164. },
  165. methods: {
  166. /** 查询安全准入资格材料列表 */
  167. getList() {
  168. this.loading = true;
  169. listMaterial(this.queryParams).then(response => {
  170. this.materialList = response.rows;
  171. this.total = response.total;
  172. this.loading = false;
  173. });
  174. },
  175. // 取消按钮
  176. cancel() {
  177. this.open = false;
  178. this.reset();
  179. },
  180. // 表单重置
  181. reset() {
  182. this.form = {
  183. id: null,
  184. materialName: null,
  185. configureId: null,
  186. remark: null
  187. };
  188. this.resetForm("form");
  189. },
  190. /** 搜索按钮操作 */
  191. handleQuery() {
  192. this.queryParams.pageNum = 1;
  193. this.getList();
  194. },
  195. /** 重置按钮操作 */
  196. resetQuery() {
  197. this.resetForm("queryForm");
  198. this.handleQuery();
  199. },
  200. // 多选框选中数据
  201. handleSelectionChange(selection) {
  202. this.ids = selection.map(item => item.id)
  203. this.single = selection.length!==1
  204. this.multiple = !selection.length
  205. },
  206. /** 新增按钮操作 */
  207. handleAdd() {
  208. this.reset();
  209. this.open = true;
  210. this.title = "添加安全准入资格材料";
  211. },
  212. /** 修改按钮操作 */
  213. handleUpdate(row) {
  214. this.reset();
  215. const id = row.id || this.ids
  216. getMaterial(id).then( response => {
  217. this.form = response.data;
  218. this.open = true;
  219. this.title = "修改安全准入资格材料";
  220. });
  221. },
  222. /** 提交按钮 */
  223. submitForm() {
  224. this.$refs["form"].validate(valid => {
  225. if (valid) {
  226. if (this.form.id != null) {
  227. updateMaterial(this.form).then( response => {
  228. this.msgSuccess("修改成功");
  229. this.open = false;
  230. this.getList();
  231. });
  232. } else {
  233. addMaterial(this.form).then( response => {
  234. this.msgSuccess("新增成功");
  235. this.open = false;
  236. this.getList();
  237. });
  238. }
  239. }
  240. });
  241. },
  242. /** 删除按钮操作 */
  243. handleDelete(row) {
  244. const ids = row.id || this.ids;
  245. this.$confirm('是否确认删除安全准入资格材料?', "警告", {
  246. confirmButtonText: "确定",
  247. cancelButtonText: "取消",
  248. type: "warning"
  249. }).then(function() {
  250. return delMaterial(ids);
  251. }).then(() => {
  252. this.getList();
  253. this.msgSuccess("删除成功");
  254. }).catch(() => {});
  255. },
  256. /** 导出按钮操作 */
  257. handleExport() {
  258. this.download('laboratory/material/export', {
  259. ...this.queryParams
  260. }, `laboratory_material.xlsx`)
  261. }
  262. }
  263. };
  264. </script>