Bläddra i källkod

✨ 新增关联公司字段和选择功能- 在 ShopDetail 模型中添加 belongsCompany 字段
- 在 EditDrawer 组件中增加关联公司选择框
- 修改 ShopDetail组件以显示关联公司信息
- 在 useColumns 文件中添加关联公司列的定义
- 更新 API 文件,添加获取公司列表的接口

WanGxC 8 månader sedan
förälder
incheckning
3245784961

+ 6 - 0
src/views/shop-information/api.ts

@@ -65,6 +65,12 @@ export function getShopSelect() {
     method: 'GET',
   });
 }
+export function getCompanySelect() {
+  return request({
+    url: '/api/assets/company/box/',
+    method: 'GET',
+  });
+}
 
 export function updateShopDetail(body: any) {
   return request({

+ 17 - 2
src/views/shop-information/components/EditDrawer.vue

@@ -5,17 +5,18 @@
  * @Author: Cheney
  */
 
-import type { FormInstance, FormRules } from 'element-plus';
+import { ElMessage, FormInstance, FormRules } from 'element-plus';
 import { useResponse } from '/@/utils/useResponse';
 import * as api from '/@/views/shop-information/api';
 
 
 const loading = ref(false);
 const isOpen = defineModel({ default: false });
-const { gridOptions, platformNumber, formSelect } = defineProps<{
+const { gridOptions, platformNumber, formSelect, companySelect } = defineProps<{
   gridOptions: any;
   platformNumber: any;
   formSelect: any;
+  companySelect: any;
 }>();
 
 const emit = defineEmits([ 'refresh' ]);
@@ -36,6 +37,7 @@ interface RuleForm {
   line: string[];
   ipaddress: string;
   company: string;
+  belongsCompany: string;
   companyEnglishName: string;
   address: string; // 新增
   juridicalPerson: string; // 新增
@@ -64,6 +66,7 @@ const ruleForm = reactive<RuleForm>({
   line: [],
   ipaddress: '',
   company: '',
+  belongsCompany: '',
   companyEnglishName: '',
   address: '',
   juridicalPerson: '',
@@ -110,6 +113,7 @@ const rules = reactive<FormRules<RuleForm>>({
   company: [
     { message: 'Please input activity form', trigger: 'blur' }
   ],
+  belongsCompany: [ { required: true, message: 'Please Select belongsCompany', trigger: 'change' } ],
   companyEnglishName: [
     { message: 'Please input Company English Name', trigger: 'blur' }
   ],
@@ -157,6 +161,7 @@ const submitForm = async (formEl: FormInstance | undefined) => {
     if (valid) {
       await useResponse({ id: gridOptions.data[0].id, partial: 1, formData: ruleForm }, api.updateShopDetail, loading);
       isOpen.value = false;
+      ElMessage.success('编辑成功');
       emit('refresh');
     } else {
       console.log('error submit!', fields);
@@ -236,6 +241,16 @@ function replaceCol() {
       <el-form-item label="公司" prop="company">
         <el-input v-model="ruleForm.company"/>
       </el-form-item>
+      <el-form-item label="关联公司" prop="belongsCompany">
+        <el-select v-model="ruleForm.belongsCompany" placeholder="请选择所属公司">
+          <el-option
+              v-for="item in companySelect"
+              :key="item.id"
+              :label="item.company"
+              :value="item.id">
+          </el-option>
+        </el-select>
+      </el-form-item>
       <el-form-item label="公司英文名称" prop="companyEnglishName">
         <el-input v-model="ruleForm.companyEnglishName"/>
       </el-form-item>

+ 9 - 1
src/views/shop-information/components/ShopDetail.vue

@@ -8,7 +8,7 @@
 import { Edit, Monitor, Picture as IconPicture, RefreshLeft, Timer } from '@element-plus/icons-vue';
 import { useResponse } from '/@/utils/useResponse';
 import * as api from '/@/views/shop-information/api';
-import { computerColumns, historyColumns, shopCurrentColumns } from '/@/views/shop-information/useColumns';
+import { computerColumns, historyColumns, shopCurrentColumns, companySelect } from '/@/views/shop-information/useColumns';
 import { useTableData } from '/@/utils/useTableData';
 import { usePagination } from '/@/utils/usePagination';
 import EditDrawer from './EditDrawer.vue';
@@ -59,6 +59,11 @@ const formSelect = ref<{ country: string[], line: string[] }>({
   line: []
 });
 
+// const companySelect = ref<{ id: string, company: string }>({
+//   id: '',
+//   company: ''
+// });
+
 onBeforeMount(() => {
   fetchShopDetailOverview();
   handleTabChange(selectedTab.value);
@@ -68,6 +73,8 @@ onBeforeMount(() => {
 async function fetchSelect() {
   const res = await useResponse({}, api.getShopSelect);
   formSelect.value = res.data;
+  // const ret = await useResponse({}, api.getCompanySelect);
+  // companySelect.value = ret.data;
 }
 
 async function fetchShopDetailOverview() {
@@ -236,6 +243,7 @@ function handleRefresh() {
         v-if="isOpen"
         v-model="isOpen"
         :formSelect
+        :companySelect
         :gridOptions="gridOptions"
         :platformNumber
         @refresh="handleRefresh"

+ 16 - 2
src/views/shop-information/useColumns.tsx

@@ -1,8 +1,14 @@
 import { useCountryInfoStore } from '/@/stores/countryInfo';
+import { useResponse } from '/@/utils/useResponse';
+import * as api from '/@/views/shop-information/api';
 
 
 const countryInfoStore = useCountryInfoStore();
 
+export const companySelect: Ref<any[]> = ref([]);
+const ret = await useResponse({}, api.getCompanySelect);
+companySelect.value = ret.data;
+
 export const platformColumns = [
   { type: 'seq', width: 50, align: 'center', fixed: 'left' },
   {
@@ -268,6 +274,15 @@ export const shopCurrentColumns = [
       }
     }
   },
+  {
+    field: 'belongsCompany', title: '关联公司', minWidth: 'auto', align: 'center',
+    slots: {
+      default({ row }: any) {
+        const company = companySelect.value.find(c => c.id === row.belongsCompany);
+        return <span class="font-medium">{ company ? company.company : '--' }</span>;
+      }
+    }
+  },
   {
     field: 'company', title: '公司名称', minWidth: 'auto', align: 'center',
     slots: {
@@ -355,7 +370,6 @@ export const shopCurrentColumns = [
     field: 'shopPhoneAndName', title: '主账户电话', minWidth: 'auto', align: 'center',
     slots: {
       default({ row }: any) {
-        console.log('Row data:', row); // 打印行数据,检查是否正确
         return <span class={ 'font-medium' }>{ row.shopPhoneAndName !== null ? row.shopPhoneAndName : '--' }</span>;
       }
     }
@@ -544,7 +558,7 @@ export const historyColumns: any = [
             class={ 'font-medium' }>{ row.receivablesAccountCompany ? row.receivablesAccountCompany : '--' }</span>;
       }
     }
-  },  
+  },
   {
     field: 'vatNumber', title: 'VAT税号', minWidth: 'auto', align: 'center',
     slots: {