index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  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="picIds">
  204. <ObsImageUpload ref="obsImageUpload" :limit="9999" :fileType="['png', 'jpg', 'jpeg']" :value="form.picIds"
  205. @input="getUrl"></ObsImageUpload>
  206. </el-form-item>
  207. <el-form-item label="备注" prop="remark">
  208. <el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/>
  209. </el-form-item>
  210. </el-form>
  211. <div slot="footer" class="dialog-footer">
  212. <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
  213. <el-button @click="cancel">取 消</el-button>
  214. </div>
  215. </el-dialog>
  216. </div>
  217. </template>
  218. <script>
  219. import { listComprehensive, getComprehensive, delComprehensive, addComprehensive, updateComprehensive } from "@/api/zdsz/comprehensive";
  220. import {getBuildings} from "@/api/zdsz/building";
  221. import {getUnits} from "@/api/zdsz/unit";
  222. import {getAreas} from "@/api/zdsz/area";
  223. import {getHouses, listHouse} from "@/api/zdsz/house";
  224. export default {
  225. name: "openrepair",
  226. dicts:['pass_check','is_repair'],
  227. data() {
  228. return {
  229. // 按钮loading
  230. buttonLoading: false,
  231. // 遮罩层
  232. loading: true,
  233. // 选中数组
  234. ids: [],
  235. // 非单个禁用
  236. single: true,
  237. // 非多个禁用
  238. multiple: true,
  239. // 显示搜索条件
  240. showSearch: true,
  241. // 总条数
  242. total: 0,
  243. // 开栓|安检|维修表格数据
  244. comprehensiveList: [],
  245. // 弹出层标题
  246. title: "",
  247. // 是否显示弹出层
  248. open: false,
  249. // 查询参数
  250. queryParams: {
  251. pageNum: 1,
  252. pageSize: 10,
  253. areaId: undefined,
  254. buildingId: undefined,
  255. unitId: undefined,
  256. houseId: undefined,
  257. type: 3,
  258. isQualified: undefined,
  259. isMaintenance: undefined,
  260. },
  261. // 表单参数
  262. form: {},
  263. areas: [],
  264. builds: [],
  265. units: [],
  266. rooms: [],
  267. houses: [],
  268. // 表单校验
  269. rules: {
  270. areaId: [
  271. { required: true, message: "小区不能为空", trigger: "change" }
  272. ],
  273. buildingId: [
  274. { required: true, message: "楼栋不能为空", trigger: "change" }
  275. ],
  276. unitId: [
  277. { required: true, message: "单元不能为空", trigger: "change" }
  278. ],
  279. houseId: [
  280. { required: true, message: "房间不能为空", trigger: "change" }
  281. ],
  282. type: [
  283. { required: false, message: "类型不能为空", trigger: "change" }
  284. ],
  285. isQualified: [
  286. { required: true, message: "安检是否合格不能为空", trigger: "blur" }
  287. ],
  288. isMaintenance: [
  289. { required: true, message: "是否维修不能为空", trigger: "blur" }
  290. ],
  291. remark: [
  292. { required: false, message: "备注不能为空", trigger: "blur" }
  293. ],
  294. }
  295. };
  296. },
  297. created() {
  298. this.getList();
  299. this.getAreas();
  300. },
  301. methods: {
  302. getUrl(url) {
  303. this.form.picIds = this.$refs.obsImageUpload.fileList?this.$refs.obsImageUpload.fileList.map(e=>e.url):[];
  304. },
  305. getBuildings(id) {
  306. this.units = []
  307. this.houses = []
  308. this.queryParams.buildingId = undefined
  309. this.queryParams.unitId = undefined
  310. this.queryParams.houseId = undefined
  311. getBuildings(id).then(res => {
  312. this.builds = res.data
  313. })
  314. },
  315. getUnits(id) {
  316. this.houses = []
  317. this.queryParams.unitId = undefined
  318. this.queryParams.houseId = undefined
  319. getUnits(this.queryParams.areaId,id).then(res => {
  320. this.units = res.data
  321. })
  322. },
  323. getAreas() {
  324. this.builds = []
  325. this.units = []
  326. this.houses = []
  327. this.queryParams.buildingId = undefined
  328. this.queryParams.unitId = undefined
  329. this.queryParams.houseId = undefined
  330. this.form.buildingId = undefined
  331. this.form.unitId = undefined
  332. this.form.houseId = undefined
  333. getAreas().then(res => {
  334. this.areas = res.data;
  335. });
  336. },
  337. getHouses() {
  338. this.houses = []
  339. this.queryParams.houseId = undefined
  340. getHouses(this.queryParams.unitId).then(res => {
  341. this.houses = res.data;
  342. });
  343. },
  344. getBuildings1(id) {
  345. this.units = []
  346. this.houses = []
  347. this.form.buildingId = undefined
  348. this.form.unitId = undefined
  349. this.form.houseId = undefined
  350. getBuildings(id).then(res => {
  351. this.builds = res.data
  352. })
  353. },
  354. getUnits1(id) {
  355. this.houses = []
  356. this.form.unitId = undefined
  357. this.form.houseId = undefined
  358. getUnits(this.form.areaId,id).then(res => {
  359. this.units = res.data
  360. })
  361. },
  362. getHouses1() {
  363. this.houses = []
  364. this.form.houseId = undefined
  365. getHouses(this.form.unitId).then(res => {
  366. this.houses = res.data;
  367. });
  368. },
  369. /** 查询开栓|安检|维修列表 */
  370. getList() {
  371. this.loading = true;
  372. listComprehensive(this.queryParams).then(response => {
  373. this.comprehensiveList = response.rows;
  374. this.total = response.total;
  375. this.loading = false;
  376. });
  377. },
  378. // 取消按钮
  379. cancel() {
  380. this.open = false;
  381. this.reset();
  382. this.houses = []
  383. this.units = []
  384. this.builds = []
  385. },
  386. // 表单重置
  387. reset() {
  388. this.form = {
  389. id: undefined,
  390. areaId: undefined,
  391. buildingId: undefined,
  392. unitId: undefined,
  393. houseId: undefined,
  394. type: 3,
  395. isQualified: undefined,
  396. isMaintenance: undefined,
  397. remark: undefined,
  398. delFlag: 0,
  399. picIds: [],
  400. createBy: undefined,
  401. createTime: undefined,
  402. updateBy: undefined,
  403. updateTime: undefined
  404. };
  405. this.resetForm("form");
  406. },
  407. /** 搜索按钮操作 */
  408. handleQuery() {
  409. this.queryParams.pageNum = 1;
  410. this.getList();
  411. },
  412. /** 重置按钮操作 */
  413. resetQuery() {
  414. this.resetForm("queryForm");
  415. this.handleQuery();
  416. },
  417. // 多选框选中数据
  418. handleSelectionChange(selection) {
  419. this.ids = selection.map(item => item.id)
  420. this.single = selection.length!==1
  421. this.multiple = !selection.length
  422. },
  423. /** 新增按钮操作 */
  424. handleAdd() {
  425. this.reset();
  426. this.open = true;
  427. this.title = "添加维修";
  428. },
  429. /** 修改按钮操作 */
  430. handleUpdate(row) {
  431. getBuildings(row.areaId).then(res => {
  432. this.builds = res.data
  433. });
  434. getUnits(row.areaId,row.buildingId).then(res => {
  435. this.units = res.data
  436. })
  437. getHouses(row.unitId).then(res => {
  438. this.houses = res.data;
  439. });
  440. this.loading = true;
  441. this.reset();
  442. const id = row.id || this.ids
  443. getComprehensive(id).then(response => {
  444. this.loading = false;
  445. this.form = response.data;
  446. this.form.picIds = response.data.mapList;
  447. this.open = true;
  448. this.title = "修改维修";
  449. });
  450. },
  451. /** 提交按钮 */
  452. submitForm() {
  453. this.$refs["form"].validate(valid => {
  454. if (valid) {
  455. this.form.picIds = this.$refs.obsImageUpload.fileList?this.$refs.obsImageUpload.fileList.map(e=>e.url):[];
  456. this.buttonLoading = true;
  457. if (this.form.id != null) {
  458. updateComprehensive(this.form).then(response => {
  459. this.$modal.msgSuccess("修改成功");
  460. this.open = false;
  461. this.getList();
  462. }).finally(() => {
  463. this.buttonLoading = false;
  464. });
  465. } else {
  466. addComprehensive(this.form).then(response => {
  467. this.$modal.msgSuccess("新增成功");
  468. this.open = false;
  469. this.getList();
  470. }).finally(() => {
  471. this.buttonLoading = false;
  472. });
  473. }
  474. }
  475. });
  476. },
  477. /** 删除按钮操作 */
  478. handleDelete(row) {
  479. const ids = row.id || this.ids;
  480. this.$modal.confirm('是否确认删除维修为"' + ids + '"的数据项?').then(() => {
  481. this.loading = true;
  482. return delComprehensive(ids);
  483. }).then(() => {
  484. this.loading = false;
  485. this.getList();
  486. this.$modal.msgSuccess("删除成功");
  487. }).catch(() => {
  488. }).finally(() => {
  489. this.loading = false;
  490. });
  491. },
  492. /** 导出按钮操作 */
  493. handleExport() {
  494. this.download('zdsz/openbolt/export', {
  495. ...this.queryParams
  496. }, `comprehensive_${new Date().getTime()}.xlsx`)
  497. }
  498. }
  499. };
  500. </script>