导入基础类

This commit is contained in:
meimei
2025-04-18 15:58:01 +08:00
parent f20b865f4d
commit ee99adfb30
15 changed files with 90 additions and 19 deletions

View File

@@ -181,7 +181,7 @@ class Tasktimer extends Controller
$birthday_record = Db::table('fa_mattertemplatecategorization')
->alias('m')
->join('fa_mattertemplatecategorizedcontent','fa_mattertemplatecategorizedcontent.mattertemplatecategorization_id = m.id')
->where('m.firm_id','in',[$value['firm_id'],0])
->where('m.firm_id','in',[$value['firm_id'],1])
->where('m.mattertemplate_id',3)
->order(['m.firm_id'=>'desc','m.id'=>'desc'])
->field('fa_mattertemplatecategorizedcontent.content')

View File

@@ -124,17 +124,20 @@ class Firm extends Backend
if (count($firmstoreData) == 0){
return json(['code'=>201,'msg'=>'请先添加门店']);
}
//大类
$firmbigcategoryData = Db::table('fa_firmbigcategory')->where('firm_id',1)->select();
foreach ($firmbigcategoryData as $key=>&$val){
unset($val['id']);
$val['firm_id'] = $ids;
}
//客户来源
$firmcustomeroriginData = Db::table('fa_firmcustomerorigin')->where('firm_id',1)->select();
foreach ($firmcustomeroriginData as $key=>&$val){
unset($val['id']);
$val['firm_id'] = $ids;
}
$firmdutyData = Db::table('fa_firmduty')->where('firm_id',1)->select();
//职务
$firmdutyData = Db::table('fa_firmduty')->where('firm_id',1)->where('firmstore_id',1)->select();
$firmdutyMore = [];
foreach ($firmdutyData as $key=>&$val){
$data = [];
@@ -145,19 +148,74 @@ class Firm extends Backend
$firmdutyMore[] = $data;
}
}
//标签
$firmtagsData = Db::table('fa_firmtags')->where('firm_id',1)->select();
foreach ($firmtagsData as $key=>&$val){
unset($val['id']);
$val['firm_id'] = $ids;
}
$firmbigcategoryResult = false;
$firmcustomerorigiResult = false;
$firmdutyResult = false;
$firmtagsResult = false;
Db::startTrans();
try {
$firmbigcategoryResult = Db::table('fa_firmbigcategory')->insertAll($firmbigcategoryData);
$firmcustomerorigiResult = Db::table('fa_firmcustomerorigin')->insertAll($firmcustomeroriginData);
$firmdutyResult = Db::table('fa_firmduty')->insertAll($firmdutyMore);
$firmtagsResult = Db::table('fa_firmtags')->insertAll($firmtagsData);
//店铺项目
$firmstoreprojectsoneData = Db::table('fa_firmstoreprojectsone')->where('firm_id',1)->where('firmstore_id',1)->select();
foreach ($firmstoreprojectsoneData as $key=>&$val){
foreach ($firmstoreData as &$v){
$data = [];
$data['firm_id'] = $ids;
$data['name'] = $val['name'];
$data['firmstore_id'] = $v['id'];
//添加一级店铺项目
$firmstoreprojectsone_id = Db::table('fa_firmstoreprojectsone')->insertGetId($data);
//查询二级店铺项目
$firmstoreprojectstwoData = Db::table('fa_firmstoreprojectstwo')->where('firm_id',1)
->where('firmstore_id',1)->where('firmstoreprojectsone_id',$val['id'])->select();
foreach ($firmstoreprojectstwoData as &$value){
$firmstoreprojectstwo_oldid = $value['id'];
unset($value['id']);
$value['firm_id'] = $ids;
$value['firmstore_id'] = $firmstoreprojectsone_id;
//添加二级店铺项目
$firmstoreprojectstwo_id = Db::table('fa_firmstoreprojectstwo')->insertGetId($value);
//查询事例模块
$mattertemplatecategorizationData = Db::table('fa_mattertemplatecategorization')->where('firm_id',1)
->where('firmstoreprojectsone_id',$val['id'])->where('firmstoreprojectstwo_id',$firmstoreprojectstwo_oldid)->find();
if ($mattertemplatecategorizationData){
$mtc_id = $mattertemplatecategorizationData['id'];
unset($mattertemplatecategorizationData['id']);
$mattertemplatecategorizationData['firm_id'] = $ids;
$mattertemplatecategorizationData['firmstoreprojectsone_id'] = $firmstoreprojectsone_id;
$mattertemplatecategorizationData['firmstoreprojectstwo_id'] = $firmstoreprojectstwo_id;
$mattertemplatecategorizationData['create_time'] = date('Y-m-d H:i:s');
$mattertemplatecategorizationData['update_time'] = date('Y-m-d H:i:s');
$mattertemplatecategorization_id = Db::table('fa_mattertemplatecategorization')->insertGetId($mattertemplatecategorizationData);
//事例模块具体内容
$fa_mattertemplatecategorizedcontent = Db::table('fa_mattertemplatecategorizedcontent')
->where('mattertemplatecategorization_id',$mtc_id)->select();
foreach ($fa_mattertemplatecategorizedcontent as &$values){
unset($values['id']);
$values['mattertemplatecategorization_id'] = $mattertemplatecategorization_id;
$values['create_time'] = date('Y-m-d H:i:s');
$values['update_time'] = date('Y-m-d H:i:s');
}
Db::table('fa_mattertemplatecategorizedcontent')->insertAll($fa_mattertemplatecategorizedcontent);
}
}
}
}
Db::commit();
}catch(ValidateException|PDOException|Exception $e){
return json(['code'=>201,'msg'=>$e->getMessage()]);
}
if (!$firmbigcategoryResult || !$firmcustomerorigiResult || !$firmdutyResult){
if (!$firmbigcategoryResult || !$firmcustomerorigiResult || !$firmdutyResult || !$firmtagsResult){
return json(['code'=>201,'msg'=>'导入失败']);
}
return json(['code'=>200,'msg'=>'导入成功']);

View File

@@ -53,7 +53,8 @@ class Firmbigcategory extends Backend
$list = $this->model
->with(['firm'])
->where($where)
->order($sort, $order)
// ->order($sort, $order)
->order('firm_id asc,id desc')
->paginate($limit);
foreach ($list as $row) {

View File

@@ -53,7 +53,8 @@ class Firmcustomerorigin extends Backend
$list = $this->model
->with(['firm'])
->where($where)
->order($sort, $order)
// ->order($sort, $order)
->order('firm_id asc,id desc')
->paginate($limit);
foreach ($list as $row) {

View File

@@ -53,7 +53,8 @@ class Firmduty extends Backend
$list = $this->model
->with(['firm','firmstore'])
->where($where)
->order($sort, $order)
// ->order($sort, $order)
->order('firm_id asc,id desc')
->paginate($limit);
foreach ($list as $row) {

View File

@@ -53,7 +53,8 @@ class Firmstoreprojectsone extends Backend
$list = $this->model
->with(['firm'])
->where($where)
->order($sort, $order)
// ->order($sort, $order)
->order('firm_id asc,id desc')
->paginate($limit);
foreach ($list as $row) {

View File

@@ -55,14 +55,16 @@ class Firmtags extends Backend
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$list = $this->model
->with(['firm'])
->where($where)
->order($sort, $order)
// ->order($sort, $order)
->order('firm_id asc,id desc')
->paginate($limit);
foreach ($list as $row) {
$row->visible(['id','name']);
$row->visible(['firm']);
$row->getRelation('firm')->visible(['full_name']);
}
$result = array("total" => $list->total(), "rows" => $list->items());

View File

@@ -54,7 +54,8 @@ class Mattertemplatecategorization extends Backend
$list = $this->model
->with(['mattertemplate','firmstoreprojectsone','firmstoreprojectstwo','firm'])
->where($where)
->order($sort, $order)
// ->order($sort, $order)
->order('firm_id asc,id desc')
->paginate($limit);
foreach ($list as $row) {

View File

@@ -30,7 +30,10 @@ class Firmtags extends Model
public function firm()
{
return $this->belongsTo('Firm', 'firm_id', 'id', [], 'LEFT')->setEagerlyType(0);
}

View File

@@ -4,9 +4,8 @@
<label class="control-label col-xs-12 col-sm-2">{:__('Firm_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-firm_id" min="0" data-rule="required"
disabled
data-source="firm/index" class="form-control selectpage"
name="row[firm_id]" type="text" value="{:session_admin_firm_id()}">
name="row[firm_id]" type="text" value="1">
</div>
</div>
<div class="form-group">

View File

@@ -10,9 +10,10 @@
<label class="control-label col-xs-12 col-sm-2">{:__('Firm_id')}:</label>
<div class="col-xs-12 col-sm-8" readonly>
<input id="c-firm_id" min="0" data-rule="required" data-source="firm/index"
class="form-control selectpage" disabled
name="row[firm_id]" type="text" value="{:session_admin_firm_id()}">
class="form-control selectpage"
name="row[firm_id]" type="text" value="1">
</div>
<span style="color: red">不选择为基础模版</span>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>

View File

@@ -13,6 +13,7 @@
disabled
data-source="firm/index" class="form-control selectpage" name="row[firm_id]" type="text" value="{$row.firm_id|htmlentities}">
</div>
<span style="color: red">不选择为基础模版</span>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>

View File

@@ -15,8 +15,9 @@
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">企业:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-firm_id" data-source="firm/index" class="form-control selectpage" name="row[firm_id]" type="text" value="">
<input id="c-firm_id" data-source="firm/index" class="form-control selectpage" name="row[firm_id]" type="text" value="1">
</div>
<span style="color: red">不选择为基础模版</span>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Firmstoreprojectsone_id')}:</label>

View File

@@ -37,7 +37,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
name: 'importBasic',
text: '导入基础管理',
title: '导入基础管理',
confirm:'确定导入【基础管理】中的【大类,客户来源,职务】吗?',
confirm:'确定导入【基础管理】中的【大类,客户来源,职务,到店项目,标签,模版内容】吗?',
classname: 'btn btn-xs btn-primary btn-ajax',
icon: 'fa fa-list',
url: 'firm/importBasic',

View File

@@ -27,6 +27,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'name', title: __('Name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'firm.full_name', title: '企业名称', operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]