linwu %!s(int64=2) %!d(string=hai) anos
pai
achega
4b7a780397

+ 3 - 1
app/admin/controller/Comjobs.php

@@ -9,6 +9,7 @@ use app\common\model\Comjobs as ComjobsModel;
 use app\common\model\ComjobsCate as ComjobsCateModel;
 use app\common\model\ComjobsLog as ComjobsLogModel;
 use app\common\model\ComjobsStar as ComjobsStarModel;
+use app\common\model\ComjobsReport as ComjobsReportModel;
 
 use app\common\model\ComjobsShare as ComjobsShareModel;
 
@@ -263,7 +264,8 @@ class Comjobs extends BaseController
         $idarr = input('idarr/a');
         ComjobsLogModel::whereIn('comjobsid', $idarr)->delete();
         ComjobsStarModel::whereIn('comjobsid', $idarr)->delete();
-        $result = Db::name('comjobs')->whereIn('id', $idarr)->update(['deletetime' => time()]);
+        ComjobsReportModel::whereIn('comjobsid', $idarr)->delete();
+        $result = ComjobsModel::destroy($idarr,true);
 
         if ($result) {
             exit(json_encode([

+ 0 - 3
app/admin/view/comjobs/comjobslist.html

@@ -124,10 +124,7 @@
 					{ field: 'agegroup', title: '招工年龄', edit: 'text', width: 120 },
 					{ field: 'enddate', title: '截止日期', edit: 'text', width: 120 },
 					{ field: 'wtype_text', title: '薪资类型', align: 'center', width: 100 },
-					
-					{ field: 'bwagall', title: '基本工资', edit: 'text' },
 					{ field: 'zwagall', title: '综合月薪', edit: 'text' },
-					{ field: 'fwagall', title: '返费政策', edit: 'text' },
 					{ field: 'telephone', title: '咨询电话', edit: 'text' },
 					{ field: 'remark', title: '补充说明', minWidth: 240, edit: 'text' },
 					{ field: 'status_text', title: '状态', width: 80, align: 'center' },

+ 2 - 0
app/common.php

@@ -543,6 +543,8 @@ function importExecl($file = '', $cell = [], $crop = 0, $sheet = 0)
                 //$cellValue = $currSheet->getCell($cellId)->getCalculatedValue();  #获取公式计算的值
                 if ($cellValue instanceof PHPExcel_RichText) {   //富文本转换字符串
                     $cellValue = $cellValue->__toString();
+                } else {
+                    $cellValue = (string)$cellValue;
                 }
                 if (!empty($cell[$_column])) {
                     $data[$_row][$cell[$_column]] = $cellValue;

+ 25 - 0
app/common/service/BaseService.php

@@ -0,0 +1,25 @@
+<?php
+
+namespace app\common\service;
+
+
+class BaseService
+{
+
+    /**
+     * 返回成功
+     */
+    protected function success($msg, $data = [])
+    {
+        return ['code' => 1, 'msg' => $msg, 'data' => $data];
+    }
+
+    /**
+     * 返回错误
+     */
+    protected function error($msg, $data = [])
+    {
+        return ['code' => 0, 'msg' => $msg, 'data' => $data];
+    }
+
+}

+ 103 - 0
app/common/service/ComjobsService.php

@@ -0,0 +1,103 @@
+<?php
+
+namespace app\common\service;
+
+
+use app\common\model\RensheCode;
+use app\common\model\Comjobs as ComjobsModel;
+use app\common\model\ComjobsCate as ComjobsCateModel;
+
+class ComjobsService extends BaseService
+{
+
+    public function importComjobs($file_url, $worker_id)
+    {
+        $data       = ['title', 'cate', 'address', 'community', 'agegroup', 'enddate', 'comdetails', 'requirement', 'wtype', 'zwagall', 'telephone', 'remark', 'recruit_num', 'education'];
+        $list       = importExecl($file_url, $data, 1);
+        $data       = [];
+        $wtype      = ['按月' => 1, '按时' => 2, '按件' => 3, '按项目' => 4, '其他' => 5];
+        $rensheCode = RensheCode::select();
+        $renshe     = [];
+        foreach ($rensheCode as $v) {
+            $renshe[$v['type']][$v['name']] = $v['code'];
+        }
+        $cateList = ComjobsCateModel::column('id', 'title');
+
+        foreach ($list as $k => $v) {
+            $empty_check = [
+                'title'       => '标题',
+                'cate'        => '岗位',
+                'address'     => '地址',
+                'community'   => '社区',
+                'agegroup'    => '招工年龄',
+                'enddate'     => '截止日期',
+                'wtype'       => '结算类型',
+                'zwagall'     => '薪酬',
+                'telephone'   => '咨询电话',
+                'recruit_num' => '招聘人数',
+                'education'   => '最低学历',
+            ];
+            foreach ($empty_check as $key => $value) {
+                if (empty($v[$key])) {
+                    return $this->error('第' . ($k + 2) . '行的' . $value . '不能为空');
+                }
+            }
+
+            $item = [];
+            if (empty($cateList[$v['cate']])) {
+                return $this->error('第' . ($k + 2) . '行的岗位选择有误');
+            }
+            $item['cateid']   = $cateList[$v['cate']];
+            $item['title']    = $v['title'];
+            $item['province'] = '福建省';
+            $item['city']     = '泉州市';
+            $item['district'] = '晋江市';
+            $item['address']  = $v['address'];
+            if (empty($renshe['community'][$v['community']])) {
+                return $this->error('第' . ($k + 2) . '行的社区选择有误');
+            }
+            $item['community'] = $renshe['community'][$v['community']];
+            $item['agegroup']  = $v['agegroup'];
+            $enddate           = strtotime($v['enddate']);
+            if ($enddate <= 0) {
+                return $this->error('第' . ($k + 2) . '行的截止日期填写错误,格式2022-10-20');
+            }
+            $item['enddate'] = strtotime($v['enddate']);
+
+            $item['comdetails']  = $v['comdetails'];
+            $item['requirement'] = $v['requirement'];
+            if (empty($wtype[$v['wtype']])) {
+                return $this->error('第' . ($k + 2) . '行的结算类型选择有误');
+            }
+            $item['wtype']   = $wtype[$v['wtype']];
+            $item['zwagall'] = $item['bwagall'] = $v['zwagall'];
+            if (empty($renshe['education'][$v['education']])) {
+                return $this->error('第' . ($k + 2) . '行的最低学历选择有误');
+            }
+            $item['telephone'] = $v['telephone'];
+            $item['remark']    = $v['remark'];
+            if ($v['recruit_num'] < 1) {
+                return $this->error('第' . ($k + 2) . '行的招聘人数需要大于等于1');
+            }
+            $item['recruit_num']    = (int)$v['recruit_num'];
+            $item['education']      = $v['education'];
+            $item['is_worry']       = 0;
+            $item['picall']         = [];
+            $item['tags']           = [];
+            $item['emp_time']       = [];
+            $item['companydetails'] = '';
+            $item['video']          = '';
+            $item['priority']       = 0;
+            $item['status']         = 3;
+            $item['createtime']     = $item['updatetime'] = time();
+            $item['workerid']       = $worker_id;
+            $data[]                 = $item;
+        }
+
+        foreach ($data as $v) {
+            ComjobsModel::create($v);
+        }
+
+        return $this->success('导入成功');
+    }
+}

+ 28 - 0
app/worker/controller/Comjobs.php

@@ -3,6 +3,7 @@
 namespace app\worker\controller;
 
 use app\common\model\RensheCode;
+use app\common\service\ComjobsService;
 use app\worker\BaseController;
 use app\common\model\Param as ParamModel;
 use app\common\model\User as UserModel;
@@ -630,4 +631,31 @@ class Comjobs extends BaseController
         ]));
     }
 
+    public function importView()
+    {
+        return view('comjobs/importview');
+    }
+
+    public function import()
+    {
+        $workerid = $this->access_worker['id'];
+        $file_url = input('file_url/s', "");
+        if (!file_exists($file_url)) {
+            exit(json_encode([
+                'code' => 1,
+                'msg'  => "文件不存在",
+            ]));
+        }
+
+        $service = new ComjobsService();
+        $res = $service->importComjobs($file_url,$workerid);
+        if (empty($res['code'])) {
+            exit(json_encode([
+                'code' => 1,
+                'msg'  => $res['msg'],
+            ]));
+        }
+
+        exit(json_encode(['code'  => 0]));
+    }
 }

