Forráskód Böngészése

新增销售易相关功能

zyy 1 hete
szülő
commit
34f68b6380
3 módosított fájl, 610 hozzáadás és 0 törlés
  1. 241 0
      src/api/xsy/xsy.js
  2. 134 0
      src/views/his/company/index.vue
  3. 235 0
      src/views/xsy/index.vue

+ 241 - 0
src/api/xsy/xsy.js

@@ -0,0 +1,241 @@
+import request from '@/utils/request'
+
+/**
+ * 查询销售易账号列表
+ */
+export function listXsyAccount(query) {
+  return request({
+    url: '/xsy/account/list',
+    method: 'get',
+    params: query
+  })
+}
+
+
+
+/**
+ * 查询销售易账号详情
+ */
+export function getXsyAccount(id) {
+  return request({
+    url: '/xsy/account/get/' + id,
+    method: 'get'
+  })
+}
+
+/**
+ * 新增销售易账号
+ */
+export function addXsyAccount(data) {
+  return request({
+    url: '/xsy/account/add',
+    method: 'post',
+    data: data
+  })
+}
+
+/**
+ * 修改销售易账号
+ */
+export function updateXsyAccount(data) {
+  return request({
+    url: '/xsy/account/update',
+    method: 'post',
+    data: data
+  })
+}
+
+/**
+ * 删除销售易账号
+ */
+export function delXsyAccount(id) {
+  return request({
+    url: '/xsy/account/delete/' + id,
+    method: 'post'
+  })
+}
+
+/**
+ * 启用/禁用销售易账号
+ */
+export function updateXsyAccountStatus(id, status) {
+  return request({
+    url: '/xsy/account/status',
+    method: 'post',
+    params: {
+      id: id,
+      status: status
+    }
+  })
+}
+
+/**
+ * 获取授权地址
+ */
+export function getXsyAuthUrl(accountId) {
+  return request({
+    url: '/xiaoShouYi/auth/url/' + accountId,
+    method: 'get'
+  })
+}
+
+
+
+/**
+ * 绑定销售易账号
+ */
+export function bindXsyAccount(data) {
+  return request({
+    url: '/xsy/companyBind/bind',
+    method: 'post',
+    data: data
+  })
+}
+
+export function unbindXsyAccount(data) {
+  return request({
+    url: '/xsy/companyBind/unbind',
+    method: 'post',
+    data: data
+  })
+}
+
+/**
+ * 查询绑定关系
+ */
+export function getXsyBind(companyUserId) {
+  return request({
+    url: '/xsy/bind/get',
+    method: 'get',
+    params: {
+      companyUserId: companyUserId
+    }
+  })
+}
+
+
+
+/**
+ * 获取授权URL(新接口)
+ */
+export function getXsyOauthUrl(accountId) {
+  return request({
+    url: '/xiaoShouYi/New/auth/url/' + accountId,
+    method: 'get'
+  })
+}
+
+
+
+/**
+ * 生成素材追踪链接
+ */
+export function generateXsyLink(companyUserId, data) {
+  return request({
+    url: '/xiaoShouYi/New/generateLink',
+    method: 'post',
+    params: {
+      companyUserId: companyUserId
+    },
+    data: data
+  })
+}
+
+/**
+ * 发送确认
+ */
+export function sendXsyConfirm(companyUserId, forwardId, forwardType) {
+  return request({
+    url: '/xiaoShouYi/New/sendConfirm',
+    method: 'post',
+    params: {
+      companyUserId: companyUserId,
+      forwardId: forwardId,
+      forwardType: forwardType
+    }
+  })
+}
+
+/**
+ * 查询素材列表
+ */
+export function queryXsyMaterials(companyUserId, data) {
+  return request({
+    url: '/xiaoShouYi/New/materials/query',
+    method: 'post',
+    params: {
+      companyUserId: companyUserId
+    },
+    data: data
+  })
+}
+
+/**
+ * 上传素材文件
+ */
+export function uploadXsyFile(companyUserId, file, isVideo) {
+  const formData = new FormData()
+  formData.append('file', file)
+  formData.append('isVideo', isVideo == null ? false : isVideo)
+
+  return request({
+    url: '/xiaoShouYi/New/uploadFile?companyUserId=' + companyUserId,
+    method: 'post',
+    data: formData,
+    headers: {
+      'Content-Type': 'multipart/form-data'
+    }
+  })
+}
+
+/**
+ * 创建素材
+ */
+export function createXsyMaterial(companyUserId, data) {
+  return request({
+    url: '/xiaoShouYi/New/createMaterial',
+    method: 'post',
+    params: {
+      companyUserId: companyUserId
+    },
+    data: data
+  })
+}
+
+/**
+ * 上传并创建素材
+ */
+export function createXsyMaterialWithUpload(params) {
+  const formData = new FormData()
+  formData.append('companyUserId', params.companyUserId)
+  formData.append('file', params.file)
+  formData.append('isVideo', params.isVideo == null ? false : params.isVideo)
+  formData.append('corpName', params.corpName)
+  formData.append('materialType', params.materialType)
+  formData.append('categoryName', params.categoryName)
+  formData.append('title', params.title)
+
+  return request({
+    url: '/xiaoShouYi/New/createMaterialWithUpload',
+    method: 'post',
+    data: formData,
+    headers: {
+      'Content-Type': 'multipart/form-data'
+    }
+  })
+}
+
+/**
+ * 完整流程:生成链接并发送确认
+ */
+export function fullProcessXsy(companyUserId, data) {
+  return request({
+    url: '/xiaoShouYi/New/fullProcess',
+    method: 'post',
+    params: {
+      companyUserId: companyUserId
+    },
+    data: data
+  })
+}
+

