agency.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. <template>
  2. <basic-container>
  3. <!-- 卡片-->
  4. <!-- <el-container>-->
  5. <!-- <el-main>-->
  6. <!-- <template>-->
  7. <!-- <el-carousel :interval="5000" height="200px">-->
  8. <!-- <el-carousel-item>-->
  9. <!-- <el-container>-->
  10. <!-- <el-header style="background-color: rgb(29,67,58);height: 65px">-->
  11. <!-- <div class="titleLabel">-->
  12. <!-- <el-row :gutter="40">-->
  13. <!-- <div>-->
  14. <!-- <el-col :span="20"><div class="titleText">{{communityCount.agencyCount}}</div></el-col>-->
  15. <!-- <el-col :span="4"><div class="titleCount">{{communityCount.buildingCount}}</div></el-col>-->
  16. <!-- </div>-->
  17. <!-- </el-row>-->
  18. <!-- </div>-->
  19. <!-- </el-header>-->
  20. <!-- <el-main>-->
  21. <!-- <div style="margin-left: 100px">-->
  22. <!-- <avue-data-display :option="dataShow(item)"></avue-data-display>-->
  23. <!-- </div>-->
  24. <!-- </el-main>-->
  25. <!-- </el-container>-->
  26. <!-- </el-carousel-item>-->
  27. <!-- </el-carousel>-->
  28. <!-- </template>-->
  29. <!-- </el-main>-->
  30. <!-- </el-container>-->
  31. <!--卡片数据展示-->
  32. <el-card style="margin-bottom: 20px">
  33. <el-tabs type="border-card">
  34. <el-tab-pane label="社区数据统计">
  35. <div><avue-data-box :option="communityStatistics"></avue-data-box></div>
  36. </el-tab-pane>
  37. </el-tabs>
  38. </el-card>
  39. <avue-crud :option="option" :table-loading="loading" :data="data" :page="page" :permission="permissionList"
  40. :before-open="beforeOpen" v-model="form" ref="crud" @row-update="rowUpdate" @row-save="rowSave" @row-del="rowDel"
  41. @search-change="searchChange" @search-reset="searchReset" @selection-change="selectionChange" @current-change="currentChange"
  42. @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad">
  43. <template slot="menuLeft">
  44. <el-button type="danger" size="small" icon="el-icon-delete" plain v-if="permission.agency_delete" @click="handleDelete">删
  45. </el-button>
  46. <cy-excel-import :flag="1" file-name="社区信息导入模板" @success="onLoad(page)"></cy-excel-import>
  47. </template>
  48. <template slot="mapSelectForm" slot-scope="scope">
  49. <div>
  50. <!-- <input class="el-input&#45;&#45;small el-input__inner" placeholder="选择地址" @click="mapVisible = true">-->
  51. <el-button @click="mapVisible = true"> 选择地址</el-button>
  52. <el-dialog :append-to-body="true" :close-on-click-modal="false" :modal-append-to-body="false" :visible.sync="mapVisible"
  53. title="编辑地址" width="80%">
  54. <editPolygonMap v-if="mapVisible" :editForm.sync="scope.row" :region.sync="scope.row.address" :latitude.sync="scope.row.latitude" :longitude.sync="scope.row.longitude" :visible.sync="mapVisible"></editPolygonMap>
  55. </el-dialog>
  56. </div>
  57. </template>
  58. </avue-crud>
  59. </basic-container>
  60. </template>
  61. <script>
  62. import {
  63. getList,
  64. getDetail,
  65. add,
  66. update,
  67. remove
  68. } from "@/api/community/agency.js";
  69. import {getCommunityList} from "../../api/grid/index";
  70. import {
  71. mapGetters
  72. } from "vuex";
  73. import {
  74. validatePhone
  75. } from "@/util/validator"
  76. import CyExcelImport from "../../components/excel/cy-excel-import"
  77. import editPolygonMap from "../../components/residential/editPolygonMap.vue"
  78. import {getDetail as getRegDetail} from "@/api/base/region"
  79. export default {
  80. components: {CyExcelImport,editPolygonMap},
  81. data() {
  82. return {
  83. communityCount:{},
  84. mapVisible:false,
  85. areaData: [],
  86. form: {},
  87. query: {},
  88. loading: true,
  89. page: {
  90. pageSize: 10,
  91. currentPage: 1,
  92. total: 0
  93. },
  94. //数据展示
  95. communityStatistics:{
  96. span:6,
  97. data: [
  98. {
  99. title: '园区数量',
  100. count: 0,
  101. icon: 'el-icon-office-building',
  102. color: 'rgb(49, 180, 141)',
  103. },
  104. {
  105. title: '区域数量',
  106. count: 0,
  107. icon: 'el-icon-school',
  108. color: 'rgb(56, 161, 242)',
  109. },
  110. {
  111. title: '楼宇数量',
  112. count: 0,
  113. icon: 'el-icon-s-home',
  114. color: 'rgb(117, 56, 199)',
  115. },
  116. {
  117. title: '住户数量',
  118. count: 0,
  119. icon: 'el-icon-user-solid',
  120. color: 'rgb(143,119,0)',
  121. },
  122. ]
  123. },
  124. selectionList: [],
  125. option: {
  126. height: 'auto',
  127. // calcHeight: 60,
  128. tip: false,
  129. searchShow: true,
  130. searchMenuSpan: 6,
  131. border: true,
  132. index: true,
  133. viewBtn: true,
  134. selection: true,
  135. dialogClickModal: false,
  136. menuWidth:350,
  137. column: [{
  138. label: "名称",
  139. prop: "name",
  140. search: true,
  141. width: 160,
  142. overHidden: true,
  143. rules: [{
  144. required: true,
  145. message: "请输入名称",
  146. trigger: "blur"
  147. }]
  148. },
  149. {
  150. label:'',
  151. prop:'mapSelect',
  152. viewDisplay: false,
  153. formslot: true,
  154. hide: true,
  155. },
  156. {
  157. label: "经度",
  158. prop: "longitude",
  159. width: 120,
  160. hide: true,
  161. rules: [{
  162. required: false,
  163. message: "请输入经度",
  164. trigger: "blur"
  165. }]
  166. },
  167. {
  168. label: "纬度",
  169. prop: "latitude",
  170. width: 120,
  171. hide: true,
  172. rules: [{
  173. required: false,
  174. message: "请输入纬度",
  175. trigger: "blur"
  176. }]
  177. },
  178. {
  179. label: "所属省",
  180. prop: "regionProvince",
  181. type: "select",
  182. width: 150,
  183. dicUrl: "/api/blade-system/region/lazy-tree?parentCode=000000",
  184. cascaderItem:["regionCity"],
  185. props:{
  186. label:"title",
  187. value: "id"
  188. },
  189. rules: [{
  190. required: true,
  191. message: "请选择所属省份",
  192. trigger: "blur"
  193. }]
  194. },
  195. {
  196. label: "所属市",
  197. prop: "regionCity",
  198. type: "select",
  199. width: 150,
  200. dicFlag: true,
  201. cascaderItem: ["regionArea"],
  202. dicUrl: `/api/blade-system/region/lazy-tree?parentCode={{key}}`,
  203. props:{
  204. label: "title",
  205. value: "id"
  206. },
  207. rules: [{
  208. required: false,
  209. message: "请选择所属市",
  210. trigger: "blur"
  211. }]
  212. },
  213. {
  214. label: "所属区",
  215. prop: "regionArea",
  216. type: "select",
  217. width: 150,
  218. cascaderItem: ["regionStreet"],
  219. dicUrl: `/api/blade-system/region/lazy-tree?parentCode={{key}}`,
  220. props: {
  221. label: "title",
  222. value: "id"
  223. },
  224. rules: [{
  225. required: false,
  226. message: "请选择所属区",
  227. trigger: "blur"
  228. }]
  229. },
  230. {
  231. label: "所属街道",
  232. prop: "regionStreet",
  233. type:"select",
  234. width: 150,
  235. dicUrl: `/api/blade-system/region/lazy-tree?parentCode={{key}}`,
  236. props: {
  237. label: "title",
  238. value: "id"
  239. },
  240. rules: [{
  241. required: true,
  242. message: "请选择所属街道",
  243. trigger: "blur"
  244. }]
  245. },
  246. {
  247. label: "详细地址",
  248. search: true,
  249. prop: "address",
  250. type: "textarea",
  251. maxRows: 2,
  252. // width: 300,
  253. overHidden: true,
  254. rules: [{
  255. required: false,
  256. message: "请输入详细地址",
  257. trigger: "blur"
  258. }]
  259. },
  260. {
  261. label: "负责人名称",
  262. prop: "personName",
  263. width: 210,
  264. labelWidth: 100,
  265. rules: [{
  266. required: false,
  267. message: "请输入负责人名称",
  268. trigger: "blur"
  269. }]
  270. },
  271. {
  272. label: "联系方式",
  273. prop: "personPhone",
  274. width: 120,
  275. rules: [{
  276. required: false,
  277. message: "请输入负责人联系方式",
  278. trigger: "blur"
  279. }, {
  280. validator: validatePhone,
  281. trigger: "blur"
  282. }],
  283. },
  284. {
  285. label: "背景图",
  286. prop: "pic",
  287. type: 'upload',
  288. hide: true,
  289. propsHttp: {
  290. res: "data",
  291. url: 'link'
  292. },
  293. listType: 'picture-img',
  294. span: 24,
  295. row: true,
  296. action: "/api/blade-resource/oss/endpoint/put-file",
  297. display: true,
  298. tip:"上传图片不能超过500K",
  299. rules: [{
  300. required: false,
  301. message: "请上传封面图片",
  302. trigger: "blur"
  303. }]
  304. },
  305. {
  306. label: "小区数量",
  307. prop: "residentialCount",
  308. display: false,
  309. hide: true,
  310. },
  311. {
  312. label: "楼栋数量",
  313. prop: "buildingCount",
  314. hide: true,
  315. display: false,
  316. },
  317. {
  318. label: "单元数量",
  319. prop: "unitCount",
  320. hide: true,
  321. display: false,
  322. },
  323. {
  324. label: "楼层数量",
  325. prop: "floorCount",
  326. hide: true,
  327. display: false,
  328. },
  329. {
  330. label: "房间数量",
  331. prop: "roomCount",
  332. hide: true,
  333. display: false,
  334. },
  335. {
  336. label: "人员数量",
  337. prop: "personCount",
  338. hide: true,
  339. display: false,
  340. },
  341. {
  342. label: "备注",
  343. prop: "remark",
  344. hide: true,
  345. },
  346. ]
  347. },
  348. data: []
  349. };
  350. },
  351. computed: {
  352. ...mapGetters(["permission"]),
  353. permissionList() {
  354. return {
  355. addBtn: this.vaildData(this.permission.agency_add, false),
  356. viewBtn: this.vaildData(this.permission.agency_view, false),
  357. delBtn: this.vaildData(this.permission.agency_delete, false),
  358. editBtn: this.vaildData(this.permission.agency_edit, false)
  359. };
  360. },
  361. ids() {
  362. let ids = [];
  363. this.selectionList.forEach(ele => {
  364. ids.push(ele.id);
  365. });
  366. return ids.join(",");
  367. },
  368. },
  369. watch: {
  370. 'form.address': {
  371. handler: function(value) {
  372. if (!value){
  373. return
  374. }else{
  375. var _this = this
  376. AMap.plugin('AMap.Geocoder', function() {
  377. var geocoder = new AMap.Geocoder({})
  378. let lnglat = [_this.form.longitude,_this.form.latitude]
  379. geocoder.getAddress(lnglat, function(status, result) {
  380. if (status === 'complete'&&result.regeocode&&result.regeocode.addressComponent.township) {
  381. let parentCode = result.regeocode.addressComponent.adcode
  382. let name = result.regeocode.addressComponent.township
  383. getRegDetail({"name":name,"regionLevel":"4","parentCode":parentCode}).then((res)=>{
  384. let data = res.data.data
  385. let obj = {}
  386. obj['regionProvince'] = data.provinceCode
  387. obj['regionCity'] = data.cityCode
  388. obj['regionArea'] = data.districtCode
  389. obj['regionStreet'] = data.code
  390. _this.form = obj
  391. })
  392. }
  393. })
  394. })
  395. }
  396. },
  397. },
  398. 'form.mapSelect': {
  399. handler: function(value) {
  400. if (!value){
  401. return
  402. }else{
  403. this.form.longitude = this.form.mapSelect.longitude;
  404. this.form.latitude = this.form.mapSelect.latitude;
  405. this.form.address = this.form.mapSelect.formattedAddress;
  406. }
  407. },
  408. }
  409. },
  410. methods: {
  411. rowSave(row, done, loading) {
  412. row.residentialCount = 0;
  413. row.unitCount = 0;
  414. row.roomCount = 0;
  415. row.personCount = 0;
  416. row.carCount = 0;
  417. add(row).then(() => {
  418. this.onLoad(this.page);
  419. this.$message({
  420. type: "success",
  421. message: "操作成功!"
  422. });
  423. done();
  424. }, error => {
  425. loading();
  426. window.console.log(error);
  427. });
  428. },
  429. rowUpdate(row, index, done, loading) {
  430. update(row).then(() => {
  431. this.onLoad(this.page);
  432. this.$message({
  433. type: "success",
  434. message: "操作成功!"
  435. });
  436. done();
  437. }, error => {
  438. loading();
  439. console.log(error);
  440. });
  441. },
  442. rowDel(row) {
  443. this.$confirm("确定将选择数据删除?", {
  444. confirmButtonText: "确定",
  445. cancelButtonText: "取消",
  446. type: "warning"
  447. })
  448. .then(() => {
  449. return remove(row.id);
  450. })
  451. .then(() => {
  452. this.onLoad(this.page);
  453. this.$message({
  454. type: "success",
  455. message: "操作成功!"
  456. });
  457. });
  458. },
  459. handleDelete() {
  460. if (this.selectionList.length === 0) {
  461. this.$message.warning("请选择至少一条数据");
  462. return;
  463. }
  464. this.$confirm("确定将选择数据删除?", {
  465. confirmButtonText: "确定",
  466. cancelButtonText: "取消",
  467. type: "warning"
  468. })
  469. .then(() => {
  470. return remove(this.ids);
  471. })
  472. .then(() => {
  473. this.onLoad(this.page);
  474. this.$message({
  475. type: "success",
  476. message: "操作成功!"
  477. });
  478. this.$refs.crud.toggleSelection();
  479. });
  480. },
  481. beforeOpen(done, type) {
  482. if (["edit", "view"].includes(type)) {
  483. getDetail(this.form.id).then(res => {
  484. this.form = res.data.data;
  485. });
  486. }
  487. done();
  488. },
  489. searchReset() {
  490. this.query = {};
  491. this.onLoad(this.page);
  492. },
  493. searchChange(params, done) {
  494. this.query = params;
  495. this.page.currentPage = 1;
  496. this.onLoad(this.page, params);
  497. done();
  498. },
  499. selectionChange(list) {
  500. this.selectionList = list;
  501. },
  502. selectionClear() {
  503. this.selectionList = [];
  504. this.$refs.crud.toggleSelection();
  505. },
  506. currentChange(currentPage) {
  507. this.page.currentPage = currentPage;
  508. },
  509. sizeChange(pageSize) {
  510. this.page.pageSize = pageSize;
  511. },
  512. refreshChange() {
  513. this.onLoad(this.page, this.query);
  514. },
  515. onLoad(page, params = {}) {
  516. getCommunityList('/640000').then(res=>{
  517. this.communityCount = res.data.data;
  518. console.log(this.communityCount,"打印communityCount");
  519. this.communityStatistics.data[0].count = this.communityCount.agencyCount;
  520. this.communityStatistics.data[1].count = this.communityCount.residentialCount;
  521. this.communityStatistics.data[2].count = this.communityCount.buildingCount;
  522. this.communityStatistics.data[3].count = this.communityCount.userCount;
  523. });
  524. this.loading = true;
  525. getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  526. const data = res.data.data;
  527. this.page.total = data.total;
  528. this.data = data.records;
  529. this.loading = false;
  530. this.selectionClear();
  531. });
  532. }
  533. }
  534. };
  535. </script>
  536. <style>
  537. </style>