+ 10 - 3
app/worker/view/comjobs/comjobslist.html

@@ -66,6 +66,7 @@
 			<div style="padding-bottom: 10px;">
 				<button class="layui-btn layuiadmin-btn" data-type="batchdel">删除</button>
 				<button class="layui-btn layuiadmin-btn" data-type="add">发布普通招聘</button>
+				<button class="layui-btn layuiadmin-btn" data-type="import">批量导入</button>
 				<?php if($wtype ==2):?>
 					<button class="layui-btn layuiadmin-btn" data-type="add_wyp">发布悬赏聘</button>
 				<?php endif;?>
@@ -116,9 +117,7 @@
 						{ field: 'agegroup', title: '招工年龄',  width: 120 },
 						{ field: 'enddate', title: '截止日期', width: 120 },
 						{ field: 'wtype_text', title: '薪资类型', align: 'center', width: 100 },
-						{ field: 'bwagall', title: '基本工资'},
 						{ field: 'zwagall', title: '综合月薪'},
-						{ field: 'fwagall', title: '返费政策'},
 						{ field: 'telephone', title: '咨询电话', edit: 'text' },
 						{ field: 'remark', title: '补充说明', minWidth: 240},
 						{ field: 'recruitmentcate_text', title: '招聘类型', width: 100, align: 'center' },
