Commit bf93cc5f7f517bac6d05aa76fdc49ea4edf247fd

Authored by sanmu
1 parent 718c52c3

feat: update

.husky/pre-commit
1   -#!/bin/sh
2   -. "$(dirname "$0")/_/husky.sh"
3   -. "$(dirname "$0")/common.sh"
  1 +# #!/bin/sh
  2 +# . "$(dirname "$0")/_/husky.sh"
  3 +# . "$(dirname "$0")/common.sh"
4 4  
5   -[ -n "$CI" ] && exit 0
  5 +# [ -n "$CI" ] && exit 0
6 6  
7   -PATH="/usr/local/bin:$PATH"
  7 +# PATH="/usr/local/bin:$PATH"
8 8  
9   -# Format and submit code according to lintstagedrc.js configuration
10   -pnpm exec lint-staged
  9 +# # Format and submit code according to lintstagedrc.js configuration
  10 +# pnpm exec lint-staged
... ...
src/api/project/approve.ts
1 1 import { find, isEmpty } from 'lodash-es';
2 2 import { defHttp } from '/@/utils/http/axios';
3   -import { FIELDS_BASE_INFO, FIELDS_PROFIT_INFO } from '/@/views/project/order/tableData';
  3 +import {
  4 + FIELDS_BASE_INFO,
  5 + FIELDS_PROFIT_INFO,
  6 + FIELDS_REPORT_INFO,
  7 +} from '/@/views/project/order/tableData';
