Bläddra i källkod

Merge branch 'feature/mockApi' of http://face3d.4dage.com:7005/zhangyupeng/zfb_mp into feature/mockApi

tangning 3 år sedan
förälder
incheckning
f53b9e9832

+ 1 - 1
src/api/corporation/list.ts

@@ -5,7 +5,7 @@ import { Result, UploadFileParams } from '/#/axios';
 
 enum Api {
   selectCompanyNum = '/zfb-api/zfb/company/selectCompanyNum',
-  listAllCompany = '/zfb-api/zfb/company/listAll',
+  listAllCompany = '/zfb-api/zfb/company/getListAll',
   selectCompanyByType = '/zfb-api/zfb/company/selectCompanyByType',
   uploadLogo = '/zfb-api/zfb/company/uploadLogo',
 }

+ 25 - 2
src/api/scene/live.ts

@@ -1,10 +1,13 @@
 import { defHttp } from '/@/utils/http/axios';
-import { PageParams, RentListGetResultModel } from './model';
+import { PageParams, RentListGetResultModel, SceneLiveItem, bindAnchorListParam } from './model';
 
 enum Api {
   pageList = '/basic-api/brand/brandBindList',
+  bindAnchorList = '/zfb-api/zfb/shop/sys/user/bindList',
+  // brandTypeList = '/zfb-api/zfb/shop/brand/brandTypeList',
+  brandTypeList = '/basic-api//brand/brandTypeList',
 }
-
+export type SceneLiveItemResult = SceneLiveItem;
 /**
  * @description: Get sample list value
  */
@@ -18,3 +21,23 @@ export const ListApi = (params: PageParams) =>
       ignoreCancelToken: true,
     },
   });
+export const bindAnchorListApi = (params: bindAnchorListParam) =>
+  defHttp.post<RentListGetResultModel>({
+    url: Api.bindAnchorList,
+    params: params,
+    data: params,
+    headers: {
+      // @ts-ignore
+      ignoreCancelToken: true,
+    },
+  });
+export const brandTypeListApi = (params: PageParams) =>
+  defHttp.get<RentListGetResultModel>({
+    url: Api.brandTypeList,
+
+    params,
+    headers: {
+      // @ts-ignore
+      ignoreCancelToken: true,
+    },
+  });

+ 34 - 5
src/api/scene/model.ts

@@ -3,22 +3,51 @@ import { BasicPageParams, BasicFetchResult } from '/@/api/model/baseModel';
  * @description: Request list interface parameters
  */
 export type PageParams = BasicPageParams;
+export interface bindAnchorListParam extends BasicPageParams {
+  brandId?: number;
+}
 
 export interface SceneEditParam {
   sceneNum: string;
   userName: string;
 }
 
