car.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. <template>
  2. <basic-container>
  3. <avue-crud :option="option"
  4. :table-loading="loading"
  5. :data="data"
  6. :page="page"
  7. :permission="permissionList"
  8. :before-open="beforeOpen"
  9. v-model="form"
  10. ref="crud"
  11. @row-update="rowUpdate"
  12. @row-save="rowSave"
  13. @row-del="rowDel"
  14. @search-change="searchChange"
  15. @search-reset="searchReset"
  16. @selection-change="selectionChange"
  17. @current-change="currentChange"
  18. @size-change="sizeChange"
  19. @refresh-change="refreshChange"
  20. @on-load="onLoad">
  21. <template slot="menuLeft">
  22. <el-button type="danger"
  23. size="small"
  24. icon="el-icon-delete"
  25. plain
  26. v-if="permission.car_delete"
  27. @click="handleDelete">删 除
  28. </el-button>
  29. <cy-excel-import :flag="6" file-name="车辆信息导入模板" @success="onLoad(page)"></cy-excel-import>
  30. </template>
  31. <!-- <template slot="personId" slot-scope="scope">-->
  32. <!--&lt;!&ndash; <el-tag type="primary" @click="personClick(scope.row)">{{scope.row.$personId}}</el-tag>&ndash;&gt;-->
  33. <!-- <el-tag type="primary">{{scope.row.$personId}}</el-tag>-->
  34. <!-- </template>-->
  35. </avue-crud>
  36. <el-dialog title="人员画像" :visible.sync="dialogOpen" :fullscreen="true" :modal-append-to-body="false" center>
  37. <cy-person-file :personId="personId"></cy-person-file>
  38. </el-dialog>
  39. </basic-container>
  40. </template>
  41. <script>
  42. import {getList, getDetail, add, update, remove} from "@/api/estate/car";
  43. // import CyPersonFile from "../../components/file/cy-person-file";
  44. import {mapGetters} from "vuex";
  45. import {validateLicense, validatePhone} from "../../util/validator";
  46. import {getList as getAgencyList} from "@/api/community/agency";
  47. import {getList as getResidentialList} from "@/api/community/residential";
  48. // import CyExcelImport from "../../components/excel/cy-excel-import";
  49. export default {
  50. // components: {
  51. // CyExcelImport,
  52. // CyPersonFile
  53. // },
  54. data() {
  55. return {
  56. form: {},
  57. query: {},
  58. loading: true,
  59. page: {
  60. pageSize: 10,
  61. currentPage: 1,
  62. total: 0
  63. },
  64. selectionList: [],
  65. dialogOpen: false,
  66. personId: '',
  67. option: {
  68. height:'auto',
  69. calcHeight: 30,
  70. tip: false,
  71. searchShow: true,
  72. searchMenuSpan: 6,
  73. border: true,
  74. index: true,
  75. viewBtn: true,
  76. selection: true,
  77. dialogClickModal: false,
  78. column: [
  79. {
  80. label: "车牌号",
  81. prop: "number",
  82. width: 200,
  83. rules: [{
  84. required: true,
  85. message: "请输入车牌号",
  86. },{
  87. validator: validateLicense,
  88. trigger: "blur"
  89. }]
  90. }, {
  91. label: "车辆类型",
  92. prop: "type",
  93. type: "select",
  94. width: 150,
  95. dicUrl: "/api/blade-system/dict-biz/dictionary?code=car-type",
  96. props: {
  97. label: "dictValue",
  98. value: "dictKey",
  99. },
  100. dataType: "number",
  101. rules: [{
  102. required: true,
  103. message: "请输入车辆类型",
  104. trigger: "blur"
  105. }]
  106. },
  107. {
  108. label: "所属社区",
  109. prop: "agencyName",
  110. editDisplay: false,
  111. addDisplay: false,
  112. },
  113. {
  114. label: "所属社区",
  115. prop: "agencyId",
  116. search: true,
  117. searchFilterable: true,
  118. filterable: true,
  119. cascaderItem: ['residentialId'],
  120. type: "select",
  121. // remote: true,
  122. dicUrl: "/api/cyzh-community/agency/list?size=9999",
  123. dicFormatter:(res)=>{
  124. return res.data.records;//返回字典的层级结构
  125. },
  126. props: {
  127. label: "name",
  128. value: "id"
  129. },
  130. rules: [{
  131. required: true,
  132. message: "请选择所属社区",
  133. trigger: "blur"
  134. }],
  135. hide: true,
  136. viewDisplay: false,
  137. },
  138. {
  139. label: "所属小区",
  140. prop: "residentialName",
  141. editDisplay: false,
  142. addDisplay: false
  143. },
  144. {
  145. label: "所属小区",
  146. prop: "residentialId",
  147. type: "select",
  148. search: true,
  149. // dataType:'string',
  150. cascaderItem: ["parkingLotId"],
  151. dicUrl: "/api/cyzh-community/residential/list?agencyId={{key}}",
  152. dicFormatter:(res)=>{
  153. return res.data.records;//返回字典的层级结构
  154. },
  155. // dicFlag: false,
  156. filterable: true,
  157. props: {
  158. label: "name",
  159. value: "id"
  160. },
  161. rules: [{
  162. required: true,
  163. message: "请选择所属小区",
  164. trigger: "blur"
  165. }],
  166. hide: true,
  167. viewDisplay: false,
  168. },
  169. {
  170. label: "所属车场",
  171. prop: "parkingLotId",
  172. type: "select",
  173. search: true,
  174. // overHidden: true,
  175. // remote: true,
  176. dicUrl: "/api/cyzh-estate/parkinglot/list?size=500&residentialId={{key}}",
  177. props: {
  178. label: 'parkName',
  179. value: 'id'
  180. },
  181. dicFormatter: (res) => {
  182. return res.data.records;
  183. },
  184. rules: [{
  185. require: true,
  186. message: "请选择所属车场",
  187. trigger: "blur"
  188. }]
  189. },
  190. {
  191. label: "车主姓名",
  192. prop: "personName",
  193. search: true,
  194. width: 150,
  195. searchSpan: 4,
  196. rules: [{
  197. required: true,
  198. message: "请输入车主姓名",
  199. trigger: "blur"
  200. }]
  201. },
  202. {
  203. label: "车主电话",
  204. prop: "personPhone",
  205. search: true,
  206. width: 200,
  207. searchSpan: 4,
  208. rules: [{
  209. required: true,
  210. message: "请输入车主电话",
  211. },{
  212. validator: validatePhone,
  213. trigger: "blur"
  214. }]
  215. },
  216. {
  217. label: "车辆性质",
  218. prop: "properties",
  219. hide:true,
  220. type: "select",
  221. dicUrl: "/api/blade-system/dict-biz/dictionary?code=car_properties",
  222. props: {
  223. label: "dictValue",
  224. value: "dictKey",
  225. },
  226. dataType: "number",
  227. rules: [{
  228. required: false,
  229. message: "请选择车辆性质",
  230. trigger: "blur"
  231. }]
  232. },
  233. {
  234. label: "车辆型号",
  235. prop: "model",
  236. hide: true,
  237. rules: [{
  238. required: false,
  239. message: "请输入车辆型号",
  240. trigger: "blur"
  241. }]
  242. },
  243. // {
  244. // label: "燃油类别",
  245. // prop: "fuelCategory",
  246. // hide: true,
  247. // type: "select",
  248. // dicUrl: "/api/blade-system/dict-biz/dictionary?code=fuel-category",
  249. // props: {
  250. // label: "dictValue",
  251. // value: "dictKey",
  252. // },
  253. // rules: [{
  254. // required: false,
  255. // message: "请输入燃油类别",
  256. // trigger: "blur"
  257. // }]
  258. // },
  259. {
  260. label: "车身颜色",
  261. prop: "color",
  262. hide: true,
  263. rules: [{
  264. required: false,
  265. message: "请输入车身颜色",
  266. trigger: "blur"
  267. }]
  268. },{
  269. label: "占用车位",
  270. prop: "parkinglot",
  271. type: "select",
  272. hide: true,
  273. dicData:[
  274. {
  275. label:'占用',
  276. value: 1
  277. },{
  278. label:'空闲',
  279. value: 0
  280. }
  281. ],
  282. rules: [{
  283. required: false,
  284. message: "请选择是否占用车位",
  285. trigger: "blur"
  286. }]
  287. },{
  288. label: "车辆照片",
  289. prop: "carImg",
  290. listType: 'picture-img',
  291. type: "upload",
  292. hide: true,
  293. propsHttp: {
  294. res: "data",
  295. url: "link"
  296. },
  297. //加水印
  298. // canvasOption: {
  299. // text: 'bladex',
  300. // ratio: 0.1
  301. // },
  302. action: "/api/blade-resource/oss/endpoint/put-file",
  303. tip: "只能上传jpg/png图片,且不超过500kb"
  304. },
  305. ]
  306. },
  307. data: []
  308. };
  309. },
  310. computed: {
  311. ...mapGetters(["permission"]),
  312. permissionList() {
  313. return {
  314. addBtn: this.vaildData(this.permission.car_add, false),
  315. viewBtn: this.vaildData(this.permission.car_view, false),
  316. delBtn: this.vaildData(this.permission.car_delete, false),
  317. editBtn: this.vaildData(this.permission.car_edit, false)
  318. };
  319. },
  320. ids() {
  321. let ids = [];
  322. this.selectionList.forEach(ele => {
  323. ids.push(ele.id);
  324. });
  325. return ids.join(",");
  326. }
  327. },
  328. watch: {
  329. "form.agencyId"() {
  330. getAgencyList(1, 10, {id: this.form.agencyId}).then(res => {
  331. this.form.agencyName = res.data.data.records[0].name;
  332. })
  333. },
  334. "form.residentialId"() {
  335. getResidentialList(1, 10, {id: this.form.residentialId}).then(res => {
  336. this.form.residentialName = res.data.data.records[0].name;
  337. console.log(JSON.stringify(this.form))
  338. })
  339. },
  340. "form.parkingLotId"() {
  341. console.log(JSON.stringify(this.form))
  342. }
  343. },
  344. mounted() {
  345. let tenantType = localStorage.getItem("tenantType");
  346. const agencyColumn = this.findObject(this.option.column, "agencyId");
  347. const residentialColumn = this.findObject(this.option.column, "residentialId");
  348. const agencyNameColumn = this.findObject(this.option.column, "agencyName");
  349. const residentialNameColumn = this.findObject(this.option.column, "residentialName");
  350. if (tenantType == 1) { //园区
  351. agencyColumn.label = "所属园区";
  352. residentialColumn.label = "所属区域";
  353. agencyNameColumn.label = "所属园区";
  354. residentialNameColumn.label = "所属区域";
  355. } else { //社区
  356. agencyColumn.label = "所属社区";
  357. residentialColumn.label = "所属小区";
  358. agencyNameColumn.label = "所属社区";
  359. residentialNameColumn.label = "所属小区";
  360. }
  361. },
  362. methods: {
  363. personClick(row) {
  364. this.personId = row.personId;
  365. // this.dialogOpen = true;
  366. },
  367. rowSave(row, done, loading) {
  368. add(row).then(() => {
  369. this.onLoad(this.page);
  370. this.$message({
  371. type: "success",
  372. message: "操作成功!"
  373. });
  374. done();
  375. }, error => {
  376. loading();
  377. window.console.log(error);
  378. });
  379. },
  380. rowUpdate(row, index, done, loading) {
  381. update(row).then(() => {
  382. this.onLoad(this.page);
  383. this.$message({
  384. type: "success",
  385. message: "操作成功!"
  386. });
  387. done();
  388. }, error => {
  389. loading();
  390. console.log(error);
  391. });
  392. },
  393. rowDel(row) {
  394. this.$confirm("确定将选择数据删除?", {
  395. confirmButtonText: "确定",
  396. cancelButtonText: "取消",
  397. type: "warning"
  398. })
  399. .then(() => {
  400. return remove(row.id);
  401. })
  402. .then(() => {
  403. this.onLoad(this.page);
  404. this.$message({
  405. type: "success",
  406. message: "操作成功!"
  407. });
  408. });
  409. },
  410. handleDelete() {
  411. if (this.selectionList.length === 0) {
  412. this.$message.warning("请选择至少一条数据");
  413. return;
  414. }
  415. this.$confirm("确定将选择数据删除?", {
  416. confirmButtonText: "确定",
  417. cancelButtonText: "取消",
  418. type: "warning"
  419. })
  420. .then(() => {
  421. return remove(this.ids);
  422. })
  423. .then(() => {
  424. this.onLoad(this.page);
  425. this.$message({
  426. type: "success",
  427. message: "操作成功!"
  428. });
  429. this.$refs.crud.toggleSelection();
  430. });
  431. },
  432. beforeOpen(done, type) {
  433. if (["edit", "view"].includes(type)) {
  434. getDetail(this.form.id).then(res => {
  435. this.form = res.data.data;
  436. });
  437. }
  438. done();
  439. },
  440. searchReset() {
  441. this.query = {};
  442. this.onLoad(this.page);
  443. },
  444. searchChange(params, done) {
  445. this.query = params;
  446. this.page.currentPage = 1;
  447. this.onLoad(this.page, params);
  448. done();
  449. },
  450. selectionChange(list) {
  451. this.selectionList = list;
  452. },
  453. selectionClear() {
  454. this.selectionList = [];
  455. this.$refs.crud.toggleSelection();
  456. },
  457. currentChange(currentPage){
  458. this.page.currentPage = currentPage;
  459. },
  460. sizeChange(pageSize){
  461. this.page.pageSize = pageSize;
  462. },
  463. refreshChange() {
  464. this.onLoad(this.page, this.query);
  465. },
  466. onLoad(page, params = {}) {
  467. this.loading = true;
  468. getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  469. const data = res.data.data;
  470. this.page.total = data.total;
  471. this.data = data.records;
  472. this.loading = false;
  473. this.selectionClear();
  474. });
  475. }
  476. }
  477. };
  478. </script>
  479. <style>
  480. </style>