Procházet zdrojové kódy

fix:功能配置功能开发

wuguojie před 1 rokem
rodič
revize
0e7b4a668c

+ 1 - 0
.env.development

@@ -5,6 +5,7 @@ VITE_APP_TITLE = 掌柜运营平台
 # 接口请求地址,会设置到 axios 的 baseURL 参数上
 # VITE_APP_API_BASEURL = http://192.168.0.55:8001  #董鑫
 VITE_APP_API_BASEURL = http://192.168.0.253:8001  #田智
+# VITE_APP_API_BASEURL = http://192.168.0.106:8001  #屈晨
 # VITE_APP_API_BASEURL = http://192.168.0.59:8001  #徐强
 
 # 调试工具,可设置 eruda 或 vconsole,如果不需要开启则留空

+ 3 - 1
src/api/index.ts

@@ -14,6 +14,7 @@ import dept from './modules/dept'
 import company from './modules/insuranceCompany'
 import product from "./modules/product"
 import configurate from './modules/configurate.ts'
+import urlApi from './modules/url.ts'
 const axiosInstance:ApiInstance = axios.create({
   baseURL: (import.meta.env.DEV && import.meta.env.VITE_OPEN_PROXY === 'true') ? '/proxy/' : import.meta.env.VITE_APP_API_BASEURL,
   timeout: 1000 * 60,
@@ -102,6 +103,7 @@ const api = {
   dept:dept(axiosInstance),
   company:company(axiosInstance),
   product:product(axiosInstance),
-  configurate: configurate(axiosInstance)
+  configurate: configurate(axiosInstance),
+  urlApi: urlApi(axiosInstance)
 }
 export default api

+ 10 - 0
src/api/modules/url.ts

@@ -0,0 +1,10 @@
+import { ApiInstance } from '../type'
+
+const urlApi = (axiosInstance: ApiInstance)  => ({
+  add: (data: any) => axiosInstance.post('/manager/agreementUrl/add ', data, {}), // 新增
+  update: (data: any) => axiosInstance.post('/manager/agreementUrl/update ', data, {}), // 编辑
+  delete: (data: any) => axiosInstance.post('/manager/agreementUrl/delete ', data, {}), // 删除
+  list: (data: any) => axiosInstance.post('/manager/agreementUrl/getAgreementUrlList', data, {}), // 列表
+})
+
+export default urlApi

+ 8 - 0
src/router/modules/insuranceCompany.ts

@@ -36,6 +36,14 @@ const routes: RouteRecordRaw = {
         title: '账号归属配置',
       },
     },
+    {
+      path: 'companyUrlConfig',
+      name: 'CompanyUrlConfigIndex',
+      component: () => import('@/views/insuranceCompanyConfiguration/companyUrlConfig.vue'),
+      meta: {
+        title: '地址配置',
+      },
+    },
   ],
 }
 

+ 2 - 2
src/store/modules/user.ts