+ 134 - 0
src/views/his/company/index.vue

@@ -219,6 +219,25 @@
             @click="handleRevenue(scope.row)"
             v-hasPermi="['company:company:revenue']"
           >分账配置</el-button>
+
+          <el-button
+            v-if="!scope.row.accountId"
+            size="mini"
+            type="text"
+            icon="el-icon-link"
+            @click="handleBindXsy(scope.row)"
+          >绑定销售易
+          </el-button>
+
+          <el-button
+            v-if="scope.row.accountId"
+            size="mini"
+            type="text"
+            icon="el-icon-close"
+            @click="handleUnbindXsy(scope.row)"
+          >解绑销售易
+          </el-button>
+
         </template>
       </el-table-column>
     </el-table>
@@ -735,6 +754,38 @@
       </div>
     </el-dialog>
 
+    <!-- 绑定销售易账号 -->
+    <!-- 绑定销售易账号 -->
+    <el-dialog :title="xsyBindDialog.title" :visible.sync="xsyBindDialog.open" width="500px" append-to-body>
+      <el-form ref="xsyBindFormRef" :model="xsyBindForm" label-width="100px">
+        <el-form-item label="公司名称">
+          <el-input v-model="xsyBindForm.companyName" disabled />
+        </el-form-item>
+        <el-form-item label="销售易账号" prop="accountId">
+          <el-select
+            v-model="xsyBindForm.accountId"
+            filterable
+            clearable
+            placeholder="请选择销售易账号"
+            style="width: 100%;"
+            :loading="xsyBindDialog.loading"
+          >
+            <el-option
+              v-for="item in xsyAccountList"
+              :key="item.id"
+              :label="item.accountName"
+              :value="item.id"
+            />
+          </el-select>
+        </el-form-item>
+      </el-form>
+
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitBindXsy">确 定</el-button>
+        <el-button @click="cancelBindXsy">取 消</el-button>
+      </div>
+    </el-dialog>
+
   </div>
 </template>
 
@@ -763,6 +814,7 @@ import { getConfigByKey } from '@/api/system/config'
 import { listDept } from '@/api/system/dept'
 import { listAll } from '@/api/course/coursePlaySourceConfig'
 import{ getSignProjectName } from '@/api/course/qw/courseWatchLog'
