index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. <template>
  2. <div class="app-container">
  3. <el-row type="flex" justify="space-between" ref="listQueryContainer" class="query-container">
  4. <el-col>
  5. <el-form :inline="true" style="flex-wrap: wrap" :model="listQuery" ref="listQuery" @submit.native.prevent @keyup.enter.native="onSubmit">
  6. <el-form-item label="编号" prop="number">
  7. <el-input oninput="value=value.replace(/[^\d]/g,'')" v-model.trim="listQuery.number" maxlength="16" placeholder="请输入编号,年+4位编号" clearable @clear="listQuery.number=undefined" @keyup.enter.native="onFilterChange">
  8. <i slot="suffix" class="el-input__icon el-icon-search" @click="onFilterChange"></i>
  9. </el-input>
  10. </el-form-item>
  11. <el-form-item label="访客姓名" prop="username">
  12. <el-input v-model.trim="listQuery.username" maxlength="16" placeholder="请输入访客姓名" clearable @clear="listQuery.username=undefined" @keyup.enter.native="onFilterChange">
  13. <i slot="suffix" class="el-input__icon el-icon-search" @click="onFilterChange"></i>
  14. </el-input>
  15. </el-form-item>
  16. <el-form-item label="访客手机号" prop="userPhone">
  17. <el-input v-model.trim="listQuery.userPhone" maxlength="16" placeholder="请输入访客手机号" clearable @clear="listQuery.userPhone=undefined" @keyup.enter.native="onFilterChange">
  18. <i slot="suffix" class="el-input__icon el-icon-search" @click="onFilterChange"></i>
  19. </el-input>
  20. </el-form-item>
  21. <el-form-item label="访客公司" prop="company">
  22. <el-input v-model.trim="listQuery.company" maxlength="16" placeholder="请输入访客公司" clearable @clear="listQuery.company=undefined" @keyup.enter.native="onFilterChange">
  23. <i slot="suffix" class="el-input__icon el-icon-search" @click="onFilterChange"></i>
  24. </el-input>
  25. </el-form-item>
  26. <el-form-item label="是否高风险" prop="highRisk">
  27. <el-select v-model="listQuery.highRisk" placeholder="请选择" clearable @clear="listQuery.highRisk=undefined" @change="onFilterChange">
  28. <el-option key="是" label="是" value="true"></el-option>
  29. <el-option key="否" label="否" value="false"></el-option>
  30. </el-select>
  31. </el-form-item>
  32. <el-form-item label="审核状态" prop="status">
  33. <el-select v-model="listQuery.status" placeholder="请选择" clearable @clear="listQuery.highRisk=undefined" @change="onFilterChange">
  34. <el-option :key="status.value" :label="status.label" :value="status.value" v-for="status in auditList"></el-option>
  35. </el-select>
  36. </el-form-item>
  37. <el-form-item label="进入时间范围" prop="entryTimeRange">
  38. <el-date-picker
  39. v-model="listQuery.entryTimeRange"
  40. value-format="timestamp"
  41. type="daterange"
  42. range-separator="-"
  43. start-placeholder="开始日期"
  44. end-placeholder="结束日期"
  45. :default-time="['00:00:00', '23:59:59']"
  46. @change="onFilterChange">
  47. </el-date-picker>
  48. </el-form-item>
  49. <el-form-item label="离开时间范围" prop="leaveTimeRange">
  50. <el-date-picker
  51. v-model="listQuery.leaveTimeRange"
  52. value-format="timestamp"
  53. type="daterange"
  54. range-separator="-"
  55. start-placeholder="开始日期"
  56. end-placeholder="结束日期"
  57. :default-time="['00:00:00', '23:59:59']"
  58. @change="onFilterChange">
  59. </el-date-picker>
  60. </el-form-item>
  61. <el-form-item label-width="0">
  62. <el-button @click="onFilterChange" type="primary">查询</el-button>
  63. <el-button @click="resetFields" plain type="primary">重置</el-button>
  64. <el-button @click="onExport" plain type="primary">导出</el-button>
  65. <el-button @click="showQrCodeIn" type="primary" style="margin-left: 20px;">进入登记二维码</el-button>
  66. <el-button @click="showQrCodeOut" type="primary">出场核销二维码</el-button>
  67. </el-form-item>
  68. </el-form>
  69. </el-col>
  70. <form-clear :shrinkable="shrinkable" @clear="resetFields" @change="onExpansion"/>
  71. </el-row>
  72. <el-table :data="list" border stripe highlight-current-row ref="table" class="mt10" @sort-change="onSortChange" @selection-change="onTableSelectionChange" @row-click="onRowClick">
  73. <el-table-column type="index" :index="indexCompute" label="序号" align="center" fixed="left" width="60px"/>
  74. <el-table-column prop="number" label="编号" sortable="custom" align="center" min-width="100px"/>
  75. <el-table-column prop="username" label="访客姓名" sortable="custom" align="center" min-width="102px"/>
  76. <el-table-column prop="userPhone" label="访客手机号" sortable="custom" align="center" min-width="116px"/>
  77. <el-table-column prop="company" label="访客公司" sortable="custom" align="center" min-width="102px"/>
  78. <el-table-column prop="duration" label="访问时长(小时)" align="center" min-width="96px"/>
  79. <el-table-column prop="itineraryCode" label="行程码" align="center" min-width="80px">
  80. <template v-slot="scope">
  81. <template v-if="scope.row.itineraryCode">
  82. <el-image style="height: 40px;" :src="scope.row.itineraryCode" contain :preview-src-list="[scope.row.itineraryCode]"></el-image>
  83. </template>
  84. <template v-else>未上传</template>
  85. </template>
  86. </el-table-column>
  87. <el-table-column prop="healthCode" label="健康码" align="center" min-width="80px">
  88. <template v-slot="scope">
  89. <template v-if="scope.row.healthCode">
  90. <el-image style="height: 40px;" :src="scope.row.healthCode" contain :preview-src-list="[scope.row.healthCode]"></el-image>
  91. </template>
  92. <template v-else>未上传</template>
  93. </template>
  94. </el-table-column>
  95. <el-table-column prop="highRisk" label="是否高风险" align="center" min-width="110px">
  96. <template v-slot="scope">
  97. <text-label v-if="scope.row.highRisk" type="danger">是</text-label>
  98. <text-label v-else type="success">否</text-label>
  99. </template>
  100. </el-table-column>
  101. <el-table-column prop="reason" label="事由" align="center" min-width="100px"/>
  102. <el-table-column prop="information" label="审核资料" align="center" min-width="160px">
  103. <template v-slot="scope">
  104. <template v-if="scope.row.information">
  105. <el-image style="height: 40px; margin: 0 3px" :src="info" contain :preview-src-list="scope.row.information.split(',')" v-for="info in scope.row.information.split(',')" :key="info"></el-image>
  106. </template>
  107. <template v-else>未上传</template>
  108. </template>
  109. </el-table-column>
  110. <el-table-column prop="operatingUsername" label="操作用户姓名" sortable="custom" align="center" min-width="130px"/>
  111. <el-table-column prop="remark" label="出场备注" align="center" min-width="102px"/>
  112. <el-table-column prop="entryTime" label="进入时间" sortable="custom" align="center" width="160px">
  113. <template v-slot="scope">{{ scope.row.entryTime | dateFormat }}</template>
  114. </el-table-column>
  115. <el-table-column prop="leaveTime" label="离开时间" sortable="custom" align="center" width="160px">
  116. <template v-slot="scope">{{ scope.row.leaveTime | dateFormat }}</template>
  117. </el-table-column>
  118. <el-table-column prop="entryTime" label="申请时间" sortable="custom" align="center" width="160px">
  119. <template v-slot="scope">{{ scope.row.createTime | dateFormat }}</template>
  120. </el-table-column>
  121. <el-table-column prop="backupValid" label="是否备案" align="center" width="78px" fixed="right">
  122. <template v-slot="scope">
  123. <text-label v-if="scope.row.backupId && scope.row.backupValid" type="success">已备案</text-label>
  124. <text-label v-else-if="scope.row.backupId" type="warning">已过期</text-label>
  125. <text-label v-else type="danger">未备案</text-label>
  126. </template>
  127. </el-table-column>
  128. <el-table-column prop="status" label="审核状态" align="center" min-width="78px" fixed="right">
  129. <template v-slot="scope">
  130. <text-label v-if="scope.row.status === 1">{{ auditList.find(item => item.value === scope.row.status).label }}</text-label>
  131. <text-label v-else-if="scope.row.status === 2" type="success">{{ auditList.find(audit => audit.value === scope.row.status).label }}</text-label>
  132. <text-label v-else-if="scope.row.status === 3" type="danger">{{ auditList.find(audit => audit.value === scope.row.status).label }}</text-label>
  133. </template>
  134. </el-table-column>
  135. <el-table-column label="操作" align="center" min-width="150px" fixed="right">
  136. <template v-slot="scope">
  137. <el-link type="primary" icon="el-icon-check" :disabled="scope.row.status!==1" @click="onAudit(scope.row, 2)">通过</el-link>
  138. <el-link type="primary" icon="el-icon-close" :disabled="scope.row.status!==1" @click="onAudit(scope.row, 3)" class="ml20">拒绝</el-link>
  139. </template>
  140. </el-table-column>
  141. </el-table>
  142. <pagination :total="total" :page.sync="listQuery.page" :size.sync="listQuery.size" @change="onPageChange"/>
  143. <el-dialog title="导出" :visible.sync="exportVisible" :close-on-click-modal="false" :close-on-press-escape="false" width="600px">
  144. <el-progress :text-inside="true" :stroke-width="24" :percentage="exportProgress" status="success"></el-progress>
  145. <el-button slot="footer" @click="onCancelExport">取 消</el-button>
  146. </el-dialog>
  147. </div>
  148. </template>
  149. <script>
  150. import {downloadImage} from "@/utils/httpUtil";
  151. import {dateFormat} from "@/utils/dateUtil"
  152. export default {
  153. name: "VisitorAudit",
  154. data() {
  155. return {
  156. shrinkable: false, // 查询条件是否可以展开
  157. listQuery: { // 查询对象
  158. number: undefined, // 编号
  159. username: undefined, // 访客姓名
  160. userPhone: undefined, // 访客手机号
  161. company: undefined, // 访客公司
  162. highRisk: undefined, // 是否高风险
  163. status: undefined, // 审核状态
  164. entryTimeRange: [], // 审批、进入时间
  165. entryTimeStart: undefined,
  166. entryTimeEnd: undefined,
  167. leaveTimeRange: [], // 离开时间
  168. leaveTimeStart: undefined,
  169. leaveTimeEnd: undefined,
  170. order: undefined,
  171. page: 1,
  172. size: 10
  173. },
  174. auditList: [{value: 1, label: '未审核'}, {value: 2, label: '通过'}, {value: 3, label: '拒绝'}],
  175. list: [], // 结果列表
  176. total: 0, // 总结果数量
  177. exportVisible: false, // 是否显示导出对话框
  178. exportData: [], // 导出数据
  179. exportPagination: { // 导出分页
  180. page: 1,
  181. size: 500,
  182. },
  183. exportProgress: 0, // 导出进度
  184. exportCancel: false, // 是否取消导出
  185. editing: false, // 表格编辑中
  186. selectItem: undefined, // 选中的单条记录
  187. selectIds: undefined, // 选中多条记录的id
  188. }
  189. },
  190. watch: {
  191. 'listQuery.entryTimeRange'(value) {
  192. if (value) {
  193. this.listQuery.entryTimeStart = value[0];
  194. this.listQuery.entryTimeEnd = value[1];
  195. } else {
  196. this.listQuery.entryTimeStart = undefined;
  197. this.listQuery.entryTimeEnd = undefined;
  198. }
  199. },
  200. 'listQuery.leaveTimeRange'(value) {
  201. if (value) {
  202. this.listQuery.leaveTimeStart = value[0];
  203. this.listQuery.leaveTimeEnd = value[1];
  204. } else {
  205. this.listQuery.leaveTimeStart = undefined;
  206. this.listQuery.leaveTimeEnd = undefined;
  207. }
  208. },
  209. 'listQuery.createTimeRange'(value) {
  210. if (value) {
  211. this.listQuery.createTimeStart = value[0];
  212. this.listQuery.createTimeEnd = value[1];
  213. } else {
  214. this.listQuery.createTimeStart = undefined;
  215. this.listQuery.createTimeEnd = undefined;
  216. }
  217. },
  218. },
  219. // 页面创建
  220. created() {
  221. this.initData();
  222. this.initEvent();
  223. },
  224. // 页面挂载
  225. mounted() {
  226. this.initView();
  227. this.initQuery();
  228. this.getList();
  229. },
  230. // keep-alive 显示界面时调用
  231. activated() {
  232. this.$refs["table"].doLayout();
  233. },
  234. // keep-alive 页面隐藏
  235. deactivated() {
  236. },
  237. methods: {
  238. // 初始化数据
  239. initData() {
  240. },
  241. // 初始化事件
  242. initEvent() {
  243. },
  244. // 初始化查询条件
  245. initQuery() {
  246. if (this.$store.state.app.paramCache) {
  247. let query = this.$storage.getData(this.$options.name);
  248. if (Object.keys(query).length > 0) {
  249. this.listQuery = query;
  250. if (query.order) {
  251. this.$refs.table.sort(query.order.substring(1), query.order.substring(0, 1) === "+" ? "ascending" : "descending");
  252. } else {
  253. this.$refs.table.clearSort();
  254. }
  255. }
  256. }
  257. },
  258. // 初始化视图
  259. initView() {
  260. this.$nextTick(() => {
  261. this.shrinkable = this.$store.state.app.filterShrink && this.$refs['listQuery'].$el.offsetHeight > 51;
  262. })
  263. },
  264. // 展开/收起查询条件
  265. onExpansion(show) {
  266. this.$refs['listQueryContainer'].$el.style.height = show ? "auto" : "51px";
  267. },
  268. // 表格索引
  269. indexCompute(index) {
  270. return index + 1 + (this.listQuery.page - 1) * this.listQuery.size;
  271. },
  272. // 表单提交
  273. onSubmit() {
  274. this.onFilterChange();
  275. },
  276. // 表单清除
  277. resetFields() {
  278. this.$refs['listQuery'].resetFields();
  279. this.listQuery.order = undefined;
  280. this.$refs.table.clearSort();
  281. this.onFilterChange();
  282. },
  283. // 审核
  284. onAudit(item, status) {
  285. this.$axios.put("/v1/visitor/audit/update", {id: item.id, status: status}).then(() => {
  286. this.getList();
  287. this.$message.success("审批成功");
  288. });
  289. },
  290. // 数据选择
  291. onTableSelectionChange(val) {
  292. this.selectIds = val.map(item => item.id);
  293. },
  294. // 排序改变
  295. onSortChange({prop, order}) {
  296. if (order === "ascending") {
  297. this.listQuery.order = "+" + prop;
  298. } else if (order === "descending") {
  299. this.listQuery.order = "-" + prop;
  300. } else {
  301. this.listQuery.order = undefined;
  302. }
  303. this.onFilterChange();
  304. },
  305. // 行点击
  306. onRowClick(row, column, event) {
  307. this.$refs["table"].setCurrentRow(row);
  308. if (this.editing) {
  309. this.$refs["table"].toggleRowSelection(row);
  310. }
  311. },
  312. // 条件改变
  313. onFilterChange() {
  314. this.listQuery.page = 1;
  315. this.$nextTick(this.getList);
  316. },
  317. // 页码改变
  318. onPageChange() {
  319. this.getList();
  320. },
  321. // 加载列表
  322. getList() {
  323. // 缓存参数
  324. if (this.$store.state.app.paramCache) {
  325. this.$storage.setData(this.$options.name, this.listQuery);
  326. }
  327. this.$axios.get("/v1/visitor/audit/list", {params: this.listQuery}).then(data => {
  328. this.list = data.list;
  329. this.total = data.total;
  330. this.$refs["table"].doLayout();
  331. });
  332. },
  333. // 进入登记二维码
  334. showQrCodeIn() {
  335. let url = encodeURIComponent(`https://www.zwywpt.top/visited/pages/writeoff/register/register`)
  336. let qrUrl = `https://yun.huaxiyou.cc/internal.qcode.stream?dstUrl=${url}`;
  337. this.$alert(`<img src="${qrUrl}" style="width:100%; height:100%">`, `进入登记二维码`, {
  338. dangerouslyUseHTMLString: true,
  339. confirmButtonText: '下载',
  340. callback: action => {
  341. if (action === 'confirm') {
  342. downloadImage(qrUrl, '进入登记二维码')
  343. }
  344. }
  345. }
  346. );
  347. },
  348. // 出场核销二维码
  349. showQrCodeOut() {
  350. let url = encodeURIComponent(`https://www.zwywpt.top/register/pages/writeoff/exitwritoff/exitwritoff`)
  351. let qrUrl = `https://yun.huaxiyou.cc/internal.qcode.stream?dstUrl=${url}`;
  352. this.$alert(`<img src="${qrUrl}" style="width:100%; height:100%">`, `出场核销二维码`, {
  353. dangerouslyUseHTMLString: true,
  354. confirmButtonText: '下载',
  355. callback: action => {
  356. if (action === 'confirm') {
  357. downloadImage(qrUrl, '出场核销二维码')
  358. }
  359. }
  360. });
  361. },
  362. // 导出数据
  363. onExport() {
  364. if (this.total > 0) {
  365. this.exportPagination.page = 1;
  366. this.exportData = [];
  367. this.exportVisible = true;
  368. this.getExportData();
  369. }
  370. },
  371. // 取消导出
  372. onCancelExport() {
  373. this.exportVisible = false;
  374. this.exportCancel = true;
  375. },
  376. // 获取数据并导出
  377. getExportData() {
  378. if (!this.exportCancel) {
  379. this.$axios.get("/v1/visitor/audit/list", {params: {...this.listQuery, ...this.exportPagination}}).then(data => {
  380. this.exportPagination.page++;
  381. this.exportData = this.exportData.concat(data.list);
  382. this.exportProgress = Math.round(this.exportData.length * 100 / this.total);
  383. if (this.exportData.length < this.total && data.list.length > 0) {
  384. this.getExportData();
  385. } else {
  386. this.exportVisible = false;
  387. let tHeader = ["序号",
  388. "编号",
  389. "访客姓名",
  390. "访客手机号",
  391. "访客公司",
  392. "访问时长",
  393. "行程码",
  394. "健康码",
  395. "是否高风险",
  396. "事由",
  397. "审核资料",
  398. "操作用户姓名",
  399. "出场备注",
  400. "审批、进入时间",
  401. "离开时间",
  402. "申请时间",
  403. "是否备案",
  404. "审核状态",
  405. ];
  406. let filterVal = ["index",
  407. "number",
  408. "username",
  409. "userPhone",
  410. "company",
  411. "duration",
  412. "itineraryCode",
  413. "healthCode",
  414. "highRisk",
  415. "reason",
  416. "information",
  417. "operatingUsername",
  418. "remark",
  419. "entryTime",
  420. "leaveTime",
  421. "createTime",
  422. "backupValid",
  423. "status",
  424. ];
  425. let data = this.exportData.map((value, index) => filterVal.map((key) => {
  426. if (key === "index") {
  427. return index + 1;
  428. } else if (key === "entryTime") {
  429. return dateFormat("yyyy-MM-dd HH:mm:ss", value[key]);
  430. } else if (key === "leaveTime") {
  431. return dateFormat("yyyy-MM-dd HH:mm:ss", value[key]);
  432. } else if (key === "createTime") {
  433. return dateFormat("yyyy-MM-dd HH:mm:ss", value[key]);
  434. } else if (key === "status") {
  435. return this.auditList.find(audit => audit.value === value[key]).label;
  436. } else {
  437. return value[key];
  438. }
  439. }));
  440. import('@/utils/Export2Excel').then(excel => {
  441. excel.export_json_to_excel({
  442. header: tHeader, // 表头 必填
  443. data, // 具体数据 必填
  444. filename: '访客审批', // 非必填
  445. autoWidth: true, // 非必填
  446. bookType: 'xlsx' // 非必填
  447. })
  448. })
  449. }
  450. });
  451. }
  452. }
  453. }
  454. }
  455. </script>
  456. <style lang="scss" scoped>
  457. .app-container {
  458. }
  459. </style>