mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-09 19:42:47 +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) {
|
||||
@@ -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}}>
|
||||
@@ -151,6 +151,18 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">产地</label>
|
||||
<div class="layui-input-block">
|
||||
<input class="layui-input" name="from_area" data-toggle="city-picker" lay-verify="required" value="" type="text" data-level="" readonly data-field-code="0" data-field-name-province="0" >
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">仓库</label>
|
||||
<div class="layui-input-block">
|
||||
<input class="layui-input" name="store_city" data-toggle="city-picker" lay-verify="required" value="" type="text" data-level="city" readonly >
|
||||
</div>
|
||||
</div>
|
||||
<div class="hr-line"></div>
|
||||
<div class="layui-form-item text-center">
|
||||
<button type="submit" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit>确认</button>
|
||||
|
||||
@@ -154,17 +154,13 @@
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">产地</label>
|
||||
<div class="layui-input-block">
|
||||
|
||||
<input class="layui-input" name="from_area" value="{$row.from_area|default=''}" data-field-code="0" readonly type="text" data-toggle="city-picker">
|
||||
|
||||
<input class="layui-input" name="from_area" data-toggle="city-picker" lay-verify="required" value="{$row.from_area|default=''}" type="text" data-level="" readonly data-field-code="0" data-field-name-province="0" >
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">仓库</label>
|
||||
<div class="layui-input-block">
|
||||
|
||||
<input class="layui-input" name="store_city" value="{$row.store_city|default=''}" readonly type="text" data-toggle="city-picker" data-level="city" >
|
||||
|
||||
<input class="layui-input" name="store_city" data-toggle="city-picker" lay-verify="required" value="{$row.store_city|default=''}" type="text" data-level="city" readonly >
|
||||
</div>
|
||||
</div>
|
||||
<div class="hr-line"></div>
|
||||
|
||||
@@ -17,7 +17,7 @@ define(["jquery", "easy-admin"], function ($, ea) {
|
||||
ea.table.render({
|
||||
init: init,
|
||||
cols: [[
|
||||
{type: 'checkbox'},
|
||||
{type: 'checkbox'},
|
||||
{field: 'id', title: 'id'},
|
||||
{field: 'cate_id', title: '分类ID'},
|
||||
{field: 'title', title: '商品名称'},
|
||||
|
||||
Reference in New Issue
Block a user