Forráskód Böngészése

对接我的工作台接口

hurx 2 hónapja
szülő
commit
395857d8e2

+ 11 - 0
src/api/pc/bank/bank.ts

@@ -0,0 +1,11 @@
+import request from '@/utils/request';
+
+/**
+ * 查询银行信息列表
+ */
+export function getBankList() {
+  return request({
+    url: `/system/bank/list/`,
+    method: 'get'
+  });
+}

+ 12 - 0
src/api/pc/bank/types.ts

@@ -0,0 +1,12 @@
+/**
+ * 银行信息
+ */
+export interface EnterpriseInfo {
+  id?: number;
+  bnId?: string;
+  bnName?: string;
+  bnAddr?: string;
+  faxNo?: string;
+  telNo?: string;
+  [key: string]: any;
+}

+ 13 - 13
src/api/pc/enterprise/index.ts

@@ -8,7 +8,7 @@ import { EnterpriseInfo, ShippingAddress, InvoiceInfo } from './types';
  */
 export function getEnterpriseInfo() {
   return request({
-    url: '/pc/enterprise/info',
+    url: '/customer/enterprise/info',
     method: 'get'
   });
 }
@@ -18,7 +18,7 @@ export function getEnterpriseInfo() {
  */
 export function updateEnterpriseInfo(data: EnterpriseInfo) {
   return request({
-    url: '/pc/enterprise/info',
+    url: '/customer/enterprise/updateEnterprise',
     method: 'put',
     data: data
   });
@@ -31,7 +31,7 @@ export function updateEnterpriseInfo(data: EnterpriseInfo) {
  */
 export function getAddressList(params?: any) {
   return request({
-    url: '/pc/enterprise/address/list',
+    url: '/customer/address/list',
     method: 'get',
     params: params
   });
@@ -42,7 +42,7 @@ export function getAddressList(params?: any) {
  */
 export function getAddressInfo(id: number) {
   return request({
-    url: `/pc/enterprise/address/${id}`,
+    url: `/customer/address/${id}`,
     method: 'get'
   });
 }
@@ -52,7 +52,7 @@ export function getAddressInfo(id: number) {
  */
 export function addAddress(data: ShippingAddress) {
   return request({
-    url: '/pc/enterprise/address',
+    url: '/customer/address',
     method: 'post',
     data: data
   });
@@ -63,7 +63,7 @@ export function addAddress(data: ShippingAddress) {
  */
 export function updateAddress(data: ShippingAddress) {
   return request({
-    url: '/pc/enterprise/address',
+    url: '/customer/address',
     method: 'put',
     data: data
   });
@@ -74,7 +74,7 @@ export function updateAddress(data: ShippingAddress) {
  */
 export function deleteAddress(ids: number[]) {
   return request({
-    url: `/pc/enterprise/address/${ids.join(',')}`,
+    url: `/customer/address/${ids.join(',')}`,
     method: 'delete'
   });
 }
@@ -84,7 +84,7 @@ export function deleteAddress(ids: number[]) {
  */
 export function setDefaultAddress(data: { id: number }) {
   return request({
-    url: '/pc/enterprise/address/default',
+    url: '/customer/address/default',
     method: 'put',
     data: data
   });
@@ -97,7 +97,7 @@ export function setDefaultAddress(data: { id: number }) {
  */
 export function getInvoiceList(params?: any) {
   return request({
-    url: '/pc/enterprise/invoice/list',
+    url: '/customer/enterprise/invoice/list',
     method: 'get',
     params: params
   });
@@ -108,7 +108,7 @@ export function getInvoiceList(params?: any) {
  */
 export function getInvoiceInfo(id: number) {
   return request({
-    url: `/pc/enterprise/invoice/${id}`,
+    url: `/customer/enterprise/invoice/${id}`,
     method: 'get'
   });
 }
@@ -118,7 +118,7 @@ export function getInvoiceInfo(id: number) {
  */
 export function addInvoice(data: InvoiceInfo) {
   return request({
-    url: '/pc/enterprise/invoice',
+    url: '/customer/enterprise/invoice',
     method: 'post',
     data: data
   });
@@ -129,7 +129,7 @@ export function addInvoice(data: InvoiceInfo) {
  */
 export function updateInvoice(data: InvoiceInfo) {
   return request({
-    url: '/pc/enterprise/invoice',
+    url: '/customer/enterprise/invoice',
     method: 'put',
     data: data
   });
@@ -140,7 +140,7 @@ export function updateInvoice(data: InvoiceInfo) {
  */
 export function deleteInvoice(ids: number[]) {
   return request({
-    url: `/pc/enterprise/invoice/${ids.join(',')}`,
+    url: `/customer/enterprise/invoice/${ids.join(',')}`,
     method: 'delete'
   });
 }

+ 2 - 2
src/api/pc/enterprise/order.ts

@@ -8,7 +8,7 @@ import { OrderMain, OrderProduct, OrderStatusStats } from './orderTypes';
  */
 export function getOrderList(params?: any) {
   return request({
-    url: '/pc/enterprise/order/list',
+    url: '/pcOrder/list',
     method: 'get',
     params: params
   });
@@ -19,7 +19,7 @@ export function getOrderList(params?: any) {
  */
 export function getOrderStatusStats() {
   return request({
-    url: '/pc/enterprise/order/statusStats',
+    url: '/order/pcOrder/statusStats',
     method: 'get'
   });
 }

+ 57 - 0
src/api/pc/enterprise/purchaseHabit.ts

@@ -0,0 +1,57 @@
+import request from '@/utils/request';
+import { PurchaseHabit } from './types';
+/**
+ * 查询发票信息详情
+ */
+export function getInvoiceInfo(id: number) {
+  return request({
+    url: `/customer/enterprise/invoice/${id}`,
+    method: 'get'
+  });
+}
+
+/**
+ * 新增客户采购习惯
+ * @param data
+ */
+export const addPurchaseHabit = (data: PurchaseHabit) => {
+  return request({
+    url: '/customer/purchaseHabit',
+    method: 'post',
+    data: data
+  });
+};
+
+/**
+ * 修改客户采购习惯
+ * @param data
+ */
+export const updatePurchaseHabit = (data: PurchaseHabit) => {
+  return request({
+    url: '/customer/pcPurchaseHabit',
+    method: 'put',
+    data: data
+  });
+};
+
+/**
+ * 删除客户采购习惯
+ * @param id
+ */
+export const delPurchaseHabit = (id: string | number | Array<string | number>) => {
+  return request({
+    url: '/customer/pcPurchaseHabit/' + id,
+    method: 'delete'
+  });
+};
+
+/**
+ * 新增客户采购习惯
+ * @param data
+ */
+export const getCustomerPurchaseHabitData = () => {
+  return request({
+    url: '/customer/pcPurchaseHabit/getCustomerPurchaseHabitData',
+    method: 'get'
+  });
+};

+ 8 - 8
src/api/pc/enterprise/statement.ts

@@ -5,7 +5,7 @@ import request from '@/utils/request';
  */
 export function getStatementList(params?: any) {
   return request({
-    url: '/pc/enterprise/statement/list',
+    url: '/bill/pcStatementOrder/list',
     method: 'get',
     params: params
   });
@@ -16,7 +16,7 @@ export function getStatementList(params?: any) {
  */
 export function getStatementInfo(id: number | string) {
   return request({
-    url: `/pc/enterprise/statement/${id}`,
+    url: `/bill/pcStatementOrder/${id}`,
     method: 'get'
   });
 }
@@ -26,7 +26,7 @@ export function getStatementInfo(id: number | string) {
  */
 export function getStatementDetails(params?: any) {
   return request({
-    url: '/pc/enterprise/statement/details',
+    url: '/bill/pcStatementOrder/details',
     method: 'get',
     params: params
   });
@@ -37,7 +37,7 @@ export function getStatementDetails(params?: any) {
  */
 export function confirmStatement(data: { id: number; remark?: string }) {
   return request({
-    url: '/pc/enterprise/statement/confirm',
+    url: '/bill/pcStatementOrder/confirm',
     method: 'put',
     data: data
   });
@@ -48,7 +48,7 @@ export function confirmStatement(data: { id: number; remark?: string }) {
  */
 export function rejectStatement(data: { id: number; rejectRemark?: string }) {
   return request({
-    url: '/pc/enterprise/statement/reject',
+    url: '/bill/pcStatementOrder/reject',
     method: 'put',
     data: data
   });
@@ -59,7 +59,7 @@ export function rejectStatement(data: { id: number; rejectRemark?: string }) {
  */
 export function getStatementDetailList(params?: any) {
   return request({
-    url: '/pc/enterprise/statementDetail/list',
+    url: '/bill/pcStatementDetail/list',
     method: 'get',
     params: params
   });
@@ -70,7 +70,7 @@ export function getStatementDetailList(params?: any) {
  */
 export function getStatementProductList(params?: any) {
   return request({
-    url: '/pc/enterprise/statementProduct/list',
+    url: '/bill/pcStatementProduct/list',
     method: 'get',
     params: params
   });
@@ -81,7 +81,7 @@ export function getStatementProductList(params?: any) {
  */
 export function getStatementInvoiceList(params?: any) {
   return request({
-    url: '/pc/enterprise/statementInvoice/list',
+    url: '/bill/pcStatementInvoice/list',
     method: 'get',
     params: params
   });

+ 24 - 0
src/api/pc/enterprise/types.ts

@@ -42,3 +42,27 @@ export interface InvoiceInfo {
   companyPhone?: string;
   [key: string]: any;
 }
+
+/**
+ * 客户采购习惯
+ */
+export interface PurchaseHabit {
+  id?: number;
+  customerId?: number;
+  customerNo?: string;
+  monthPurchase?: number;
+  yearPurchase?: number;
+  permanentOfficer?: string;
+  choiceModel?: string;
+  printAmount?: string;
+  buyOriginal?: string;
+  technologyService?: string;
+  purchaseCategory?: string;
+  otherCategory?: string;
+  adaptScene?: string;
+  otherScene?: string;
+  customizeDemand?: string;
+  otherCustomize?: string;
+  remark?: string;
+  [key: string]: any;
+}

+ 158 - 114
src/views/easybuv/index.vue

@@ -13,7 +13,7 @@
         <div class="address-info">
           <div class="address-name">
             <span>{{ item.consignee }}</span>
-            <el-tag v-if="item.defaultAddress === '1'" type="danger" size="small">默认地址</el-tag>
+            <el-tag v-if="item.defaultAddress === '0'" type="danger" size="small">默认地址</el-tag>
           </div>
           <div class="address-detail">{{ item.provincialCityCountry }} {{ item.address }}</div>
           <div class="address-phone">{{ item.phone }}</div>
@@ -21,7 +21,7 @@
         <div class="address-actions">
           <el-button type="primary" link @click="handleEdit(item)">编辑</el-button>
           <el-button type="danger" link @click="handleDelete(item)">删除</el-button>
-          <el-button v-if="item.defaultAddress !== '1'" type="danger" link @click="handleSetDefault(item)">设为默认</el-button>
+          <el-button v-if="item.defaultAddress !== '0'" type="danger" link @click="handleSetDefault(item)">设为默认</el-button>
         </div>
       </div>
       <el-empty v-if="addressList.length === 0" description="暂无收货地址" />
@@ -39,8 +39,7 @@
         <el-form-item label="所在地区" prop="region">
           <el-cascader
             v-model="form.regionCodes"
-            :options="regionOptions"
-            :props="{ value: 'code', label: 'name', children: 'children' }"
+            :options="regionData as any"
             placeholder="请选择省/市/区"
             style="width: 100%"
             @change="handleRegionChange"
@@ -60,117 +59,114 @@
 </template>
 
 <script setup lang="ts">
-import { ref, reactive, onMounted } from 'vue'
-import { Plus } from '@element-plus/icons-vue'
-import { ElMessage, ElMessageBox } from 'element-plus'
-import { PageTitle } from '@/components'
-import { getAddressList, addAddress, updateAddress, deleteAddress, setDefaultAddress } from '@/api/pc/enterprise'
-
-const dialogVisible = ref(false)
-const dialogTitle = ref('新增收货地址')
-const formRef = ref()
-const editingId = ref<number | null>(null)
-
-const form = reactive({ name: '', phone: '', regionCodes: [], region: '', address: '', isDefault: false })
-
-// 省市区数据(示例数据,需要替换为完整数据)
-const regionOptions = ref([
-  {
-    code: '14',
-    name: '山西省',
-    children: [
-      {
-        code: '1405',
-        name: '晋城市',
-        children: [
-          { code: '140524', name: '陵川县' },
-          { code: '140525', name: '泽州县' }
-        ]
-      }
-    ]
-  },
-  {
-    code: '44',
-    name: '广东省',
-    children: [
-      {
-        code: '4401',
-        name: '广州市',
-        children: [
-          { code: '440103', name: '荔湾区' },
-          { code: '440104', name: '越秀区' }
-        ]
-      },
-      {
-        code: '4403',
-        name: '深圳市',
-        children: [
-          { code: '440303', name: '罗湖区' },
-          { code: '440304', name: '福田区' }
-        ]
-      }
-    ]
-  }
-])
+import { ref, reactive, onMounted } from 'vue';
+import { Plus } from '@element-plus/icons-vue';
+import { ElMessage, ElMessageBox } from 'element-plus';
+import { PageTitle } from '@/components';
+import { getAddressList, addAddress, updateAddress, deleteAddress, setDefaultAddress } from '@/api/pc/enterprise';
+import { regionData } from 'element-china-area-data';
+
+const dialogVisible = ref(false);
+const dialogTitle = ref('新增收货地址');
+const formRef = ref();
+const editingId = ref<number | null>(null);
+
+const form = reactive({ name: '', phone: '', regionCodes: [], region: '', address: '', isDefault: false });
+
 const rules = {
   name: [{ required: true, message: '请输入收货人姓名', trigger: 'blur' }],
-  phone: [{ required: true, message: '请输入联系电话', trigger: 'blur' }, { pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号', trigger: 'blur' }],
+  phone: [
+    { required: true, message: '请输入联系电话', trigger: 'blur' },
+    { pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号', trigger: 'blur' }
+  ],
   address: [{ required: true, message: '请输入详细地址', trigger: 'blur' }]
-}
+};
 
-const addressList = ref([])
+const addressList = ref([]);
 
 // 加载地址列表
 const loadAddressList = async () => {
   try {
-    const res = await getAddressList()
+    const res = await getAddressList();
     if (res.code === 200) {
-      addressList.value = res.rows || []
+      addressList.value = res.rows || [];
     }
   } catch (error) {
-    console.error('加载地址列表失败:', error)
-    ElMessage.error('加载地址列表失败')
+    console.error('加载地址列表失败:', error);
+    ElMessage.error('加载地址列表失败');
   }
-}
+};
 
 onMounted(() => {
-  loadAddressList()
-})
+  loadAddressList();
+});
 
-const resetForm = () => { form.name = ''; form.phone = ''; form.regionCodes = []; form.region = ''; form.address = ''; form.isDefault = false; editingId.value = null }
+const resetForm = () => {
+  form.name = '';
+  form.phone = '';
+  form.regionCodes = [];
+  form.region = '';
+  form.address = '';
+  form.isDefault = false;
+  editingId.value = null;
+};
 
 // 处理地区选择变化
 const handleRegionChange = (value: string[]) => {
   if (value && value.length === 3) {
     // 根据选中的代码查找对应的名称
-    const province = regionOptions.value.find(p => p.code === value[0])
-    const city = province?.children?.find(c => c.code === value[1])
-    const district = city?.children?.find(d => d.code === value[2])
 
-    if (province && city && district) {
-      form.region = `${province.name}/${city.name}/${district.name}`
+    // 根据编码获取名称
+    const names: string[] = [];
+    if (value[0]) {
+      const province = regionData.find((item: any) => item.value === value[0]);
+      if (province) {
+        names.push(province.label);
+
+        if (value[1] && province.children) {
+          const city = province.children.find((item: any) => item.value === value[1]);
+          if (city) {
+            names.push(city.label);
+
+            if (value[2] && city.children) {
+              const county = city.children.find((item: any) => item.value === value[2]);
+              if (county) {
+                names.push(county.label);
+              }
+            }
+          }
+        }
+      }
     }
+
+    // 将省市区名称用斜杠连接
+    form.region = names.join('/');
   }
-}
-const handleAdd = () => { resetForm(); dialogTitle.value = '新增收货地址'; dialogVisible.value = true }
+};
+
+const handleAdd = () => {
+  resetForm();
+  dialogTitle.value = '新增收货地址';
+  dialogVisible.value = true;
+};
 const handleEdit = (item: any) => {
-  editingId.value = item.id
-  form.name = item.consignee
-  form.phone = item.phone
-  form.region = item.provincialCityCountry || ''
-  form.address = item.address || ''
-  form.isDefault = item.defaultAddress === '1'
+  editingId.value = item.id;
+  form.name = item.consignee;
+  form.phone = item.phone;
+  form.region = item.provincialCityCountry || '';
+  form.address = item.address || '';
+  form.isDefault = item.defaultAddress;
 
   // 尝试根据省市区代码设置级联选择器的值
   if (item.provincialNo && item.cityNo && item.countryNo) {
-    form.regionCodes = [item.provincialNo, item.cityNo, item.countryNo]
+    form.regionCodes = [item.provincialNo, item.cityNo, item.countryNo];
   } else {
-    form.regionCodes = []
+    form.regionCodes = [];
   }
 
-  dialogTitle.value = '编辑收货地址'
-  dialogVisible.value = true
-}
+  dialogTitle.value = '编辑收货地址';
+  dialogVisible.value = true;
+};
 const handleSave = async () => {
   const valid = await formRef.value?.validate();
   if (!valid) return;
@@ -179,52 +175,100 @@ const handleSave = async () => {
       consignee: form.name,
       phone: form.phone,
       address: form.address,
-      isDefault: form.isDefault ? 1 : 0
-    }
+      isDefault: form.isDefault
+    };
 
     // 如果选择了省市区,发送代码
     if (form.regionCodes && form.regionCodes.length === 3) {
-      data.provincialNo = form.regionCodes[0]
-      data.cityNo = form.regionCodes[1]
-      data.countryNo = form.regionCodes[2]
+      data.provincialNo = form.regionCodes[0];
+      data.cityNo = form.regionCodes[1];
+      data.countryNo = form.regionCodes[2];
+      data.provincialCityCountry = form.region;
     }
 
     if (editingId.value) {
-      data.id = editingId.value
-      await updateAddress(data)
+      data.id = editingId.value;
+      await updateAddress(data);
     } else {
-      await addAddress(data)
+      await addAddress(data);
     }
-    ElMessage.success(editingId.value ? '修改成功' : '新增成功')
-    dialogVisible.value = false
-    loadAddressList()
+    ElMessage.success(editingId.value ? '修改成功' : '新增成功');
+    dialogVisible.value = false;
+    loadAddressList();
   } catch (error) {
-    ElMessage.error('操作失败')
+    ElMessage.error('操作失败');
   }
-}
+};
 const handleDelete = (item: any) => {
-  ElMessageBox.confirm('确定要删除该收货地址吗?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(async () => {
-    try {
-      await deleteAddress([item.id])
-      ElMessage.success('删除成功')
-      loadAddressList()
-    } catch (error) {
-      ElMessage.error('删除失败')
+  ElMessageBox.confirm('确定要删除该收货地址吗?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(
+    async () => {
+      try {
+        await deleteAddress([item.id]);
+        ElMessage.success('删除成功');
+        loadAddressList();
+      } catch (error) {
+        ElMessage.error('删除失败');
+      }
     }
-  })
-}
+  );
+};
 const handleSetDefault = async (item: any) => {
   try {
-    await setDefaultAddress({ id: item.id })
-    ElMessage.success('设置成功')
-    loadAddressList()
+    await setDefaultAddress({ id: item.id });
+    ElMessage.success('设置成功');
+    loadAddressList();
   } catch (error) {
-    ElMessage.error('设置失败')
+    ElMessage.error('设置失败');
   }
-}
+};
 </script>
 
 <style scoped lang="scss">
-.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; :deep(.page-title) { margin-bottom: 0; } }
-.address-list { .address-item { display: flex; justify-content: space-between; align-items: center; padding: 20px; border: 1px solid #eee; border-radius: 4px; margin-bottom: 15px; &:last-child { margin-bottom: 0; } .address-info { .address-name { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 500; color: #333; margin-bottom: 8px; } .address-detail { font-size: 14px; color: #666; margin-bottom: 5px; } .address-phone { font-size: 14px; color: #666; } } .address-actions { display: flex; gap: 10px; } } }
+.page-header {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  margin-bottom: 20px;
+  :deep(.page-title) {
+    margin-bottom: 0;
+  }
+}
+.address-list {
+  .address-item {
+    display: flex;
+    justify-content: space-between;
+    align-items: center;
+    padding: 20px;
+    border: 1px solid #eee;
+    border-radius: 4px;
+    margin-bottom: 15px;
+    &:last-child {
+      margin-bottom: 0;
+    }
+    .address-info {
+      .address-name {
+        display: flex;
+        align-items: center;
+        gap: 10px;
+        font-size: 15px;
+        font-weight: 500;
+        color: #333;
+        margin-bottom: 8px;
+      }
+      .address-detail {
+        font-size: 14px;
+        color: #666;
+        margin-bottom: 5px;
+      }
+      .address-phone {
+        font-size: 14px;
+        color: #666;
+      }
+    }
+    .address-actions {
+      display: flex;
+      gap: 10px;
+    }
+  }
+}
 </style>

+ 53 - 70
src/views/enterprise/companyInfo/edit.vue

@@ -17,50 +17,38 @@
           <el-row :gutter="20">
             <el-col :span="12">
               <el-form-item label="企业名称" prop="companyName">
-                <el-input v-model="form.companyName" placeholder="请输入" />
+                <el-input v-model="form.companyName" placeholder="请输入" disabled />
               </el-form-item>
             </el-col>
             <el-col :span="12">
               <el-form-item label="统一社会信用代码" prop="creditCode">
-                <el-input v-model="form.creditCode" placeholder="请输入" />
+                <el-input v-model="form.creditCode" placeholder="请输入" disabled />
               </el-form-item>
             </el-col>
           </el-row>
           <el-row :gutter="20">
             <el-col :span="12">
               <el-form-item label="法人" prop="legalPerson">
-                <el-input v-model="form.legalPerson" placeholder="请输入" />
+                <el-input v-model="form.legalPerson" placeholder="请输入" disabled />
               </el-form-item>
             </el-col>
             <el-col :span="12">
               <el-form-item label="注册资本" prop="registeredCapital">
-                <el-input v-model="form.registeredCapital" placeholder="请输入" />
+                <el-input v-model="form.registeredCapital" placeholder="请输入" disabled />
               </el-form-item>
             </el-col>
           </el-row>
           <el-row :gutter="20">
             <el-col :span="24">
               <el-form-item label="详细地址" prop="detailAddress">
-                <el-input 
-                  v-model="form.detailAddress" 
-                  placeholder="请输入" 
-                  maxlength="50"
-                  show-word-limit
-                />
+                <el-input v-model="form.detailAddress" placeholder="请输入" maxlength="50" show-word-limit disabled />
               </el-form-item>
             </el-col>
           </el-row>
           <el-row :gutter="20">
             <el-col :span="24">
               <el-form-item label="经营范围" prop="businessScope">
-                <el-input 
-                  v-model="form.businessScope" 
-                  type="textarea"
-                  :rows="3"
-                  placeholder="请输入" 
-                  maxlength="50"
-                  show-word-limit
-                />
+                <el-input v-model="form.businessScope" type="textarea" :rows="3" placeholder="请输入" maxlength="300" show-word-limit disabled />
               </el-form-item>
             </el-col>
           </el-row>
@@ -125,12 +113,7 @@
           <el-row :gutter="20">
             <el-col :span="24">
               <el-form-item label="网址" prop="website">
-                <el-input 
-                  v-model="form.website" 
-                  placeholder="请输入" 
-                  maxlength="50"
-                  show-word-limit
-                />
+                <el-input v-model="form.website" placeholder="请输入" maxlength="50" show-word-limit />
               </el-form-item>
             </el-col>
           </el-row>
@@ -187,14 +170,14 @@
 </template>
 
 <script setup lang="ts">
-import { ref, reactive, onMounted } from 'vue'
-import { useRouter } from 'vue-router'
-import { ArrowLeft, Plus } from '@element-plus/icons-vue'
-import { ElMessage } from 'element-plus'
-import { getEnterpriseInfo, updateEnterpriseInfo } from '@/api/pc/enterprise'
+import { ref, reactive, onMounted } from 'vue';
+import { useRouter } from 'vue-router';
+import { ArrowLeft, Plus } from '@element-plus/icons-vue';
+import { ElMessage } from 'element-plus';
+import { getEnterpriseInfo, updateEnterpriseInfo } from '@/api/pc/enterprise';
 
-const router = useRouter()
-const formRef = ref()
+const router = useRouter();
+const formRef = ref();
 
 const form = reactive({
   companyName: '',
@@ -212,70 +195,70 @@ const form = reactive({
   website: '',
   businessLicense: '',
   idCard: ''
-})
+});
 
 const rules = {
   companyName: [{ required: true, message: '请输入企业名称', trigger: 'blur' }],
   creditCode: [{ required: true, message: '请输入统一社会信用代码', trigger: 'blur' }]
-}
+};
 
 // 加载企业信息
 const loadEnterpriseInfo = async () => {
   try {
-    const res = await getEnterpriseInfo()
+    const res = await getEnterpriseInfo();
     if (res.code === 200 && res.data) {
-      const data = res.data
-      const businessInfo = data.customerBusinessInfoVo || {}
+      const data = res.data;
+      const businessInfo = data.customerBusinessInfoVo || {};
 
-      form.companyName = data.customerName || data.businessCustomerName || ''
-      form.creditCode = businessInfo.socialCreditCode || ''
-      form.legalPerson = businessInfo.legalPersonName || ''
-      form.registeredCapital = businessInfo.registeredCapital || ''
-      form.detailAddress = businessInfo.businessAddress || ''
-      form.businessScope = businessInfo.bussinessRange || ''
-      form.officeAddress = data.address || ''
-      form.industry = data.industryCategory || ''
-      form.scale = data.enterpriseScale || ''
-      form.phone = data.landline || ''
-      form.email = businessInfo.email || data.email || ''
-      form.website = businessInfo.website || ''
-      form.businessLicense = businessInfo.businessLicense || ''
-      form.idCard = businessInfo.idCard || ''
+      form.companyName = data.customerName || data.businessCustomerName || '';
+      form.creditCode = businessInfo.socialCreditCode || '';
+      form.legalPerson = businessInfo.legalPersonName || '';
+      form.registeredCapital = businessInfo.registeredCapital || '';
+      form.detailAddress = businessInfo.businessAddress || '';
+      form.businessScope = businessInfo.bussinessRange || '';
+      form.officeAddress = data.address || '';
+      form.industry = data.industryCategory || '';
+      form.scale = data.enterpriseScale || '';
+      form.phone = data.landline || '';
+      form.email = businessInfo.email || data.fax || '';
+      form.website = data.url || '';
+      form.businessLicense = businessInfo.businessLicense || '';
+      form.idCard = businessInfo.idCard || '';
     }
   } catch (error) {
-    console.error('加载企业信息失败:', error)
-    ElMessage.error('加载企业信息失败')
+    console.error('加载企业信息失败:', error);
+    ElMessage.error('加载企业信息失败');
   }
-}
+};
 
 onMounted(() => {
-  loadEnterpriseInfo()
-})
+  loadEnterpriseInfo();
+});
 
 const handleBack = () => {
-  router.push('/enterprise/companyInfo')
-}
+  router.push('/enterprise/companyInfo');
+};
 
 const handleUpload = (file: any, field: string) => {
-  const reader = new FileReader()
+  const reader = new FileReader();
   reader.onload = (e) => {
-    (form as any)[field] = e.target?.result as string
-  }
-  reader.readAsDataURL(file.raw)
-}
+    (form as any)[field] = e.target?.result as string;
+  };
+  reader.readAsDataURL(file.raw);
+};
 
 const handleSave = async () => {
-  const valid = await formRef.value?.validate()
-  if (!valid) return
+  const valid = await formRef.value?.validate();
+  if (!valid) return;
 
   try {
-    await updateEnterpriseInfo(form as any)
-    ElMessage.success('保存成功')
-    handleBack()
+    await updateEnterpriseInfo(form as any);
+    ElMessage.success('保存成功');
+    handleBack();
   } catch (error) {
-    ElMessage.error('保存失败')
+    ElMessage.error('保存失败');
   }
-}
+};
 </script>
 
 <style scoped lang="scss">
@@ -356,7 +339,7 @@ const handleSave = async () => {
   .upload-preview {
     width: 100%;
     height: 100%;
-    
+
     .el-image {
       width: 100%;
       height: 100%;

+ 61 - 58
src/views/enterprise/companyInfo/index.vue

@@ -27,8 +27,7 @@
         </div>
       </div>
       <div class="tab-nav">
-        <div v-for="tab in tabs" :key="tab.key" :class="['tab-item', { active: activeTab === tab.key }]"
-          @click="handleTabClick(tab.key)">
+        <div v-for="tab in tabs" :key="tab.key" :class="['tab-item', { active: activeTab === tab.key }]" @click="handleTabClick(tab.key)">
           <el-icon><Grid /></el-icon>
           <span>{{ tab.label }}</span>
           <el-icon><ArrowRight /></el-icon>
@@ -110,7 +109,7 @@
               {{ person.name }}
               <el-tag :type="person.type === '专属采购顾问' ? 'danger' : 'primary'" size="small">{{ person.type }}</el-tag>
             </div>
-            <div class="person-contact">{{ person.department }}  {{ person.phone }}</div>
+            <div class="person-contact">{{ person.department }} {{ person.phone }}</div>
           </div>
         </div>
       </div>
@@ -131,16 +130,16 @@
 </template>
 
 <script setup lang="ts">
-import { ref, reactive, onMounted } from 'vue'
-import { useRouter } from 'vue-router'
-import { OfficeBuilding, Grid, ArrowRight, Edit, Bell, User, Ticket } from '@element-plus/icons-vue'
-import { getEnterpriseInfo } from '@/api/pc/enterprise'
-import { getAnnouncementList } from '@/api/pc/system/announcement'
-import { getServicePersons } from '@/api/pc/enterprise/servicePerson'
-import { ElMessage } from 'element-plus'
+import { ref, reactive, onMounted } from 'vue';
+import { useRouter } from 'vue-router';
+import { OfficeBuilding, Grid, ArrowRight, Edit, Bell, User, Ticket } from '@element-plus/icons-vue';
+import { getEnterpriseInfo } from '@/api/pc/enterprise';
+import { getAnnouncementList } from '@/api/pc/system/announcement';
+import { getServicePersons } from '@/api/pc/enterprise/servicePerson';
+import { ElMessage } from 'element-plus';
 
-const router = useRouter()
-const activeTab = ref('companyInfo')
+const router = useRouter();
+const activeTab = ref('companyInfo');
 
 const tabs = [
   { key: 'companyInfo', label: '企业信息' },
@@ -149,7 +148,7 @@ const tabs = [
   { key: 'invoice', label: '开票信息' },
   { key: 'creditApply', label: '额度申请' },
   { key: 'changePerson', label: '更换负责人' }
-]
+];
 
 const companyData = reactive({
   companyName: '加载中...',
@@ -163,73 +162,73 @@ const companyData = reactive({
   phone: '-',
   email: '-',
   address: '-'
-})
+});
 
 // 加载企业信息
 const loadEnterpriseInfo = async () => {
   try {
-    const res = await getEnterpriseInfo()
-    console.log('企业信息完整数据:', res.data) // 调试用,查看完整数据结构
+    const res = await getEnterpriseInfo();
+    console.log('企业信息完整数据:', res.data); // 调试用,查看完整数据结构
     if (res.code === 200 && res.data) {
-      const data = res.data
-      const salesInfo = data.customerSalesInfoVo || {}
-      const businessInfo = data.customerBusinessInfoVo || {}
+      const data = res.data;
+      const salesInfo = data.customerSalesInfoVo || {};
+      const businessInfo = data.customerBusinessInfoVo || {};
 
       // 辅助函数:处理空值,空字符串也转为 '-'
-      const formatValue = (value: any) => (value && value !== '' ? value : '-')
-
-      companyData.companyName = formatValue(data.customerName || data.businessCustomerName)
-      companyData.companyCode = formatValue(data.customerNo)
-      companyData.creditCode = formatValue(businessInfo.socialCreditCode)
-      companyData.industry = formatValue(data.industryCategory)
-      companyData.scale = formatValue(data.enterpriseScale)
-      companyData.phone = formatValue(data.landline)
-      companyData.email = formatValue(businessInfo.email || data.email)
-      companyData.address = formatValue(data.address)
-      companyData.availableAmount = salesInfo.remainingQuota || '0.00'
-      companyData.creditAmount = salesInfo.creditAmount || '0.00'
+      const formatValue = (value: any) => (value && value !== '' ? value : '-');
+
+      companyData.companyName = formatValue(data.customerName || data.businessCustomerName);
+      companyData.companyCode = formatValue(data.customerNo);
+      companyData.creditCode = formatValue(businessInfo.socialCreditCode);
+      companyData.industry = formatValue(data.industryCategory);
+      companyData.scale = formatValue(data.enterpriseScale);
+      companyData.phone = formatValue(data.landline);
+      companyData.email = formatValue(businessInfo.email || data.fax);
+      companyData.address = formatValue(data.address);
+      companyData.availableAmount = salesInfo.remainingQuota || '0.00';
+      companyData.creditAmount = salesInfo.creditAmount || '0.00';
     }
   } catch (error) {
-    console.error('加载企业信息失败:', error)
-    ElMessage.error('加载企业信息失败')
+    console.error('加载企业信息失败:', error);
+    ElMessage.error('加载企业信息失败');
   }
-}
+};
 
 // 加载公告列表
-const noticeList = ref([])
+const noticeList = ref([]);
 const loadAnnouncementList = async () => {
   try {
-    const res = await getAnnouncementList({ pageNum: 1, pageSize: 4 })
+    const res = await getAnnouncementList({ pageNum: 1, pageSize: 4 });
     if (res.code === 200 && res.rows) {
       noticeList.value = res.rows.map((item: any) => ({
         title: item.announcementTitle,
         description: item.announcementContent?.substring(0, 50) || '',
         date: item.createTime ? new Date(item.createTime).toLocaleDateString('zh-CN', { month: '2-digit', day: '2-digit' }) : ''
-      }))
+      }));
     }
   } catch (error) {
-    console.error('加载公告失败:', error)
+    console.error('加载公告失败:', error);
   }
-}
+};
 
 onMounted(() => {
-  loadEnterpriseInfo()
-  loadAnnouncementList()
-  loadServicePersons()
-})
+  loadEnterpriseInfo();
+  loadAnnouncementList();
+  loadServicePersons();
+});
 
 // 加载专属服务人员
-const servicePersons = ref([])
+const servicePersons = ref([]);
 const loadServicePersons = async () => {
   try {
-    const res = await getServicePersons()
+    const res = await getServicePersons();
     if (res.code === 200 && res.data) {
-      servicePersons.value = res.data
+      servicePersons.value = res.data;
     }
   } catch (error) {
-    console.error('加载服务人员失败:', error)
+    console.error('加载服务人员失败:', error);
   }
-}
+};
 
 const privileges = ref([
   { name: '满免运费', description: '会员购买商品订单总金额达到标准后可免运费。' },
@@ -239,16 +238,18 @@ const privileges = ref([
   { name: '专属采购顾问', description: '会员购买商品订单总金额达到标准后可免运费。' },
   { name: '维保服务', description: '会员购买商品订单总金额达到标准后可免运费。' },
   { name: '专属库存', description: '会员购买商品订单总金额达到标准后可免运费。' }
-])
+]);
 
-const handleUpdateInfo = () => { router.push('/enterprise/companyInfo/edit') }
+const handleUpdateInfo = () => {
+  router.push('/enterprise/companyInfo/edit');
+};
 const handleTabClick = (tabKey: string) => {
-  activeTab.value = tabKey
-  if (tabKey === 'security') router.push('/enterprise/securitySetting')
-  else if (tabKey === 'purchaseHabit') router.push('/enterprise/purchaseHabit')
-  else if (tabKey === 'invoice') router.push('/enterprise/invoiceManage')
-  else if (tabKey === 'creditApply') router.push('/cost/quotaControl/apply')
-}
+  activeTab.value = tabKey;
+  if (tabKey === 'security') router.push('/enterprise/securitySetting');
+  else if (tabKey === 'purchaseHabit') router.push('/enterprise/purchaseHabit');
+  else if (tabKey === 'invoice') router.push('/enterprise/invoiceManage');
+  else if (tabKey === 'creditApply') router.push('/cost/quotaControl/apply');
+};
 </script>
 
 <style scoped lang="scss">
@@ -345,7 +346,8 @@ const handleTabClick = (tabKey: string) => {
     border-bottom: 2px solid transparent;
     transition: all 0.2s;
 
-    &:hover, &.active {
+    &:hover,
+    &.active {
       color: #e60012;
     }
     &.active {
@@ -463,7 +465,8 @@ const handleTabClick = (tabKey: string) => {
   }
 }
 
-.service-section, .privilege-section {
+.service-section,
+.privilege-section {
   background: #fff;
   border-radius: 8px;
   padding: 24px;

+ 143 - 36
src/views/enterprise/purchaseHabit/index.vue

@@ -32,18 +32,28 @@
         <!-- 产品选型 -->
         <el-form-item label="产品选型">
           <div class="tag-group">
-            <div v-for="item in productTypeOptions" :key="item"
+            <div
+              v-for="item in productTypeOptions"
+              :key="item"
               :class="['tag-item', { active: form.productTypes.includes(item) }]"
-              @click="toggleTag(form.productTypes, item)">{{ item }}</div>
+              @click="toggleTag(form.productTypes, item)"
+            >
+              {{ item }}
+            </div>
           </div>
         </el-form-item>
 
         <!-- 日常打印量 -->
         <el-form-item label="日常打印量">
           <div class="tag-group">
-            <div v-for="item in printVolumeOptions" :key="item"
+            <div
+              v-for="item in printVolumeOptions"
+              :key="item"
               :class="['tag-item', { active: form.printVolume === item }]"
-              @click="form.printVolume = item">{{ item }}</div>
+              @click="form.printVolume = item"
+            >
+              {{ item }}
+            </div>
           </div>
         </el-form-item>
 
@@ -70,9 +80,14 @@
         <!-- 主要办公采购类目 -->
         <el-form-item label="主要办公采购类目">
           <div class="tag-group">
-            <div v-for="item in categoryOptions" :key="item"
+            <div
+              v-for="item in categoryOptions"
+              :key="item"
               :class="['tag-item', { active: form.categories.includes(item) }]"
-              @click="toggleTag(form.categories, item)">{{ item }}</div>
+              @click="toggleTag(form.categories, item)"
+            >
+              {{ item }}
+            </div>
           </div>
           <el-input v-model="form.otherCategory" placeholder="其他采购类目" maxlength="50" show-word-limit class="other-input" />
         </el-form-item>
@@ -80,9 +95,14 @@
         <!-- 企业福利 -->
         <el-form-item label="企业福利">
           <div class="tag-group">
-            <div v-for="item in welfareOptions" :key="item"
+            <div
+              v-for="item in welfareOptions"
+              :key="item"
               :class="['tag-item', { active: form.welfares.includes(item) }]"
-              @click="toggleTag(form.welfares, item)">{{ item }}</div>
+              @click="toggleTag(form.welfares, item)"
+            >
+              {{ item }}
+            </div>
           </div>
           <el-input v-model="form.otherWelfare" placeholder="其他福利" maxlength="50" show-word-limit class="other-input" />
         </el-form-item>
@@ -90,9 +110,14 @@
         <!-- 产品定制需求 -->
         <el-form-item label="产品定制需求">
           <div class="tag-group">
-            <div v-for="item in customOptions" :key="item"
+            <div
+              v-for="item in customOptions"
+              :key="item"
               :class="['tag-item', { active: form.customs.includes(item) }]"
-              @click="toggleTag(form.customs, item)">{{ item }}</div>
+              @click="toggleTag(form.customs, item)"
+            >
+              {{ item }}
+            </div>
           </div>
           <el-input v-model="form.otherCustom" placeholder="其他需求" maxlength="50" show-word-limit class="other-input" />
         </el-form-item>
@@ -108,37 +133,119 @@
 </template>
 
 <script setup lang="ts">
-import { reactive } from 'vue'
-import { useRouter } from 'vue-router'
-import { ArrowLeft } from '@element-plus/icons-vue'
-import { ElMessage } from 'element-plus'
+import { reactive } from 'vue';
+import { useRouter } from 'vue-router';
+import { ArrowLeft } from '@element-plus/icons-vue';
+import { ElMessage } from 'element-plus';
+import { getCustomerPurchaseHabitData } from '@/api/pc/enterprise/purchaseHabit';
 
-const router = useRouter()
+const router = useRouter();
 
-const productTypeOptions = ['经济适用', '性价比高', '大牌商品']
-const printVolumeOptions = ['100-500张', '500-1000张', '1000-3000张', '3000张以上']
-const categoryOptions = ['办公耗材', '办公设备', '数码设备', '办公日用', '办公家具', '清洁用品', '劳保用品', '食品饮料']
-const welfareOptions = ['新年福利', '中秋福利', '端午福利', '生日福利', '员工体检', '团建活动', '节日礼品', '年终奖品']
-const customOptions = ['服装定制', '礼品定制', '包装定制', '印刷定制', 'LOGO定制', '文创定制', '工艺品定制', '其他定制']
+const productTypeOptions = ['经济适用', '性价比高', '大牌商品'];
+const printVolumeOptions = ['100-500张', '500-1000张', '1000-3000张', '3000张以上'];
+const categoryOptions = ['办公耗材', '办公设备', '数码设备', '办公日用', '办公家具', '清洁用品', '劳保用品', '食品饮料'];
+const welfareOptions = ['新年福利', '中秋福利', '端午福利', '生日福利', '员工体检', '团建活动', '节日礼品', '年终奖品'];
+const customOptions = ['服装定制', '礼品定制', '包装定制', '印刷定制', 'LOGO定制', '文创定制', '工艺品定制', '其他定制'];
 
 const form = reactive({
-  monthlyAmount: '', yearlyAmount: '', productTypes: ['经济适用'] as string[], printVolume: '100-500张',
-  buyOriginal: '是', techService: '是', categories: ['办公耗材'] as string[], otherCategory: '',
-  welfares: ['新年福利'] as string[], otherWelfare: '', customs: ['服装定制'] as string[], otherCustom: ''
-})
-
-const toggleTag = (arr: string[], item: string) => { const index = arr.indexOf(item); if (index > -1) arr.splice(index, 1); else arr.push(item) }
-const handleBack = () => { router.push('/enterprise/companyInfo') }
-const handleSave = () => { ElMessage.success('保存成功'); handleBack() }
+  monthlyAmount: '',
+  yearlyAmount: '',
+  productTypes: ['经济适用'] as string[],
+  printVolume: '100-500张',
+  buyOriginal: '是',
+  techService: '是',
+  categories: ['办公耗材'] as string[],
+  otherCategory: '',
+  welfares: ['新年福利'] as string[],
+  otherWelfare: '',
+  customs: ['服装定制'] as string[],
+  otherCustom: ''
+});
+
+const toggleTag = (arr: string[], item: string) => {
+  const index = arr.indexOf(item);
+  if (index > -1) arr.splice(index, 1);
+  else arr.push(item);
+};
+const handleBack = () => {
+  router.push('/enterprise/companyInfo');
+};
+const handleSave = () => {
+  ElMessage.success('保存成功');
+  handleBack();
+};
+
+const getPurchaseHabitData = async () => {
+  const res = await getCustomerPurchaseHabitData();
+  Object.assign(form, res);
+};
+
+onMounted(() => {
+  getPurchaseHabitData();
+});
 </script>
 
 <style scoped lang="scss">
-.purchase-habit-container { background: #f5f5f5; min-height: 100%; }
-.page-header { background: #fff; padding: 15px 20px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid #eee; .page-title { font-size: 16px; font-weight: bold; color: #333; } }
-.page-content { padding: 20px; background: #fff; margin: 20px; border-radius: 8px; }
-.tag-group { display: flex; flex-wrap: wrap; gap: 10px; .tag-item { padding: 8px 20px; border: 1px solid #ddd; border-radius: 4px; cursor: pointer; font-size: 14px; color: #666; transition: all 0.2s; &:hover { border-color: #e60012; color: #e60012; } &.active { border-color: #e60012; color: #e60012; background: #fff5f5; } } }
-.other-input { margin-top: 10px; }
-.form-footer { text-align: center; padding-top: 30px; border-top: 1px solid #eee; margin-top: 20px; }
-:deep(.el-form-item__label) { font-weight: 500; color: #333; }
-:deep(.el-radio) { margin-right: 30px; }
+.purchase-habit-container {
+  background: #f5f5f5;
+  min-height: 100%;
+}
+.page-header {
+  background: #fff;
+  padding: 15px 20px;
+  display: flex;
+  align-items: center;
+  gap: 10px;
+  border-bottom: 1px solid #eee;
+  .page-title {
+    font-size: 16px;
+    font-weight: bold;
+    color: #333;
+  }
+}
+.page-content {
+  padding: 20px;
+  background: #fff;
+  margin: 20px;
+  border-radius: 8px;
+}
+.tag-group {
+  display: flex;
+  flex-wrap: wrap;
+  gap: 10px;
+  .tag-item {
+    padding: 8px 20px;
+    border: 1px solid #ddd;
+    border-radius: 4px;
+    cursor: pointer;
+    font-size: 14px;
+    color: #666;
+    transition: all 0.2s;
+    &:hover {
+      border-color: #e60012;
+      color: #e60012;
+    }
+    &.active {
+      border-color: #e60012;
+      color: #e60012;
+      background: #fff5f5;
+    }
+  }
+}
+.other-input {
+  margin-top: 10px;
+}
+.form-footer {
+  text-align: center;
+  padding-top: 30px;
+  border-top: 1px solid #eee;
+  margin-top: 20px;
+}
+:deep(.el-form-item__label) {
+  font-weight: 500;
+  color: #333;
+}
+:deep(.el-radio) {
+  margin-right: 30px;
+}
 </style>

+ 105 - 77
src/views/reconciliation/billManage/index.vue

@@ -6,25 +6,27 @@
 
     <el-table v-loading="loading" :data="tableData" border style="width: 100%">
       <el-table-column prop="billNo" label="对账编号" min-width="130" align="center" />
-      <el-table-column prop="billDate" label="对账日期" min-width="110" align="center" />
+      <el-table-column prop="billDate" label="对账日期" min-width="110" align="center">
+        <template #default="{ row }">{{ parseTime(row.billDate, '{y}-{m}-{d}') }}</template>
+      </el-table-column>
       <el-table-column prop="amount" label="对账单金额" min-width="110" align="center">
         <template #default="{ row }">¥{{ row.amount.toFixed(2) }}</template>
       </el-table-column>
       <el-table-column prop="billStatus" label="对账状态" min-width="90" align="center">
         <template #default="{ row }">
-          {{ billStatusMap[row.billStatus] || '-' }}
+          {{ getDictLabel(statement_status, row.billStatus) }}
         </template>
       </el-table-column>
       <el-table-column prop="invoiceStatus" label="开票状态" min-width="90" align="center">
         <template #default="{ row }">
-          <span :style="{ color: row.invoiceStatus === '1' ? '#e60012' : '' }">
-            {{ invoiceStatusMap[row.invoiceStatus] || '-' }}
+          <span :style="{ color: row.invoiceStatus === '0' ? '#e60012' : '' }">
+            {{ getDictLabel(invoice_issuance_status, row.invoiceStatus) }}
           </span>
         </template>
       </el-table-column>
       <el-table-column prop="payStatus" label="支付状态" min-width="90" align="center">
         <template #default="{ row }">
-          {{ payStatusMap[row.payStatus] || '-' }}
+          {{ getDictLabel(payment_status, row.payStatus) }}
         </template>
       </el-table-column>
       <el-table-column label="操作" width="100" align="center">
@@ -42,44 +44,49 @@
 </template>
 
 <script setup lang="ts">
-import { reactive, ref, onMounted, watch } from 'vue'
-import { ElMessage, ElMessageBox } from 'element-plus'
-import { PageTitle, SearchBar, TablePagination } from '@/components'
-import { getStatementList, confirmStatement } from '@/api/pc/enterprise/statement'
-import type { StatementOrder } from '@/api/pc/enterprise/statementTypes'
-import { getDictByType } from '@/api/pc/system/dict'
+import { reactive, ref, onMounted, watch } from 'vue';
+import { ElMessage, ElMessageBox } from 'element-plus';
+import { PageTitle, SearchBar, TablePagination } from '@/components';
+import { getStatementList, confirmStatement } from '@/api/pc/enterprise/statement';
+import type { StatementOrder } from '@/api/pc/enterprise/statementTypes';
+import { getDictByType } from '@/api/pc/system/dict';
+
+const { proxy } = getCurrentInstance() as ComponentInternalInstance;
+const { invoice_issuance_status, statement_status, payment_status } = toRefs<any>(
+  proxy?.useDict('invoice_issuance_status', 'statement_status', 'payment_status')
+);
 
 const searchForm = reactive({
-  keyword: '',  // 对账编号
+  keyword: '', // 对账编号
   dateRange: [],
   billStatus: '',
   invoiceStatus: '',
   payStatus: ''
-})
+});
 
-const billStatusOptions = ref([{ label: '全部', value: '' }])
-const invoiceStatusOptions = ref([{ label: '全部', value: '' }])
-const payStatusOptions = ref([{ label: '全部', value: '' }])
+const billStatusOptions = ref([{ label: '全部', value: '' }]);
+const invoiceStatusOptions = ref([{ label: '全部', value: '' }]);
+const payStatusOptions = ref([{ label: '全部', value: '' }]);
 
 // 状态值到文本的映射
-const billStatusMap = ref<Record<string, string>>({})
-const invoiceStatusMap = ref<Record<string, string>>({})
-const payStatusMap = ref<Record<string, string>>({})
+const billStatusMap = ref<Record<string, string>>({});
+const invoiceStatusMap = ref<Record<string, string>>({});
+const payStatusMap = ref<Record<string, string>>({});
 
 const filters = ref([
   { field: 'billStatus', label: '对账状态', options: billStatusOptions.value },
   { field: 'invoiceStatus', label: '开票状态', options: invoiceStatusOptions.value },
   { field: 'payStatus', label: '支付状态', options: payStatusOptions.value }
-])
+]);
 
-const pagination = reactive({ page: 1, pageSize: 5, total: 0 })
-const tableData = ref<any[]>([])
-const loading = ref(false)
+const pagination = reactive({ page: 1, pageSize: 5, total: 0 });
+const tableData = ref<any[]>([]);
+const loading = ref(false);
 
 // 加载对账单列表
 const loadStatementList = async () => {
   try {
-    loading.value = true
+    loading.value = true;
     const res = await getStatementList({
       pageNum: pagination.page,
       pageSize: pagination.pageSize,
@@ -87,7 +94,7 @@ const loadStatementList = async () => {
       statementStatus: searchForm.billStatus,
       isInvoiceStatus: searchForm.invoiceStatus,
       isPaymentStatus: searchForm.payStatus
-    })
+    });
 
     if (res.code === 200 && res.rows) {
       tableData.value = res.rows.map((item: StatementOrder) => ({
@@ -98,101 +105,122 @@ const loadStatementList = async () => {
         billStatus: item.statementStatus,
         invoiceStatus: item.isInvoiceStatus,
         payStatus: item.isPaymentStatus
-      }))
-      pagination.total = res.total || 0
+      }));
+      pagination.total = res.total || 0;
     }
   } catch (error) {
-    console.error('加载对账单列表失败:', error)
-    ElMessage.error('加载对账单列表失败')
+    console.error('加载对账单列表失败:', error);
+    ElMessage.error('加载对账单列表失败');
   } finally {
-    loading.value = false
+    loading.value = false;
   }
-}
+};
 
 // 监听分页变化
-watch(() => [pagination.page, pagination.pageSize], () => {
-  loadStatementList()
-})
+watch(
+  () => [pagination.page, pagination.pageSize],
+  () => {
+    loadStatementList();
+  }
+);
 
 // 监听搜索条件变化
-watch(() => [searchForm.keyword, searchForm.billStatus, searchForm.invoiceStatus, searchForm.payStatus], () => {
-  pagination.page = 1
-  loadStatementList()
-})
+watch(
+  () => [searchForm.keyword, searchForm.billStatus, searchForm.invoiceStatus, searchForm.payStatus],
+  () => {
+    pagination.page = 1;
+    loadStatementList();
+  }
+);
+
+const getDictLabel = (dictOptions: any[], value: string) => {
+  if (!dictOptions || !value) return value;
+  const dict = dictOptions.find((item) => item.value === value);
+  return dict ? dict.label : value;
+};
 
 // 加载字典数据
 const loadDictData = async () => {
   try {
     // 加载对账状态
-    const statementRes = await getDictByType('statement_status')
+    const statementRes = await getDictByType('statement_status');
     if (statementRes.data) {
       billStatusOptions.value = [
         { label: '全部', value: '' },
-        ...statementRes.data.map(item => ({
+        ...statementRes.data.map((item) => ({
           label: item.dictLabel,
           value: item.dictValue
         }))
-      ]
-      filters.value[0].options = billStatusOptions.value
+      ];
+      filters.value[0].options = billStatusOptions.value;
 
       // 构建状态值到文本的映射
-      billStatusMap.value = statementRes.data.reduce((map, item) => {
-        map[item.dictValue] = item.dictLabel
-        return map
-      }, {} as Record<string, string>)
+      billStatusMap.value = statementRes.data.reduce(
+        (map, item) => {
+          map[item.dictValue] = item.dictLabel;
+          return map;
+        },
+        {} as Record<string, string>
+      );
     }
 
     // 加载开票状态
-    const invoiceRes = await getDictByType('invoice_issuance_status')
+    const invoiceRes = await getDictByType('invoice_issuance_status');
     if (invoiceRes.data) {
       invoiceStatusOptions.value = [
         { label: '全部', value: '' },
-        ...invoiceRes.data.map(item => ({
+        ...invoiceRes.data.map((item) => ({
           label: item.dictLabel,
           value: item.dictValue
         }))
-      ]
-      filters.value[1].options = invoiceStatusOptions.value
+      ];
+      filters.value[1].options = invoiceStatusOptions.value;
 
       // 构建状态值到文本的映射
-      invoiceStatusMap.value = invoiceRes.data.reduce((map, item) => {
-        map[item.dictValue] = item.dictLabel
-        return map
-      }, {} as Record<string, string>)
+      invoiceStatusMap.value = invoiceRes.data.reduce(
+        (map, item) => {
+          map[item.dictValue] = item.dictLabel;
+          return map;
+        },
+        {} as Record<string, string>
+      );
     }
 
     // 加载支付状态
-    const payRes = await getDictByType('payment_status')
+    const payRes = await getDictByType('payment_status');
     if (payRes.data) {
       payStatusOptions.value = [
         { label: '全部', value: '' },
-        ...payRes.data.map(item => ({
+        ...payRes.data.map((item) => ({
           label: item.dictLabel,
           value: item.dictValue
         }))
-      ]
-      filters.value[2].options = payStatusOptions.value
+      ];
+      filters.value[2].options = payStatusOptions.value;
 
       // 构建状态值到文本的映射
-      payStatusMap.value = payRes.data.reduce((map, item) => {
-        map[item.dictValue] = item.dictLabel
-        return map
-      }, {} as Record<string, string>)
+      payStatusMap.value = payRes.data.reduce(
+        (map, item) => {
+          map[item.dictValue] = item.dictLabel;
+          return map;
+        },
+        {} as Record<string, string>
+      );
     }
   } catch (error) {
-    console.error('加载字典数据失败:', error)
+    console.error('加载字典数据失败:', error);
   }
-}
+};
 
 // 页面加载时获取数据
 onMounted(() => {
-  loadDictData()
-  loadStatementList()
-})
+  loadDictData();
+  loadStatementList();
+});
 
 const handleView = (row: any) => {
-  ElMessage.info(`查看对账单:${row.billNo}`)
-}
+  ElMessage.info(`查看对账单:${row.billNo}`);
+};
 
 const handleConfirm = async (row: any) => {
   try {
@@ -200,19 +228,19 @@ const handleConfirm = async (row: any) => {
       confirmButtonText: '确定',
       cancelButtonText: '取消',
       type: 'warning'
-    })
+    });
 
-    await confirmStatement({ id: row.id })
-    row.billStatus = '2'
-    ElMessage.success('确认成功')
-    loadStatementList()
+    await confirmStatement({ id: row.id });
+    row.billStatus = '2';
+    ElMessage.success('确认成功');
+    loadStatementList();
   } catch (error) {
     if (error !== 'cancel') {
-      console.error('确认对账单失败:', error)
-      ElMessage.error('确认对账单失败')
+      console.error('确认对账单失败:', error);
+      ElMessage.error('确认对账单失败');
     }
   }
-}
+};
 </script>
 
 <style scoped>