gemercheung 1 год назад
Родитель
Сommit
b81cb85e4e

+ 42 - 27
src/api/scene/list.ts

@@ -8,6 +8,8 @@ import {
   SceneDownloadModel,
   patchcoldStoragedParam,
   collaborateParam,
+  unCollaborateParam,
+  collaborateDetailParam,
 } from './model';
 import { Result } from '/#/axios';
 
@@ -23,6 +25,8 @@ enum Api {
   sceneCopy = 'service/manage_jp/scene/copyScene',
   coldStorage = 'service/manage_jp/storage/coldStorage',
   collaborate = 'service/manage_jp/contractor/collaborate',
+  unCollaborate = 'service/manage_jp/contractor/unCollaborate',
+  unCollaborateList = 'service/manage_jp/contractor/details',
 }
 
 /**
@@ -119,33 +123,44 @@ export const checkDownloadApi = (params: SceneDownloadParam) =>
     },
   });
 export const patchcoldStorageApi = (params: patchcoldStoragedParam) =>
-  defHttp.post<Result>(
-    {
-      url: Api.coldStorage,
-      params,
-
-      headers: {
-        // @ts-ignore
-        ignoreCancelToken: true,
-      },
-    },
-    // {
-    //   isTransformResponse: false,
-    // },
-  );
+  defHttp.post<Result>({
+    url: Api.coldStorage,
+    params,
+    headers: {
+      // @ts-ignore
+      ignoreCancelToken: true,
+    },
+  });
 
 export const addCollaborateApi = (params: collaborateParam) =>
-  defHttp.post<Result>(
-    {
-      url: Api.collaborate,
-      params,
+  defHttp.post<Result>({
+    url: Api.collaborate,
+    params,
+
+    headers: {
+      // @ts-ignore
+      ignoreCancelToken: true,
+    },
+  });
 
-      headers: {
-        // @ts-ignore
-        ignoreCancelToken: true,
-      },
-    },
-    // {
-    //   isTransformResponse: false,
-    // },
-  );
+export const unCollaborateApi = (params: unCollaborateParam) =>
+  defHttp.post<Result>({
+    url: Api.unCollaborate,
+    params,
+
+    headers: {
+      // @ts-ignore
+      ignoreCancelToken: true,
+    },
+  });
+
+export const getUnCollaborateDetailApi = (params: collaborateDetailParam) =>
+  defHttp.post<Result>({
+    url: Api.unCollaborateList,
+    params,
+
+    headers: {
+      // @ts-ignore
+      ignoreCancelToken: true,
+    },
+  });

+ 8 - 0
src/api/scene/model.ts

@@ -90,6 +90,14 @@ export interface collaborateParam {
   numList: string[];
   userName: string;
 }
+export interface unCollaborateParam {
+  numList: string[];
+  id: string;
+}
+export interface collaborateDetailParam {
+  id: string;
+}
+
 /**
  * @description: Request list return value
  */

+ 1 - 0
src/locales/lang/zh-CN/common.ts

@@ -40,4 +40,5 @@ export default {
   mobile: '手机',
   phone: '请填写您的手机号码!',
   phoneError: '请正确填写您的手机号码!',
+  isConfirm: '是否确定?',
 };

+ 1 - 0
src/locales/lang/zh-CN/routes/corporation.ts

@@ -46,4 +46,5 @@ export default {
   approveState: '审核状态',
   addError: '账号已被绑定,请重新输入',
   contractorList: '承包商管理',
+  patchAction: '批量处理',
 };

+ 58 - 42
src/views/corporation/contractorList.vue

@@ -1,36 +1,37 @@
 <template>
-  <!-- <PageWrapper contentBackground> -->
-  <!-- <template #footer>
-    
-      <a-tabs v-model:activeKey="tableType" @change="changeTable">
-        <a-tab-pane :key="0" :tab="t('routes.scenes.4dkk')" :disabled="loading" />
-        <a-tab-pane :key="1" :tab="t('routes.scenes.4dkj')" :disabled="loading" />
-        <a-tab-pane :key="2" :tab="t('routes.scenes.4dssdy')" :disabled="loading" />
-        <a-tab-pane :key="4" :tab="t('routes.scenes.obj')" :disabled="loading" />
-
-      </a-tabs>
-    </template> -->
-  <!-- :rowSelection="{ type: 'checkbox', onChange: handleSelect }" -->
-  <BasicTable @register="registerTable">
-    <template #toolbar>
-      <!-- <a-button type="primary" @click="handleCreate"> 新增</a-button> -->
-      <!-- <a-button type="primary" color="warning" @click="() => {}"> 编辑</a-button>
+  <div>
+    <BasicTable @register="registerTable">
+      <template #toolbar>
+        <!-- <a-button type="primary" @click="handleCreate"> 新增</a-button> -->
+        <!-- <a-button type="primary" color="warning" @click="() => {}"> 编辑</a-button>
         <a-button type="primary" color="error" @click="() => {}"> 删除</a-button> -->