-export interface DeviceListItem {
+export interface SceneLiveItem {
+  address: string;
+  adminId: number;
+  appListPicUrl: string;
+  bindShowerId: number;
+  bindShowerName: string;
+  bindShowerNameList: string;
+  city: string;
+  contractPhone: string;
+  createTime: number;
+  createUserDeptId: number;
+  createUserId: number;
+  deleted: number;
   id: number;
+  introduceVideo: string;
+  introduceVideoCover: string;
+  latitude: number;
+  liveRoomUrl: string;
+  livestreamStatus: number;
+  longitude: number;
   name: string;
-  image: string;
-  link: string;
-  createTime: string;
-  isShow: boolean;
+  picList: string;
+  sceneName: string;
+  sceneNum: string;
+  sceneUrl: string;
+  shareWxQrCode: string;
+  simpleDesc: string;
+  sortOrder: number;
+  token: string;
+  type: number;
+  updateTime: number;
+  updateUserId: number;
 }
 
 /**
  * @description: Request list return value
  */
 export type RentListGetResultModel = BasicFetchResult<DeviceListItem>;
+export type LiveListGetResultModel = BasicFetchResult<SceneLiveItem>;

+ 2 - 2
src/api/staff/list.ts

@@ -2,7 +2,7 @@ import { defHttp } from '/@/utils/http/axios';
 import { PageParams, ListGetResultModel } from './model';
 
 enum Api {
-  pageList = '/basic-api/sys/user/staffList',
+  pageList = '/zfb-api/zfb/shop/sys/user/staffList',
 }
 
 /**
@@ -10,7 +10,7 @@ enum Api {
  */
 
 export const ListApi = (params: PageParams) =>
-  defHttp.get<ListGetResultModel>({
+  defHttp.post<ListGetResultModel>({
     url: Api.pageList,
     params,
     headers: {

+ 131 - 0
src/views/scenes/bindModal.vue

@@ -0,0 +1,131 @@
+<template>
+  <BasicModal
+    v-bind="$attrs"
+    @register="register"
+    title="绑定主播"
+    width="700px"
+    @visible-change="handleVisibleChange"
+    @ok="handleSubmit"
+  >
+    <div class="pt-2px pr-3px">
+      <BasicTable
+        @register="registerTable"
+        :searchInfo="searchInfo"
+        :rowSelection="{ type: 'checkbox' }"
+      />
+      <!-- <BasicForm @register="registerForm" :model="model" /> -->
+    </div>
+    <template #centerFooter>
+      <!-- <a-button>xxxx</a-button> -->
+    </template>
+  </BasicModal>
+</template>
+<script lang="ts">
+  import { defineComponent, reactive, nextTick } from 'vue';
+  import { BasicModal, useModalInner } from '/@/components/Modal';
+  // import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
+  import { BasicTable, useTable, BasicColumn } from '/@/components/Table';
+  // import { useMessage } from '/@/hooks/web/useMessage';
+  // import { checkUserAddAble } from '/@/api/corporation/modal';
+  // import { useI18n } from '/@/hooks/web/useI18n';
+  import { bindAnchorListApi } from '/@/api/scene/live';
+
+  // const { t } = useI18n();
+  const schemas: FormSchema[] = [
+    {
+      field: 'own',
+      label: '主播选择:',
+      component: 'ApiSelect',
+      componentProps: {
+        api: bindAnchorListApi,
+        // resultField: 'list',
+        numberToString: true,
+        labelField: 'name',
+        valueField: 'id',
+        immediate: true,
+        params: {
+          page: 1,
+          // brandId:
+          limit: 1000,
+        },
+      },
+    },
+  ];
+  const columns: BasicColumn[] = [
+    {
+      title: 'ID',
+      dataIndex: 'id',
+      fixed: 'left',
+      width: 40,
+    },
+    {
+      title: '员工名称',
+      dataIndex: 'name',
+      width: 100,
+    },
+    {
+      title: '角色',
+      dataIndex: 'roleName',
+      width: 100,
+    },
+
+    {
+      title: '手机号',
+      dataIndex: 'phone',
+      width: 100,
+    },
+    {
+      title: '绑定时间',
+      dataIndex: 'createTime',
+      width: 100,
+    },
+  ];
+  export default defineComponent({
+    components: { BasicModal, BasicTable },
+    props: {
+      userData: { type: Object },
+    },
+    setup(props) {
+      const [register, { closeModal }] = useModalInner((data) => {
+        data && onDataReceive(data);
+      });
+
+      const searchInfo = reactive<Recordable>({});
+      const [registerTable, { reload }] = useTable({
+        title: '主播列表',
+        api: bindAnchorListApi,
+        columns: columns,
+        useSearchForm: false,
+        // formConfig: searchForm,
+        showTableSetting: false,
+        tableSetting: { fullScreen: true },
+        showIndexColumn: false,
+        immediate: false,
+        rowKey: 'id',
+        pagination: { pageSize: 1000 },
+        bordered: true,
+      });
+
+      function onDataReceive(data) {
+        console.log('Data Received', data.id);
+        searchInfo.brandId = data.id;
+        // searchInfo.key = data.id;
+        reload();
+      }
+      const handleSubmit = async () => {};
+      function handleVisibleChange(v) {
+        v && props.userData && nextTick(() => onDataReceive(props.userData));
+      }
+
+      return {
+        register,
+        schemas,
+        registerTable,
+        handleVisibleChange,
+        handleSubmit,
+        searchInfo,
+        closeModal,
+      };
+    },
+  });
+</script>

+ 0 - 176
src/views/scenes/list copy.vue

@@ -1,176 +0,0 @@
-<template>
-  <div class="p-4">
-    <BasicTable @register="registerTable">
-      <template #toolbar> </template>
-      <template #cover="{ record }">
-        <TableImg :size="150" :simpleShow="true" :imgList="[record.cover]" />
-      </template>
-      <template #action>
-        <TableAction
-          :actions="[
-            {
-              icon: 'clarity:note-edit-line',
-              label: '编辑',
-              onClick: () => {
-                createMessage.info(`暂未接入`);
-              },
-            },
-            {
-              icon: 'ant-design:delete-outlined',
-              color: 'error',
-              label: '删除',
-              popConfirm: {
-                title: '是否确认删除',
-                confirm: () => {
-                  createMessage.info(`暂未接入`);
-                },
-              },
-            },
-          ]"
-        />
-      </template>
-    </BasicTable>
-  </div>
-</template>
-<script lang="ts">
-  import { defineComponent } from 'vue';
-  import {
-    BasicTable,
-    useTable,
-    BasicColumn,
-    FormProps,
-    TableAction,
-    TableImg,
-  } from '/@/components/Table';
-  import { useMessage } from '/@/hooks/web/useMessage';
-  import { uploadApi } from '/@/api/sys/upload';
-  import { Switch } from 'ant-design-vue';
-  import { h } from 'vue';
-  import { ListApi } from '/@/api/scene/list';
-  import { useI18n } from '/@/hooks/web/useI18n';
-
-  export default defineComponent({
-    components: { BasicTable, TableAction, TableImg },
-    setup() {
-      const { createMessage } = useMessage();
-      const { t } = useI18n();
-      const columns: BasicColumn[] = [
-        {
-          title: 'ID',
-          dataIndex: 'id',
-          fixed: 'left',
-          width: 100,
-        },
-        {
-          title: '场景名称',
-          dataIndex: 'name',
-          width: 230,
-        },
-        {
-          title: '封面',
-          dataIndex: 'cover',
-          slots: { customRender: 'cover' },
-          width: 120,
-        },
-        {
-          title: '场景链接',
-          dataIndex: 'link',
-          slots: { customRender: 'link' },
-          width: 180,
-        },
-        {
-          title: '是否显示',
-          dataIndex: 'isShow',
-          width: 180,
-          customRender: ({ record }) => {
-            if (!Reflect.has(record, 'pendingStatus')) {
-              record.pendingStatus = false;
-            }
-            return h(Switch, {
-              checked: record.isShow,
-              checkedChildren: t('common.yes'),
-              unCheckedChildren: t('common.no'),
-              loading: false,
-              onChange(checked: boolean) {
-                record.pendingStatus = true;
-                const newStatus = checked ? '1' : '0';
-                const { createMessage } = useMessage();
-                createMessage.info(`暂未接入` + newStatus);
-                // setRoleStatus(record.id, newStatus)
-                //   .then(() => {
-                //     record.status = newStatus;
-                //     createMessage.success(`已成功修改角色状态`);
-                //   })
-                //   .catch(() => {
-                //     createMessage.error('修改角色状态失败');
-                //   })
-                //   .finally(() => {
-                //     record.pendingStatus = false;
-                //   });
-              },
-            });
-          },
-        },
-
-        {
-          title: '操作',
-          dataIndex: '',
-          slots: { customRender: 'action' },
-          width: 120,
-        },
-      ];
-
-      const searchForm: Partial<FormProps> = {
-        labelWidth: 100,
-        schemas: [
-          {
-            field: 'id',
-            label: 'id',
-            component: 'Input',
-            colProps: {
-              xl: 3,
-              xxl: 3,
-            },
-          },
-          {
-            field: 'userName',
-            label: '企业账号',
-            component: 'Input',
-            colProps: {
-              xl: 12,
-              xxl: 8,
-            },
-          },
-        ],
-      };
-      // { getForm }
-      const [registerTable] = useTable({
-        title: '场景列表',
-        api: ListApi,
-        columns: columns,
-        useSearchForm: false,
-        formConfig: searchForm,
-        showTableSetting: true,
-        tableSetting: { fullScreen: true },
-        showIndexColumn: false,
-        rowKey: 'id',
-        //TODO
-        fetchSetting: {
-          pageField: 'pageNum',
-          sizeField: 'pageSize',
-          listField: 'list',
-          totalField: 'total',
-        },
-        pagination: { pageSize: 20 },
-      });
-
-      // pagination.value = { pageSize: 20 };
-      return {
-        registerTable,
-        createMessage,
-        t,
-        uploadApi: uploadApi as any,
-      };
-    },
-  });
-</script>

+ 115 - 59
src/views/scenes/live.vue

@@ -44,31 +44,32 @@ updateUserId: null -->
       <template #houseType="{ record }">
         {{ renderHouseType(record.houseType) }}
       </template>
-      <template #action>
+      <template #action="{ record }">
         <TableAction
           :actions="[
             {
-              icon: 'clarity:note-edit-line',
-              label: '编辑',
-              onClick: () => {
-                createMessage.info(`暂未接入`);
-              },
-            },
-            {
-              icon: 'ant-design:delete-outlined',
-              color: 'error',
-              label: '删除',
-              popConfirm: {
-                title: '是否确认删除',
-                confirm: () => {
-                  createMessage.info(`暂未接入`);
-                },
-              },
+              icon: 'eos-icons:role-binding',
+              label: '绑定主播',
+              color: 'warning',
+              onClick: handleBindAnchor.bind(null, record),
             },
+
+            // {
+            //   icon: 'ant-design:delete-outlined',
+            //   color: 'error',
+            //   label: '删除',
+            //   popConfirm: {
+            //     title: '是否确认删除',
+            //     confirm: () => {
+            //       createMessage.info(`暂未接入`);
+            //     },
+            //   },
+            // },
           ]"
         />
       </template>
     </BasicTable>
+    <bindModal @register="registerBindModal" />
   </div>
 </template>
 <script lang="ts">
@@ -77,22 +78,26 @@ updateUserId: null -->
     BasicTable,
     useTable,
     BasicColumn,
+    // FormSchema,
     FormProps,
     TableAction,
     TableImg,
   } from '/@/components/Table';
   import { useMessage } from '/@/hooks/web/useMessage';
-  import { uploadApi } from '/@/api/sys/upload';
-  import { Switch } from 'ant-design-vue';
+  // import { uploadApi } from '/@/api/sys/upload';
+  import { Tag } from 'ant-design-vue';
   import { h } from 'vue';
-  import { ListApi } from '/@/api/scene/live';
+  import { ListApi, brandTypeListApi } from '/@/api/scene/live';
   import { useI18n } from '/@/hooks/web/useI18n';
+  import { useModal } from '/@/components/Modal';
+  import bindModal from './bindModal.vue';
 
   export default defineComponent({
-    components: { BasicTable, TableAction, TableImg },
+    components: { BasicTable, TableAction, TableImg, bindModal },
     setup() {
       const { createMessage } = useMessage();
       const { t } = useI18n();
+      const [registerBindModal, { openModal: openBindModal }] = useModal();
 
       const columns: BasicColumn[] = [
         {
@@ -131,44 +136,51 @@ updateUserId: null -->
           width: 180,
         },
         {
+          title: '已绑定主播',
+          dataIndex: 'bindShowerNameList',
+          width: 180,
+        },
+
+        {
           title: '是否开播',
-          dataIndex: 'isSteam',
+          dataIndex: 'livestreamStatus',
           width: 180,
           customRender: ({ record }) => {
-            if (!Reflect.has(record, 'pendingStatus')) {
-              record.pendingStatus = false;
-            }
-            return h(Switch, {
-              checked: record.isSteam,
-              checkedChildren: t('common.yes'),
-              unCheckedChildren: t('common.no'),
-              loading: false,
-              onChange(checked: boolean) {
-                record.pendingStatus = true;
-                const newStatus = checked ? '1' : '0';
-                const { createMessage } = useMessage();
-                createMessage.info(`暂未接入` + newStatus);
-                // setRoleStatus(record.id, newStatus)
-                //   .then(() => {
-                //     record.status = newStatus;
-                //     createMessage.success(`已成功修改角色状态`);
-                //   })
-                //   .catch(() => {
-                //     createMessage.error('修改角色状态失败');
-                //   })
-                //   .finally(() => {
-                //     record.pendingStatus = false;
-                //   });
-              },
-            });
+            const enable = record.livestreamStatus === 0;
+            const color = enable ? 'green' : 'red';
+            const text = enable ? '是' : '否';
+            return h(Tag, { color: color }, () => text);
           },
         },
+        // {
+        //   title: '是否开播',
+        //   dataIndex: 'isSteam',
+        //   width: 180,
+        //   customRender: ({ record }) => {
+        //     if (!Reflect.has(record, 'pendingStatus')) {
+        //       record.pendingStatus = false;
+        //     }
+        //     return h(Switch, {
+        //       checked: record.isSteam,
+        //       checkedChildren: t('common.yes'),
+        //       unCheckedChildren: t('common.no'),
+        //       loading: false,
+        //       onChange(checked: boolean) {
+        //         record.pendingStatus = true;
+        //         const newStatus = checked ? '1' : '0';
+        //         const { createMessage } = useMessage();
+        //         createMessage.info(`暂未接入` + newStatus);
+        //       },
+        //     });
+        //   },
+        // },
 
         {
           title: '操作',
           dataIndex: '',
           slots: { customRender: 'action' },
           width: 120,
+          fixed: 'right',
         },
       ];
 
@@ -176,21 +188,59 @@ updateUserId: null -->
         labelWidth: 100,
         schemas: [
           {
-            field: 'id',
-            label: 'id',
+            field: 'sceneName',
+            label: '直播间名称',
             component: 'Input',
             colProps: {
-              xl: 3,
-              xxl: 3,
+              xl: 5,
+              xxl: 5,
             },
           },
           {
-            field: 'userName',
-            label: '企业账号',
-            component: 'Input',
+            field: 'type',
+            label: '类型',
+            component: 'ApiSelect',
             colProps: {
-              xl: 12,
-              xxl: 8,
+              xl: 5,
+              xxl: 5,
+            },
+            componentProps: {
+              api: brandTypeListApi,
+              resultField: 'list',
+              labelField: 'name',
+              valueField: 'id',
+              params: {
+                page: 1,
+                limit: 1000,
+              },
+            },
+          },
+          {
+            field: 'livestreamStatus',
+            label: '是否开播',
+            component: 'Select',
+            colProps: {
+              xl: 5,
+              xxl: 5,
+            },
+            componentProps: {
+              options: [
+                {
+                  label: '全部',
+                  value: '',
+                  key: '1',
+                },
+                {
+                  label: '是',
+                  value: '',
+                  key: '2',
+                },
+                {
+                  label: '否',
+                  value: '0',
+                  key: '2',
+                },
+              ],
             },
           },
         ],
@@ -214,7 +264,7 @@ updateUserId: null -->
         title: '直播列表',
         api: ListApi,
         columns: columns,
-        useSearchForm: false,
+        useSearchForm: true,
         formConfig: searchForm,
         showTableSetting: true,
         tableSetting: { fullScreen: true },
@@ -233,12 +283,18 @@ updateUserId: null -->
         },
       });
 
+      function handleBindAnchor(record: Recordable) {
+        console.log('record', record);
+        openBindModal(true, record);
+      }
+
       return {
         registerTable,
         createMessage,
         renderHouseType,
         t,
-        uploadApi: uploadApi as any,
+        registerBindModal,
+        handleBindAnchor,
       };
     },
   });

