index.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <template>
  2. <el-dialog title="仪器维护记录" append-to-body :visible.sync="visible" width="85%">
  3. <el-row :gutter="10" class="mb8">
  4. <el-col :span="1.5">
  5. <el-button
  6. type="primary"
  7. plain
  8. icon="el-icon-plus"
  9. size="mini"
  10. @click="handleAdd"
  11. v-hasPermi="['check:record:add']"
  12. >新增</el-button>
  13. </el-col>
  14. <el-col :span="1.5">
  15. <el-button
  16. type="success"
  17. plain
  18. icon="el-icon-edit"
  19. size="mini"
  20. :disabled="single"
  21. @click="handleUpdate"
  22. v-hasPermi="['check:record:edit']"
  23. >修改</el-button>
  24. </el-col>
  25. <el-col :span="1.5">
  26. <el-button
  27. type="danger"
  28. plain
  29. icon="el-icon-delete"
  30. size="mini"
  31. :disabled="multiple"
  32. @click="handleDelete"
  33. v-hasPermi="['check:record:remove']"
  34. >删除</el-button>
  35. </el-col>
  36. <el-col :span="1.5">
  37. <el-button
  38. type="warning"
  39. plain
  40. icon="el-icon-download"
  41. size="mini"
  42. @click="handleExport"
  43. v-hasPermi="['check:record:export']"
  44. >导出</el-button>
  45. </el-col>
  46. </el-row>
  47. <el-table v-loading="loading" :data="recordList" @selection-change="handleSelectionChange" :height="clientHeight" border>
  48. <el-table-column type="selection" width="55" align="center" />
  49. <el-table-column label="仪器类型编号" align="center" prop="code"/>
  50. <el-table-column label="仪器类型名称" align="center" prop="name"/>
  51. <el-table-column label="仪器型号" align="center" prop="model"/>
  52. <el-table-column label="维护内容" align="center" prop="content" />
  53. <el-table-column label="检定/校准单位" align="center" prop="unit" />
  54. <el-table-column label="检定/校准证书编号" align="center" prop="certificate" />
  55. <el-table-column label="备注" align="center" prop="remarks" />
  56. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  57. <template slot-scope="scope">
  58. <el-button
  59. size="mini"
  60. type="text"
  61. icon="el-icon-edit"
  62. @click="handleUpdate(scope.row)"
  63. v-hasPermi="['check:record:edit']"
  64. >修改</el-button>
  65. <el-button
  66. size="mini"
  67. type="text"
  68. icon="el-icon-delete"
  69. @click="handleDelete(scope.row)"
  70. v-hasPermi="['check:record:remove']"
  71. >删除</el-button>
  72. </template>
  73. </el-table-column>
  74. </el-table>
  75. <pagination
  76. v-show="total>0"
  77. :total="total"
  78. :page.sync="queryParams.pageNum"
  79. :limit.sync="queryParams.pageSize"
  80. @pagination="getList"
  81. />
  82. <!-- 添加或修改仪器维护记录对话框 -->
  83. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
  84. <el-form ref="form" :model="form" :rules="rules" label-width="130px">
  85. <el-form-item label="仪器" prop="instrumentId">
  86. <el-select v-model="form.instrumentId" placeholder="请选择仪器" disabled clearable size="small" style="width: 100%">
  87. <el-option
  88. v-for="dict in instrumentList"
  89. :key="dict.id"
  90. :label="dict.name"
  91. :value="dict.id"
  92. />
  93. </el-select>
  94. </el-form-item>
  95. <el-form-item label="维护内容">
  96. <el-input v-model="form.content" placeholder="请输入维护内容"/>
  97. </el-form-item>
  98. <el-form-item label="检定/校准单位" prop="unit">
  99. <el-input v-model="form.unit" placeholder="请输入检定/校准单位" />
  100. </el-form-item>
  101. <el-form-item label="检定/校准证书编号" prop="certificate">
  102. <el-input v-model="form.certificate" placeholder="请输入检定/校准证书编号" />
  103. </el-form-item>
  104. <el-form-item label="备注" prop="remarks">
  105. <el-input v-model="form.remarks" placeholder="请输入备注" />
  106. </el-form-item>
  107. </el-form>
  108. <div slot="footer" class="dialog-footer">
  109. <el-button type="primary" @click="submitForm">确 定</el-button>
  110. <el-button @click="cancel">取 消</el-button>
  111. </div>
  112. </el-dialog>
  113. </el-dialog>
  114. </template>
  115. <script>
  116. import { listRecord, getRecord, delRecord, addRecord, updateRecord } from "@/api/check/record";
  117. import {getAllInstrument} from "@/api/check/instrument";
  118. export default {
  119. name: "Record",
  120. data() {
  121. return {
  122. row:{},
  123. instrumentList:[],
  124. visible: false,
  125. // 页面高度
  126. clientHeight:600,
  127. // 遮罩层
  128. loading: true,
  129. // 选中数组
  130. ids: [],
  131. // 非单个禁用
  132. single: true,
  133. // 非多个禁用
  134. multiple: true,
  135. // 显示搜索条件
  136. showSearch: false,
  137. // 总条数
  138. total: 0,
  139. // 仪器维护记录表格数据
  140. recordList: [],
  141. // 弹出层标题
  142. title: "",
  143. // 是否显示弹出层
  144. open: false,
  145. // 查询参数
  146. queryParams: {
  147. pageNum: 1,
  148. pageSize: 10,
  149. instrumentId: null,
  150. content: null,
  151. unit: null,
  152. certificate: null,
  153. remarks: null,
  154. deptId: null,
  155. createrCode: null,
  156. createdate: null,
  157. updaterCode: null,
  158. updatedate: null
  159. },
  160. // 表单参数
  161. form: {},
  162. // 表单校验
  163. rules: {
  164. }
  165. };
  166. },
  167. created() {
  168. },
  169. methods: {
  170. init(row) {
  171. this.recordList=[];
  172. console.log(row)
  173. this.row=row
  174. this.visible = true
  175. getAllInstrument().then(response=>{
  176. this.instrumentList=response.data;
  177. });
  178. this.queryParams.instrumentId=row.id;
  179. this.getList();
  180. },
  181. /** 查询仪器维护记录列表 */
  182. getList() {
  183. this.loading = true;
  184. listRecord(this.queryParams).then(response => {
  185. this.recordList = response.rows;
  186. this.total = response.total;
  187. this.loading = false;
  188. });
  189. },
  190. // 取消按钮
  191. cancel() {
  192. this.open = false;
  193. this.reset();
  194. },
  195. // 表单重置
  196. reset() {
  197. this.form = {
  198. id: null,
  199. instrumentId: null,
  200. content: null,
  201. unit: null,
  202. certificate: null,
  203. remarks: null,
  204. deptId: null,
  205. delFlag: null,
  206. createrCode: null,
  207. createdate: null,
  208. updaterCode: null,
  209. updatedate: null
  210. };
  211. this.resetForm("form");
  212. },
  213. /** 搜索按钮操作 */
  214. handleQuery() {
  215. this.queryParams.pageNum = 1;
  216. this.getList();
  217. },
  218. /** 重置按钮操作 */
  219. resetQuery() {
  220. this.resetForm("queryForm");
  221. this.handleQuery();
  222. },
  223. // 多选框选中数据
  224. handleSelectionChange(selection) {
  225. this.ids = selection.map(item => item.id)
  226. this.single = selection.length!==1
  227. this.multiple = !selection.length
  228. },
  229. /** 新增按钮操作 */
  230. handleAdd() {
  231. this.reset();
  232. this.form.instrumentId=this.row.id
  233. console.log(this.form.instrumentId)
  234. this.open = true;
  235. this.title = "添加仪器维护记录";
  236. },
  237. /** 修改按钮操作 */
  238. handleUpdate(row) {
  239. this.reset();
  240. const id = row.id || this.ids
  241. getRecord(id).then(response => {
  242. this.form = response.data;
  243. this.open = true;
  244. this.title = "修改仪器维护记录";
  245. });
  246. },
  247. /** 提交按钮 */
  248. submitForm() {
  249. this.$refs["form"].validate(valid => {
  250. if (valid) {
  251. if (this.form.id != null) {
  252. updateRecord(this.form).then(response => {
  253. this.$modal.msgSuccess("修改成功");
  254. this.open = false;
  255. this.getList();
  256. });
  257. } else {
  258. addRecord(this.form).then(response => {
  259. this.$modal.msgSuccess("新增成功");
  260. this.open = false;
  261. this.getList();
  262. });
  263. }
  264. }
  265. });
  266. },
  267. /** 删除按钮操作 */
  268. handleDelete(row) {
  269. const ids = row.id || this.ids;
  270. this.$modal.confirm('是否确认删除仪器维护记录编号为"' + ids + '"的数据项?').then(function() {
  271. return delRecord(ids);
  272. }).then(() => {
  273. this.getList();
  274. this.$modal.msgSuccess("删除成功");
  275. }).catch(() => {});
  276. },
  277. /** 导出按钮操作 */
  278. handleExport() {
  279. this.download('check/record/export', {
  280. ...this.queryParams
  281. }, `仪器维护记录_${new Date().getTime()}.xlsx`)
  282. }
  283. }
  284. };
  285. </script>