| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 |
- <template>
- <view class="process-list">
- <view class="search-row">
- <input
- class="search-input"
- v-model="searchName"
- placeholder="事故事件名称"
- />
- <view class="dept-btn" @click="showDeptPicker"
- ><text>{{ deptName || "责任单位" }}</text
- ><text class="arrow">▾</text></view
- >
- <button class="search-btn" @click="handleSearch">搜索</button>
- </view>
- <u-list @scrolltolower="loadMore" class="list-content">
- <view v-for="(item, idx) in listData" :key="item.id" class="card-wrapper">
- <myCard
- :item="item"
- :index="idx + 1"
- :btnList="getBtnList(item)"
- :columns="processColumns"
- :title="item.acdntName"
- :status="getStatusLabel(item.approvalStatus)"
- @goDetail="goDetail"
- @handleProcess="handleProcess"
- />
- </view>
- <view style="height: 20rpx"></view>
- <view v-if="loading" class="load-more">加载中...</view>
- <view v-if="isEnd && listData.length > 0" class="load-more"
- >没有更多了</view
- >
- <u-empty v-if="!loading && listData.length === 0" text="暂无待处理事故" />
- </u-list>
- <!-- 弹窗 -->
- <processDialog ref="processDialogRef" @reload="reloadList" />
- <accidentDialog ref="dialogRef" @reload="reloadList" />
- <ba-tree-picker
- ref="treePicker"
- key="dept"
- :multiple="false"
- @select-change="onDeptConfirm"
- title="选择部门"
- :localdata="deptList"
- valueKey="id"
- textKey="name"
- />
- <u-toast ref="uToast" />
- </view>
- </template>
- <script>
- import myCard from "@/components/myCard.vue";
- import processDialog from "./processDialog.vue";
- import accidentDialog from "./accidentDialog.vue";
- import baTreePicker from "@/components/ba-tree-picker/ba-tree-picker.vue";
- import { pageApproved } from "@/api/accidentReport/index.js";
- import { listOrganizations } from "@/api/common.js";
- export default {
- components: { myCard, processDialog, accidentDialog, baTreePicker },
- data() {
- return {
- searchName: "",
- deptId: null,
- deptName: "责任单位",
- deptList: [],
- listData: [],
- page: 1,
- size: 10,
- isEnd: false,
- loading: false,
- processColumns: [
- [{ prop: "acdntCode", label: "编码", className: "perce100" }],
- [
- { prop: "dutyUnitName", label: "责任单位", className: "perce50" },
- { prop: "acdntPlace", label: "地点", className: "perce50" },
- ],
- [{ prop: "occurrenceTime", label: "发生时间", className: "perce100" }],
- [
- {
- prop: "ascertainedStatus",
- label: "事故原因",
- className: "perce33",
- formatter: (row) =>
- row.ascertainedStatus == 1 ? "已查清" : "未查清",
- },
- {
- prop: "responsibilityStatus",
- label: "责任人员",
- className: "perce33",
- formatter: (row) =>
- row.responsibilityStatus == 1 ? "已处理" : "未处理",
- },
- {
- prop: "correctiveMeasuresStatus",
- label: "整改措施",
- className: "perce33",
- formatter: (row) =>
- row.correctiveMeasuresStatus == 1 ? "已落实" : "未落实",
- },
- ],
- [
- {
- label: "操作",
- prop: "action",
- type: "action",
- className: "perce100",
- },
- ],
- ],
- };
- },
- mounted() {
- this.loadDeptList();
- this.getList();
- },
- methods: {
- async loadDeptList() {
- try {
- const res = await listOrganizations({});
- this.deptList = res || [];
- } catch (e) {}
- },
- showDeptPicker() {
- this.$refs.treePicker._show();
- },
- onDeptConfirm(data) {
- const id = data[0];
- this.deptId = id;
- const find = (list) => {
- for (const item of list) {
- if (item.id === id) return item.name;
- if (item.children) {
- const f = find(item.children);
- if (f) return f;
- }
- }
- return null;
- };
- this.deptName = find(this.deptList) || "责任单位";
- this.page = 1;
- this.isEnd = false;
- this.getList();
- },
- getStatusLabel(status) {
- return (
- { 0: "待提交", 1: "审批中", 2: "已通过", 3: "已驳回" }[status] || status
- );
- },
- getBtnList(item) {
- return [
- {
- name: "查看",
- apiName: "goDetail",
- btnType: "info",
- judge: [{ fn: () => true }],
- },
- {
- name: "处理",
- apiName: "handleProcess",
- btnType: "primary",
- judge: [{ fn: () => true }],
- },
- ];
- },
- goDetail(item) {
- this.$refs.dialogRef.open(item, "view");
- },
- handleProcess(item) {
- this.$refs.processDialogRef.open(item);
- },
- handleSearch() {
- this.page = 1;
- this.isEnd = false;
- this.getList();
- },
- reloadList() {
- this.page = 1;
- this.isEnd = false;
- this.getList();
- },
- async getList() {
- if (this.loading || this.isEnd) return;
- this.loading = true;
- try {
- const params = {
- pageNum: this.page,
- size: this.size,
- acdntName: this.searchName || undefined,
- dutyUnitId: this.deptId || undefined,
- };
- const res = await pageApproved(params);
- const list = res.list || [];
- if (this.page === 1) this.listData = list;
- else this.listData = this.listData.concat(list);
- this.isEnd =
- list.length < this.size || this.listData.length >= res.count;
- this.page += 1;
- } catch (e) {
- this.$refs.uToast.show({ type: "error", message: e.message });
- } finally {
- this.loading = false;
- }
- },
- loadMore() {
- if (!this.isEnd && !this.loading) this.getList();
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .process-list {
- .search-row {
- display: flex;
- align-items: center;
- gap: 12rpx;
- padding: 16rpx 20rpx;
- background: #fff;
- border-radius: 24rpx;
- margin-bottom: 16rpx;
- .search-input {
- flex: 1;
- height: 60rpx;
- background: #f5f7fb;
- border-radius: 48rpx;
- padding: 0 20rpx;
- font-size: 26rpx;
- }
- .dept-btn {
- display: flex;
- align-items: center;
- height: 60rpx;
- padding: 0 20rpx;
- background: #e8edf4;
- border-radius: 48rpx;
- color: #2979ff;
- font-size: 24rpx;
- gap: 4rpx;
- .arrow {
- font-size: 18rpx;
- }
- }
- .search-btn {
- height: 60rpx;
- padding: 0 28rpx;
- background: $theme-color;
- border-radius: 48rpx;
- color: #fff;
- font-size: 26rpx;
- line-height: 60rpx;
- }
- }
- .list-content {
- height: calc(100vh - 300rpx);
- }
- .card-wrapper {
- margin-top: 16rpx;
- }
- .load-more {
- text-align: center;
- font-size: 26rpx;
- color: #aaa;
- padding: 20rpx 0;
- }
- }
- </style>
|