Blame view

src/views/project/approve/ProfitPanel.vue 6.26 KB
sanmu authored
1
2
3
4
5
6
7
8
9
<template>
  <PageWrapper contentBackground>
    <BasicTable @register="registerTable">
      <template #form-custom> custom-slot </template>
      <template #bodyCell="{ column, record }">
        <template v-if="column.key === 'action'">
          <TableAction
            :actions="[
              {
sanmu authored
10
                label: '详情',
sanmu authored
11
                // icon: 'ic:outline-delete-outline',
sanmu authored
12
                onClick: handleDetail.bind(null, record),
sanmu authored
13
14
15
16
17
18
              },
            ]"
          />
        </template>
      </template>
    </BasicTable>
sanmu authored
19
    <BasicDrawer
sanmu authored
20
      :showFooter="!isApproved && role === ROLE.ADMIN"
sanmu authored
21
22
23
24
25
      @register="registerDrawer"
      title="申请信息"
      okText="通过"
      @ok="handleTrue"
    >
sanmu authored
26
      <BaseInfo :baseInfos="baseInfos" />
sanmu authored
27
      <h2>利润分析信息</h2>
sanmu authored
28
29
30
31
32
33
34
35
      <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>
sanmu authored
36
    <MsgModal v-if="msgVisible" @msg-modal-close="handleMsgModalClose" />
sanmu authored
37
38
39
  </PageWrapper>
</template>
<script lang="ts">
sanmu authored
40
  import MsgModal from './MsgModal.vue';
sanmu authored
41
  import { computed, defineComponent, ref } from 'vue';
sanmu authored
42
43
  import { BasicTable, useTable, TableAction } from '/@/components/Table';
  import { PageWrapper } from '/@/components/Page';
sanmu authored
44
  import { BasicDrawer, useDrawer } from '/@/components/Drawer';
sanmu authored
45
sanmu authored
46
47
  import { approveAuditApi, getApprovedListApi, getWaitListApi } from '/@/api/project/approve';
  import { FIELDS_BASE_INFO, FIELDS_PROFIT_INFO, FIELDS_REPORT_INFO } from '../order/tableData';
sanmu authored
48
49
50
51
52
  import { ROLE } from '../order//type.d';
  import { useUserStoreWithOut } from '/@/store/modules/user';
  import BaseInfo from './BaseInfo.vue';

  const userStore = useUserStoreWithOut();
sanmu authored
53
54
55
56
57

  export default defineComponent({
    components: {
      PageWrapper,
      BasicTable,
sanmu authored
58
      BasicDrawer,
sanmu authored
59
      TableAction,
sanmu authored
60
      BaseInfo,
sanmu authored
61
      MsgModal,
sanmu authored
62
    },
sanmu authored
63
64
65
66
    props: {
      isApproved: { type: Boolean },
    },
    setup(props) {
sanmu authored
67
68
      // visible 用于msgModal显示隐藏
      const msgVisible = ref(false);
sanmu authored
69
70
      const checkedKeys = ref<Array<string | number>>([]);
      const currentKey = ref('1');
sanmu authored
71
72
73
74
      const [registerDrawer, { openDrawer, closeDrawer }] = useDrawer();
      const fieldInfos = ref({});
      const baseInfos = ref({});
      const id = ref('');
sanmu authored
75
sanmu authored
76
77
78
79
80
81
82
      let columns = [
        {
          title: '申请人',
          dataIndex: 'createBy',
          width: 150,
        },
      ];
sanmu authored
83
sanmu authored
84
85
      if (props.isApproved) {
        columns = columns.concat([
sanmu authored
86
          {
sanmu authored
87
88
            title: '状态',
            dataIndex: 'status',
sanmu authored
89
            width: 150,
sanmu authored
90
91
92
93
94
            customRender: (column) => {
              const { record } = column || {};

              return record.status === 10 ? '通过' : '拒绝';
            },
sanmu authored
95
          },
sanmu authored
96
97
98
99
100
101
102
103
104
          { title: '拒绝原因', dataIndex: 'refuseRemark', width: 250 },
        ]);
      }

      const [registerTable, { reload }] = useTable({
        api: props.isApproved ? getApprovedListApi : getWaitListApi,
        searchInfo: { type: 10 },

        columns,
sanmu authored
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
        // useSearchForm: true,
        // formConfig: getFormConfig(),
        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
140
141
142
      async function handleDetail(data) {
        openDrawer(true, { data });
        id.value = data.id;
sanmu authored
143
144
145
146
147
148
149
150
151
152
153
154
        fieldInfos.value = (FIELDS_PROFIT_INFO as any)
          .concat({
            label: '利润率',
            field: 'profitRate',
          })
          .map((field) => {
            if (field.field === 'profitType') {
              return {
                label: field.label,
                value: data.fieldInfos.profitAnalysisFields[field.field] == 0 ? '方式1' : '方式2',
              };
            }
sanmu authored
155
156
            return {
              label: field.label,
sanmu authored
157
              value: data.fieldInfos.profitAnalysisFields[field.field],
sanmu authored
158
            };
sanmu authored
159
160
          })
          .filter((item) => !!item.value);
sanmu authored
161
162
163
164
165
166
        baseInfos.value = FIELDS_BASE_INFO.map((field) => {
          return {
            label: field.label,
            value: data.orderBaseInfo[field.field],
          };
        }).filter((item) => !!item.value);
sanmu authored
167
168
      }
sanmu authored
169
170
      async function handleTrue() {
        await approveAuditApi({ status: 10, id: id.value });
sanmu authored
171
        reload();
sanmu authored
172
        closeDrawer();
sanmu authored
173
174
      }
sanmu authored
175
      async function handleFalse() {
sanmu authored
176
177
178
179
        msgVisible.value = true;
        // await approveAuditApi({ status: 20, id: id.value });
        // reload();
        // closeDrawer();
sanmu authored
180
      }
sanmu authored
181
182
183
184

      const role = computed(() => {
        return userStore.getUserInfo?.roleSmallVO?.code;
      });
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
198
199
200
201
202
      return {
        handleProfitModal,
        registerTable,
        checkedKeys,
        currentKey,
        onSelect,
        handleEdit,
        onSelectAll,
sanmu authored
203
204
205
206
        handleDetail,
        registerDrawer,
        fieldInfos,
        baseInfos,
sanmu authored
207
208
        handleTrue,
        handleFalse,
sanmu authored
209
210
        role,
        ROLE,
sanmu authored
211
212
        msgVisible,
        handleMsgModalClose,
sanmu authored
213
214
215
216
      };
    },
  });
</script>