guestrecordmng.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. <template>
  2. <basic-container>
  3. <avue-crud :option="option"
  4. :table-loading="loading"
  5. :data="data"
  6. :page.sync="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.guestrecord_delete"
  27. @click="handleDelete">删 除
  28. </el-button>
  29. </template>
  30. <template slot="auditStatus" slot-scope="scope">
  31. <el-tag v-if="scope.row.auditStatus===0" type="info">待审核</el-tag>
  32. <el-tag v-if="scope.row.auditStatus===1" type="success">审核通过</el-tag>
  33. <el-tag v-if="scope.row.auditStatus===2" type="danger">审核不通过</el-tag>
  34. </template>
  35. <template slot="registerSource" slot-scope="{row}">
  36. <el-tag v-if="row.registerSource===1">小程序</el-tag>
  37. <el-tag v-if="row.registerSource===2">管理后台</el-tag>
  38. <el-tag v-if="row.registerSource===3">访客机</el-tag>
  39. </template>
  40. <template slot="menu" slot-scope="{row}">
  41. <el-button size="mini" type="text" icon="el-icon-setting">
  42. <el-dropdown>
  43. <span class="el-dropdown-link">
  44. 更多<i class="el-icon-arrow-down el-icon--right"></i>
  45. </span>
  46. <el-dropdown-menu slot="dropdown">
  47. <el-dropdown-item style="color: limegreen" type="text" @click.native="pushFace(row)" icon="el-icon-sort-down">人脸下发</el-dropdown-item>
  48. <el-dropdown-item style="color: red" type="text" @click.native="deleteFace(row)" icon="el-icon-sort-up">人脸禁用</el-dropdown-item>
  49. </el-dropdown-menu>
  50. </el-dropdown>
  51. </el-button>
  52. </template>
  53. </avue-crud>
  54. </basic-container>
  55. </template>
  56. <script>
  57. import {getList, getDetail, add, update, remove, pushGuestFace, deleteGuestFace} from "@/api/estate/guestrecord";
  58. import {mapGetters} from "vuex";
  59. export default {
  60. data() {
  61. return {
  62. form: {},
  63. query: {},
  64. loading: true,
  65. page: {
  66. pageSize: 10,
  67. currentPage: 1,
  68. total: 0
  69. },
  70. selectionList: [],
  71. option: {
  72. menuWidth: 300,
  73. height:'auto',
  74. calcHeight: 30,
  75. tip: false,
  76. searchShow: true,
  77. searchMenuSpan: 6,
  78. border: true,
  79. index: true,
  80. addBtn:true,
  81. delBtn:true,
  82. viewBtn: true,
  83. selection: true,
  84. dialogClickModal: false,
  85. column: [
  86. {
  87. label: "预约开始时间",
  88. prop: "beginTime",
  89. type: "datetime",
  90. width: 130,
  91. format: "yyyy-MM-dd HH:mm:ss",
  92. valueFormat: "yyyy-MM-dd HH:mm:ss"
  93. },
  94. {
  95. label: "预约结束时间",
  96. prop: "endTime",
  97. type: "datetime",
  98. width: 130,
  99. format: "yyyy-MM-dd HH:mm:ss",
  100. valueFormat: "yyyy-MM-dd HH:mm:ss"
  101. },
  102. {
  103. label: "登记来源",
  104. prop: "registerSource",
  105. slot: true,
  106. editDisplay: false,
  107. addDisplay:false,
  108. },
  109. {
  110. label: "访客姓名",
  111. prop: "guestName",
  112. search: true,
  113. rules: [{
  114. required: true,
  115. message: "请输入访客名称",
  116. trigger: "blur"
  117. }]
  118. },
  119. {
  120. label: "访客手机号",
  121. prop: "guestTel",
  122. labelWidth: 100,
  123. rules: [{
  124. required: true,
  125. message: "请输入访客手机号",
  126. trigger: "blur"
  127. }]
  128. },
  129. {
  130. label: "证件号码",
  131. prop: "guestIdcard",
  132. hide: true,
  133. rules: [{
  134. required: false,
  135. message: "请输入证件号码",
  136. trigger: "blur"
  137. }]
  138. },
  139. {
  140. label: "拜访园区",
  141. prop: "agencyId",
  142. cascaderItem: ['enterpriseId'],
  143. type: "select",
  144. remote: true,
  145. hide: true,
  146. search: true,
  147. viewDisplay: false,
  148. dicUrl: "/api/cyzh-community/agency/list",
  149. dicFormatter:(res)=>{
  150. return res.data.records;//返回字典的层级结构
  151. },
  152. props: {
  153. label: "name",
  154. value: "id"
  155. },
  156. rules: [{
  157. required: true,
  158. message: "请选择拜访园区",
  159. trigger: "blur"
  160. }]
  161. },
  162. {
  163. label: "拜访企业",
  164. prop: "enterpriseId",
  165. type: "select",
  166. search: true,
  167. hide: true,
  168. viewDisplay: false,
  169. dicUrl: "/api/cyzh-enterprise/enterprise/list?agencyId={{key}}",
  170. dicFormatter:(res)=>{
  171. return res.data.records;//返回字典的层级结构
  172. },
  173. // dicFlag: false,
  174. filterable: true,
  175. props: {
  176. label: "enterpriseName",
  177. value: "id"
  178. },
  179. rules: [{
  180. required: true,
  181. message: "请选择拜访企业",
  182. trigger: "blur"
  183. }]
  184. },
  185. {
  186. label: "拜访园区",
  187. prop: "agencyName",
  188. editDisplay: false,
  189. addDisplay: false,
  190. },
  191. {
  192. label: "拜访企业",
  193. prop: "enterpriseName",
  194. editDisplay: false,
  195. addDisplay: false,
  196. },
  197. {
  198. label: "审核状态",
  199. prop: "auditStatus",
  200. slot: true,
  201. type:'select',
  202. addDisplay: false,
  203. dicData:[
  204. {
  205. label:'待审核',
  206. value:0,
  207. color:'red'
  208. },{
  209. label:'审核通过',
  210. value:1
  211. },{
  212. label:'审核不通过',
  213. value:2
  214. }
  215. ]
  216. },
  217. {
  218. label: "审核意见",
  219. prop: "opinion",
  220. hide: true,
  221. editDisplay: false,
  222. addDisplay: false
  223. },
  224. {
  225. label: "访客事由",
  226. prop: "guestReason",
  227. type: 'textarea',
  228. rules: [{
  229. required: false,
  230. message: "请输入访问缘由",
  231. trigger: "blur"
  232. }]
  233. },
  234. {
  235. label: "访客人脸",
  236. prop: "imageUri",
  237. type: "upload",
  238. width: 150,
  239. listType: 'picture-img',
  240. propsHttp: {
  241. res: "data",
  242. url: "link"
  243. },
  244. action: "/api/blade-resource/oss/endpoint/put-file",
  245. rules: [{
  246. required: false,
  247. message: "请上传访客人脸",
  248. trigger: "blur"
  249. }]
  250. },
  251. ]
  252. },
  253. data: []
  254. };
  255. },
  256. computed: {
  257. ...mapGetters(["permission"]),
  258. permissionList() {
  259. return {
  260. addBtn: this.vaildData(this.permission.guestrecord_add, false),
  261. viewBtn: this.vaildData(this.permission.guestrecord_view, false),
  262. delBtn: this.vaildData(this.permission.guestrecord_delete, false),
  263. editBtn: this.vaildData(this.permission.guestrecord_edit, false)
  264. };
  265. },
  266. ids() {
  267. let ids = [];
  268. this.selectionList.forEach(ele => {
  269. ids.push(ele.id);
  270. });
  271. return ids.join(",");
  272. }
  273. },
  274. created() {
  275. const tenantType = localStorage.getItem("tenantType");
  276. if (tenantType == 0){
  277. let findObject1 = this.findObject(this.option.column, "agencyName");
  278. let findObject2 = this.findObject(this.option.column, "residentialName");
  279. let findObject3 = this.findObject(this.option.column, "buildingName");
  280. let findObject4 = this.findObject(this.option.column, "unitName");
  281. let findObject5 = this.findObject(this.option.column, "floorName");
  282. let findObject6 = this.findObject(this.option.column, "roomName");
  283. let findObject7 = this.findObject(this.option.column, "enterpriseName");
  284. findObject1.label = "拜访园区";
  285. findObject2.label = "拜访小区";
  286. findObject3.hide = false;findObject3.viewDisplay = true;
  287. findObject4.hide = false;findObject4.viewDisplay = true;
  288. findObject5.hide = false;findObject5.viewDisplay = true;
  289. findObject6.hide = false;findObject6.viewDisplay = true;
  290. findObject7.hide = true;
  291. }else if (tenantType == 1){
  292. let findObject1 = this.findObject(this.option.column, "agencyName");
  293. let findObject2 = this.findObject(this.option.column, "residentialName");
  294. let findObject3 = this.findObject(this.option.column, "enterpriseName");
  295. let findObject4 = this.findObject(this.option.column, "buildingName");
  296. let findObject5 = this.findObject(this.option.column, "unitName");
  297. let findObject6 = this.findObject(this.option.column, "floorName");
  298. let findObject7 = this.findObject(this.option.column, "roomName");
  299. findObject1.label = "拜访园区";
  300. findObject2.label = "拜访区域";
  301. findObject3.hide = false;
  302. findObject4.hide = true;findObject4.viewDisplay = false;
  303. findObject5.hide = true;findObject5.viewDisplay = false;
  304. findObject6.hide = true;findObject6.viewDisplay = false;
  305. findObject7.hide = true;findObject7.viewDisplay = false;
  306. }
  307. },
  308. methods: {
  309. pushFace(row){
  310. //下发人脸到测温系统和设备
  311. pushGuestFace(row).then(res => {
  312. this.$message({
  313. type: "success",
  314. message: "操作成功!"
  315. });
  316. })
  317. },
  318. deleteFace(row){
  319. this.$confirm("确定禁用人脸吗?", {
  320. confirmButtonText: "确定",
  321. cancelButtonText: "取消",
  322. type: "warning"
  323. })
  324. .then(() => {
  325. return deleteGuestFace(row);
  326. })
  327. .then(() => {
  328. this.onLoad(this.page);
  329. this.$message({
  330. type: "success",
  331. message: "操作成功!"
  332. });
  333. });
  334. },
  335. rowSave(row, done, loading) {
  336. row.agencyName = row.$agencyId;
  337. row.enterpriseName = row.$enterpriseId;
  338. row.auditStatus = 1;
  339. row.registerSource = 2;
  340. add(row).then(() => {
  341. this.onLoad(this.page);
  342. this.$message({
  343. type: "success",
  344. message: "操作成功!"
  345. });
  346. done();
  347. }, error => {
  348. loading();
  349. window.console.log(error);
  350. });
  351. },
  352. rowUpdate(row, index, done, loading) {
  353. row.agencyName = row.$agencyId;
  354. row.enterpriseName = row.$enterpriseId;
  355. row.registerSource = 2;
  356. update(row).then(() => {
  357. this.onLoad(this.page);
  358. this.$message({
  359. type: "success",
  360. message: "操作成功!"
  361. });
  362. done();
  363. }, error => {
  364. loading();
  365. console.log(error);
  366. });
  367. },
  368. rowDel(row) {
  369. this.$confirm("确定将选择数据删除?", {
  370. confirmButtonText: "确定",
  371. cancelButtonText: "取消",
  372. type: "warning"
  373. })
  374. .then(() => {
  375. return remove(row.id);
  376. })
  377. .then(() => {
  378. this.onLoad(this.page);
  379. this.$message({
  380. type: "success",
  381. message: "操作成功!"
  382. });
  383. });
  384. },
  385. handleDelete() {
  386. if (this.selectionList.length === 0) {
  387. this.$message.warning("请选择至少一条数据");
  388. return;
  389. }
  390. this.$confirm("确定将选择数据删除?", {
  391. confirmButtonText: "确定",
  392. cancelButtonText: "取消",
  393. type: "warning"
  394. })
  395. .then(() => {
  396. return remove(this.ids);
  397. })
  398. .then(() => {
  399. this.onLoad(this.page);
  400. this.$message({
  401. type: "success",
  402. message: "操作成功!"
  403. });
  404. this.$refs.crud.toggleSelection();
  405. });
  406. },
  407. beforeOpen(done, type) {
  408. if (["edit", "view"].includes(type)) {
  409. getDetail(this.form.id).then(res => {
  410. this.form = res.data.data;
  411. });
  412. }
  413. done();
  414. },
  415. searchReset() {
  416. this.query = {};
  417. this.onLoad(this.page);
  418. },
  419. searchChange(params, done) {
  420. this.query = params;
  421. this.page.currentPage = 1;
  422. this.onLoad(this.page, params);
  423. done();
  424. },
  425. selectionChange(list) {
  426. this.selectionList = list;
  427. },
  428. selectionClear() {
  429. this.selectionList = [];
  430. this.$refs.crud.toggleSelection();
  431. },
  432. currentChange(currentPage){
  433. this.page.currentPage = currentPage;
  434. },
  435. sizeChange(pageSize){
  436. this.page.pageSize = pageSize;
  437. },
  438. refreshChange() {
  439. this.onLoad(this.page, this.query);
  440. },
  441. onLoad(page, params = {}) {
  442. this.loading = true;
  443. getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  444. const data = res.data.data;
  445. this.page.total = data.total;
  446. this.data = data.records;
  447. this.loading = false;
  448. this.selectionClear();
  449. });
  450. }
  451. }
  452. };
  453. </script>
  454. <style>
  455. </style>