index.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="位号" prop="devNo">
  5. <el-input
  6. v-model="queryParams.devNo"
  7. placeholder="请输入位号"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item label="位置" prop="position">
  13. <el-input
  14. v-model="queryParams.position"
  15. placeholder="请输入位置"
  16. clearable
  17. @keyup.enter.native="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item label="状态" prop="status">
  21. <el-select v-model="queryParams.status" clearable placeholder="请选择状态" @change="handleQuery">
  22. <el-option
  23. v-for="dict in dict.type.dev_status"
  24. :key="dict.value"
  25. :label="dict.label"
  26. :value="dict.value"
  27. />
  28. </el-select>
  29. </el-form-item>
  30. <el-form-item>
  31. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  32. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  33. </el-form-item>
  34. </el-form>
  35. <el-row :gutter="10" class="mb8">
  36. <el-col :span="1.5">
  37. <el-button
  38. type="primary"
  39. plain
  40. icon="el-icon-plus"
  41. size="mini"
  42. @click="handleAdd"
  43. v-hasPermi="['dev:standpipe:add']"
  44. >新增</el-button>
  45. </el-col>
  46. <el-col :span="1.5">
  47. <el-button
  48. type="success"
  49. plain
  50. icon="el-icon-edit"
  51. size="mini"
  52. :disabled="single"
  53. @click="handleUpdate"
  54. v-hasPermi="['dev:standpipe:edit']"
  55. >修改</el-button>
  56. </el-col>
  57. <el-col :span="1.5">
  58. <el-button
  59. type="danger"
  60. plain
  61. icon="el-icon-delete"
  62. size="mini"
  63. :disabled="multiple"
  64. @click="handleDelete"
  65. v-hasPermi="['dev:standpipe:remove']"
  66. >删除</el-button>
  67. </el-col>
  68. <el-col :span="1.5">
  69. <el-button
  70. type="warning"
  71. plain
  72. icon="el-icon-download"
  73. size="mini"
  74. @click="handleExport"
  75. v-hasPermi="['dev:standpipe:export']"
  76. >导出</el-button>
  77. </el-col>
  78. <el-col :span="1.5">
  79. <el-button
  80. v-hasPermi="['dev:standpipe:export']"
  81. icon="el-icon-download"
  82. plain
  83. size="mini"
  84. type="warning"
  85. @click="handleExportQRCode"
  86. >导出设备二维码
  87. </el-button>
  88. </el-col>
  89. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  90. </el-row>
  91. <el-table v-loading="loading" :data="standpipeList" :height="clientHeight" @selection-change="handleSelectionChange" border>
  92. <el-table-column type="selection" width="55" align="center" />
  93. <el-table-column label="位号" align="center" prop="devNo" />
  94. <el-table-column label="位置" align="center" prop="position" />
  95. <el-table-column align="center" label="状态" prop="status">
  96. <template slot-scope="scope">
  97. <dict-tag :options="dict.type.dev_status" :value="scope.row.status"/>
  98. </template>
  99. </el-table-column>
  100. <el-table-column label="备注" align="center" prop="remarks" />
  101. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  102. <template slot-scope="scope">
  103. <el-button
  104. size="mini"
  105. type="text"
  106. icon="el-icon-edit"
  107. @click="handleUpdate(scope.row)"
  108. v-hasPermi="['dev:standpipe:edit']"
  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="['dev:standpipe:remove']"
  116. >删除</el-button>
  117. </template>
  118. </el-table-column>
  119. </el-table>
  120. <pagination
  121. v-show="total>0"
  122. :total="total"
  123. :page.sync="queryParams.pageNum"
  124. :limit.sync="queryParams.pageSize"
  125. @pagination="getList"
  126. />
  127. <!-- 添加或修改消防竖管对话框 -->
  128. <el-dialog :close-on-click-modal="false":title="title" :visible.sync="open" width="500px" append-to-body>
  129. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  130. <el-form-item label="位号" prop="devNo">
  131. <el-input v-model="form.devNo" placeholder="请输入位号" />
  132. </el-form-item>
  133. <el-form-item label="位置" prop="position">
  134. <el-input v-model="form.position" placeholder="请输入位置" />
  135. </el-form-item>
  136. <el-form-item label="状态" prop="status">
  137. <el-radio-group v-model="form.status">
  138. <el-radio
  139. v-for="dict in dict.type.dev_status"
  140. :key="dict.value"
  141. :label="dict.value"
  142. >{{dict.label}}</el-radio>
  143. </el-radio-group>
  144. </el-form-item>
  145. <el-form-item label="备注" prop="remarks">
  146. <el-input v-model="form.remarks" placeholder="请输入备注" />
  147. </el-form-item>
  148. </el-form>
  149. <div slot="footer" class="dialog-footer">
  150. <el-button type="primary" @click="submitForm">确 定</el-button>
  151. <el-button @click="cancel">取 消</el-button>
  152. </div>
  153. </el-dialog>
  154. </div>
  155. </template>
  156. <script>
  157. import { listStandpipe, getStandpipe, delStandpipe, addStandpipe, updateStandpipe } from "@/api/patrol/dev/standpipe";
  158. export default {
  159. name: "Standpipe",
  160. dicts: ['dev_status'],
  161. data() {
  162. return {
  163. // 遮罩层
  164. loading: true,
  165. // 选中数组
  166. ids: [],
  167. // 非单个禁用
  168. single: true,
  169. // 非多个禁用
  170. multiple: true,
  171. // 显示搜索条件
  172. showSearch: false,
  173. // 页面高度
  174. clientHeight: 300,
  175. // 总条数
  176. total: 0,
  177. // 消防竖管表格数据
  178. standpipeList: [],
  179. // 弹出层标题
  180. title: "",
  181. // 是否显示弹出层
  182. open: false,
  183. // 查询参数
  184. queryParams: {
  185. pageNum: 1,
  186. pageSize: 20,
  187. devNo: null,
  188. position: null,
  189. createrCode: null,
  190. createdate: null,
  191. updaterCode: null,
  192. updatedate: null,
  193. remarks: null,
  194. deptId: null,
  195. status: null,
  196. patrolType: null
  197. },
  198. // 表单参数
  199. form: {},
  200. // 表单校验
  201. rules: {
  202. devNo: [
  203. { required: true, message: "位号不能为空", trigger: "blur" }
  204. ],
  205. position: [
  206. { required: true, message: "位置不能为空", trigger: "blur" }
  207. ],
  208. }
  209. };
  210. },
  211. created() {
  212. //设置表格高度对应屏幕高度
  213. this.$nextTick(() => {
  214. this.clientHeight = document.body.clientHeight - 270
  215. });
  216. this.getList();
  217. },
  218. methods: {
  219. /** 查询消防竖管列表 */
  220. getList() {
  221. this.loading = true;
  222. listStandpipe(this.queryParams).then(response => {
  223. this.standpipeList = response.rows;
  224. this.total = response.total;
  225. this.loading = false;
  226. });
  227. },
  228. // 取消按钮
  229. cancel() {
  230. this.open = false;
  231. this.reset();
  232. },
  233. // 表单重置
  234. reset() {
  235. this.form = {
  236. id: null,
  237. devNo: null,
  238. position: null,
  239. delFlag: null,
  240. createrCode: null,
  241. createdate: null,
  242. updaterCode: null,
  243. updatedate: null,
  244. remarks: null,
  245. deptId: null,
  246. status: "1",
  247. patrolType: 5
  248. };
  249. this.resetForm("form");
  250. },
  251. /** 搜索按钮操作 */
  252. handleQuery() {
  253. this.queryParams.pageNum = 1;
  254. this.getList();
  255. },
  256. /** 重置按钮操作 */
  257. resetQuery() {
  258. this.resetForm("queryForm");
  259. this.handleQuery();
  260. },
  261. // 多选框选中数据
  262. handleSelectionChange(selection) {
  263. this.ids = selection.map(item => item.id)
  264. this.single = selection.length!==1
  265. this.multiple = !selection.length
  266. },
  267. /** 新增按钮操作 */
  268. handleAdd() {
  269. this.reset();
  270. this.open = true;
  271. this.title = "添加消防竖管";
  272. },
  273. /** 修改按钮操作 */
  274. handleUpdate(row) {
  275. this.reset();
  276. const id = row.id || this.ids
  277. getStandpipe(id).then(response => {
  278. this.form = response.data;
  279. this.open = true;
  280. this.title = "修改消防竖管";
  281. });
  282. },
  283. /** 提交按钮 */
  284. submitForm() {
  285. this.$refs["form"].validate(valid => {
  286. if (valid) {
  287. if (this.form.id != null) {
  288. updateStandpipe(this.form).then(response => {
  289. this.msgSuccess("修改成功");
  290. this.open = false;
  291. this.getList();
  292. });
  293. } else {
  294. addStandpipe(this.form).then(response => {
  295. this.msgSuccess("新增成功");
  296. this.open = false;
  297. this.getList();
  298. });
  299. }
  300. }
  301. });
  302. },
  303. /** 删除按钮操作 */
  304. handleDelete(row) {
  305. const ids = row.id || this.ids;
  306. this.$confirm('是否确认删除消防竖管编号为"' + ids + '"的数据项?').then(function() {
  307. return delStandpipe(ids);
  308. }).then(() => {
  309. this.getList();
  310. this.msgSuccess("删除成功");
  311. }).catch(() => {});
  312. },
  313. /** 导出按钮操作 */
  314. handleExport() {
  315. this.download2('dev/standpipe/export', {
  316. ...this.queryParams
  317. }, `standpipe_${new Date().getTime()}.xlsx`)
  318. },
  319. /** 导出按钮操作 */
  320. handleExportQRCode() {
  321. this.download2('dev/standpipe/exportQRCode', {
  322. ...this.queryParams
  323. }, `消防竖管QRCode_${new Date().getTime()}.docx`)
  324. }
  325. }
  326. };
  327. </script>