car.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  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 {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. trigger: "blur"
  87. }]
  88. }, {
  89. label: "车辆类型",
  90. prop: "type",
  91. type: "select",
  92. width: 150,
  93. dicUrl: "/api/blade-system/dict-biz/dictionary?code=car-type",
  94. props: {
  95. label: "dictValue",
  96. value: "dictKey",
  97. },
  98. dataType: "number",
  99. rules: [{
  100. required: true,
  101. message: "请输入车辆类型",
  102. trigger: "blur"
  103. }]
  104. },
  105. {
  106. label: "所属社区",
  107. prop: "agencyName",
  108. editDisplay: false,
  109. addDisplay: false,
  110. },
  111. {
  112. label: "所属社区",
  113. prop: "agencyId",
  114. search: true,
  115. searchFilterable: true,
  116. filterable: true,
  117. cascaderItem: ['residentialId'],
  118. type: "select",
  119. // remote: true,
  120. dicUrl: "/api/cyzh-community/agency/list?size=9999",
  121. dicFormatter:(res)=>{
  122. return res.data.records;//返回字典的层级结构
  123. },
  124. props: {
  125. label: "name",
  126. value: "id"
  127. },
  128. rules: [{
  129. required: true,
  130. message: "请选择所属社区",
  131. trigger: "blur"
  132. }],
  133. hide: true,
  134. viewDisplay: false,
  135. },
  136. {
  137. label: "所属小区",
  138. prop: "residentialName",
  139. editDisplay: false,
  140. addDisplay: false
  141. },
  142. {
  143. label: "所属小区",
  144. prop: "residentialId",
  145. type: "select",
  146. search: true,
  147. // dataType:'string',
  148. cascaderItem: ["parkingLotId"],
  149. dicUrl: "/api/cyzh-community/residential/list?agencyId={{key}}",
  150. dicFormatter:(res)=>{
  151. return res.data.records;//返回字典的层级结构
  152. },
  153. // dicFlag: false,
  154. filterable: true,
  155. props: {
  156. label: "name",
  157. value: "id"
  158. },
  159. rules: [{
  160. required: true,
  161. message: "请选择所属小区",
  162. trigger: "blur"
  163. }],
  164. hide: true,
  165. viewDisplay: false,
  166. },
  167. {
  168. label: "所属车场",
  169. prop: "parkingLotId",
  170. type: "select",
  171. search: true,
  172. overHidden: true,
  173. remote: true,
  174. dicUrl: "/api/cyzh-estate/parkinglot/list?size=500&residentialId={{key}}",
  175. props: {
  176. label: 'parkName',
  177. value: 'id'
  178. },
  179. dicFormatter: (res) => {
  180. return res.data.records;
  181. },
  182. rules: [{
  183. require: true,
  184. message: "请选择所属车场",
  185. trigger: "blur"
  186. }]
  187. },
  188. {
  189. label: "车主姓名",
  190. prop: "personName",
  191. search: true,
  192. width: 150,
  193. searchSpan: 4,
  194. rules: [{
  195. required: true,
  196. message: "请输入车主姓名",
  197. trigger: "blur"
  198. }]
  199. },
  200. {
  201. label: "车主电话",
  202. prop: "personPhone",
  203. search: true,
  204. width: 200,
  205. searchSpan: 4,
  206. rules: [{
  207. required: true,
  208. message: "请输入车主电话",
  209. },{
  210. validator: validatePhone,
  211. trigger: "blur"
  212. }]
  213. },
  214. {
  215. label: "车辆性质",
  216. prop: "properties",
  217. hide:true,
  218. type: "select",
  219. dicUrl: "/api/blade-system/dict-biz/dictionary?code=car_properties",
  220. props: {
  221. label: "dictValue",
  222. value: "dictKey",
  223. },
  224. dataType: "number",
  225. rules: [{
  226. required: false,
  227. message: "请选择车辆性质",
  228. trigger: "blur"
  229. }]
  230. },
  231. {
  232. label: "车辆型号",
  233. prop: "model",
  234. hide: true,
  235. rules: [{
  236. required: false,
  237. message: "请输入车辆型号",
  238. trigger: "blur"
  239. }]
  240. },
  241. {
  242. label: "燃油类别",
  243. prop: "fuelCategory",
  244. hide: true,
  245. type: "select",
  246. dicUrl: "/api/blade-system/dict-biz/dictionary?code=fuel-category",
  247. props: {
  248. label: "dictValue",
  249. value: "dictKey",
  250. },
  251. rules: [{
  252. required: false,
  253. message: "请输入燃油类别",
  254. trigger: "blur"
  255. }]
  256. }, {
  257. label: "车身颜色",
  258. prop: "color",
  259. hide: true,
  260. rules: [{
  261. required: false,
  262. message: "请输入车身颜色",
  263. trigger: "blur"
  264. }]
  265. },{
  266. label: "占用车位",
  267. prop: "parkinglot",
  268. type: "select",
  269. hide: true,
  270. dicData:[
  271. {
  272. label:'占用',
  273. value: 1
  274. },{
  275. label:'空闲',
  276. value: 0
  277. }
  278. ],
  279. rules: [{
  280. required: false,
  281. message: "请选择是否占用车位",
  282. trigger: "blur"
  283. }]
  284. },{
  285. label: "车辆照片",
  286. prop: "carImg",
  287. listType: 'picture-img',
  288. type: "upload",
  289. hide: true,
  290. propsHttp: {
  291. res: "data",
  292. url: "link"
  293. },
  294. //加水印
  295. // canvasOption: {
  296. // text: 'bladex',
  297. // ratio: 0.1
  298. // },
  299. action: "/api/blade-resource/oss/endpoint/put-file",
  300. tip: "只能上传jpg/png图片,且不超过500kb"
  301. },
  302. ]
  303. },
  304. data: []
  305. };
  306. },
  307. computed: {
  308. ...mapGetters(["permission"]),
  309. permissionList() {
  310. return {
  311. addBtn: this.vaildData(this.permission.car_add, false),
  312. viewBtn: this.vaildData(this.permission.car_view, false),
  313. delBtn: this.vaildData(this.permission.car_delete, false),
  314. editBtn: this.vaildData(this.permission.car_edit, false)
  315. };
  316. },
  317. ids() {
  318. let ids = [];
  319. this.selectionList.forEach(ele => {
  320. ids.push(ele.id);
  321. });
  322. return ids.join(",");
  323. }
  324. },
  325. watch: {
  326. "form.agencyId"() {
  327. getAgencyList(1, 10, {id: this.form.agencyId}).then(res => {
  328. this.form.agencyName = res.data.data.records[0].name;
  329. })
  330. },
  331. "form.residentialId"() {
  332. getResidentialList(1, 10, {id: this.form.residentialId}).then(res => {
  333. this.form.residentialName = res.data.data.records[0].name;
  334. console.log(JSON.stringify(this.form))
  335. })
  336. },
  337. "form.parkinglotId"() {
  338. console.log(JSON.stringify(this.form))
  339. }
  340. },
  341. mounted() {
  342. let tenantType = localStorage.getItem("tenantType");
  343. const agencyColumn = this.findObject(this.option.column, "agencyId");
  344. const residentialColumn = this.findObject(this.option.column, "residentialId");
  345. if (tenantType == 1) { //园区
  346. agencyColumn.label = "所属园区";
  347. residentialColumn.label = "所属区域";
  348. } else { //社区
  349. agencyColumn.label = "所属社区";
  350. residentialColumn.label = "所属小区";
  351. }
  352. },
  353. methods: {
  354. personClick(row) {
  355. this.personId = row.personId;
  356. // this.dialogOpen = true;
  357. },
  358. rowSave(row, done, loading) {
  359. add(row).then(() => {
  360. this.onLoad(this.page);
  361. this.$message({
  362. type: "success",
  363. message: "操作成功!"
  364. });
  365. done();
  366. }, error => {
  367. loading();
  368. window.console.log(error);
  369. });
  370. },
  371. rowUpdate(row, index, done, loading) {
  372. update(row).then(() => {
  373. this.onLoad(this.page);
  374. this.$message({
  375. type: "success",
  376. message: "操作成功!"
  377. });
  378. done();
  379. }, error => {
  380. loading();
  381. console.log(error);
  382. });
  383. },
  384. rowDel(row) {
  385. this.$confirm("确定将选择数据删除?", {
  386. confirmButtonText: "确定",
  387. cancelButtonText: "取消",
  388. type: "warning"
  389. })
  390. .then(() => {
  391. return remove(row.id);
  392. })
  393. .then(() => {
  394. this.onLoad(this.page);
  395. this.$message({
  396. type: "success",
  397. message: "操作成功!"
  398. });
  399. });
  400. },
  401. handleDelete() {
  402. if (this.selectionList.length === 0) {
  403. this.$message.warning("请选择至少一条数据");
  404. return;
  405. }
  406. this.$confirm("确定将选择数据删除?", {
  407. confirmButtonText: "确定",
  408. cancelButtonText: "取消",
  409. type: "warning"
  410. })
  411. .then(() => {
  412. return remove(this.ids);
  413. })
  414. .then(() => {
  415. this.onLoad(this.page);
  416. this.$message({
  417. type: "success",
  418. message: "操作成功!"
  419. });
  420. this.$refs.crud.toggleSelection();
  421. });
  422. },
  423. beforeOpen(done, type) {
  424. if (["edit", "view"].includes(type)) {
  425. getDetail(this.form.id).then(res => {
  426. this.form = res.data.data;
  427. });
  428. }
  429. done();
  430. },
  431. searchReset() {
  432. this.query = {};
  433. this.onLoad(this.page);
  434. },
  435. searchChange(params, done) {
  436. this.query = params;
  437. this.page.currentPage = 1;
  438. this.onLoad(this.page, params);
  439. done();
  440. },
  441. selectionChange(list) {
  442. this.selectionList = list;
  443. },
  444. selectionClear() {
  445. this.selectionList = [];
  446. this.$refs.crud.toggleSelection();
  447. },
  448. currentChange(currentPage){
  449. this.page.currentPage = currentPage;
  450. },
  451. sizeChange(pageSize){
  452. this.page.pageSize = pageSize;
  453. },
  454. refreshChange() {
  455. this.onLoad(this.page, this.query);
  456. },
  457. onLoad(page, params = {}) {
  458. this.loading = true;
  459. getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  460. const data = res.data.data;
  461. this.page.total = data.total;
  462. this.data = data.records;
  463. this.loading = false;
  464. this.selectionClear();
  465. });
  466. }
  467. }
  468. };
  469. </script>
  470. <style>
  471. </style>