shmily1213 1 месяц назад
Родитель
Сommit
17a50e7bd0

+ 8 - 26
back-ui/src/api/dz/cards.js

@@ -59,29 +59,11 @@ export function issueCard(institutionId, type, count) {
 }
 
 // 分配卡
-export function assignCard(
-  cardType,
-  agentId,
-  begin,
-  end,
-  location,
-  examType,
-  schoolId,
-  days
-) {
+export function assignCard(params) {
   return request({
     url: "/dz/cards/assignCard",
     method: "post",
-    params: {
-      cardType,
-      agentId,
-      begin,
-      end,
-      location,
-      examType,
-      schoolId,
-      days,
-    },
+    params,
   });
 }
 
@@ -108,7 +90,7 @@ export function getAgentList(query) {
 // 缴费
 export function payCard(cardIds) {
   return request({
-    url: "/dz/cards/changeCard",
+    url: "/dz/cards/change/pay",
     method: "post",
     params: {
       action: "Pay",
@@ -120,7 +102,7 @@ export function payCard(cardIds) {
 // 关卡
 export function closeCard(cardIds) {
   return request({
-    url: "/dz/cards/changeCard",
+    url: "/dz/cards/change/close",
     method: "post",
     params: {
       action: "Close",
@@ -132,7 +114,7 @@ export function closeCard(cardIds) {
 // 重开
 export function reopenCard(cardIds) {
   return request({
-    url: "/dz/cards/changeCard",
+    url: "/dz/cards/change/reopen",
     method: "post",
     params: {
       action: "ReOpen",
@@ -144,7 +126,7 @@ export function reopenCard(cardIds) {
 // 退费
 export function refundCard(cardIds) {
   return request({
-    url: "/dz/cards/changeCard",
+    url: "/dz/cards/change/refund",
     method: "post",
     params: {
       action: "Refund",
@@ -156,7 +138,7 @@ export function refundCard(cardIds) {
 // 结算
 export function settleCard(cardIds) {
   return request({
-    url: "/dz/cards/changeCard",
+    url: "/dz/cards/change/settlement",
     method: "post",
     params: {
       action: "Settlement",
@@ -168,7 +150,7 @@ export function settleCard(cardIds) {
 // 续费
 export function renewCard(cardIds) {
   return request({
-    url: "/dz/cards/changeCard",
+    url: "/dz/cards/change/renew",
     method: "post",
     params: {
       action: "Renew",

+ 5 - 0
back-ui/src/components/IeSelect/index.vue

@@ -4,6 +4,10 @@
   </el-select>
 </template>
 <script setup>
+const selectedItemModel = defineModel('selectedItem', {
+  type: Object,
+  default: null,
+});
 const props = defineProps({
   options: {
     type: Array,
@@ -21,6 +25,7 @@ const props = defineProps({
 const emit = defineEmits(['change']);
 const handleChange = (val) => {
   const fullItem = props.options.find(option => option[props.valueKey] === val);
+  selectedItemModel.value = fullItem;
   emit('change', val, fullItem);
 }
 </script>

+ 226 - 0
back-ui/src/hooks/useSchool copy.js

@@ -0,0 +1,226 @@
+import { onMounted, ref, watch } from "vue";
+import { cascaderAreaList } from "@/api/system/area";
+import { listSchool } from "@/api/dz/school";
+import { listClasses } from "@/api/dz/classes";
+import { listCampus } from "@/api/dz/campus";
+import { getExamTypes } from "@/api/dz/cards";
+
+const defaultOptions = {
+  autoLoad: true, // 是否自动加载省份
+  loadCampus: false, // 切换省份时是否自动加载培训学校
+  loadCampusClass: false, // 切换培训学校时是否自动加载培训班级
+  loadClass: false, // 切换注册学校时是否自动加载注册班级
+  loadExamType: false, // 切换省份时是否自动加载考生类型
+};
+const useSchool = (options = {}) => {
+  const { autoLoad, loadCampus, loadCampusClass, loadClass, loadExamType } = Object.assign(
+    defaultOptions,
+    options
+  );
+
+  const area = ref({
+    list: [],
+    selected: [],
+    foreignKeyValue: null,
+  })
+
+  // const areaList = ref([]);
+  // const selectedArea = ref([]);
+
+  const schoolList = ref([]);
+  const selectedSchool = ref();
+  const selectedAssignSchool = ref();
+
+  const classList = ref([]);
+  const selectedClass = ref();
+
+  const campusList = ref([]);
+  const selectedCampus = ref();
+
+  const campusClassList = ref([]);
+  const selectedCampusClass = ref();
+
+  const examTypeList = ref([]);
+  const selectedExamType = ref("");
+
+  const getExamTypeList = async () => {
+    examTypeList.value = [];
+    const res = await getExamTypes((getProvinceName() || "").replace("省", ""));
+    examTypeList.value = res.data;
+    return res.data;
+  };
+
+  const getAreaList = async () => {
+    const rows = await cascaderAreaList();
+    // areaList.value = rows;
+    return rows;
+  };
+
+  const getSchoolList = async () => {
+    schoolList.value = [];
+    const areaId = Array.isArray(selectedArea.value)
+      ? selectedArea.value?.[selectedArea.value.length - 1]
+      : selectedArea.value;
+    const res = await listSchool({
+      areaCode: areaId,
+      pageNo: 1,
+      pageSize: 100000,
+    });
+    schoolList.value = res.rows;
+    return res.rows;
+  };
+
+  const getClassList = async () => {
+    classList.value = [];
+    const res = await listClasses({
+      schoolId: selectedSchool.value,
+      pageNo: 1,
+      pageSize: 100000,
+    });
+    classList.value = res.rows;
+    return res.rows;
+  };
+
+  const getCampusList = async () => {
+    const areaId = Array.isArray(selectedArea.value)
+      ? selectedArea.value?.[selectedArea.value.length - 1]
+      : selectedArea.value;
+    const res = await listCampus({
+      areaCode: areaId,
+    });
+    campusList.value = res.rows;
+    return res.rows;
+  };
+
+  const getCampusClassList = async () => {
+    campusClassList.value = [];
+    const res = await listClasses({
+      campusId: selectedCampus.value,
+    });
+    campusClassList.value = res.rows;
+    return res.rows;
+  };
+
+  watch(
+    () => selectedArea.value,
+    (newVal) => {
+      if (schoolList.value.length > 0) {
+        selectedSchool.value = null;
+        selectedAssignSchool.value = null;
+        schoolList.value = [];
+      }
+      if (campusList.value.length > 0) {
+        selectedCampus.value = null;
+        campusList.value = [];
+      }
+      if (examTypeList.value.length > 0) {
+        selectedExamType.value = null;
+        examTypeList.value = [];
+      }
+      if (isAreaValid(newVal)) {
+        getSchoolList();
+        if (loadCampus) {
+          getCampusList();
+        }
+        if (loadExamType) {
+          getExamTypeList();
+        }
+      }
+    }
+  );
+
+  watch(
+    () => selectedSchool.value,
+    (newVal) => {
+      if (classList.value.length > 0) {
+        selectedClass.value = null;
+        classList.value = [];
+      }
+      if (newVal !== null) {
+        if (loadClass) {
+          getClassList();
+        }
+      }
+    }
+  );
+
+  watch(
+    () => selectedCampus.value,
+    (newVal) => {
+      if (campusClassList.value.length > 0) {
+        selectedCampusClass.value = null;
+        campusClassList.value = [];
+      }
+      if (newVal !== null) {
+        if (loadCampusClass) {
+          getCampusClassList();
+        }
+      }
+    }
+  );
+
+  const getProvinceName = () => {
+    const areaId = Array.isArray(selectedArea.value)
+      ? selectedArea.value?.[selectedArea.value.length - 1]
+      : selectedArea.value;
+    const area = areaList.value.find((item) => item.areaId === areaId);
+    return area?.areaName;
+  };
+
+  const init = () => {
+    getAreaList();
+  };
+
+  const reset = () => {
+    selectedArea.value = Array.isArray(selectedArea.value) ? [] : null;
+    selectedSchool.value = null;
+    selectedAssignSchool.value = null;
+    selectedClass.value = null;
+    selectedCampus.value = null;
+    selectedCampusClass.value = null;
+    selectedExamType.value = "";
+  };
+
+  const isAreaValid = (value) => {
+    return (
+      (!Array.isArray(value) && value !== null) ||
+      (Array.isArray(value) && value.length > 0)
+    );
+  };
+
+  onMounted(() => {
+    if (autoLoad) {
+      getAreaList();
+    }
+  });
+
+  return {
+    init,
+    reset,
+
+    areaList,
+    selectedArea,
+    getAreaList,
+
+    schoolList,
+    selectedSchool,
+    selectedAssignSchool,
+
+    classList,
+    selectedClass,
+    getClassList,
+
+    campusList,
+    selectedCampus,
+    getCampusList,
+
+    campusClassList,
+    selectedCampusClass,
+    getCampusClassList,
+
+    examTypeList,
+    selectedExamType,
+    getExamTypeList,
+  };
+};
+export default useSchool;

+ 24 - 20
back-ui/src/hooks/useSchool.js

@@ -4,6 +4,7 @@ import { listSchool } from "@/api/dz/school";
 import { listClasses } from "@/api/dz/classes";
 import { listCampus } from "@/api/dz/campus";
 import { getExamTypes } from "@/api/dz/cards";
+import { reactive } from "vue";
 
 const defaultOptions = {
   autoLoad: true, // 是否自动加载省份
@@ -18,9 +19,12 @@ const useSchool = (options = {}) => {
     options
   );
 
-  const areaList = ref([]);
-  const selectedArea = ref([]);
-
+  const area = reactive({
+    list: [],
+    selected: [],
+    selectedItem: null,
+  })
+  
   const schoolList = ref([]);
   const selectedSchool = ref();
   const selectedAssignSchool = ref();
@@ -46,15 +50,15 @@ const useSchool = (options = {}) => {
 
   const getAreaList = async () => {
     const rows = await cascaderAreaList();
-    areaList.value = rows;
+    area.list = rows;
     return rows;
   };
 
   const getSchoolList = async () => {
     schoolList.value = [];
-    const areaId = Array.isArray(selectedArea.value)
-      ? selectedArea.value?.[selectedArea.value.length - 1]
-      : selectedArea.value;
+    const areaId = Array.isArray(area.selected)
+      ? area.selected?.[area.selected.length - 1]
+      : area.selected;
     const res = await listSchool({
       areaCode: areaId,
       pageNo: 1,
@@ -76,9 +80,9 @@ const useSchool = (options = {}) => {
   };
 
   const getCampusList = async () => {
-    const areaId = Array.isArray(selectedArea.value)
-      ? selectedArea.value?.[selectedArea.value.length - 1]
-      : selectedArea.value;
+    const areaId = Array.isArray(area.selected)
+      ? area.selected?.[area.selected.length - 1]
+      : area.selected;
     const res = await listCampus({
       areaCode: areaId,
     });
@@ -96,7 +100,7 @@ const useSchool = (options = {}) => {
   };
 
   watch(
-    () => selectedArea.value,
+    () => area.selected,
     (newVal) => {
       if (schoolList.value.length > 0) {
         selectedSchool.value = null;
@@ -154,11 +158,11 @@ const useSchool = (options = {}) => {
   );
 
   const getProvinceName = () => {
-    const areaId = Array.isArray(selectedArea.value)
-      ? selectedArea.value?.[selectedArea.value.length - 1]
-      : selectedArea.value;
-    const area = areaList.value.find((item) => item.areaId === areaId);
-    return area?.areaName;
+    const areaId = Array.isArray(area.selected)
+      ? area.selected?.[area.selected.length - 1]
+      : area.selected;
+    const targetArea = area.list.find((item) => item.areaId === areaId);
+    return targetArea?.areaName;
   };
 
   const init = () => {
@@ -166,7 +170,7 @@ const useSchool = (options = {}) => {
   };
 
   const reset = () => {
-    selectedArea.value = Array.isArray(selectedArea.value) ? [] : null;
+    area.selected = Array.isArray(area.selected) ? [] : null;
     selectedSchool.value = null;
     selectedAssignSchool.value = null;
     selectedClass.value = null;
@@ -192,9 +196,9 @@ const useSchool = (options = {}) => {
     init,
     reset,
 
-    areaList,
-    selectedArea,
-    getAreaList,
+    area,
+    // selectedArea,
+    // getAreaList,
 
     schoolList,
     selectedSchool,

+ 17 - 16
back-ui/src/views/dz/cards/components/AssignDialog.vue

@@ -19,8 +19,8 @@
         <ie-agent-select v-model="form.agentId" :deptId="form.deptId" class="w-[350px]!" filterable />
       </el-form-item>
       <el-form-item label="省份" prop="provinceId">
-        <ie-select v-model="selectedArea" :options="areaList" label-key="areaName" value-key="areaId"
-          class="w-[350px]!" />
+        <ie-select v-model="area.selected" v-model:selectedItem="area.selectedItem" :options="area.list"
+          label-key="areaName" value-key="areaId" class="w-[350px]!" />
       </el-form-item>
       <el-form-item label="学校" prop="schoolId">
         <ie-select v-model="selectedSchool" :options="schoolList" label-key="name" value-key="id" filterable
@@ -56,8 +56,7 @@ const {
 const {
   init,
   reset,
-  areaList,
-  selectedArea,
+  area,
   schoolList,
   selectedSchool,
   examTypeList,
@@ -89,7 +88,8 @@ const validateCardNoRange = (rule, value, callback) => {
 
 watchEffect(() => {
   form.value.cardNoRange = `${form.value.begin}-${form.value.end}`;
-  form.value.provinceId = selectedArea.value;
+  // form.value.provinceId = area.selected;
+  form.value.location = area.selectedItem?.shortName;
   form.value.schoolId = selectedSchool.value;
   form.value.assignExamType = selectedExamType.value;
 });
@@ -107,15 +107,6 @@ const rules = ref({
   agentId: [
     { required: true, message: '请选择代理商', trigger: 'change' },
   ],
-  // provinceId: [
-  //   { required: true, message: '请选择省份', trigger: 'change' },
-  // ],
-  // schoolId: [
-  //   { required: true, message: '请选择学校', trigger: 'change' },
-  // ],
-  // assignExamType: [
-  //   { required: true, message: '请选择考生类型', trigger: 'change' },
-  // ],
   days: [
     { required: true, message: '请输入有效期', trigger: 'change' },
   ],
@@ -138,9 +129,19 @@ const emit = defineEmits(['refresh'])
 const handleConfirm = () => {
   formRef.value.validate(async (valid) => {
     if (valid) {
-      const { cardType, agentId, begin, end, provinceId, assignExamType, schoolId, days } = form.value;
+      const { cardType, agentId, begin, end, location, assignExamType, schoolId, days } = form.value;
       modalRef.value.showLoading()
-      assignCard(cardType, agentId, begin, end, provinceId, assignExamType, schoolId, days).then(res => {
+      const params = {
+        cardType,
+        agentId,
+        begin,
+        end,
+        location,
+        examType: assignExamType,
+        schoolId,
+        days
+      }
+      assignCard(params).then(res => {
         proxy.$modal.msgSuccess('分配卡成功')
         close();
         setTimeout(() => {

+ 8 - 6
back-ui/src/views/dz/cards/components/OpenDialog.vue

@@ -13,7 +13,7 @@
         <ie-agent-select v-model="form.agentId" class="w-[350px]!" filterable />
       </el-form-item>
       <el-form-item label="省份" prop="provinceId" required>
-        <ie-select v-model="selectedArea" :options="areaList" label-key="areaName" value-key="areaId"
+        <ie-select v-model="area.selected" v-model:selectedItem="area.selectedItem" :options="area.list" label-key="areaName" value-key="areaId"
           class="w-[350px]!" />
       </el-form-item>
       <el-form-item label="学校" prop="schoolId" required>
@@ -37,8 +37,9 @@ const { proxy } = getCurrentInstance();
 const {
   init,
   reset,
-  areaList,
-  selectedArea,
+  area,
+  // areaList,
+  // selectedArea,
   schoolList,
   selectedSchool,
 } = useSchool({ autoLoad: false, loadExamType: true });
@@ -64,7 +65,8 @@ const validateCardNoRange = (rule, value, callback) => {
 
 watchEffect(() => {
   form.value.cardNoRange = `${form.value.begin}-${form.value.end}`;
-  form.value.provinceId = selectedArea.value;
+  // form.value.provinceId = area.selectedItem?.shortName;
+  form.value.location = area.selectedItem?.shortName;
   form.value.schoolId = selectedSchool.value;
 })
 
@@ -103,8 +105,8 @@ const handleConfirm = () => {
   formRef.value.validate(async (valid) => {
     if (valid) {
       modalRef.value.showLoading()
-      const { agentId, provinceId, schoolId, begin, end } = form.value;
-      requestOpenCard(agentId, provinceId, schoolId, begin, end).then(res => {
+      const { agentId, location, schoolId, begin, end } = form.value;
+      requestOpenCard(agentId, location, schoolId, begin, end).then(res => {
         proxy.$modal.msgSuccess('开卡申请成功')
         close();
         setTimeout(() => {

+ 5 - 4
back-ui/src/views/dz/cards/index.vue

@@ -2,7 +2,7 @@
   <div class="app-page">
     <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="100px">
       <el-form-item label="省份筛选" prop="provinceId">
-        <el-cascader class="w-[180px]!" :options="areaList" :props="cascaderProps" v-model="selectedArea" clearable />
+        <el-cascader class="w-[180px]!" :options="area.list" :props="cascaderProps" v-model="area.selected" clearable />
       </el-form-item>
       <el-form-item label="分配学校" prop="assignSchoolId">
         <ie-select v-model="selectedAssignSchool" :options="schoolList" label-key="name" value-key="id" filterable
@@ -163,8 +163,9 @@ import { getCurrentInstance, nextTick } from 'vue';
 const { proxy } = getCurrentInstance();
 const {
   reset,
-  areaList,
-  selectedArea,
+  area,
+  // areaList,
+  // selectedArea,
   schoolList,
   selectedSchool,
   selectedAssignSchool,
@@ -209,7 +210,7 @@ const editDisabled = computed(() => {
 })
 
 watchEffect(() => {
-  queryParams.value.areaIds = selectedArea.value;
+  queryParams.value.areaIds = area.selected;
   queryParams.value.schoolId = selectedSchool.value;
   queryParams.value.assignSchoolId = selectedAssignSchool.value;
   queryParams.value.classId = selectedClass.value;