+import { listXsyAccount, bindXsyAccount, unbindXsyAccount } from '@/api/xsy/xsy'
 export default {
   name: 'Company',
   data() {
@@ -948,6 +1000,20 @@ export default {
         open: false,
         title: '批量修改小程序'
       },
+      // 销售易绑定弹窗
+      xsyBindDialog: {
+        open: false,
+        title: '绑定销售易账号',
+        loading: false
+      },
+      // 销售易账号列表
+      xsyAccountList: [],
+      // 绑定表单
+      xsyBindForm: {
+        companyId: null,
+        companyName: '',
+        accountId: null
+      },
 
     }
   },
@@ -1400,6 +1466,74 @@ export default {
         }
       });
     },
+    // 打开绑定销售易账号弹窗
+    handleBindXsy(row) {
+      this.xsyBindForm = {
+        companyId: row.companyId,
+        companyName: row.companyName,
+        accountId: null
+      }
+      this.xsyAccountList = []
+      this.xsyBindDialog.open = true
+      this.xsyBindDialog.loading = true
+
+      listXsyAccount({
+        pageNum: 1,
+        pageSize: 9999
+      }).then(res => {
+        this.xsyAccountList = res.rows || []
+      }).finally(() => {
+        this.xsyBindDialog.loading = false
+      })
+    },
+
+    // 取消绑定
+    cancelBindXsy() {
+      this.xsyBindDialog.open = false
+      this.xsyBindForm = {
+        companyId: null,
+        companyName: '',
+        accountId: null
+      }
+    },
+
+    // 提交绑定
+    submitBindXsy() {
+      if (!this.xsyBindForm.accountId) {
+        this.$message.warning('请选择销售易账号')
+        return
+      }
+
+      bindXsyAccount({
+        companyId: this.xsyBindForm.companyId,
+        accountId: this.xsyBindForm.accountId
+      }).then(res => {
+        if (res.code === 200) {
+          this.msgSuccess('绑定成功')
+          this.xsyBindDialog.open = false
+          this.getList()
+        }
+      })
+    },
+
+    // 解绑销售易账号
+    handleUnbindXsy(row) {
+      this.$confirm('是否确认解绑当前销售易账号?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        return unbindXsyAccount({
+          companyId: row.companyId,
+          accountId: row.accountId
+        })
+      }).then(res => {
+        if (res.code === 200) {
+          this.msgSuccess('解绑成功')
+          this.getList()
+        }
+      }).catch(() => {})
+    },
   }
 }
 </script>

+ 235 - 0
src/views/xsy/index.vue

