吴sir 2 kuukautta sitten
vanhempi
sitoutus
4989fe420c

+ 26 - 10
src/components/Form/index.vue

@@ -1,7 +1,7 @@
 <template>
   <a-form ref="formRef" :model="formData" :rules="formRules" @submit="handleSubmit">
     <template v-for="(item, index) in formConfig" :key="`field-${index}`">
-      <a-col :span="item.layout === 1 ? 24 : 12" v-if="isVisibleShow(item, formData)">
+      <a-col :span="item.layout === 1 ? 24 : 12" v-if="showField(item)">
         <a-form-item :label="item.label" :rules="item.rules" :field="item.field"
           :validate-trigger="rulesTagse(item?.rules)">
           <component :is="'a-' + item.type" v-model="formData[item.field]" v-bind="item.props"
@@ -26,7 +26,7 @@
 </template>
 
 <script setup>
-import { ref,  defineProps, toRefs, defineEmits, onMounted, watchEffect } from 'vue';
+import { ref, defineProps, toRefs, defineEmits, onMounted, watchEffect } from 'vue';
 import service from '@/utils/axios.js'
 import { Getdictionary } from '@/mixins/index'
 
@@ -74,13 +74,26 @@ const { formConfig } = toRefs(props)
 
 const formData = ref({}); // 存储表单数据
 const formRules = ref({}); // 存储表单验证规则
