|
@@ -1,8 +1,8 @@
|
|
|
<script setup lang="ts">
|
|
|
import BasicModal from '/@/components/Modal/src/BasicModal.vue';
|
|
|
- import { useModal } from '/@/components/Modal';
|
|
|
+ import { useModal, useModalInner } from '/@/components/Modal';
|
|
|
import { Steps } from 'ant-design-vue';
|
|
|
- import { ref } from 'vue';
|
|
|
+ import { ref, unref } from 'vue';
|
|
|
import { useTable } from '/@/components/Table';
|
|
|
import BasicForm from '/@/components/Form/src/BasicForm.vue';
|
|
|
import { useForm } from '/@/components/Form';
|
|
@@ -10,21 +10,27 @@
|
|
|
import BasicTable from '/@/components/Table/src/BasicTable.vue';
|
|
|
import addTextbook from './addTextbook.vue';
|
|
|
import selectModalVue from './selectModal.vue';
|
|
|
- import { getTextbookPageSubscription } from '/@/services/apis/TextbookController';
|
|
|
- import { postTextbookWfTextbookSubscription } from '/@/services/apis/WfTextbookSubscriptionController';
|
|
|
+ import { getTextbookListSubscription } from '/@/services/apis/TextbookController';
|
|
|
import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
import historyView from './historyView.vue';
|
|
|
import { requestMagicApi } from '/@/api/magicApi';
|
|
|
+ import {
|
|
|
+ getTextbookSubscriptionInfo,
|
|
|
+ postTextbookTextbookSubscription,
|
|
|
+ putTextbookTextbookSubscription,
|
|
|
+ } from '/@/services/apis/TextbookSubscriptionController';
|
|
|
const step = Steps.Step;
|
|
|
const selectRow = ref<any>([]);
|
|
|
const thisStep = ref(0);
|
|
|
const dataInfo = ref<any>({});
|
|
|
const selectUserList = ref<any>([]);
|
|
|
- const [modalReg, { closeModal }] = useModal();
|
|
|
+ const isUpdate = ref(true);
|
|
|
+ const modelRef = ref({});
|
|
|
+
|
|
|
const [addReg, { openModal: addModelOpen }] = useModal();
|
|
|
const [historyViewReg, { openModal: historyViewOpen }] = useModal();
|
|
|
const emits = defineEmits(['success']);
|
|
|
- const [formReg, { validate, resetFields }] = useForm({
|
|
|
+ const [formReg, { validate, resetFields, setFieldsValue }] = useForm({
|
|
|
labelWidth: 120,
|
|
|
schemas: [
|
|
|
{
|
|
@@ -55,7 +61,7 @@
|
|
|
},
|
|
|
{
|
|
|
label: '征订方式',
|
|
|
- field: 'baseOrderTypeId',
|
|
|
+ field: 'subscriptionMethod',
|
|
|
component: 'Select',
|
|
|
required: true,
|
|
|
componentProps: () => {
|
|
@@ -86,6 +92,44 @@
|
|
|
],
|
|
|
showActionButtonGroup: false,
|
|
|
});
|
|
|
+
|
|
|
+ const handleChangeDiscount = (record) => {
|
|
|
+ if (record.discount < 1) {
|
|
|
+ record.discount = 1;
|
|
|
+ }
|
|
|
+ if (record.discount > 10) {
|
|
|
+ record.discount = 10;
|
|
|
+ }
|
|
|
+ record.price = Number((Number(record.sourcePrice || 0) * record.discount) / 10).toFixed(2);
|
|
|
+ };
|
|
|
+
|
|
|
+ const handleChangePrice = (record) => {
|
|
|
+ if (record.price !== 0) {
|
|
|
+ record.discount = Number(((record.price / record.sourcePrice) * 10).toFixed(1));
|
|
|
+ } else {
|
|
|
+ record.discount = 0;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ const [modalReg, { closeModal }] = useModalInner(async (data) => {
|
|
|
+ isUpdate.value = !!data?.isUpdate;
|
|
|
+ modelRef.value = { ...data.baseData };
|
|
|
+
|
|
|
+ if (unref(isUpdate)) {
|
|
|
+ const resData = await getTextbookSubscriptionInfo({ id: data.baseData.id });
|
|
|
+ modelRef.value = { ...resData };
|
|
|
+ setFieldsValue(resData);
|
|
|
+
|
|
|
+ resData.textbookSubscriptionItemList.forEach((item: any) => {
|
|
|
+ item.studentSubscriptionNumber = item.studentNum;
|
|
|
+ item.teacherSubscriptionNumber = item.teacherNum;
|
|
|
+ item.courseName = item.courseSubjectIdCn;
|
|
|
+ item.sourcePrice = item.pricing;
|
|
|
+ });
|
|
|
+
|
|
|
+ setTableData(resData.textbookSubscriptionItemList);
|
|
|
+ }
|
|
|
+ });
|
|
|
const handleChange = () => {
|
|
|
setTableData([]);
|
|
|
selectUserList.value = [];
|
|
@@ -115,6 +159,7 @@
|
|
|
selectRow.value = selectedRowKeys;
|
|
|
},
|
|
|
},
|
|
|
+ pagination: false,
|
|
|
});
|
|
|
const handleAdd = () => {
|
|
|
addModelOpen(true, {
|
|
@@ -126,6 +171,9 @@
|
|
|
const addList: any[] = [];
|
|
|
e.forEach((item: any) => {
|
|
|
if (!data.find((i: any) => i.id === item.id)) {
|
|
|
+ item.sourcePrice = item.price;
|
|
|
+ item.textbookId = item.id;
|
|
|
+ handleChangeDiscount(item);
|
|
|
addList.push(item);
|
|
|
}
|
|
|
});
|
|
@@ -143,26 +191,53 @@
|
|
|
const handleSelect = async (e) => {
|
|
|
selectUserList.value = e.classList;
|
|
|
const ids = selectUserList.value.map((item: any) => item.id);
|
|
|
- const { list } = await getTextbookPageSubscription({
|
|
|
+ const data = await getTextbookListSubscription({
|
|
|
classIds: ids.join(','),
|
|
|
baseSemesterId: dataInfo.value.baseSemesterId,
|
|
|
});
|
|
|
- setTableData(list);
|
|
|
+
|
|
|
+ data.forEach((item: any) => {
|
|
|
+ item.sourcePrice = item.price;
|
|
|
+ handleChangeDiscount(item);
|
|
|
+ });
|
|
|
+ setTableData(data);
|
|
|
};
|
|
|
const { createMessage } = useMessage();
|
|
|
const handleSubmit = async () => {
|
|
|
- if (getDataSource().length === 0) {
|
|
|
+ const dataSoruce = getDataSource();
|
|
|
+
|
|
|
+ if (dataSoruce.length === 0) {
|
|
|
createMessage.warning('至少征订一本教材');
|
|
|
return;
|
|
|
}
|
|
|
- const params = {
|
|
|
+
|
|
|
+ dataSoruce.forEach((item: any) => {
|
|
|
+ item.studentNum = item.studentSubscriptionNumber;
|
|
|
+ item.teacherNum = item.teacherSubscriptionNumber;
|
|
|
+ });
|
|
|
+
|
|
|
+ const postParams = unref(modelRef);
|
|
|
+ Object.assign(postParams, {
|
|
|
remark: dataInfo.value?.remark,
|
|
|
- subscriptionMethod: dataInfo.value.baseOrderTypeId,
|
|
|
+ subscriptionMethod: dataInfo.value.subscriptionMethod,
|
|
|
baseSemesterId: dataInfo.value.baseSemesterId,
|
|
|
- wfTextbookSubscriptionItemList: getDataSource(),
|
|
|
- };
|
|
|
+ textbookSubscriptionItemList: getDataSource(),
|
|
|
+ baseClassIds: dataSoruce[0].classIds,
|
|
|
+ });
|
|
|
+
|
|
|
+ // const params = {
|
|
|
+ // remark: dataInfo.value?.remark,
|
|
|
+ // subscriptionMethod: dataInfo.value.subscriptionMethod,
|
|
|
+ // baseSemesterId: dataInfo.value.baseSemesterId,
|
|
|
+ // textbookSubscriptionItemList: getDataSource(),
|
|
|
+ // baseClassIds: dataSoruce[0].classIds,
|
|
|
+ // };
|
|
|
try {
|
|
|
- await postTextbookWfTextbookSubscription(params, 'none');
|
|
|
+ if (isUpdate.value) {
|
|
|
+ await putTextbookTextbookSubscription(postParams, 'none');
|
|
|
+ } else {
|
|
|
+ await postTextbookTextbookSubscription(postParams, 'none');
|
|
|
+ }
|
|
|
createMessage.success('新增成功');
|
|
|
emits('success');
|
|
|
thisStep.value = 0;
|
|
@@ -201,14 +276,14 @@
|
|
|
<BasicForm @register="formReg" />
|
|
|
</div>
|
|
|
<div v-show="thisStep === 1" class="mt-[24px] w-full">
|
|
|
- <div v-if="dataInfo && dataInfo.baseOrderTypeId == 2">
|
|
|
+ <div v-if="dataInfo && dataInfo.subscriptionMethod == 2">
|
|
|
<span class="required">征订教材</span>
|
|
|
<a-button type="primary" class="ml-[12px]" @click="handleAdd">选择教材</a-button>
|
|
|
</div>
|
|
|
<div
|
|
|
@click="selectModalOpen(true, { classList: selectUserList })"
|
|
|
class="flex flex-row items-center mt-[24px]"
|
|
|
- v-if="dataInfo && dataInfo.baseOrderTypeId == 1"
|
|
|
+ v-if="dataInfo && dataInfo.subscriptionMethod == 1"
|
|
|
>
|
|
|
<span class="required">用书班级</span>
|
|
|
<div
|
|
@@ -249,11 +324,27 @@
|
|
|
<template #teacherSubscriptionNumber="{ record }">
|
|
|
<a-input-number :step="1" :min="0" v-model:value="record.teacherSubscriptionNumber" />
|
|
|
</template>
|
|
|
+ <template #discount="{ record }">
|
|
|
+ <a-input-number
|
|
|
+ :step="1"
|
|
|
+ :min="0"
|
|
|
+ v-model:value="record.discount"
|
|
|
+ @change="handleChangeDiscount(record)"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ <template #price="{ record }">
|
|
|
+ <a-input-number
|
|
|
+ :step="1"
|
|
|
+ :min="0"
|
|
|
+ v-model:value="record.price"
|
|
|
+ @change="handleChangePrice(record)"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
<template #action="{ record }">
|
|
|
<a-button type="link" @click="handleClear(record.id)">移出</a-button>
|
|
|
- <a-button type="link" @click="handleViewHistory(record.textbookId)"
|
|
|
- >历史征订</a-button
|
|
|
- >
|
|
|
+ <a-button type="link" @click="handleViewHistory(record.textbookId)">
|
|
|
+ 历史征订
|
|
|
+ </a-button>
|
|
|
</template>
|
|
|
</BasicTable>
|
|
|
</div>
|
|
@@ -261,12 +352,12 @@
|
|
|
<div class="mt-[24px] ml-[120px]">
|
|
|
<a-button @click="handleClose">取消</a-button>
|
|
|
<a-button v-show="thisStep === 1" @click="thisStep = 0" class="ml-[24px]">上一步</a-button>
|
|
|
- <a-button v-show="thisStep === 0" type="primary" @click="handleNext" class="ml-[24px]"
|
|
|
- >下一步</a-button
|
|
|
- >
|
|
|
- <a-button v-show="thisStep === 1" type="primary" class="ml-[24px]" @click="handleSubmit"
|
|
|
- >提交</a-button
|
|
|
- >
|
|
|
+ <a-button v-show="thisStep === 0" type="primary" @click="handleNext" class="ml-[24px]">
|
|
|
+ 下一步
|
|
|
+ </a-button>
|
|
|
+ <a-button v-show="thisStep === 1" type="primary" class="ml-[24px]" @click="handleSubmit">
|
|
|
+ 提交
|
|
|
+ </a-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
<addTextbook @register="addReg" @success="handleSuccess" />
|