Blame view

src/views/project/approve/ReportPanel.vue 6.38 KB
sanmu authored
1
<template>
2
3
4
5
  <BasicTable @register="registerTable" className="p-0">
    <template #bodyCell="{ column, record }">
      <template v-if="column.key === 'picUrl'">
        <img
6
7
          :width="50"
          :height="50"
8
9
10
          :src="record?.orderBaseInfo?.smallPicUrl"
          @click="handlePreview(record?.orderBaseInfo?.picUrl)"
        />
sanmu authored
11
      </template>
12
13
14
15
16
17
18
19
20
21
      <template v-if="column.key === 'action'">
        <TableAction
          :actions="[
            {
              label: '详情',
              // icon: 'ic:outline-delete-outline',
              onClick: handleDetail.bind(null, record),
            },
          ]"
        />
sanmu authored
22
      </template>
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
    </template>
  </BasicTable>
  <BasicDrawer
    :showFooter="!isApproved && role === ROLE.ADMIN"
    @register="registerDrawer"
    title="申请信息"
    okText="通过"
    @ok="handleTrue"
  >
    <BaseInfo :baseInfos="baseInfos" />
    <h2>项目报告书信息</h2>
    <div v-for="field in fieldInfos" :key="field">
      <span className="w-[140px] inline-block text-right mr-3">{{ field.label }}:</span
      ><span>{{ field.value }}</span>
    </div>
    <template #appendFooter>
      <a-button @click="handleFalse"> 不通过</a-button>
    </template>
  </BasicDrawer>
  <MsgModal v-if="msgVisible" @msg-modal-close="handleMsgModalClose" />
sanmu authored
43
44
</template>
<script lang="ts">
sanmu authored
45
  import MsgModal from './MsgModal.vue';
sanmu authored
46
  import { computed, defineComponent, ref } from 'vue';
sanmu authored
47
  import { BasicTable, useTable, TableAction } from '/@/components/Table';
sanmu authored
48
  import { BasicDrawer, useDrawer } from '/@/components/Drawer';
sanmu authored
49
sanmu authored
50
51
  import { approveAuditApi, getApprovedListApi, getWaitListApi } from '/@/api/project/approve';
  import { FIELDS_BASE_INFO, FIELDS_REPORT_INFO } from '../order/tableData';
sanmu authored
52
53
54
  import { ROLE } from '../order//type.d';
  import { useUserStoreWithOut } from '/@/store/modules/user';
  import BaseInfo from './BaseInfo.vue';
55
  import { createImgPreview } from '/@/components/Preview';
56
  import { getFormConfig } from './data';
sanmu authored
57
58

  const userStore = useUserStoreWithOut();
