<?xml version="1.0" encoding="utf-8" ?>
<select>
	<selectstr>
		SELECT
		u_mattress_mx_mtrl.mattressmxid,
		u_mattress_mx_mtrl.mattressid,
		u_mattress_formula.formulakind as formulakind ,
		u_mattress_mx_mtrl.formula as  formula,
		u_mattress_mx_mtrl.formulaid,
		u_mattress_mx_mtrl.mtrlid,
		u_mattress_mx_mtrl.price,
		u_mattress_mx_mtrl.gram_weight,
		u_mattress_mx_mtrl.cloth_width,
		u_mattress_mx_mtrl.if_inputqty,
		u_mattress_mx_mtrl.qty ,
		u_mattress_mx_mtrl.costamt,
		u_mattress_mx_mtrl.if_areaprice,
		u_mattress_formula.formulatype,
		case when u_mattress_mx_mtrl.chastr <> '' then  u_mattress_mx_mtrl.chastr  else u_mattress_formula.sortcode end  as  sortcode,
		u_mattress_formula.if_mtrl,
		u_mattress_mx_mtrl.if_success,
		u_mattress_mx_mtrl.replace_formula,
		u_mattress_mx_mtrl.priceunit,
		u_mattress_mx_mtrl.shrinkage,
		CASE when u_mattress_formula.if_mtrl > 1 THEN '+' ELSE '' END as addmx,
		CASE when u_mattress_formula.if_mtrl > 1 THEN '-' ELSE '' END as delmx,
		u_mtrl_price.name,
		u_mattress_mx_mtrl.thickness,
		u_mattress_mx_mtrl.chastr,
		u_mattress_mx_mtrl.xu,
		u_mattress_mx_mtrl.costamt as useqty,
		u_mattress_mx_mtrl.useformula,
		u_mattress_mx_mtrl.replace_useformula,
		u_mattress_mx_mtrl.gydscrp

		From u_mattress_mx_mtrl
		Left join u_mattress_formula On u_mattress_formula.formulaid = u_mattress_mx_mtrl.formulaid left outer join u_mtrl_price on
		u_mattress_mx_mtrl.mtrlid = u_mtrl_price.mtrlid
	</selectstr>
	<where>
		<when notnull="@arg_mattressid">
			u_mattress_mx_mtrl.mattressid = @arg_mattressid
		</when>
		<when notnull="@arg_formulatype">
			u_mattress_formula.formulatype = @arg_formulatype
		</when>
	</where>
	<displayfields>
		<field field="pid" compute="getrow()">序</field>
		<field field="if_success" datatype="checkbox">
			计算
			成功?
		</field>
		<field field="formulakind" table="u_mattress_formula" mapper="" ddd="ddd_mattress_formula_formulakind_dc">公式名</field>
		<field field="chastr" mapper="u_mattress_mx_mtrl.dianceng_area" ddd="dddw_dianceng_area">位置</field>
		<field field="thickness" datatype="number">厚度cm</field>
		<field field="mtrlid" mapper="u_mattress_mx_mtrl.mtrl_price" ddd="ddd_mtrl_price">物料</field>
		<field field="qty" datatype="number">数量</field>
		<field field="price" datatype="number">
			物料
			单价
		</field>
		<field field="priceunit">单位</field>
		<field field="shrinkage" datatype="number">收缩率</field>
		<field field="gram_weight" datatype="number">克重</field>
		<field field="cloth_width" datatype="number">幅宽</field>
		<field field="if_inputqty" datatype="checkbox">
			固定
			厚度?
		</field>
		<field field="if_areaprice" datatype="checkbox">
			按面积
			单价？
		</field>
		<field field="costamt" datatype="number">
			成本
			金额
		</field>
		<field field="formula">
			金额文本
			公式
		</field>
		<field field="replace_formula">
			金额数字
			公式
		</field>
		<field field="useqty" datatype="number">清单用量</field>
		<field field="useformula">
			用量文本
			公式
		</field>
		<field field="replace_useformula">
			用量数字
			公式
		</field>
		<field field="gydscrp">工艺填写说明</field>
	</displayfields>
</select>
