<?xml version="1.0" encoding="utf-8" ?>
<select>
  <selectstr>
SELECT formulaid
	,formulakind
	,formulatype
	,sortcode
	,if_mtrl
	,formula
	,usetype
	,if_packtype0
	,if_packtype1
	,if_packtype2
	,default_mtrlid
	,createtime
	,createby
	,useformula
	,gydscrp
	,mtrltype
FROM u_mattress_formula
  </selectstr>
  <where>
	  <when notempty="@@arg_array_formulakind@@">
		  u_mattress_formula.formulakind IN (@@arg_array_formulakind@@)
	  </when>
	  <when notempty="@@arg_array_formulatype@@">
		  u_mattress_formula.formulatype IN (@@arg_array_formulatype@@)
	  </when>
	  <when notempty="@@arg_array_formulaid@@">
		  u_mattress_formula.formulaid IN (@@arg_array_formulaid@@)
	  </when>
	  <when notnull="@arrg_usetype">
		  u_mattress_formula.usetype = @arrg_usetype
	  </when>
  </where>
	<orderstr>
		formulatype, sortcode, 
		CASE
			WHEN formulakind = 2 THEN 1
			WHEN formulakind = 82 THEN 2
			WHEN formulakind = 42 THEN 3
			WHEN formulakind = 52 THEN 4
			WHEN formulakind = 62 THEN 5
			WHEN formulakind = 72 THEN 6
		END
	</orderstr>
  <displayfields>
    <field field="pid" compute="getrow()">序</field>
    <field field="formulatype" mapper="">类别</field>
    <field field="sortcode">类别序号</field>
    <field field="formulakind" mapper="">公式名</field>
    <field field="if_mtrl" mapper="">按物料</field>
    <field field="usetype" mapper="">公式应用分类</field>
    <field field="formula">金额公式</field>
    <field field="useformula">用量公式</field>
    <field field="if_packtype0" datatype="checkbox">压包</field>
    <field field="if_packtype1" datatype="checkbox">卷包</field>
    <field field="if_packtype2" datatype="checkbox">国内</field>
    <field field="default_mtrlid" mapper="mtrl_price">默认物料</field>
    <field field="mtrltype" mapper="mtrltypeid">物料类别</field>
    <field field="createby">登记人</field>
    <field field="createtime" datatype="datetime">登记时间</field>
    <field field="gydscrp">工艺说明</field>
  </displayfields>
</select>
