index.vue 13 KB

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