index.vue 21 KB

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