+const visibilityCache = ref({}); // 缓存每个字段的可见性状态
 
 const isVisibleShow = async (item, formData) => {
-  if (item && item.isVisible && typeof item.isVisible === 'function') {
-    let distShow = await item.isVisible(item, formData);
-    return distShow
+  if (item && item.isVisible) {
+    if (typeof item.isVisible === 'function') {
+      const result = await item.isVisible(item, formData);
+      visibilityCache.value[item.field] = result;
+      return result;
+    } else {
+      visibilityCache.value[item.field] = item.isVisible;
+      return item.isVisible;
+    }
   }
+  return true;
+};
+
+const showField = (item) => {
+  return visibilityCache.value[item.field] !== false;
 };
+
 // 加载字典数据
 const loadDictOptions = async (index, dict, api) => {
   if (dict) {
@@ -95,11 +108,9 @@ const loadDictOptions = async (index, dict, api) => {
   }
 };
 
-
-
-const handelChange = (e, item) => {
+const handelChange = async (e, item) => {
   emits('change', e)
-  isVisibleShow(item, formData.value)
+  await isVisibleShow(item, formData.value)
 }
 
 // 表单提交方法
@@ -112,7 +123,12 @@ const rulesTagse = (item) => {
   return item[0]?.trigger
 }
 
-onMounted(() => {
+onMounted(async () => {
+  // 初始化所有字段的可见性状态
+  for (const item of formConfig.value) {
+    await isVisibleShow(item, formData.value);
+  }
+
   formConfig.value.forEach(async (res, key) => {
     if (res.dict) {
       await loadDictOptions(key, res.dict); // 加载字典数据

+ 1 - 1
src/views/admin/order/BuyCard/detaile.vue

@@ -38,7 +38,7 @@
             <div class="detail-item-box">
                 <div class="detail-item">
                     <div class="item-label">{{ $t('order.CardNum') }}</div>
-                    <div class="item-content">{{ dataDetail.length }}
+                    <div class="item-content">{{ dataDetail.length }} / {{ FormDataList.quantity }}
                         <template v-if="!show">
                             <a-button type="primary" @click="showCard = true" style="margin-left:10px;"
                                 v-if="userType == 1 && FormDataList.moderationStatus == 2">{{

+ 16 - 7
src/views/admin/tariffManagement/SetMeal/addSetMeal.vue

@@ -35,6 +35,7 @@
                     <a-form-item label="套餐名称" field="label" validate-trigger="input">
                         <a-input placeholder="请输入套餐名称" v-model="Form.label"></a-input>
                     </a-form-item>
+                    <div class="title">套餐名称将在终端用户的充值也中展示,建议不超过10个字</div>
                     <a-form-item label="充值类型" field="type" validate-trigger="input">
                         <a-select v-model="Form.type" placeholder="请选择充值类型">
                             <a-option v-for="item in puyType" :value="item.value" :key="item.value">{{ item.label
@@ -88,7 +89,7 @@ import { columnsTarrit } from '../config'
 import { tariffList, addTariffPackage, UpdateTariffTtems, DeleteTariffItems } from "@/api/path/tariffManagement.api"
 import { Message, Modal } from '@arco-design/web-vue';
 const props = defineProps({
-    id: [Array, String]
+    list: Object
 })
 
 const emits = defineEmits(['break'])
@@ -167,10 +168,10 @@ const processData = (data) => {
             ...item,
             priceName: item.price + item.currency,
             typeName: item.type == 1 ? '服务时长' : "购买流量",
-            profitPrice: item.profitPrice + item.currency,
+            profitPrice: item.billingMethod == 1 ? '---' : item.profitPrice + item.currency,
             billingMethod: filterDict(billingMethodList.value, item.billingMethod),
             costPrice: item.costPrice + item.trafficCurrency,
-            oldPrice: item.oldPrice + item.trafficCurrency
+            oldPrice: item.billingMethod == 1 ? '---' : item.oldPrice + item.trafficCurrency,
         }
     })
 }
@@ -185,7 +186,7 @@ const handleSubmit = () => {
                 ...Form.value,
                 type: Number(Form.value.type),
                 period: Number(Form.value.period),
-                simTerminalId: props.id
+                simTerminalId: pagination.value.simTerminalId
             }
             if (Edit.value) {
                 delete FormList.id
@@ -224,7 +225,7 @@ const unmount = async (record) => {
                 ...record,
                 type: Number(Form.value.type),
                 period: Number(Form.value.period),
-                simTerminalId: props.id
+                simTerminalId: pagination.value.simTerminalId
             }
             let res = await UpdateTariffTtems(FormList)
             if (res.code === 200) {
@@ -266,7 +267,7 @@ onMounted(async () => {
     Currency.value = dict[2]
     Form.value.currency = Currency.value[0]?.value
     billingMethodList.value = dict[3]
-    let res = await tariffList({ current: 1, size: 99999 })
+    let res = await tariffList({ current: 1, size: 99999 ,source:props.list.source })
     if (res.code === 200) {
         tariffListData.value = (res.data.records || []).map(item => {
             return {
@@ -276,7 +277,7 @@ onMounted(async () => {
             }
         })
     }
-    pagination.value.simTerminalId = props.id
+    pagination.value.simTerminalId = props.list.id
     initData()
 })
 </script>
@@ -291,4 +292,12 @@ onMounted(async () => {
     display: flex;
     justify-content: space-between;
 }
+
+.title {
+    font-size: 14px;
+    color: #ccc;
+    margin-left: 120px;
+    margin-top: -15px;
+    margin-bottom: 10px;
+}
 </style>

+ 47 - 25
src/views/admin/tariffManagement/SetMeal/index.vue

@@ -17,27 +17,21 @@
           </template>
           <template #Controls="{ record }">
             <a-space>
-              <a-button type="text" @click="SetUpPackage(record)" v-if="record.isRecharge==1"> 设置套餐</a-button>
+              <a-button type="text" @click="SetUpPackage(record)" v-if="record.isRecharge == 1"> 设置套餐</a-button>
               <a-button type="text" @click="unmount(record)">{{ record.status == 1 ? '下架' : '上架' }}</a-button>
             </a-space>
           </template>
           <template #isRechargeName="{ record }">
             {{ filterDict(SetMealList, record.isRecharge) }}
           </template>
+          <template #defaultTrafficName="{ record }">
+            {{ record.defaultTraffic.label }}
+          </template>
         </a-table>
       </div>
     </template>
 
-    <a-modal v-model:visible="visibleQrCode" width="700px" @cancel="visibleQrCode = false" title="充值二维码">
-      <div class="code">
-        <qrcode-vue :value="codeUrl" size="150" level="H"></qrcode-vue>
-      </div>
-      <template #footer>
-        <a-button @click="visibleQrCode = false">关闭</a-button>
-      </template>
-    </a-modal>
-
-    <!-- <a-modal v-model:visible="visibleSetMeal" width="600px" @cancel="handelCancel" title="新增套餐计划">
+    <a-modal v-model:visible="visibleSetMeal" width="600px" @cancel="handelCancel" title="新增套餐计划">
       <div class="Form">
         <a-form ref="formRef" :rules="rules" :model="Form">
           <a-form-item label="套餐计划名称" field="label" validate-trigger="blur">
@@ -48,6 +42,11 @@
               <a-option v-for="(item, index) in userList" :value="item.id">{{ item.name }}</a-option>
             </a-select>
           </a-form-item>
+          <a-form-item label="运营商" field="source" validate-trigger="blur">
+            <a-select :style="{ width: '320px' }" v-model="Form.source" placeholder="请选择运营商">
+              <a-option v-for="(item, index) in sourceList" :value="item.value">{{ item.label }}</a-option>
+            </a-select>
+          </a-form-item>
           <a-form-item label="套餐计划类型" field="isRecharge">
             <a-radio-group v-model="Form.isRecharge" :options="SetMealList" />
           </a-form-item>
@@ -60,18 +59,18 @@
         </a-form>
       </div>
       <template #footer>
-        <a-button @click="visibleSetMeal = false">取消</a-button>
+        <a-button @click="handelCancel">取消</a-button>
         <a-button type="primary" @click="handleSubmit">确定</a-button>
       </template>
-    </a-modal> -->
+    </a-modal>
     <!-- 新增套餐计划 -->
-    <AddSetMeal v-if="!AddSet" :id="pid" @break="AddSet = true" />
+    <AddSetMeal v-if="!AddSet" :list="list" @break="AddSet = true" />
   </div>
 
 </template>
 
 <script setup>
-import { ref, onMounted, toRefs } from 'vue';
+import { ref, onMounted, toRefs, watch } from 'vue';
 import Search from '@/components/Search/index.vue'
 import { SetMealSearchForm, columnsSetMeal } from '../config.js'
 import { getMessUserList, } from '@/api/customer.js';
@@ -80,7 +79,6 @@ import QrcodeVue from 'qrcode.vue'
 import { Getdictionary, tableFunction, filterDict } from '@/mixins/index.js'
 import { Message, Modal } from '@arco-design/web-vue';
 import AddSetMeal from './addSetMeal.vue'
-import { add } from 'lodash';
 const formRef = ref(null);
 const rules = {
   userId: [
@@ -89,6 +87,9 @@ const rules = {
   label: [
     { required: true, message: '请输入套餐计划名称', trigger: 'blur' },
   ],
+  source: [
+    { required: true, message: '请选择运营商', trigger: 'blur' },
+  ],
 };
 
 
@@ -98,22 +99,22 @@ const state = ref({
     pageSize: 10,
     current: 1,
   },
-  visibleQrCode: false,
-  codeUrl: 'https://baidu.com',
   visibleSetMeal: false,
   Form: {
     userId: null,
     label: null,
     isRecharge: '1',
-    defaultTrafficId: null
+    defaultTrafficId: null,
+    source: null
   },
   userList: [],
   SetMealList: [],
   tariffListData: [],
+  sourceList:[],
   AddSet: true,
-  pid: null
+  list: {}
 })
-const { pagination, visibleQrCode, codeUrl, visibleSetMeal, userList, Form, AddSet, pid, SetMealList, tariffListData } = toRefs(state.value)
+const { pagination, visibleSetMeal, userList, Form, AddSet, SetMealList, tariffListData, sourceList, list } = toRefs(state.value)
 
 
 const { tableData, evChangePage, initData, reset } = tableFunction(pagination.value, PackageSchedule)
@@ -132,6 +133,7 @@ const fetchCustomerList = async (item) => {
 const handleSubmit = ({ values, errors }) => {
   formRef.value.validate(async (values, errors) => {
     if (!errors) {
+      if (Form.value.isRecharge == 1 && Form.value.defaultTrafficId == null) return Message.error('请选择充值绑定资费')
       Form.value.isRecharge = Number(Form.value.isRecharge)
       const response = await addTariffSchedule(Form.value)
       if (response.code === 200) {
@@ -160,7 +162,8 @@ const unmount = async (record) => {
 }
 
 const SetUpPackage = (item) => {
-  pid.value = item.id
+  list.value.id = item.id
+  list.value.source = item.source
   AddSet.value = false
 }
 
@@ -169,11 +172,23 @@ const handelCancel = () => {
     Form.value[res] = null
   })
   visibleSetMeal.value = false
+  Form.value.isRecharge = "1"
 }
 
-onMounted(async () => {
-  SetMealList.value = await Getdictionary('setMeal')
-  let res = await tariffList({ current: 1, size: 99999 })
+
+watch(() => Form.value.userId, val => {
+  getTarrife(val)
+}, { deep: true })
+
+watch(() => Form.value.source, val => {
+  getTarrife(Form.value.userId, val)
+}, { deep: true })
+
+// 资费
+const getTarrife = async (item, sourceId) => {
+  let res = await tariffList({ current: 1, size: 99999, userId: item, source: sourceId })
+  tariffListData.value = []
+  Form.value.defaultTrafficId = null
   if (res.code === 200) {
     tariffListData.value = (res.data.records || []).map(item => {
       return {
@@ -183,8 +198,15 @@ onMounted(async () => {
       }
     })
   }
+}
+
+onMounted(async () => {
+  let dict = await Getdictionary(['setMeal', 'source'])
+  SetMealList.value = dict[0]
+  sourceList.value = dict[1]
   initData()
   fetchCustomerList()
+  getTarrife()
 })
 </script>
 <style lang="less" scoped>

+ 7 - 1
src/views/admin/tariffManagement/config.js

@@ -181,6 +181,12 @@ export const columnsSetMeal = [
     align: "center",
     ellipsis: true,
   },
+  {
+    title: "运营商名称",
+    dataIndex: "source",
+    align: "center",
+    ellipsis: true,
+  },
   {
     title: "套餐计划类型",
     slotName: "isRechargeName",
@@ -189,7 +195,7 @@ export const columnsSetMeal = [
   },
   {
     title: "默认绑定资费",
-    dataIndex: "defaultTrafficName",
+    slotName: "defaultTrafficName",
     align: "center",
     ellipsis: true,
   },

+ 1 - 1
src/views/admin/tariffManagement/index.vue

@@ -118,7 +118,7 @@ const processData = (data) => {
     return {
       ...item,
       sourceName: filterDict(sourceList.value, item.source),
-      pricingName: item.billingMethod == 1 ? item.trafficBillingAmount + item.currency : item.pricing + item.currency,
+      pricingName: item.billingMethod == 1 ? item.trafficBilling + item.trafficBillingType  +'/'+  item.trafficBillingAmount + item.currency   : item.pricing + item.currency,
       billingCycleName: filterDict(cycleist.value, item.billingCycle),
       Activated: item.trafficBilling + item.trafficBillingType,
       status: "正常",

+ 4 - 4
src/views/user/SetMeal/addSetMeal.vue

@@ -51,12 +51,12 @@ const processData = (data) => {
     return (data.records || []).map((item, index) => {
         return {
             ...item,
-            price: item.price + '/' + item.currency,
+            priceName: item.price + item.currency,
             typeName: item.type == 1 ? '服务时长' : "购买流量",
-            profitPrice: item.profitPrice + '/' + item.currency,
+            profitPrice: item.billingMethod == 1 ? '---' : item.profitPrice + item.currency,
             billingMethod: filterDict(billingMethodList.value, item.billingMethod),
-            costPrice: item.costPrice + '/' + item.trafficCurrency,
-            oldPrice: item.oldPrice + '/' + item.trafficCurrency
+            costPrice: item.costPrice + item.trafficCurrency,
+            oldPrice: item.billingMethod == 1 ? '---' : item.oldPrice + item.trafficCurrency,
         }
     })
 }

+ 8 - 2
src/views/user/SetMeal/config.js

@@ -86,6 +86,12 @@ export const columnsSetMeal = [
     align: "center",
     ellipsis: true,
   },
+  {
+    title: "运营商名称",
+    dataIndex: "source",
+    align: "center",
+    ellipsis: true,
+  },
   {
     title: "套餐计划类型",
     slotName: "isRechargeName",
@@ -94,7 +100,7 @@ export const columnsSetMeal = [
   },
   {
     title: "绑定资费",
-    dataIndex: "defaultTrafficName",
+    slotName: "defaultTrafficName",
     align: "center",
     ellipsis: true,
   },
@@ -178,7 +184,7 @@ export const columnsTarrit = [
   },
   {
     title: "售价(终端充值)",
-    dataIndex: "price",
+    dataIndex: "priceName",
     align: "center",
     ellipsis: true,
   },

+ 3 - 1
src/views/user/SetMeal/index.vue

@@ -20,11 +20,13 @@
           <template #isRechargeName="{ record }">
             {{ filterDict(SetMealList, record.isRecharge) }}
           </template>
+          <template #defaultTrafficName="{ record }">
+            {{ record.defaultTraffic.label }}
+          </template>
         </a-table>
       </div>
     </template>
 
-    <!-- 新增套餐计划 -->
     <AddSetMeal v-if="!AddSet" :id="pid" @break="AddSet=true"/>
   </div>
 

+ 10 - 3
src/views/user/order/BuyCard/Card.vue

@@ -63,7 +63,7 @@
 <script setup>
 import { ref, toRefs, defineProps, watch, toRef } from 'vue';
 import { tariffList, ExampleQueryTrafficPool, PackageSchedule } from "@/api/path/tariffManagement.api";
-import { Getdictionary ,} from '@/mixins/index.js'
+import { Getdictionary, } from '@/mixins/index.js'
 import { CardPurchase } from '@/api/path/order'
 import { Message } from '@arco-design/web-vue';
 import { useI18n } from 'vue-i18n'
@@ -194,12 +194,20 @@ const closeModal = (val) => {
     formState.value.isTrafficPool = '1'
 }
 
+
+watch(() => formState.value.source, val => {
+    getList(formState.value.isRecharge)
+}, { deep: true })
+
 // 套餐计划
 const getList = async (val) => {
+    PackagePlan.value = []
+    formState.value.SimTerminalId = null
     const param = {
         current: 1,
         size: 999,
-        isRecharge: Number(val)
+        isRecharge: Number(val),
+        source: formState.value.source
     }
     let res = await PackageSchedule(param)
     if (res.code === 200) {
@@ -221,7 +229,6 @@ watch(() => modelValue.value, val => {
     }
 })
 watch(() => formState.value.isRecharge, async val => {
-    formState.value.SimTerminalId = null
     getList(val)
 }, { deep: true })
 </script>