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.
114 lines
4.0 KiB
114 lines
4.0 KiB
<?php
|
|
defined('IN_IA') or exit('Access Denied');
|
|
/**
|
|
* Comment: 自定义表单控制器
|
|
* Author: zzw
|
|
* Class DiyForm_WeliamController
|
|
*/
|
|
class DiyForm_WeliamController{
|
|
/**
|
|
* Comment: 自定义表单列表
|
|
* Author: zzw
|
|
* Date: 2020/11/19 10:42
|
|
*/
|
|
public function index(){
|
|
global $_W,$_GPC;
|
|
//参数获取
|
|
$page = max(1 , intval($_GPC['page']));
|
|
$pageIndex = 10;
|
|
$pageStart = $page * $pageIndex - $pageIndex;
|
|
$title = $_GPC['title'] ? : '';//表单名称
|
|
//条件生成
|
|
$where = " WHERE a.uniacid = {$_W['uniacid']} AND a.aid = {$_W['aid']} ";
|
|
if(is_store()) $where .= " AND a.sid = {$_W['storeid']} ";
|
|
if($title) $where .= " AND a.title LIKE '%{$title}%'";
|
|
//列表信息获取
|
|
$field = "a.id,a.title,a.create_time,a.update_time,a.template_type,b.storename";
|
|
$sql = "SELECT {$field} FROM ".tablename(PDO_NAME."diyform")
|
|
." as a LEFT JOIN ".tablename(PDO_NAME."merchantdata")
|
|
." as b ON a.sid = b.id {$where}";
|
|
$list = pdo_fetchall($sql." ORDER BY a.update_time DESC,a.create_time DESC limit {$pageStart},{$pageIndex}");
|
|
foreach ($list as &$itemVal) {
|
|
$itemVal['template_type_title'] = FormTemplate::$template_type[$itemVal['template_type']];
|
|
}
|
|
//总数信息获取
|
|
$countSql = str_replace($field,"count(*)",$sql);
|
|
$total = pdo_fetchcolumn($countSql);
|
|
//分页操作
|
|
$pager = wl_pagination($total, $page, $pageIndex);
|
|
|
|
include wl_template('agentset/diy_form/list');
|
|
}
|
|
/**
|
|
* Comment: 添加|编辑 自定义表单
|
|
* Author: zzw
|
|
* Date: 2020/11/19 10:56
|
|
*/
|
|
public function edit(){
|
|
global $_W,$_GPC;
|
|
//参数信息获取
|
|
$id = $_GPC['id'] ? : '';
|
|
if($_W['aid'] == 0 && p('attestation')){
|
|
$attflag = 1;
|
|
}else{
|
|
$attflag = 0;
|
|
}
|
|
//添加储存/编辑修改 信息处理
|
|
if($_W['ispost']){
|
|
//参数信息获取
|
|
$data = $_GPC['data'] OR wl_json(0,'请添加组件');
|
|
$t_name = [];
|
|
foreach($data['list'] as $da){
|
|
$t_name[] = $da['data']['title'];
|
|
}
|
|
if (count($t_name) != count(array_unique($t_name))) {
|
|
wl_json(0,'组件请勿设置相同标题');
|
|
}
|
|
//信息拼装
|
|
$params = [
|
|
'title' => $data['base']['title'] ? : '自定义表单',
|
|
'template_type' => $data['base']['template_type'] ? : 1,
|
|
'info' => base64_encode(json_encode($data,JSON_UNESCAPED_UNICODE)),
|
|
'update_time' => time()
|
|
];
|
|
//判断是添加还是修改
|
|
if($id > 0){
|
|
//修改操作
|
|
pdo_update(PDO_NAME."diyform",$params,['id'=>$id]);
|
|
}else{
|
|
//添加操作
|
|
$params['uniacid'] = $_W['uniacid'];
|
|
$params['aid'] = $_W['aid'];
|
|
$params['create_time'] = time();
|
|
if(is_store()) $params['sid'] = $_W['storeid'];
|
|
pdo_insert(PDO_NAME."diyform",$params);
|
|
}
|
|
|
|
wl_json(1,$id > 0 ? '编辑成功' : '添加成功');
|
|
}
|
|
//id存在 编辑信息 获取表单信息
|
|
if($id > 0){
|
|
$info = pdo_getcolumn(PDO_NAME."diyform",['id'=>$id],'info');
|
|
$info = json_decode(base64_decode($info), true);//页面的配置信息
|
|
}
|
|
|
|
|
|
|
|
include wl_template('agentset/diy_form/edit');
|
|
}
|
|
/**
|
|
* Comment: 删除表单
|
|
* Author: zzw
|
|
* Date: 2020/11/19 10:58
|
|
*/
|
|
public function delete(){
|
|
global $_W,$_GPC;
|
|
//参数信息获取
|
|
$id = $_GPC['id'] OR show_json(0, '参数错误,请刷新重试!');
|
|
//删除内容
|
|
$res = pdo_delete(PDO_NAME."diyform",['id'=>$id]);
|
|
if ($res) show_json(1 , '删除成功');
|
|
else show_json(0 , '删除失败,请刷新重试');
|
|
}
|
|
|
|
}
|
|
|