123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- <?php
- namespace app\admin\controller;
- use app\data\model\BasePostageRegion;
- use app\data\model\DataBidding;
- use app\data\model\DataBidding as Model;
- use app\data\model\DataBiddingType;
- use think\admin\Controller;
- /**
- * 招标中心
- * Class Xw
- * @package app\admin\controller\Xw
- */
- class Bidding extends Controller
- {
- /**
- * 招标列表
- * @auth true
- * @menu true
- */
- public function index(){
- $this->title='招标列表';
- $this->assign('type',DataBiddingType::select());
- Model::mQuery()
- ->with(['type'])
- ->equal('type_id')
- ->like('title')->dateBetween('create_time')->layTable();
- }
- /**
- * 招标添加
- * @auth true
- * @menu true
- */
- public function add(){
- $this->title='招标添加';
- $this->xw_vali();
- $this->assign('category',DataBiddingType::select());
- $this->assign('city',BasePostageRegion::getCity());
- Model::mForm('form');
- }
- /**
- * 招标编辑
- * @auth true
- * @menu true
- */
- public function edit(){
- $this->title='招标编辑';
- $this->xw_vali();
- $this->assign('category',DataBiddingType::select());
- $this->assign('city',BasePostageRegion::getCity());
- Model::mForm('form');
- }
- protected function xw_vali(){
- if($this->request->isPost()){
- $this->_vali([
- 'title.max:50'=>'标题过长',
- ]);
- }
- }
- /**
- * 招标删除
- * @auth true
- * @menu true
- */
- public function remove(){
- $ids=$this->request->post('id');
- Model::whereIn('id',$ids)->select()->each(function ($d){$d->delete();});
- $this->success('删除成功');
- }
- /**
- * 招标设置
- * @auth true
- * @menu true
- */
- public function config(){
- if($this->request->isGet()){
- $this->title='招标设置';
- $this->assign('vo',sysconf('config_res_center.'));
- $this->fetch();
- }else{
- $data=$this->_vali([
- 'c_rule.require'=>'规则数必须',
- 'c_conv.require'=>'公约数必须',
- 'c_menu.require'=>'清单数必须',
- ]);
- sysconf('config_res_center',$data);
- $this->success('保存成功');
- }
- }
- /**
- * 招标类型管理
- * @auth true
- * @menu true
- */
- public function type(){
- $this->title='招标类型管理';
- DataBiddingType::mQuery()
- ->layTable();
- }
- /**
- * 招标类型管理
- * @auth true
- * @menu true
- */
- public function type_add(){
- if($this->request->isPost()){
- $data=$this->_vali([
- 'name.require'=>'名称必须',
- ]);
- DataBiddingType::create($data);
- $this->success('保存成功');
- }
- $this->fetch('type_form');
- }
- /**
- * 招标类型管理
- * @auth true
- * @menu true
- */
- public function type_edit(){
- if($this->request->isPost()){
- $data=$this->_vali([
- 'name.require'=>'名称必须',
- ]);
- DataBiddingType::where('id',input('id'))->save($data);
- $this->success('保存成功');
- }else{
- $this->assign('vo',DataBiddingType::find(input('id')));
- $this->fetch('type_form');
- }
- }
- /**
- * 招标类型管理
- * @auth true
- * @menu true
- */
- public function type_remove(){
- $ids=$this->request->post('id');
- $has=DataBidding::whereIn('type_id',$ids)->find();
- if($has){
- $this->error('该分类下还有招标,请删除后再试');
- }
- DataBiddingType::whereIn('id',$ids)->select()->each(function ($d){
- $d->delete();
- });
- $this->success('删除成功');
- }
- /**
- * 表单结果处理
- * @param boolean $state
- */
- protected function _form_result(bool $state)
- {
- if ($state) {
- $this->success('保存成功!', 'javascript:history.back()');
- }
- }
- /**
- * 中标
- * @auth true
- */
- public function make_bidding(){
- $id = input('id');
- $bidding=DataBidding::find($id);
- $this->assign('vo',$bidding);
- if($bidding->win){
- //$this->error('该招标已中标');
- }
- if($this->request->isGet()) {
- $this->fetch();
- }else{
- $data=$this->_vali([
- 'com_name.require'=>'公司名称必须',
- 'com_username.require'=>'公司联系人必须',
- 'com_mobile.require'=>'公司手机号必须',
- ]);
- $bidding->win()->save($data);
- $bidding->status=1;
- $bidding->save();
- $this->success('中标成功');
- }
- }
- }
|