Files
duolamaojiazhen/application/admin/controller/Material.php
2025-12-22 13:59:40 +08:00

154 lines
4.3 KiB
PHP

<?php
namespace app\admin\controller;
use think\Db;
use app\admin\logic\MaterialLogic;
use app\admin\logic\StaffLogic;
use app\common\server\ConfigServer;
class Material extends AdminBase
{
/**
* 原料库存列表
* @param $get
* @return array
*/
public function lists(){
if ($this->request->isAjax()) {
$get = $this->request->get();
$lists = MaterialLogic::lists($get);
$this->_success('',$lists);
}
return $this->fetch();
}
/**
* 增加库存列表
* @param $get
* @return array
*/
public function add(){
if ($this->request->isAjax()) {
$get = $this->request->post();
$lists = MaterialLogic::add($get);
$this->_success('增加原料库存成功');
}
$this->assign('staff_bellist', json_encode(StaffLogic::staff_bellist(), JSON_UNESCAPED_UNICODE));
$this->assign('brand_lists', json_encode(MaterialLogic::typelists(), JSON_UNESCAPED_UNICODE));
return $this->fetch();
}
/**
* 编辑原料库存
* @param $get
* @return array
*/
public function edit(){
if ($this->request->isAjax()) {
$get = $this->request->post();
$lists = MaterialLogic::edit($get);
$this->_success('更新成功');
}
$id = $this->request->get('id');
$this->assign('info', json_encode(MaterialLogic::infolist($id),JSON_UNESCAPED_UNICODE));
$this->assign('brand_lists', json_encode(MaterialLogic::typelists(), JSON_UNESCAPED_UNICODE));
$this->assign('staff_bellist', json_encode(StaffLogic::staff_bellist(), JSON_UNESCAPED_UNICODE));
return $this->fetch();
}
/**
* 原料类型
* @param $get
* @return array
*/
public function typelist(){
if ($this->request->isAjax()) {
$get = $this->request->get();
$lists = MaterialLogic::typelist($get);
$this->_success('',$lists);
}
return $this->fetch();
}
/**
*增加原料类型
* @param $get
* @return array
*/
public function typeadd(){
if ($this->request->isAjax()) {
$get = $this->request->post('name');
$data=Db::name('material_type')->data(['name'=>$get,'time'=>time()])->insert();
$this->_success('增加原料分类成功');
}
return $this->fetch();
}
/**
*修改原料分类名称
* @param $get
* @return array
*/
public function typeidt($id){
if ($this->request->isAjax()) {
$get = $this->request->post();
$data=Db::name('material_type')->where('id',$get['id'])->data(['name'=>$get['name']])->update();
$this->_success('更改分类成功');
}
$detail=Db::name('material_type')->where('id',$id)->find();
$this->assign('detail',$detail);
return $this->fetch();
}
/**
*删除原料分类
* @param $get
* @return array
*/
public function typedel($id){
$data=Db::name('material_type')->where('id',$id)->delete();
$this->_success('删除成功');
}
/**
*删除原料库存
* @param $get
* @return array
*/
public function del($id){
$data=Db::name('epr')->where('id',$id)->delete();
$this->_success('删除成功');
}
//员工申请物料
public function usermaterial(){
if ($this->request->isAjax()) {
$post = $this->request->get();
$this->_success('获取数据成功',MaterialLogic::usermaterial($post));
}
$this->assign('satff',StaffLogic::serverstaff());
return $this->fetch();
}
//删除员工申请
public function delusermaterial(){
$id = $this->request->post('id');
$this->_success('获取数据成功',MaterialLogic::delusermaterial($id));
}
//物料申请审核通过
public function audit(){
$id = $this->request->post('id');
$this->_success('审核通过',MaterialLogic::audit($id));
}
//拒绝通过
public function noaudit(){
$id = $this->request->post('id');
$this->_success('修改成功',MaterialLogic::noaudit($id));
}
}