index.vue 20 KB

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