Blame view

src/views/project/order/CheckDetail.vue 7.39 KB
sanmu authored
1
2
3
4
5
6
7
<template>
  <BasicDrawer
    @register="register"
    v-bind="$attrs"
    showFooter
    title="字段编辑权限申请"
    width="60%"
sanmu authored
8
    :destroyOnClose="true"
sanmu authored
9
10
11
12
13
14
    :isDetail="true"
    @ok="handleSubmit"
    :showDetailBack="false"
    okText="申请"
    ><input />
    <div>
sanmu authored
15
16
17
18
      <template v-if="role === ROLE.ADMIN || role === ROLE.TRACKER">
        <h3>基本信息</h3>
        <BasicForm @register="registerForm" />
      </template>
sanmu authored
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
      <template v-if="role === ROLE.ADMIN || role === ROLE.BUSINESS">
        <h3>利润分析</h3>
        <BasicForm @register="registerProfitForm" />
      </template>
      <template v-if="role === ROLE.ADMIN || role === ROLE.BUSINESS">
        <h3>项目报告书</h3>
        <BasicForm @register="registerReportForm" />
      </template>
      <template v-if="role === ROLE.ADMIN || role === ROLE.TRACKER">
        <h3>跟单信息</h3>
        <BasicForm @register="registerTrackForm" />
      </template>
      <template v-if="role === ROLE.ADMIN || role === ROLE.INSPECT">
        <h3>质量信息</h3>
        <BasicForm @register="registryInspectForm" />
      </template>
sanmu authored
35
36
37
    </div>
    <!-- <template #titleToolbar> <a-button type="primary"> 申请编辑权限 </a-button></template> -->
sanmu authored
38
    <!-- <template #appendFooter>
sanmu authored
39
      <a-button type="primary" @click="onGoFormDetail"> 返回编辑</a-button>
sanmu authored
40
    </template> -->
sanmu authored
41
42
43
  </BasicDrawer>
</template>
<script lang="ts">
sanmu authored
44
  import { computed, defineComponent, reactive, ref } from 'vue';
sanmu authored
45
  import { BasicForm, useForm } from '/@/components/Form/index';
sanmu authored
46
  import { orderAuth } from '/@/api/project/order';
sanmu authored
47
  import { ROLE } from './type.d';
sanmu authored
48
49

  import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
sanmu authored
50
51
52
53
54
55
56
57
  import {
    FIELDS_BASE_INFO,
    FIELDS_INSPECTION_INFO,
    FIELDS_PROFIT_INFO,
    FIELDS_REPORT_INFO,
    FIELDS_TRACK_STAGE_INFO,
  } from './tableData';
  import { useUserStoreWithOut } from '/@/store/modules/user';
sanmu authored
58
sanmu authored
59
  const userStore = useUserStoreWithOut();
sanmu authored
60
  const getSchema = (fields) =>
sanmu authored
61
62
63
64
65
66
67
68
69
70
71
72
73
74
    fields
      .map((item) => ({
        field: `${item.field}`,
        dataIndex: `${item.field}`,
        label: item.label,
        component: 'Switch',
        componentProps: {
          checkedValue: 'UN_LOCKED',
          unCheckedValue: 'LOCKED',
        },
        colProps: {
          span: 6,
        },
      }))
sanmu authored
75
76
      .filter(
        (item) =>
77
78
          // item.field !== 'packetPrice' &&
          item.field !== 'exchangeRate' && item.field !== 'profitRate',
sanmu authored
79
      );