-    </template>
+      </template>
 
-    <template #cover="{ record }">
-      <TableImg
-        :size="120"
-        :simpleShow="true"
-        :imgList="[record.thumb || '/resource/img/header.jpg']"
-      />
-    </template>
-    <template #createTime="{ record }">
-      <Time v-if="record.createTime" :value="record.createTime" mode="datetime" />
-    </template>
-  </BasicTable>
+      <template #cover="{ record }">
+        <TableImg
+          :size="120"
+          :simpleShow="true"
+          :imgList="[record.thumb || '/resource/img/header.jpg']"
+        />
+      </template>
+      <template #createTime="{ record }">
+        <Time v-if="record.createTime" :value="record.createTime" mode="datetime" />
+      </template>
 
-  <!-- </PageWrapper> -->
+      <template #action="{ record }">
+        <TableAction
+          :actions="[
+            {
+              label: t('routes.scenes.unAssistant'),
+              onClick: handleUnAssistantModal.bind(null, record),
+              ifShow: isPatchAuth,
+            },
+          ]"
+        />
+      </template>
+    </BasicTable>
+    <unAssistantModal @register="registerUnAssistantModal" />
+  </div>
 </template>
 <script lang="ts">
   import { defineComponent, computed, ref } from 'vue';
@@ -39,7 +40,7 @@
     useTable,
     BasicColumn,
     FormProps,
-    // TableAction,
+    TableAction,
     TableImg,
   } from '/@/components/Table';
   import { useMessage } from '/@/hooks/web/useMessage';
@@ -48,25 +49,28 @@
 
   import { useI18n } from '/@/hooks/web/useI18n';
   import { Time } from '/@/components/Time';
-  // import { useUserStore } from '/@/store/modules/user';
 
   import { useLocaleStore } from '/@/store/modules/locale';
-  // import { PageWrapper } from '/@/components/Page';
+  import unAssistantModal from './unAssistantModal.vue';
+  import { useModal } from '/@/components/Modal';
+  import { useUserStore } from '/@/store/modules/user';
+  import { RoleEnum } from '/@/enums/roleEnum';
 
   const localeStore = useLocaleStore();
   console.log('localeStore', localeStore);
 
-  // const userStore = useUserStore();
+  const userStore = useUserStore();
 
   export default defineComponent({
     components: {
       BasicTable,
-      // TableAction,
+      TableAction,
       TableImg,
       // PageWrapper,
       Time,
       [Tabs.name]: Tabs,
       [Tabs.TabPane.name]: Tabs.TabPane,
+      unAssistantModal,
     },
     setup() {
       const { createMessage } = useMessage();
@@ -118,15 +122,21 @@
           slots: { customRender: 'createTime' },
           width: 200,
         },
-        // {
-        //   title: t('common.operation'),
-        //   dataIndex: '',
-        //   slots: { customRender: 'action' },
-        //   width: isJA.value ? 100 : 100,
-        //   fixed: 'right',
-        // },
+        {
+          title: t('common.operation'),
+          dataIndex: '',
+          slots: { customRender: 'action' },
+          width: 100,
+          // fixed: 'right',
+        },
       ];
 
+      const roleList = userStore.roleList;
+      console.log('roleList', roleList);
+
+      const isPatchAuth = computed(() => {
+        return roleList.includes(RoleEnum.PLAT_ADMIN) || roleList.includes(RoleEnum.SUPER);
+      });
       const searchForm: Partial<FormProps> = {
         labelWidth: 100,
         schemas: [
@@ -156,7 +166,7 @@
           },
         ],
       };
-      // { getForm }
+      const [registerUnAssistantModal, { openModal: openUnAssistantModal }] = useModal();
       const [registerTable, { reload, getSelectRowKeys }] = useTable({
         title: t('routes.dashboard.contractorManage'),
         api: contractorListApi,
@@ -190,7 +200,11 @@
       const handleCreate = () => {
         console.log('handleCreate');
       };
+      const handleUnAssistantModal = (record: Recordable) => {
+        openUnAssistantModal(true, { ...record });
+      };
       return {
+        isPatchAuth,
         registerTable,
         createMessage,
         t,
@@ -200,6 +214,8 @@
         isJA,
         handleSelect,
         handleCreate,
+        handleUnAssistantModal,
+        registerUnAssistantModal,
       };
     },
   });

