diff --git a/app/article/view/index/list.html b/app/article/view/index/list.html index bb06746..a3b3e3d 100644 --- a/app/article/view/index/list.html +++ b/app/article/view/index/list.html @@ -118,7 +118,7 @@ icon: 3, title: '提示' }, function(index) { - let callback = function (e) { + let callback = function (res) { layer.msg(res.msg); if (res.code == 0) { obj.del(); diff --git a/app/common.php b/app/common.php index 9c910c0..7c89485 100644 --- a/app/common.php +++ b/app/common.php @@ -77,6 +77,19 @@ function isTemplate($url='') return $isTemplate; } +//是否是某数据权限,count>1即有权限 +function isAuth($uid,$name) +{ + if($uid == 1){ + return 1; + } + $map = []; + $map[] = ['name', '=', $name]; + $map[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',uids)")]; + $count = Db::name('DataAuth')->where($map)->count(); + return $count; +} + //获取服务器信息 function get_system_info($key) { diff --git a/app/contract/common.php b/app/contract/common.php new file mode 100644 index 0000000..276b76c --- /dev/null +++ b/app/contract/common.php @@ -0,0 +1,60 @@ +where($map)->count(); + return $count; +} +//读取分类列表 +function contract_cate() +{ + $cate = Db::name('ContractCate')->where(['status' => 1])->order('id desc')->select()->toArray(); + return $cate; +} + +//读取签约主体 +function contract_subject() +{ + $subject = Db::name('InvoiceSubject')->where(['status' => 1])->order('id desc')->select()->toArray(); + return $subject; +} + +//读取签约主体 +function to_log($uid,$new,$old) +{ + $log_data = []; + $key_array = ['id', 'create_time', 'update_time', 'sign_did']; + foreach ($new as $key => $value) { + if (!in_array($key, $key_array)) { + if(isset($old[$key]) && ($old[$key]!=$value)){ + $log_data[] = array( + 'field' => $key, + 'contract_id' => $new['id'], + 'admin_id' => $uid, + 'old_content' => $old[$key], + 'new_content' => $value, + 'create_time' => time(), + ); + } + } + } + Db::name('ContractLog')->strict(false)->field(true)->insertAll($log_data); +} \ No newline at end of file diff --git a/app/contract/config/install.gouguoa b/app/contract/config/install.gouguoa new file mode 100644 index 0000000..8809f36 --- /dev/null +++ b/app/contract/config/install.gouguoa @@ -0,0 +1 @@ +勾股OA模块安装鉴定文件,请勿删除!!!!!此次模块标识为:contract \ No newline at end of file diff --git a/app/contract/config/install.sql b/app/contract/config/install.sql new file mode 100644 index 0000000..c43bd6e --- /dev/null +++ b/app/contract/config/install.sql @@ -0,0 +1,123 @@ + +-- ---------------------------- +-- Table structure for oa_contract_cate +-- ---------------------------- +DROP TABLE IF EXISTS `oa_contract_cate`; +CREATE TABLE `oa_contract_cate` ( + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `title` varchar(100) NOT NULL DEFAULT '' COMMENT '合同类别名称', + `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态:-1删除 0禁用 1启用', + `create_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间', + `update_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COMMENT = '合同类别'; + +-- ---------------------------- +-- Records of oa_contract_cate +-- ---------------------------- +INSERT INTO `oa_contract_cate` VALUES (1, '销售合同', 1, 1637987189, 0); +INSERT INTO `oa_contract_cate` VALUES (2, '采购合同', 1, 1637987199, 0); +INSERT INTO `oa_contract_cate` VALUES (3, '租赁合同', 1, 1637987199, 0); +INSERT INTO `oa_contract_cate` VALUES (4, '委托协议', 1, 1637987199, 0); +INSERT INTO `oa_contract_cate` VALUES (5, '代理协议', 1, 1637987199, 0); +INSERT INTO `oa_contract_cate` VALUES (6, '其他合同', 1, 1637987199, 0); + +-- ---------------------------- +-- Table structure for oa_contract +-- ---------------------------- +DROP TABLE IF EXISTS `oa_contract`; +CREATE TABLE `oa_contract` ( + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `pid` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '父协议id', + `code` varchar(255) NOT NULL DEFAULT '' COMMENT '合同编号', + `name` varchar(255) NOT NULL DEFAULT '' COMMENT '合同名称', + `cate_id` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '分类id', + `type` tinyint(1) NOT NULL DEFAULT 0 COMMENT '合同性质:0未设置,1普通合同、2框架合同、3补充协议、4其他合同', + `subject_id` varchar(255) NOT NULL DEFAULT '' COMMENT '签约主体', + `customer_id` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '客户ID,预设数据', + `customer` varchar(255) NOT NULL DEFAULT '' COMMENT '客户名称', + `customer_name` varchar(255) NOT NULL DEFAULT '' COMMENT '客户代表', + `customer_mobile` varchar(255) NOT NULL DEFAULT '' COMMENT '客户电话', + `customer_address` varchar(255) NOT NULL DEFAULT '' COMMENT '客户地址', + `start_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '合同开始时间', + `end_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '合同结束时间', + `admin_id` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建人', + `prepared_uid` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '合同制定人', + `sign_uid` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '合同签订人', + `keeper_uid` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '合同保管人', + `share_ids` varchar(500) NOT NULL DEFAULT '' COMMENT '共享人员,如:1,2,3', + `sign_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '合同签订时间', + `sign_did` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '合同签订部门', + `cost` decimal(15, 2) NOT NULL DEFAULT 0.00 COMMENT '合同金额', + `is_tax` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否含税:0未含税,1含税', + `tax` decimal(15, 2) NOT NULL DEFAULT 0.00 COMMENT '税点', + `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '合同状态:0未设置,1已录入,2待审核,3已审核,4已中止,5已作废', + `check_uid` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '审核人', + `check_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '审核时间', + `check_remark` text NULL COMMENT '审核备注信息', + `stop_uid` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '中止人', + `stop_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '中止时间', + `stop_remark` text NULL COMMENT '中止备注信息', + `void_uid` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '作废人', + `void_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '作废时间', + `void_remark` text NULL COMMENT '作废备注信息', + `archive_status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '归档状态:0未归档,1已归档', + `archive_uid` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '归档人', + `archive_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '归档时间', + `remark` text NULL COMMENT '备注信息', + `create_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '添加时间', + `update_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '修改时间', + `delete_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1000 CHARACTER SET = utf8mb4 COMMENT = '合同表'; + +-- ---------------------------- +-- Table structure for oa_contract_file +-- ---------------------------- +DROP TABLE IF EXISTS `oa_contract_file`; +CREATE TABLE `oa_contract_file` ( + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `contract_id` int(11) UNSIGNED NOT NULL COMMENT '关联合同id', + `file_id` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '相关联附件id', + `admin_id` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建人', + `create_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间', + `update_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '修改时间', + `delete_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COMMENT = '合同附件关联表'; + +-- ---------------------------- +-- Table structure for oa_contract_log +-- ---------------------------- +DROP TABLE IF EXISTS `oa_contract_log`; +CREATE TABLE `oa_contract_log` ( + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `action` varchar(100) NOT NULL DEFAULT 'edit' COMMENT '动作:add,edit,del,check,upload', + `field` varchar(100) NOT NULL DEFAULT '' COMMENT '字段', + `contract_id` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '关联合同id', + `admin_id` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '操作人', + `old_content` text NULL COMMENT '修改前的内容', + `new_content` text NULL COMMENT '修改后的内容', + `remark` text NULL COMMENT '补充备注', + `create_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COMMENT = '合同操作记录表'; + + +-- ---------------------------- +-- Table structure for oa_data_auth +-- ---------------------------- +DROP TABLE IF EXISTS `oa_data_auth`; +CREATE TABLE `oa_data_auth` ( + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `title` varchar(255) NOT NULL DEFAULT '' COMMENT '权限名称', + `name` varchar(255) NOT NULL DEFAULT '' COMMENT '权限标识唯一,字母', + `desc` text NULL COMMENT '备注描述', + `module` varchar(255) NOT NULL DEFAULT '' COMMENT '所属模块,唯一,字母', + `uids` text NULL COMMENT '权限用户,1,2,3', + `create_time` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间', + `update_time` int(11) NOT NULL DEFAULT 0 COMMENT '更新时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COMMENT = '数据权限表'; + +INSERT INTO `oa_data_auth` VALUES ((SELECT MAX(id) +1 FROM `oa_data_auth` a), '合同管理员','contract_admin','拥有该权限的员工可以查看、编辑、审核、作废、中止所有合同。', 'contract', '', 1656143065, 0); \ No newline at end of file diff --git a/app/contract/controller/Api.php b/app/contract/controller/Api.php new file mode 100644 index 0000000..aeb160f --- /dev/null +++ b/app/contract/controller/Api.php @@ -0,0 +1,166 @@ +field('id,name,sign_uid,sign_time')->order('end_time asc')->where($where)->select()->toArray(); + if (!empty($list)) { + foreach ($list as $k => &$v) { + $v['sign_name'] = Db::name('Admin')->where('id',$v['sign_uid'])->value('name'); + $v['sign_time'] = date('Y-m-d', $v['sign_time']); + } + } + to_assign(0, '', $list); + } + + //添加附件 + public function add_file() + { + $param = get_params(); + $param['create_time'] = time(); + $param['admin_id'] = $this->uid; + $fid = Db::name('ContractFile')->strict(false)->field(true)->insertGetId($param); + if ($fid) { + $log_data = array( + 'field' => 'file', + 'action' => 'upload', + 'contract_id' => $param['contract_id'], + 'admin_id' => $param['admin_id'], + 'old_content' => '', + 'new_content' => $param['file_name'], + 'create_time' => time(), + ); + Db::name('ContractLog')->strict(false)->field(true)->insert($log_data); + return to_assign(0, '上传成功', $fid); + } + } + + //删除 + public function delete_file() + { + if (request()->isDelete()) { + $id = get_params("id"); + $data['id'] = $id; + $data['delete_time'] = time(); + if (Db::name('ContractFile')->update($data) !== false) { + $detail = Db::name('ContractFile')->where('id', $id)->find(); + $file_name = Db::name('File')->where('id', $detail['file_id'])->value('name'); + $log_data = array( + 'field' => 'file', + 'action' => 'delete', + 'contract_id' => $detail['contract_id'], + 'admin_id' => $this->uid, + 'new_content' => $file_name, + 'create_time' => time(), + ); + Db::name('ContractLog')->strict(false)->field(true)->insert($log_data); + return to_assign(0, "删除成功"); + } else { + return to_assign(1, "删除失败"); + } + } else { + return to_assign(1, "错误的请求"); + } + } + + //审核等操作 + public function check() + { + if (request()->isPost()) { + $params = get_params(); + if($params['status'] == 3){ + $params['check_uid'] = $this->uid; + $params['check_time'] = time(); + $params['check_remark'] = $params['mark']; + } + if($params['status'] == 4){ + $params['stop_uid'] = $this->uid; + $params['stop_time'] = time(); + $params['stop_remark'] = $params['mark']; + } + if($params['status'] == 5){ + $params['void_uid'] = $this->uid; + $params['void_time'] = time(); + $params['void_remark'] = $params['mark']; + } + $old = Db::name('Contract')->where('id', $params['id'])->find(); + if (Db::name('Contract')->strict(false)->update($params) !== false) { + $log_data = array( + 'field' => 'status', + 'contract_id' => $params['id'], + 'admin_id' => $this->uid, + 'new_content' => $params['status'], + 'old_content' => $old['status'], + 'create_time' => time(), + ); + Db::name('ContractLog')->strict(false)->field(true)->insert($log_data); + return to_assign(0, "操作成功"); + } else { + return to_assign(1, "操作失败"); + } + } else { + return to_assign(1, "错误的请求"); + } + } + + //归档等操作 + public function archive() + { + if (request()->isPost()) { + $params = get_params(); + $old = 1; + if($params['archive_status'] == 1){ + $params['archive_uid'] = $this->uid; + $params['archive_time'] = time(); + $old = 0; + } + $old = Db::name('Contract')->where('id', $params['id'])->find(); + if (Db::name('Contract')->strict(false)->update($params) !== false) { + $log_data = array( + 'field' => 'archive_status', + 'contract_id' => $params['id'], + 'admin_id' => $this->uid, + 'new_content' => $params['archive_status'], + 'old_content' => $old['archive_status'], + 'create_time' => time(), + ); + Db::name('ContractLog')->strict(false)->field(true)->insert($log_data); + return to_assign(0, "操作成功"); + } else { + return to_assign(1, "操作失败"); + } + } else { + return to_assign(1, "错误的请求"); + } + } + + //合同操作日志列表 + public function contract_log() + { + $param = get_params(); + $list = new ContractLog(); + $content = $list->contract_log($param); + return to_assign(0, '', $content); + } + +} diff --git a/app/contract/controller/Cate.php b/app/contract/controller/Cate.php new file mode 100644 index 0000000..9f707a3 --- /dev/null +++ b/app/contract/controller/Cate.php @@ -0,0 +1,102 @@ +isPost()) { + $param['update_time'] = time(); + $res = Db::name('DataAuth')->strict(false)->field(true)->update($param); + return to_assign(); + } else { + $detail = Db::name('DataAuth')->where('name','contract_admin')->find(); + $uids = Db::name('Admin')->where('id', 'in', $detail['uids'])->column('name'); + $detail['unames'] = implode(',', $uids); + View::assign('detail', $detail); + return view(); + } + } + + //类别 + public function cate() + { + if (request()->isAjax()) { + $cate = Db::name('ContractCate')->order('create_time asc')->select(); + return to_assign(0, '', $cate); + } else { + return view(); + } + } + //类别添加 + public function cate_add() + { + if (request()->isAjax()) { + $param = get_params(); + if (!empty($param['id']) && $param['id'] > 0) { + try { + validate(ContractCateCheck::class)->scene('edit')->check($param); + } catch (ValidateException $e) { + // 验证失败 输出错误信息 + return to_assign(1, $e->getError()); + } + $data['update_time'] = time(); + $res = Db::name('ContractCate')->strict(false)->field(true)->update($param); + if ($res) { + add_log('edit', $param['id'], $param); + } + return to_assign(); + } else { + try { + validate(ContractCateCheck::class)->scene('add')->check($param); + } catch (ValidateException $e) { + // 验证失败 输出错误信息 + return to_assign(1, $e->getError()); + } + $param['create_time'] = time(); + $insertId = Db::name('ContractCate')->strict(false)->field(true)->insertGetId($param); + if ($insertId) { + add_log('add', $insertId, $param); + } + return to_assign(); + } + } + } + + //类别设置 + public function cate_check() + { + $param = get_params(); + $res = Db::name('ContractCate')->strict(false)->field('id,status')->update($param); + if ($res) { + if($param['status'] == 0){ + add_log('disable', $param['id'], $param); + } + else if($param['status'] == 1){ + add_log('recovery', $param['id'], $param); + } + return to_assign(); + } + else{ + return to_assign(0, '操作失败'); + } + } + + +} diff --git a/app/contract/controller/Index.php b/app/contract/controller/Index.php new file mode 100644 index 0000000..666f523 --- /dev/null +++ b/app/contract/controller/Index.php @@ -0,0 +1,270 @@ +isAjax()) { + $param = get_params(); + $where = array(); + $whereOr = array(); + if (!empty($param['keywords'])) { + $where[] = ['a.id|a.name|c.title', 'like', '%' . $param['keywords'] . '%']; + } + if (!empty($param['cate_id'])) { + $where[] = ['a.cate_id', '=', $param['cate_id']]; + } + if (!empty($param['type'])) { + $where[] = ['a.type', '=', $param['type']]; + } + if (!empty($param['status'])) { + $where[] = ['a.status', '=', $param['status']]; + } + $where[] = ['a.delete_time', '=', 0]; + $where[] = ['a.archive_status', '=', 0]; + + $uid = $this->uid; + $auth = contract_auth($uid); + if($auth==0){ + $whereOr[] =['a.admin_id|a.prepared_uid|a.sign_uid|a.keeper_uid', '=', $uid]; + $whereOr[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',a.share_ids)")]; + } + + $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit']; + $content = ContractList::where($where) + ->where(function ($query) use($whereOr) { + $query->whereOr($whereOr); + }) + ->field('a.*,c.title as cate_title,d.title as sign_department') + ->alias('a') + ->join('contract_cate c', 'a.cate_id = c.id') + ->join('department d', 'a.sign_did = d.id','LEFT') + ->order('a.create_time desc') + ->paginate($rows, false, ['query' => $param]) + ->each(function ($item, $key) { + $item->keeper_name = Db::name('Admin')->where(['id' => $item->keeper_uid])->value('name'); + $item->sign_name = Db::name('Admin')->where(['id' => $item->sign_uid])->value('name'); + $item->sign_time = date('Y-m-d', $item->sign_time); + $item->interval_time = date('Y-m-d', $item->start_time) . ' 至 ' . date('Y-m-d', $item->end_time); + $item->type_name = ContractList::$Type[(int) $item->type]; + $item->status_name = ContractList::$Status[(int) $item->status]; + $item->chack_status_name = ContractList::$Status[(int) $item->CheckStatus]; + if($item->cost == 0){ + $item->cost = '-'; + } + }); + return table_assign(0, '', $content); + } else { + return view(); + } + } + + public function archive() + { + if (request()->isAjax()) { + $param = get_params(); + $where = array(); + $whereOr = array(); + if (!empty($param['keywords'])) { + $where[] = ['a.id|a.name|c.title', 'like', '%' . $param['keywords'] . '%']; + } + if (!empty($param['cate_id'])) { + $where[] = ['a.cate_id', '=', $param['cate_id']]; + } + if (!empty($param['cate_id'])) { + $where[] = ['a.cate_id', '=', $param['cate_id']]; + } + if (!empty($param['type'])) { + $where[] = ['a.type', '=', $param['type']]; + } + $where[] = ['a.delete_time', '=', 0]; + $where[] = ['a.archive_status', '=', 1]; + + $uid = $this->uid; + $auth = contract_auth($uid); + if($auth==0){ + $whereOr[] =['a.admin_id|a.prepared_uid|a.sign_uid|a.keeper_uid', '=', $uid]; + $whereOr[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',a.share_ids)")]; + } + + $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit']; + $content = ContractList::where($where) + ->where(function ($query) use($whereOr) { + $query->whereOr($whereOr); + }) + ->field('a.*,c.title as cate_title,d.title as sign_department') + ->alias('a') + ->join('contract_cate c', 'a.cate_id = c.id') + ->join('department d', 'a.sign_did = d.id','LEFT') + ->order('a.create_time desc') + ->paginate($rows, false, ['query' => $param]) + ->each(function ($item, $key) { + $item->keeper_name = Db::name('Admin')->where(['id' => $item->keeper_uid])->value('name'); + $item->sign_name = Db::name('Admin')->where(['id' => $item->sign_uid])->value('name'); + $item->sign_time = date('Y-m-d', $item->sign_time); + $item->interval_time = date('Y-m-d', $item->start_time) . ' 至 ' . date('Y-m-d', $item->end_time); + $item->type_name = ContractList::$Type[(int) $item->type]; + $item->status_name = ContractList::$Status[(int) $item->status]; + $item->chack_status_name = ContractList::$Status[(int) $item->CheckStatus]; + if($item->cost == 0){ + $item->cost = '-'; + } + }); + return table_assign(0, '', $content); + } else { + return view(); + } + } + + //文章添加&&编辑 + public function add() + { + $param = get_params(); + if (request()->isAjax()) { + if (isset($param['sign_time'])) { + $param['sign_time'] = strtotime($param['sign_time']); + } + if (isset($param['start_time'])) { + $param['start_time'] = strtotime($param['start_time']); + } + if (isset($param['end_time'])) { + $param['end_time'] = strtotime($param['end_time']); + if ($param['end_time'] <= $param['start_time']) { + return to_assign(1, "结束时间需要大于开始时间"); + } + } + if (!empty($param['id']) && $param['id'] > 0) { + try { + validate(ContractCheck::class)->scene($param['scene'])->check($param); + } catch (ValidateException $e) { + // 验证失败 输出错误信息 + return to_assign(1, $e->getError()); + } + $param['update_time'] = time(); + $old = Db::name('Contract')->where(['id' => $param['id']])->find(); + $auth = contract_auth($this->uid); + if($this->uid!=$old['admin_id'] && $auth==0 && $old['status'] == 1){ + return to_assign(1, "只有录入人员和合同管理员有权限操作"); + } + if($auth==0 && $old['status'] > 1){ + return to_assign(1, "只有合同管理员有权限操作"); + } + $res = contractList::strict(false)->field(true)->update($param); + if ($res) { + add_log('edit', $param['id'], $param); + to_log($this->uid,$param,$old); + return to_assign(); + } else { + return to_assign(1, '操作失败'); + } + } else { + try { + validate(ContractCheck::class)->scene('add')->check($param); + } catch (ValidateException $e) { + // 验证失败 输出错误信息 + return to_assign(1, $e->getError()); + } + $param['create_time'] = time(); + $param['admin_id'] = $this->uid; + $aid = ContractList::strict(false)->field(true)->insertGetId($param); + if ($aid) { + add_log('add', $aid, $param); + $log_data = array( + 'field' => 'new', + 'action' => 'add', + 'contract_id' => $aid, + 'admin_id' => $param['admin_id'], + 'create_time' => time(), + ); + Db::name('ContractLog')->strict(false)->field(true)->insert($log_data); + return to_assign(); + } else { + return to_assign(1, '操作失败'); + } + } + } else { + $id = isset($param['id']) ? $param['id'] : 0; + $type = isset($param['type']) ? $param['type'] : 0; + $pid = isset($param['pid']) ? $param['pid'] : 0; + View::assign('id', $id); + View::assign('type', $type); + View::assign('pid', $pid); + View::assign('auth', contract_auth($this->uid)); + if ($id > 0) { + $detail = (new ContractList())->detail($id); + if($detail['status']>1){ + echo '
母合同名称 | +{$detail.pname} | +|||||||||||||
合同名称 | +{$detail.name} | +合同编号 | +{$detail.code} | +|||||||||||
签约主体(乙方) | ++ {volist name=":contract_subject()" id="v"} + {eq name="$v.id" value="$detail.subject_id" }{$v.title}{/eq} + {/volist} + | +合同性质 | ++ {eq name="$detail.type" value="1" }普通合同{/eq} + {eq name="$detail.type" value="2" }框架合同{/eq} + {eq name="$detail.type" value="3" }补充协议{/eq} + {eq name="$detail.type" value="4" }其他合同{/eq} + | +合同类别 | ++ {volist name=":contract_cate()" id="v"} + {eq name="$v.id" value="$detail.cate_id" }{$v.title}{/eq} + {/volist} + | +|||||||||
客户名称(甲方) | +{$detail.customer} | +签约客户代表 | +{$detail.customer_name} | +客户联系电话 | +{$detail.customer_mobile} | +|||||||||
客户联系地址 | +{$detail.customer_address} | +合同开始日期 | +{$detail.start_time} | +合同结束日期 | +{$detail.end_time} | +|||||||||
合同金额 | +{$detail.cost} | + {eq name="$detail.is_tax" value="1" } +是否含税 | +是 | +税点(百分比) | +{$detail.tax}% | + {/eq} + {eq name="$detail.is_tax" value="0" } +是否含税 | +否 | + {/eq} +|||||||
备注信息 | +{$detail.remark} | +|||||||||||||
+ 合同附件
+ {eq name="$detail.status" value="1" }{/eq}
+ |
+ + {volist name="$detail.file_array" id="vo"} + + {/volist} + | +|||||||||||||
签订信息 | +||||||||||||||
合同制定人 | +{$detail.prepared_name} | +合同签订人 | +{$detail.sign_name} | +合同签订时间 | +{$detail.sign_time} | +合同签订部门 | +{$detail.sign_department} | +|||||||
审核信息 | +||||||||||||||
合同保管人 | +{$detail.keeper_name}{gt name="$auth" value="0"}{/gt} | +合同共享人员 | +{$detail.share_names}{gt name="$auth" value="0"}{/gt} | +|||||||||||
合同状态 | +{$detail.status_name} | +录入人 | +{$detail.admin_name} | +录入时间 | +{$detail.create_time} | +|||||||||
合同状态 | +{$detail.status_name} | +|||||||||||||
审核人 | +{$detail.check_name} | +审核时间 | +{$detail.check_time} | +录入人 | +{$detail.admin_name} | +录入时间 | +{$detail.create_time} | +|||||||
审核备注 | +{$detail.check_remark} | +|||||||||||||
归档状态 | + {eq name="$detail.archive_status" value="0" } +{$detail.archive_status_name} | + {else/} +{$detail.archive_status_name} | +归档人 | +{$detail.archive_name} | +归档时间 | +{$detail.archive_time} | + {/eq} +||||||||
合同状态 | +{$detail.status_name} | +|||||||||||||
中止人 | +{$detail.stop_name} | +中止时间 | +{$detail.stop_time} | +录入人 | +{$detail.admin_name} | +录入时间 | +{$detail.create_time} | +|||||||
中止备注 | +{$detail.stop_remark} | +|||||||||||||
合同状态 | +{$detail.status_name} | +|||||||||||||
作废人 | +{$detail.void_name} | +作废时间 | +{$detail.void_time} | +录入人 | +{$detail.admin_name} | +录入时间 | +{$detail.create_time} | +|||||||
作废备注 | +{$detail.void_remark} | +
i.pages||(i.curr=e,t.render())});e&&o.on(e,"change",function(){var e=this.value;i.curr*e>i.count&&(i.curr=Math.ceil(i.count/e)),i.limit=e,t.render()}),n&&o.on(n,"click",function(){s()})}},t.prototype.skip=function(t){var i,e;t&&(i=this,(e=t[c]("input")[0])&&o.on(e,"keyup",function(e){var a=this.value,e=e.keyCode;/^(37|38|39|40)$/.test(e)||(/\D/.test(a)&&(this.value=a.replace(/\D/,"")),13===e&&i.jump(t,!0))}))},t.prototype.render=function(e){var a=this,t=a.config,i=a.type(),r=a.view(),i=(2===i?t.elem&&(t.elem.innerHTML=r):3===i?t.elem.html(r):n[u](t.elem)&&(n[u](t.elem).innerHTML=r),t.jump&&t.jump(t,e),n[u]("layui-laypage-"+t.index));a.jump(i),t.hash&&!e&&(location.hash="!"+t.hash+"="+t.curr),a.skip(i)},{render:function(e){return new t(e).index},index:layui.laypage?layui.laypage.index+1e4:0,on:function(a,e,t){return a.attachEvent?a.attachEvent("on"+e,function(e){e.target=e.srcElement,t.call(a,e)}):a.addEventListener(e,t,!1),this}});e("laypage",o)});!function(i,r){"use strict";var n=i.layui&&layui.define,l={getPath:i.lay&&lay.getPath?lay.getPath:"",link:function(e,t,a){u.path&&i.lay&&lay.layui&&lay.layui.link(u.path+e,t,a)}},e=i.LAYUI_GLOBAL||{},u={v:"5.3.1",config:{weekStart:0},index:i.laydate&&i.laydate.v?1e5:0,path:e.laydate_dir||l.getPath,set:function(e){var t=this;return t.config=lay.extend({},t.config,e),t},ready:function(e){var t="laydate",a=(n?"modules/laydate/":"theme/")+"default/laydate.css?v="+u.v;return n?layui.addcss(a,e,t):l.link(a,e,t),this}},s=function(){var t=this,e=t.config.id;return{hint:function(e){t.hint.call(t,e)},config:(s.that[e]=t).config}},a="laydate",w="layui-this",x="laydate-disabled",h=[100,2e5],p="layui-laydate-static",M="layui-laydate-list",o="layui-laydate-hint",E=".laydate-btns-confirm",C="laydate-time-text",k="laydate-btns-time",f="layui-laydate-preview",g=function(e){var t=this;t.index=++u.index,t.config=lay.extend({},t.config,u.config,e),(e=t.config).id="id"in e?e.id:t.index,u.ready(function(){t.init()})},y="yyyy|y|MM|M|dd|d|HH|H|mm|m|ss|s";s.formatArr=function(e){return(e||"").match(new RegExp(y+"|.","g"))||[]},g.isLeapYear=function(e){return e%4==0&&e%100!=0||e%400==0},g.prototype.config={type:"date",range:!1,format:"yyyy-MM-dd",value:null,isInitValue:!0,min:"1900-1-1",max:"2099-12-31",trigger:"click",show:!1,showBottom:!0,isPreview:!0,btns:["clear","now","confirm"],lang:"cn",theme:"default",position:null,calendar:!1,mark:{},zIndex:null,done:null,change:null},g.prototype.lang=function(){var e={cn:{weeks:["\u65e5","\u4e00","\u4e8c","\u4e09","\u56db","\u4e94","\u516d"],time:["\u65f6","\u5206","\u79d2"],timeTips:"\u9009\u62e9\u65f6\u95f4",startTime:"\u5f00\u59cb\u65f6\u95f4",endTime:"\u7ed3\u675f\u65f6\u95f4",dateTips:"\u8fd4\u56de\u65e5\u671f",month:["\u4e00","\u4e8c","\u4e09","\u56db","\u4e94","\u516d","\u4e03","\u516b","\u4e5d","\u5341","\u5341\u4e00","\u5341\u4e8c"],tools:{confirm:"\u786e\u5b9a",clear:"\u6e05\u7a7a",now:"\u73b0\u5728"},timeout:"\u7ed3\u675f\u65f6\u95f4\u4e0d\u80fd\u65e9\u4e8e\u5f00\u59cb\u65f6\u95f4
\u8bf7\u91cd\u65b0\u9009\u62e9",invalidDate:"\u4e0d\u5728\u6709\u6548\u65e5\u671f\u6216\u65f6\u95f4\u8303\u56f4\u5185",formatError:["\u65e5\u671f\u683c\u5f0f\u4e0d\u5408\u6cd5
\u5fc5\u987b\u9075\u5faa\u4e0b\u8ff0\u683c\u5f0f\uff1a
","
\u5df2\u4e3a\u4f60\u91cd\u7f6e"],preview:"\u5f53\u524d\u9009\u4e2d\u7684\u7ed3\u679c"},en:{weeks:["Su","Mo","Tu","We","Th","Fr","Sa"],time:["Hours","Minutes","Seconds"],timeTips:"Select Time",startTime:"Start Time",endTime:"End Time",dateTips:"Select Date",month:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],tools:{confirm:"Confirm",clear:"Clear",now:"Now"},timeout:"End time cannot be less than start Time
Please re-select",invalidDate:"Invalid date",formatError:["The date format error
Must be followed\uff1a
","
It has been reset"],preview:"The selected result"}};return e[this.config.lang]||e.cn},g.prototype.init=function(){var r=this,o=r.config,e="static"===o.position,t={year:"yyyy",month:"yyyy-MM",date:"yyyy-MM-dd",time:"HH:mm:ss",datetime:"yyyy-MM-dd HH:mm:ss"};o.elem=lay(o.elem),o.eventElem=lay(o.eventElem),o.elem[0]&&(r.rangeStr=o.range?"string"==typeof o.range?o.range:"-":"","array"===layui.type(o.range)&&(r.rangeElem=[lay(o.range[0]),lay(o.range[1])]),t[o.type]||(i.console&&console.error&&console.error("laydate type error:'"+o.type+"' is not supported"),o.type="date"),o.format===t.date&&(o.format=t[o.type]||t.date),r.format=s.formatArr(o.format),o.weekStart&&!/^[0-6]$/.test(o.weekStart)&&(t=r.lang(),o.weekStart=t.weeks.indexOf(o.weekStart),-1===o.weekStart&&(o.weekStart=0)),r.EXP_IF="",r.EXP_SPLIT="",lay.each(r.format,function(e,t){e=new RegExp(y).test(t)?"\\d{"+(new RegExp(y).test(r.format[0===e?e+1:e-1]||"")?/^yyyy|y$/.test(t)?4:t.length:/^yyyy$/.test(t)?"1,4":/^y$/.test(t)?"1,308":"1,2")+"}":"\\"+t;r.EXP_IF=r.EXP_IF+e,r.EXP_SPLIT=r.EXP_SPLIT+"("+e+")"}),r.EXP_IF_ONE=new RegExp("^"+r.EXP_IF+"$"),r.EXP_IF=new RegExp("^"+(o.range?r.EXP_IF+"\\s\\"+r.rangeStr+"\\s"+r.EXP_IF:r.EXP_IF)+"$"),r.EXP_SPLIT=new RegExp("^"+r.EXP_SPLIT+"$",""),r.isInput(o.elem[0])||"focus"===o.trigger&&(o.trigger="click"),o.elem.attr("lay-key")||(o.elem.attr("lay-key",r.index),o.eventElem.attr("lay-key",r.index)),o.mark=lay.extend({},o.calendar&&"cn"===o.lang?{"0-1-1":"\u5143\u65e6","0-2-14":"\u60c5\u4eba","0-3-8":"\u5987\u5973","0-3-12":"\u690d\u6811","0-4-1":"\u611a\u4eba","0-5-1":"\u52b3\u52a8","0-5-4":"\u9752\u5e74","0-6-1":"\u513f\u7ae5","0-9-10":"\u6559\u5e08","0-10-1":"\u56fd\u5e86","0-12-25":"\u5723\u8bde"}:{},o.mark),lay.each(["min","max"],function(e,t){var a,n,i=[],l=[];l="number"==typeof o[t]?(n=o[t],a=new Date,a=r.newDate({year:a.getFullYear(),month:a.getMonth(),date:a.getDate(),hours:"23",minutes:"59",seconds:"59"}).getTime(),i=[(n=new Date(n?n<864e5?a+864e5*n:n:a)).getFullYear(),n.getMonth()+1,n.getDate()],[n.getHours(),n.getMinutes(),n.getSeconds()]):(i=(o[t].match(/\d+-\d+-\d+/)||[""])[0].split("-"),(o[t].match(/\d+:\d+:\d+/)||[""])[0].split(":")),o[t]={year:0|i[0]||(new Date).getFullYear(),month:i[1]?(0|i[1])-1:(new Date).getMonth(),date:0|i[2]||(new Date).getDate(),hours:0|l[0],minutes:0|l[1],seconds:0|l[2]}}),r.elemID="layui-laydate"+o.elem.attr("lay-key"),(o.show||e)&&r.render(),e||r.events(),o.value&&o.isInitValue&&("date"===layui.type(o.value)?r.setValue(r.parse(0,r.systemDate(o.value))):r.setValue(o.value)))},g.prototype.render=function(){var n,e,t=this,o=t.config,s=t.lang(),i="static"===o.position,a=t.elem=lay.elem("div",{id:t.elemID,"class":["layui-laydate",o.range?" layui-laydate-range":"",i?" "+p:"",o.theme&&"default"!==o.theme&&!/^#/.test(o.theme)?" laydate-theme-"+o.theme:""].join("")}),y=t.elemMain=[],d=t.elemHeader=[],m=t.elemCont=[],c=t.table=[],l=t.footer=lay.elem("div",{"class":"layui-laydate-footer"});o.zIndex&&(a.style.zIndex=o.zIndex),lay.each(new Array(2),function(e){if(!o.range&&0