You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
2.2 KiB
89 lines
2.2 KiB
<?php
|
|
|
|
namespace app\calculator\model;
|
|
|
|
use think\model\concern\SoftDelete;
|
|
|
|
class CalculatorDetail extends Base
|
|
{
|
|
|
|
use SoftDelete;
|
|
|
|
/**
|
|
* 获取计算方式
|
|
* @date 2023-01-18
|
|
*/
|
|
public function getCalculationTypeTextAttr($value, $data)
|
|
{
|
|
$status_text = [
|
|
1 => '疏散人数-有耐火等级 W=疏散人数/100*百人最小疏散净宽度',
|
|
2 => '疏散人数-无耐火等级 W=疏散人数/100*百人最小疏散净宽度',
|
|
3 => '疏散人数-无耐火等级-有宽度最小值 ',
|
|
4 => '待评价',
|
|
5 => '已完成',
|
|
6 => '退款中',
|
|
7 => '已退款',
|
|
8 => '已取消',
|
|
];
|
|
return $status_text[$data['status']];
|
|
}
|
|
|
|
/**
|
|
* 查找单条数据或单个字段
|
|
* @param array $where 条件
|
|
* @param string $field 获取字段
|
|
* @param string $order 排序条件
|
|
* @date 2023-01-19
|
|
*/
|
|
public function listDetail($where = [], $field = '*', $order = '')
|
|
{
|
|
if (empty($order)) {
|
|
$order = 'id desc';
|
|
}
|
|
|
|
$data_list = $this->with(['calculatorPlace', 'calculatorPosition', 'calculatorRefractory'])
|
|
->field($field)->where($where)->order($order)->select()
|
|
->each(function ($item) {
|
|
|
|
// 删除无用数组
|
|
unset($item['calculatorPlace']);
|
|
unset($item['calculatorPosition']);
|
|
unset($item['calculatorRefractory']);
|
|
});
|
|
|
|
|
|
return $data_list;
|
|
}
|
|
|
|
/**
|
|
* 一对一关联场所
|
|
*/
|
|
public function calculatorPlace()
|
|
{
|
|
return $this->hasOne('CalculatorPlace', 'id', 'place_id')->bind([
|
|
'place_name' => 'name',
|
|
'remark'
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* 一对一关联位置
|
|
*/
|
|
public function calculatorPosition()
|
|
{
|
|
return $this->hasOne('CalculatorPosition', 'id', 'position_id')->bind([
|
|
'position_name' => 'name'
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* 一对一关联场所
|
|
*/
|
|
public function calculatorRefractory()
|
|
{
|
|
return $this->hasOne('calculatorRefractory', 'id', 'refractory_id')->bind([
|
|
'refractory_name' => 'name'
|
|
]);
|
|
}
|
|
}
|