@@ -0,0 +1,235 @@
+<template>
+  <div class="app-container">
+
+    <!-- 查询 -->
+    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
+
+      <el-form-item label="ClientId">
+        <el-input v-model="queryParams.clientId" placeholder="请输入ClientId" size="small"/>
+      </el-form-item>
+
+      <el-form-item label="状态">
+        <el-select v-model="queryParams.status" clearable size="small">
+          <el-option label="启用" :value="1"/>
+          <el-option label="禁用" :value="0"/>
+        </el-select>
+      </el-form-item>
+
+      <el-form-item>
+        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
+        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
+      </el-form-item>
+
+    </el-form>
+
+    <!-- 按钮 -->
+    <el-row class="mb8">
+      <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
+      <el-button type="success" icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate">修改</el-button>
+      <el-button type="danger" icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete">删除</el-button>
+    </el-row>
+
+    <!-- 表格 -->
+    <el-table v-loading="loading" :data="accountList" @selection-change="handleSelectionChange">
+      <el-table-column type="selection" width="55"/>
+      <el-table-column prop="id" label="ID"/>
+      <el-table-column prop="clientId" label="ClientId"/>
+      <el-table-column prop="redirectUri" label="回调地址"/>
+
+      <el-table-column label="状态">
+        <template slot-scope="scope">
+          <el-tag :type="scope.row.status==1?'success':'danger'">
+            {{ scope.row.status==1?'启用':'禁用' }}
+          </el-tag>
+        </template>
+      </el-table-column>
+
+      <el-table-column label="操作">
+        <template slot-scope="scope">
+
+          <el-button size="mini" type="text" @click="handleUpdate(scope.row)">修改</el-button>
+
+          <el-button size="mini" type="text" @click="handleDelete(scope.row)">删除</el-button>
+
+          <el-button size="mini" type="text" @click="toggleStatus(scope.row)">
+            {{scope.row.status==1?'禁用':'启用'}}
+          </el-button>
+
+          <el-button size="mini" type="text" @click="auth(scope.row.id)">
+            授权
+          </el-button>
+
+        </template>
+      </el-table-column>
+    </el-table>
+
+    <!-- 分页(注意这里 total 用 length) -->
+    <pagination
+      v-show="accountList.length > 0"
+      :total="accountList.length"
+      :page.sync="queryParams.pageNum"
+      :limit.sync="queryParams.pageSize"
+    />
+
+    <!-- 弹窗 -->
+    <el-dialog :title="title" :visible.sync="open" width="500px">
+
+      <el-form ref="form" :model="form">
+
+        <el-form-item label="ClientId">
+          <el-input v-model="form.clientId"/>
+        </el-form-item>
+
+        <el-form-item label="ClientSecret">
+          <el-input v-model="form.clientSecret"/>
+        </el-form-item>
+
+        <el-form-item label="回调地址">
+          <el-input v-model="form.redirectUri"/>
+        </el-form-item>
+
+      </el-form>
+
+      <div slot="footer">
+        <el-button type="primary" @click="submitForm">确定</el-button>
+        <el-button @click="cancel">取消</el-button>
+      </div>
+
+    </el-dialog>
+
+  </div>
+</template>
+
+<script>
+import {
+  listXsyAccount,
+  addXsyAccount,
+  updateXsyAccount,
+  delXsyAccount,
+  updateXsyAccountStatus,
+  getXsyAuthUrl
+} from "@/api/xsy/xsy";
+
+export default {
+  name: "XsyAccount",
+
+  data() {
+    return {
+      loading: true,
+      accountList: [],
+      ids: [],
+      single: true,
+      multiple: true,
+      showSearch: true,
+
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        clientId: null,
+        status: null
+      },
+
+      form: {},
+      open: false,
+      title: ""
+    };
+  },
+
+  created() {
+    this.getList();
+  },
+
+  methods: {
+
+    /** 查询列表 */
+    getList() {
+      this.loading = true;
+      listXsyAccount(this.queryParams).then(res => {
+        this.accountList = res.rows || [];
+        this.loading = false;
+      });
+    },
+
+    /** 搜索 */
+    handleQuery() {
+      this.getList();
+    },
+
+    /** 重置 */
+    resetQuery() {
+      this.resetForm("queryForm");
+      this.getList();
+    },
+
+    /** 选中 */
+    handleSelectionChange(selection) {
+      this.ids = selection.map(item => item.id);
+      this.single = selection.length !== 1;
+      this.multiple = !selection.length;
+    },
+
+    /** 新增 */
+    handleAdd() {
+      this.form = {};
+      this.open = true;
+      this.title = "新增账号";
+    },
+
+    /** 修改 */
+    handleUpdate(row) {
+      this.form = row || {};
+      this.open = true;
+      this.title = "修改账号";
+    },
+
+    /** 提交 */
+    submitForm() {
+      const api = this.form.id ? updateXsyAccount : addXsyAccount;
+
+      api(this.form).then(res => {
+        if (res.code === 200) {
+          this.msgSuccess("操作成功");
+          this.open = false;
+          this.getList();
+        }
+      });
+    },
+
+    /** 删除 */
+    handleDelete(row) {
+      const ids = row.id || this.ids;
+
+      this.$confirm('是否确认删除编号为"' + ids + '"的数据项?', "警告")
+        .then(() => {
+          return delXsyAccount(ids);
+        })
+        .then(() => {
+          this.msgSuccess("删除成功");
+          this.getList();
+        });
+    },
+
+    /** 状态切换 */
+    toggleStatus(row) {
+      const status = row.status === 1 ? 0 : 1;
+
+      updateXsyAccountStatus(row.id, status).then(() => {
+        this.msgSuccess("状态修改成功");
+        this.getList();
+      });
+    },
+
+    /** 授权 */
+    auth(id) {
+      getXsyAuthUrl(id).then(res => {
+        window.open(res.msg);
+      });
+    },
+
+    cancel() {
+      this.open = false;
+    }
+
+  }
+};
+</script>