index.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="小区名" prop="name">
  5. <el-input
  6. v-model="queryParams.name"
  7. placeholder="请输入小区名"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="负责工长" prop="userId">
  14. <el-select v-model="queryParams.userId" filterable placeholder="请选择负责工长" clearable size="small">
  15. <el-option v-for="item in workerList"
  16. :key="item.id"
  17. :label="item.name"
  18. :value="item.id"/>
  19. </el-select>
  20. </el-form-item>
  21. <el-form-item label="行政区" prop="district">
  22. <el-select v-model="queryParams.district" placeholder="请选择行政区" clearable size="small">
  23. <el-option
  24. v-for="dict in dict.type.district"
  25. :key="dict.value"
  26. :label="dict.label"
  27. :value="dict.value"
  28. />
  29. </el-select>
  30. </el-form-item>
  31. <el-form-item>
  32. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  33. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  34. </el-form-item>
  35. </el-form>
  36. <el-row :gutter="10" class="mb8">
  37. <el-col :span="1.5">
  38. <el-button
  39. type="primary"
  40. plain
  41. icon="el-icon-plus"
  42. size="mini"
  43. @click="handleAdd"
  44. v-hasPermi="['gas:area:add']"
  45. >新增
  46. </el-button>
  47. </el-col>
  48. <el-col :span="1.5">
  49. <el-button
  50. type="success"
  51. plain
  52. icon="el-icon-edit"
  53. size="mini"
  54. :disabled="single"
  55. @click="handleUpdate"
  56. v-hasPermi="['gas:area:edit']"
  57. >修改
  58. </el-button>
  59. </el-col>
  60. <el-col :span="1.5">
  61. <el-button
  62. type="danger"
  63. plain
  64. icon="el-icon-delete"
  65. size="mini"
  66. :disabled="multiple"
  67. @click="handleDelete"
  68. v-hasPermi="['gas:area:remove']"
  69. >删除
  70. </el-button>
  71. </el-col>
  72. <el-col :span="1.5">
  73. <el-button
  74. type="info"
  75. plain
  76. icon="el-icon-upload2"
  77. size="mini"
  78. @click="handleImport"
  79. v-hasPermi="['system:user:import']"
  80. >导入小区
  81. </el-button>
  82. </el-col>
  83. <el-col :span="1.5">
  84. <el-button
  85. type="warning"
  86. plain
  87. icon="el-icon-download"
  88. size="mini"
  89. :loading="exportLoading"
  90. @click="handleExport"
  91. v-hasPermi="['gas:area:export']"
  92. >导出
  93. </el-button>
  94. </el-col>
  95. <!-- <el-col :span="1.5">-->
  96. <!-- <el-button-->
  97. <!-- type="success"-->
  98. <!-- plain-->
  99. <!-- icon="el-icon-download"-->
  100. <!-- size="mini"-->
  101. <!-- :loading="exportLoading"-->
  102. <!-- @click="handleInstall"-->
  103. <!-- v-hasPermi="['gas:courtyardNetworkManagement:export']"-->
  104. <!-- >下载-->
  105. <!-- </el-button>-->
  106. <!-- </el-col>-->
  107. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  108. </el-row>
  109. <el-table v-loading="loading" :data="areaList" @selection-change="handleSelectionChange">
  110. <el-table-column type="selection" width="55" align="center"/>
  111. <el-table-column label="主键id" align="center" prop="id" v-if="false"/>
  112. <el-table-column label="序列" width="70">
  113. <template slot-scope="scope">
  114. {{(queryParams.pageNum-1)*queryParams.pageSize+scope.$index+1}}
  115. </template>
  116. </el-table-column>
  117. <el-table-column label="小区名" align="center" prop="name"/>
  118. <el-table-column label="负责工长" align="center" prop="userName">
  119. <!-- <template slot-scope="scope">-->
  120. <!-- {{ getUserName(scope.row.userId) }}-->
  121. <!-- </template>-->
  122. </el-table-column>
  123. <!-- <el-table-column label="是否释放" align="center" prop="releaseIs">-->
  124. <!-- <template slot-scope="scope">-->
  125. <!-- <dict-tag :options="dict.type.release_status" :value="scope.row.releaseIs"/>-->
  126. <!-- </template>-->
  127. <!-- </el-table-column>-->
  128. <!-- <el-table-column label="释放人" align="center" prop="releaseBy"/>-->
  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>
  134. <el-table-column label="小区规模" align="center" prop="areaSize"/>
  135. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  136. <template slot-scope="scope">
  137. <el-button
  138. size="mini"
  139. type="text"
  140. icon="el-icon-edit"
  141. @click="handleUpdate(scope.row)"
  142. v-hasPermi="['gas:area:edit']"
  143. >修改
  144. </el-button>
  145. <!-- <el-button-->
  146. <!-- size="mini"-->
  147. <!-- type="text"-->
  148. <!-- icon="el-icon-edit"-->
  149. <!-- @click="handleRelease(scope.row)"-->
  150. <!-- v-hasPermi="['gas:area:edit']"-->
  151. <!-- >释放-->
  152. <!-- </el-button>-->
  153. <el-button
  154. size="mini"
  155. type="text"
  156. icon="el-icon-delete"
  157. @click="handleDelete(scope.row)"
  158. v-hasPermi="['gas:area:remove']"
  159. >删除
  160. </el-button>
  161. <el-button
  162. type="text"
  163. size="mini"
  164. icon="el-icon-download"
  165. :loading="exportLoading"
  166. @click="handleInstall(scope.row)"
  167. v-hasPermi="['gas:courtyardNetworkManagement:export']"
  168. >下载
  169. </el-button>
  170. </template>
  171. </el-table-column>
  172. </el-table>
  173. <pagination
  174. v-show="total>0"
  175. :total="total"
  176. :page.sync="queryParams.pageNum"
  177. :limit.sync="queryParams.pageSize"
  178. @pagination="getList"
  179. />
  180. <!-- 用户导入对话框 -->
  181. <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  182. <el-upload
  183. ref="upload"
  184. :limit="1"
  185. accept=".xlsx, .xls"
  186. :headers="upload.headers"
  187. :action="upload.url + '?updateSupport=' + upload.updateSupport"
  188. :disabled="upload.isUploading"
  189. :on-progress="handleFileUploadProgress"
  190. :on-success="handleFileSuccess"
  191. :auto-upload="false"
  192. drag
  193. >
  194. <i class="el-icon-upload"></i>
  195. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  196. <div class="el-upload__tip text-center" slot="tip">
  197. <!--<div class="el-upload__tip" slot="tip">-->
  198. <!--<el-checkbox v-model="upload.updateSupport"/>-->
  199. <!--是否更新已经存在的用户数据-->
  200. <!--</div>-->
  201. <span>仅允许导入xls、xlsx格式文件。</span>
  202. <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;"
  203. @click="importTemplate"
  204. >下载模板
  205. </el-link>
  206. </div>
  207. </el-upload>
  208. <div style="padding-top: 15px;line-height: 25px;font-size: 14px;">
  209. 完成度:{{ bfb }}%
  210. <progress max="100" :value="bfb" style="width: 200px;height: 18px;"></progress>
  211. <br>
  212. 导入结果:{{ jdtMsg }}
  213. </div>
  214. <div slot="footer" class="dialog-footer">
  215. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  216. <el-button @click="upload.open = false;bfb='0';jdtMsg=''">取 消</el-button>
  217. </div>
  218. </el-dialog>
  219. <!-- 添加或修改小区对话框 -->
  220. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  221. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  222. <el-form-item label="小区名" prop="name">
  223. <el-input v-model="form.name" placeholder="请输入小区名"/>
  224. </el-form-item>
  225. <el-form-item label="负责工长" prop="userIds">
  226. <el-select v-model="userIds" multiple filterable placeholder="请选择负责工长" style="width: 100%">
  227. <el-option v-for="(item,index) in workerList"
  228. :key="index"
  229. :label="item.name"
  230. :value="item.id"/>
  231. </el-select>
  232. </el-form-item>
  233. <el-form-item label="行政区" prop="district">
  234. <el-select v-model="form.district" placeholder="请选择行政区" style="width: 100%">
  235. <el-option
  236. v-for="dict in dict.type.district"
  237. :key="dict.value"
  238. :label="dict.label"
  239. :value="dict.value"
  240. ></el-option>
  241. </el-select>
  242. </el-form-item>
  243. <el-form-item label="小区规模" prop="areaSize">
  244. <el-input-number v-model="form.areaSize" :min="1" label="请输入小区规模" style="width: 100%"/>
  245. </el-form-item>
  246. <el-form-item label="照片" prop="photoList">
  247. <imageUpload v-model="form.photoList"/>
  248. </el-form-item>
  249. </el-form>
  250. <div slot="footer" class="dialog-footer">
  251. <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
  252. <el-button @click="cancel">取 消</el-button>
  253. </div>
  254. </el-dialog>
  255. </div>
  256. </template>
  257. <script>
  258. import {
  259. listArea,
  260. getArea,
  261. delArea,
  262. addArea,
  263. updateArea,
  264. releaseIs,
  265. flushProgress,
  266. clearFlushProgress
  267. } from "@/api/gas/area";
  268. import {getWorker} from "@/api/gas/user";
  269. import el from "element-ui/src/locale/lang/el";
  270. import {getToken} from "@/utils/auth";
  271. export default {
  272. name: "Area",
  273. dicts: ['release_status', 'district', 'district','install_type'],
  274. data() {
  275. return {
  276. //进度条
  277. timeInterval: null,
  278. bfb: '0',
  279. jdtMsg: '',
  280. // 用户导入参数
  281. upload: {
  282. // 是否显示弹出层(用户导入)
  283. open: false,
  284. // 弹出层标题(用户导入)
  285. title: '',
  286. // 是否禁用上传
  287. isUploading: false,
  288. // 是否更新已经存在的用户数据
  289. updateSupport: 0,
  290. // 设置上传的请求头部
  291. headers: { Authorization: 'Bearer ' + getToken() },
  292. // 上传的地址
  293. url: process.env.VUE_APP_BASE_API + '/gas/area/importData'
  294. },
  295. // 按钮loading
  296. buttonLoading: false,
  297. // 遮罩层
  298. loading: true,
  299. // 导出遮罩层
  300. exportLoading: false,
  301. // 选中数组
  302. ids: [],
  303. userIds: [],
  304. // 非单个禁用
  305. single: true,
  306. // 非多个禁用
  307. multiple: true,
  308. // 显示搜索条件
  309. showSearch: true,
  310. // 总条数
  311. total: 0,
  312. // 小区表格数据
  313. areaList: [],
  314. // 弹出层标题
  315. title: "",
  316. // 是否显示弹出层
  317. open: false,
  318. // 查询参数
  319. queryParams: {
  320. pageNum: 1,
  321. pageSize: 10,
  322. name: undefined,
  323. userId: undefined,
  324. district: undefined,
  325. },
  326. // 表单参数
  327. form: {},
  328. // 表单校验
  329. rules: {
  330. name: [
  331. {required: true, message: "小区名不能为空", trigger: "blur"}
  332. ],
  333. userIds: [
  334. {required: false, message: "负责工长不能为空", trigger: "change"}
  335. ],
  336. releaseIs: [
  337. {required: true, message: "是否释放不能为空", trigger: "change"}
  338. ],
  339. district: [
  340. {required: true, message: "行政区不能为空", trigger: "change"}
  341. ],
  342. },
  343. workerList: [],
  344. installList:[],
  345. value:'庭院网管'
  346. };
  347. },
  348. created() {
  349. this.getWorkerList();
  350. this.getList();
  351. this.getdictList();
  352. },
  353. methods: {
  354. // 文件上传中处理
  355. handleFileUploadProgress(event, file, fileList) {
  356. this.upload.isUploading = true
  357. },
  358. // 文件上传成功处理
  359. handleFileSuccess(response, file, fileList) {
  360. this.upload.isUploading = false
  361. this.$refs.upload.clearFiles()
  362. this.getList()
  363. },
  364. /** 下载模板操作 */
  365. importTemplate() {
  366. this.$download.excel('/gas/area/importTemplate')
  367. },
  368. // 提交上传文件
  369. submitFileForm() {
  370. const ther = this
  371. this.timeInterval = setInterval(function() {
  372. ther.flushProgress()
  373. }, 1500)
  374. this.$refs.upload.submit()
  375. },
  376. // 提交上传文件
  377. flushProgress() {
  378. flushProgress().then(response => {
  379. this.bfb = parseInt(response.data.bfb) >= 100 ? 100 : response.data.bfb
  380. this.jdtMsg = response.data.message
  381. if (response.data.message != null && response.data.message != '') {
  382. clearFlushProgress().then(response => {
  383. })
  384. clearInterval(this.timeInterval)
  385. }
  386. })
  387. },
  388. /** 导入按钮操作 */
  389. handleImport() {
  390. this.upload.title = '用户导入'
  391. this.upload.open = true
  392. },
  393. //释放
  394. handleRelease(row) {
  395. this.$modal.confirm('请确认照片是否下载!释放过程不可逆!是否释放?').then(() => {
  396. this.loading = true
  397. return releaseIs(row.id)
  398. }).then(() => {
  399. this.loading = false
  400. this.getList()
  401. this.getArea()
  402. this.$modal.msgSuccess('释放成功')
  403. }).finally(() => {
  404. this.loading = false
  405. })
  406. },
  407. getUserName(userId) {
  408. let name = ''
  409. if (userId == undefined || userId == null || userId == '') {
  410. return ''
  411. }
  412. for (let i = 0; i < userId.split(",").length; i++) {
  413. if (i === 0) name = this.workerList.filter(item => item.id == userId.split(",")[i])[0].name
  414. else name = name + "," + this.workerList.filter(item => item.id == userId.split(",")[i])[0].name
  415. }
  416. return name
  417. },
  418. getWorkerList(ranks) {
  419. let data = null
  420. if(ranks){
  421. data = {
  422. ranks:ranks
  423. }
  424. }
  425. getWorker(data).then(req => {
  426. this.workerList = req.data
  427. })
  428. },
  429. /** 查询小区列表 */
  430. getList() {
  431. this.loading = true;
  432. if (this.queryParams.userId == '') {
  433. this.queryParams.userId = undefined
  434. }
  435. if (this.queryParams.userId != undefined)
  436. this.queryParams.userId = this.queryParams.userId + ""
  437. listArea(this.queryParams).then(response => {
  438. this.areaList = []
  439. this.areaList = response.rows;
  440. this.total = response.total;
  441. this.loading = false;
  442. });
  443. if (this.queryParams.userId != undefined)
  444. this.queryParams.userId = this.queryParams.userId * 1
  445. },
  446. // 取消按钮
  447. cancel() {
  448. this.open = false;
  449. this.reset();
  450. },
  451. // 表单重置
  452. reset() {
  453. this.userIds = []
  454. this.form = {
  455. id: undefined,
  456. name: undefined,
  457. userId: undefined,
  458. userIds: [],
  459. releaseIs: undefined,
  460. releaseBy: undefined,
  461. district: undefined,
  462. calculateDistrictId: undefined,
  463. areaSize: 1,
  464. affiliatedPackage: undefined,
  465. delFlag: undefined,
  466. createBy: undefined,
  467. createTime: undefined,
  468. updateBy: undefined,
  469. updateTime: undefined,
  470. photoList: ""
  471. };
  472. this.resetForm("form");
  473. },
  474. getdictList() {
  475. this.getDicts("install_type").then(response => {
  476. this.installList = response.data;
  477. console.log(this.installList)
  478. });
  479. },
  480. /** 搜索按钮操作 */
  481. handleQuery() {
  482. this.queryParams.pageNum = 1;
  483. this.getList();
  484. },
  485. /** 重置按钮操作 */
  486. resetQuery() {
  487. this.resetForm("queryForm");
  488. this.handleQuery();
  489. },
  490. // 多选框选中数据
  491. handleSelectionChange(selection) {
  492. this.ids = selection.map(item => item.id)
  493. this.single = selection.length !== 1
  494. this.multiple = !selection.length
  495. },
  496. /** 新增按钮操作 */
  497. handleAdd() {
  498. this.reset();
  499. this.open = true;
  500. this.title = "添加小区";
  501. },
  502. /** 修改按钮操作 */
  503. handleUpdate(row) {
  504. this.loading = true;
  505. this.reset();
  506. const id = row.id || this.ids
  507. getArea(id).then(response => {
  508. this.loading = false;
  509. this.form = response.data;
  510. this.userIds = response.data.userId == '' || response.data.userId == null ? [] : response.data.userId.split(",").map(Number);
  511. this.form.userId = response.data.userId;
  512. this.open = true;
  513. this.title = "修改小区";
  514. });
  515. },
  516. /** 提交按钮 */
  517. submitForm() {
  518. this.$refs["form"].validate(valid => {
  519. if (valid) {
  520. this.buttonLoading = true;
  521. this.form.userId = this.userIds.join(",")
  522. if (this.form.releaseIs === 'Y') {
  523. this.form.releaseBy = this.$store.state.user.userId
  524. }
  525. if (this.form.id != null) {
  526. if (typeof this.form.photoList === 'string') {
  527. this.form.photoList = this.form.photoList.split(',')
  528. }
  529. updateArea(this.form).then(response => {
  530. this.$modal.msgSuccess("修改成功");
  531. this.open = false;
  532. this.getList();
  533. }).finally(() => {
  534. this.buttonLoading = false;
  535. });
  536. } else {
  537. this.form.photoList = this.form.photoList.split(',')
  538. addArea(this.form).then(response => {
  539. this.$modal.msgSuccess("新增成功");
  540. this.open = false;
  541. this.getList();
  542. }).finally(() => {
  543. this.buttonLoading = false;
  544. });
  545. }
  546. }
  547. });
  548. },
  549. /** 删除按钮操作 */
  550. handleDelete(row) {
  551. const ids = row.id || this.ids;
  552. this.$modal.confirm('是否确认删除小区编号为"' + ids + '"的数据项?').then(() => {
  553. this.loading = true;
  554. return delArea(ids);
  555. }).then(() => {
  556. this.loading = false;
  557. this.getList();
  558. this.$modal.msgSuccess("删除成功");
  559. }).finally(() => {
  560. this.loading = false;
  561. });
  562. },
  563. /** 导出按钮操作 */
  564. handleExport() {
  565. this.$download.excel('/gas/area/export', this.queryParams);
  566. },
  567. handleInstall(data) {
  568. const h = this.$createElement;
  569. const that = this
  570. this.$msgbox({
  571. title: '消息',
  572. message: h('p', null, [
  573. h('span', null, '选择下载类型 '),
  574. h('el-select', {
  575. props: {
  576. value: that.value,
  577. filterable: true,
  578. },
  579. ref: 'selectView',
  580. on: {
  581. change:e => {
  582. that.value = e
  583. that.$refs.selectView.value = e // select下拉框值改变,回显到页面上
  584. },
  585. },
  586. },
  587. [
  588. that.installList.map(it => {
  589. return h('el-option', {
  590. props: {
  591. label: it.dictLabel,
  592. key: it.dictLabel,
  593. value: it.dictLabel,
  594. },
  595. });
  596. })
  597. ]
  598. )
  599. ]),
  600. showCancelButton: true,
  601. confirmButtonText: '确定',
  602. cancelButtonText: '取消',
  603. beforeClose: (action, instance, done) => {
  604. console.log(this.value)
  605. let obj=that.installList.filter(item=>item.dictLabel==this.value)
  606. console.log(obj)
  607. if (action === 'confirm') {
  608. instance.confirmButtonLoading = true;
  609. instance.confirmButtonText = '执行中...';
  610. this.$download.zip(`/gas/courtyardNetworkManagement/install?id=${data.id}&findProblem=${this.value}&remarks=${obj[0].dictValue}`, data.name+this.value);
  611. setTimeout(() => {
  612. done();
  613. setTimeout(() => {
  614. instance.confirmButtonLoading = false;
  615. }, 300);
  616. }, 3000);
  617. } else {
  618. done();
  619. }
  620. }
  621. }).then(action => {
  622. });
  623. }
  624. }
  625. };
  626. </script>