+ 8 - 2
src/views/system/role/RoleDrawer.vue

@@ -38,7 +38,7 @@
     setup(_, { emit }) {
       const isUpdate = ref(true);
       const treeData = ref<TreeMenuNode[]>([]);
-
+      const roleId = ref(0);
       const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({
         labelWidth: 90,
         schemas: formSchema,
@@ -57,6 +57,7 @@
         isUpdate.value = !!data?.isUpdate;
 
         if (unref(isUpdate)) {
+          roleId.value = data.record.roleId;
           setFieldsValue({
             ...data.record,
           });
@@ -69,11 +70,16 @@
         try {
           const values = await validate();
           setDrawerProps({ confirmLoading: true });
-          // TODO custom api
+
+          //TODO hardcode 转变companyIdList backend request
+          if ('companyId' in values) {
+            values.companyIdList = [values.companyId];
+          }
           let result;
           if (!unref(isUpdate)) {
             result = await saveRoleApi(values);
           } else {
+            values.roleId = roleId.value;
             result = await updateRoleApi(values);
           }
 

+ 7 - 6
src/views/system/role/role.data.ts

@@ -18,14 +18,14 @@ export const columns: BasicColumn[] = [
   },
   {
     title: '所属部门',
-    dataIndex: 'deptName',
+    dataIndex: 'companyName',
     width: 180,
   },
-  {
-    title: '排序',
-    dataIndex: 'orderNo',
-    width: 50,
-  },
+  // {
+  //   title: '显示',
+  //   dataIndex: 'canShow',
+  //   width: 50,
+  // },
   {
     title: '状态',
     dataIndex: 'canShow',
@@ -107,6 +107,7 @@ export const formSchema: FormSchema[] = [
     field: 'companyId',
     label: '公司',
     component: 'ApiSelect',
+    required: true,
     componentProps: {
       api: ListAllCompanyApi,
       resultField: 'list',