index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. <template>
  2. <div class="app-container">
  3. <!-- 搜索工作栏 -->
  4. <el-form
  5. :model="queryParams"
  6. ref="queryForm"
  7. size="small"
  8. :inline="true"
  9. v-show="showSearch"
  10. label-width="100px"
  11. >
  12. <el-form-item label="预计检测时间" prop="detdate">
  13. <el-date-picker
  14. v-model="queryParams.detdate"
  15. style="width: 240px"
  16. value-format="yyyy-MM-dd HH:mm:ss"
  17. type="daterange"
  18. range-separator="-"
  19. start-placeholder="开始日期"
  20. end-placeholder="结束日期"
  21. :default-time="['00:00:00', '23:59:59']"
  22. />
  23. </el-form-item>
  24. <el-form-item label="检测维保结果" prop="detresult">
  25. <el-select
  26. v-model="queryParams.detresult"
  27. placeholder="请选择检测维保结果"
  28. clearable
  29. size="small"
  30. >
  31. <el-option
  32. v-for="dict in this.getDictDatas(DICT_TYPE.BACKEND_DET_RESULT)"
  33. :key="dict.value"
  34. :label="dict.label"
  35. :value="dict.value"
  36. />
  37. </el-select>
  38. </el-form-item>
  39. <el-form-item>
  40. <el-button type="primary" icon="el-icon-search" @click="handleQuery"
  41. >搜索</el-button
  42. >
  43. <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
  44. </el-form-item>
  45. </el-form>
  46. <!-- 操作工具栏 -->
  47. <el-row :gutter="10" class="mb8">
  48. <!-- <el-col :span="1.5">
  49. <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
  50. v-hasPermi="['backend:fpd-detection:create']">新增</el-button>
  51. </el-col> -->
  52. <el-col :span="1.5">
  53. <el-button
  54. type="warning"
  55. plain
  56. icon="el-icon-download"
  57. size="mini"
  58. @click="handleExport"
  59. :loading="exportLoading"
  60. v-hasPermi="['backend:fpd-detection:export']"
  61. >导出</el-button
  62. >
  63. </el-col>
  64. <right-toolbar
  65. :showSearch.sync="showSearch"
  66. @queryTable="getList"
  67. ></right-toolbar>
  68. </el-row>
  69. <!-- 列表 -->
  70. <el-table v-loading="loading" :data="list">
  71. <el-table-column label="ID" align="center" prop="id" />
  72. <el-table-column label="所属单位" align="center" prop="orgName" />
  73. <el-table-column
  74. label="预计检测时间"
  75. align="center"
  76. prop="detdate"
  77. width="180"
  78. >
  79. <template v-slot="scope">
  80. <span>{{ parseTime(scope.row.detdate) }}</span>
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="检测项目" align="center" prop="detinspect" />
  84. <el-table-column label="检测维保结果" align="center" prop="detresult">
  85. <template v-slot="scope">
  86. <dict-tag
  87. :type="DICT_TYPE.BACKEND_DET_RESULT"
  88. :value="scope.row.detresult"
  89. />
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="资料附件" align="center" prop="att">
  93. <template v-slot="scope">
  94. <el-link v-if="scope.row.att" type="primary" :href="scope.row.att"
  95. >下载</el-link
  96. >
  97. </template>
  98. </el-table-column>
  99. <!-- <el-table-column
  100. label="操作"
  101. align="center"
  102. class-name="small-padding fixed-width"
  103. >
  104. <template v-slot="scope">
  105. <el-button
  106. size="mini"
  107. type="text"
  108. icon="el-icon-edit"
  109. @click="handleUpdate(scope.row)"
  110. v-hasPermi="['backend:fpd-detection:update']"
  111. >修改</el-button
  112. >
  113. <el-button
  114. size="mini"
  115. type="text"
  116. icon="el-icon-delete"
  117. @click="handleDelete(scope.row)"
  118. v-hasPermi="['backend:fpd-detection:delete']"
  119. >删除</el-button
  120. >
  121. </template>
  122. </el-table-column> -->
  123. </el-table>
  124. <!-- 分页组件 -->
  125. <pagination
  126. v-show="total > 0"
  127. :total="total"
  128. :page.sync="queryParams.pageNo"
  129. :limit.sync="queryParams.pageSize"
  130. @pagination="getList"
  131. />
  132. <!-- 对话框(添加 / 修改) -->
  133. <el-dialog
  134. :title="title"
  135. :visible.sync="open"
  136. width="500px"
  137. v-dialogDrag
  138. append-to-body
  139. >
  140. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  141. <el-form-item label="所属单位" prop="orgName">
  142. <el-input v-model="form.orgName" placeholder="请输入所属单位" />
  143. </el-form-item>
  144. <el-form-item label="预计检测时间" prop="detdate">
  145. <el-date-picker
  146. clearable
  147. v-model="form.detdate"
  148. type="date"
  149. value-format="yyyy-MM-dd HH:mm:ss"
  150. placeholder="选择预计检测时间"
  151. />
  152. <!-- value-format="yyyy-MM-dd HH:mm:ss" -->
  153. </el-form-item>
  154. <el-form-item label="检测项目" prop="detinspect">
  155. <el-input
  156. v-model="form.detinspect"
  157. type="textarea"
  158. placeholder="请输入内容"
  159. />
  160. </el-form-item>
  161. <el-form-item label="检测维保结果" prop="detresult">
  162. <el-select v-model="form.detresult" placeholder="请选择检测维保结果">
  163. <el-option
  164. v-for="dict in this.getDictDatas(DICT_TYPE.SYSTEM_LOGIN_RESULT)"
  165. :key="dict.value"
  166. :label="dict.label"
  167. :value="dict.value"
  168. />
  169. </el-select>
  170. </el-form-item>
  171. <!-- <el-form-item label="资料附件" prop="att">
  172. <el-input v-model="form.att" placeholder="请输入资料附件" />
  173. </el-form-item> -->
  174. <el-form-item label="附件">
  175. <fileUpload v-model="form.att" />
  176. </el-form-item>
  177. </el-form>
  178. <div slot="footer" class="dialog-footer">
  179. <el-button type="primary" @click="submitForm">确 定</el-button>
  180. <el-button @click="cancel">取 消</el-button>
  181. </div>
  182. </el-dialog>
  183. </div>
  184. </template>
  185. <script>
  186. import {
  187. createFpdDetection,
  188. updateFpdDetection,
  189. deleteFpdDetection,
  190. getFpdDetection,
  191. getFpdDetectionPage,
  192. exportFpdDetectionExcel,
  193. } from "@/api/backend/fpdDetection";
  194. import FileUpload from "@/components/FileUpload";
  195. export default {
  196. name: "FpdDetection",
  197. components: { FileUpload },
  198. data() {
  199. return {
  200. // 遮罩层
  201. loading: true,
  202. // 导出遮罩层
  203. exportLoading: false,
  204. // 显示搜索条件
  205. showSearch: true,
  206. // 总条数
  207. total: 0,
  208. // 消防设备维护和检测台账列表
  209. list: [],
  210. // 弹出层标题
  211. title: "",
  212. // 是否显示弹出层
  213. open: false,
  214. // 查询参数
  215. queryParams: {
  216. pageNo: 1,
  217. pageSize: 10,
  218. detdate: [],
  219. detinspect: null,
  220. detresult: null,
  221. },
  222. // 表单参数
  223. form: {},
  224. // 表单校验
  225. rules: {
  226. orgId: [
  227. { required: true, message: "所属单位不能为空", trigger: "blur" },
  228. ],
  229. },
  230. };
  231. },
  232. created() {
  233. this.getList();
  234. },
  235. methods: {
  236. /** 查询列表 */
  237. getList() {
  238. this.loading = true;
  239. // 执行查询
  240. getFpdDetectionPage(this.queryParams)
  241. .then((response) => {
  242. if (response.data) {
  243. this.list = response.data.list;
  244. this.total = response.data.total;
  245. } else {
  246. this.list = [];
  247. this.total = 0;
  248. }
  249. this.loading = false;
  250. })
  251. .catch((err) => {
  252. this.loading = false;
  253. });
  254. },
  255. /** 取消按钮 */
  256. cancel() {
  257. this.open = false;
  258. this.reset();
  259. },
  260. /** 表单重置 */
  261. reset() {
  262. this.form = {
  263. id: undefined,
  264. orgId: undefined,
  265. detdate: undefined,
  266. detinspect: undefined,
  267. detresult: undefined,
  268. att: undefined,
  269. };
  270. this.resetForm("form");
  271. },
  272. /** 搜索按钮操作 */
  273. handleQuery() {
  274. this.queryParams.pageNo = 1;
  275. this.getList();
  276. },
  277. /** 重置按钮操作 */
  278. resetQuery() {
  279. this.resetForm("queryForm");
  280. this.handleQuery();
  281. },
  282. /** 新增按钮操作 */
  283. handleAdd() {
  284. this.reset();
  285. this.open = true;
  286. this.title = "添加消防设备维护和检测台账";
  287. },
  288. /** 修改按钮操作 */
  289. handleUpdate(row) {
  290. console.log("row", row);
  291. this.reset();
  292. this.form = { ...row };
  293. this.open = true;
  294. this.title = "修改消防设备维护和检测台账";
  295. //接口拿到的数据没有orgName 所以直接使用行数据
  296. // const id = row.id;
  297. // getFpdDetection(id).then((response) => {
  298. // // console.log('response',response);
  299. // this.form = response.data;
  300. // this.open = true;
  301. // this.title = "修改消防设备维护和检测台账";
  302. // });
  303. },
  304. /** 提交按钮 */
  305. submitForm() {
  306. this.$refs["form"].validate((valid) => {
  307. if (!valid) {
  308. return;
  309. }
  310. // 修改的提交
  311. if (this.form.id != null) {
  312. updateFpdDetection(this.form).then((response) => {
  313. this.$modal.msgSuccess("修改成功");
  314. this.open = false;
  315. this.getList();
  316. });
  317. return;
  318. }
  319. // 添加的提交
  320. createFpdDetection(this.form).then((response) => {
  321. this.$modal.msgSuccess("新增成功");
  322. this.open = false;
  323. this.getList();
  324. });
  325. });
  326. },
  327. /** 删除按钮操作 */
  328. handleDelete(row) {
  329. const id = row.id;
  330. this.$modal
  331. .confirm(
  332. '是否确认删除消防设备维护和检测台账编号为"' + id + '"的数据项?'
  333. )
  334. .then(function () {
  335. return deleteFpdDetection(id);
  336. })
  337. .then(() => {
  338. this.getList();
  339. this.$modal.msgSuccess("删除成功");
  340. })
  341. .catch(() => {});
  342. },
  343. /** 导出按钮操作 */
  344. handleExport() {
  345. // 处理查询参数
  346. let params = { ...this.queryParams };
  347. params.pageNo = undefined;
  348. params.pageSize = undefined;
  349. this.$modal
  350. .confirm("是否确认导出所有消防设备维护和检测台账数据项?")
  351. .then(() => {
  352. this.exportLoading = true;
  353. return exportFpdDetectionExcel(params);
  354. })
  355. .then((response) => {
  356. this.$download.excel(response, "消防设备维护和检测台账.xls");
  357. this.exportLoading = false;
  358. })
  359. .catch(() => {});
  360. },
  361. },
  362. };
  363. </script>