10 changed files with 1066 additions and 32 deletions
@ -0,0 +1,58 @@ |
|||||
|
import request from '@/utils/request' |
||||
|
|
||||
|
|
||||
|
|
||||
|
// USER_CODE_BEGIN -- contract_sign
|
||||
|
/** |
||||
|
* 获取合同关系列表 |
||||
|
* @param params |
||||
|
* @returns |
||||
|
*/ |
||||
|
export function getContractSignList(params: Record<string, any>) { |
||||
|
return request.get(`contract_sign/contract_sign`, {params}) |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取合同关系详情 |
||||
|
* @param id 合同关系id |
||||
|
* @returns |
||||
|
*/ |
||||
|
export function getContractSignInfo(id: number) { |
||||
|
return request.get(`contract_sign/contract_sign/${id}`); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 添加合同关系 |
||||
|
* @param params |
||||
|
* @returns |
||||
|
*/ |
||||
|
export function addContractSign(params: Record<string, any>) { |
||||
|
return request.post('contract_sign/contract_sign', params, { showErrorMessage: true, showSuccessMessage: true }) |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 编辑合同关系 |
||||
|
* @param id |
||||
|
* @param params |
||||
|
* @returns |
||||
|
*/ |
||||
|
export function editContractSign(params: Record<string, any>) { |
||||
|
return request.put(`contract_sign/contract_sign/${params.id}`, params, { showErrorMessage: true, showSuccessMessage: true }) |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除合同关系 |
||||
|
* @param id |
||||
|
* @returns |
||||
|
*/ |
||||
|
export function deleteContractSign(id: number) { |
||||
|
return request.delete(`contract_sign/contract_sign/${id}`, { showErrorMessage: true, showSuccessMessage: true }) |
||||
|
} |
||||
|
|
||||
|
export function getWithContractList(params: Record<string,any>){ |
||||
|
return request.get('contract_sign/contract_all', {params}) |
||||
|
}export function getWithPersonnelList(params: Record<string,any>){ |
||||
|
return request.get('contract_sign/personnel_all', {params}) |
||||
|
} |
||||
|
|
||||
|
// USER_CODE_END -- contract_sign
|
||||
@ -0,0 +1,17 @@ |
|||||
|
{ |
||||
|
"contractId":"合同", |
||||
|
"contractIdPlaceholder":"请输入合同", |
||||
|
"personnelId":"下发人员", |
||||
|
"personnelIdPlaceholder":"请输入下发人员", |
||||
|
"status":"签署状态", |
||||
|
"statusPlaceholder":"请输入签署状态", |
||||
|
"createdAt":"创建时间", |
||||
|
"createdAtPlaceholder":"请输入创建时间", |
||||
|
"signTime":"签署时间", |
||||
|
"signTimePlaceholder":"请输入签署时间", |
||||
|
"addContractSign":"添加合同关系", |
||||
|
"updateContractSign":"编辑合同关系", |
||||
|
"contractSignDeleteTips":"确定要删除该数据吗?", |
||||
|
"startDate":"请选择开始时间", |
||||
|
"endDate":"请选择结束时间" |
||||
|
} |
||||
@ -0,0 +1,184 @@ |
|||||
|
<template> |
||||
|
<el-dialog v-model="showDialog" :title="formData.id ? t('updateContractSign') : t('addContractSign')" width="50%" class="diy-dialog-wrap" :destroy-on-close="true"> |
||||
|
<el-form :model="formData" label-width="120px" ref="formRef" :rules="formRules" class="page-form" v-loading="loading"> |
||||
|
<el-form-item :label="t('contractId')" prop="contract_id"> |
||||
|
<el-select class="input-width" v-model="formData.contract_id" clearable :placeholder="t('contractIdPlaceholder')"> |
||||
|
<el-option label="请选择" value=""></el-option> |
||||
|
<el-option |
||||
|
v-for="(item, index) in contractIdList" |
||||
|
:key="index" |
||||
|
:label="item['contract_name']" |
||||
|
:value="item['id']" |
||||
|
/> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item :label="t('personnelId')" prop="personnel_id"> |
||||
|
<el-select class="input-width" v-model="formData.personnel_id" clearable :placeholder="t('personnelIdPlaceholder')"> |
||||
|
<el-option label="请选择" value=""></el-option> |
||||
|
<el-option |
||||
|
v-for="(item, index) in personnelIdList" |
||||
|
:key="index" |
||||
|
:label="item['name']" |
||||
|
:value="item['id']" |
||||
|
/> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
|
||||
|
</el-form> |
||||
|
|
||||
|
<template #footer> |
||||
|
<span class="dialog-footer"> |
||||
|
<el-button @click="showDialog = false">{{ t('cancel') }}</el-button> |
||||
|
<el-button type="primary" :loading="loading" @click="confirm(formRef)">{{ |
||||
|
t('confirm') |
||||
|
}}</el-button> |
||||
|
</span> |
||||
|
</template> |
||||
|
</el-dialog> |
||||
|
</template> |
||||
|
|
||||
|
<script lang="ts" setup> |
||||
|
import { ref, reactive, computed, watch } from 'vue' |
||||
|
import { useDictionary } from '@/app/api/dict' |
||||
|
import { t } from '@/lang' |
||||
|
import type { FormInstance } from 'element-plus' |
||||
|
import { addContractSign, editContractSign, getContractSignInfo, getWithContractList, getWithPersonnelList } from '@/app/api/contract_sign' |
||||
|
|
||||
|
let showDialog = ref(false) |
||||
|
const loading = ref(false) |
||||
|
|
||||
|
/** |
||||
|
* 表单数据 |
||||
|
*/ |
||||
|
const initialFormData = { |
||||
|
id: '', |
||||
|
contract_id: '', |
||||
|
personnel_id: '', |
||||
|
} |
||||
|
const formData: Record<string, any> = reactive({ ...initialFormData }) |
||||
|
|
||||
|
const formRef = ref<FormInstance>() |
||||
|
|
||||
|
// 表单验证规则 |
||||
|
const formRules = computed(() => { |
||||
|
return { |
||||
|
contract_id: [ |
||||
|
{ required: true, message: t('contractIdPlaceholder'), trigger: 'blur' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
personnel_id: [ |
||||
|
{ required: true, message: t('personnelIdPlaceholder'), trigger: 'blur' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
} |
||||
|
}) |
||||
|
|
||||
|
const emit = defineEmits(['complete']) |
||||
|
|
||||
|
/** |
||||
|
* 确认 |
||||
|
* @param formEl |
||||
|
*/ |
||||
|
const confirm = async (formEl: FormInstance | undefined) => { |
||||
|
if (loading.value || !formEl) return |
||||
|
let save = formData.id ? editContractSign : addContractSign |
||||
|
|
||||
|
await formEl.validate(async (valid) => { |
||||
|
if (valid) { |
||||
|
loading.value = true |
||||
|
|
||||
|
let data = formData |
||||
|
|
||||
|
save(data).then(res => { |
||||
|
loading.value = false |
||||
|
showDialog.value = false |
||||
|
emit('complete') |
||||
|
}).catch(err => { |
||||
|
loading.value = false |
||||
|
}) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
// 获取字典数据 |
||||
|
let statusList = ref([]) |
||||
|
const statusDictList = async () => { |
||||
|
statusList.value = await (await useDictionary('contract_status')).data.dictionary |
||||
|
} |
||||
|
statusDictList(); |
||||
|
watch(() => statusList.value, () => { formData.status = statusList.value[0].value }) |
||||
|
|
||||
|
|
||||
|
const contractIdList = ref([] as any[]) |
||||
|
const setContractIdList = async () => { |
||||
|
contractIdList.value = await (await getWithContractList({})).data |
||||
|
} |
||||
|
setContractIdList() |
||||
|
const personnelIdList = ref([] as any[]) |
||||
|
const setPersonnelIdList = async () => { |
||||
|
personnelIdList.value = await (await getWithPersonnelList({})).data |
||||
|
} |
||||
|
setPersonnelIdList() |
||||
|
const setFormData = async (row: any = null) => { |
||||
|
Object.assign(formData, initialFormData) |
||||
|
loading.value = true |
||||
|
if(row){ |
||||
|
const data = await (await getContractSignInfo(row.id)).data |
||||
|
if (data) Object.keys(formData).forEach((key: string) => { |
||||
|
if (data[key] != undefined) formData[key] = data[key] |
||||
|
}) |
||||
|
} |
||||
|
loading.value = false |
||||
|
} |
||||
|
|
||||
|
// 验证手机号格式 |
||||
|
const mobileVerify = (rule: any, value: any, callback: any) => { |
||||
|
if (value && !/^1[3-9]\d{9}$/.test(value)) { |
||||
|
callback(new Error(t('generateMobile'))) |
||||
|
} else { |
||||
|
callback() |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 验证身份证号 |
||||
|
const idCardVerify = (rule: any, value: any, callback: any) => { |
||||
|
if (value && !/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/.test(value)) { |
||||
|
callback(new Error(t('generateIdCard'))) |
||||
|
} else { |
||||
|
callback() |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 验证邮箱号 |
||||
|
const emailVerify = (rule: any, value: any, callback: any) => { |
||||
|
if (value && !/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test(value)) { |
||||
|
callback(new Error(t('generateEmail'))) |
||||
|
} else { |
||||
|
callback() |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 验证请输入整数 |
||||
|
const numberVerify = (rule: any, value: any, callback: any) => { |
||||
|
if (!Number.isInteger(value)) { |
||||
|
callback(new Error(t('generateNumber'))) |
||||
|
} else { |
||||
|
callback() |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
defineExpose({ |
||||
|
showDialog, |
||||
|
setFormData |
||||
|
}) |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss" scoped></style> |
||||
|
<style lang="scss"> |
||||
|
.diy-dialog-wrap .el-form-item__label{ |
||||
|
height: auto !important; |
||||
|
} |
||||
|
</style> |
||||
@ -0,0 +1,235 @@ |
|||||
|
<template> |
||||
|
<div class="main-container"> |
||||
|
<el-card class="box-card !border-none" shadow="never"> |
||||
|
|
||||
|
<div class="flex justify-between items-center"> |
||||
|
<span class="text-lg">{{pageName}}</span> |
||||
|
<el-button type="primary" @click="addEvent"> |
||||
|
{{ t('addContractSign') }} |
||||
|
</el-button> |
||||
|
</div> |
||||
|
|
||||
|
<el-card class="box-card !border-none my-[10px] table-search-wrap" shadow="never"> |
||||
|
<el-form :inline="true" :model="contractSignTable.searchParam" ref="searchFormRef"> |
||||
|
|
||||
|
<el-form-item :label="t('status')" prop="status"> |
||||
|
<el-select class="w-[280px]" v-model="contractSignTable.searchParam.status" clearable :placeholder="t('statusPlaceholder')"> |
||||
|
<el-option label="全部" value=""></el-option> |
||||
|
<el-option |
||||
|
v-for="(item, index) in statusList" |
||||
|
:key="index" |
||||
|
:label="item.name" |
||||
|
:value="item.value" |
||||
|
/> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item :label="t('createdAt')" prop="created_at"> |
||||
|
<el-date-picker v-model="contractSignTable.searchParam.created_at" type="datetimerange" format="YYYY-MM-DD hh:mm:ss" |
||||
|
:start-placeholder="t('startDate')" :end-placeholder="t('endDate')" /> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item :label="t('signTime')" prop="sign_time"> |
||||
|
<el-date-picker v-model="contractSignTable.searchParam.sign_time" type="datetimerange" format="YYYY-MM-DD hh:mm:ss" |
||||
|
:start-placeholder="t('startDate')" :end-placeholder="t('endDate')" /> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item> |
||||
|
<el-button type="primary" @click="loadContractSignList()">{{ t('search') }}</el-button> |
||||
|
<el-button @click="resetForm(searchFormRef)">{{ t('reset') }}</el-button> |
||||
|
</el-form-item> |
||||
|
</el-form> |
||||
|
</el-card> |
||||
|
|
||||
|
<div class="mt-[10px]"> |
||||
|
<el-table :data="contractSignTable.data" size="large" v-loading="contractSignTable.loading"> |
||||
|
<template #empty> |
||||
|
<span>{{ !contractSignTable.loading ? t('emptyData') : '' }}</span> |
||||
|
</template> |
||||
|
<el-table-column prop="contract_id_name" :label="t('contractId')" min-width="120" :show-overflow-tooltip="true"/> |
||||
|
|
||||
|
<el-table-column prop="personnel_id_name" :label="t('personnelId')" min-width="120" :show-overflow-tooltip="true"/> |
||||
|
|
||||
|
<el-table-column :label="t('status')" min-width="180" align="center" :show-overflow-tooltip="true"> |
||||
|
<template #default="{ row }"> |
||||
|
<div v-for="(item, index) in statusList"> |
||||
|
<div v-if="item.value == row.status">{{ item.name }}</div> |
||||
|
</div> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
|
||||
|
|
||||
|
<el-table-column label="预览" min-width="120" > |
||||
|
|
||||
|
<template #default="{ row }"> |
||||
|
|
||||
|
|
||||
|
|
||||
|
<template v-if="!row.sign_file"> |
||||
|
未签署 |
||||
|
</template> |
||||
|
|
||||
|
<template v-else-if="row.sign_file"> |
||||
|
<el-button type="success" text @click="openFile(row.sign_file)">打开文件</el-button> |
||||
|
</template> |
||||
|
|
||||
|
|
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
|
||||
|
|
||||
|
<el-table-column prop="created_at" :label="t('createdAt')" min-width="120" :show-overflow-tooltip="true"/> |
||||
|
|
||||
|
<el-table-column prop="sign_time" :label="t('signTime')" min-width="120" :show-overflow-tooltip="true"/> |
||||
|
|
||||
|
<el-table-column :label="t('operation')" fixed="right" min-width="120"> |
||||
|
<template #default="{ row }"> |
||||
|
<el-button type="primary" link @click="editEvent(row)">{{ t('edit') }}</el-button> |
||||
|
<el-button type="primary" link @click="deleteEvent(row.id)">{{ t('delete') }}</el-button> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
|
||||
|
</el-table> |
||||
|
<div class="mt-[16px] flex justify-end"> |
||||
|
<el-pagination v-model:current-page="contractSignTable.page" v-model:page-size="contractSignTable.limit" |
||||
|
layout="total, sizes, prev, pager, next, jumper" :total="contractSignTable.total" |
||||
|
@size-change="loadContractSignList()" @current-change="loadContractSignList" /> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<edit ref="editContractSignDialog" @complete="loadContractSignList" /> |
||||
|
</el-card> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script lang="ts" setup> |
||||
|
import { reactive, ref, watch } from 'vue' |
||||
|
import { t } from '@/lang' |
||||
|
import { useDictionary } from '@/app/api/dict' |
||||
|
import { getContractSignList, deleteContractSign, getWithContractList, getWithPersonnelList } from '@/app/api/contract_sign' |
||||
|
import { img } from '@/utils/common' |
||||
|
import { ElMessageBox,FormInstance } from 'element-plus' |
||||
|
import Edit from '@/app/views/contract_sign/components/contract-sign-edit.vue' |
||||
|
import { useRoute } from 'vue-router' |
||||
|
const route = useRoute() |
||||
|
const pageName = route.meta.title; |
||||
|
|
||||
|
let contractSignTable = reactive({ |
||||
|
page: 1, |
||||
|
limit: 10, |
||||
|
total: 0, |
||||
|
loading: true, |
||||
|
data: [], |
||||
|
searchParam:{ |
||||
|
"status":"", |
||||
|
"created_at":[], |
||||
|
"sign_time":[] |
||||
|
} |
||||
|
}) |
||||
|
|
||||
|
|
||||
|
const openFile = (url: string) => { |
||||
|
window.open(`${import.meta.env.VITE_IMG_DOMAIN}/${url}`, '_blank'); |
||||
|
}; |
||||
|
|
||||
|
|
||||
|
const searchFormRef = ref<FormInstance>() |
||||
|
|
||||
|
// 选中数据 |
||||
|
const selectData = ref<any[]>([]) |
||||
|
|
||||
|
// 字典数据 |
||||
|
const statusList = ref([] as any[]) |
||||
|
const statusDictList = async () => { |
||||
|
statusList.value = await (await useDictionary('contract_status')).data.dictionary |
||||
|
} |
||||
|
statusDictList(); |
||||
|
|
||||
|
/** |
||||
|
* 获取合同关系列表 |
||||
|
*/ |
||||
|
const loadContractSignList = (page: number = 1) => { |
||||
|
contractSignTable.loading = true |
||||
|
contractSignTable.page = page |
||||
|
|
||||
|
getContractSignList({ |
||||
|
page: contractSignTable.page, |
||||
|
limit: contractSignTable.limit, |
||||
|
...contractSignTable.searchParam |
||||
|
}).then(res => { |
||||
|
contractSignTable.loading = false |
||||
|
contractSignTable.data = res.data.data |
||||
|
contractSignTable.total = res.data.total |
||||
|
}).catch(() => { |
||||
|
contractSignTable.loading = false |
||||
|
}) |
||||
|
} |
||||
|
loadContractSignList() |
||||
|
|
||||
|
const editContractSignDialog: Record<string, any> | null = ref(null) |
||||
|
|
||||
|
/** |
||||
|
* 添加合同关系 |
||||
|
*/ |
||||
|
const addEvent = () => { |
||||
|
editContractSignDialog.value.setFormData() |
||||
|
editContractSignDialog.value.showDialog = true |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 编辑合同关系 |
||||
|
* @param data |
||||
|
*/ |
||||
|
const editEvent = (data: any) => { |
||||
|
editContractSignDialog.value.setFormData(data) |
||||
|
editContractSignDialog.value.showDialog = true |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除合同关系 |
||||
|
*/ |
||||
|
const deleteEvent = (id: number) => { |
||||
|
ElMessageBox.confirm(t('contractSignDeleteTips'), t('warning'), |
||||
|
{ |
||||
|
confirmButtonText: t('confirm'), |
||||
|
cancelButtonText: t('cancel'), |
||||
|
type: 'warning', |
||||
|
} |
||||
|
).then(() => { |
||||
|
deleteContractSign(id).then(() => { |
||||
|
loadContractSignList() |
||||
|
}).catch(() => { |
||||
|
}) |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
|
||||
|
const contractIdList = ref([]) |
||||
|
const setContractIdList = async () => { |
||||
|
contractIdList.value = await (await getWithContractList({})).data |
||||
|
} |
||||
|
setContractIdList() |
||||
|
const personnelIdList = ref([]) |
||||
|
const setPersonnelIdList = async () => { |
||||
|
personnelIdList.value = await (await getWithPersonnelList({})).data |
||||
|
} |
||||
|
setPersonnelIdList() |
||||
|
|
||||
|
const resetForm = (formEl: FormInstance | undefined) => { |
||||
|
if (!formEl) return |
||||
|
formEl.resetFields() |
||||
|
loadContractSignList() |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss" scoped> |
||||
|
/* 多行超出隐藏 */ |
||||
|
.multi-hidden { |
||||
|
word-break: break-all; |
||||
|
text-overflow: ellipsis; |
||||
|
overflow: hidden; |
||||
|
display: -webkit-box; |
||||
|
-webkit-line-clamp: 2; |
||||
|
-webkit-box-orient: vertical; |
||||
|
} |
||||
|
</style> |
||||
@ -0,0 +1,97 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Niucloud-admin 企业快速开发的多应用管理平台 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 官方网址:https://www.niucloud.com |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | niucloud团队 版权所有 开源版本可自由商用 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: Niucloud Team |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
namespace app\adminapi\controller\contract_sign; |
||||
|
|
||||
|
use core\base\BaseAdminController; |
||||
|
use app\service\admin\contract_sign\ContractSignService; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 合同关系控制器 |
||||
|
* Class ContractSign |
||||
|
* @package app\adminapi\controller\contract_sign |
||||
|
*/ |
||||
|
class ContractSign extends BaseAdminController |
||||
|
{ |
||||
|
/** |
||||
|
* 获取合同关系列表 |
||||
|
* @return \think\Response |
||||
|
*/ |
||||
|
public function lists(){ |
||||
|
$data = $this->request->params([ |
||||
|
["status",""], |
||||
|
["created_at",["",""]], |
||||
|
["sign_time",["",""]] |
||||
|
]); |
||||
|
return success((new ContractSignService())->getPage($data)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 合同关系详情 |
||||
|
* @param int $id |
||||
|
* @return \think\Response |
||||
|
*/ |
||||
|
public function info(int $id){ |
||||
|
return success((new ContractSignService())->getInfo($id)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 添加合同关系 |
||||
|
* @return \think\Response |
||||
|
*/ |
||||
|
public function add(){ |
||||
|
$data = $this->request->params([ |
||||
|
["contract_id",0], |
||||
|
["personnel_id",0], |
||||
|
|
||||
|
]); |
||||
|
$this->validate($data, 'app\validate\contract_sign\ContractSign.add'); |
||||
|
$id = (new ContractSignService())->add($data); |
||||
|
return success('ADD_SUCCESS', ['id' => $id]); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 合同关系编辑 |
||||
|
* @param $id 合同关系id |
||||
|
* @return \think\Response |
||||
|
*/ |
||||
|
public function edit(int $id){ |
||||
|
$data = $this->request->params([ |
||||
|
["contract_id",0], |
||||
|
["personnel_id",0], |
||||
|
|
||||
|
]); |
||||
|
$this->validate($data, 'app\validate\contract_sign\ContractSign.edit'); |
||||
|
(new ContractSignService())->edit($id, $data); |
||||
|
return success('EDIT_SUCCESS'); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 合同关系删除 |
||||
|
* @param $id 合同关系id |
||||
|
* @return \think\Response |
||||
|
*/ |
||||
|
public function del(int $id){ |
||||
|
(new ContractSignService())->del($id); |
||||
|
return success('DELETE_SUCCESS'); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public function getContractAll(){ |
||||
|
return success(( new ContractSignService())->getContractAll()); |
||||
|
} |
||||
|
|
||||
|
public function getPersonnelAll(){ |
||||
|
return success(( new ContractSignService())->getPersonnelAll()); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,42 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Niucloud-admin 企业快速开发的多应用管理平台 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 官方网址:https://www.niucloud.com |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | niucloud团队 版权所有 开源版本可自由商用 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: Niucloud Team |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
use think\facade\Route; |
||||
|
|
||||
|
use app\adminapi\middleware\AdminCheckRole; |
||||
|
use app\adminapi\middleware\AdminCheckToken; |
||||
|
use app\adminapi\middleware\AdminLog; |
||||
|
|
||||
|
// USER_CODE_BEGIN -- contract_sign |
||||
|
|
||||
|
Route::group('contract_sign', function () { |
||||
|
|
||||
|
//合同关系列表 |
||||
|
Route::get('contract_sign', 'contract_sign.ContractSign/lists'); |
||||
|
//合同关系详情 |
||||
|
Route::get('contract_sign/:id', 'contract_sign.ContractSign/info'); |
||||
|
//添加合同关系 |
||||
|
Route::post('contract_sign', 'contract_sign.ContractSign/add'); |
||||
|
//编辑合同关系 |
||||
|
Route::put('contract_sign/:id', 'contract_sign.ContractSign/edit'); |
||||
|
//删除合同关系 |
||||
|
Route::delete('contract_sign/:id', 'contract_sign.ContractSign/del'); |
||||
|
|
||||
|
Route::get('contract_all','contract_sign.ContractSign/getContractAll'); |
||||
|
|
||||
|
Route::get('personnel_all','contract_sign.ContractSign/getPersonnelAll'); |
||||
|
|
||||
|
})->middleware([ |
||||
|
AdminCheckToken::class, |
||||
|
AdminCheckRole::class, |
||||
|
AdminLog::class |
||||
|
]); |
||||
|
// USER_CODE_END -- contract_sign |
||||
@ -0,0 +1,118 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Niucloud-admin 企业快速开发的多应用管理平台 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 官方网址:https://www.niucloud.com |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | niucloud团队 版权所有 开源版本可自由商用 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: Niucloud Team |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
namespace app\model\contract_sign; |
||||
|
|
||||
|
use core\base\BaseModel; |
||||
|
use think\model\concern\SoftDelete; |
||||
|
use think\model\relation\HasMany; |
||||
|
use think\model\relation\HasOne; |
||||
|
|
||||
|
use app\model\contract\Contract; |
||||
|
|
||||
|
use app\model\personnel\Personnel; |
||||
|
|
||||
|
/** |
||||
|
* 合同关系模型 |
||||
|
* Class ContractSign |
||||
|
* @package app\model\contract_sign |
||||
|
*/ |
||||
|
class ContractSign extends BaseModel |
||||
|
{ |
||||
|
|
||||
|
use SoftDelete; |
||||
|
|
||||
|
/** |
||||
|
* 数据表主键 |
||||
|
* @var string |
||||
|
*/ |
||||
|
protected $pk = 'id'; |
||||
|
|
||||
|
/** |
||||
|
* 模型名称 |
||||
|
* @var string |
||||
|
*/ |
||||
|
protected $name = 'contract_sign'; |
||||
|
|
||||
|
/** |
||||
|
* 定义软删除标记字段. |
||||
|
* @var string |
||||
|
*/ |
||||
|
protected $deleteTime = 'deleted_at'; |
||||
|
|
||||
|
/** |
||||
|
* 定义软删除字段的默认值. |
||||
|
* @var int |
||||
|
*/ |
||||
|
protected $defaultSoftDelete = 0; |
||||
|
|
||||
|
/** |
||||
|
* 搜索器:合同关系签署状态 |
||||
|
* @param $value |
||||
|
* @param $data |
||||
|
*/ |
||||
|
public function searchStatusAttr($query, $value, $data) |
||||
|
{ |
||||
|
if ($value) { |
||||
|
$query->where("status", $value); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 搜索器:合同关系创建时间 |
||||
|
* @param $value |
||||
|
* @param $data |
||||
|
*/ |
||||
|
public function searchCreatedAtAttr($query, $value, $data) |
||||
|
{ |
||||
|
$start = empty($value[0]) ? 0 : strtotime($value[0]); |
||||
|
$end = empty($value[1]) ? 0 : strtotime($value[1]); |
||||
|
if ($start > 0 && $end > 0) { |
||||
|
$query->where([["created_at", "between", [$start, $end]]]); |
||||
|
} else if ($start > 0 && $end == 0) { |
||||
|
$query->where([["created_at", ">=", $start]]); |
||||
|
} else if ($start == 0 && $end > 0) { |
||||
|
$query->where([["created_at", "<=", $end]]); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 搜索器:合同关系签署时间 |
||||
|
* @param $value |
||||
|
* @param $data |
||||
|
*/ |
||||
|
public function searchSignTimeAttr($query, $value, $data) |
||||
|
{ |
||||
|
$start = empty($value[0]) ? 0 : strtotime($value[0]); |
||||
|
$end = empty($value[1]) ? 0 : strtotime($value[1]); |
||||
|
if ($start > 0 && $end > 0) { |
||||
|
$query->where([["sign_time", "between", [$start, $end]]]); |
||||
|
} else if ($start > 0 && $end == 0) { |
||||
|
$query->where([["sign_time", ">=", $start]]); |
||||
|
} else if ($start == 0 && $end > 0) { |
||||
|
$query->where([["sign_time", "<=", $end]]); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
public function contract(){ |
||||
|
return $this->hasOne(Contract::class, 'id', 'contract_id')->joinType('left')->withField('contract_name,id')->bind(['contract_id_name'=>'contract_name']); |
||||
|
} |
||||
|
|
||||
|
public function personnel(){ |
||||
|
return $this->hasOne(Personnel::class, 'id', 'personnel_id')->joinType('left')->withField('name,id')->bind(['personnel_id_name'=>'name']); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,111 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Niucloud-admin 企业快速开发的多应用管理平台 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 官方网址:https://www.niucloud.com |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | niucloud团队 版权所有 开源版本可自由商用 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: Niucloud Team |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
namespace app\service\admin\contract_sign; |
||||
|
|
||||
|
use app\model\contract_sign\ContractSign; |
||||
|
use app\model\contract\Contract; |
||||
|
use app\model\personnel\Personnel; |
||||
|
|
||||
|
use core\base\BaseAdminService; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 合同关系服务层 |
||||
|
* Class ContractSignService |
||||
|
* @package app\service\admin\contract_sign |
||||
|
*/ |
||||
|
class ContractSignService extends BaseAdminService |
||||
|
{ |
||||
|
public function __construct() |
||||
|
{ |
||||
|
parent::__construct(); |
||||
|
$this->model = new ContractSign(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取合同关系列表 |
||||
|
* @param array $where |
||||
|
* @return array |
||||
|
*/ |
||||
|
public function getPage(array $where = []) |
||||
|
{ |
||||
|
$field = 'id,contract_id,personnel_id,sign_file,status,created_at,sign_time,updated_at,deleted_at'; |
||||
|
$order = 'id desc'; |
||||
|
|
||||
|
$search_model = $this->model->withSearch(["status","created_at","sign_time"], $where)->with(['contract','personnel'])->field($field)->order($order); |
||||
|
$list = $this->pageQuery($search_model); |
||||
|
return $list; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取合同关系信息 |
||||
|
* @param int $id |
||||
|
* @return array |
||||
|
*/ |
||||
|
public function getInfo(int $id) |
||||
|
{ |
||||
|
$field = 'id,contract_id,personnel_id,sign_file,status,created_at,sign_time,updated_at,deleted_at'; |
||||
|
|
||||
|
$info = $this->model->field($field)->where([['id', "=", $id]])->with(['contract','personnel'])->findOrEmpty()->toArray(); |
||||
|
return $info; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 添加合同关系 |
||||
|
* @param array $data |
||||
|
* @return mixed |
||||
|
*/ |
||||
|
public function add(array $data) |
||||
|
{ |
||||
|
$res = $this->model->create($data); |
||||
|
return $res->id; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 合同关系编辑 |
||||
|
* @param int $id |
||||
|
* @param array $data |
||||
|
* @return bool |
||||
|
*/ |
||||
|
public function edit(int $id, array $data) |
||||
|
{ |
||||
|
|
||||
|
$this->model->where([['id', '=', $id]])->update($data); |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除合同关系 |
||||
|
* @param int $id |
||||
|
* @return bool |
||||
|
*/ |
||||
|
public function del(int $id) |
||||
|
{ |
||||
|
$model = $this->model->where([['id', '=', $id]])->find(); |
||||
|
$res = $model->delete(); |
||||
|
return $res; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public function getContractAll(){ |
||||
|
$contractModel = new Contract(); |
||||
|
return $contractModel->select()->toArray(); |
||||
|
} |
||||
|
|
||||
|
public function getPersonnelAll(){ |
||||
|
$personnelModel = new Personnel(); |
||||
|
return $personnelModel->select()->toArray(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,37 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Niucloud-admin 企业快速开发的多应用管理平台 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 官方网址:https://www.niucloud.com |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | niucloud团队 版权所有 开源版本可自由商用 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: Niucloud Team |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
namespace app\validate\contract_sign; |
||||
|
use core\base\BaseValidate; |
||||
|
/** |
||||
|
* 合同关系验证器 |
||||
|
* Class ContractSign |
||||
|
* @package addon\app\validate\contract_sign |
||||
|
*/ |
||||
|
class ContractSign extends BaseValidate |
||||
|
{ |
||||
|
|
||||
|
protected $rule = [ |
||||
|
'contract_id' => 'require', |
||||
|
'personnel_id' => 'require', |
||||
|
]; |
||||
|
|
||||
|
protected $message = [ |
||||
|
'contract_id.require' => ['common_validate.require', ['contract_id']], |
||||
|
'personnel_id.require' => ['common_validate.require', ['personnel_id']], |
||||
|
]; |
||||
|
|
||||
|
protected $scene = [ |
||||
|
"add" => ['contract_id', 'personnel_id'], |
||||
|
"edit" => ['contract_id', 'personnel_id'] |
||||
|
]; |
||||
|
|
||||
|
} |
||||
Loading…
Reference in new issue