index.vue 9.3 KB

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