工作框架各种使用整理 -- 展示数据列表并做update

时间:2023-03-08 16:32:04
 <!--ProductCategory.xml-->

 <?xml version="1.0" encoding="UTF-8"?>
<screen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/xml-screen-2.0.xsd"
default-menu-title="ProductCategory" default-menu-index="1"> <subscreens default-item="ProductCategoryList"/> <widgets>
<subscreens-panel id="productCategory-panel" type="popup" title="ProductCategory"/>
</widgets>
</screen>
 <!--ProductCategoryList.xml-->

 <?xml version="1.0" encoding="UTF-8"?>
<screen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/xml-screen-2.0.xsd"
default-menu-title="ProductCategoryList" default-menu-index="1"> <transition name="editProductCategoryContent"><default-response url="../EditProductCategoryContent"/></transition> <actions>
<entity-find entity-name="mantle.product.category.ProductCategory" list="productCategoryList">
<search-form-inputs />
</entity-find>
</actions>
<widgets>
<form-list name="ListProductCategory" list="productCategoryList">
<field name="productCategoryId">
<default-field>
<link url="editProductCategoryContent" text="${productCategoryId}"/>
</default-field>
</field>
<auto-fields-entity entity-name="mantle.product.category.ProductCategory" field-type="find-display" include="nonpk"/>
</form-list>
</widgets>
</screen>
 <!--EditProductCategoryContent.xml-->

 <?xml version="1.0" encoding="UTF-8"?>
<screen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/xml-screen-2.0.xsd"
default-menu-title="ProductCategoryList" default-menu-index="1">
<parameter name="productCategoryId" required="true"/> <transition name="updateProductCategoryContent"><service-call name="update#mantle.product.category.ProductCategoryContent"/>
<default-response url="."/></transition>
<transition name="deleteProductCategoryContent"><service-call name="delete#mantle.product.category.ProductCategoryContent"/>
<default-response url="."/></transition> <transition name="uploadProductCategoryContent">
<actions><script><![CDATA[
import org.moqui.context.ResourceReference
org.moqui.context.ExecutionContext ec = context.ec org.apache.commons.fileupload.FileItem contentFile = context.contentFile
String fileName = contentFile.getName()
ec.logger.info("Uploading file [${fileName}] for ProductCategory [${productCategoryId}] in repository [${repositoryName}] with content type [${categoryContentTypeEnumId}] and locale [${locale}]") // String contentLocation = "content://${repositoryName}/mantle/ProductCategory/${productCategoryId}/content/${fileName}"
String contentLocation = "dbresource://mantle/productCategory/${productCategoryId}/content/${fileName}"
ResourceReference newRr = ec.resource.getLocationReference(contentLocation)
InputStream fileStream = contentFile.getInputStream()
newRr.putStream(fileStream)
fileStream.close() ec.service.sync().name("create", "mantle.product.category.ProductCategoryContent").parameters([productCategoryId: productCategoryId,
contentLocation: contentLocation, categoryContentTypeEnumId: categoryContentTypeEnumId, locale: locale]).call()
]]></script></actions>
<default-response url="."/>
</transition> <actions>
<entity-find entity-name="mantle.product.category.ProductCategoryContent" list="productCategoryContentList">
<econdition field-name="productCategoryId" from="productCategoryId"/>
<order-by field-name="contentLocation"/>
</entity-find>
</actions>
<widgets>
<container>
<container-dialog id="UploadCategoryContentDialog" button-text="Upload Content">
<form-single name="UploadCategoryProductContent" transition="uploadProductCategoryContent">
<field name="productCategoryId"><default-field><hidden/></default-field></field>
<field name="contentFile"><default-field><file/></default-field></field>
<field name="categoryContentTypeEnumId"><default-field>
<drop-down><entity-options>
<entity-find entity-name="moqui.basic.Enumeration">
<econdition field-name="enumTypeId" value="ProductCategoryContentType"/>
<order-by field-name="description"/>
</entity-find>
</entity-options></drop-down>
</default-field></field>
<field name="locale"><default-field><text-line size="6"/></default-field></field>
<field name="submitButton"><default-field><submit confirmation="Really Add?"/></default-field></field>
</form-single>
</container-dialog>
</container>
<form-list name="ListProductCategoryContent" transition="updateProductCategoryContent" list="productCategoryContentList">
<field name="productCategoryContentId"><default-field><display/></default-field></field>
<field name="productCategoryId"><default-field><display/></default-field></field>
<field name="contentLocation"><default-field title="Location"><display/></default-field></field>
<field name="categoryContentTypeEnumId"><default-field title="Content Type">
<drop-down><entity-options><entity-find entity-name="moqui.basic.Enumeration">
<econdition field-name="enumTypeId" value="ProductCategoryContentType"/>
<order-by field-name="description"/>
</entity-find></entity-options></drop-down>
</default-field></field>
<field name="locale"><default-field><text-line size="6"/></default-field></field>
<field name="submitButton"><default-field title="Update"><submit/></default-field></field>
<field name="deleteLink">
<default-field title=" ">
<!-- the parameters for this will be auto-mapped: productId, contentLocation -->
<link url="deleteProductCategoryContent" text="Delete" confirmation="Really Delete?"/>
</default-field>
</field>
</form-list> </widgets>
</screen>