index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  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="fireExtinguisherNo">
  5. <el-input
  6. v-model="queryParams.fireExtinguisherNo"
  7. placeholder="请输入现场编号"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="现场位置" prop="position">
  14. <el-input
  15. v-model="queryParams.position"
  16. placeholder="请输入现场位置"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item>
  23. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  24. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  25. </el-form-item>
  26. </el-form>
  27. <el-row :gutter="10" class="mb8">
  28. <el-col :span="1.5">
  29. <el-button
  30. type="primary"
  31. icon="el-icon-plus"
  32. size="mini"
  33. @click="handleAdd"
  34. v-hasPermi="['ps:patrol:add']"
  35. >新增
  36. </el-button>
  37. </el-col>
  38. <el-col :span="1.5">
  39. <el-button
  40. type="success"
  41. icon="el-icon-edit"
  42. size="mini"
  43. :disabled="single"
  44. @click="handleUpdate"
  45. v-hasPermi="['ps:patrol:edit']"
  46. >修改
  47. </el-button>
  48. </el-col>
  49. <el-col :span="1.5">
  50. <el-button
  51. type="danger"
  52. icon="el-icon-delete"
  53. size="mini"
  54. :disabled="multiple"
  55. @click="handleDelete"
  56. v-hasPermi="['ps:patrol:remove']"
  57. >删除
  58. </el-button>
  59. </el-col>
  60. <el-col :span="1.5">
  61. <el-button
  62. type="info"
  63. icon="el-icon-upload2"
  64. size="mini"
  65. @click="handleImport"
  66. v-hasPermi="['ps:patrol:edit']"
  67. >导入
  68. </el-button>
  69. </el-col>
  70. <el-col :span="1.5">
  71. <el-button
  72. type="warning"
  73. icon="el-icon-download"
  74. size="mini"
  75. @click="handleExport"
  76. v-hasPermi="['ps:patrol:list']"
  77. >导出
  78. </el-button>
  79. </el-col>
  80. <el-col :span="1.5">
  81. <el-button
  82. v-hasPermi="['ps:patrol:export']"
  83. icon="el-icon-download"
  84. plain
  85. size="mini"
  86. type="warning"
  87. @click="handleExportQRCode"
  88. >导出设备二维码
  89. </el-button>
  90. </el-col>
  91. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  92. </el-row>
  93. <el-table v-loading="loading" :data="extinguisherList" @selection-change="handleSelectionChange"
  94. :height="clientHeight" border>
  95. <el-table-column type="selection" width="55" align="center"/>
  96. <el-table-column label="现场编号" align="center" prop="fireExtinguisherNo" :show-overflow-tooltip="true"/>
  97. <el-table-column label="现场位置" align="center" prop="position" :show-overflow-tooltip="true"/>
  98. <el-table-column label="灭火器型号" align="center" prop="fireExtinguisherModel" :show-overflow-tooltip="true"/>
  99. <el-table-column label="灭火器类型" align="center" prop="devType" :show-overflow-tooltip="true">
  100. <template slot-scope="scope">
  101. <span v-if="scope.row.devType === '1'">常规</span>
  102. <span v-else-if="scope.row.devType === '2'">二氧化碳</span>
  103. <span v-else>{{ scope.row.devType }}</span>
  104. </template>
  105. </el-table-column>
  106. <el-table-column label="状态" align="center" prop="status" >
  107. <template slot-scope="scope">
  108. <dict-tag :options="dict.type.dev_status" :value="scope.row.status"/>
  109. </template>
  110. </el-table-column>
  111. <el-table-column label="备注" align="center" prop="remarks" :show-overflow-tooltip="true"/>
  112. <el-table-column label="操作" align="center" fixed="right" width="120" class-name="small-padding fixed-width">
  113. <template slot-scope="scope">
  114. <el-button
  115. size="mini"
  116. type="text"
  117. icon="el-icon-edit"
  118. @click="handleUpdate(scope.row)"
  119. v-hasPermi="['ps:patrol:edit']"
  120. >修改
  121. </el-button>
  122. <el-button
  123. size="mini"
  124. type="text"
  125. icon="el-icon-delete"
  126. @click="handleDelete(scope.row)"
  127. v-hasPermi="['ps:patrol:remove']"
  128. >删除
  129. </el-button>
  130. </template>
  131. </el-table-column>
  132. </el-table>
  133. <pagination
  134. v-show="total>0"
  135. :total="total"
  136. :page.sync="queryParams.pageNum"
  137. :limit.sync="queryParams.pageSize"
  138. @pagination="getList"
  139. />
  140. <!-- 添加或修改现场灭火器基础信息对话框 -->
  141. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  142. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  143. <el-form-item label="现场编号" prop="fireExtinguisherNo">
  144. <el-input v-model="form.fireExtinguisherNo" placeholder="请输入现场编号"/>
  145. </el-form-item>
  146. <el-form-item label="现场位置" prop="position">
  147. <el-input v-model="form.position" placeholder="请输入现场位置"/>
  148. </el-form-item>
  149. <el-form-item label="灭火器型号" prop="fireExtinguisherModel">
  150. <el-input v-model="form.fireExtinguisherModel" placeholder="请输入灭火器型号"/>
  151. </el-form-item>
  152. <el-form-item label="灭火器类型" prop="devType">
  153. <el-radio-group v-model="form.devType">
  154. <el-radio label="1">常规</el-radio>
  155. <el-radio label="2">二氧化碳</el-radio>
  156. </el-radio-group>
  157. </el-form-item>
  158. <el-form-item label="状态" prop="status">
  159. <el-radio-group v-model="form.status">
  160. <el-radio label="1">启用</el-radio>
  161. <el-radio label="0">停用</el-radio>
  162. </el-radio-group>
  163. </el-form-item>
  164. <el-form-item label="备注" prop="remarks">
  165. <el-input v-model="form.remarks" placeholder="请输入备注"/>
  166. </el-form-item>
  167. </el-form>
  168. <div slot="footer" class="dialog-footer">
  169. <el-button type="primary" @click="submitForm">确 定</el-button>
  170. <el-button @click="cancel">取 消</el-button>
  171. </div>
  172. </el-dialog>
  173. <!-- 用户导入对话框 -->
  174. <el-dialog :close-on-click-modal="false" v-dialogDrag :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  175. <el-upload
  176. ref="upload"
  177. :limit="1"
  178. accept=".xlsx, .xls"
  179. :headers="upload.headers"
  180. :action="upload.url"
  181. :disabled="upload.isUploading"
  182. :on-progress="handleFileUploadProgress"
  183. :on-success="handleFileSuccess"
  184. :auto-upload="false"
  185. drag
  186. >
  187. <i class="el-icon-upload"></i>
  188. <div class="el-upload__text">
  189. 将文件拖到此处,或
  190. <em>点击上传</em>
  191. </div>
  192. <div class="el-upload__tip" slot="tip">
  193. <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
  194. </div>
  195. <form ref="downloadFileForm" :action="upload.downloadAction" target="FORMSUBMIT">
  196. <input name="type" :value="upload.type" hidden/>
  197. </form>
  198. <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
  199. </el-upload>
  200. <div slot="footer" class="dialog-footer">
  201. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  202. <el-button @click="upload.open = false">取 消</el-button>
  203. </div>
  204. </el-dialog>
  205. </div>
  206. </template>
  207. <script>
  208. import {
  209. addExtinguisher,
  210. delExtinguisher,
  211. exportExtinguisher,
  212. getExtinguisher,
  213. listExtinguisher,
  214. updateExtinguisher
  215. } from "@/api/ps/dev/extinguisher";
  216. import {treeselect} from "@/api/system/dept";
  217. import {getToken} from "@/utils/auth";
  218. import Treeselect from "@riophae/vue-treeselect";
  219. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  220. export default {
  221. name: "Extinguisher",
  222. components: {Treeselect},
  223. dicts: ['dev_status'],
  224. data() {
  225. return {
  226. // 遮罩层
  227. loading: true,
  228. // 选中数组
  229. ids: [],
  230. // 非单个禁用
  231. single: true,
  232. // 非多个禁用
  233. multiple: true,
  234. // 显示搜索条件
  235. showSearch: false,
  236. // 总条数
  237. total: 0,
  238. // 现场灭火器基础信息表格数据
  239. extinguisherList: [],
  240. // 弹出层标题
  241. title: "",
  242. // 部门树选项
  243. deptOptions: undefined,
  244. clientHeight: 300,
  245. // 是否显示弹出层
  246. open: false,
  247. // 用户导入参数
  248. upload: {
  249. downloadAction: process.env.VUE_APP_BASE_API + '/common/template',
  250. //下载模板类型
  251. type: 'extinguisher',
  252. // 是否显示弹出层(用户导入)
  253. open: false,
  254. // 弹出层标题(用户导入)
  255. title: "",
  256. // 是否禁用上传
  257. isUploading: false,
  258. // 设置上传的请求头部
  259. headers: {Authorization: "Bearer " + getToken()},
  260. // 上传的地址
  261. url: process.env.VUE_APP_BASE_API + "/ps/dev/extinguisher/importData"
  262. },
  263. // 查询参数
  264. queryParams: {
  265. pageNum: 1,
  266. pageSize: 20,
  267. fireExtinguisherNo: null,
  268. position: null,
  269. fireExtinguisherModel: null,
  270. devType: null,
  271. createrCode: null,
  272. createdate: null,
  273. updaterCode: null,
  274. updatedate: null,
  275. remarks: null,
  276. deptId: null,
  277. status: null,
  278. patrolType: '6'
  279. },
  280. // 表单参数
  281. form: {},
  282. // 表单校验
  283. rules: {
  284. fireExtinguisherNo: [
  285. {required: true, message: "现场编号不能为空", trigger: "blur"}
  286. ],
  287. position: [
  288. {required: true, message: "现场位置不能为空", trigger: "blur"}
  289. ],
  290. fireExtinguisherModel: [
  291. {required: true, message: "灭火器型号不能为空", trigger: "blur"}
  292. ],
  293. devType: [
  294. {required: true, message: "灭火器类型不能为空", trigger: "blur"}
  295. ],
  296. status: [
  297. {required: true, message: "状态不能为空", trigger: "blur"}
  298. ]
  299. }
  300. };
  301. },
  302. watch: {
  303. // 根据名称筛选部门树
  304. deptName(val) {
  305. this.$refs.tree.filter(val);
  306. }
  307. },
  308. created() {
  309. //设置表格高度对应屏幕高度
  310. this.$nextTick(() => {
  311. this.clientHeight = document.body.clientHeight - 250
  312. })
  313. this.getList();
  314. this.getTreeselect();
  315. },
  316. methods: {
  317. /** 查询现场灭火器基础信息列表 */
  318. getList() {
  319. this.loading = true;
  320. listExtinguisher(this.queryParams).then(response => {
  321. this.extinguisherList = response.rows;
  322. this.total = response.total;
  323. this.loading = false;
  324. });
  325. },
  326. /** 查询部门下拉树结构 */
  327. getTreeselect() {
  328. treeselect().then(response => {
  329. this.deptOptions = response.data;
  330. });
  331. },
  332. // 取消按钮
  333. cancel() {
  334. this.open = false;
  335. this.reset();
  336. },
  337. // 表单重置
  338. reset() {
  339. this.form = {
  340. id: null,
  341. fireExtinguisherNo: null,
  342. position: null,
  343. fireExtinguisherModel: null,
  344. devType: null,
  345. delFlag: null,
  346. createrCode: null,
  347. createdate: null,
  348. updaterCode: null,
  349. updatedate: null,
  350. remarks: null,
  351. deptId: null,
  352. status: "1",
  353. patrolType: "6"
  354. };
  355. this.resetForm("form");
  356. },
  357. /** 搜索按钮操作 */
  358. handleQuery() {
  359. this.queryParams.pageNum = 1;
  360. this.getList();
  361. },
  362. /** 重置按钮操作 */
  363. resetQuery() {
  364. this.resetForm("queryForm");
  365. this.handleQuery();
  366. },
  367. // 多选框选中数据
  368. handleSelectionChange(selection) {
  369. this.ids = selection.map(item => item.id)
  370. this.single = selection.length !== 1
  371. this.multiple = !selection.length
  372. },
  373. /** 新增按钮操作 */
  374. handleAdd() {
  375. this.reset();
  376. this.open = true;
  377. this.title = "添加现场灭火器基础信息";
  378. },
  379. /** 修改按钮操作 */
  380. handleUpdate(row) {
  381. this.reset();
  382. const id = row.id || this.ids
  383. getExtinguisher(id).then(response => {
  384. this.form = response.data;
  385. this.open = true;
  386. this.title = "修改现场灭火器基础信息";
  387. });
  388. },
  389. /** 提交按钮 */
  390. submitForm() {
  391. this.$refs["form"].validate(valid => {
  392. if (valid) {
  393. if (this.form.id != null) {
  394. updateExtinguisher(this.form).then(response => {
  395. this.msgSuccess("修改成功");
  396. this.open = false;
  397. this.getList();
  398. });
  399. } else {
  400. addExtinguisher(this.form).then(response => {
  401. this.msgSuccess("新增成功");
  402. this.open = false;
  403. this.getList();
  404. });
  405. }
  406. }
  407. });
  408. },
  409. /** 删除按钮操作 */
  410. handleDelete(row) {
  411. const ids = row.id || this.ids;
  412. this.$confirm('是否确认删除?', "警告", {
  413. confirmButtonText: "确定",
  414. cancelButtonText: "取消",
  415. type: "warning"
  416. }).then(function () {
  417. return delExtinguisher(ids);
  418. }).then(() => {
  419. this.getList();
  420. this.msgSuccess("删除成功");
  421. })
  422. },
  423. /** 导出按钮操作 */
  424. handleExport() {
  425. const queryParams = this.queryParams;
  426. this.$confirm('是否确认导出所有现场灭火器基础信息数据项?', "警告", {
  427. confirmButtonText: "确定",
  428. cancelButtonText: "取消",
  429. type: "warning"
  430. }).then(function () {
  431. return exportExtinguisher(queryParams);
  432. }).then(response => {
  433. this.download(response.msg);
  434. })
  435. },
  436. /** 导入按钮操作 */
  437. handleImport() {
  438. this.upload.title = "用户导入";
  439. this.upload.open = true;
  440. },
  441. /** 下载模板操作 */
  442. importTemplate() {
  443. this.$refs['downloadFileForm'].submit()
  444. },
  445. // 文件上传中处理
  446. handleFileUploadProgress(event, file, fileList) {
  447. this.upload.isUploading = true;
  448. },
  449. // 文件上传成功处理
  450. handleFileSuccess(response, file, fileList) {
  451. this.upload.open = false;
  452. this.upload.isUploading = false;
  453. this.$refs.upload.clearFiles();
  454. if (response.data[0] != null) {
  455. this.$alert('成功导入' + response.msg + '条数据,' + '第' + response.data + '行数据出现错误导入失败' + '。', '导入结果', {dangerouslyUseHTMLString: true});
  456. } else {
  457. this.$alert('成功导入' + response.msg + '条数据', '导入结果', {dangerouslyUseHTMLString: true});
  458. }
  459. this.getList();
  460. },
  461. // 提交上传文件
  462. submitFileForm() {
  463. this.$refs.upload.submit();
  464. },
  465. /** 导出按钮操作 */
  466. handleExportQRCode() {
  467. this.download2('ps/dev/extinguisher/exportQRCode', {
  468. ...this.queryParams
  469. }, `extinguisherQRCode_${new Date().getTime()}.zip`)
  470. }
  471. }
  472. };
  473. </script>