+ 160 - 0
src/views/corporation/unAssistantModal.vue

@@ -0,0 +1,160 @@
+<template>
+  <BasicModal
+    v-bind="$attrs"
+    @register="register"
+    title="取消协助"
+    width="800px"
+    :minHeight="400"
+    @ok="handleSubmit"
+    :centered="true"
+    @cancel="handleClose"
+  >
+    <div class="pt-2px pr-3px flex">
+      <BasicTable
+        :searchInfo="searchInfo"
+        :rowSelection="{ type: 'checkbox' }"
+        class="flex-1"
+        height="100%"
+        @register="registerTable"
+      >
+        <template #toolbar>
+          <a-button type="primary" @click="handlePatchSelect">
+            {{ t('routes.corporation.patchAction') }}</a-button
+          >
+        </template>
+        <template #action="{ record }">
+          <TableAction
+            :actions="[
+              {
+                label: t('routes.scenes.unAssistant'),
+                onClick: handleUnAssistant.bind(null, record),
+              },
+            ]"
+          />
+        </template>
+      </BasicTable>
+    </div>
+  </BasicModal>
+</template>
+<script lang="ts">
+  import { defineComponent, ref } from 'vue';
+  import { BasicModal, useModalInner } from '/@/components/Modal';
+  import { useMessage } from '/@/hooks/web/useMessage';
+  import { unCollaborateApi, getUnCollaborateDetailApi } from '/@/api/scene/list';
+  import { BasicTable, useTable, BasicColumn, TableAction } from '/@/components/Table';
+  import { useI18n } from '/@/hooks/web/useI18n';
+
+  const { createMessage, createConfirm } = useMessage();
+
+  const { t } = useI18n();
+
+  const columns: BasicColumn[] = [
+    {
+      title: 'ID',
+      dataIndex: 'id',
+      width: 80,
+      defaultHidden: true,
+    },
+    {
+      title: t('routes.scenes.num'),
+      dataIndex: 'num',
+      ellipsis: false,
+      width: 120,
+    },
+  ];
+
+  export default defineComponent({
+    components: { BasicModal, BasicTable, TableAction },
+    props: {
+      // userData: { type: Object },
+    },
+    emits: ['register', 'submit'],
+    setup(_, { emit }) {
+      const searchInfo = ref({
+        id: '',
+        pageSize: 1000,
+        pageNum: 1,
+      });
+
+      const [register, { closeModal }] = useModalInner((data) => {
+        data && onDataReceive(data);
+      });
+      const [registerTable, { reload, getSelectRowKeys, clearSelectedRowKeys }] = useTable({
+        title: t('routes.scenes.sceneList'),
+        api: getUnCollaborateDetailApi,
+        columns: columns,
+        canResize: true,
+        rowKey: 'id',
+        immediate: false,
+        bordered: true,
+        clickToRowSelect: false,
+        actionColumn: {
+          width: 120,
+          title: t('common.operation'),
+          dataIndex: 'action',
+          slots: { customRender: 'action' },
+        },
+      });
+
+      async function onDataReceive(data) {
+        searchInfo.value.id = String(data.id);
+        console.log('searchInfo', searchInfo.value);
+        reload();
+      }
+      const handleSubmit = async () => {
+        emit('submit');
+      };
+
+      function handleClose() {
+        // resetFields();
+        clearSelectedRowKeys();
+      }
+      const handleUnAssistant = async (record: Recordable) => {
+        console.log('record', record);
+        await unCollaborateApi({
+          id: record.id,
+          numList: [record.num],
+        });
+        createMessage.success(t('common.optSuccess'));
+        clearSelectedRowKeys();
+        reload();
+      };
+      function handlePatchSelect() {
+        const keys = getSelectRowKeys();
+        if (keys.length > 0) {
+          createConfirm({
+            iconType: 'warning',
+            title: () => t('routes.corporation.patchAction'),
+            content: () => t('common.isConfirm'),
+            onOk: async () => {
+              try {
+                await unCollaborateApi({
+                  id: searchInfo.value.id,
+                  numList: keys,
+                });
+                createMessage.success(t('common.optSuccess'));
+                clearSelectedRowKeys();
+                reload();
+                // closeModal();
+              } catch (error) {}
+            },
+          });
+        } else {
+          createMessage.info(t('modal.atLeastOne'));
+        }
+      }
+
+      return {
+        searchInfo,
+        t,
+        register,
+        handleSubmit,
+        closeModal,
+        handleClose,
+        registerTable,
+        handleUnAssistant,
+        handlePatchSelect,
+      };
+    },
+  });
+</script>