index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  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="cofferNo">
  5. <el-input
  6. v-model="queryParams.cofferNo"
  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="cofferList" @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="cofferNo" :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="100px">
  135. <el-form-item label="编号" prop="cofferNo">
  136. <el-input v-model="form.cofferNo" 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 {
  192. addCoffer,
  193. delCoffer,
  194. exportCoffer,
  195. getCoffer,
  196. listCoffer,
  197. updateCoffer
  198. } from "@/api/ps/dev/coffer";
  199. import {treeselect} from "@/api/system/dept";
  200. import {getToken} from "@/utils/auth";
  201. import Treeselect from "@riophae/vue-treeselect";
  202. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  203. export default {
  204. name: "Coffer",
  205. components: {Treeselect},
  206. dicts: ['dev_status'],
  207. data() {
  208. return {
  209. // 遮罩层
  210. loading: true,
  211. // 选中数组
  212. ids: [],
  213. // 非单个禁用
  214. single: true,
  215. // 非多个禁用
  216. multiple: true,
  217. // 显示搜索条件
  218. showSearch: false,
  219. // 总条数
  220. total: 0,
  221. // 围堰基础信息表格数据
  222. cofferList: [],
  223. // 弹出层标题
  224. title: "",
  225. // 部门树选项
  226. deptOptions: undefined,
  227. clientHeight: 300,
  228. // 是否显示弹出层
  229. open: false,
  230. // 用户导入参数
  231. upload: {
  232. downloadAction: process.env.VUE_APP_BASE_API + '/common/template',
  233. //下载模板类型
  234. type: 'coffer',
  235. // 是否显示弹出层(用户导入)
  236. open: false,
  237. // 弹出层标题(用户导入)
  238. title: "",
  239. // 是否禁用上传
  240. isUploading: false,
  241. // 设置上传的请求头部
  242. headers: {Authorization: "Bearer " + getToken()},
  243. // 上传的地址
  244. url: process.env.VUE_APP_BASE_API + "/ps/dev/coffer/importData"
  245. },
  246. // 查询参数
  247. queryParams: {
  248. pageNum: 1,
  249. pageSize: 20,
  250. cofferNo: null,
  251. position: null,
  252. createrCode: null,
  253. createdate: null,
  254. updaterCode: null,
  255. updatedate: null,
  256. remarks: null,
  257. deptId: null,
  258. status: null,
  259. patrolType: null
  260. },
  261. // 表单参数
  262. form: {},
  263. // 表单校验
  264. rules: {
  265. cofferNo: [
  266. {required: true, message: "编号不能为空", trigger: "blur"}
  267. ],
  268. position: [
  269. {required: true, message: "现场位置不能为空", trigger: "blur"}
  270. ],
  271. status: [
  272. {required: true, message: "状态不能为空", trigger: "blur"}
  273. ]
  274. }
  275. };
  276. },
  277. watch: {
  278. // 根据名称筛选部门树
  279. deptName(val) {
  280. this.$refs.tree.filter(val);
  281. }
  282. },
  283. created() {
  284. //设置表格高度对应屏幕高度
  285. this.$nextTick(() => {
  286. this.clientHeight = document.body.clientHeight - 250
  287. })
  288. this.getList();
  289. this.getTreeselect();
  290. },
  291. methods: {
  292. /** 查询围堰基础信息列表 */
  293. getList() {
  294. this.loading = true;
  295. listCoffer(this.queryParams).then(response => {
  296. this.cofferList = response.rows;
  297. this.total = response.total;
  298. this.loading = false;
  299. });
  300. },
  301. /** 查询部门下拉树结构 */
  302. getTreeselect() {
  303. treeselect().then(response => {
  304. this.deptOptions = response.data;
  305. });
  306. },
  307. // 取消按钮
  308. cancel() {
  309. this.open = false;
  310. this.reset();
  311. },
  312. // 表单重置
  313. reset() {
  314. this.form = {
  315. id: null,
  316. cofferNo: null,
  317. position: null,
  318. delFlag: null,
  319. createrCode: null,
  320. createdate: null,
  321. updaterCode: null,
  322. updatedate: null,
  323. remarks: null,
  324. deptId: null,
  325. status: "1",
  326. patrolType: null
  327. };
  328. this.resetForm("form");
  329. },
  330. /** 搜索按钮操作 */
  331. handleQuery() {
  332. this.queryParams.pageNum = 1;
  333. this.getList();
  334. },
  335. /** 重置按钮操作 */
  336. resetQuery() {
  337. this.resetForm("queryForm");
  338. this.handleQuery();
  339. },
  340. // 多选框选中数据
  341. handleSelectionChange(selection) {
  342. this.ids = selection.map(item => item.id)
  343. this.single = selection.length !== 1
  344. this.multiple = !selection.length
  345. },
  346. /** 新增按钮操作 */
  347. handleAdd() {
  348. this.reset();
  349. this.open = true;
  350. this.title = "添加围堰基础信息";
  351. },
  352. /** 修改按钮操作 */
  353. handleUpdate(row) {
  354. this.reset();
  355. const id = row.id || this.ids
  356. getCoffer(id).then(response => {
  357. this.form = response.data;
  358. this.open = true;
  359. this.title = "修改围堰基础信息";
  360. });
  361. },
  362. /** 提交按钮 */
  363. submitForm() {
  364. this.$refs["form"].validate(valid => {
  365. if (valid) {
  366. if (this.form.id != null) {
  367. updateCoffer(this.form).then(response => {
  368. this.msgSuccess("修改成功");
  369. this.open = false;
  370. this.getList();
  371. });
  372. } else {
  373. addCoffer(this.form).then(response => {
  374. this.msgSuccess("新增成功");
  375. this.open = false;
  376. this.getList();
  377. });
  378. }
  379. }
  380. });
  381. },
  382. /** 删除按钮操作 */
  383. handleDelete(row) {
  384. const ids = row.id || this.ids;
  385. this.$confirm('是否确认删除?', "警告", {
  386. confirmButtonText: "确定",
  387. cancelButtonText: "取消",
  388. type: "warning"
  389. }).then(function () {
  390. return delCoffer(ids);
  391. }).then(() => {
  392. this.getList();
  393. this.msgSuccess("删除成功");
  394. })
  395. },
  396. /** 导出按钮操作 */
  397. handleExport() {
  398. const queryParams = this.queryParams;
  399. this.$confirm('是否确认导出所有围堰基础信息数据项?', "警告", {
  400. confirmButtonText: "确定",
  401. cancelButtonText: "取消",
  402. type: "warning"
  403. }).then(function () {
  404. return exportCoffer(queryParams);
  405. }).then(response => {
  406. this.download(response.msg);
  407. })
  408. },
  409. /** 导入按钮操作 */
  410. handleImport() {
  411. this.upload.title = "用户导入";
  412. this.upload.open = true;
  413. },
  414. /** 下载模板操作 */
  415. importTemplate() {
  416. this.$refs['downloadFileForm'].submit()
  417. },
  418. // 文件上传中处理
  419. handleFileUploadProgress(event, file, fileList) {
  420. this.upload.isUploading = true;
  421. },
  422. // 文件上传成功处理
  423. handleFileSuccess(response, file, fileList) {
  424. this.upload.open = false;
  425. this.upload.isUploading = false;
  426. this.$refs.upload.clearFiles();
  427. if (response.data[0] != null) {
  428. this.$alert('成功导入' + response.msg + '条数据,' + '第' + response.data + '行数据出现错误导入失败' + '。', '导入结果', {dangerouslyUseHTMLString: true});
  429. } else {
  430. this.$alert('成功导入' + response.msg + '条数据', '导入结果', {dangerouslyUseHTMLString: true});
  431. }
  432. this.getList();
  433. },
  434. // 提交上传文件
  435. submitFileForm() {
  436. this.$refs.upload.submit();
  437. },
  438. /** 导出按钮操作 */
  439. handleExportQRCode() {
  440. this.download2('ps/dev/coffer/exportQRCode', {
  441. ...this.queryParams
  442. }, `cofferQRCode_${new Date().getTime()}.zip`)
  443. }
  444. }
  445. };
  446. </script>