4 8  
5 9 enum Api {
6 10 APPROVE = '/order/erp/audit/wait_audit_list',
... ... @@ -23,7 +27,6 @@ export const getWaitListApi = async (params: DemoParams) => {
23 27 params,
24 28 });
25 29  
26   - console.log('%c [ ]-26', 'font-size:13px; background:pink; color:#bf2c9f;', 123);
27 30 res.records = res.records.map((item) => {
28 31 item.fields = [];
29 32 !isEmpty(item.fieldInfos.baseFields) &&
... ... @@ -33,21 +36,24 @@ export const getWaitListApi = async (params: DemoParams) => {
33 36 item.fields.push(obj?.label);
34 37 }
35 38 });
36   - !isEmpty(item.fieldInfos.baseFields) &&
37   - Object.entries(item.fieldInfos.profitAnalysisFields).map(([key, value]) => {
  39 + !isEmpty(item.fieldInfos.reportFields) &&
  40 + Object.entries(item.fieldInfos.reportFields).map(([key, value]) => {
  41 + if (value === 'UN_LOCKED') {
  42 + const obj = find(FIELDS_REPORT_INFO, { field: key });
  43 + item.fields.push(obj?.label);
  44 + }
  45 + });
  46 + !isEmpty(item.fieldInfos.reportFields) &&
  47 + Object.entries(item.fieldInfos.reportFields).map(([key, value]) => {
38 48 if (value === 'UN_LOCKED') {
39   - const obj = find(FIELDS_PROFIT_INFO, { field: `profitAnalysisFields.${key}` });
  49 + const obj = find(FIELDS_PROFIT_INFO, { field: key });
40 50 item.fields.push(obj?.label);
41 51 }
42 52 });
  53 +
43 54 item.fields = item.fields.join(',');
44 55 return item;
45 56 });
46   - console.log(
47   - '%c [ res.records ]-27',
48   - 'font-size:13px; background:pink; color:#bf2c9f;',
49   - res.records,
50   - );
51 57  
52 58 return new Promise((resolve) => {
53 59 resolve(res.records);
... ... @@ -57,18 +63,32 @@ export const getWaitListApi = async (params: DemoParams) => {
57 63 export const getApprovedListApi = async (params: any) => {
58 64 const res = await defHttp.post({
59 65 url: Api.APPROVE_ED,
60   -
61 66 params,
62 67 });
63 68  
64 69 res.records = res.records.map((item) => {
65 70 item.fields = [];
66   - Object.entries(item.fieldInfos.baseFields).map(([key, value]) => {
67   - if (value === 'UN_LOCKED') {
68   - const obj = find(FIELDS_BASE_INFO, { field: key });
69   - item.fields.push(obj?.label);
70   - }
71   - });
  71 + !isEmpty(item.fieldInfos.baseFields) &&
  72 + Object.entries(item.fieldInfos.baseFields).map(([key, value]) => {
  73 + if (value === 'UN_LOCKED') {
  74 + const obj = find(FIELDS_BASE_INFO, { field: key });
  75 + item.fields.push(obj?.label);
  76 + }
  77 + });
  78 + !isEmpty(item.fieldInfos.reportFields) &&
  79 + Object.entries(item.fieldInfos.reportFields).map(([key, value]) => {
  80 + if (value === 'UN_LOCKED') {
  81 + const obj = find(FIELDS_REPORT_INFO, { field: key });
  82 + item.fields.push(obj?.label);
  83 + }
  84 + });
  85 + !isEmpty(item.fieldInfos.reportFields) &&
  86 + Object.entries(item.fieldInfos.reportFields).map(([key, value]) => {
  87 + if (value === 'UN_LOCKED') {
  88 + const obj = find(FIELDS_PROFIT_INFO, { field: key });
  89 + item.fields.push(obj?.label);
  90 + }
  91 + });
72 92 item.fields = item.fields.join(',');
73 93 return item;
74 94 });
... ...
src/views/project/approve/ProfitPanel.vue 0 → 100644
  1 +<template>
  2 + <PageWrapper contentBackground>
  3 + <BasicTable @register="registerTable">
  4 + <template #form-custom> custom-slot </template>
  5 + <template #bodyCell="{ column, record }">
  6 + <template v-if="column.key === 'action'">
  7 + <TableAction
  8 + :actions="[
  9 + {
  10 + label: '通过',
  11 + // icon: 'ic:outline-delete-outline',
  12 + onClick: handleTrue.bind(null, record),
  13 + },
  14 + {
  15 + label: '拒绝',
  16 + // icon: 'ic:outline-delete-outline',
  17 + onClick: handleFalse.bind(null, record),
  18 + },
  19 + ]"
  20 + />
  21 + </template>
  22 + </template>
  23 + </BasicTable>
  24 + </PageWrapper>
  25 +</template>
  26 +<script lang="ts">
  27 + import { defineComponent, ref } from 'vue';
  28 + import { BasicTable, useTable, TableAction } from '/@/components/Table';
  29 + import { Tabs } from 'ant-design-vue';
  30 + import { PageWrapper } from '/@/components/Page';
  31 +
  32 + import { approveAuditApi, getWaitListApi } from '/@/api/project/approve';
  33 +
  34 + export default defineComponent({
  35 + components: {
  36 + PageWrapper,
  37 + BasicTable,
  38 + TableAction,
  39 + [Tabs.name]: Tabs,
  40 + [Tabs.TabPane.name]: Tabs.TabPane,
  41 + },
  42 + setup() {
  43 + const checkedKeys = ref<Array<string | number>>([]);
  44 + const currentKey = ref('1');
  45 +
  46 + const [registerTable, { reload }] = useTable({
  47 + api: getWaitListApi,
  48 + searchInfo: { type: 10 },
  49 +
  50 + columns: [
  51 + {
  52 + title: '申请人',
  53 + dataIndex: 'createBy',
  54 + width: 150,
  55 + },
  56 + {
  57 + title: '申请字段',
  58 + dataIndex: 'fields',
  59 + width: 600,
  60 + },
  61 + {
  62 + title: '订单号',
  63 + dataIndex: 'no6',
  64 + },
  65 + {
  66 + title: '订单字段1',
  67 + dataIndex: 'no5',
  68 + },
  69 + {
  70 + title: '订单字段2',
  71 + dataIndex: 'no4',
  72 + },
  73 + {
  74 + title: '订单字段3',
  75 + dataIndex: 'no3',
  76 + },
  77 +
  78 + {
  79 + title: '订单字段5',
  80 + dataIndex: 'no1',
  81 + },
  82 + ],
  83 + // useSearchForm: true,
  84 + // formConfig: getFormConfig(),
  85 + rowKey: 'id',
  86 + actionColumn: {
  87 + width: 160,
  88 + title: 'Action',
  89 + dataIndex: 'action',
  90 + // slots: { customRender: 'action' },
  91 + },
  92 + });
  93 +
  94 + function onSelect(record, selected) {
  95 + if (selected) {
  96 + checkedKeys.value = [...checkedKeys.value, record.id];
  97 + } else {
  98 + checkedKeys.value = checkedKeys.value.filter((id) => id !== record.id);
  99 + }
  100 + }
  101 + function onSelectAll(selected, selectedRows, changeRows) {
  102 + const changeIds = changeRows.map((item) => item.id);
  103 + if (selected) {
  104 + checkedKeys.value = [...checkedKeys.value, ...changeIds];
  105 + } else {
  106 + checkedKeys.value = checkedKeys.value.filter((id) => {
  107 + return !changeIds.includes(id);
  108 + });
  109 + }
  110 + }
  111 + function handleEdit(record, e) {
  112 + e?.stopPropagation();
  113 + return false;
  114 + }
  115 +
  116 + function handleProfitModal() {}
  117 +
  118 + async function handleTrue(record) {
  119 + await approveAuditApi({ status: 10, id: record.id });
  120 + reload();
  121 + }
  122 +
  123 + async function handleFalse(record) {
  124 + await approveAuditApi({ status: 20, id: record.id });
  125 + reload();
  126 + }
  127 +
  128 + return {
  129 + handleProfitModal,
  130 + registerTable,
  131 + checkedKeys,
  132 + currentKey,
  133 + onSelect,
  134 + handleEdit,
  135 + onSelectAll,
  136 + handleTrue,
  137 + handleFalse,
  138 + };
  139 + },
  140 + });
  141 +</script>
... ...
src/views/project/approve/ReportPanel.vue 0 → 100644
  1 +<template>
  2 + <PageWrapper contentBackground>
  3 + <BasicTable @register="registerTable">
  4 + <template #form-custom> custom-slot </template>
  5 + <template #bodyCell="{ column, record }">
  6 + <template v-if="column.key === 'action'">
  7 + <TableAction
  8 + :actions="[
  9 + {
  10 + label: '通过',
  11 + // icon: 'ic:outline-delete-outline',
  12 + onClick: handleTrue.bind(null, record),
  13 + },
  14 + {
  15 + label: '拒绝',
  16 + // icon: 'ic:outline-delete-outline',
  17 + onClick: handleFalse.bind(null, record),
  18 + },
  19 + ]"
  20 + />
  21 + </template>
  22 + </template>
  23 + </BasicTable>
  24 + </PageWrapper>
  25 +</template>
  26 +<script lang="ts">
  27 + import { defineComponent, ref } from 'vue';
  28 + import { BasicTable, useTable, TableAction } from '/@/components/Table';
  29 + import { Tabs } from 'ant-design-vue';
  30 + import { PageWrapper } from '/@/components/Page';
  31 +
  32 + import { approveAuditApi, getWaitListApi, getApprovedListApi } from '/@/api/project/approve';
  33 +
  34 + export default defineComponent({
  35 + components: {
  36 + PageWrapper,
  37 + BasicTable,
  38 + TableAction,
  39 + [Tabs.name]: Tabs,
  40 + [Tabs.TabPane.name]: Tabs.TabPane,
  41 + },
  42 + setup() {
  43 + const checkedKeys = ref<Array<string | number>>([]);
  44 + const currentKey = ref('1');
  45 +
  46 + const [registerTable, { reload }] = useTable({
  47 + api: getWaitListApi,
  48 + searchInfo: { type: 20 },
  49 +
  50 + columns: [
  51 + {
  52 + title: '申请人',
  53 + dataIndex: 'createBy',
  54 + width: 150,
  55 + },
  56 + {
  57 + title: '申请字段',
  58 + dataIndex: 'fields',
  59 + width: 600,
  60 + },
  61 + {
  62 + title: '订单号',
  63 + dataIndex: 'no6',
  64 + },
  65 + {
  66 + title: '订单字段1',
  67 + dataIndex: 'no5',
  68 + },
  69 + {
  70 + title: '订单字段2',
  71 + dataIndex: 'no4',
  72 + },
  73 + {
  74 + title: '订单字段3',
  75 + dataIndex: 'no3',
  76 + },
  77 +
  78 + {
  79 + title: '订单字段5',
  80 + dataIndex: 'no1',
  81 + },
  82 + ],
  83 + // useSearchForm: true,
  84 + // formConfig: getFormConfig(),
  85 + rowKey: 'id',
  86 + actionColumn: {
  87 + width: 160,
  88 + title: 'Action',
  89 + dataIndex: 'action',
  90 + // slots: { customRender: 'action' },
  91 + },
  92 + });
  93 +
  94 + function onSelect(record, selected) {
  95 + if (selected) {
  96 + checkedKeys.value = [...checkedKeys.value, record.id];
  97 + } else {
  98 + checkedKeys.value = checkedKeys.value.filter((id) => id !== record.id);
  99 + }
  100 + }
  101 + function onSelectAll(selected, selectedRows, changeRows) {
  102 + const changeIds = changeRows.map((item) => item.id);
  103 + if (selected) {
  104 + checkedKeys.value = [...checkedKeys.value, ...changeIds];
  105 + } else {
  106 + checkedKeys.value = checkedKeys.value.filter((id) => {
  107 + return !changeIds.includes(id);
  108 + });
  109 + }
  110 + }
  111 + function handleEdit(record, e) {
  112 + e?.stopPropagation();
  113 + return false;
  114 + }
  115 +
  116 + function handleProfitModal() {}
  117 +
  118 + async function handleTrue(record) {
  119 + await approveAuditApi({ status: 10, id: record.id });
  120 + reload();
  121 + }
  122 +
  123 + async function handleFalse(record) {
  124 + await approveAuditApi({ status: 20, id: record.id });
  125 + reload();
  126 + }
  127 +
  128 + return {
  129 + handleProfitModal,
  130 + registerTable,
  131 + checkedKeys,
  132 + currentKey,
  133 + onSelect,
  134 + handleEdit,
  135 + onSelectAll,
  136 + handleTrue,
  137 + handleFalse,
  138 + };
  139 + },
  140 + });
  141 +</script>
... ...
src/views/project/approve/index.vue
... ... @@ -27,6 +27,12 @@
27 27 <a-tab-pane key="2" tab="已审核列表">
28 28 <BasicTable @register="registerTable2" />
29 29 </a-tab-pane>
  30 + <a-tab-pane key="3" tab="利润分析申请">
  31 + <ProfitPanel />
  32 + </a-tab-pane>
  33 + <a-tab-pane key="4" tab="项目报告书申请">
  34 + <ReportPanel />
  35 + </a-tab-pane>
30 36 </a-tabs>
31 37 </template>
32 38 </PageWrapper>
... ... @@ -36,7 +42,8 @@
36 42 import { BasicTable, useTable, TableAction } from '/@/components/Table';
37 43 import { Tabs } from 'ant-design-vue';
38 44 import { PageWrapper } from '/@/components/Page';
39   -
  45 + import ReportPanel from './ReportPanel.vue';
  46 + import ProfitPanel from './ProfitPanel.vue';
40 47 import { approveAuditApi, getWaitListApi, getApprovedListApi } from '/@/api/project/approve';
41 48  
42 49 export default defineComponent({
... ... @@ -46,6 +53,8 @@
46 53 TableAction,
47 54 [Tabs.name]: Tabs,
48 55 [Tabs.TabPane.name]: Tabs.TabPane,
  56 + ReportPanel,
  57 + ProfitPanel,
49 58 },
50 59 setup() {
51 60 const checkedKeys = ref<Array<string | number>>([]);
... ...
src/views/project/order/CheckDetail.vue
... ... @@ -15,29 +15,34 @@
15 15 <BasicForm @register="registerForm" />
16 16 <h3>利润分析</h3>
17 17 <BasicForm @register="registerProfitForm" />
  18 + <h3>项目报告书</h3>
  19 + <BasicForm @register="registerReportForm" />
18 20 </div>
19 21 <!-- <template #titleToolbar> <a-button type="primary"> 申请编辑权限 </a-button></template> -->
20 22  
21   - <template #appendFooter>
  23 + <!-- <template #appendFooter>
22 24 <a-button type="primary" @click="onGoFormDetail"> 返回编辑</a-button>
23   - </template>
  25 + </template> -->
24 26 </BasicDrawer>
25 27 </template>
26 28 <script lang="ts">
27 29 import { defineComponent, reactive, ref } from 'vue';
28   - import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
  30 + import { BasicForm, useForm } from '/@/components/Form/index';
29 31 import { orderAuth } from '/@/api/project/order';
30 32  
31 33 import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
32   - import { FIELDS_BASE_INFO, FIELDS_PROFIT_INFO } from './tableData';
33   - import { cloneDeep, isEmpty, mapValues, mergeWith } from 'lodash-es';
  34 + import { FIELDS_BASE_INFO, FIELDS_PROFIT_INFO, FIELDS_REPORT_INFO } from './tableData';
34 35  
35   - const getSchema = (fields, base) =>
  36 + const getSchema = (fields) =>
36 37 fields.map((item) => ({
37   - field: `${base}.${item.field}`,
38   - dataIndex: `${base}.${item.field}`,
  38 + field: `${item.field}`,
  39 + dataIndex: `${item.field}`,
39 40 label: item.label,
40 41 component: 'Switch',
  42 + componentProps: {
  43 + checkedValue: 'UN_LOCKED',
  44 + unCheckedValue: 'LOCKED',
  45 + },
41 46 colProps: {
42 47 span: 6,
43 48 },
... ... @@ -52,8 +57,9 @@
52 57 },
53 58 setup() {
54 59 const id = ref('');
55   - const schemas = getSchema(FIELDS_BASE_INFO, 'baseFields');
56   - const profitSchemas = getSchema(FIELDS_PROFIT_INFO, 'profitAnalysisFields');
  60 + const schemas = getSchema(FIELDS_BASE_INFO);
  61 + const profitSchemas = getSchema(FIELDS_PROFIT_INFO);
  62 + const reportSchemas = getSchema(FIELDS_REPORT_INFO);
57 63 const [registerForm, { getFieldsValue }] = useForm({
58 64 labelWidth: 120,
59 65 schemas,
... ... @@ -70,45 +76,83 @@
70 76 span: 24,
71 77 },
72 78 });
  79 + const [registerReportForm, { getFieldsValue: getReportFieldsValue }] = useForm({
  80 + labelWidth: 120,
  81 + schemas: reportSchemas,
  82 + showActionButtonGroup: false,
  83 + actionColOptions: {
  84 + span: 24,
  85 + },
  86 + });
73 87 const lockFields = reactive({});
74 88 const [register, { closeDrawer }] = useDrawerInner((data) => {
75 89 Object.assign(lockFields, data.lockFields);
76 90 id.value = data.id;
77 91 });
78 92  
79   - function customizer(objValue, srcValue, key) {
80   - // 检查是否在 baseFields 内以及值是否为 true
81   - if (srcValue === true) {
82   - return 'UN_LOCKED';
83   - }
84   - return objValue; // 如果不需要改变,返回原值
85   - }
86 93 const handleSubmit = async () => {
87 94 const baseFieldValues = getFieldsValue();
88 95 const profitFieldValues = getProfitFieldsValue();
  96 + const reportFieldValues = getReportFieldsValue();
89 97  
90   - !isEmpty(baseFieldValues) &&
91   - Object.keys(baseFieldValues.baseFields)?.map((key) => {
92   - baseFieldValues.baseFields[key] = baseFieldValues.baseFields[key]
93   - ? 'UN_LOCKED'
94   - : 'LOCKED';
95   - });
  98 + FIELDS_BASE_INFO.map(
  99 + ({ field }) =>
  100 + (baseFieldValues[field] =
  101 + baseFieldValues[field] === 'UN_LOCKED' ? 'UN_LOCKED' : 'LOCKED'),
  102 + );
96 103  
97   - !isEmpty(profitFieldValues) &&
98   - Object.keys(profitFieldValues.profitAnalysisFields).map((key) => {
99   - profitFieldValues.profitAnalysisFields[key] = profitFieldValues.profitAnalysisFields[
100   - key
101   - ]
102   - ? 'UN_LOCKED'
103   - : 'LOCKED';
104   - });
  104 + FIELDS_REPORT_INFO.map(
  105 + ({ field }) =>
  106 + (reportFieldValues[field] =
  107 + reportFieldValues[field] === 'UN_LOCKED' ? 'UN_LOCKED' : 'LOCKED'),
  108 + );
105 109  
106   - const values = Object.assign({ orderId: id.value }, baseFieldValues, profitFieldValues);
107   - console.log('%c [ values ]-103', 'font-size:13px; background:pink; color:#bf2c9f;', values);
  110 + FIELDS_PROFIT_INFO.map(
  111 + ({ field }) =>
  112 + (profitFieldValues[field] =
  113 + profitFieldValues[field] === 'UN_LOCKED' ? 'UN_LOCKED' : 'LOCKED'),
  114 + );
  115 +
  116 + // !isEmpty(baseFieldValues) &&
  117 + // Object.keys(baseFieldValues.baseFields)?.map((key) => {
  118 + // baseFieldValues.baseFields[key] = baseFieldValues.baseFields[key]
  119 + // ? 'UN_LOCKED'
  120 + // : 'LOCKED';
  121 + // });
  122 +
  123 + // !isEmpty(profitFieldValues) &&
  124 + // Object.keys(profitFieldValues.profitAnalysisFields).map((key) => {
  125 + // profitFieldValues.profitAnalysisFields[key] = profitFieldValues.profitAnalysisFields[
  126 + // key
  127 + // ]
  128 + // ? 'UN_LOCKED'
  129 + // : 'LOCKED';
  130 + // });
  131 +
  132 + // !isEmpty(reportFieldValues) &&
  133 + // Object.keys(reportFieldValues.reportFields).map((key) => {
  134 + // reportFieldValues.reportFields[key] = reportFieldValues.reportFields[key]
  135 + // ? 'UN_LOCKED'
  136 + // : 'LOCKED';
  137 + // });
  138 +
  139 + const values = Object.assign(
  140 + { orderId: id.value },
  141 + { baseFields: baseFieldValues },
  142 + { profitAnalysisFields: profitFieldValues },
  143 + { reportFields: reportFieldValues },
  144 + );
108 145 await orderAuth(values);
109 146 closeDrawer();
110 147 };
111   - return { register, schemas, registerForm, registerProfitForm, handleSubmit };
  148 + return {
  149 + register,
  150 + schemas,
  151 + registerForm,
  152 + registerProfitForm,
  153 + registerReportForm,
  154 + handleSubmit,
  155 + };
112 156 },
113 157 });
114 158 </script>
... ...
src/views/project/order/FormDetail.vue
... ... @@ -21,13 +21,13 @@
21 21 <ProfitFormPanel ref="profitFormPanelRef" :id="id" />
22 22 </TabPanel>
23 23 <TabPanel key="3" tab="项目报告书" :forceRender="true">
24   - <ReportFormPanel ref="ReportFormPanelRef" />
  24 + <ReportFormPanel ref="reportFormPanelRef" :id="id" />
25 25 </TabPanel>
26 26 <TabPanel key="4" tab="跟单信息" :forceRender="true">
27   - <TrackFormPanel ref="TrackFormPanelRef" />
  27 + <TrackFormPanel ref="trackFormPanelRef" :id="id" />
28 28 </TabPanel>
29 29 <TabPanel key="5" tab="质检信息" :forceRender="true">
30   - <InspectionFormPanel ref="InspectionFormRef" />
  30 + <InspectionFormPanel ref="inspectionFormRef" :id="id" />
31 31 </TabPanel>
32 32 </Tabs>
33 33 <!-- <BasicForm @register="registerForm" />
... ... @@ -41,14 +41,14 @@
41 41 </BasicDrawer>
42 42 </template>
43 43 <script lang="ts">
44   - import { computed, defineComponent, reactive, ref, toRaw, watch, watchEffect } from 'vue';
  44 + import { computed, defineComponent, reactive, ref, toRaw, watch, toRefs } from 'vue';
45 45 import { BasicForm, FormActionType, FormSchema, useForm } from '/@/components/Form/index';
46 46 import { orderCreate, orderUpdate, uploadImg } from '/@/api/project/order';
47 47 import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
48 48 import { useOrderStoreWithOut } from '/@/store/modules/order';
49 49 import { useOrderInfo } from '/@/hooks/component/order';
50 50 import { dateUtil } from '/@/utils/dateUtil';
51   - import { FIELDS_REPORT_INFO } from './tableData';
  51 + import {} from './tableData';
52 52 import ProfitFormPanel from './component/ProfitFormPanel.vue';
53 53 import ReportFormPanel from './component/ReportFormPanel.vue';
54 54 import TrackFormPanel from './component/TrackFormPanel.vue';
... ... @@ -82,10 +82,10 @@
82 82 setup(_, { emit }) {
83 83 const orderStore = useOrderStoreWithOut();
84 84 const activeKey = ref('1');
85   - const profitFormPanelRef = ref(null);
86   - const ReportFormPanelRef = ref(null);
87   - const TrackFormPanelRef = ref(null);
88   - const InspectionFormPanelRef = ref(null);
  85 + const profitFormPanelRef = ref();
  86 + const reportFormPanelRef = ref();
  87 + const trackFormPanelRef = ref(null);
  88 + const inspectionFormPanelRef = ref(null);
89 89  
90 90 const {
91 91 customerCode,
... ... @@ -119,6 +119,12 @@
119 119 };
120 120  
121 121 const schemas = computed(() => {
  122 + console.log(
  123 + '%c [ fields?.baseFields ]-134',
  124 + 'font-size:13px; background:pink; color:#bf2c9f;',
  125 + fields?.baseFields,
  126 + );
  127 +
122 128 return [
123 129 {
124 130 field: 'baseInfo.customerCode',
... ... @@ -356,24 +362,7 @@
356 362 },
357 363 ];
358 364 });
359   - const reportSchemas = computed(() => {
360   - return FIELDS_REPORT_INFO.map((item) => {
361   - return {
362   - field: `reportInfo.${item.field}`,
363   - component: item.component,
364   - label: item.label,
365   - rules: [{ required: true }],
366   - colProps: {
367   - span: 24,
368   - },
369   - componentProps: {
370   - disabled: getDisable(fields?.baseFields.customerCode),
371   - },
372   - };
373   - });
374   - });
375   -
376   - const [registerForm, { setFieldsValue, getFieldsValue, reload }] = useForm({
  365 + const [registerForm, { setFieldsValue, getFieldsValue, resetFields }] = useForm({
377 366 labelWidth: 120,
378 367 schemas,
379 368 showActionButtonGroup: false,
... ... @@ -383,6 +372,18 @@
383 372 });
384 373  
385 374 const [register, { closeDrawer }] = useDrawerInner((data) => {
  375 + if (!data.id) {
  376 + id.value = '';
  377 + picUrl.value = '';
  378 + // 新建
  379 + resetFields();
  380 + profitFormPanelRef?.value?.resetFields();
  381 + reportFormPanelRef?.value?.resetFields();
  382 + trackFormPanelRef?.value?.resetFields();
  383 + inspectionFormPanelRef?.value?.resetFields();
  384 +
  385 + return;
  386 + }
386 387 id.value = data.id;
387 388  
388 389 // 方式1
... ... @@ -402,12 +403,15 @@
402 403 baseInfo: { ...toRaw(data) },
403 404 });
404 405  
405   - profitFormPanelRef.value.fields.profitAnalysisInfo =
406   - { ...data.lockFields?.profitAnalysisFields } || {};
  406 + profitFormPanelRef.value.fields = { ...data.lockFields?.profitAnalysisFields } || {};
407 407  
408 408 profitFormPanelRef?.value?.setFieldsValue({
409 409 ...toRaw(data.profitAnalysisInfo),
410   - profitAnalysisInfo: { ...toRaw(data.profitAnalysisInfo) },
  410 + });
  411 +
  412 + reportFormPanelRef.value.fields = { ...data.lockFields?.reportFields } || {};
  413 + reportFormPanelRef?.value?.setFieldsValue({
  414 + ...toRaw(data.reportInfo),
411 415 });
412 416 } else {
413 417 setFieldsValue({});
... ... @@ -422,30 +426,39 @@
422 426 picUrl: picUrl?.value || '',
423 427 };
424 428 if (id.value) {
425   - values.orderId = id.value;
  429 + const forms = { orderId: id.value } as any;
  430 + if (activeKey.value === '1') {
  431 + forms.baseInfo = { ...values.baseInfo };
  432 + } else if (activeKey.value === '2') {
  433 + const v = profitFormPanelRef?.value?.getFieldsValue() || {};
  434 + forms.profitAnalysisInfo = { ...v };
  435 + } else if (activeKey.value === '3') {
  436 + const v = reportFormPanelRef?.value?.getFieldsValue() || {};
  437 + forms.reportInfo = { ...v };
  438 + }
426 439  
427   - await orderUpdate(values);
  440 + await orderUpdate(forms);
428 441 } else {
429   - const v2 = profitFormPanelRef?.value?.getFieldsValue() || { profitAnalysisInfo: {} };
430   - const v3 = ReportFormPanelRef?.value?.getFieldsValue() || { reportInfo: {} };
431   - const v4 = TrackFormPanelRef?.value?.getFieldsValue() || { trackStageInfo: {} };
432   - const v5 = InspectionFormPanelRef?.value?.getFieldsValue() || { inspectionStageInfo: {} };
  442 + const v2 = profitFormPanelRef?.value?.getFieldsValue() || {};
  443 + const v3 = reportFormPanelRef?.value?.getFieldsValue() || {};
  444 + const v4 = trackFormPanelRef?.value?.getFieldsValue() || {};
  445 + const v5 = inspectionFormPanelRef?.value?.getFieldsValue() || {};
433 446  
434   - values.profitAnalysisInfo = { ...v2.profitAnalysisInfo };
435   - values.reportInfo = { ...v3.reportInfo };
436   - values.trackStageInfo = { ...v4.trackStageInfo };
437   - values.inspectionStageInfo = { ...v5.inspectionStageInfo };
  447 + values.profitAnalysisInfo = { ...v2 };
  448 + values.reportInfo = { ...v3 };
  449 + values.trackStageInfo = { ...v4 };
  450 + values.inspectionStageInfo = { ...v5 };
438 451 await orderCreate(values);
439 452 }
440 453 closeDrawer();
441   - emit('success', {});
  454 + // emit('success', {});
442 455 };
443 456 return {
444 457 id,
445 458 profitFormPanelRef,
446   - ReportFormPanelRef,
447   - TrackFormPanelRef,
448   - InspectionFormPanelRef,
  459 + reportFormPanelRef,
  460 + trackFormPanelRef,
  461 + inspectionFormPanelRef,
449 462 activeKey,
450 463 formRef,
451 464 schemas,
... ...
src/views/project/order/component/ProfitFormPanel.vue
... ... @@ -3,8 +3,7 @@
3 3 </template>
4 4 <script lang="ts">
5 5 import { computed, defineComponent, reactive, ref, toRaw } from 'vue';
6   - import { BasicForm, FormActionType, useForm } from '/@/components/Form/index';
7   - import { orderCreate, orderUpdate } from '/@/api/project/order';
  6 + import { BasicForm, useForm } from '/@/components/Form/index';
8 7 import { dateUtil } from '/@/utils/dateUtil';
9 8 import { FIELDS_PROFIT_INFO } from '../tableData';
10 9 import { getDisable } from '/@/utils/project';
... ... @@ -26,22 +25,16 @@
26 25 },
27 26 emits: ['success'],
28 27 setup(props, { emit }) {
29   - console.log('%c [ props ]-29', 'font-size:13px; background:pink; color:#bf2c9f;', props);
30   - let fields = reactive({ profitAnalysisInfo: {} });
  28 + let fields = ref({});
31 29  
32 30 const schemas = computed(() => {
33 31 return FIELDS_PROFIT_INFO.map((item) => {
34   - console.log(
35   - '%c [ ]-31',
36   - 'font-size:13px; background:pink; color:#bf2c9f;',
37   - get(fields, `${item.field}`),
38   - getDisable(get(fields, `${item.field}`), props.id),
39   - );
40 32 return {
41 33 ...item,
  34 + field: `${item.field}`,
42 35 componentProps: {
43 36 ...item.componentProps,
44   - disabled: getDisable(get(fields, `${item.field}`), props.id),
  37 + disabled: getDisable(get(fields.value, `${item.field}`), props.id),
45 38 },
46 39 colProps: {
47 40 span: 24,
... ... @@ -50,7 +43,7 @@
50 43 });
51 44 });
52 45  
53   - const [registerForm, { setFieldsValue, getFieldsValue, reload }] = useForm({
  46 + const [registerForm, { setFieldsValue, getFieldsValue }] = useForm({
54 47 labelWidth: 120,
55 48 schemas,
56 49 showActionButtonGroup: false,
... ...
src/views/project/order/component/ReportFormPanel.vue
... ... @@ -2,13 +2,11 @@
2 2 <BasicForm @register="registerForm" />
3 3 </template>
4 4 <script lang="ts">
5   - import { computed, defineComponent, reactive, ref, toRaw } from 'vue';
6   - import { BasicForm, FormActionType, useForm } from '/@/components/Form/index';
7   - import { dateUtil } from '/@/utils/dateUtil';
  5 + import { computed, defineComponent, ref } from 'vue';
  6 + import { BasicForm, useForm } from '/@/components/Form/index';
8 7 import { FIELDS_REPORT_INFO } from '../tableData';
9 8 import { getDisable } from '/@/utils/project';
10 9 import { useOrderStoreWithOut } from '/@/store/modules/order';
11   - import { useDrawerInner } from '/@/components/Drawer';
12 10  
13 11 import { useOrderInfo } from '/@/hooks/component/order';
14 12  
... ... @@ -22,10 +20,13 @@
22 20 onGoCheckDetail: {
23 21 type: Function,
24 22 },
  23 + id: {
  24 + type: String,
  25 + },
25 26 },
26 27 emits: ['success'],
27   - setup(_, { emit }) {
28   - let fields = reactive({ baseFields: {}, profitAnalysisInfo: {} });
  28 + setup(props) {
  29 + let fields = ref({});
29 30 const orderStore = useOrderStoreWithOut();
30 31  
31 32 const { ideaSource, manualPreform } = useOrderInfo(orderStore);
... ... @@ -35,19 +36,24 @@
35 36 ideaSource,
36 37 manualPreform,
37 38 };
38   - return FIELDS_REPORT_INFO.map((item) => ({
39   - ...item,
40   - componentProps: {
41   - ...(item.component === 'Select' && { options: options[item.optionField] }),
42   - disabled: getDisable(`fields.${item.field}`),
43   - },
44   - colProps: {
45   - span: 24,
46   - },
47   - }));
  39 +
  40 + const res = FIELDS_REPORT_INFO.map((item) => {
  41 + return {
  42 + ...item,
  43 + field: `${item.field}`,
  44 + componentProps: {
  45 + ...(item.component === 'Select' && { options: options[item.optionField] }),
  46 + disabled: getDisable(fields.value[item.field], props.id),
  47 + },
  48 + colProps: {
  49 + span: 24,
  50 + },
  51 + };
  52 + });
  53 + return res;
48 54 });
49 55  
50   - const [registerForm, { setFieldsValue, getFieldsValue, reload }] = useForm({
  56 + const [registerForm, { setFieldsValue, getFieldsValue }] = useForm({
51 57 labelWidth: 120,
52 58 schemas,
53 59 showActionButtonGroup: false,
... ... @@ -56,29 +62,7 @@
56 62 },
57 63 });
58 64  
59   - const [register, { closeDrawer }] = useDrawerInner((data) => {
60   - // 方式1
61   - data.orderHodTime = data.orderHodTime ? dateUtil(data.orderHodTime) : null;
62   - data.productionDepartmentConsignTime = data.productionDepartmentConsignTime
63   - ? dateUtil(data.productionDepartmentConsignTime)
64   - : null;
65   -
66   - fields.baseFields = {
67   - ...fields.baseFields,
68   - ...data.lockFields.baseFields,
69   - };
70   -
71   - if (id.value) {
72   - setFieldsValue({
73   - ...toRaw(data),
74   - baseInfo: { ...toRaw(data) },
75   - });
76   - } else {
77   - setFieldsValue({});
78   - }
79   - });
80   -
81   - return { register, schemas, registerForm, getFieldsValue };
  65 + return { fields, schemas, registerForm, getFieldsValue, setFieldsValue };
82 66 },
83 67 });
84 68 </script>
... ...
src/views/project/order/index.vue
... ... @@ -201,7 +201,7 @@
201 201 }
202 202  
203 203 function handleAdd() {
204   - openFormDetailDrawer(true);
  204 + openFormDetailDrawer(true, {});
205 205 }
206 206  
207 207 function handleCheck(record, e) {
... ... @@ -254,6 +254,8 @@
254 254 };
255 255  
256 256 return {
  257 + SELECT_FIELD_COLUMNS,
  258 +
257 259 fieldDetailRegister,
258 260 profitModalRegister,
259 261 historyDetailRegister,
... ... @@ -274,7 +276,6 @@
274 276 handleGoFormDetail,
275 277 handleHistory,
276 278 handleAdd,
277   - SELECT_FIELD_COLUMNS,
278 279 createImgPreview,
279 280 handleExport,
280 281 handlePreview,
... ...
src/views/project/order/tableData.tsx
... ... @@ -112,21 +112,34 @@ export function getOrderColumns() {
112 112 {
113 113 title: '项目完成报告信息',
114 114 width: 150,
  115 + dataIndex: 'reportInfo',
115 116 children: [
116 117 {
117 118 title: '想法来源',
118 119 width: 150,
119   - dataIndex: 'ideaSource',
  120 + dataIndex: 'reportInfo.ideaSource',
  121 + customRender: (column) => {
  122 + const { record } = column || {};
  123 + return record?.reportInfo?.ideaSource;
  124 + },
120 125 },
121 126 {
122 127 title: '手工初型',
123 128 width: 150,
124   - dataIndex: 'manualPreform',
  129 + dataIndex: 'reportInfo.manualPreform',
  130 + customRender: (column) => {
  131 + const { record } = column || {};
  132 + return record?.reportInfo?.manualPreform;
  133 + },
125 134 },
126 135 {
127 136 title: '想法和手工比例分配',
128 137 width: 150,
129   - dataIndex: 'ideaManualRate',
  138 + dataIndex: 'reportInfo.ideaManualRate',
  139 + customRender: (column) => {
  140 + const { record } = column || {};
  141 + return record?.reportInfo?.ideaManualRate;
  142 + },
130 143 },
131 144 ],
132 145 },
... ... @@ -466,21 +479,21 @@ export const FIELDS_BASE_INFO = [
466 479 //项目完成报告信息
467 480 export const FIELDS_REPORT_INFO = [
468 481 {
469   - field: 'reportInfo.ideaSource',
  482 + field: 'ideaSource',
470 483 component: 'Select',
471 484 optionField: 'ideaSource',
472 485 label: '想法来源',
473 486 rules: [{ required: true }],
474 487 },
475 488 {
476   - field: 'reportInfo.manualPreform',
  489 + field: 'manualPreform',
477 490 component: 'Select',
478 491 optionField: 'manualPreform',
479 492 label: '手工初型',
480 493 rules: [{ required: true }],
481 494 },
482 495 {
483   - field: 'reportInfo.ideaManualRate',
  496 + field: 'ideaManualRate',
484 497 component: 'Input',
485 498 label: '想法和手工比例分配',
486 499 rules: [{ required: true }],
... ... @@ -615,13 +628,13 @@ export const FIELDS_TRACK_STAGE_INFO = [
615 628 // 利润分析
616 629 export const FIELDS_PROFIT_INFO = [
617 630 {
618   - field: 'profitAnalysisInfo.customerPrice',
  631 + field: 'customerPrice',
619 632 component: 'InputNumber',
620 633 label: '客户单价',
621 634 rules: [{ required: true }],
622 635 },
623 636 {
624   - field: 'profitAnalysisInfo.customerCurrency',
  637 + field: 'customerCurrency',
625 638 component: 'Select',
626 639 label: '客户单价单位',
627 640 rules: [{ required: true }],
... ... @@ -633,13 +646,13 @@ export const FIELDS_PROFIT_INFO = [
633 646 },
634 647 },
635 648 {
636   - field: 'profitAnalysisInfo.customerTotalPrice',
  649 + field: 'customerTotalPrice',
637 650 component: 'InputNumber',
638 651 label: '客户总价',
639 652 rules: [{ required: true }],
640 653 },
641 654 {
642   - field: 'profitAnalysisInfo.customerTotalCurrency',
  655 + field: 'customerTotalCurrency',
643 656 component: 'Select',
644 657 label: '客户总价单位',
645 658 rules: [{ required: true }],
... ... @@ -651,7 +664,7 @@ export const FIELDS_PROFIT_INFO = [
651 664 },
652 665 },
653 666 {
654   - field: 'profitAnalysisInfo.productionDepartmentPrice',
  667 + field: 'productionDepartmentPrice',
655 668 component: 'InputNumber',
656 669 label: '生成科单价¥',
657 670 rules: [{ required: true }],
... ... @@ -671,13 +684,13 @@ export const FIELDS_PROFIT_INFO = [
671 684 {
672 685 label: '包装费用合计$',
673 686 component: 'InputNumber',
674   - field: 'profitAnalysisInfo.packetTotalPrice',
  687 + field: 'packetTotalPrice',
675 688 rules: [{ required: true }],
676 689 },
677 690 {
678 691 label: '包装费用合计单位',
679 692 component: 'Select',
680   - field: 'profitAnalysisInfo.packetCurrency',
  693 + field: 'packetCurrency',
681 694 rules: [{ required: true }],
682 695 componentProps: {
683 696 options: [
... ... @@ -689,7 +702,7 @@ export const FIELDS_PROFIT_INFO = [
689 702 {
690 703 label: '汇率',
691 704 component: 'InputNumber',
692   - field: 'profitAnalysisInfo.exchangeRate',
  705 + field: 'exchangeRate',
693 706 rules: [{ required: true }],
694 707 },
695 708 // {
... ...