index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  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="district">
  5. <el-select v-model="queryParams.district" placeholder="请选择行政区" filterable @change="getAreas" >
  6. <el-option
  7. v-for="dict in dict.type.district"
  8. :key="dict.value"
  9. :label="dict.label"
  10. :value="dict.value"
  11. ></el-option>
  12. </el-select>
  13. </el-form-item>
  14. <el-form-item label="所属小区" prop="areaId">
  15. <el-select v-model="queryParams.areaId" placeholder="请选择所属小区" filterable @change="getBuildings">
  16. <el-option
  17. v-for="obj in areas"
  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="buildingId">
  25. <el-select v-model="queryParams.buildingId" placeholder="请选择所属楼宇" filterable @change="getUnits">
  26. <el-option
  27. v-for="obj in builds"
  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="unitId">
  35. <el-select v-model="queryParams.unitId" placeholder="请选择所属单元" filterable @change="getHouses">
  36. <el-option
  37. v-for="obj in units"
  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 label="所属房间" prop="houseId">
  45. <el-select v-model="queryParams.houseId" placeholder="请选择所属房间" filterable>
  46. <el-option
  47. v-for="obj in houses"
  48. :key="obj.id"
  49. :label="obj.name"
  50. :value="obj.id"
  51. ></el-option>
  52. </el-select>
  53. </el-form-item>
  54. <el-form-item label="职工" prop="personBy">
  55. <el-select v-model="queryParams.personBy" placeholder="请选择职工" filterable>
  56. <el-option
  57. v-for="obj in users"
  58. :key="obj.userId"
  59. :label="obj.nickName"
  60. :value="obj.userId"
  61. ></el-option>
  62. </el-select>
  63. </el-form-item>
  64. <el-form-item label="施工时间" prop="times">
  65. <el-date-picker
  66. v-model="queryParams.times"
  67. size="small"
  68. style="width: 240px"
  69. value-format="yyyy-MM-dd HH:mm:ss"
  70. type="daterange"
  71. range-separator="-"
  72. start-placeholder="开始日期"
  73. end-placeholder="结束日期"
  74. :default-time="['00:00:00', '23:59:59']"
  75. ></el-date-picker>
  76. </el-form-item>
  77. <el-form-item>
  78. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  79. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  80. </el-form-item>
  81. </el-form>
  82. <el-row :gutter="10" class="mb8">
  83. <el-col :span="1.5">
  84. <el-button
  85. type="primary"
  86. plain
  87. icon="el-icon-plus"
  88. size="mini"
  89. @click="handleAdd"
  90. v-hasPermi="['zdsz:openbolt:add']"
  91. >新增</el-button>
  92. </el-col>
  93. <el-col :span="1.5">
  94. <el-button
  95. type="success"
  96. plain
  97. icon="el-icon-edit"
  98. size="mini"
  99. :disabled="single"
  100. @click="handleUpdate"
  101. v-hasPermi="['zdsz:openbolt:edit']"
  102. >修改</el-button>
  103. </el-col>
  104. <el-col :span="1.5">
  105. <el-button
  106. type="danger"
  107. plain
  108. icon="el-icon-delete"
  109. size="mini"
  110. :disabled="multiple"
  111. @click="handleDelete"
  112. v-hasPermi="['zdsz:openbolt:remove']"
  113. >删除</el-button>
  114. </el-col>
  115. <!-- <el-col :span="1.5">-->
  116. <!-- <el-button-->
  117. <!-- type="warning"-->
  118. <!-- plain-->
  119. <!-- icon="el-icon-download"-->
  120. <!-- size="mini"-->
  121. <!-- @click="handleExport"-->
  122. <!-- v-hasPermi="['zdsz:openbolt:export']"-->
  123. <!-- >导出</el-button>-->
  124. <!-- </el-col>-->
  125. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  126. </el-row>
  127. <el-table v-loading="loading" :data="comprehensiveList" @selection-change="handleSelectionChange">
  128. <el-table-column type="selection" width="55" align="center" />
  129. <el-table-column label="行政区" align="center" prop="district">
  130. <template slot-scope="scope">
  131. <dict-tag :options="dict.type.district" :value="scope.row.district"/>
  132. </template>
  133. </el-table-column> <el-table-column label="小区" align="center" prop="areaName" />
  134. <el-table-column label="楼栋" align="center" prop="buildingName" />
  135. <el-table-column label="单元" align="center" prop="unitName" />
  136. <el-table-column label="房间" align="center" prop="houseName" />
  137. <el-table-column label="是否合格" align="center" prop="isQualified">
  138. <template slot-scope="scope">
  139. <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.isQualified"/>
  140. </template>
  141. </el-table-column>
  142. <el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip/>
  143. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  144. <template slot-scope="scope">
  145. <el-button
  146. size="mini"
  147. type="text"
  148. icon="el-icon-edit"
  149. @click="handleUpdate(scope.row)"
  150. v-hasPermi="['zdsz:openbolt:edit']"
  151. >修改</el-button>
  152. <el-button
  153. size="mini"
  154. type="text"
  155. icon="el-icon-delete"
  156. @click="handleDelete(scope.row)"
  157. v-hasPermi="['zdsz:openbolt:remove']"
  158. >删除</el-button>
  159. </template>
  160. </el-table-column>
  161. </el-table>
  162. <pagination
  163. v-show="total>0"
  164. :total="total"
  165. :page.sync="queryParams.pageNum"
  166. :limit.sync="queryParams.pageSize"
  167. @pagination="getList"
  168. />
  169. <!-- 添加或修改开栓|安检|维修对话框 -->
  170. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
  171. <el-form ref="form" :model="form" :rules="rules" label-width="110px">
  172. <el-row :gutter="20">
  173. <el-col :span="12">
  174. <el-form-item label="行政区" prop="district">
  175. <el-select v-model="form.district" placeholder="请选择行政区" filterable @change="getAreas" style="width: 100%;">
  176. <el-option
  177. v-for="dict in dict.type.district"
  178. :key="dict.value"
  179. :label="dict.label"
  180. :value="dict.value"
  181. ></el-option>
  182. </el-select>
  183. </el-form-item>
  184. </el-col>
  185. <el-col :span="12">
  186. <el-form-item label="小区" prop="areaId">
  187. <el-select v-model="form.areaId" placeholder="请选择小区" filterable @change="getBuildings1" style="width: 100%">
  188. <el-option
  189. v-for="obj in areas"
  190. :key="obj.id"
  191. :label="obj.name"
  192. :value="obj.id"
  193. ></el-option>
  194. </el-select>
  195. </el-form-item>
  196. </el-col>
  197. </el-row>
  198. <el-row :gutter="20">
  199. <el-col :span="12">
  200. <el-form-item label="楼栋" prop="buildingId">
  201. <el-select v-model="form.buildingId" placeholder="请选择楼栋" filterable @change="getUnits1" style="width: 100%">
  202. <el-option
  203. v-for="obj in builds"
  204. :key="obj.id"
  205. :label="obj.name"
  206. :value="obj.id"
  207. ></el-option>
  208. </el-select>
  209. </el-form-item>
  210. </el-col>
  211. <el-col :span="12">
  212. <el-form-item label="单元" prop="unitId">
  213. <el-select v-model="form.unitId" placeholder="请选择单元" filterable @change="getHouses1" style="width: 100%">
  214. <el-option
  215. v-for="obj in units"
  216. :key="obj.id"
  217. :label="obj.name"
  218. :value="obj.id"
  219. ></el-option>
  220. </el-select>
  221. </el-form-item>
  222. </el-col>
  223. </el-row>
  224. <el-row :gutter="20">
  225. <el-col :span="12">
  226. <el-form-item label="房间号" prop="houseId">
  227. <el-select v-model="form.houseId" placeholder="请选择房间号" filterable style="width: 100%">
  228. <el-option
  229. v-for="obj in houses"
  230. :key="obj.id"
  231. :label="obj.name"
  232. :value="obj.id"
  233. ></el-option>
  234. </el-select>
  235. </el-form-item>
  236. </el-col>
  237. </el-row>
  238. <el-row :gutter="20">
  239. <el-col :span="12">
  240. <el-form-item label="是否合格" prop="isQualified">
  241. <el-select v-model="form.isQualified" placeholder="请选择是否合格" filterable style="width: 100%">
  242. <el-option
  243. v-for="obj in dict.type.sys_yes_no"
  244. :key="obj.value"
  245. :label="obj.label"
  246. :value="obj.value"
  247. ></el-option>
  248. </el-select>
  249. </el-form-item>
  250. </el-col>
  251. </el-row>
  252. <el-row :gutter="20">
  253. <el-col :span="24">
  254. <el-form-item label="备注" prop="remark">
  255. <el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/>
  256. </el-form-item>
  257. </el-col>
  258. <el-col :span="24">
  259. <el-form-item label="照片" prop="picIds">
  260. <ObsImageUpload ref="obsImageUpload" :limit="9999" :fileType="['png', 'jpg', 'jpeg']" :value="form.picIds"
  261. @input="getUrl"></ObsImageUpload>
  262. </el-form-item>
  263. </el-col>
  264. </el-row>
  265. </el-form>
  266. <div slot="footer" class="dialog-footer">
  267. <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
  268. <el-button @click="cancel">取 消</el-button>
  269. </div>
  270. </el-dialog>
  271. </div>
  272. </template>
  273. <script>
  274. import { listComprehensive, getComprehensive, delComprehensive, addComprehensive, updateComprehensive } from "@/api/zdsz/comprehensive";
  275. import {getBuildings} from "@/api/zdsz/building";
  276. import {getUnits} from "@/api/zdsz/unit";
  277. import {getAreas} from "@/api/zdsz/area";
  278. import {getHouses, listHouse} from "@/api/zdsz/house";
  279. import {listAll} from "@/api/system/user";
  280. export default {
  281. name: "opencheck",
  282. dicts:['sys_yes_no','is_repair','district'],
  283. data() {
  284. return {
  285. // 按钮loading
  286. buttonLoading: false,
  287. // 遮罩层
  288. loading: true,
  289. // 选中数组
  290. ids: [],
  291. // 非单个禁用
  292. single: true,
  293. // 非多个禁用
  294. multiple: true,
  295. // 显示搜索条件
  296. showSearch: true,
  297. // 总条数
  298. total: 0,
  299. // 开栓|安检|维修表格数据
  300. comprehensiveList: [],
  301. // 弹出层标题
  302. title: "",
  303. // 是否显示弹出层
  304. open: false,
  305. // 查询参数
  306. queryParams: {
  307. pageNum: 1,
  308. pageSize: 10,
  309. times: [],
  310. areaId: undefined,
  311. buildingId: undefined,
  312. constructTime: undefined,
  313. constructEndTime: undefined,
  314. district: undefined,
  315. unitId: undefined,
  316. personBy: undefined,
  317. houseId: undefined,
  318. type: 3,
  319. isQualified: undefined,
  320. },
  321. // 表单参数
  322. form: {},
  323. areas: [],
  324. builds: [],
  325. units: [],
  326. rooms: [],
  327. houses: [],
  328. users: [],
  329. // 表单校验
  330. rules: {
  331. district: [
  332. { required: true, message: "行政区不能为空", trigger: "change" }
  333. ],
  334. areaId: [
  335. { required: true, message: "小区不能为空", trigger: "change" }
  336. ],
  337. buildingId: [
  338. { required: true, message: "楼栋不能为空", trigger: "change" }
  339. ],
  340. unitId: [
  341. { required: true, message: "单元不能为空", trigger: "change" }
  342. ],
  343. houseId: [
  344. { required: true, message: "房间不能为空", trigger: "change" }
  345. ],
  346. type: [
  347. { required: false, message: "类型不能为空", trigger: "change" }
  348. ],
  349. isQualified: [
  350. { required: true, message: "是否合格不能为空", trigger: "blur" }
  351. ],
  352. remark: [
  353. { required: false, message: "备注不能为空", trigger: "blur" }
  354. ],
  355. }
  356. };
  357. },
  358. created() {
  359. this.getList();
  360. this.getUsers();
  361. },
  362. methods: {
  363. getUsers(){
  364. listAll().then(res=>{
  365. this.users=res.data
  366. })
  367. },
  368. getUrl(url) {
  369. this.form.picIds = this.$refs.obsImageUpload.fileList?this.$refs.obsImageUpload.fileList.map(e=>e.url):[];
  370. },
  371. getBuildings(id) {
  372. this.units = []
  373. this.houses = []
  374. this.queryParams.buildingId = undefined
  375. this.queryParams.unitId = undefined
  376. this.queryParams.houseId = undefined
  377. getBuildings(id).then(res => {
  378. this.builds = res.data
  379. })
  380. },
  381. // 取消按钮
  382. cancel() {
  383. this.open = false;
  384. this.reset();
  385. this.areas = []
  386. this.houses = []
  387. this.units = []
  388. this.builds = []
  389. },
  390. getUnits(id) {
  391. this.houses = []
  392. this.queryParams.unitId = undefined
  393. this.queryParams.houseId = undefined
  394. getUnits(id).then(res => {
  395. this.units = res.data
  396. })
  397. },
  398. getAreas(district) {
  399. this.builds = []
  400. this.units = []
  401. this.houses = []
  402. this.queryParams.buildingId = undefined
  403. this.queryParams.areaId = undefined
  404. this.queryParams.unitId = undefined
  405. this.queryParams.houseId = undefined
  406. this.form.buildingId = undefined
  407. this.form.unitId = undefined
  408. this.form.areaId = undefined
  409. this.form.houseId = undefined
  410. getAreas(district).then(res => {
  411. this.areas = res.data;
  412. });
  413. },
  414. getHouses() {
  415. this.houses = []
  416. this.queryParams.houseId = undefined
  417. getHouses(this.queryParams.unitId).then(res => {
  418. this.houses = res.data;
  419. });
  420. },
  421. getBuildings1(id) {
  422. this.units = []
  423. this.houses = []
  424. this.form.buildingId = undefined
  425. this.form.unitId = undefined
  426. this.form.houseId = undefined
  427. getBuildings(id).then(res => {
  428. this.builds = res.data
  429. })
  430. },
  431. getUnits1(id) {
  432. this.houses = []
  433. this.form.unitId = undefined
  434. this.form.houseId = undefined
  435. getUnits(id).then(res => {
  436. this.units = res.data
  437. })
  438. },
  439. getHouses1() {
  440. this.houses = []
  441. this.form.houseId = undefined
  442. getHouses(this.form.unitId).then(res => {
  443. this.houses = res.data;
  444. });
  445. },
  446. /** 查询开栓|安检|维修列表 */
  447. getList() {
  448. this.loading = true;
  449. listComprehensive(this.queryParams).then(response => {
  450. this.comprehensiveList = response.rows;
  451. this.total = response.total;
  452. this.loading = false;
  453. });
  454. },
  455. reset() {
  456. this.houses = []
  457. this.units = []
  458. this.areas = []
  459. this.builds = []
  460. this.form = {
  461. id: undefined,
  462. areaId: undefined,
  463. buildingId: undefined,
  464. unitId: undefined,
  465. district: undefined,
  466. houseId: undefined,
  467. type: 3,
  468. isQualified: undefined,
  469. photo: undefined,
  470. remark: undefined,
  471. delFlag: 0,
  472. createBy: undefined,
  473. createTime: undefined,
  474. updateBy: undefined,
  475. picIds: [],
  476. updateTime: undefined
  477. };
  478. this.resetForm("form");
  479. },
  480. /** 搜索按钮操作 */
  481. handleQuery() {
  482. if (this.queryParams.times.length>0){
  483. this.queryParams.constructTime=this.queryParams.times[0]
  484. this.queryParams.constructEndTime=this.queryParams.times[1]
  485. }
  486. this.queryParams.pageNum = 1;
  487. this.getList();
  488. },
  489. /** 重置按钮操作 */
  490. resetQuery() {
  491. this.queryParams= {
  492. pageNum: 1,
  493. pageSize: 10,
  494. times: [],
  495. areaId: undefined,
  496. buildingId: undefined,
  497. constructTime: undefined,
  498. constructEndTime: undefined,
  499. district: undefined,
  500. unitId: undefined,
  501. personBy: undefined,
  502. houseId: undefined,
  503. type: 3,
  504. isQualified: undefined,
  505. }
  506. this.handleQuery();
  507. },
  508. // 多选框选中数据
  509. handleSelectionChange(selection) {
  510. this.ids = selection.map(item => item.id)
  511. this.single = selection.length!==1
  512. this.multiple = !selection.length
  513. },
  514. /** 新增按钮操作 */
  515. handleAdd() {
  516. this.reset();
  517. this.open = true;
  518. this.title = "添加维修";
  519. },
  520. /** 修改按钮操作 */
  521. handleUpdate(row) {
  522. getAreas(row.district).then(res => {
  523. this.areas = res.data
  524. });
  525. getBuildings(row.areaId).then(res => {
  526. this.builds = res.data
  527. });
  528. getUnits(row.buildingId).then(res => {
  529. this.units = res.data
  530. })
  531. getHouses(row.unitId).then(res => {
  532. this.houses = res.data;
  533. });
  534. this.loading = true;
  535. this.reset();
  536. const id = row.id || this.ids
  537. getComprehensive(id).then(response => {
  538. this.loading = false;
  539. this.form = response.data;
  540. response.data.mapList.forEach(a=>a.url=a.picUrl)
  541. this.form.picIds = response.data.mapList;
  542. this.open = true;
  543. this.title = "修改维修";
  544. });
  545. },
  546. /** 提交按钮 */
  547. submitForm() {
  548. this.$refs["form"].validate(valid => {
  549. if (valid) {
  550. this.form.picIds = this.$refs.obsImageUpload.fileList?this.$refs.obsImageUpload.fileList.map(e=>e.url):[];
  551. this.buttonLoading = true;
  552. if (this.form.id != null) {
  553. updateComprehensive(this.form).then(response => {
  554. this.$modal.msgSuccess("修改成功");
  555. this.open = false;
  556. this.getList();
  557. }).finally(() => {
  558. this.buttonLoading = false;
  559. });
  560. } else {
  561. addComprehensive(this.form).then(response => {
  562. this.$modal.msgSuccess("新增成功");
  563. this.open = false;
  564. this.getList();
  565. }).finally(() => {
  566. this.buttonLoading = false;
  567. });
  568. }
  569. }
  570. });
  571. },
  572. /** 删除按钮操作 */
  573. handleDelete(row) {
  574. const ids = row.id || this.ids;
  575. this.$modal.confirm('是否确认删除维修为"' + ids + '"的数据项?').then(() => {
  576. this.loading = true;
  577. return delComprehensive(ids);
  578. }).then(() => {
  579. this.loading = false;
  580. this.getList();
  581. this.$modal.msgSuccess("删除成功");
  582. }).catch(() => {
  583. }).finally(() => {
  584. this.loading = false;
  585. });
  586. },
  587. /** 导出按钮操作 */
  588. handleExport() {
  589. this.download('zdsz/openbolt/export', {
  590. ...this.queryParams
  591. }, `comprehensive_${new Date().getTime()}.xlsx`)
  592. }
  593. }
  594. };
  595. </script>