check.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. <template>
  2. <el-dialog :title="$t('检验记录')" :visible.sync="visible" width="1200px" append-to-body>
  3. <el-table v-loading="loading" :data="checkList" @selection-change="handleSelectionChange" :height="clientHeight" border>
  4. <!-- <el-table-column :label="$t('创建人')" align="center" prop="createrCode" :show-overflow-tooltip="true"/>-->
  5. <el-table-column :label="$t('检验单位')" align="center" prop="checkUnit" />
  6. <el-table-column :label="$t('定期检验日期')" align="center" prop="warnDate" width="100">
  7. <template slot-scope="scope">
  8. <span>{{ parseTime(scope.row.warnDate, '{y}-{m}-{d}') }}</span>
  9. </template>
  10. </el-table-column>
  11. <el-table-column :label="$t('下次定期检验日期')" align="center" prop="nextWarnDate" width="100">
  12. <template slot-scope="scope">
  13. <span>{{ parseTime(scope.row.nextWarnDate, '{y}-{m}-{d}') }}</span>
  14. </template>
  15. </el-table-column>
  16. <el-table-column :label="$t('定期检验报告编号')" align="center" prop="reportNo" />
  17. <el-table-column v-if="[1,2].includes(this.devType)" :label="$t('年度检查日期')" align="center" prop="yearWarnDate" width="100">
  18. <template slot-scope="scope">
  19. <span>{{ parseTime(scope.row.yearWarnDate, '{y}-{m}-{d}') }}</span>
  20. </template>
  21. </el-table-column>
  22. <el-table-column v-if="[1,2].includes(this.devType)" :label="$t('年度检查结论')" align="center" prop="checkConclusion" />
  23. <el-table-column v-if="[1,2].includes(this.devType)" :label="$t('下次年度检查日期')" align="center" prop="yearNextWarnDate" width="100">
  24. <template slot-scope="scope">
  25. <span>{{ parseTime(scope.row.yearNextWarnDate, '{y}-{m}-{d}') }}</span>
  26. </template>
  27. </el-table-column>
  28. <el-table-column v-if="[1,2].includes(this.devType)" :label="$t('年度检查报告编号')" align="center" prop="yearReportNo" />
  29. <el-table-column v-if="this.devType == 4" :label="$t('本次外部检测日期')" align="center" prop="outWarnDate" width="100">
  30. <template slot-scope="scope">
  31. <span>{{ parseTime(scope.row.outWarnDate, '{y}-{m}-{d}') }}</span>
  32. </template>
  33. </el-table-column>
  34. <el-table-column v-if="this.devType == 4" :label="$t('下次外部检测日期')" align="center" prop="outNextWarnDate" width="100">
  35. <template slot-scope="scope">
  36. <span>{{ parseTime(scope.row.outNextWarnDate, '{y}-{m}-{d}') }}</span>
  37. </template>
  38. </el-table-column>
  39. <el-table-column v-if="this.devType == 4" :label="$t('外部检验结论')" align="center" prop="outCheckConclusion" />
  40. <el-table-column v-if="this.devType == 4" :label="$t('外部检验编号')" align="center" prop="outReportNo" />
  41. <el-table-column :label="$t('安全等级')" align="center" prop="safeClass" />
  42. <el-table-column :label="$t('录入时间')" align="center" prop="createdate" width="100">
  43. <template slot-scope="scope">
  44. <span>{{ parseTime(scope.row.createdate, '{y}-{m}-{d}') }}</span>
  45. </template>
  46. </el-table-column>
  47. <!-- <el-table-column :label="$t('操作')" align="center" fixed="right" width="120" class-name="small-padding fixed-width">-->
  48. <!-- <template slot-scope="scope">-->
  49. <!-- <el-button-->
  50. <!-- size="mini"-->
  51. <!-- type="text"-->
  52. <!-- icon="el-icon-edit"-->
  53. <!-- @click="handleUpdate(scope.row)"-->
  54. <!-- >{{ $t('修改') }}</el-button>-->
  55. <!-- <el-button-->
  56. <!-- size="mini"-->
  57. <!-- type="text"-->
  58. <!-- icon="el-icon-delete"-->
  59. <!-- @click="handleDelete(scope.row)"-->
  60. <!-- >{{ $t('删除') }}</el-button>-->
  61. <!-- </template>-->
  62. <!-- </el-table-column>-->
  63. </el-table>
  64. <pagination
  65. v-show="total>0"
  66. :total="total"
  67. :page.sync="queryParams.pageNum"
  68. :limit.sync="queryParams.pageSize"
  69. @pagination="getList"
  70. />
  71. </el-dialog>
  72. </template>
  73. <script>
  74. import {addCheck, delCheck, exportCheck, getCheck, importTemplate, listCheck, updateCheck} from "@/api/sems/check";
  75. import {treeselect} from "@/api/system/dept";
  76. import {getToken} from "@/utils/auth";
  77. import Treeselect from "@riophae/vue-treeselect";
  78. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  79. export default {
  80. name: "Check",
  81. components: { Treeselect },
  82. data() {
  83. return {
  84. devType: null,
  85. // 遮罩层
  86. loading: true,
  87. visible: false,
  88. // 选中数组
  89. ids: [],
  90. // 非单个禁用
  91. single: true,
  92. // 非多个禁用
  93. multiple: true,
  94. // 显示搜索条件
  95. showSearch: false,
  96. // 总条数
  97. total: 0,
  98. // 特种设备检验记录表格数据
  99. checkList: [],
  100. // 弹出层标题
  101. title: "",
  102. // 部门树选项
  103. deptOptions: undefined,
  104. clientHeight:300,
  105. // 是否显示弹出层
  106. open: false,
  107. // 用户导入参数
  108. upload: {
  109. // 是否显示弹出层(用户导入)
  110. open: false,
  111. // 弹出层标题(用户导入)
  112. title: "",
  113. // 是否禁用上传
  114. isUploading: false,
  115. // 是否更新已经存在的用户数据
  116. updateSupport: 0,
  117. // 设置上传的请求头部
  118. headers: { Authorization: "Bearer " + getToken() },
  119. // 上传的地址
  120. url: process.env.VUE_APP_BASE_API + "/sems/check/importData"
  121. },
  122. // 查询参数
  123. queryParams: {
  124. pageNum: 1,
  125. pageSize: 20,
  126. createrCode: null,
  127. createdate: null,
  128. updaterCode: null,
  129. updatedate: null,
  130. checkUnit: null,
  131. warnDate: null,
  132. nextWarnDate: null,
  133. reportNo: null,
  134. yearWarnDate: null,
  135. checkConclusion: null,
  136. yearNextWarnDate: null,
  137. yearReportNo: null,
  138. outWarnDate: null,
  139. outNextWarnDate: null,
  140. outCheckConclusion: null,
  141. outReportNo: null,
  142. devId: null,
  143. devType: null,
  144. safeClass: null
  145. },
  146. // 表单参数
  147. form: {},
  148. // 表单校验
  149. rules: {
  150. }
  151. };
  152. },
  153. watch: {
  154. // 根据名称筛选部门树
  155. deptName(val) {
  156. this.$refs.tree.filter(val);
  157. }
  158. },
  159. created() {
  160. //设置表格高度对应屏幕高度
  161. this.$nextTick(() => {
  162. this.clientHeight = document.body.clientHeight -250
  163. })
  164. this.getTreeselect();
  165. },
  166. methods: {
  167. init (row, type) {
  168. this.visible = true
  169. this.queryParams.devId = row.id
  170. this.queryParams.devType = type
  171. this.devType = type
  172. console.log(this.devType)
  173. this.loading = true;
  174. this.$nextTick(() => {
  175. console.log(this.queryParams)
  176. listCheck(this.queryParams).then(response => {
  177. this.checkList = response.rows;
  178. this.total = response.total;
  179. this.loading = false;
  180. });
  181. })
  182. },
  183. /** 查询特种设备检验记录列表 */
  184. getList() {
  185. this.loading = true;
  186. listCheck(this.queryParams).then(response => {
  187. this.checkList = response.rows;
  188. this.total = response.total;
  189. this.loading = false;
  190. });
  191. },
  192. /** 查询部门下拉树结构 */
  193. getTreeselect() {
  194. treeselect().then(response => {
  195. this.deptOptions = response.data;
  196. });
  197. },
  198. // 取消按钮
  199. cancel() {
  200. this.open = false;
  201. this.reset();
  202. },
  203. // 表单重置
  204. reset() {
  205. this.form = {
  206. id: null,
  207. delFlag: null,
  208. createrCode: null,
  209. createdate: null,
  210. updaterCode: null,
  211. updatedate: null,
  212. checkUnit: null,
  213. warnDate: null,
  214. nextWarnDate: null,
  215. reportNo: null,
  216. yearWarnDate: null,
  217. checkConclusion: null,
  218. yearNextWarnDate: null,
  219. yearReportNo: null,
  220. outWarnDate: null,
  221. outNextWarnDate: null,
  222. outCheckConclusion: null,
  223. outReportNo: null,
  224. devId: null,
  225. devType: null,
  226. safeClass: null
  227. };
  228. this.resetForm("form");
  229. },
  230. /** 搜索按钮操作 */
  231. handleQuery() {
  232. this.queryParams.pageNum = 1;
  233. this.getList();
  234. },
  235. /** 重置按钮操作 */
  236. resetQuery() {
  237. this.resetForm("queryForm");
  238. this.handleQuery();
  239. },
  240. // 多选框选中数据
  241. handleSelectionChange(selection) {
  242. this.ids = selection.map(item => item.id)
  243. this.single = selection.length!==1
  244. this.multiple = !selection.length
  245. },
  246. /** 新增按钮操作 */
  247. handleAdd() {
  248. this.reset();
  249. this.open = true;
  250. this.title =this.$t('添加')+this.$t('特种设备') +this.$t('空格')+this.$t('检验记录');
  251. },
  252. /** 修改按钮操作 */
  253. handleUpdate(row) {
  254. this.reset();
  255. const id = row.id || this.ids
  256. getCheck(id).then(response => {
  257. this.form = response.data;
  258. this.open = true;
  259. this.title = this.$t('修改')+this.$t('特种设备') +this.$t('空格')+this.$t('检验记录');
  260. });
  261. },
  262. /** 提交按钮 */
  263. submitForm() {
  264. this.$refs["form"].validate(valid => {
  265. if (valid) {
  266. if (this.form.id != null) {
  267. updateCheck(this.form).then(response => {
  268. this.msgSuccess(this.$t('修改成功'));
  269. this.open = false;
  270. this.getList();
  271. });
  272. } else {
  273. addCheck(this.form).then(response => {
  274. this.msgSuccess(this.$t('新增成功'));
  275. this.open = false;
  276. this.getList();
  277. });
  278. }
  279. }
  280. });
  281. },
  282. /** 删除按钮操作 */
  283. handleDelete(row) {
  284. const ids = row.id || this.ids;
  285. this.$confirm(this.$t('是否确认删除?'), this.$t('警告'), {
  286. confirmButtonText: this.$t('确定'),
  287. cancelButtonText: this.$t('取消'),
  288. type: "warning"
  289. }).then(function() {
  290. return delCheck(ids);
  291. }).then(() => {
  292. this.getList();
  293. this.msgSuccess(this.$t('删除成功'));
  294. })
  295. },
  296. /** 导出按钮操作 */
  297. handleExport() {
  298. const queryParams = this.queryParams;
  299. this.$confirm(this.$t('是否确认导出所有特种设备检验记录数据项?'), this.$t('警告'), {
  300. confirmButtonText: this.$t('确定'),
  301. cancelButtonText: this.$t('取消'),
  302. type: "warning"
  303. }).then(function() {
  304. return exportCheck(queryParams);
  305. }).then(response => {
  306. this.download(response.msg);
  307. })
  308. },
  309. /** 导入按钮操作 */
  310. handleImport() {
  311. this.upload.title = this.$t('用户导入');
  312. this.upload.open = true;
  313. },
  314. /** 下载模板操作 */
  315. importTemplate() {
  316. importTemplate().then(response => {
  317. this.download(response.msg);
  318. });
  319. },
  320. // 文件上传中处理
  321. handleFileUploadProgress(event, file, fileList) {
  322. this.upload.isUploading = true;
  323. },
  324. // 文件上传成功处理
  325. handleFileSuccess(response, file, fileList) {
  326. this.upload.open = false;
  327. this.upload.isUploading = false;
  328. this.$refs.upload.clearFiles();
  329. this.$alert(response.msg, this.$t('导入结果'), { dangerouslyUseHTMLString: true });
  330. this.getList();
  331. },
  332. // 提交上传文件
  333. submitFileForm() {
  334. this.$refs.upload.submit();
  335. }
  336. }
  337. };
  338. </script>