@@ -220,7 +219,15 @@
 					layer.full(index);
 				});
 			},
-
+			import: function() {
+				var index = layer.open({
+					type: 2,
+					title: '添加悬赏聘',
+					content: 'importView.html',
+					maxmin: true,
+					area: ['750px', '300px']
+				});
+			},
 		};
 
 		table.on('tool(LAY-comjobs-comjobslist-table)', function(obj) {

+ 68 - 0
app/worker/view/comjobs/importview.html

@@ -0,0 +1,68 @@
+<div class="layui-fluid">
+	<div class="layui-row layui-col-space15">
+		<div class="layui-col-md12">
+			<div class="layui-card">
+				<div class="layui-card-header">导入</div>
+				<div class="layui-card-body" pad15>
+					<div class="layui-form layui-form-pane" lay-filter="LAY-comjobs-comjobsform-edit">
+						<div class="layui-form-item">
+							<label class="layui-form-label">文件名</label>
+							<div class="layui-input-block">
+								<input type="text" id="file_name" autocomplete="off" readonly placeholder="请点击上传文件按钮" class="layui-input">
+							</div>
+						</div>
+						<input type="hidden" name="file_url" value="" id="file_url">
+						<div class="layui-form-item">
+							<div class="layui-input-block">
+								<a href="/static/exl/comjobs_import.xlsx" target="_blank">
+									<button type="button" class="layui-btn layui-btn-normal" id="test3">下载模板</button>
+								</a>
+								<button type="button" class="layui-btn layui-btn-normal" id="upload"><i class="layui-icon"></i>上传文件</button>
+								<input type="button" lay-submit lay-filter="LAY-comjobs-comjobsimport-edit-submit" value="确认提交" class="layui-btn">
+							</div>
+						</div>
+					</div>
+
+				</div>
+			</div>
+		</div>
+	</div>
+</div>
+
+
+<script>
+	layui.config({
+		base: '/static/echoui/' //静态资源所在路径
+	}).extend({
+		index: 'lib/index' //主入口模块
+	}).use(['index', 'form', 'upload'], function() {
+		var $ = layui.$,setter = layui.setter, admin = layui.admin, upload = layui.upload,form = layui.form;
+		form.render();
+
+		form.on('submit(LAY-comjobs-comjobsimport-edit-submit)', function(obj) {
+			var index = parent.layer.getFrameIndex(window.name);
+			admin.req({
+				url: setter.baseWorkerUrl + 'comjobs/import',
+				data: obj.field,
+				type: 'post',
+				done: function(res) {
+					layer.msg("导入成功", {
+						icon: 1
+					});
+					parent.layui.table.reload('LAY-comjobs-comjobslist-table'); //重载表格
+					parent.layer.close(index);
+				}
+			});
+		});
+
+		upload.render({
+			elem: '#upload'
+			,url: setter.baseAdminUrl + 'attachment/tplFieldFile' //此处配置你自己的上传接口即可
+			,accept: 'file' //普通文件
+			,done: function(res){
+				$('#file_url').val(res.data.path);
+				$('#file_name').val(res.data.title);
+			}
+		});
+	});
+</script>

BIN=BIN
public/static/exl/comjobs_import.xlsx