权限管理bug修复

This commit is contained in:
THK3121 2023-07-19 09:44:49 +08:00
commit 4504d354ad
6 changed files with 3603 additions and 3298 deletions

26
src/api/contract.ts Normal file
View File

@ -0,0 +1,26 @@
import request from '@/utils/request'
// 合同列表
export function apiContractLists(params: any) {
return request.get({ url: '/contract.contract/lists', params })
}
// 添加合同
export function apiContractAdd(params: any) {
return request.post({ url: '/contract.contract/add', params })
}
// 编辑合同
export function apiContractEdit(params: any) {
return request.post({ url: '/contract.contract/edit', params })
}
// 删除合同
export function apiContractDelete(params: any) {
return request.post({ url: '/contract.contract/delete', params })
}
// 合同详情
export function apiContractDetail(params: any) {
return request.get({ url: '/contract.contract/detail', params })
}

View File

@ -10,7 +10,7 @@
placeholder="请输入公司名称"
/>
</el-form-item>
<el-form-item label="区" prop="area">
<el-form-item label="区" prop="area" v-show="company_type_show">
<el-input
class="w-[280px]"
v-model="queryParams.area"
@ -18,7 +18,7 @@
placeholder="请输入区"
/>
</el-form-item>
<el-form-item label="镇" prop="street">
<el-form-item label="镇" prop="street" v-show="company_type_show">
<el-input
class="w-[280px]"
v-model="queryParams.street"
@ -26,30 +26,21 @@
placeholder="请输入镇"
/>
</el-form-item>
<!-- <el-form-item label="公司类型" prop="company_type">
<el-input
class="w-[280px]"
<el-form-item label="公司类型" prop="company_type" v-show="company_type_show">
<el-select
v-model="queryParams.company_type"
placeholder="请选择公司类型"
clearable
placeholder="请输入公司类型"
/>
</el-form-item> -->
<el-form-item label="公司类型" prop="company_type">
<el-select
v-model="queryParams.company_type"
placeholder="请选择公司类型"
clearable
:style="{ width: '100%' }"
>
<el-option
v-for="(item, index) in datas.dictTypeLists"
:key="index"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
:style="{ width: '100%' }"
>
<el-option
v-for="(item, index) in datas.dictTypeLists"
:key="index"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="片区经理" prop="area_manager">
<el-input
class="w-[280px]"
@ -60,20 +51,14 @@
</el-form-item>
<el-form-item label="是否签约" prop="is_contract">
<el-select
v-model="queryParams.is_contract"
placeholder="是否签约"
clearable
:style="{ width: '100%' }"
>
<el-option
label="已签约"
value="1"
></el-option>
<el-option
label="未签约"
value="0"
></el-option>
</el-select>
v-model="queryParams.is_contract"
placeholder="是否签约"
clearable
:style="{ width: '100%' }"
>
<el-option label="已签约" value="1"></el-option>
<el-option label="未签约" value="0"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="resetPage">查询</el-button>
@ -100,7 +85,7 @@
</template>
创建
</el-button>
</router-link>
</router-link>
<div class="mt-4">
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
<el-table-column label="id" prop="id" show-overflow-tooltip />
@ -115,49 +100,50 @@
<el-table-column label="是否签约" prop="is_contract" show-overflow-tooltip />
<el-table-column label="操作" width="140" fixed="right">
<template #default="{ row }">
<div style="display:flex;">
<div style="display: flex">
<el-button
v-perms="['company/edit', 'company/add']"
type="primary"
link>
<router-link
:to="{
path: getRoutePath('company/add:edit'),
query: {
id: row.id,
read:true
}
}"
> 查看</router-link>
</el-button>
<el-button
v-perms="['company/edit', 'company/add']"
type="primary"
link
>
<router-link
:to="{
path: getRoutePath('company/add:edit'),
query: {
id: row.id,
edit:true
}
}"
v-perms="['company/edit', 'company/add']"
type="primary"
link
>
编辑
</router-link>
</el-button>
<el-button
v-perms="['company/delete']"
type="danger"
link
@click="handleDelete(row.id)"
>
删除
</el-button>
<router-link
:to="{
path: getRoutePath('company/add:edit'),
query: {
id: row.id,
read: true
}
}"
>
查看</router-link
>
</el-button>
<el-button
v-perms="['company/edit', 'company/add']"
type="primary"
link
>
<router-link
:to="{
path: getRoutePath('company/add:edit'),
query: {
id: row.id,
edit: true
}
}"
>
编辑
</router-link>
</el-button>
<el-button
v-perms="['company/delete']"
type="danger"
link
@click="handleDelete(row.id)"
>
删除
</el-button>
</div>
</template>
</el-table-column>
</el-table>
@ -187,37 +173,29 @@ import EditPopup from './edit.vue'
import { getRoutePath } from '@/router'
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
const route = useRoute()
const company_type_show = ref(true)
//
const showEdit = ref(false)
//
const queryParams = reactive({
level_two: '',
level_one: '',
company_name: '',
organization_code: '',
city: '',
area: '',
street: '',
company_type: '',
master_name: '',
master_position: '',
master_phone: '',
master_email: '',
other_contacts: '',
area_manager: '',
//
is_contract: '',
account: '',
password: '',
deposit: '',
deposit_time: '',
qualification: '',
status: ''
is_contract: ''
})
const datas = reactive({
dictTypeLists: [],
if (route.query.company_type) {
company_type_show.value = false
queryParams['company_type'] = route.query.company_type?.toString() || ''
}
const datas = reactive({
dictTypeLists: []
})
const getdictTypeLists = async () => {
const data = await dictDataLists({ type_id: 6 })
@ -241,21 +219,6 @@ const { pager, getLists, resetParams, resetPage } = usePaging({
params: queryParams
})
//
const handleAdd = async () => {
showEdit.value = true
await nextTick()
editRef.value?.open('add')
}
//
const handleEdit = async (data: any) => {
showEdit.value = true
await nextTick()
editRef.value?.open('edit')
editRef.value?.setFormData(data)
}
//
const handleDelete = async (id: number | any[]) => {
await feedback.confirm('确定要删除?')
@ -266,8 +229,7 @@ const handleDelete = async (id: number | any[]) => {
getLists()
</script>
<style lang="scss">
.btn{
position: absolute;
.btn {
position: absolute;
}
</style>

162
src/views/contract/edit.vue Normal file
View File

@ -0,0 +1,162 @@
<template>
<div class="edit-popup">
<popup
ref="popupRef"
:title="popupTitle"
:async="true"
width="550px"
@confirm="handleSubmit"
@close="handleClose"
>
<el-form ref="formRef" :model="formData" label-width="90px" :rules="formRules">
<el-form-item label="公司" prop="company_id">
<el-input v-model="formData.company_id" clearable placeholder="请输入公司" />
</el-form-item>
<el-form-item label="合同类型" prop="contract_type">
<el-input v-model="formData.contract_type" clearable placeholder="请输入合同类型" />
</el-form-item>
<el-form-item label="合同编号" prop="contract_no">
<el-input v-model="formData.contract_no" clearable placeholder="请输入合同编号" />
</el-form-item>
<el-form-item label="文件" prop="file">
<el-input v-model="formData.file" clearable placeholder="请输入文件" />
</el-form-item>
<el-form-item label="状态" prop="status">
<el-input v-model="formData.status" clearable placeholder="请输入状态" />
</el-form-item>
<el-form-item label="甲方" prop="party_a">
<el-input v-model="formData.party_a" clearable placeholder="请输入甲方" />
</el-form-item>
<el-form-item label="乙方" prop="party_b">
<el-input v-model="formData.party_b" clearable placeholder="请输入乙方" />
</el-form-item>
<el-form-item label="片区经理" prop="area_manager">
<el-input v-model="formData.area_manager" clearable placeholder="请输入片区经理" />
</el-form-item>
</el-form>
</popup>
</div>
</template>
<script lang="ts" setup name="contractEdit">
import type { FormInstance } from 'element-plus'
import Popup from '@/components/popup/index.vue'
import { apiContractAdd, apiContractEdit, apiContractDetail } from '@/api/contract'
import { timeFormat } from '@/utils/util'
import type { PropType } from 'vue'
defineProps({
dictData: {
type: Object as PropType<Record<string, any[]>>,
default: () => ({})
}
})
const emit = defineEmits(['success', 'close'])
const formRef = shallowRef<FormInstance>()
const popupRef = shallowRef<InstanceType<typeof Popup>>()
const mode = ref('add')
//
const popupTitle = computed(() => {
return mode.value == 'edit' ? '编辑合同' : '新增合同'
})
//
const formData = reactive({
id: '',
company_id: '',
contract_type: '',
contract_no: '',
file: '',
status: '',
party_a: '',
party_b: '',
area_manager: '',
})
//
const formRules = reactive<any>({
company_id: [{
required: true,
message: '请输入公司',
trigger: ['blur']
}],
contract_type: [{
required: true,
message: '请输入合同类型',
trigger: ['blur']
}],
contract_no: [{
required: true,
message: '请输入合同编号',
trigger: ['blur']
}],
file: [{
required: true,
message: '请输入文件',
trigger: ['blur']
}],
party_a: [{
required: true,
message: '请输入甲方',
trigger: ['blur']
}],
party_b: [{
required: true,
message: '请输入乙方',
trigger: ['blur']
}]
})
//
const setFormData = async (data: Record<any, any>) => {
for (const key in formData) {
if (data[key] != null && data[key] != undefined) {
//@ts-ignore
formData[key] = data[key]
}
}
}
const getDetail = async (row: Record<string, any>) => {
const data = await apiContractDetail({
id: row.id
})
setFormData(data)
}
//
const handleSubmit = async () => {
await formRef.value?.validate()
const data = { ...formData, }
mode.value == 'edit'
? await apiContractEdit(data)
: await apiContractAdd(data)
popupRef.value?.close()
emit('success')
}
//
const open = (type = 'add') => {
mode.value = type
popupRef.value?.open()
}
//
const handleClose = () => {
emit('close')
}
defineExpose({
open,
setFormData,
getDetail
})
</script>

View File

@ -0,0 +1,179 @@
<template>
<div>
<el-card class="!border-none mb-4" shadow="never">
<el-form class="mb-[-16px]" :model="queryParams" inline>
<el-form-item label="公司" prop="company_id">
<el-input
class="w-[280px]"
v-model="queryParams.company_id"
clearable
placeholder="请输入公司"
/>
</el-form-item>
<el-form-item label="合同类型" prop="contract_type">
<el-input
class="w-[280px]"
v-model="queryParams.contract_type"
clearable
placeholder="请输入合同类型"
/>
</el-form-item>
<el-form-item label="合同编号" prop="contract_no">
<el-input
class="w-[280px]"
v-model="queryParams.contract_no"
clearable
placeholder="请输入合同编号"
/>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-input
class="w-[280px]"
v-model="queryParams.status"
clearable
placeholder="请输入状态"
/>
</el-form-item>
<el-form-item label="片区经理" prop="area_manager">
<el-input
class="w-[280px]"
v-model="queryParams.area_manager"
clearable
placeholder="请输入片区经理"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="resetPage">查询</el-button>
<el-button @click="resetParams">重置</el-button>
</el-form-item>
</el-form>
</el-card>
<el-card class="!border-none" v-loading="pager.loading" shadow="never">
<!-- <el-button v-perms="['contract.contract/add']" type="primary" @click="handleAdd">
<template #icon>
<icon name="el-icon-Plus" />
</template>
新增
</el-button> -->
<el-button
v-perms="['contract.contract/delete']"
:disabled="!selectData.length"
@click="handleDelete(selectData)"
>
删除
</el-button>
<div class="mt-4">
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" />
<el-table-column label="id" prop="id" show-overflow-tooltip />
<el-table-column label="公司" prop="company_name" show-overflow-tooltip />
<el-table-column
label="合同类型"
prop="contract_type_name"
show-overflow-tooltip
/>
<el-table-column label="合同编号" prop="contract_no" show-overflow-tooltip />
<el-table-column label="状态" prop="status" show-overflow-tooltip />
<el-table-column label="甲方" prop="party_a_name" show-overflow-tooltip />
<el-table-column label="片区经理" prop="area_manager" show-overflow-tooltip />
<el-table-column label="操作" width="120" fixed="right">
<template #default="{ row }">
<!-- <el-button
v-perms="['contract.contract/edit']"
type="primary"
link
@click="handleEdit(row)"
>
编辑
</el-button> -->
<el-button
v-perms="['contract.contract/delete']"
type="danger"
link
@click="handleDelete(row.id)"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div class="flex mt-4 justify-end">
<pagination v-model="pager" @change="getLists" />
</div>
</el-card>
<edit-popup
v-if="showEdit"
ref="editRef"
:dict-data="dictData"
@success="getLists"
@close="showEdit = false"
/>
</div>
</template>
<script lang="ts" setup name="contractLists">
import { usePaging } from '@/hooks/usePaging'
import { useDictData } from '@/hooks/useDictOptions'
import { apiContractLists, apiContractDelete } from '@/api/contract'
import { timeFormat } from '@/utils/util'
import feedback from '@/utils/feedback'
import EditPopup from './edit.vue'
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
//
const showEdit = ref(false)
//
const queryParams = reactive({
company_id: '',
contract_type: '',
contract_no: '',
status: '',
party_a: '',
party_b: '',
area_manager: ''
})
//
const selectData = ref<any[]>([])
//
const handleSelectionChange = (val: any[]) => {
selectData.value = val.map(({ id }) => id)
}
//
const { dictData } = useDictData('')
//
const { pager, getLists, resetParams, resetPage } = usePaging({
fetchFun: apiContractLists,
params: queryParams
})
//
const handleAdd = async () => {
showEdit.value = true
await nextTick()
editRef.value?.open('add')
}
//
const handleEdit = async (data: any) => {
showEdit.value = true
await nextTick()
editRef.value?.open('edit')
editRef.value?.setFormData(data)
}
//
const handleDelete = async (id: number | any[]) => {
await feedback.confirm('确定要删除?')
await apiContractDelete({ id })
getLists()
}
getLists()
</script>

View File

@ -189,7 +189,7 @@
<el-col :span="24">
<el-row>
<el-col :span="8">
<el-form-item label="身份证" prop="id_card" >
<el-form-item label="身份证" prop="id_card">
<el-upload
v-model="formData.qualification.id_card"
class="avatar-uploader"
@ -229,7 +229,7 @@
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="行驶证" prop="car_card" >
<el-form-item label="行驶证" prop="car_card">
<el-upload
v-model="formData.qualification.car_card"
class="avatar-uploader"
@ -268,7 +268,7 @@
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="银行卡号" prop="bank_account" >
<el-form-item label="银行卡号" prop="bank_account">
<el-upload
v-model="formData.qualification.bank_account"
class="avatar-uploader"
@ -329,9 +329,8 @@
:disabled="true"
clearable
:style="{ width: '100%' }"
:value="formData.sex==1?'男':'女'"
:value="formData.sex == 1 ? '男' : '女'"
></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
@ -394,11 +393,6 @@
</el-form-item>
</el-col>
<!-- <el-col :span="12">
<el-form-item label="合同类型" prop="field124">
<el-input
@ -435,7 +429,7 @@
</el-col>
<el-col :span="24">
<el-form-item label="上传" prop="field127" >
<el-form-item label="上传" prop="field127">
<!-- <el-upload ref="field127">
<el-button size="small" type="primary" icon="el-icon-upload"
>点击上传</el-button
@ -448,27 +442,19 @@
:on-success="handleAvatarSuccess_four"
multiple
:limit="1"
>
<el-button type="primary">上传</el-button>
<el-button type="primary">上传</el-button>
</el-upload>
</el-form-item>
</el-col>
<!-- 账号输入框 -->
<!-- 管理员头像 -->
<!-- 密码输入框 -->
<!-- 确认密码输入框 -->
<!-- 管理员状态 -->
</el-form>
</popup>
</div>
@ -509,13 +495,12 @@ const formData = reactive({
car_card_b: '',
bank_account: '',
bank_account_b: ''
},
//
contract_type:"",
contract_type: '',
//
contract:"",
file:'',
contract: '',
file: '',
is_contract: 0,
role_id: "",
avatar: '',
@ -523,14 +508,14 @@ const formData = reactive({
root: 0
})
//
const datas:any = reactive({
const datas: any = reactive({
provinceOptions: [],
cityOptions: [],
areaOptions: [],
streetOptions: [],
dictTypeLists: [],
contract_type: [],
contract:[]
contract: []
})
const getcontract_type = async () => {
const data = await dictDataLists({ type_id: 7 })
@ -549,28 +534,25 @@ getcontract_type()
//
const ValidatorPhone = (rule: object, value: string, callback: any) => {
let rg= /^(?:(?:\+|00)86)?1[3-9]\d{9}$/
rg.test(formData.phone)?callback():callback(new Error('请输入正确的手机号'))
const rg = /^(?:(?:\+|00)86)?1[3-9]\d{9}$/
rg.test(formData.phone) ? callback() : callback(new Error('请输入正确的手机号'))
}
//
const ValidatorId = (rule: object, value: string, callback: any) => {
let rg= /^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[1-2]\d|30|31)\d{3}[\dXx]$/
rg.test(formData.id_card)?callback():callback(new Error('请输入正确的身份证号码'))
const rg = /^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[1-2]\d|30|31)\d{3}[\dXx]$/
rg.test(formData.id_card) ? callback() : callback(new Error('请输入正确的身份证号码'))
}
const Validatorcard = (rule: object, value: string, callback: any) => {
formData.qualification.car_card?callback():callback(new Error('请输入驾驶证正面'))
formData.qualification.car_card ? callback() : callback(new Error('请输入驾驶证正面'))
}
const ValidatorcardB = (rule: object, value: string, callback: any) => {
formData.qualification.car_card_b?callback():callback(new Error('请输入驾驶证反面'))
formData.qualification.car_card_b ? callback() : callback(new Error('请输入驾驶证反面'))
}
const ValidatorBankcard = (rule: object, value: string, callback: any) => {
formData.qualification.bank_account?callback():callback(new Error('请输入银行卡正面'))
formData.qualification.bank_account ? callback() : callback(new Error('请输入银行卡正面'))
}
const ValidatorBankcardB = (rule: object, value: string, callback: any) => {
formData.qualification.bank_account_b?callback():callback(new Error('请输入银行卡反面'))
formData.qualification.bank_account_b ? callback() : callback(new Error('请输入银行卡反面'))
}
const formRules = reactive({
account: [
@ -580,31 +562,28 @@ const formRules = reactive({
trigger: ['blur']
}
],
id_card:[
id_card: [
{
required: true,
trigger: ['blur'],
validator:ValidatorId
validator: ValidatorId
}
],
phone:[
phone: [
{
required: true,
trigger: ['blur'],
validator:ValidatorPhone
validator: ValidatorPhone
}
],
sex:[
sex: [
{
required: true,
message: '请选择性别',
trigger: ['blur']
}
],
name: [
{
required: true,
@ -612,36 +591,36 @@ const formRules = reactive({
trigger: ['blur']
}
],
car_card:[
car_card: [
{
required: true,
trigger: ['change'],
validator:Validatorcard
validator: Validatorcard
}
],
car_card_b:[
car_card_b: [
{
required: true,
trigger: ['blur'],
validator:ValidatorcardB
validator: ValidatorcardB
}
],
bank_account:[
bank_account: [
{
required: true,
trigger: ['change'],
validator:ValidatorBankcard
validator: ValidatorBankcard
}
],bank_account_b:[
],
bank_account_b: [
{
required: true,
trigger: ['change'],
validator:ValidatorBankcardB
validator: ValidatorBankcardB
}
],
role_id: [
{
required: true,
message: '请选择角色',
trigger: ['blur']
@ -649,10 +628,6 @@ const formRules = reactive({
]
})
const { optionsData } = useDictOptions<{
role: any[]
jobs: any[]
@ -671,8 +646,9 @@ const { optionsData } = useDictOptions<{
const handleSubmit = async () => {
await formRef.value?.validate()
mode.value == 'edit' ? await adminEdit(formData) : await adminAdd(formData).then(res=>console.log(res))
mode.value == 'edit'
? await adminEdit(formData)
: await adminAdd(formData).then((res) => console.log(res))
popupRef.value?.close()
emit('success')
}

6242
yarn.lock

File diff suppressed because it is too large Load Diff