Browse Source

feat: 会员身份

LAPTOP-2ACP37JG\shark 4 years ago
parent
commit
05fdeb2ae1
2 changed files with 26 additions and 22 deletions
  1. 20 16
      src/views/member/member/data.ts
  2. 6 6
      src/views/member/member/popup.vue

+ 20 - 16
src/views/member/member/data.ts

@@ -4,6 +4,7 @@ import { adapt } from '/@/utils/adapt';
 import { h } from 'vue';
 import CustomInput from './customCom/CustomInput.vue';
 import moment from 'moment';
+import { Tag } from 'ant-design-vue';
 
 const adaptWidth = adapt();
 
@@ -25,11 +26,14 @@ export const columns: BasicColumn[] = [
   },
   {
     title: '会员身份',
-    dataIndex: 'status',
+    dataIndex: 'type',
     width: 130,
-    customRender({ record }) {
-      const options = ['个人', '单位'];
-      return options[record.status];
+    customRender: ({ record }) => {
+      const type = record.type;
+      const enable = type === 'person';
+      const color = enable ? 'green' : 'red';
+      const text = enable ? '个人' : '单位';
+      return h(Tag, { color: color }, () => text);
     },
     sorter: true,
   },
@@ -107,14 +111,14 @@ export function getFormConfig(): Partial<FormProps> {
         },
       },
       {
-        field: `status`,
+        field: `type`,
         label: `会员身份`,
         component: 'Select',
         componentProps: {
           placeholder: '会员身份',
           options: [
-            { label: '个人', value: 0 },
-            { label: '单位', value: 1 },
+            { label: '个人', value: 'person' },
+            { label: '单位', value: 'unit' },
           ],
         },
         colProps: {
@@ -193,7 +197,7 @@ export function getFormConfig(): Partial<FormProps> {
 // =================popup================================
 export const schemas: FormSchema[] = [
   {
-    field: 'status',
+    field: 'type',
     label: '会员身份',
     component: 'RadioButtonGroup',
     labelWidth: adaptWidth.labelWidth,
@@ -201,16 +205,16 @@ export const schemas: FormSchema[] = [
       span: adaptWidth.elContainer,
     },
     componentProps: (value) => {
-      console.log(`value ---- status`, value);
+      console.log(`value ---- type`, value);
       return {
         // disabled: true,
         options: [
-          { label: '个人', value: 0 },
-          { label: '单位', value: 1 },
+          { label: '个人', value: 'person' },
+          { label: '单位', value: 'unit' },
         ],
       };
     },
-    defaultValue: 0,
+    defaultValue: 'person',
   },
   {
     field: 'name',
@@ -230,13 +234,13 @@ export const schemas: FormSchema[] = [
       });
     },
     show: ({ values }) => {
-      if (!values.status) {
+      if (values.type == 'person') {
         return true;
       }
       return false;
     },
     required: ({ values }) => {
-      if (!values.status) {
+      if (values.type == 'person') {
         return true;
       }
       return false;
@@ -261,13 +265,13 @@ export const schemas: FormSchema[] = [
       });
     },
     show: ({ values }) => {
-      if (values.status) {
+      if (values.type == 'unit') {
         return true;
       }
       return false;
     },
     required: ({ values }) => {
-      if (values.status) {
+      if (values.type == 'unit') {
         return true;
       }
       return false;

+ 6 - 6
src/views/member/member/popup.vue

@@ -49,12 +49,12 @@
           role.id = data.id;
           updateSchema([
             {
-              field: 'status',
+              field: 'type',
               componentProps: {
                 disabled: true,
                 options: [
-                  { label: '个人', value: 0 },
-                  { label: '单位', value: 1 },
+                  { label: '个人', value: 'person' },
+                  { label: '单位', value: 'unit' },
                 ],
               },
             },
@@ -75,12 +75,12 @@
           role.id = 0;
           updateSchema([
             {
-              field: 'status',
+              field: 'type',
               componentProps: {
                 disabled: false,
                 options: [
-                  { label: '个人', value: 0 },
-                  { label: '单位', value: 1 },
+                  { label: '个人', value: 'person' },
+                  { label: '单位', value: 'unit' },
                 ],
               },
             },