sanmu authored
59
60
61
62

  export default defineComponent({
    components: {
      BasicTable,
sanmu authored
63
      BasicDrawer,
sanmu authored
64
      BaseInfo,
sanmu authored
65
      TableAction,
sanmu authored
66
      MsgModal,
sanmu authored
67
    },
sanmu authored
68
69
70
71
    props: {
      isApproved: { type: Boolean },
    },
    setup(props) {
sanmu authored
72
73
      // visible 用于msgModal显示隐藏
      const msgVisible = ref(false);
sanmu authored
74
75
      const checkedKeys = ref<Array<string | number>>([]);
      const currentKey = ref('1');
sanmu authored
76
77
78
79
      const [registerDrawer, { openDrawer, closeDrawer }] = useDrawer();
      const fieldInfos = ref({});
      const baseInfos = ref({});
      const id = ref('');
sanmu authored
80
81
82
83
84
85
      let columns = [
        {
          title: '申请人',
          dataIndex: 'createBy',
          width: 150,
        },
86
87
88
89
90
91
92
93
94
95
96
97
98
99
        {
          title: '内部编号',
          dataIndex: 'innerNo',
          width: 150,
          customRender: (column) => {
            const { record } = column || {};
            return record?.orderBaseInfo?.innerNo;
          },
        },
        {
          title: '图片',
          dataIndex: 'picUrl',
          width: 150,
        },
sanmu authored
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
      ];

      if (props.isApproved) {
        columns = columns.concat([
          {
            title: '状态',
            dataIndex: 'status',
            width: 150,
            customRender: (column) => {
              const { record } = column || {};

              return record.status === 10 ? '通过' : '拒绝';
            },
          },
          { title: '拒绝原因', dataIndex: 'refuseRemark', width: 250 },
        ]);
      }
sanmu authored
117
118

      const [registerTable, { reload }] = useTable({
sanmu authored
119
        api: props.isApproved ? getApprovedListApi : getWaitListApi,
sanmu authored
120
121
        searchInfo: { type: 20 },
sanmu authored
122
        columns,
123
124
        useSearchForm: true,
        formConfig: getFormConfig(),
sanmu authored
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
        rowKey: 'id',
        actionColumn: {
          width: 160,
          title: 'Action',
          dataIndex: 'action',
          // slots: { customRender: 'action' },
        },
      });

      function onSelect(record, selected) {
        if (selected) {
          checkedKeys.value = [...checkedKeys.value, record.id];
        } else {
          checkedKeys.value = checkedKeys.value.filter((id) => id !== record.id);
        }
      }
      function onSelectAll(selected, selectedRows, changeRows) {
        const changeIds = changeRows.map((item) => item.id);
        if (selected) {
          checkedKeys.value = [...checkedKeys.value, ...changeIds];
        } else {
          checkedKeys.value = checkedKeys.value.filter((id) => {
            return !changeIds.includes(id);
          });
        }
      }
      function handleEdit(record, e) {
        e?.stopPropagation();
        return false;
      }

      function handleProfitModal() {}
sanmu authored
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
      async function handleDetail(data) {
        openDrawer(true, { data });
        id.value = data.id;
        fieldInfos.value = FIELDS_REPORT_INFO.map((field) => {
          return {
            label: field.label,
            value: data.fieldInfos.reportFields[field.field],
          };
        }).filter((item) => !!item.value);
        baseInfos.value = FIELDS_BASE_INFO.map((field) => {
          return {
            label: field.label,
            value: data.orderBaseInfo[field.field],
          };
        }).filter((item) => !!item.value);
sanmu authored
173
174
      }
sanmu authored
175
176
      async function handleTrue() {
        await approveAuditApi({ status: 10, id: id.value });
sanmu authored
177
        reload();
sanmu authored
178
        closeDrawer();
sanmu authored
179
180
      }
sanmu authored
181
      async function handleFalse() {
sanmu authored
182
        msgVisible.value = true;
sanmu authored
183
      }
sanmu authored
184
sanmu authored
185
186
187
188
189
190
191
192
193
194
      // 定义MsgModalClose的事件,方便子组件调用
      const handleMsgModalClose = async (data) => {
        if (data) {
          await approveAuditApi({ status: 20, id: id.value, refuseRemark: data });
          reload();
          closeDrawer();
        }
        msgVisible.value = false;
      };
sanmu authored
195
196
197
      const role = computed(() => {
        return userStore.getUserInfo?.roleSmallVO?.code;
      });
198
199
200
201
202
203

      const handlePreview = (url) => {
        createImgPreview({ imageList: [url], defaultWidth: 500 });
        return false;
      };
sanmu authored
204
205
206
207
208
209
210
211
      return {
        handleProfitModal,
        registerTable,
        checkedKeys,
        currentKey,
        onSelect,
        handleEdit,
        onSelectAll,
sanmu authored
212
213
214
215
        handleDetail,
        registerDrawer,
        fieldInfos,
        baseInfos,
sanmu authored
216
217
        handleTrue,
        handleFalse,
sanmu authored
218
219
        role,
        ROLE,
sanmu authored
220
221
        msgVisible,
        handleMsgModalClose,
222
        handlePreview,
sanmu authored
223
224
225
226
      };
    },
  });
</script>