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.

75 lines
3.0 KiB

<?php
namespace App\Forms;
use App\Models\AlipayAccount;
use App\Models\WechatpayAccount;
use Kris\LaravelFormBuilder\Form;
use Kris\LaravelFormBuilder\Field;
class ProjectForm extends Form
{
public function buildForm()
{
$this->add("latitude", Field::HIDDEN);
$this->add("longitude", Field::HIDDEN);
$this->add("name", Field::TEXT, ["label" => "名称", "rules" => "required"]);
$this->add("address", Field::TEXT, ["label" => "地址", "rules" => "required"]);
$this->add("wechatpay_account_id", Field::SELECT, ["label" => "微信支付账号", "choices" => $this->getWechatpayAccount()]);
$this->add("alipay_account_id", Field::SELECT, ["label" => "支付宝账号", "choices" => $this->getAlipayAccount()]);
$this->add("percent_first_party", Field::NUMBER, ["label" => "院方结算百分比"]);
$this->add("logo", Field::TEXT, ["label" => "logo", "attr" => ["data-plugin" => "uploader"]]);
$this->add("banners", Field::TEXT, ["label" => "banner", "attr" => ["data-plugin" => "uploader", "data-multiple-multiple" => 1]]);
// 派工电话
$this->add("range_mobile", Field::TEXT, ["label" => "派工电话"]);
// 投诉电话
$this->add("complaint_mobile", Field::TEXT, ["label" => "投诉电话"]);
// 是否需要签订协议
$this->add("agreement", Field::SELECT, ["label" => "是否需要签订协议", "choices" => [0 => "", 1 => ""]]);
// 状态
$this->add("status", Field::SELECT, ["label" => "状态", "choices" => [1 => "启用", 0 => "禁用"], "default_value" => 1]);
// 协议
$this->add("content", Field::TEXTAREA, ["label" => "协议"]);
$this->add("profile", Field::TEXTAREA, ["label" => "简介"]);
$this->add("auto_checkout_days", Field::NUMBER, [
"label" => "开启自动结单天数",
"default_value" => 0,
"help_block" => [
"text" => "0表示不开启自动结单"
]
]);
$this->add('paramedicLevels', 'collection', [
'type' => 'form',
'label' => "护工等级",
'options' => [
'class' => 'App\Forms\ParamedicLevelForm',
'label' => false
]
]);
$this->add('buttons', 'buttongroup', ["splitted" => true, "buttons" => [
["label" => "保存", "attr" => ["class" => "btn btn-primary mr-1", "type" => "submit"]],
["label" => "返回", "attr" => ["class" => "btn btn-light btn-back", "type" => "button"]]
]]);
}
function getWechatpayAccount()
{
$rows = (new WechatpayAccount())->get();
$res = [];
foreach ($rows as $row) {
$res["{$row->id}"] = $row->name."({$row->mchid})";
}
return $res;
}
function getAlipayAccount()
{
$rows = (new AlipayAccount())->get();
$res = [];
foreach ($rows as $row) {
$res["{$row->id}"] = $row->name."({$row->appid})";
}
return $res;
}
}