index.vue 16 KB

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