|
@@ -18,7 +18,7 @@
|
|
|
name="name">
|
|
name="name">
|
|
|
<a-input class="commonInput"
|
|
<a-input class="commonInput"
|
|
|
v-model:value="formState.name"
|
|
v-model:value="formState.name"
|
|
|
- placeholder="30天账期"
|
|
|
|
|
|
|
+ placeholder="请输入模版名称"
|
|
|
style="width: 260px" />
|
|
style="width: 260px" />
|
|
|
</a-form-item>
|
|
</a-form-item>
|
|
|
</a-col>
|
|
</a-col>
|
|
@@ -88,6 +88,8 @@
|
|
|
class="fixedBtns">
|
|
class="fixedBtns">
|
|
|
<a-form-item class="btnCenter">
|
|
<a-form-item class="btnCenter">
|
|
|
<a-button class="listedBtn"
|
|
<a-button class="listedBtn"
|
|
|
|
|
+ :loading="loading"
|
|
|
|
|
+ :disabled="loading"
|
|
|
@click="submit">确定</a-button>
|
|
@click="submit">确定</a-button>
|
|
|
</a-form-item>
|
|
</a-form-item>
|
|
|
</a-col>
|
|
</a-col>
|
|
@@ -113,6 +115,9 @@ import { AddPerformanceTemp, PerfomanceStempTempInfo } from '@/services/proto/pe
|
|
|
import { validateAction } from '@/common/setup/form';
|
|
import { validateAction } from '@/common/setup/form';
|
|
|
import { PermanceTemp, PermanceTempForm } from './interface';
|
|
import { PermanceTemp, PermanceTempForm } from './interface';
|
|
|
import { getUserId } from '@/services/bus/account';
|
|
import { getUserId } from '@/services/bus/account';
|
|
|
|
|
+import { requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
|
|
|
|
|
+import { addPerformanceTemp } from '@/services/proto/performance';
|
|
|
|
|
+import { geLoginID_number } from '@/services/bus/login';
|
|
|
|
|
|
|
|
// 初始化 模板
|
|
// 初始化 模板
|
|
|
const initTemp = (): PermanceTemp => {
|
|
const initTemp = (): PermanceTemp => {
|
|
@@ -121,8 +126,8 @@ const initTemp = (): PermanceTemp => {
|
|
|
|
|
|
|
|
// 新增 模板
|
|
// 新增 模板
|
|
|
const useAddTemp = (formState: UnwrapRef<PermanceTempForm>) => {
|
|
const useAddTemp = (formState: UnwrapRef<PermanceTempForm>) => {
|
|
|
- const temp = initTemp();
|
|
|
|
|
function addTemp() {
|
|
function addTemp() {
|
|
|
|
|
+ const temp = initTemp();
|
|
|
formState.domains.push(temp);
|
|
formState.domains.push(temp);
|
|
|
}
|
|
}
|
|
|
function showAddTempBtn(index: number) {
|
|
function showAddTempBtn(index: number) {
|
|
@@ -167,6 +172,13 @@ const userForm = () => {
|
|
|
const formState: UnwrapRef<PermanceTempForm> = reactive({ domains: [temp], name: '' });
|
|
const formState: UnwrapRef<PermanceTempForm> = reactive({ domains: [temp], name: '' });
|
|
|
const findIndex = (name: string): number => formState.domains.findIndex((temp) => temp.steptypename === name);
|
|
const findIndex = (name: string): number => formState.domains.findIndex((temp) => temp.steptypename === name);
|
|
|
const findItem = (name: string) => formState.domains.find((temp) => temp.steptypename === name);
|
|
const findItem = (name: string) => formState.domains.find((temp) => temp.steptypename === name);
|
|
|
|
|
+ const total = (name: string): number =>
|
|
|
|
|
+ formState.domains
|
|
|
|
|
+ .filter((temp) => temp.steptypename === name)
|
|
|
|
|
+ .reduce((acc, cur) => {
|
|
|
|
|
+ const { stepvalue } = cur;
|
|
|
|
|
+ return stepvalue ? acc + stepvalue : acc;
|
|
|
|
|
+ }, 0);
|
|
|
// 配置卖方收款之前要有买方支付
|
|
// 配置卖方收款之前要有买方支付
|
|
|
function validateSepeTypeId(value: any) {
|
|
function validateSepeTypeId(value: any) {
|
|
|
const sellIndex = findIndex('卖方收款');
|
|
const sellIndex = findIndex('卖方收款');
|
|
@@ -178,15 +190,11 @@ const userForm = () => {
|
|
|
}
|
|
}
|
|
|
return Promise.resolve();
|
|
return Promise.resolve();
|
|
|
}
|
|
}
|
|
|
- function validateStepValue() {
|
|
|
|
|
- const sell = findItem('卖方收款');
|
|
|
|
|
- const buy = findItem('买方支付');
|
|
|
|
|
- if (sell && buy) {
|
|
|
|
|
- const buyValue = sell.stepvalue;
|
|
|
|
|
- const sellValue = sell.stepvalue;
|
|
|
|
|
- if (buyValue && sellValue && sellValue > buyValue) {
|
|
|
|
|
- return Promise.reject('卖方收款不能多于买方付款');
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ function validateStepValue(value: any) {
|
|
|
|
|
+ const buyTotal = total('买方支付');
|
|
|
|
|
+ const sellTotal = total('卖方收款');
|
|
|
|
|
+ if (sellTotal > buyTotal) {
|
|
|
|
|
+ return Promise.reject('卖方收款不能多于买方付款');
|
|
|
}
|
|
}
|
|
|
return Promise.resolve();
|
|
return Promise.resolve();
|
|
|
}
|
|
}
|
|
@@ -198,10 +206,10 @@ const userForm = () => {
|
|
|
{ required: true, validator: validateSepeTypeId },
|
|
{ required: true, validator: validateSepeTypeId },
|
|
|
],
|
|
],
|
|
|
stepvalue: [
|
|
stepvalue: [
|
|
|
- { required: true, message: '请输入步骤值', trigger: 'blur' },
|
|
|
|
|
|
|
+ { required: true, message: '请输入步骤值', trigger: 'blur', type: 'number' },
|
|
|
{ required: true, validator: validateStepValue },
|
|
{ required: true, validator: validateStepValue },
|
|
|
],
|
|
],
|
|
|
- stepdays: { required: true, message: '请输入距离上一步天数', trigger: 'blur' },
|
|
|
|
|
|
|
+ stepdays: { required: true, message: '请输入距离上一步天数', trigger: 'blur', type: 'number' },
|
|
|
},
|
|
},
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -221,16 +229,27 @@ export default defineComponent({
|
|
|
|
|
|
|
|
function submit() {
|
|
function submit() {
|
|
|
validateAction<PermanceTempForm>(formRef, formState).then((res) => {
|
|
validateAction<PermanceTempForm>(formRef, formState).then((res) => {
|
|
|
- // const performancesteps:PerfomanceStempTempInfo[] = res.domains.map(el => {
|
|
|
|
|
- // const { }
|
|
|
|
|
- // return el
|
|
|
|
|
- // })
|
|
|
|
|
- // const param: AddPerformanceTemp = {
|
|
|
|
|
- // autoid: 0,
|
|
|
|
|
- // templatename: res.name,
|
|
|
|
|
- // userid: getUserId(),
|
|
|
|
|
- // performancesteps:
|
|
|
|
|
- // }
|
|
|
|
|
|
|
+ const performancesteps: PerfomanceStempTempInfo[] = res.domains.map((el) => {
|
|
|
|
|
+ const { steptypeid, stepvalue, stepdays, isauto, remark, stepindex } = el;
|
|
|
|
|
+ return {
|
|
|
|
|
+ steptypeid: steptypeid as number,
|
|
|
|
|
+ stepvalue: stepvalue as number,
|
|
|
|
|
+ stepdays: stepdays as number,
|
|
|
|
|
+ isauto,
|
|
|
|
|
+ remark,
|
|
|
|
|
+ stepindex,
|
|
|
|
|
+ };
|
|
|
|
|
+ });
|
|
|
|
|
+ const param: AddPerformanceTemp = {
|
|
|
|
|
+ autoid: 0,
|
|
|
|
|
+ templatename: res.name,
|
|
|
|
|
+ userid: getUserId(),
|
|
|
|
|
+ performancesteps,
|
|
|
|
|
+ creatorid: geLoginID_number()!,
|
|
|
|
|
+ };
|
|
|
|
|
+ requestResultLoadingAndInfo(addPerformanceTemp, param, loading, ['新增履约模板成功', '新增履约模板失败:']).then(() => {
|
|
|
|
|
+ cancel(true);
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
return {
|
|
return {
|