index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="110px">
  4. <el-form-item label="小区" prop="areaId">
  5. <el-select v-model="queryParams.areaId" placeholder="请选择小区" filterable @change="getBuildings">
  6. <el-option
  7. v-for="obj in areas"
  8. :key="obj.id"
  9. :label="obj.name"
  10. :value="obj.id"
  11. ></el-option>
  12. </el-select>
  13. </el-form-item>
  14. <el-form-item label="楼栋" prop="buildingId">
  15. <el-select v-model="queryParams.buildingId" placeholder="请选择楼栋" filterable @change="getUnits">
  16. <el-option
  17. v-for="obj in builds"
  18. :key="obj.id"
  19. :label="obj.name"
  20. :value="obj.id"
  21. ></el-option>
  22. </el-select>
  23. </el-form-item>
  24. <el-form-item label="单元" prop="unitId">
  25. <el-select v-model="queryParams.unitId" placeholder="请选择单元" filterable @change="getHouses">
  26. <el-option
  27. v-for="obj in units"
  28. :key="obj.id"
  29. :label="obj.name"
  30. :value="obj.id"
  31. ></el-option>
  32. </el-select>
  33. </el-form-item>
  34. <el-form-item label="房间号" prop="houseId">
  35. <el-select v-model="queryParams.houseId" placeholder="请选择房间号" filterable>
  36. <el-option
  37. v-for="obj in houses"
  38. :key="obj.id"
  39. :label="obj.name"
  40. :value="obj.id"
  41. ></el-option>
  42. </el-select>
  43. </el-form-item>
  44. <el-form-item>
  45. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  46. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  47. </el-form-item>
  48. </el-form>
  49. <el-row :gutter="10" class="mb8">
  50. <el-col :span="1.5">
  51. <el-button
  52. type="primary"
  53. plain
  54. icon="el-icon-plus"
  55. size="mini"
  56. @click="handleAdd"
  57. v-hasPermi="['zdsz:openbolt:add']"
  58. >新增</el-button>
  59. </el-col>
  60. <el-col :span="1.5">
  61. <el-button
  62. type="success"
  63. plain
  64. icon="el-icon-edit"
  65. size="mini"
  66. :disabled="single"
  67. @click="handleUpdate"
  68. v-hasPermi="['zdsz:openbolt:edit']"
  69. >修改</el-button>
  70. </el-col>
  71. <el-col :span="1.5">
  72. <el-button
  73. type="danger"
  74. plain
  75. icon="el-icon-delete"
  76. size="mini"
  77. :disabled="multiple"
  78. @click="handleDelete"
  79. v-hasPermi="['zdsz:openbolt:remove']"
  80. >删除</el-button>
  81. </el-col>
  82. <!-- <el-col :span="1.5">-->
  83. <!-- <el-button-->
  84. <!-- type="warning"-->
  85. <!-- plain-->
  86. <!-- icon="el-icon-download"-->
  87. <!-- size="mini"-->
  88. <!-- @click="handleExport"-->
  89. <!-- v-hasPermi="['zdsz:openbolt:export']"-->
  90. <!-- >导出</el-button>-->
  91. <!-- </el-col>-->
  92. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  93. </el-row>
  94. <el-table v-loading="loading" :data="comprehensiveList" @selection-change="handleSelectionChange">
  95. <el-table-column type="selection" width="55" align="center" />
  96. <!-- <el-table-column label="" align="center" prop="id" v-if="true"/>-->
  97. <el-table-column label="小区" align="center" prop="areaName" />
  98. <el-table-column label="楼栋" align="center" prop="buildingName" />
  99. <el-table-column label="单元" align="center" prop="unitName" />
  100. <el-table-column label="房间" align="center" prop="houseName" />
  101. <el-table-column label="安检是否合格" align="center" prop="isQualified">
  102. <template slot-scope="scope">
  103. <dict-tag :options="dict.type.pass_check" :value="scope.row.isQualified"/>
  104. </template>
  105. </el-table-column>
  106. <el-table-column label="是否维修" align="center" prop="isMaintenance">
  107. <template slot-scope="scope">
  108. <dict-tag :options="dict.type.is_repair" :value="scope.row.isMaintenance"/>
  109. </template>
  110. </el-table-column>
  111. <el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip/>
  112. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  113. <template slot-scope="scope">
  114. <el-button
  115. size="mini"
  116. type="text"
  117. icon="el-icon-edit"
  118. @click="handleUpdate(scope.row)"
  119. v-hasPermi="['zdsz:comprehensive:edit']"
  120. >修改</el-button>
  121. <el-button
  122. size="mini"
  123. type="text"
  124. icon="el-icon-delete"
  125. @click="handleDelete(scope.row)"
  126. v-hasPermi="['zdsz:comprehensive:remove']"
  127. >删除</el-button>
  128. </template>
  129. </el-table-column>
  130. </el-table>
  131. <pagination
  132. v-show="total>0"
  133. :total="total"
  134. :page.sync="queryParams.pageNum"
  135. :limit.sync="queryParams.pageSize"
  136. @pagination="getList"
  137. />
  138. <!-- 添加或修改开栓|安检|维修对话框 -->
  139. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  140. <el-form ref="form" :model="form" :rules="rules" label-width="110px">
  141. <el-form-item label="小区" prop="areaId">
  142. <el-select v-model="form.areaId" placeholder="请选择小区" filterable @change="getBuildings1">
  143. <el-option
  144. v-for="obj in areas"
  145. :key="obj.id"
  146. :label="obj.name"
  147. :value="obj.id"
  148. ></el-option>
  149. </el-select>
  150. </el-form-item>
  151. <el-form-item label="楼栋" prop="buildingId">
  152. <el-select v-model="form.buildingId" placeholder="请选择楼栋" filterable @change="getUnits1">
  153. <el-option
  154. v-for="obj in builds"
  155. :key="obj.id"
  156. :label="obj.name"
  157. :value="obj.id"
  158. ></el-option>
  159. </el-select>
  160. </el-form-item>
  161. <el-form-item label="单元" prop="unitId">
  162. <el-select v-model="form.unitId" placeholder="请选择单元" filterable @change="getHouses1">
  163. <el-option
  164. v-for="obj in units"
  165. :key="obj.id"
  166. :label="obj.name"
  167. :value="obj.id"
  168. ></el-option>
  169. </el-select>
  170. </el-form-item>
  171. <el-form-item label="房间号" prop="houseId">
  172. <el-select v-model="form.houseId" placeholder="请选择房间号" filterable>
  173. <el-option
  174. v-for="obj in houses"
  175. :key="obj.id"
  176. :label="obj.name"
  177. :value="obj.id"
  178. ></el-option>
  179. </el-select>
  180. </el-form-item>
  181. <el-form-item label="安检是否合格" prop="isQualified">
  182. <!-- <el-input v-model="form.isQualified" placeholder="请输入安检是否合格" />-->
  183. <el-select v-model="form.isQualified" placeholder="请选择安检是否合格" filterable>
  184. <el-option
  185. v-for="obj in dict.type.pass_check"
  186. :key="obj.value"
  187. :label="obj.label"
  188. :value="obj.value"
  189. ></el-option>
  190. </el-select>
  191. </el-form-item>
  192. <el-form-item label="是否维修" prop="isMaintenance">
  193. <!-- <el-input v-model="form.isMaintenance" placeholder="请输入是否维修" />-->
  194. <el-select v-model="form.isMaintenance" placeholder="请选择是否维修" filterable>
  195. <el-option
  196. v-for="obj in dict.type.is_repair"
  197. :key="obj.value"
  198. :label="obj.label"
  199. :value="obj.value"
  200. ></el-option>
  201. </el-select>
  202. </el-form-item>
  203. <el-form-item label="备注" prop="remark">
  204. <el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/>
  205. </el-form-item>
  206. </el-form>
  207. <div slot="footer" class="dialog-footer">
  208. <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
  209. <el-button @click="cancel">取 消</el-button>
  210. </div>
  211. </el-dialog>
  212. </div>
  213. </template>
  214. <script>
  215. import { listComprehensive, getComprehensive, delComprehensive, addComprehensive, updateComprehensive } from "@/api/zdsz/comprehensive";
  216. import {getBuildings} from "@/api/zdsz/building";
  217. import {getUnits} from "@/api/zdsz/unit";
  218. import {getAreas} from "@/api/zdsz/area";
  219. import {getHouses, listHouse} from "@/api/zdsz/house";
  220. export default {
  221. name: "openrepair",
  222. dicts:['pass_check','is_repair'],
  223. data() {
  224. return {
  225. // 按钮loading
  226. buttonLoading: false,
  227. // 遮罩层
  228. loading: true,
  229. // 选中数组
  230. ids: [],
  231. // 非单个禁用
  232. single: true,
  233. // 非多个禁用
  234. multiple: true,
  235. // 显示搜索条件
  236. showSearch: true,
  237. // 总条数
  238. total: 0,
  239. // 开栓|安检|维修表格数据
  240. comprehensiveList: [],
  241. // 弹出层标题
  242. title: "",
  243. // 是否显示弹出层
  244. open: false,
  245. // 查询参数
  246. queryParams: {
  247. pageNum: 1,
  248. pageSize: 10,
  249. areaId: undefined,
  250. buildingId: undefined,
  251. unitId: undefined,
  252. houseId: undefined,
  253. type: 3,
  254. isQualified: undefined,
  255. isMaintenance: undefined,
  256. },
  257. // 表单参数
  258. form: {},
  259. areas: [],
  260. builds: [],
  261. units: [],
  262. rooms: [],
  263. houses: [],
  264. // 表单校验
  265. rules: {
  266. areaId: [
  267. { required: true, message: "小区不能为空", trigger: "change" }
  268. ],
  269. buildingId: [
  270. { required: true, message: "楼栋不能为空", trigger: "change" }
  271. ],
  272. unitId: [
  273. { required: true, message: "单元不能为空", trigger: "change" }
  274. ],
  275. houseId: [
  276. { required: true, message: "房间不能为空", trigger: "change" }
  277. ],
  278. type: [
  279. { required: false, message: "类型不能为空", trigger: "change" }
  280. ],
  281. isQualified: [
  282. { required: true, message: "安检是否合格不能为空", trigger: "blur" }
  283. ],
  284. isMaintenance: [
  285. { required: true, message: "是否维修不能为空", trigger: "blur" }
  286. ],
  287. remark: [
  288. { required: false, message: "备注不能为空", trigger: "blur" }
  289. ],
  290. }
  291. };
  292. },
  293. created() {
  294. this.getList();
  295. this.getAreas();
  296. },
  297. methods: {
  298. getBuildings(id) {
  299. this.units = []
  300. this.houses = []
  301. this.queryParams.buildingId = undefined
  302. this.queryParams.unitId = undefined
  303. this.queryParams.houseId = undefined
  304. getBuildings(id).then(res => {
  305. this.builds = res.data
  306. })
  307. },
  308. getUnits(id) {
  309. this.houses = []
  310. this.queryParams.unitId = undefined
  311. this.queryParams.houseId = undefined
  312. getUnits(this.queryParams.areaId,id).then(res => {
  313. this.units = res.data
  314. })
  315. },
  316. getAreas() {
  317. this.builds = []
  318. this.units = []
  319. this.houses = []
  320. this.queryParams.buildingId = undefined
  321. this.queryParams.unitId = undefined
  322. this.queryParams.houseId = undefined
  323. this.form.buildingId = undefined
  324. this.form.unitId = undefined
  325. this.form.houseId = undefined
  326. getAreas().then(res => {
  327. this.areas = res.data;
  328. });
  329. },
  330. getHouses() {
  331. this.houses = []
  332. this.queryParams.houseId = undefined
  333. getHouses(this.queryParams.unitId).then(res => {
  334. this.houses = res.data;
  335. });
  336. },
  337. getBuildings1(id) {
  338. this.units = []
  339. this.houses = []
  340. this.form.buildingId = undefined
  341. this.form.unitId = undefined
  342. this.form.houseId = undefined
  343. getBuildings(id).then(res => {
  344. this.builds = res.data
  345. })
  346. },
  347. getUnits1(id) {
  348. this.houses = []
  349. this.form.unitId = undefined
  350. this.form.houseId = undefined
  351. getUnits(this.form.areaId,id).then(res => {
  352. this.units = res.data
  353. })
  354. },
  355. getHouses1() {
  356. this.houses = []
  357. this.form.houseId = undefined
  358. getHouses(this.form.unitId).then(res => {
  359. this.houses = res.data;
  360. });
  361. },
  362. /** 查询开栓|安检|维修列表 */
  363. getList() {
  364. this.loading = true;
  365. listComprehensive(this.queryParams).then(response => {
  366. this.comprehensiveList = response.rows;
  367. this.total = response.total;
  368. this.loading = false;
  369. });
  370. },
  371. // 取消按钮
  372. cancel() {
  373. this.open = false;
  374. this.reset();
  375. this.houses = []
  376. this.units = []
  377. this.builds = []
  378. },
  379. // 表单重置
  380. reset() {
  381. this.form = {
  382. id: undefined,
  383. areaId: undefined,
  384. buildingId: undefined,
  385. unitId: undefined,
  386. houseId: undefined,
  387. type: 3,
  388. isQualified: undefined,
  389. isMaintenance: undefined,
  390. remark: undefined,
  391. delFlag: 0,
  392. createBy: undefined,
  393. createTime: undefined,
  394. updateBy: undefined,
  395. updateTime: undefined
  396. };
  397. this.resetForm("form");
  398. },
  399. /** 搜索按钮操作 */
  400. handleQuery() {
  401. this.queryParams.pageNum = 1;
  402. this.getList();
  403. },
  404. /** 重置按钮操作 */
  405. resetQuery() {
  406. this.resetForm("queryForm");
  407. this.handleQuery();
  408. },
  409. // 多选框选中数据
  410. handleSelectionChange(selection) {
  411. this.ids = selection.map(item => item.id)
  412. this.single = selection.length!==1
  413. this.multiple = !selection.length
  414. },
  415. /** 新增按钮操作 */
  416. handleAdd() {
  417. this.reset();
  418. this.open = true;
  419. this.title = "添加维修";
  420. },
  421. /** 修改按钮操作 */
  422. handleUpdate(row) {
  423. getBuildings(row.areaId).then(res => {
  424. this.builds = res.data
  425. });
  426. getUnits(row.areaId,row.buildingId).then(res => {
  427. this.units = res.data
  428. })
  429. getHouses(row.unitId).then(res => {
  430. this.houses = res.data;
  431. });
  432. this.loading = true;
  433. this.reset();
  434. const id = row.id || this.ids
  435. getComprehensive(id).then(response => {
  436. this.loading = false;
  437. this.form = response.data;
  438. this.open = true;
  439. this.title = "修改维修";
  440. });
  441. },
  442. /** 提交按钮 */
  443. submitForm() {
  444. this.$refs["form"].validate(valid => {
  445. if (valid) {
  446. this.buttonLoading = true;
  447. if (this.form.id != null) {
  448. updateComprehensive(this.form).then(response => {
  449. this.$modal.msgSuccess("修改成功");
  450. this.open = false;
  451. this.getList();
  452. }).finally(() => {
  453. this.buttonLoading = false;
  454. });
  455. } else {
  456. addComprehensive(this.form).then(response => {
  457. this.$modal.msgSuccess("新增成功");
  458. this.open = false;
  459. this.getList();
  460. }).finally(() => {
  461. this.buttonLoading = false;
  462. });
  463. }
  464. }
  465. });
  466. },
  467. /** 删除按钮操作 */
  468. handleDelete(row) {
  469. const ids = row.id || this.ids;
  470. this.$modal.confirm('是否确认删除维修为"' + ids + '"的数据项?').then(() => {
  471. this.loading = true;
  472. return delComprehensive(ids);
  473. }).then(() => {
  474. this.loading = false;
  475. this.getList();
  476. this.$modal.msgSuccess("删除成功");
  477. }).catch(() => {
  478. }).finally(() => {
  479. this.loading = false;
  480. });
  481. },
  482. /** 导出按钮操作 */
  483. handleExport() {
  484. this.download('zdsz/openbolt/export', {
  485. ...this.queryParams
  486. }, `comprehensive_${new Date().getTime()}.xlsx`)
  487. }
  488. }
  489. };
  490. </script>