瀏覽代碼

Merge branch 'feature/mockApi' of http://192.168.0.115:3000/zhangyupeng/zfb_mp into feature/mockApi

gemercheung 3 年之前
父節點
當前提交
7d32e4dd26

+ 11 - 0
src/api/corporation/modal.ts

@@ -6,6 +6,7 @@ import {
   checkUserParam,
   SubAccountUsers,
   selectCompanyParam,
+  auditParam,
 } from './model';
 import type { Result } from '/#/axios';
 
@@ -16,6 +17,7 @@ enum Api {
   checkUserAddAble = '/zfb-api/zfb/company/back/checkUserAddAble',
   saveSubUsers = '/zfb-api/zfb/company/saveSubUsers',
   selectCompanyById = '/zfb-api/zfb/company/selectCompanyById',
+  auditCompany = '/zfb-api/zfb/company/auditCompany',
 }
 /**
  * @description: Get sample list value
@@ -40,6 +42,15 @@ export const checkDevice = (params: checkDeiceParam) =>
       ignoreCancelToken: true,
     },
   });
+export const auditCompany = (params: auditParam) =>
+  defHttp.post<Result>({
+    url: Api.auditCompany,
+    params,
+    headers: {
+      // @ts-ignore
+      ignoreCancelToken: true,
+    },
+  });
 export const selectUserList = (params: selectUserListParam) =>
   defHttp.post<Result>({
     url: Api.selectUserList,

+ 5 - 1
src/api/corporation/model.ts

@@ -12,6 +12,10 @@ export interface addDeiceParam {
 export interface checkDeiceParam {
   childName: string | null;
 }
+export interface auditParam {
+  state: number | null;
+  id: number | null;
+}
 
 export interface selectUserListParam {
   id: number | null;
@@ -25,7 +29,7 @@ export interface checkUserParam {
 export interface SubAccountUsers {
   id: number | null;
   subNum: string | null;
-  subUsers: SubAccountUser[];
+  subUsers: Recordable<any>[]; //SubAccountUser[];
 }
 
 export interface selectCompanyParam {

+ 23 - 10
src/views/dashboard/corporation/SubaccountModal.vue

@@ -24,6 +24,8 @@
       <div class="table_list">
         <BasicTable
           title="子账户列表"
+          ref="tableRef"
+          rowKey="id"
           :columns="columns"
           :showIndexColumn="false"
           :dataSource="myData.TableData"
@@ -48,7 +50,7 @@
             />
           </template>
         </BasicTable>
-        <AddModal @register="register4" />
+        <AddModal @register="register4" @addtable="addTabledata" />
       </div>
     </div>
     <EditModal @register="registerEdit" />
@@ -65,9 +67,10 @@
     ComponentOptions,
     shallowRef,
     computed,
+    inject,
   } from 'vue';
   import { BasicModal, useModalInner, useModal } from '/@/components/Modal';
-  import { BasicTable, BasicColumn, TableAction } from '/@/components/Table';
+  import { BasicTable, BasicColumn, TableAction, TableActionType } from '/@/components/Table';
   import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
   import { selectUserList, saveSubUsers } from '/@/api/corporation/modal';
   import { useMessage } from '/@/hooks/web/useMessage';
@@ -79,12 +82,14 @@
     props: {
       userData: { type: Object },
     },
-    emits: ['reload'],
-    setup(props, context) {
+    emits: ['addtable'],
+    setup(props) {
       const { createConfirm, createMessage } = useMessage();
       const currentModal = shallowRef<Nullable<ComponentOptions>>(null);
+      const tableRef = ref<Nullable<TableActionType>>(null);
       const [register4, { openModal: addopenModal }] = useModal();
       const modelRef = ref({});
+      const reload = inject('tablereload');
       // const editList = ref({
       //   list:[]
       // })
@@ -202,6 +207,7 @@
         getApiList();
       }
       function numOnChange(event) {
+        myData.subNum = event;
         console.log('numOnChange', event);
       }
       async function handleDelete(item, type) {
@@ -215,15 +221,14 @@
           });
         } else {
           //解除
-          let confirm = await createConfirm({
+          createConfirm({
             iconType: 'warning',
             title: '提示',
             content: '确定要解绑该子账号?',
             onOk: async () => {
-              // await this.logout(true);
+              tableRef.value.deleteTableDataRecord(item.id);
             },
           });
-          console.log('confirm', confirm);
         }
       }
       function pageChange(page, d, a) {
@@ -265,19 +270,25 @@
         });
       }
       async function saveTable() {
+        let tableData = tableRef.value.getDataSource() || [];
         let res = await saveSubUsers({
           id: myData.id,
           subNum: myData.subNum,
-          subUsers: myData.TableData,
+          subUsers: tableData,
         });
-        console.log('saveTable', res, context);
-        context.emit('reload');
+        console.log('saveTable', res);
+        createMessage.success('操作成功');
+        reload();
         closeModal();
       }
+      function addTabledata(val) {
+        console.log('addTabledata', val);
+      }
       onMounted(async () => {
         myData.id && getApiList();
       });
       return {
+        tableRef,
         register,
         handleDelete,
         registerEdit,
@@ -298,6 +309,8 @@
         addopenModal,
         saveTable,
         closeModal,
+        addTabledata,
+        reload,
       };
     },
   });

+ 75 - 70
src/views/dashboard/corporation/deviceModal.vue

@@ -3,16 +3,24 @@
     v-bind="$attrs"
     @register="register"
     title="新增设备"
-    @ok="submitMolad"
+    @ok="submitMolad(true)"
+    cancelText="拒绝"
+    okText="通过"
+    @cancel="submitMolad(false)"
     @visible-change="handleVisibleChange"
   >
     <div class="pt-3px pr-3px">
       <BasicForm @register="registerForm">
-        <template #userName="{ model, field }">
+        <template #text="{ model, field }">
           {{ model[field] }}
         </template>
-        <template #name="{ model, field }">
-          {{ model[field] }}
+        <template #link="{ model, field }">
+          <a :href="model[field]" target="_blank">{{ model[field] }}</a>
+        </template>
+        <template #iamge="{ model, field }">
+          <div v-if="model[field]">
+            <TableImg :size="200" :simpleShow="true" :imgList="[model[field]]" />
+          </div>
         </template>
       </BasicForm>
     </div>
@@ -20,12 +28,13 @@
 </template>
 <script lang="ts">
   import { defineComponent, ref, nextTick } from 'vue';
+  import { TableImg } from '/@/components/Table';
   import { BasicModal, useModalInner } from '/@/components/Modal';
   import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
   import { useMessage } from '/@/hooks/web/useMessage';
-  import { AddDevice, checkDevice } from '/@/api/corporation/modal';
+  import { checkDevice, selectCompanyById, auditCompany } from '/@/api/corporation/modal';
   export default defineComponent({
-    components: { BasicModal, BasicForm },
+    components: { BasicModal, BasicForm, TableImg },
     props: {
       userData: { type: Object },
     },
@@ -33,7 +42,7 @@
       const modelRef = ref({});
       const num = ref(0);
       const { createMessage } = useMessage();
-      const { success, error } = createMessage;
+      const { error, success } = createMessage; //success,
       const [register, { closeModal }] = useModalInner((data) => {
         data && onDataReceive(data);
       });
@@ -58,44 +67,64 @@
       };
       const schemas: FormSchema[] = [
         {
-          field: 'userName',
-          label: '企业名称',
-          slot: 'userName',
+          field: 'name',
+          label: '信息标题',
+          slot: 'text',
+          component: 'Input',
+        },
+        {
+          field: 'contacts',
+          label: '联系人',
+          slot: 'text',
+          component: 'Input',
+        },
+        {
+          field: 'phone',
+          label: '手机号',
+          slot: 'text',
+          component: 'Input',
+        },
+        {
+          field: 'area',
+          label: '所属区域',
+          slot: 'text',
+          component: 'Input',
+        },
+        {
+          field: 'address',
+          label: '详细地址',
+          slot: 'text',
+          component: 'Input',
+        },
+        {
+          field: 'website',
+          label: '企业官网',
+          slot: 'text',
           component: 'Input',
         },
         {
           field: 'name',
-          label: '企业账号',
+          label: '企业简介',
           slot: 'name',
           component: 'Input',
         },
         {
-          field: 'num',
-          component: 'InputNumber',
-          label: '设备数量',
-          colProps: {
-            span: 8,
-          },
-          componentProps: () => {
-            return {
-              // xxxx props schema, tableAction, formModel  checkDevice
-              min: 0,
-              onChange: numOnChange,
-            };
-          },
+          field: 'logo',
+          label: '企业LOGO',
+          slot: 'iamge',
+          component: 'Input',
+        },
+        {
+          field: 'qualification',
+          label: '企业资质',
+          slot: 'iamge',
+          component: 'Input',
         },
       ];
       // let schemasList = []
       const [
         registerForm,
-        {
-          setFieldsValue,
-          resetFields,
-          getFieldsValue,
-          validateFields,
-          appendSchemaByField,
-          removeSchemaByFiled,
-        },
+        { setFieldsValue, resetFields, appendSchemaByField, removeSchemaByFiled },
       ] = useForm({
         labelWidth: 120,
         schemas,
@@ -104,50 +133,26 @@
           span: 24,
         },
       });
-      async function submitMolad() {
-        let formData = {
-          ...getFieldsValue(),
-        };
-        let validate = false;
-        try {
-          const res = await validateFields();
-          validate = true;
-          console.log('passing', res, formData);
-        } catch (error: unknown) {
-          console.log('not passing', error);
-        }
-        if (validate) {
-          const { subNum, id, userName } = modelRef.value;
-          try {
-            const res = await AddDevice({
-              childName: null,
-              id,
-              subNum,
-              userName,
-            });
-            if (res.code == 200) {
-              success(res.message);
-              closeModal();
-            }
-          } catch (errors) {
-            error('errors');
-            console.log('not passing', error);
-          }
-        }
+      async function submitMolad(val) {
+        let res = await auditCompany({
+          id: modelRef.value.id,
+          state: val ? 1 : 2,
+        });
+        success(res);
+        closeModal();
       }
-      function onDataReceive(data) {
+      async function onDataReceive(data) {
         // 方式1;
         resetFields();
+        let { id } = data.record;
+        let res = await selectCompanyById({
+          id,
+        });
+        console.log('setFieldsValue', res);
         setFieldsValue({
-          ...data.record,
+          ...res,
         });
-
-        // // 方式2
         modelRef.value = { ...data.record };
-
-        // setProps({
-        //   ...data.record,
-        // });
       }
       function numOnChange(event) {
         const value = Number(event);

+ 2 - 6
src/views/dashboard/corporation/index.vue

@@ -54,13 +54,12 @@
       </template>
     </BasicTable>
     <chargeModal @register="registerChargeModal" />
-    <deviceModal @register="registerDeviceModal" />
     <SubaccountModal @reload="tablereload" @register="registerSubaccountModal" />
   </div>
 </template>
 <script lang="ts">
   import { useI18n } from '/@/hooks/web/useI18n';
-  import { defineComponent } from 'vue';
+  import { defineComponent, provide } from 'vue';
   import { BasicTable, useTable, BasicColumn, FormProps, TableAction } from '/@/components/Table';
   // import { CollapseContainer } from '/@/components/Container';
   import { CropperAvatar } from '/@/components/Cropper';
@@ -70,7 +69,6 @@
   import { ListApi, uploadLogoApi } from '/@/api/corporation/list';
   import { useModal } from '/@/components/Modal';
   import chargeModal from './chargeModal.vue';
-  import deviceModal from './deviceModal.vue';
   import SubaccountModal from './SubaccountModal.vue';
   import { Time } from '/@/components/Time';
 
@@ -80,13 +78,11 @@
       CropperAvatar,
       TableAction,
       chargeModal,
-      deviceModal,
       SubaccountModal,
       Time,
     },
     setup() {
       const [registerChargeModal, { openModal: openChargeModal }] = useModal();
-      const [registerDeviceModal, { openModal: openDeviceModal }] = useModal();
       const [registerSubaccountModal, { openModal: openSubaccountModal }] = useModal();
       const { t } = useI18n();
       const columns: BasicColumn[] = [
@@ -176,6 +172,7 @@
         ],
       };
       // { getForm }
+      provide('tablereload', tablereload);
       const [registerTable, { reload }] = useTable({
         title: '企业账号',
         api: ListApi,
@@ -223,7 +220,6 @@
         t,
         registerTable,
         registerChargeModal,
-        registerDeviceModal,
         registerSubaccountModal,
         handleOpenModal,
         uploadApi: uploadApi as any,

+ 17 - 6
src/views/dashboard/corporation/verify.vue

@@ -7,19 +7,22 @@
           {{ state || '审核中' }}
         </Tag>
       </template>
-      <template #action>
+      <template #action="{ record }">
         <TableAction
           :actions="[
             {
               icon: 'clarity:info-standard-line',
-              tooltip: '详细信息',
+              // tooltip: '详细信息',
               label: '详细信息',
-              onClick: () => {},
+              onClick: () => {
+                infoText(record);
+              },
             },
           ]"
         />
       </template>
     </BasicTable>
+    <deviceModal @register="registerDeviceModal" />
   </div>
 </template>
 <script lang="ts">
@@ -28,14 +31,17 @@
   import { uploadApi } from '/@/api/sys/upload';
   import { Tag } from 'ant-design-vue';
   import { ListVerifyApi } from '/@/api/corporation/list';
+  import deviceModal from './deviceModal.vue';
+  import { useModal } from '/@/components/Modal';
 
   export default defineComponent({
-    components: { BasicTable, Tag, TableAction },
+    components: { BasicTable, Tag, TableAction, deviceModal },
     setup() {
+      const [registerDeviceModal, { openModal: openDeviceModal }] = useModal();
       const columns: BasicColumn[] = [
         {
           title: '提交日期',
-          dataIndex: 'startTime',
+          dataIndex: 'createTime',
           width: 180,
         },
         {
@@ -45,7 +51,7 @@
         },
         {
           title: '手机号',
-          dataIndex: 'phone',
+          dataIndex: 'userName',
           width: 120,
         },
         {
@@ -104,10 +110,15 @@
           totalField: 'total',
         },
       });
+      function infoText(record) {
+        openDeviceModal(true, { record });
+      }
       // pagination.value = { pageSize: 20 };
       return {
         registerTable,
         uploadApi: uploadApi as any,
+        registerDeviceModal,
+        infoText,
       };
     },
   });

+ 83 - 2
src/views/dashboard/product/ref.vue

@@ -1,5 +1,86 @@
 <template>
-  <div> 商品属性 </div>
+  <BasicTable @register="registerTable">
+    <template #toolbar>
+      <a-button type="primary" @click="handleCreate"> 新增商品分类</a-button>
+      <a-button type="warning" @click="expandAll">展开全部</a-button>
+      <a-button type="error" @click="collapseAll">折叠全部</a-button>
+    </template>
+    <template #action="{ record }">
+      <TableAction
+        :actions="[
+          {
+            icon: 'clarity:note-edit-line',
+            onClick: handleEdit.bind(null, record),
+          },
+          {
+            icon: 'ant-design:delete-outlined',
+            color: 'error',
+            popConfirm: {
+              title: '是否确认删除',
+              confirm: handleDelete.bind(null, record),
+            },
+          },
+        ]"
+      />
+    </template>
+  </BasicTable>
 </template>
 
-<script lang="ts" setup></script>
+<script lang="ts">
+  import { defineComponent } from 'vue'; // h
+  import { BasicTable, useTable, BasicColumn, TableAction } from '/@/components/Table';
+  import { categoryApi } from '/@/api/product/category';
+  // import { Tag } from 'ant-design-vue';
+
+  import { useI18n } from '/@/hooks/web/useI18n';
+  import { useMessage } from '/@/hooks/web/useMessage';
+
+  export default defineComponent({
+    components: { BasicTable, TableAction },
+    setup() {
+      const { createMessage } = useMessage();
+
+      const { t } = useI18n();
+
+      const columns: BasicColumn[] = [
+        {
+          title: '商品属性',
+          dataIndex: 'id',
+          fixed: 'left',
+          width: 100,
+        },
+        {
+          title: '排序',
+          dataIndex: 'orderNo',
+          width: 50,
+        },
+      ];
+
+      const [registerTable, { expandAll, collapseAll }] = useTable({
+        title: '商品分类',
+        api: categoryApi,
+        columns: columns,
+        useSearchForm: true,
+        showTableSetting: true,
+        tableSetting: { fullScreen: true },
+        showIndexColumn: false,
+        isTreeTable: true,
+        rowKey: 'id',
+        bordered: true,
+      });
+      function handleCreate() {}
+      function handleEdit() {}
+      function handleDelete() {}
+      return {
+        registerTable,
+        createMessage,
+        t,
+        handleCreate,
+        handleEdit,
+        handleDelete,
+        expandAll,
+        collapseAll,
+      };
+    },
+  });
+</script>