优化编辑原名判断

master
chenzhi 3 years ago
parent a1fa0afee5
commit f7296408c7

@ -134,13 +134,19 @@ class StatementWarningController extends AdminController
}
unset($data[$type]['list'][$name]);
if(isset($this->statementWarningKey[$name])){
if( in_array($name,['margin_ratio','profit_ratio']) ){
$data[$type]['list'][$name]['is_edit'] = 0;
}else{
$data[$type]['list'][$name]['is_edit'] = 1;
}
$data[$type]['list'][$name]['name'] = $this->statementWarningKey[$name];
$data[$type]['list'][$name]['list'] = $value;
$data[$type]['list'][$name]['is_edit'] = 0;
$data[$type]['list'][$name]['is_del'] = 0;
}else{
$data[$type]['list'][$name]['name'] = $name;
$data[$type]['list'][$name]['list'] = $value;
$data[$type]['list'][$name]['is_edit'] = 1;
$data[$type]['list'][$name]['is_del'] = 1;
}
}
}
@ -168,6 +174,7 @@ class StatementWarningController extends AdminController
if($act == 'add'){
$isEdit = 0;
$this->assign('is_edit', 0);
$this->assign('chenge_name', 1);
}else{
$this->assign('is_edit', 1);
}
@ -222,22 +229,32 @@ class StatementWarningController extends AdminController
}
private function resetWarningData()
{
//获取真实名称
$name = $_REQUEST['name'];
$sendData = [
'value'=>[0,0,0,0,0,0,0,0,0,0,0,0],
'ids'=>[0,0,0,0,0,0,0,0,0,0,0,0],
'chenge_name'=>1,
'count_year'=>$_REQUEST['count_year']
];
$key = array_flip($this->statementWarningKey);
if(isset($key[$_REQUEST['name']])){
$sendData['chenge_name'] = 0;
$sendData['orgin_name'] = $key[$_REQUEST['name']];
$sendData['name'] = $name;
$name = $key[$_REQUEST['name']];
}else{
$sendData['orgin_name'] = $name;
$sendData['name'] = $name;
}
$where = [
'name'=>$_REQUEST['name'],
'name'=>$name,
'count_year'=>$_REQUEST['count_year']
];
$data = $this->statementWarningModel->where($where)->select();
$sendData = [
'count_year'=>$data[0]['count_year'],
'type'=>$data[0]['type'],
'name'=>$data[0]['name'],
'value'=>[0,0,0,0,0,0,0,0,0,0,0,0],
'ids'=>[0,0,0,0,0,0,0,0,0,0,0,0]
];
$sendData['type'] = $data[0]['type'];
foreach ($data as $key => $value) {
$sendData['value'][$value['count_month']-1] = $value['money']/10000;
$sendData['value'][$value['count_month']-1] = round($value['money']/10000,2);
$sendData['ids'][$value['count_month']-1] = $value['id'];
}
$this->assign('data', $sendData);

@ -104,11 +104,10 @@
<if condition="$is_edit eq 1">
<input type="text" name="year" value="{$data['count_year']}" style="display: none;">
<input type="text" name="type" value="{$data['type']}" style="display: none;">
<if condition="$data['chenge_name'] eq 0">
<input type="text" name="name" value="{$data['orgin_name']}" style="display: none;">
</if>
<if condition="($data['name'] eq '费用') OR ($data.name eq '其他收入')">
<input type="text" name="name" value="{$data['name']}" style="display: none;">
</if>
<tr>
<td class="l"><i class="mustmark">*</i>年度:</td>
<td class="r table_radio">
@ -138,7 +137,7 @@
<td class="l"><i class="mustmark">*</i>类型名称:</td>
<td class="r table_radio">
<div style="float: left;">
<input type="text" class="txt ratio" name="name" id="name" value="{$data['name']}" placeholder="请输入名称" style="width: 150px;" <if condition="($data['name'] eq '费用') OR ($data.name eq '其他收入')">disabled</if>>
<input type="text" class="txt ratio" name="name" id="name" value="{$data['name']}" placeholder="请输入名称" style="width: 150px;" <if condition="($data['chenge_name'] eq 0) AND ($is_edit eq 1)">disabled</if>>
</div>
</td>
</tr>

@ -124,10 +124,9 @@
<td>
<if condition="$vo.is_edit eq 1 ">
<a href="{:U('edit?act=edit',array('name'=>$vo['name'],'count_year'=>I('year')))}">编辑</a>
<if condition="($vo['name'] neq '费用') AND ($vo.name neq '其他收入')">
<a style="color: red;" href="{:U('del',array('name'=>$vo['name'],'count_year'=>I('year')))}" class="confirm ajax-get">删除</a>
</if>
<if condition="$vo.is_del eq 1 ">
<a style="color: red;" href="{:U('del',array('name'=>$vo['name'],'count_year'=>I('year')))}" class="confirm ajax-get">删除</a>
</if>
</td>
</tr>

Loading…
Cancel
Save