index.vue 18 KB

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