于宏哲PHP 9 months ago
parent
commit
6a863f059d
  1. 6
      admin/src/app/api/customer_resources.ts
  2. 6
      admin/src/app/api/personnel.ts
  3. 60
      admin/src/app/views/customer_resources/customer_resources.vue
  4. 61
      admin/src/app/views/personnel/personnel.vue
  5. 6
      niucloud/app/adminapi/controller/customer_resources/CustomerResources.php
  6. 11
      niucloud/app/adminapi/controller/personnel/Personnel.php
  7. 11
      niucloud/app/adminapi/controller/upload/Upload.php
  8. 2
      niucloud/app/adminapi/route/customer_resources.php
  9. 4
      niucloud/app/adminapi/route/personnel.php
  10. 4
      niucloud/app/adminapi/route/sys.php
  11. 19
      niucloud/app/common.php
  12. 22
      niucloud/app/model/personnel/Personnel.php
  13. 83
      niucloud/app/service/admin/customer_resources/CustomerResourcesService.php
  14. 60
      niucloud/app/service/admin/personnel/PersonnelService.php
  15. 9
      niucloud/app/service/admin/upload/UploadService.php
  16. 4
      niucloud/app/service/core/contract_sign/ContractSign.php

6
admin/src/app/api/customer_resources.ts

@ -88,3 +88,9 @@ export function getStudentCoursesList(params: Record<string, any>) {
export function getOrderTableList(params: Record<string, any>) {
return request.get('customer_resources/order_table', { params })
}
export function toLeadInto(params: Record<string, any>) {
return request.post(`customer_resources/to_lead_into`, params, { showErrorMessage: true, showSuccessMessage: true })
}

6
admin/src/app/api/personnel.ts

@ -56,4 +56,10 @@ export function deletePersonnel(id: number) {
})
}
export function toLeadInto(params: Record<string, any>) {
return request.post(`personnel/to_lead_into`, params, { showErrorMessage: true, showSuccessMessage: true })
}
// USER_CODE_END -- personnel

60
admin/src/app/views/customer_resources/customer_resources.vue