sanmu authored
80
81
82
83
84
85
86
87
88
89

  export default defineComponent({
    components: { BasicDrawer, BasicForm },
    props: {
      onGoFormDetail: {
        type: Function,
      },
    },
    setup() {
      const id = ref('');
sanmu authored
90
91
92
      const schemas = getSchema(FIELDS_BASE_INFO);
      const profitSchemas = getSchema(FIELDS_PROFIT_INFO);
      const reportSchemas = getSchema(FIELDS_REPORT_INFO);
sanmu authored
93
94
      const inspecSchemas = getSchema(FIELDS_INSPECTION_INFO);
      const trackSchemas = getSchema(FIELDS_TRACK_STAGE_INFO);
sanmu authored
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
      const [registerForm, { getFieldsValue }] = useForm({
        labelWidth: 120,
        schemas,
        showActionButtonGroup: false,
        actionColOptions: {
          span: 24,
        },
      });
      const [registerProfitForm, { getFieldsValue: getProfitFieldsValue }] = useForm({
        labelWidth: 120,
        schemas: profitSchemas,
        showActionButtonGroup: false,
        actionColOptions: {
          span: 24,
        },
      });
sanmu authored
111
112
113
114
115
116
117
118
      const [registerReportForm, { getFieldsValue: getReportFieldsValue }] = useForm({
        labelWidth: 120,
        schemas: reportSchemas,
        showActionButtonGroup: false,
        actionColOptions: {
          span: 24,
        },
      });
sanmu authored
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
      const [registryInspectForm, { getFieldsValue: getInspectFieldsValue }] = useForm({
        labelWidth: 120,
        schemas: inspecSchemas,
        showActionButtonGroup: false,
        actionColOptions: {
          span: 24,
        },
      });
      const [registerTrackForm, { getFieldsValue: getTrackFieldsValue }] = useForm({
        labelWidth: 120,
        schemas: trackSchemas,
        showActionButtonGroup: false,
        actionColOptions: {
          span: 24,
        },
      });
sanmu authored
135
136
137
138
139
140
      const lockFields = reactive({});
      const [register, { closeDrawer }] = useDrawerInner((data) => {
        Object.assign(lockFields, data.lockFields);
        id.value = data.id;
      });
sanmu authored
141
142
143
144
      const role = computed(() => {
        return userStore.getUserInfo?.roleSmallVO?.code;
      });
sanmu authored
145
146
147
      const handleSubmit = async () => {
        const baseFieldValues = getFieldsValue();
        const profitFieldValues = getProfitFieldsValue();
sanmu authored
148
        const reportFieldValues = getReportFieldsValue();
sanmu authored
149
150
        const inspectFieldValues = getInspectFieldsValue();
        const trackFieldValues = getTrackFieldsValue();
sanmu authored
151
sanmu authored
152
153
154
155
156
157
158
        if (baseFieldValues) {
          FIELDS_BASE_INFO.map(
            ({ field }) =>
              (baseFieldValues[field] =
                baseFieldValues[field] === 'UN_LOCKED' ? 'UN_LOCKED' : 'LOCKED'),
          );
        }
sanmu authored
159
sanmu authored
160
161
162
163
164
165
        if (reportFieldValues)
          FIELDS_REPORT_INFO.map(
            ({ field }) =>
              (reportFieldValues[field] =
                reportFieldValues[field] === 'UN_LOCKED' ? 'UN_LOCKED' : 'LOCKED'),
          );
sanmu authored
166
sanmu authored
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
        if (profitFieldValues)
          FIELDS_PROFIT_INFO.map(
            ({ field }) =>
              (profitFieldValues[field] =
                profitFieldValues[field] === 'UN_LOCKED' ? 'UN_LOCKED' : 'LOCKED'),
          );
        if (trackFieldValues)
          FIELDS_TRACK_STAGE_INFO.map(
            ({ field }) =>
              (trackFieldValues[field] =
                trackFieldValues[field] === 'UN_LOCKED' ? 'UN_LOCKED' : 'LOCKED'),
          );

        if (inspectFieldValues)
          FIELDS_INSPECTION_INFO.map(
            ({ field }) =>
              (inspectFieldValues[field] =
                inspectFieldValues[field] === 'UN_LOCKED' ? 'UN_LOCKED' : 'LOCKED'),
          );
sanmu authored
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214

        // !isEmpty(baseFieldValues) &&
        //   Object.keys(baseFieldValues.baseFields)?.map((key) => {
        //     baseFieldValues.baseFields[key] = baseFieldValues.baseFields[key]
        //       ? 'UN_LOCKED'
        //       : 'LOCKED';
        //   });

        // !isEmpty(profitFieldValues) &&
        //   Object.keys(profitFieldValues.profitAnalysisFields).map((key) => {
        //     profitFieldValues.profitAnalysisFields[key] = profitFieldValues.profitAnalysisFields[
        //       key
        //     ]
        //       ? 'UN_LOCKED'
        //       : 'LOCKED';
        //   });

        // !isEmpty(reportFieldValues) &&
        //   Object.keys(reportFieldValues.reportFields).map((key) => {
        //     reportFieldValues.reportFields[key] = reportFieldValues.reportFields[key]
        //       ? 'UN_LOCKED'
        //       : 'LOCKED';
        //   });

        const values = Object.assign(
          { orderId: id.value },
          { baseFields: baseFieldValues },
          { profitAnalysisFields: profitFieldValues },
          { reportFields: reportFieldValues },
sanmu authored
215
216
          { trackStageFields: trackFieldValues },
          { inspectionStageFields: inspectFieldValues },
sanmu authored
217
        );
sanmu authored
218
219
220
        await orderAuth(values);
        closeDrawer();
      };
sanmu authored
221
222
223
224
225
226
      return {
        register,
        schemas,
        registerForm,
        registerProfitForm,
        registerReportForm,
sanmu authored
227
228
        registryInspectForm,
        registerTrackForm,
sanmu authored
229
        handleSubmit,
sanmu authored
230
231
        ROLE,
        role,
sanmu authored
232
      };
sanmu authored
233
234
235
    },
  });
</script>