<?xml version="1.0" encoding="utf-8" ?>
<select>
	<selectstr>
		SELECT
		u_mtrl_price.mtrlid,
		u_mtrl_price.mtrltype,
		u_mtrl_price.name AS mtrlname,
		u_mtrl_price.priceunit,
		u_mtrl_price.shrinkage AS price,
		u_mtrl_price.gram_weight,
		u_mtrl_price.cloth_width,
		u_mtrl_price.if_inputqty,
		u_mtrl_price.if_areaprice,
		u_mtrl_price.thickness,
		u_mtrl_price.dscrp,
		u_mtrl_price.createtime,
		u_mtrl_price.createby,
		ISNULL(u_mtrl_price_pricelist.price, 0) AS pricelistprice,
		ISNULL(u_mtrl_price_pricelist.price_formula, '') AS price_formula,
		u_mtrl_price.erp_mtrlid,
		SPACE(200) AS erp_mtrlcode,
		SPACE(200) AS erp_mtrlname,
		SPACE(200) AS erp_mtrlmode,
		SPACE(200) AS erp_unit,
		SPACE(200) AS erp_mtrlengname
		FROM u_mtrl_price
		LEFT JOIN u_mtrl_price_pricelist ON u_mtrl_price.mtrlid = u_mtrl_price_pricelist.mtrlid
	</selectstr>
	<where>
		<when notnull="@keyword">
			u_mtrl_price.name like '%'+ @keyword + '%' OR u_mtrl_price.dscrp like '%'+ @keyword + '%' OR u_mtrl_price.mtrlid like '%'+ @keyword + '%'
		</when>
		<when>
			u_mtrl_price.isuse = 1
		</when>
		<when>
			u_mtrl_price.lastdate >= GETDATE()
		</when>
		<when notnull="@arg_mtrltype">
			u_mtrl_price.mtrltype = @arg_mtrltype 
			OR ( @arg_mtrltype = 200 AND u_mtrl_price.mtrlid IN (8727, 8728, 47414) )
		</when>
		<when notnull="@arg_pricelistid">
			u_mtrl_price_pricelist.pricelistid = @arg_pricelistid
			OR u_mtrl_price.mtrlid NOT IN (SELECT mtrlid FROM u_mtrl_price_pricelist WHERE pricelistid = @arg_pricelistid)
		</when>
		<when notnull="@arg_mtrlid">
			u_mtrl_price.mtrlid = @arg_mtrlid 
		</when>
	</where>
	<displayfields>
		<field field="pid" compute="getrow()">序</field>
		<field field="mtrlname">名称</field>
		<field field="thickness">厚度</field>
		<field field="priceunit">单位</field>
		<field field="pricelistprice" funcid="96">单价</field>
		<field field="dscrp" table="u_mtrl_price">备注</field>
		<field field="erp_mtrlcode">L1编码</field>
		<field field="erp_mtrlname">L1名称</field>
		<field field="erp_mtrlmode">L1规格</field>
		<field field="erp_unit">L1单位</field>
		<field field="erp_mtrlengname">L1英文名称</field>
	</displayfields>
</select>