@ -64,6 +64,12 @@
<el-form-item>
<el-button type="primary" @click="loadCustomerResourcesList()">{{ t('search') }}</el-button>
<el-button @click="resetForm(searchFormRef)">{{ t('reset') }}</el-button>
<el-button @click="DownloadExcel">下载导入模板</el-button>
<el-upload v-bind="upload" style="margin-left: 10px;">
<el-button type="primary">导入</el-button>
</el-upload>
</el-form-item>
</el-form>
</el-card>
@ -226,9 +232,9 @@
import { reactive, ref, watch } from 'vue'
import { t } from '@/lang'
import { useDictionary } from '@/app/api/dict'
import { getCustomerResourcesList, deleteCustomerResources, getWithPersonnelList, getWithCampusList } from '@/app/api/customer_resources'
import { img } from '@/utils/common'
import { ElMessageBox, FormInstance } from 'element-plus'
import { getCustomerResourcesList, deleteCustomerResources, getWithPersonnelList, getWithCampusList,toLeadInto } from '@/app/api/customer_resources'
import { img,getToken } from '@/utils/common'
import { ElMessageBox, FormInstance ,UploadFile, ElMessage } from 'element-plus'
import Edit from '@/app/views/customer_resources/components/customer-resources-edit.vue'
import Fp from '@/app/views/customer_resources/components/fp.vue'
import Order from '@/app/views/order_table/components/order-table-edit.vue'
@ -244,6 +250,54 @@
const pageName = route.meta.title;
const router = useRouter()
const DownloadExcel = () => {
const link = document.createElement('a');
link.href = 'https://api.hnhbty.cn/upload/template/资源导入模板.xlsx'; //
link.download = '资源导入模板.xlsx';
link.click();
}
const prop = defineProps({
modelValue: {
type: String,
default: '',
},
api: {
type: String,
default: 'sys/document_lead/document',
},
})
const upload: Record<string, any> = {
action: `${import.meta.env.VITE_APP_BASE_URL}/${prop.api}`,
showFileList: false,
headers: {},
accept: '.xls,.xlsx',
onSuccess: (response: any, uploadFile: UploadFile) => {
if (response.code != undefined && response.code != 1) {
ElMessage({ message: response.msg, type: 'error' })
return
}
Import(response.data.url);
},
}
upload.headers[import.meta.env.VITE_REQUEST_HEADER_TOKEN_KEY] = getToken()
const Import = async(url) => {
customerResourcesTable.loading = true
toLeadInto({url:url}).then(res => {
customerResourcesTable.loading = false
loadCustomerResourcesList();
}).catch(() => {
customerResourcesTable.loading = false
})
}
let customerResourcesTable = reactive({
page: 1,
limit: 10,

61
admin/src/app/views/personnel/personnel.vue

@ -109,6 +109,13 @@
<el-button @click="resetForm(searchFormRef)">{{
t('reset')
}}</el-button>
<el-button @click="DownloadExcel">下载导入模板</el-button>
<el-upload v-bind="upload" style="margin-left: 10px;">
<el-button type="primary">导入</el-button>
</el-upload>
</el-form-item>
</el-form>
</el-card>
@ -255,15 +262,65 @@
import { reactive, ref, watch } from 'vue'
import { t } from '@/lang'
import { useDictionary } from '@/app/api/dict'
import { getPersonnelList, deletePersonnel } from '@/app/api/personnel'
import { img } from '@/utils/common'
import { getPersonnelList, deletePersonnel,toLeadInto } from '@/app/api/personnel'
import { ElMessageBox, FormInstance } from 'element-plus'
import Edit from '@/app/views/personnel/components/personnel-edit.vue'
import Role from '@/app/views/campus_person_role/components/campus-person-role-edit.vue'
import { useRoute } from 'vue-router'
import { UploadFile, ElMessage } from 'element-plus'
import { img,getToken } from '@/utils/common'
const route = useRoute()
const pageName = route.meta.title
const DownloadExcel = () => {
const link = document.createElement('a');
link.href = 'https://api.hnhbty.cn/upload/template/人员导入模板.xlsx'; //
link.download = '人员导入模板.xlsx';
link.click();
}
const prop = defineProps({
modelValue: {
type: String,
default: '',
},
api: {
type: String,
default: 'sys/document_lead/document',
},
})
const upload: Record<string, any> = {
action: `${import.meta.env.VITE_APP_BASE_URL}/${prop.api}`,
showFileList: false,
headers: {},
accept: '.xls,.xlsx',
onSuccess: (response: any, uploadFile: UploadFile) => {
if (response.code != undefined && response.code != 1) {
ElMessage({ message: response.msg, type: 'error' })
return
}
Import(response.data.url);
},
}
upload.headers[import.meta.env.VITE_REQUEST_HEADER_TOKEN_KEY] = getToken()
const Import = async(url) => {
personnelTable.loading = true
toLeadInto({url:url}).then(res => {
personnelTable.loading = false
loadPersonnelList();
}).catch(() => {
personnelTable.loading = false
})
}
let personnelTable = reactive({
page: 1,
limit: 10,

6
niucloud/app/adminapi/controller/customer_resources/CustomerResources.php

@ -225,5 +225,11 @@ class CustomerResources extends BaseAdminController
return success((new CustomerResourcesService())->order_table($data));
}
public function to_lead_into(){
$data = $this->request->post();
return (new CustomerResourcesService())->to_lead_into($data);
}
}

11
niucloud/app/adminapi/controller/personnel/Personnel.php

@ -73,14 +73,14 @@ class Personnel extends BaseAdminController
["approval_config_id", 0], // 审批配置ID
]);
$this->validate($data, 'app\validate\personnel\Personnel.add');
// 检查是否使用审批流程
if ($data['use_approval'] && $data['approval_config_id'] > 0) {
// 使用审批流程
$approvalService = new \app\service\school_approval\SchoolApprovalProcessService();
$processId = $approvalService->createPersonnelApproval(
$data,
$this->request->uid(),
$data,
$this->request->uid(),
$data['approval_config_id']
);
return success('APPROVAL_CREATED_SUCCESS', ['process_id' => $processId]);
@ -140,4 +140,9 @@ class Personnel extends BaseAdminController
}
public function to_lead_into(){
$data = $this->request->post();
return (new PersonnelService())->to_lead_into($data);
}
}

