index.vue 10 KB

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