sanmu
authored
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
<template>
<BasicModal
v-bind="$attrs"
destroyOnClose
@register="register"
title="创建配置"
width="600px"
@visible-change="handleShow"
@ok="handleOk"
>
<BasicForm @register="registerForm" />
</BasicModal>
</template>
<script lang="ts">
import { defineComponent, ref, defineEmits } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { orderGravity } from '/@/api/project/order';
import { useOrderStoreWithOut } from '/@/store/modules/order';
import { useOrderInfo } from '/@/hooks/component/order';
import { BasicForm, useForm } from '/@/components/Form/index';
import { addConfig } from '/@/api/sys/config';
export default defineComponent({
components: { BasicModal, BasicForm },
props: {
column: { type: Number },
},
emits: ['modal-success'],
setup(props, { emit }) {
const orderStore = useOrderStoreWithOut();
const { manualPreform, exchangeRate } = useOrderInfo(orderStore);
const loading = ref(true);
const activeUser = ref();
const info = ref();
const searchData = ref({});
const [register, { setModalProps, closeModal }] = useModalInner(async (data) => {
searchData.value = data.data || {};
activeUser.value = undefined;
info.value = '';
});
|
|
42
43
|
const { customerCode: customerCodeOptions, productionDepartment: productDepartmentOptions } =
useOrderInfo(orderStore);
|
sanmu
authored
|
44
|
var [registerForm, { getFieldsValue, validate }] = useForm({
|
柏杨
authored
|
45
|
labelWidth: 100,
|
|
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
// schemas: [
// {
// field: 'settingValue',
// component: 'Select',
// label: '客户编码',
// rules: [{ required: true }],
// componentProps: {
// options: customerCodeOptions,
// },
// colProps: {
// span: 24,
// },
// },
// {
// field: 'relationValue',
// component: 'InputNumber',
// label:
// props.column === 1
// ? '利润率'
// : props.column === 2
// ? '包装费用'
// : props.column === 5
// ? '最后回款日期'
// : props.column === 7
// ? '销售额'
// : '生产科回款日期',
// rules: [{ required: true }],
// colProps: {
// span: 24,
// },
// },
// ],
|
sanmu
authored
|
78
79
80
81
|
schemas: [
{
field: 'settingValue',
component: 'Select',
|
|
82
|
label: props.column === 8 ? '生产科' : '客户编码',
|
sanmu
authored
|
83
84
|
rules: [{ required: true }],
componentProps: {
|
|
85
|
options: props.column === 8 ? productDepartmentOptions : customerCodeOptions,
|
sanmu
authored
|
86
87
88
89
90
91
92
93
|
},
colProps: {
span: 24,
},
},
{
field: 'relationValue',
component: 'InputNumber',
|
柏杨
authored
|
94
95
96
97
98
99
100
|
label:
props.column === 1
? '利润率'
: props.column === 2
? '包装费用'
: props.column === 5
? '最后回款日期'
|
|
101
102
103
|
: props.column === 7
? '销售额'
: '生产科回款日期',
|
sanmu
authored
|
104
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
140
|
rules: [{ required: true }],
colProps: {
span: 24,
},
},
],
showActionButtonGroup: false,
actionColOptions: {
span: 24,
},
});
function handleShow(visible: boolean) {
if (visible) {
loading.value = true;
// setModalProps({ loading: true, confirmLoading: true });
setModalProps({ loading: false, confirmLoading: false });
}
}
async function handleCalc() {
const res = await orderGravity({
...searchData.value,
designer: activeUser.value,
});
info.value = res?.rate || 0;
}
async function handleOk() {
try {
const values = getFieldsValue();
await validate();
const params = {
settingCode: 'customerCode',
settingName: '客户编码',
settingValue: values.settingValue,
settingType: 1,
|
柏杨
authored
|
141
142
143
144
145
|
relationCode:
props.column === 1
? 'profitRate'
: props.column === 2
? 'packetPrice'
|
柏杨
authored
|
146
147
|
: props.column === 5
? 'orderHodTime'
|
|
148
149
150
|
: props.column === 7
? 'salesAmount'
: 'produHodTime',
|
sanmu
authored
|
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
relationName: '包装费用',
relationValue: values.relationValue,
};
await addConfig(params);
emit('modal-success');
closeModal();
} catch (error) {
console.log('%c [ error ]-108', 'font-size:13px; background:pink; color:#bf2c9f;', error);
}
}
return {
register,
loading,
handleShow,
info,
manualPreform,
handleCalc,
activeUser,
exchangeRate,
registerForm,
handleOk,
};
},
});
</script>
<style scoped>
.empty-tips {
height: 100px;
line-height: 100px;
text-align: center;
}
</style>
|