11
niucloud/app/adminapi/controller/upload/Upload.php

@ -47,6 +47,17 @@ class Upload extends BaseAdminController
return success($upload_service->document($data['file'], $type));
}
public function document_lead($type)
{
$data = $this->request->params([
['file', 'file'],
]);
$upload_service = new UploadService();
return success($upload_service->document_lead($data['file'], $type));
}
/**
* 视频上传
* @return Response

2
niucloud/app/adminapi/route/customer_resources.php

@ -52,6 +52,8 @@ Route::group('customer_resources', function () {
Route::get('student_courses','customer_resources.CustomerResources/student_courses');
Route::get('order_table','customer_resources.CustomerResources/order_table');
Route::post('to_lead_into', 'customer_resources.CustomerResources/to_lead_into');
})->middleware([
AdminCheckToken::class,
AdminCheckRole::class,

4
niucloud/app/adminapi/route/personnel.php

@ -30,7 +30,9 @@ Route::group('personnel', function () {
Route::delete('personnel/:id', 'personnel.Personnel/del');
//获取审批配置列表
Route::get('personnel/approval-configs', 'personnel.Personnel/getApprovalConfigs');
Route::post('to_lead_into', 'personnel.Personnel/to_lead_into');
})->middleware([
AdminCheckToken::class,
AdminCheckRole::class,

4
niucloud/app/adminapi/route/sys.php

@ -325,6 +325,10 @@ Route::group('sys', function() {
Route::post('video', 'upload.Upload/video');
//附件上传
Route::post('document/:type', 'upload.Upload/document');
Route::post('document_lead/:type', 'upload.Upload/document_lead');
//附件列表
Route::get('attachment', 'sys.Attachment/lists');
//附件列表

19
niucloud/app/common.php

@ -1243,6 +1243,25 @@ function get_dict_value($key, $value)
}
function get_dict_name($key, $value)
{
$dict = new \app\model\dict\Dict();
$field = 'id,name,key,dictionary,memo,create_time,update_time';
$info = $dict->field($field)->where([['key', '=', $key]])->findOrEmpty()->toArray();
if ($info['dictionary'] == null) {
$info['dictionary'] = [];
}
$map = [];
foreach ($info['dictionary'] as $item) {
$map[$item['name']] = $item['value'];
}
return $map[$value] ?? '';
}
//$date = 年月 $campus_person_role_id 人员角色表id
//$field complete_num 完成数量 expire_num 到期数量 renew_num 续费数量 resource_num 分配的资源数量 visit_num 到访数量
//$num 增加数量 默认1

22
niucloud/app/model/personnel/Personnel.php

@ -47,7 +47,7 @@ class Personnel extends BaseModel
* 定义软删除标记字段.
* @var string
*/
protected $deleteTime = 'delete_time';
protected $deleteTime = 'deleted_at';
/**
* 定义软删除字段的默认值.
@ -66,7 +66,7 @@ class Personnel extends BaseModel
$query->where("name", "like", "%".$value."%");
}
}
/**
* 搜索器:人力资源-人员性别
* @param $value
@ -78,7 +78,7 @@ class Personnel extends BaseModel
$query->where("gender", $value);
}
}
/**
* 搜索器:人力资源-人员电话
* @param $value
@ -90,7 +90,7 @@ class Personnel extends BaseModel
$query->where("phone", $value);
}
}
/**
* 搜索器:人力资源-人员家庭住址
* @param $value
@ -102,7 +102,7 @@ class Personnel extends BaseModel
$query->where("address", $value);
}
}
/**
* 搜索器:人力资源-人员学历
* @param $value
@ -114,7 +114,7 @@ class Personnel extends BaseModel
$query->where("education", $value);
}
}
/**
* 搜索器:人力资源-人员员工编号
* @param $value
@ -126,7 +126,7 @@ class Personnel extends BaseModel
$query->where("employee_number", $value);
}
}
/**
* 搜索器:人力资源-人员员工状态
* @param $value
@ -138,7 +138,7 @@ class Personnel extends BaseModel
$query->where("status", $value);
}
}
/**
* 搜索器:人力资源-人员创建时间
* @param $value
@ -150,8 +150,8 @@ class Personnel extends BaseModel
$query->where("create_time", $value);
}
}
public function sys_user()
{
@ -160,5 +160,5 @@ class Personnel extends BaseModel
}

83
niucloud/app/service/admin/customer_resources/CustomerResourcesService.php

@ -27,6 +27,7 @@ use app\model\six_speed_modification_log\SixSpeedModificationLog;
use app\model\student_courses\StudentCourses;
use app\service\admin\member\MemberLabelService;
use core\base\BaseAdminService;
use PhpOffice\PhpSpreadsheet\IOFactory;
use think\facade\Event;
@ -229,10 +230,10 @@ class CustomerResourcesService extends BaseAdminService
public function edit(int $id, array $data)
{
$personnel = new Personnel();
// $data['consultant'] = $personnel->where(['sys_user_id' => $this->uid])->value("id");
// if(!$data['consultant']){
// return fail("操作失败");
// }
$data['consultant'] = $personnel->where(['sys_user_id' => $this->uid])->value("id");
if(!$data['consultant']){
return fail("操作失败");
}
if ($this->model->where([
['phone_number', '=', $data['phone_number']],
@ -600,4 +601,78 @@ class CustomerResourcesService extends BaseAdminService
}
}
public function to_lead_into(array $data)
{
$filePath = public_path() . $data['url'];
$personnel = new Personnel();
$campusModel = new Campus();
// $consultant = $personnel->where(['sys_user_id' => $this->uid])->value("id");
// if(!$consultant){
// return fail("操作失败");
// }
$consultant = 3;
try {
$spreadsheet = IOFactory::load($filePath);
$worksheet = $spreadsheet->getActiveSheet();
$highestRow = $worksheet->getHighestRow();
$list = [];
// 遍历每一行
foreach ($worksheet->getRowIterator() as $rowIndex => $row) {
if ($rowIndex == 1) {
// 跳过第一行(表头)和最后一行
continue;
}
$cellIterator = $row->getCellIterator();
$cellIterator->setIterateOnlyExistingCells(false);
$data = [];
foreach ($cellIterator as $cell) {
$value = $cell->getValue(); // 获取每个单元格的值
if ($value instanceof \PhpOffice\PhpSpreadsheet\RichText\RichText) {
$value = $value->getPlainText();
}
$data[] = $value;
}
$list[] = $data;
}
$inserAll = [];
// $status = ['已禁用' => 0,'待审核'=>1,'已审核' => 2];
// $is_sys_user = ['是' => 1,'否'=>0];
foreach ($list as $key => $item) {
$source_channel = get_dict_name('source',$item[1]);
$source = get_dict_name('SourceChannel',$item[2]);
$gender = get_dict_name('zy_sex',$item[4]);
$purchasing_power = get_dict_name('customer_purchasing_power',$item[7]);
$cognitive_idea = get_dict_name('cognitive_concept',$item[8]);
$campus = $campusModel->where(['campus_name' => $item[0]])->value('id');
$inserAll[] = [
'campus' => $campus,
'source_channel' => $source_channel,
'source' => $source,
'name' =>$item[3],
'gender' =>$gender,
'phone_number' => $item[5],
'demand' => $item[6],
'purchasing_power' =>$purchasing_power,
'cognitive_idea' => $cognitive_idea,
'consultant' => $consultant,
'create_year_month' => date("Y-m"),
'create_date' => date("Y-m-d")
];
}
$this->model->insertAll($inserAll);
return success("导入成功");
} catch (\PhpOffice\PhpSpreadsheet\Reader\Exception $e) {
return fail($e->getMessage());
}
}
}

60
niucloud/app/service/admin/personnel/PersonnelService.php

@ -19,6 +19,7 @@ use app\model\personnel\PersonnelInfo;
use app\model\sys\SysUser;
use app\service\admin\user\UserService;
use core\base\BaseAdminService;
use PhpOffice\PhpSpreadsheet\IOFactory;
use think\facade\Db;
@ -42,7 +43,7 @@ class PersonnelService extends BaseAdminService
*/
public function getPage(array $where = [])
{
$field = 'id,name,head_img,gender,birthday,phone,address,native_place,education,profile,emergency_contact_phone,id_card_front,id_card_back,employee_number,status,is_sys_user,sys_user_id,create_time,update_time,delete_time';
$field = 'id,name,head_img,gender,birthday,phone,address,native_place,education,profile,emergency_contact_phone,id_card_front,id_card_back,employee_number,status,is_sys_user,sys_user_id,create_time,update_time,deleted_at';
$order = 'create_time desc';
$search_model = $this->model->withSearch(["name", "gender", "phone", "address", "education", "employee_number", "status", "create_time"], $where)->field($field)->order($order);
@ -80,7 +81,7 @@ class PersonnelService extends BaseAdminService
*/
public function getInfo(int $id)
{
$field = 'id,name,gender,head_img,birthday,phone,address,native_place,education,profile,emergency_contact_phone,id_card_front,id_card_back,employee_number,status,is_sys_user,sys_user_id,create_time,update_time,delete_time';
$field = 'id,name,gender,head_img,birthday,phone,address,native_place,education,profile,emergency_contact_phone,id_card_front,id_card_back,employee_number,status,is_sys_user,sys_user_id,create_time,update_time,deleted_at';
$info = $this->model->field($field)->where([['id', "=", $id]])->findOrEmpty()->toArray();
$info['gender'] = strval($info['gender']);
@ -188,4 +189,59 @@ class PersonnelService extends BaseAdminService
}
public function to_lead_into(array $data)
{
$filePath = public_path() . $data['url'];
try {
$spreadsheet = IOFactory::load($filePath);
$worksheet = $spreadsheet->getActiveSheet();
$highestRow = $worksheet->getHighestRow();
$list = [];
// 遍历每一行
foreach ($worksheet->getRowIterator() as $rowIndex => $row) {
if ($rowIndex == 1) {
// 跳过第一行(表头)和最后一行
continue;
}
$cellIterator = $row->getCellIterator();
$cellIterator->setIterateOnlyExistingCells(false);
$data = [];
foreach ($cellIterator as $cell) {
$value = $cell->getValue(); // 获取每个单元格的值
if ($value instanceof \PhpOffice\PhpSpreadsheet\RichText\RichText) {
$value = $value->getPlainText();
}
$data[] = $value;
}
$list[] = $data;
}
$inserAll = [];
$status = ['已禁用' => 0,'待审核'=>1,'已审核' => 2];
$is_sys_user = ['是' => 1,'否'=>0];
foreach ($list as $key => $item) {
$inserAll[] = [
'name' => $item[0],
'phone' => $item[1],
'status' =>$status[$item[2]],
'is_sys_user' =>$is_sys_user[$item[3]],
'create_time' => date("Y-m-d H:i:s")
];
}
$this->model->insertAll($inserAll);
return success("导入成功");
} catch (\PhpOffice\PhpSpreadsheet\Reader\Exception $e) {
return fail($e->getMessage());
}
}
}

9
niucloud/app/service/admin/upload/UploadService.php

@ -62,6 +62,15 @@ class UploadService extends BaseAdminService
return $core_upload_service->document($file, $type, $dir, StorageDict::TENCENT);
}
public function document_lead($file, string $type){
$dir = $this->root_path.'/document/'.$type.'/'.date('Ym').'/'.date('d');
$core_upload_service = new CoreUploadService();
return $core_upload_service->document($file, $type, $dir, StorageDict::LOCAL);
}
/**
* 附件库上传视频
* @param $file

4
niucloud/app/service/core/contract_sign/ContractSign.php

@ -44,8 +44,8 @@ class ContractSign extends BaseCoreService
$templateProcessor->setImageValue($placeholder, [
'path' => $tempImagePath,
'width' => 120,
'height' => 50,
// 'width' => 120,
// 'height' => 50,
'ratio' => false,
]);

Loading…
Cancel
Save