@@ -40,9 +40,9 @@ const useUserStore = defineStore(
     }) {
       const res = await api.user.login(data)
       localStorage.setItem('userName', data.userName)
-      localStorage.setItem('token', res.data)
+      localStorage.setItem('token', res.data.token)
       userName.value = data.userName
-      token.value = res.data
+      token.value = res.data.token
       if(token.value){
         getPermissions();
         getUserInfo();

+ 275 - 0
src/views/insuranceCompanyConfiguration/companyUrlConfig.vue

@@ -0,0 +1,275 @@
+<template>
+  <div class="companyUrlConfig">
+    <el-form :model="searchForm" style="width: 100%">
+      <el-row :gutter="20">
+        <el-col :span="8">
+          <el-form-item label="名称">
+            <el-input v-model="searchForm.name" clearable></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8">
+          <el-form-item label="保险公司">
+            <el-select v-model="searchForm.companyId" clearable>
+              <el-option v-for="item in companyList" :key="item.value" :label="item.name" :value="item.id"></el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8" style="display: flex; align-items: center; justify-content: flex-end">
+          <el-button plain @click="reset">重置</el-button>
+          <el-button type="primary" @click="search">搜索</el-button>
+        </el-col>
+      </el-row>
+    </el-form>
+    <el-button type="primary" @click="addUrl">新增</el-button>
+    <el-table :data="tableData">
+      <el-table-column label="名称" prop="name"></el-table-column>
+      <el-table-column label="地址" prop="url"></el-table-column>
+      <el-table-column label="保险公司" prop="companyName"></el-table-column>
+      <el-table-column label="操作">
+        <template #default="scope">
+          <el-button link type="primary" @click="urlEdit(scope.row)">编辑</el-button>
+          <el-button link type="danger" @click="urlDel(scope.row)">删除</el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+    <div class="pagination">
+      <el-pagination  :current-page="pageNum" :page-size="pageSize" :page-sizes="[20, 40, 60, 80]" :total="total" @size-change="handleSizeChange" @current-change="handlePageChange" layout="total, sizes, prev, pager, next"></el-pagination>
+    </div>
+    <el-dialog
+      :title="title"
+      v-model="urlShow"
+      width="600"
+    >
+      <div>
+        <el-form class="urlForm" ref="UrlForm" :model="form" :rules="formRules" label-width="80">
+          <el-form-item label="名称" prop="name">
+            <el-input v-model="form.name"></el-input>
+          </el-form-item>
+          <el-form-item label="地址" prop="url">
+            <el-input v-model="form.url"></el-input>
+          </el-form-item>
+          <el-form-item label="保险公司" prop="companyId">
+            <el-select v-model="form.companyId">
+              <el-option v-for="item in companyList" :key="item.value" :label="item.name" :value="item.id"></el-option>
+            </el-select>
+          </el-form-item>
+        </el-form>
+        <div class="footer">
+          <el-button plain @click="handleCancel()">取消</el-button>
+          <el-button type="primary" @click="handleConfirm(UrlForm)">保存</el-button>
+        </div>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script setup lang="ts">
+import api from '@/api'
+import type { FormInstance, FormRules } from 'element-plus'
+import { ElMessage, ElPagination, ElMessageBox } from "element-plus";
+
+let searchForm = ref({
+  name: '',
+  companyId: ''
+})
+const reset = () => {
+  searchForm.value = {
+    name: '',
+    companyId: ''
+  }
+  initData()
+}
+const search = () => {
+  initData()
+}
+
+// 新增
+const addUrl = () => {
+  urlShow.value = true
+  title.value = '新增'
+  form.value = {
+    name: '',
+    url: '',
+    companyId: ''
+  }
+}
+
+let tableData = ref([])
+let pageNum = ref(1)
+let pageSize = ref(10)
+let total = ref(0)
+const initData = () => {
+  let params = {
+    ...searchForm.value,
+    pages: pageNum.value,
+    size: pageSize.value
+  }
+  api.urlApi.list({...params}).then((res: any) => {
+    if(res.code == 200) {
+      tableData.value = res.data.records
+      total.value = res.data.total
+    }
+  })
+}
+const handleSizeChange = (size) => {
+  pageSize.value = size
+  initData()
+}
+const handlePageChange = (page) => {
+  pageNum.value = page
+  initData()
+}
+
+// 新增/编辑
+let title = ref('新增')
+let urlShow = ref(false)
+let UrlForm = ref()
+let form = ref({
+  name: '',
+  url: '',
+  companyId: ''
+})
+
+const urlEdit = (row) => {
+  urlShow.value = true
+  title.value = '编辑'
+  form.value = JSON.parse(JSON.stringify(row))
+}
+const urlDel = (row) => {
+  ElMessageBox({
+    title: '提示',
+    message: '请确定是否删除',
+    confirmButtonText: "确认删除",
+    cancelButtonText: "取消",
+    type: "warning",
+    center:true
+  }).then((action) => {
+    if(action === 'confirm') {
+      api.urlApi.delete({
+        id: row.id
+      }).then((res: any) => {
+        if(res.code == 200) {
+          ElMessage({
+            message: '删除成功',
+            type: 'success'
+          })
+          initData()
+        } else {
+          ElMessage({
+            message: res.msg,
+            type: 'warning'
+          })
+        }
+      })
+    }
+  })
+    .catch(() => {
+      ElMessage.warning("用户取消操作");
+    });
+}
+
+let formRules = ref<FormRules>({
+  name: [
+    { required: true, trigger: 'blur', message: '请输入名称' },
+  ],
+  url: [
+    { required: true, trigger: 'blur', message: '请输入地址' },
+  ],
+  companyId: [
+    { required: true, trigger: 'change', message: '请选择保险公司' },
+  ],
+})
+let companyList = ref([])
+
+const findTree = () => {
+  api.company.findTree({
+    name: ''
+  }).then((res: any) => {
+    if(res.code == 200) {
+      companyList.value = res.data
+    } else {
+      ElMessage({
+        message: res.msg,
+        type: 'warning'
+      })
+    }
+  })
+}
+const handleCancel = () => {
+  form.value = {
+    name: '',
+    url: '',
+    companyId: ''
+  }
+  urlShow.value = false
+}
+const handleConfirm = async (formEl) => {
+  if(!formEl) return
+  await formEl.validate((valid) => {
+    if(valid) {
+      if(title.value === '新增') {
+        api.urlApi.add({
+          ...form.value
+        }).then((res: any) => {
+          if(res.code == 200) {
+            ElMessage({
+              message: res.msg,
+              type: 'success'
+            })
+            initData()
+          } else {
+            ElMessage({
+              message: res.msg,
+              type: 'warning'
+            })
+          }
+        })
+      } else {
+        api.urlApi.update({
+          ...form.value
+        }).then((res: any) => {
+          if(res.code == 200) {
+            ElMessage({
+              message: res.msg,
+              type: 'success'
+            })
+            initData()
+          } else {
+            ElMessage({
+              message: res.msg,
+              type: 'warning'
+            })
+          }
+        })
+      }
+      urlShow.value = false
+    }
+  })
+}
+
+onMounted(() => {
+  findTree();
+  initData()
+})
+
+</script>
+
+<style scoped lang="scss">
+.companyUrlConfig{
+  width: calc(100% - 20px);
+  height: calc(100vh - 130px);
+  background: #ffffff;
+  padding: 24px;
+  .pagination{
+    margin: 10px 0;
+    display: flex;
+    align-items: center;
+    justify-content: flex-end;
+  }
+  .footer{
+    display: flex;
+    align-items: center;
+    justify-content: flex-end;
+  }
+}
+</style>