mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-05 17:42:49 +08:00
完成curd的城市选择器组件;
This commit is contained in:
@@ -225,7 +225,7 @@ class BuildCurdService
|
||||
* 表单类型
|
||||
* @var array
|
||||
*/
|
||||
protected $formTypeArray = ['text', 'image', 'images', 'file', 'files', 'select', 'switch', 'date', 'editor', 'textarea', 'checkbox', 'radio', 'relation', 'table'];
|
||||
protected $formTypeArray = ['text', 'image', 'images', 'file', 'files', 'select', 'switch', 'date', 'editor', 'textarea', 'checkbox', 'radio', 'relation', 'table', 'city'];
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
@@ -665,9 +665,9 @@ class BuildCurdService
|
||||
preg_match('/\([\s\S]*?\)/i', $string, $defineMatch);
|
||||
if (!empty($formTypeMatch) && isset($defineMatch[0])) {
|
||||
$colum['comment'] = str_replace($defineMatch[0], '', $colum['comment']);
|
||||
if (isset($colum['formType']) && in_array($colum['formType'], ['images', 'files', 'select', 'switch', 'radio', 'checkbox', 'date', 'relation', 'table'])) {
|
||||
if (isset($colum['formType']) && in_array($colum['formType'], ['images', 'files', 'select', 'switch', 'radio', 'checkbox', 'date', 'relation', 'table', 'city'])) {
|
||||
$define = str_replace(')', '', str_replace('(', '', $defineMatch[0]));
|
||||
if (in_array($colum['formType'], ['select', 'switch', 'radio', 'checkbox', 'relation', 'table'])) {
|
||||
if (in_array($colum['formType'], ['select', 'switch', 'radio', 'checkbox', 'relation', 'table', 'city'])) {
|
||||
$formatDefine = [];
|
||||
$explodeArray = explode(',', $define);
|
||||
foreach ($explodeArray as $vo) {
|
||||
@@ -708,7 +708,7 @@ class BuildCurdService
|
||||
);
|
||||
return $selectCode;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 构架下拉模型
|
||||
* @param $field
|
||||
@@ -753,6 +753,54 @@ class BuildCurdService
|
||||
);
|
||||
return $optionCode;
|
||||
}
|
||||
|
||||
protected function buildCityView($field, $options, $value)
|
||||
{
|
||||
|
||||
|
||||
$default_define = [
|
||||
'comment' => $options['comment'],
|
||||
'field' => $field,
|
||||
'required' => $this->buildRequiredHtml($options['required']),
|
||||
'value' => $value,
|
||||
'level' => ''
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
$define = array_merge($default_define, $options['define']);
|
||||
|
||||
|
||||
$formatTargetList = [];
|
||||
$formatTargetList['name'] = 1;
|
||||
$formatTargetList['code'] = 1;
|
||||
$formatTargetList['name-province'] = 1;
|
||||
$formatTargetList['name-city'] = 1;
|
||||
$formatTargetList['name-district'] = 1;
|
||||
$formatTargetList['code-province'] = 1;
|
||||
$formatTargetList['code-city'] = 1;
|
||||
$formatTargetList['code-district'] = 1;
|
||||
|
||||
$submit_field_content = '';
|
||||
|
||||
foreach ($formatTargetList as $key => $value) {
|
||||
if (isset($define[$key])) {
|
||||
$submit_field_content .= 'data-field-' . $key . '="' . $define[$key] . '" ';
|
||||
}
|
||||
}
|
||||
|
||||
$define['submit_field_content'] = $submit_field_content;
|
||||
|
||||
|
||||
$city_main_code = $this->replaceTemplate(
|
||||
$this->getTemplate("view{$this->DS}module{$this->DS}cityMain"),
|
||||
$define
|
||||
);
|
||||
|
||||
return $city_main_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建表格选择器视图
|
||||
* @param $field
|
||||
@@ -1226,6 +1274,9 @@ class BuildCurdService
|
||||
} elseif ($val['formType'] == 'table') {
|
||||
$templateFile = "view{$this->DS}module{$this->DS}table";
|
||||
$define = $this->buildTableView($field, $val, $val['default']);
|
||||
} elseif ($val['formType'] == 'city') {
|
||||
$templateFile = "view{$this->DS}module{$this->DS}city";
|
||||
$define = $this->buildCityView($field, $val, $val['default']);
|
||||
}
|
||||
|
||||
|
||||
@@ -1319,6 +1370,9 @@ class BuildCurdService
|
||||
} elseif ($val['formType'] == 'table') {
|
||||
$templateFile = "view{$this->DS}module{$this->DS}table";
|
||||
$define = $this->buildTableView($field, $val, $value);
|
||||
} elseif ($val['formType'] == 'city') {
|
||||
$templateFile = "view{$this->DS}module{$this->DS}city";
|
||||
$define = $this->buildCityView($field, $val, $value);
|
||||
}
|
||||
|
||||
$editFormList .= $this->replaceTemplate(
|
||||
|
||||
7
app/admin/service/curd/templates/view/module/city.code
Normal file
7
app/admin/service/curd/templates/view/module/city.code
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">{{comment}}</label>
|
||||
<div class="layui-input-block">
|
||||
{{define}}
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1 @@
|
||||
<input class="layui-input" name="{{field}}" data-toggle="city-picker" {{required}} value="{{value}}" type="text" data-level="{{level}}" readonly {{submit_field_content}}>
|
||||
Reference in New Issue
Block a user