index.vue 13 KB

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