Commit 2b3965b4 by 宋春膨

feat(ckgl): 添加仓库管理采购到货功能模块

- 创建 CgdhModal 组件实现采购到货的新增、编辑、查看功能
- 定义 MesWarehouseArrived 相关数据模型和接口类型
- 配置采购到货表单的字段、布局和验证规则
- 实现表单的数据加载、验证、提交和保存功能
- 添加子表单物料明细的展示和操作功能
- 集成上传附件组件和自定义按钮功能
- 实现单据的复制、重置等操作功能
parent b86528fa
import {
http
} from '@/common/request/index.js'; // 局部引入
const api = {
Page : '/ckgl/pcgl/page',
List : '/ckgl/pcgl/list',
Info : '/ckgl/pcgl/info',
MesWarehouseBatch : '/ckgl/pcgl'
}
/**
* 根据参数 查询MesWarehouseBatch分页列表
* @param {Object} params - 查询参数
*/
export const getMesWarehouseBatchPage = (params) => {
return http.get(api.Page, {
params
})
}
/**
* 根据参数 查询MesWarehouseBatch列表
* @param {Object} params - 查询参数
*/
export const getMesWarehouseBatchList = (params) => {
return http.get(api.List, {
params
})
}
/**
* 获取MesWarehouseBatch信息
* @param {Object} params - id
*/
export const getMesWarehouseBatch = (id) => {
return http.get(api.Info, {
params: { id },
})
}
/**
* 新增MesWarehouseBatch
* @param {Object} params - 表单数据
*/
export const addMesWarehouseBatch = (formData) => {
return http.post(api.MesWarehouseBatch, formData)
}
/**
* 修改MesWarehouseBatch
* @param {Object} params - 表单数据
*/
export const updateMesWarehouseBatch = (formData) => {
return http.put(api.MesWarehouseBatch, formData)
}
/**
* 删除MesWarehouseBatch(批量删除)
* @param {Object} params - 表单数据
*/
export const deleteMesWarehouseBatch = (ids) => {
return http.delete(api.MesWarehouseBatch, ids)
}
import {
http
} from '@/common/request/index.js'; // 局部引入
const api = {
Page : '/scgl/scjh/page',
List : '/scgl/scjh/list',
Info : '/scgl/scjh/info',
MesProductionPlan : '/scgl/scjh'
}
/**
* 根据参数 查询MesProductionPlan分页列表
* @param {Object} params - 查询参数
*/
export const getMesProductionPlanPage = (params) => {
return http.get(api.Page, {
params
})
}
/**
* 根据参数 查询MesProductionPlan列表
* @param {Object} params - 查询参数
*/
export const getMesProductionPlanList = (params) => {
return http.get(api.List, {
params
})
}
/**
* 获取MesProductionPlan信息
* @param {Object} params - id
*/
export const getMesProductionPlan = (id) => {
return http.get(api.Info, {
params: { id },
})
}
/**
* 新增MesProductionPlan
* @param {Object} params - 表单数据
*/
export const addMesProductionPlan = (formData) => {
return http.post(api.MesProductionPlan, formData)
}
/**
* 修改MesProductionPlan
* @param {Object} params - 表单数据
*/
export const updateMesProductionPlan = (formData) => {
return http.put(api.MesProductionPlan, formData)
}
/**
* 删除MesProductionPlan(批量删除)
* @param {Object} params - 表单数据
*/
export const deleteMesProductionPlan = (ids) => {
return http.delete(api.MesProductionPlan, ids)
}
import {
getMesWarehouseBatchPage,
deleteMesWarehouseBatch
} from '@/common/api/ckgl/pcgl/index.js';
import {
componentType,
datasourceTypeEnum
} from '@/components/simple-form/types/form.js'
export const listProps = {
rowKey:'id',
//列表请求接口
api: getMesWarehouseBatchPage,
// 请求之前处理参数 (params) => {}
beforeFetch: (params) => {
for(let key in params){
if(key.includes(',')){
delete params[key]
}
}
params.PK='id'
params.FormId='2009150321167294464'
return params
},
// 自定义处理接口返回参数
afterFetch: (data) => {
return data
},
//数据源 静态
datasource: [],
workflowConfig:{
Pk:'id',
Formid:'2009150321167294464'
},
//列配置
columnConfigs: [
{
title: '单件/批次号',
mainField:false,
showLabel:true,
componentType:'AutoCode',
field: 'pch',
},{
title: '客户/供应商',
mainField:false,
showLabel:true,
componentType:'Select',
field: 'gys',
},{
title: '产品',
mainField:false,
showLabel:true,
componentType:'Select',
field: 'cp',
},{
title: '数量',
mainField:false,
showLabel:true,
componentType:'InputNumber',
field: 'sl',
},{
title: '成本单价',
mainField:false,
showLabel:true,
componentType:'InputNumber',
field: 'cbdj',
},{
title: '入库日期',
mainField:false,
showLabel:true,
componentType:'DateTime',
field: 'createDate',
}
],
//是否启用搜索
isSearch: true,
//是否分页
isPage: true,
pageSize: 10,
//分类筛选配置
categoryConfigs:"",
//搜索配置
searchConfigs: [{
key: '1d3aace87f304d42a108e5152f8c8345',
name: '单件/批次号',
label: '单件/批次号',
field: 'pch',
component: componentType.input, //组件类型
componentProps: {
placeholder: '请输入单件/批次号',
}
},
{
key: 'd132722378d64da6838371444968271b',
name: '客户/供应商',
label: '客户/供应商',
field: 'gys',
component: componentType.select, //组件类型
componentProps: {"placeholder":"请选择客户/供应商","isShow":true,"apiConfig":{"method":"GET","path":"/bmxx/getCompanyList","requestParamsConfigs":[],"requestHeaderConfigs":[],"requestBodyConfigs":[]},"map":{"text":"label","value":"value"},"multiple":false,"isSearch":false},
},
{
key: '63fb36d6b45d41fe8d984d637336af7b',
name: '产品',
label: '产品',
field: 'cp',
component: componentType.select, //组件类型
componentProps: {"placeholder":"请选择产品","isShow":true,"apiConfig":{"method":"GET","path":"/scgl/scjh/getAllProduct","requestParamsConfigs":[],"requestHeaderConfigs":[],"requestBodyConfigs":[]},"map":{"text":"label","value":"value"},"multiple":false,"isSearch":false},
},],
//表单页面地址
formUrl: '/pages/ckgl/pcgl/container',
//列表页面地址
listUrl: '/pages/ckgl/pcgl/list',
//按钮配置
otherButtons:[
{
text: '查看',
isUse:true,
code:'pcgl:view',
},
{
text: '新增',
isUse:true,
code:'pcgl:add',
},
{
text: '发起审批',
isUse:false,
code:'pcgl:startwork',
}],
buttonConfigs: [{
code: 'pcgl:edit',
icon: 'ant-design:edit-square',
color:'#5E95FF',
text: '编辑',
action: (record) =>{
uni.navigateTo({
url: listProps.formUrl + '?type=edit&id=' + record[listProps.rowKey],
});
}
},{
code: 'pcgl:delete',
icon: 'ant-design:delete-outlined',
color:'#EF6969',
text: '删除',
action: async (record, { reload }) => {
await deleteMesWarehouseBatch ([record[listProps.rowKey]]);
reload()
//请求删除接口
uni.showToast({
title: "删除成功"
})
}
}],
formEventConfig:{"0":[],"1":[],"2":[],"3":[],"4":[]}
}
export const formProps = {"validateTrigger":"submit","labelPosition":"left","labelWidth":75,"labelAlign":"right","errShowType":"undertext","border":false,"schemas":[{"key":"1d3aace87f304d42a108e5152f8c8345","field":"pch","label":"单件/批次号","component":"AutoCode","componentProps":{"autoCodeRule":"pcbh","placeholder":"自动生成","prefixIcon":"","suffixIcon":"","addonBefore":"","addonAfter":"","isShow":true},"required":false,"rules":[],"name":"单件/批次号","ifShow":true},{"key":"d132722378d64da6838371444968271b","field":"gys","label":"客户/供应商","component":"Select","defaultValue":"","componentProps":{"placeholder":"请选择客户/供应商","isShow":true,"apiConfig":{"method":"GET","path":"/bmxx/getCompanyList","requestParamsConfigs":[],"requestHeaderConfigs":[],"requestBodyConfigs":[]},"map":{"text":"label","value":"value"},"multiple":false,"isSearch":false},"required":false,"rules":[],"name":"客户/供应商","ifShow":true,"dynamicDisabled":false,"events":{}},{"key":"63fb36d6b45d41fe8d984d637336af7b","field":"cp","label":"产品","component":"Select","defaultValue":"","componentProps":{"placeholder":"请选择产品","isShow":true,"apiConfig":{"method":"GET","path":"/scgl/scjh/getAllProduct","requestParamsConfigs":[],"requestHeaderConfigs":[],"requestBodyConfigs":[]},"map":{"text":"label","value":"value"},"multiple":false,"isSearch":false},"required":true,"rules":[{"required":true,"errorMessage":"产品项必填"}],"name":"产品","ifShow":true,"dynamicDisabled":false,"events":{}},{"key":"4cbb4a0b76b94de4b0cd50e332d57f90","field":"sl","label":"数量","component":"InputNumber","defaultValue":0,"componentProps":{"min":0,"max":null,"step":1,"maxlength":-1,"isShow":true},"required":false,"rules":[],"name":"数量","ifShow":true,"dynamicDisabled":true,"events":{}},{"key":"a2fa14e2600a48dcbe977b55fe004157","field":"cbdj","label":"成本单价","component":"InputNumber","defaultValue":0,"componentProps":{"min":0,"max":null,"step":1,"maxlength":-1,"isShow":true},"required":false,"rules":[],"name":"成本单价","ifShow":true,"dynamicDisabled":false,"events":{}},{"key":"b929322dd8924750a29077e7308d1259","field":"createDate","label":"入库日期","component":"DateTime","componentProps":{"clearIcon":false,"placeholder":"请选择入库日期","type":"datetime","formatType":"datetime","isShow":true},"required":false,"rules":[],"name":"入库日期","ifShow":true,"dynamicDisabled":true,"events":{}},{"key":"cde52e0a23ef4208987f60559bff0681","field":"ysph","label":"原始批号","component":"Input","componentProps":{"placeholder":"请输入原始批号","prefixIcon":"","suffixIcon":"","addonBefore":"","addonAfter":"","clearable":false,"maxlength":-1,"isShow":true},"required":false,"rules":[],"name":"原始批号","ifShow":true,"dynamicDisabled":false,"events":{}},{"key":"e6a4af149da54b6baebcb250a9d2c66d","field":"bz","label":"备注说明","component":"Input","componentProps":{"type":"textarea","placeholder":"请输入备注说明","maxlength":-1,"showCount":false,"autoHeight":false,"clearable":false,"isShow":true},"required":false,"rules":[],"name":"备注说明","ifShow":true,"dynamicDisabled":false,"events":{}}],"rules":[]};
<template>
<view>
<PageHead :title="routeTitle" backUrl=""></PageHead>
<view class="form-container">
<view class="form-box">
<Form ref="formRef" :disabled="formConfig.isView" :id="formConfig.id" :type="formConfig.type" :options="options"></Form>
<view v-if="!formConfig.isView" class="form-btn-box">
<button type="default" class="button" @click="reset">重置</button>
<button type="primary" class="button" @click="submit">确定</button>
</view>
</view>
</view>
</view>
</template>
<script setup>
import { ref, reactive } from 'vue';
import Form from './form.vue';
import { onLoad } from '@dcloudio/uni-app';
import PageHead from "@/components/layout/PageHead.vue";
import { FromPageType } from "@/common/enums/form.ts";
import { getFormTitle } from "@/common/hooks/form.ts";
import { listProps } from './config/index.js'
const formRef = ref(); //表单ref
const routeTitle = ref('表单信息');
const options=ref({});
const formConfig = reactive({
type:FromPageType.ADD,
id:'',
isView:false
});
onLoad(async (option) => {
options.value=option;
formConfig.id = option.id??'';
formConfig.type = option.type;
let title = getFormTitle(formConfig.type);
routeTitle.value =title;
uni.setNavigationBarTitle({title:title});
formConfig.isView = false;
if(formConfig.type==FromPageType.VIEW){
formConfig.isView = true;
}
});
async function submit(){
let saveVal = await formRef.value.submit();
if(saveVal){
if(formConfig.type==FromPageType.ADD){
uni.showToast({
title: '新增成功'
});
}else if(formConfig.type==FromPageType.EDIT){
uni.showToast({
title: '修改成功'
});
}
uni.navigateTo({
url: listProps.listUrl
});
}
}
async function reset(){
formRef.value.reset();
}
</script>
<style>
page{
background: #fff;
}
</style>
<template>
<view>
<SimpleForm ref="formRef" :formProps="formConfig.formProps" :disabled="disabled" :control="formConfig.type" :options="options"></SimpleForm>
</view>
</template>
<script setup>
import { ref, reactive,onMounted } from 'vue';
import SimpleForm from '@/components/simple-form/SimpleForm.vue';
import { formProps } from './config/index.js';
import { FromPageType } from "@/common/enums/form.ts";
import { listProps } from './config/index.js'
import { addMesWarehouseBatch, updateMesWarehouseBatch, getMesWarehouseBatch } from '@/common/api/ckgl/pcgl/index.js';
import { cloneDeep } from '@/utils/helper/utils.js';
import { handlerFormPermission } from "@/common/hooks/form.ts";
import { setFormPropsAuth } from '@/utils/simpleForm/changeJson.js'
const props = defineProps({
disabled: {
type:Boolean,
default:false
},
type: {
type:String,
default:FromPageType.ADD
},
id: {
type:String,
default:''
},
isWorkFlow:{
type:Boolean,
default:false
},
formModel: {
type:Object
},
workFlowParams: {
type:Object
},
options:Object
});
const rowKey = listProps.rowKey;
const formConfig = reactive({
formProps:formProps,
id:"",
uploadComponentIds:[],
type:FromPageType.ADD
});
const formRef = ref();
onMounted(async () => {
formConfig.id = props.id;
formConfig.type = props.type;
if(props.isWorkFlow){
formConfig.type = props.workFlowParams.type;
if( props.formModel&&props.formModel[rowKey]){
formConfig.type = FromPageType.EDIT;
formConfig.id = props.formModel[rowKey];
}
if(props.disabled) formConfig.type = FromPageType.VIEW;
setWorkflowFormData(formProps);
await formRef.value.setFormData( props.formModel )
}else{
let auth=uni.getStorageSync('MenuAuth')
let formAuth=auth.formAuthCode||[];
setFormPropsAuth(formConfig.formProps.schemas,formAuth)
await setForm();
}
})
async function setForm(){
// 编辑
if (formConfig.type == FromPageType.EDIT||formConfig.type == FromPageType.VIEW) {
const {
data
} = await getMesWarehouseBatch(formConfig.id);
if (data) {
await formRef.value.setFormData({...data,...props.formModel})
}
}
//新增
else if (formConfig.type == FromPageType.ADD) {
await formRef.value.init()
}
if(formConfig.type== FromPageType.EDIT){
//获取表单数据
if(listProps.formEventConfig&&listProps.formEventConfig[1]){
formRef.value.executeFormEvent(listProps.formEventConfig[1],false);
}
}
//初始化表单
if(listProps.formEventConfig&&listProps.formEventConfig[0]){
formRef.value.executeFormEvent(listProps.formEventConfig[0],false);
}
//加载表单
if(listProps.formEventConfig&&listProps.formEventConfig[2]){
formRef.value.executeFormEvent(listProps.formEventConfig[2],false);
}
}
// 工作流设置表单数据
async function setWorkflowForm(){
if(props.isWorkFlow){
setWorkflowFormData(formProps);
}
// formConfig.type
await setForm();
}
// 工作流辅助设置表单数据
function setWorkflowFormData(formProps){
let options = cloneDeep(formProps);
let otherParams = {...props.workFlowParams.otherParams,uploadComponentIds:formConfig.uploadComponentIds}
let obj = handlerFormPermission(
options,
props.workFlowParams.formConfigChildren,
props.workFlowParams.formConfigKey,
otherParams
);
formRef.value.updateSchema(obj.buildOptionJson.schemas)
formConfig.uploadComponentIds = obj.otherParams.uploadComponentIds;
}
// 获取上传组件Id集合
function getUploadComponentIds(){
return formConfig.uploadComponentIds
}
// 校验
async function validate() {
await formRef.value.validate();
}
// 提交
async function submit() {
let formModelIdVal = {};
try {
await formRef.value.validate();
const formData = await formRef.value.getFormData();
if(formConfig.type == FromPageType.EDIT){
formData[listProps.rowKey]=formConfig.id;
await updateMesWarehouseBatch(formData);
formModelIdVal[listProps.rowKey]=formConfig.id;
}
else{
let res = await addMesWarehouseBatch(formData);
formModelIdVal[listProps.rowKey]=res.data;
}
} catch (err) {
return;
}
//提交表单事件
if(listProps.formEventConfig&&listProps.formEventConfig[3]){
formRef.value.executeFormEvent(listProps.formEventConfig[3],false);
}
return formModelIdVal;
}
// 重置
async function reset() {
await formRef.value.reset();
}
// 表单初始化
async function init() {
await formRef.value.init();
}
// 设置表单数据
async function setFormData(formModels) {
await formRef.value.setFormData(formModels);
}
// 获取表单数据
async function getFormData() {
let formModelObj = await formRef.value.getFormData();
if(formConfig.type == FromPageType.EDIT||formConfig.type == FromPageType.VIEW){
formModelObj[listProps.rowKey]=formConfig.id;
}
return formModelObj;
}
defineExpose({
init,
submit,
reset,
setFormData,
validate,
getFormData,
setWorkflowForm,
getUploadComponentIds
});
</script>
<style>
page{
background: #fff;
}
</style>
<template>
<SimpleList ref="listRef" :routeTitle="routeTitle" :listProps="listProps">
<template v-slot:buttonSlot="{rowData}">
<!-- 当前行数据{{rowData}} -->
<!-- 自定义按钮
<view class="uni-select__selector-item" v-if="auth.buttonAuthCode.includes('自定义按钮权限名称')">
<view class="item-text">
自定义按钮
</view>
</view>
-->
</template>
</SimpleList>
</template>
<script setup>
import { ref } from 'vue';
import { onReachBottom, onPullDownRefresh,onShow } from '@dcloudio/uni-app'; //不支持onLoad
import SimpleList from '@/components/simple-list/SimpleList.vue';
import { listProps } from './config/index.js'
onReachBottom(() => {
// 必须要这个事件 可以不写逻辑
});
const listRef = ref();
const firstLoad = ref(true);
const routeTitle = ref('列表');
let auth=uni.getStorageSync('MenuAuth')
onShow(()=>{
const pages = getCurrentPages();
if(pages&&Array.isArray(pages)&&pages.length>0){
const currentPage = pages[pages.length - 1];
if(currentPage&&currentPage.$page&&currentPage.$page.meta&&currentPage.$page.meta.navigationBar&&currentPage.$page.meta.navigationBar.titleText){
const title = currentPage.$page.meta.navigationBar.titleText;
routeTitle.value = title;
}
}
if (firstLoad.value) {
firstLoad.value = !firstLoad.value;
return;
}
listRef.value.reload();
})
</script>
<style></style>
\ No newline at end of file
import {
getMesProductionPlanPage,
deleteMesProductionPlan
} from '@/common/api/scgl/scjh/index.js';
import {
componentType,
datasourceTypeEnum
} from '@/components/simple-form/types/form.js'
export const listProps = {
rowKey:'id',
//列表请求接口
api: getMesProductionPlanPage,
// 请求之前处理参数 (params) => {}
beforeFetch: (params) => {
for(let key in params){
if(key.includes(',')){
delete params[key]
}
}
params.PK='id'
params.FormId='2004396568728281088'
return params
},
// 自定义处理接口返回参数
afterFetch: (data) => {
return data
},
//数据源 静态
datasource: [],
workflowConfig:{
Pk:'id',
Formid:'2004396568728281088'
},
//列配置
columnConfigs: [
{
title: '计划编号',
mainField:false,
showLabel:true,
componentType:'Input',
field: 'jhbh',
},{
title: '订单编号',
mainField:false,
showLabel:true,
componentType:'Input',
field: 'ddbh',
},{
title: '客户',
mainField:false,
showLabel:true,
componentType:'Input',
field: 'kh',
},{
title: '计划交付日期',
mainField:false,
showLabel:true,
componentType:'DateTime',
field: 'jhjhrq',
},{
title: '状态',
mainField:false,
showLabel:true,
componentType:'Select',
field: 'zt',
}
],
//是否启用搜索
isSearch: true,
//是否分页
isPage: true,
pageSize: 10,
//分类筛选配置
categoryConfigs:"",
//搜索配置
searchConfigs: [{
key: 'bb401260571f476c9816266b858aa2fa',
name: '计划编号',
label: '计划编号',
field: 'jhbh',
component: componentType.input, //组件类型
componentProps: {
placeholder: '请输入计划编号',
}
},
{
key: '0cad80076f6347b5966ef3d246d23165',
name: '订单编号',
label: '订单编号',
field: 'ddbh',
component: componentType.input, //组件类型
componentProps: {
placeholder: '请输入订单编号',
}
},
{
key: 'f7ae7fe08ec74cf6b91cd3cd35cfeaaf',
name: '状态',
label: '状态',
field: 'zt',
component: componentType.select, //组件类型
componentProps: {"placeholder":"请选择下拉选择","isShow":false,"itemId":"2004464883576217601","map":{"text":"name","value":"value"},"multiple":false,"isSearch":false},
},],
//表单页面地址
formUrl: '/pages/scgl/scjh/container',
//列表页面地址
listUrl: '/pages/scgl/scjh/list',
//按钮配置
otherButtons:[
{
text: '查看',
isUse:true,
code:'scjh:view',
},
{
text: '新增',
isUse:true,
code:'scjh:add',
},
{
text: '发起审批',
isUse:false,
code:'scjh:startwork',
},
{
text: '下发任务',
isUse:true,
code:'scjh:xiafa',
}],
buttonConfigs: [{
code: 'scjh:edit',
icon: 'ant-design:edit-square',
color:'#5E95FF',
text: '编辑',
action: (record) =>{
uni.navigateTo({
url: listProps.formUrl + '?type=edit&id=' + record[listProps.rowKey],
});
}
},{
code: 'scjh:delete',
icon: 'ant-design:delete-outlined',
color:'#EF6969',
text: '删除',
action: async (record, { reload }) => {
await deleteMesProductionPlan ([record[listProps.rowKey]]);
reload()
//请求删除接口
uni.showToast({
title: "删除成功"
})
}
},{
code: 'more',
icon: 'ant-design:lipsis-outlined',
color: '#5E95FF',
text: '更多',
buttons: [{"buttonId":"2004471125057142784","name":"下发任务","code":"xiafa","icon":"ant-design:export-outlined","isDefault":false,"isUse":true,"setting":[],"showType":"top","buttonType":"primary","isEnableLock":null,"schemaInitConfig":null,"apiConfig":null,"modal":null}],
action: async (record, { showMoreButton }) => {
showMoreButton(record[listProps.rowKey])
},
}],
formEventConfig:{"0":[],"1":[],"2":[],"3":[],"4":[]}
}
export const formProps = {"validateTrigger":"submit","labelPosition":"left","labelWidth":75,"labelAlign":"right","errShowType":"undertext","border":false,"schemas":[{"key":"bb401260571f476c9816266b858aa2fa","field":"jhbh","label":"计划编号","component":"Input","componentProps":{"placeholder":"请输入计划编号","prefixIcon":"","suffixIcon":"","addonBefore":"","addonAfter":"","clearable":false,"maxlength":-1,"isShow":true},"required":true,"rules":[{"required":true,"errorMessage":"计划编号项必填"}],"name":"计划编号","ifShow":true,"dynamicDisabled":false,"events":{}},{"key":"cde76649b62b4db4a820c7fccfe2810c","field":"khxmh","label":"客户项目号","component":"Input","componentProps":{"placeholder":"请输入客户项目号","prefixIcon":"","suffixIcon":"","addonBefore":"","addonAfter":"","clearable":false,"maxlength":-1,"isShow":true},"required":false,"rules":[],"name":"客户项目号","ifShow":true,"dynamicDisabled":false,"events":{}},{"key":"253e91345aeb4346b0081560c11c9420","field":"sfnbdd","label":"是否内部订单","component":"Radio","defaultValue":"option 1","componentProps":{"isShow":true,"localdata":[{"key":2,"label":"是","value":"1"},{"key":3,"label":"否","value":"2"}],"map":{"text":"label","value":"value"},"mode":"default"},"required":true,"rules":[{"required":true,"errorMessage":"是否内部订单项必填"}],"name":"是否内部订单","ifShow":true,"dynamicDisabled":false,"events":{}},{"key":"0cad80076f6347b5966ef3d246d23165","field":"ddbh","label":"订单编号","component":"Input","componentProps":{"placeholder":"请输入订单编号","prefixIcon":"","suffixIcon":"","addonBefore":"","addonAfter":"","clearable":false,"maxlength":-1,"isShow":true},"required":false,"rules":[],"name":"订单编号","ifShow":true,"dynamicDisabled":false,"events":{}},{"key":"7db6a62a09e347149a3110719726e010","field":"jhjhrq","label":"计划交付日期","component":"DateTime","componentProps":{"clearIcon":true,"placeholder":"请选择计划交付日期","type":"datetime","formatType":"datetime","isShow":true},"required":false,"rules":[],"name":"计划交付日期","ifShow":true,"dynamicDisabled":false,"events":{}},{"key":"c40beca261124a17b8ea5258ae8b1b82","field":"jsyq","label":"技术要求","component":"FileUpload","defaultValue":"","componentProps":{"showType":"text","fileExtname":[],"limit":5,"multiple":false,"maxSize":"","sourceType":["album","camera"],"isShow":true},"required":false,"rules":[],"name":"技术要求","ifShow":true,"dynamicDisabled":false,"events":{}},{"key":"105fe8a606b74e0ca90ea9ff1d20b648","field":"kh","label":"客户","component":"Input","componentProps":{"placeholder":"请输入客户","prefixIcon":"","suffixIcon":"","addonBefore":"","addonAfter":"","clearable":false,"maxlength":-1,"isShow":true},"required":false,"rules":[],"name":"客户","ifShow":true,"dynamicDisabled":false,"events":{}},{"key":"6833bea0c42c432b83e6946695f2d723","field":"ssgs","label":"所属公司","component":"Select","componentProps":{"placeholder":"请选择下拉选择","isShow":true,"apiConfig":{"method":"GET","path":"/bmxx/getCompanyList","requestParamsConfigs":[],"requestHeaderConfigs":[],"requestBodyConfigs":[]},"map":{"text":"label","value":"value"},"multiple":false,"isSearch":false},"required":false,"rules":[],"name":"所属公司","ifShow":true,"dynamicDisabled":false,"events":{}},{"field":"mesProductionPlanProductList","key":"24ea4c6631d047a1a8e7c3fe86ab080c","name":"表格组件","component":"SubForm","columns":[{"key":"416cd1b15c314d0dafaf6fc91e3f4653","field":"cpid","label":"产品选择","component":"AssociatePopup","componentProps":{"placeholder":"请选择产品选择","isShow":true,"apiConfig":{"method":"GET","path":"/scgl/scjh/getAllProduct","requestParamsConfigs":[],"requestHeaderConfigs":[],"requestBodyConfigs":[]},"map":{"text":"label","value":"value"},"associateOptions":[{"name":"cpmc","tableTitle":"产品名称","bindField":"","show":true,"width":150},{"name":"cpbh","tableTitle":"物料编号","bindField":"cpbh","show":true,"width":150,"component":"cd0038f42bc64c189b3821f0e2061321","bindTable":"mes_production_plan_product"},{"name":"nbdm","tableTitle":"内部代码","bindField":"nbdm","show":true,"width":150,"component":"6ce71ecb0b6e4d14ae65be4029b179fd","bindTable":"mes_production_plan_product"},{"name":"xh","tableTitle":"型号","bindField":"xh","show":true,"width":150,"component":"0c075736898c431ea3f5bca58ec65af6","bindTable":"mes_production_plan_product"},{"name":"gg","tableTitle":"规格","bindField":"gg","show":true,"width":150,"component":"2f56d9297a9c49d59d3b43f62e2946f2","bindTable":"mes_production_plan_product"},{"name":"hjzt","tableTitle":"合金状态","bindField":"hjzt","show":true,"width":150,"component":"697829b6aed54b8cbaa853c62619831a","bindTable":"mes_production_plan_product"}]},"required":false,"rules":[],"name":"产品选择","ifShow":true,"dynamicDisabled":false,"events":{}},{"key":"cd0038f42bc64c189b3821f0e2061321","field":"cpbh","label":"物料编号","component":"Input","componentProps":{"placeholder":"请输入物料编号","prefixIcon":"","suffixIcon":"","addonBefore":"","addonAfter":"","clearable":false,"maxlength":-1,"isShow":true},"required":false,"rules":[],"name":"物料编号","ifShow":true,"dynamicDisabled":false,"events":{}},{"key":"6ce71ecb0b6e4d14ae65be4029b179fd","field":"nbdm","label":"内部代码","component":"Input","componentProps":{"placeholder":"请输入内部代码","prefixIcon":"","suffixIcon":"","addonBefore":"","addonAfter":"","clearable":false,"maxlength":-1,"isShow":true},"required":false,"rules":[],"name":"内部代码","ifShow":true,"dynamicDisabled":false,"events":{}},{"key":"0c075736898c431ea3f5bca58ec65af6","field":"xh","label":"型号","component":"Input","componentProps":{"placeholder":"请输入型号","prefixIcon":"","suffixIcon":"","addonBefore":"","addonAfter":"","clearable":false,"maxlength":-1,"isShow":true},"required":false,"rules":[],"name":"型号","ifShow":true,"dynamicDisabled":false,"events":{}},{"key":"697829b6aed54b8cbaa853c62619831a","field":"hjzt","label":"合金状态","component":"Input","componentProps":{"placeholder":"请输入合金状态","prefixIcon":"","suffixIcon":"","addonBefore":"","addonAfter":"","clearable":false,"maxlength":-1,"isShow":true},"required":false,"rules":[],"name":"合金状态","ifShow":true,"dynamicDisabled":false,"events":{}},{"key":"2f56d9297a9c49d59d3b43f62e2946f2","field":"gg","label":"规格(尺寸)","component":"Input","componentProps":{"placeholder":"请输入规格(尺寸)","prefixIcon":"","suffixIcon":"","addonBefore":"","addonAfter":"","clearable":false,"maxlength":-1,"isShow":true},"required":false,"rules":[],"name":"规格(尺寸)","ifShow":true,"dynamicDisabled":false,"events":{}},{"key":"6a93c6d77ce1428c9fbba62a02afd6d0","field":"sl","label":"数量","component":"InputNumber","defaultValue":0,"componentProps":{"min":0,"step":1,"maxlength":-1,"isShow":true},"required":false,"rules":[],"name":"数量","ifShow":true,"dynamicDisabled":false,"events":{}},{"key":"3b80cb19086e49e1a746cf9ace3f938e","field":"zl","label":"质量/KG","component":"InputNumber","defaultValue":0,"componentProps":{"min":0,"step":0.1,"maxlength":-1,"isShow":true},"required":false,"rules":[],"name":"质量/KG","ifShow":true,"dynamicDisabled":false,"events":{}}],"componentProps":{"isShow":true},"useSelectButton":false,"buttonName":"选择数据","preloadType":"api"},{"key":"f7ae7fe08ec74cf6b91cd3cd35cfeaaf","field":"zt","label":"状态","component":"Select","defaultValue":"1","componentProps":{"placeholder":"请选择下拉选择","isShow":false,"itemId":"2004464883576217601","map":{"text":"name","value":"value"},"multiple":false,"isSearch":false},"required":false,"rules":[],"name":"状态","ifShow":false,"dynamicDisabled":false,"events":{}}],"rules":[]};
<template>
<view>
<PageHead :title="routeTitle" backUrl=""></PageHead>
<view class="form-container">
<view class="form-box">
<Form ref="formRef" :disabled="formConfig.isView" :id="formConfig.id" :type="formConfig.type" :options="options"></Form>
<view v-if="!formConfig.isView" class="form-btn-box">
<button type="default" class="button" @click="reset">重置</button>
<button type="primary" class="button" @click="submit">确定</button>
</view>
</view>
</view>
</view>
</template>
<script setup>
import { ref, reactive } from 'vue';
import Form from './form.vue';
import { onLoad } from '@dcloudio/uni-app';
import PageHead from "@/components/layout/PageHead.vue";
import { FromPageType } from "@/common/enums/form.ts";
import { getFormTitle } from "@/common/hooks/form.ts";
import { listProps } from './config/index.js'
const formRef = ref(); //表单ref
const routeTitle = ref('表单信息');
const options=ref({});
const formConfig = reactive({
type:FromPageType.ADD,
id:'',
isView:false
});
onLoad(async (option) => {
options.value=option;
formConfig.id = option.id??'';
formConfig.type = option.type;
let title = getFormTitle(formConfig.type);
routeTitle.value =title;
uni.setNavigationBarTitle({title:title});
formConfig.isView = false;
if(formConfig.type==FromPageType.VIEW){
formConfig.isView = true;
}
});
async function submit(){
let saveVal = await formRef.value.submit();
if(saveVal){
if(formConfig.type==FromPageType.ADD){
uni.showToast({
title: '新增成功'
});
}else if(formConfig.type==FromPageType.EDIT){
uni.showToast({
title: '修改成功'
});
}
uni.navigateTo({
url: listProps.listUrl
});
}
}
async function reset(){
formRef.value.reset();
}
</script>
<style>
page{
background: #fff;
}
</style>
<template>
<view>
<SimpleForm ref="formRef" :formProps="formConfig.formProps" :disabled="disabled" :control="formConfig.type" :options="options"></SimpleForm>
</view>
</template>
<script setup>
import { ref, reactive,onMounted } from 'vue';
import SimpleForm from '@/components/simple-form/SimpleForm.vue';
import { formProps } from './config/index.js';
import { FromPageType } from "@/common/enums/form.ts";
import { listProps } from './config/index.js'
import { addMesProductionPlan, updateMesProductionPlan, getMesProductionPlan } from '@/common/api/scgl/scjh/index.js';
import { cloneDeep } from '@/utils/helper/utils.js';
import { handlerFormPermission } from "@/common/hooks/form.ts";
import { setFormPropsAuth } from '@/utils/simpleForm/changeJson.js'
const props = defineProps({
disabled: {
type:Boolean,
default:false
},
type: {
type:String,
default:FromPageType.ADD
},
id: {
type:String,
default:''
},
isWorkFlow:{
type:Boolean,
default:false
},
formModel: {
type:Object
},
workFlowParams: {
type:Object
},
options:Object
});
const rowKey = listProps.rowKey;
const formConfig = reactive({
formProps:formProps,
id:"",
uploadComponentIds:[],
type:FromPageType.ADD
});
const formRef = ref();
onMounted(async () => {
formConfig.id = props.id;
formConfig.type = props.type;
if(props.isWorkFlow){
formConfig.type = props.workFlowParams.type;
if( props.formModel&&props.formModel[rowKey]){
formConfig.type = FromPageType.EDIT;
formConfig.id = props.formModel[rowKey];
}
if(props.disabled) formConfig.type = FromPageType.VIEW;
setWorkflowFormData(formProps);
await formRef.value.setFormData( props.formModel )
}else{
let auth=uni.getStorageSync('MenuAuth')
let formAuth=auth.formAuthCode||[];
setFormPropsAuth(formConfig.formProps.schemas,formAuth)
await setForm();
}
})
async function setForm(){
// 编辑
if (formConfig.type == FromPageType.EDIT||formConfig.type == FromPageType.VIEW) {
const {
data
} = await getMesProductionPlan(formConfig.id);
if (data) {
await formRef.value.setFormData({...data,...props.formModel})
}
}
//新增
else if (formConfig.type == FromPageType.ADD) {
await formRef.value.init()
}
if(formConfig.type== FromPageType.EDIT){
//获取表单数据
if(listProps.formEventConfig&&listProps.formEventConfig[1]){
formRef.value.executeFormEvent(listProps.formEventConfig[1],false);
}
}
//初始化表单
if(listProps.formEventConfig&&listProps.formEventConfig[0]){
formRef.value.executeFormEvent(listProps.formEventConfig[0],false);
}
//加载表单
if(listProps.formEventConfig&&listProps.formEventConfig[2]){
formRef.value.executeFormEvent(listProps.formEventConfig[2],false);
}
}
// 工作流设置表单数据
async function setWorkflowForm(){
if(props.isWorkFlow){
setWorkflowFormData(formProps);
}
// formConfig.type
await setForm();
}
// 工作流辅助设置表单数据
function setWorkflowFormData(formProps){
let options = cloneDeep(formProps);
let otherParams = {...props.workFlowParams.otherParams,uploadComponentIds:formConfig.uploadComponentIds}
let obj = handlerFormPermission(
options,
props.workFlowParams.formConfigChildren,
props.workFlowParams.formConfigKey,
otherParams
);
formRef.value.updateSchema(obj.buildOptionJson.schemas)
formConfig.uploadComponentIds = obj.otherParams.uploadComponentIds;
}
// 获取上传组件Id集合
function getUploadComponentIds(){
return formConfig.uploadComponentIds
}
// 校验
async function validate() {
await formRef.value.validate();
}
// 提交
async function submit() {
let formModelIdVal = {};
try {
await formRef.value.validate();
const formData = await formRef.value.getFormData();
if(formConfig.type == FromPageType.EDIT){
formData[listProps.rowKey]=formConfig.id;
await updateMesProductionPlan(formData);
formModelIdVal[listProps.rowKey]=formConfig.id;
}
else{
let res = await addMesProductionPlan(formData);
formModelIdVal[listProps.rowKey]=res.data;
}
} catch (err) {
return;
}
//提交表单事件
if(listProps.formEventConfig&&listProps.formEventConfig[3]){
formRef.value.executeFormEvent(listProps.formEventConfig[3],false);
}
return formModelIdVal;
}
// 重置
async function reset() {
await formRef.value.reset();
}
// 表单初始化
async function init() {
await formRef.value.init();
}
// 设置表单数据
async function setFormData(formModels) {
await formRef.value.setFormData(formModels);
}
// 获取表单数据
async function getFormData() {
let formModelObj = await formRef.value.getFormData();
if(formConfig.type == FromPageType.EDIT||formConfig.type == FromPageType.VIEW){
formModelObj[listProps.rowKey]=formConfig.id;
}
return formModelObj;
}
defineExpose({
init,
submit,
reset,
setFormData,
validate,
getFormData,
setWorkflowForm,
getUploadComponentIds
});
</script>
<style>
page{
background: #fff;
}
</style>
<template>
<SimpleList ref="listRef" :routeTitle="routeTitle" :listProps="listProps">
<template v-slot:buttonSlot="{rowData}">
<!-- 当前行数据{{rowData}} -->
<!-- 自定义按钮
<view class="uni-select__selector-item" v-if="auth.buttonAuthCode.includes('自定义按钮权限名称')">
<view class="item-text">
自定义按钮
</view>
</view>
-->
</template>
</SimpleList>
</template>
<script setup>
import { ref } from 'vue';
import { onReachBottom, onPullDownRefresh,onShow } from '@dcloudio/uni-app'; //不支持onLoad
import SimpleList from '@/components/simple-list/SimpleList.vue';
import { listProps } from './config/index.js'
onReachBottom(() => {
// 必须要这个事件 可以不写逻辑
});
const listRef = ref();
const firstLoad = ref(true);
const routeTitle = ref('列表');
let auth=uni.getStorageSync('MenuAuth')
onShow(()=>{
const pages = getCurrentPages();
if(pages&&Array.isArray(pages)&&pages.length>0){
const currentPage = pages[pages.length - 1];
if(currentPage&&currentPage.$page&&currentPage.$page.meta&&currentPage.$page.meta.navigationBar&&currentPage.$page.meta.navigationBar.titleText){
const title = currentPage.$page.meta.navigationBar.titleText;
routeTitle.value = title;
}
}
if (firstLoad.value) {
firstLoad.value = !firstLoad.value;
return;
}
listRef.value.reload();
})
</script>
<style></style>
\ No newline at end of file
import { MesWarehouseArrivedPageModel, MesWarehouseArrivedPageParams, MesWarehouseArrivedPageResult } from './model/CgdhModel';
import { defHttp } from '/@/utils/http/axios';
import { ErrorMessageMode } from '/#/axios';
enum Api {
Page = '/ckgl/cgdh/page',
List = '/ckgl/cgdh/list',
Info = '/ckgl/cgdh/info',
MesWarehouseArrived = '/ckgl/cgdh',
}
/**
* @description: 查询MesWarehouseArrived分页列表
*/
export async function getMesWarehouseArrivedPage(params: MesWarehouseArrivedPageParams, mode: ErrorMessageMode = 'modal') {
return defHttp.get<MesWarehouseArrivedPageResult>(
{
url: Api.Page,
params,
},
{
errorMessageMode: mode,
},
);
}
/**
* @description: 获取MesWarehouseArrived信息
*/
export async function getMesWarehouseArrived(id: String, mode: ErrorMessageMode = 'modal') {
return defHttp.get<MesWarehouseArrivedPageModel>(
{
url: Api.Info,
params: { id },
},
{
errorMessageMode: mode,
},
);
}
/**
* @description: 新增MesWarehouseArrived
*/
export async function addMesWarehouseArrived(mesWarehouseArrived: Recordable, mode: ErrorMessageMode = 'modal') {
return defHttp.post<boolean>(
{
url: Api.MesWarehouseArrived,
params: mesWarehouseArrived,
},
{
errorMessageMode: mode,
},
);
}
/**
* @description: 更新MesWarehouseArrived
*/
export async function updateMesWarehouseArrived(mesWarehouseArrived: Recordable, mode: ErrorMessageMode = 'modal') {
return defHttp.put<boolean>(
{
url: Api.MesWarehouseArrived,
params: mesWarehouseArrived,
},
{
errorMessageMode: mode,
},
);
}
/**
* @description: 删除MesWarehouseArrived(批量删除)
*/
export async function deleteMesWarehouseArrived(ids: string[], mode: ErrorMessageMode = 'modal') {
return defHttp.delete<boolean>(
{
url: Api.MesWarehouseArrived,
data: ids,
},
{
errorMessageMode: mode,
},
);
}
import { BasicPageParams, BasicFetchResult } from '/@/api/model/baseModel';
/**
* @description: MesWarehouseArrived分页参数 模型
*/
export interface MesWarehouseArrivedPageParams extends BasicPageParams {
djh: string;
ck: string;
gys: string;
}
/**
* @description: MesWarehouseArrived分页返回值模型
*/
export interface MesWarehouseArrivedPageModel {
id: string;
djh: string;
djrq: string;
crklx: string;
ck: string;
gys: string;
zdr: string;
kczz: string;
}
/**
* @description: MesWarehouseArrived表类型
*/
export interface MesWarehouseArrivedModel {
id: string;
deleteMark: string;
djh: string;
kczz: string;
djrq: string;
crklx: string;
ck: string;
gys: string;
zsl: string;
zdr: string;
fj: string;
bz: string;
p3: string;
p4: string;
p5: string;
p6: string;
p7: string;
p8: string;
p9: string;
p10: string;
createDate: string;
createUserId: string;
modifyDate: string;
modifyUserId: string;
mesWarehouseArrivedInfoList?: MesWarehouseArrivedInfoModel;
}
/**
* @description: MesWarehouseArrivedInfo表类型
*/
export interface MesWarehouseArrivedInfoModel {
id: string;
deleteMark: string;
dhdid: string;
lydhid: string;
wlbm: string;
wlmc: string;
ggxh: string;
dw: string;
yssl: string;
sssl: string;
xqbm: string;
sfzp: string;
sfzj: string;
hwh: string;
bz: string;
p1: string;
p2: string;
p3: string;
p4: string;
p5: string;
p6: string;
p7: string;
p8: string;
p9: string;
p10: string;
createDate: string;
createUserId: string;
modifyDate: string;
modifyUserId: string;
}
/**
* @description: MesWarehouseArrived分页返回值结构
*/
export type MesWarehouseArrivedPageResult = BasicFetchResult<MesWarehouseArrivedPageModel>;
<template>
<BasicModal
:height="1080"
v-bind="$attrs" @register="registerModal" :title="getTitle"
@ok="handleSubmit" @cancel="handleClose" >
<ModalForm ref="formRef" v-model:value="state.formModel" :fromPage="FromPageType.MENU" />
<template #footer v-if=" !state.isView">
<template v-for="(item, index) in sortBy(formButtons, 'index')" :key="item.key">
<template v-if="item.isShow">
<CustomButtonModal v-if="item.type == CustomButtonModalType.Modal" :info="item" />
<a-button
:type="item.style"
v-else
:style="{ marginLeft: index > 0 ? '10px' : 0 }"
@click="customClick(item)"
>
{{ t(item.name) }}
</a-button>
</template>
</template>
</template>
</BasicModal>
</template>
<script lang="ts" setup>
import { ref, computed, reactive, provide, Ref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { CustomButtonModalType } from '/@/enums/userEnum';
import CustomButtonModal from '/@/components/Form/src/components/CustomButtonModal.vue';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
import { formProps ,formButtons } from './config';
import ModalForm from './Form.vue';
import { FromPageType } from '/@/enums/workflowEnum';
import { sortBy } from 'lodash-es';
import { executeCurFormEvent } from '/@/utils/event/data';
const emit = defineEmits(['success', 'register']);
const { notification } = useMessage();
const formRef = ref();
const isCopy = ref<boolean>(false)
const state = reactive({
formModel: {},
isUpdate: true,
isView: false,
rowId: '',
});
provide<Ref<boolean>>('isCopy', isCopy);
const { t } = useI18n();
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
await handleInner(data);
});
const getTitle = computed(() => (state.isView ? '查看' : state.isUpdate ? '编辑' : isCopy.value ? '复制数据' : '新增'));
async function handleInner(data){
state.isUpdate = !!data?.isUpdate;
state.isView = !!data?.isView;
isCopy.value = !!data?.isCopy;
setModalProps({
destroyOnClose: true,
maskClosable: false,
showCancelBtn: false,
showOkBtn: false,
canFullscreen: true,
width: 1980,
footer: state.isView ? null : undefined,defaultFullscreen:true,
});
if (state.isUpdate || state.isView || isCopy.value) {
state.rowId = data.id;
if (state.isView) {
await formRef.value.setDisabledForm();
}
await formRef.value.setFormDataFromId(state.rowId);
} else {
formRef.value.resetFields();
}
}
async function saveModal() {
let saveSuccess = false;
try {
const values = await formRef.value?.validate();
//添加隐藏组件
if (formProps.hiddenComponent?.length) {
formProps.hiddenComponent.forEach((component) => {
values[component.bindField] = component.value;
});
}
if (values !== false) {
try {
if (!state.isUpdate || isCopy.value) {
saveSuccess = await formRef.value.add(values);
} else {
saveSuccess = await formRef.value.update({ values, rowId: state.rowId });
}
return saveSuccess;
} catch (error) {}
}
} catch (error) {
return saveSuccess;
}
}
async function handleSubmit() {
try {
const saveSuccess = await saveModal();
setModalProps({ confirmLoading: true });
if (saveSuccess) {
if (!state.isUpdate || isCopy.value) {
//false 新增
notification.success({
message: 'Tip',
description: isCopy.value ? '复制成功' : t('新增成功!'),
}); //提示消息
} else {
notification.success({
message: 'Tip',
description: t('修改成功!'),
}); //提示消息
}
closeModal();
formRef.value.resetFields();
emit('success');
}
} finally {
setModalProps({ confirmLoading: false });
}
}
function customClick(item) {
if (item.key == 'confirm') {
handleSubmit();
} else if (item.key == 'cancel' && props.formType !== 'normal') {
handleClose();
closeModal();
} else if (item.key == 'reset') {
formRef.value.resetFields();
} else {
executeCurFormEvent(item.event, state.formModel, true);
}
}
function handleClose() {
formRef.value.resetFields();
}
</script>
\ No newline at end of file
<template>
<div class="pt-4">
<SimpleForm
ref="systemFormRef"
:formProps="data.formDataProps"
:formModel="state.formModel"
:isWorkFlow="props.fromPage!=FromPageType.MENU"
:isCamelCase="true"
@model-change="handleChange"
/>
</div>
</template>
<script lang="ts" setup>
import { reactive, ref, onMounted, nextTick, watch } from 'vue';
import { formProps, formEventConfigs } from './config';
import SimpleForm from '/@/components/SimpleForm/src/SimpleForm.vue';
import { addMesWarehouseArrived, getMesWarehouseArrived, updateMesWarehouseArrived } from '/@/api/ckgl/cgdh';
import { cloneDeep, isString } from 'lodash-es';
import { FormDataProps } from '/@/components/Designer/src/types';
import { usePermission } from '/@/hooks/web/usePermission';
import CustomButtonModal from '/@/components/Form/src/components/CustomButtonModal.vue';
import { FromPageType } from '/@/enums/workflowEnum';
import { createFormEvent, getFormDataEvent, loadFormEvent, submitFormEvent,} from '/@/hooks/web/useFormEvent';
import { changeWorkFlowForm, changeSchemaDisabled } from '/@/hooks/web/useWorkFlowForm';
import { WorkFlowFormParams } from '/@/model/workflow/bpmnConfig';
import { useRouter } from 'vue-router';
const { filterFormSchemaAuth } = usePermission();
const RowKey = 'id';
const emits = defineEmits(['changeUploadComponentIds','loadingCompleted', 'update:value']);
const props = defineProps({
fromPage: {
type: Number,
default: FromPageType.MENU,
},
});
const systemFormRef = ref();
const data: { formDataProps: FormDataProps } = reactive({
formDataProps: cloneDeep(formProps),
});
const state = reactive({
formModel: {},
formInfo:{formId:'',formName:''}
});
const { currentRoute } = useRouter();
watch(
() => state.formModel,
(val) => {
emits('update:value', val);
},
{
deep: true,
},
);
onMounted(async () => {
try {
if (props.fromPage == FromPageType.MENU) {
setMenuPermission();
if(currentRoute.value.meta){
state.formInfo.formName = currentRoute.value.meta.title&&isString(currentRoute.value.meta.title)?currentRoute.value.meta.title:'';
state.formInfo.formId = currentRoute.value.meta.formId&&isString(currentRoute.value.meta.formId)?currentRoute.value.meta.formId:'';
}
await createFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas, true, state.formInfo.formName,state.formInfo.formId); //表单事件:初始化表单
await nextTick();
await loadFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas, true, state.formInfo.formName,state.formInfo.formId); //表单事件:加载表单
} else if (props.fromPage == FromPageType.FLOW) {
emits('loadingCompleted'); //告诉系统表单已经加载完毕
// loadingCompleted后 工作流页面直接利用Ref调用setWorkFlowForm方法
} else if (props.fromPage == FromPageType.PREVIEW) {
// 预览 无需权限,表单事件也无需执行
} else if (props.fromPage == FromPageType.DESKTOP) {
// 桌面设计 表单事件需要执行
emits('loadingCompleted'); //告诉系统表单已经加载完毕
await createFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas, true, state.formInfo.formName,state.formInfo.formId); //表单事件:初始化表单
await loadFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas, true, state.formInfo.formName,state.formInfo.formId); //表单事件:加载表单
}
} catch (error) {}
});
// 根据菜单页面权限,设置表单属性(必填,禁用,显示)
function setMenuPermission() {
data.formDataProps.schemas = filterFormSchemaAuth(data.formDataProps.schemas!);
}
// 校验form 通过返回表单数据
async function validate() {
let values = [];
try {
values = await systemFormRef.value?.validate();
//添加隐藏组件
if (data.formDataProps.hiddenComponent?.length) {
data.formDataProps.hiddenComponent.forEach((component) => {
values[component.bindField] = component.value;
});
}
} finally {
}
return values;
}
// 根据行唯一ID查询行数据,并设置表单数据 【编辑】
async function setFormDataFromId(rowId) {
try {
const record = await getMesWarehouseArrived(rowId);
setFieldsValue(record);
state.formModel = record;
await getFormDataEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas, true, state.formInfo.formName,state.formInfo.formId); //表单事件:获取表单数据
} catch (error) {
}
}
// 辅助返回表单数据
async function getFieldsValue() {
let values = [];
try {
values = await systemFormRef.value?.getFieldsValue();
//添加隐藏组件
if (data.formDataProps.hiddenComponent?.length) {
data.formDataProps.hiddenComponent.forEach((component) => {
values[component.bindField] = component.value;
});
}
} finally {
}
return values;
}
// 辅助设置表单数据
function setFieldsValue(record) {
systemFormRef.value.setFieldsValue(record);
}
// 重置表单数据
async function resetFields() {
await systemFormRef.value.resetFields();
}
// 设置表单数据全部为Disabled 【查看】
async function setDisabledForm( ) {
data.formDataProps.schemas = changeSchemaDisabled(cloneDeep(data.formDataProps.schemas));
}
// 获取行键值
function getRowKey() {
return RowKey;
}
// 更新api表单数据
async function update({ values, rowId }) {
try {
values[RowKey] = rowId;
state.formModel = values;
let saveVal = await updateMesWarehouseArrived(values);
await submitFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas, true, state.formInfo.formName,state.formInfo.formId); //表单事件:提交表单
return saveVal;
} catch (error) {}
}
// 新增api表单数据
async function add(values) {
try {
state.formModel = values;
let saveVal = await addMesWarehouseArrived(values);
await submitFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas, true, state.formInfo.formName,state.formInfo.formId); //表单事件:提交表单
return saveVal;
} catch (error) {}
}
// 根据工作流页面权限,设置表单属性(必填,禁用,显示)
async function setWorkFlowForm(obj: WorkFlowFormParams) {
try {
if (obj.formId) state.formInfo.formId = obj.formId;
if (obj.formName) state.formInfo.formName = obj.formName;
let flowData = await changeWorkFlowForm(cloneDeep(formProps), obj);
let { buildOptionJson, uploadComponentIds, formModels, isViewProcess } = flowData;
data.formDataProps = buildOptionJson;
emits('changeUploadComponentIds', uploadComponentIds); //工作流中必须保存上传组件id【附件汇总需要】
if (isViewProcess) {
setDisabledForm(); //查看
}
state.formModel = formModels;
setFieldsValue(formModels);
} catch (error) {}
await createFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas, true, state.formInfo.formName,state.formInfo.formId); //表单事件:初始化表单
await loadFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas, true, state.formInfo.formName,state.formInfo.formId); //表单事件:加载表单
}
function handleChange(val) {
emits('update:value', val);
}
async function sendMessageForAllIframe() {
try {
if (systemFormRef.value && systemFormRef.value.sendMessageForAllIframe) {
systemFormRef.value.sendMessageForAllIframe();
}
} catch (error) {}
}
defineExpose({
setFieldsValue,
resetFields,
validate,
add,
update,
setFormDataFromId,
setDisabledForm,
setMenuPermission,
setWorkFlowForm,
getRowKey,
getFieldsValue,
sendMessageForAllIframe
});
</script>
\ No newline at end of file
import { FormProps, FormSchema } from '/@/components/Form';
import { BasicColumn } from '/@/components/Table';
import { uploadApi } from '/@/api/sys/upload';
export const searchFormSchema: FormSchema[] = [
{
field: 'djh',
label: '单据号',
defaultValue: undefined,
component: 'Input',
},
{
field: 'ck',
label: '仓库',
defaultValue: undefined,
component: 'Input',
},
{
field: 'gys',
label: '供应商',
defaultValue: undefined,
component: 'Input',
},
];
export const columns: BasicColumn[] = [
{
resizable: true,
dataIndex: 'djh',
title: '单据号',
componentType: 'input',
fixed: false,
sorter: true,
styleConfig: undefined,
listStyle: '',
},
{
resizable: true,
dataIndex: 'djrq',
title: '单据日期',
componentType: 'date',
fixed: false,
sorter: true,
styleConfig: undefined,
listStyle: undefined,
},
{
resizable: true,
dataIndex: 'crklx',
title: '出入库类型',
componentType: 'input',
fixed: false,
sorter: true,
styleConfig: undefined,
listStyle: '',
},
{
resizable: true,
dataIndex: 'ck',
title: '仓库',
componentType: 'input',
fixed: false,
sorter: true,
styleConfig: undefined,
listStyle: '',
},
{
resizable: true,
dataIndex: 'gys',
title: '供应商',
componentType: 'input',
fixed: false,
sorter: true,
styleConfig: undefined,
listStyle: '',
},
{
resizable: true,
dataIndex: 'zdr',
title: '制单人',
componentType: 'input',
fixed: false,
sorter: true,
styleConfig: undefined,
listStyle: '',
},
{
resizable: true,
dataIndex: 'kczz',
title: '库存组织',
componentType: 'input',
fixed: false,
sorter: true,
styleConfig: undefined,
listStyle: '',
},
];
//表头合并配置
export const headerMergingData = [];
//表单事件
export const formEventConfigs = {
0: [
{
type: 'circle',
color: '#2774ff',
text: '开始节点',
icon: '#icon-kaishi',
bgcColor: '#D8E5FF',
isUserDefined: false,
},
{
color: '#F6AB01',
icon: '#icon-chushihua',
text: '初始化表单',
bgcColor: '#f9f5ea',
isUserDefined: false,
nodeInfo: { processEvent: [] },
},
],
1: [
{
color: '#B36EDB',
icon: '#icon-shujufenxi',
text: '获取表单数据',
detail: '(新增无此操作)',
bgcColor: '#F8F2FC',
isUserDefined: false,
nodeInfo: { processEvent: [] },
},
],
2: [
{
color: '#F8625C',
icon: '#icon-jiazai',
text: '加载表单',
bgcColor: '#FFF1F1',
isUserDefined: false,
nodeInfo: { processEvent: [] },
},
],
3: [
{
color: '#6C6AE0',
icon: '#icon-jsontijiao',
text: '提交表单',
bgcColor: '#F5F4FF',
isUserDefined: false,
nodeInfo: { processEvent: [] },
},
],
4: [
{
type: 'circle',
color: '#F8625C',
text: '结束节点',
icon: '#icon-jieshuzhiliao',
bgcColor: '#FFD6D6',
isLast: true,
isUserDefined: false,
},
],
};
export const formProps: FormProps = {
labelCol: {},
labelAlign: 'right',
layout: 'horizontal',
size: 'default',
schemas: [
{
key: 'af3bef52ccbb47378d216f4386fb730c',
field: '',
label: '',
type: 'grid',
colProps: { span: 24 },
component: 'Grid',
children: [
{
span: 8,
list: [
{
key: '2be7c2009d5d496fa83ebca7a699f656',
field: 'djh',
label: '单据号',
type: 'input',
component: 'Input',
colProps: { span: 24 },
defaultValue: '',
componentProps: {
width: '100%',
span: 7,
defaultValue: '',
placeholder: '',
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: false,
allowClear: false,
showLabel: true,
required: false,
rules: [],
events: {},
listStyle: '',
isSave: false,
isShow: true,
scan: false,
bordered: true,
isShowAi: false,
tooltipConfig: { visible: false, title: '提示文本' },
style: { width: '100%' },
},
},
],
},
{
span: 8,
list: [
{
key: 'd30ddf6f2a4c44799cdf61184f930cdf',
field: 'djrq',
label: '单据日期',
type: 'date',
component: 'DatePicker',
colProps: { span: 24 },
defaultValue: '',
componentProps: {
span: 7,
defaultValue: '',
width: '100%',
placeholder: '',
format: 'YYYY-MM-DD HH:mm:ss',
showLabel: true,
allowClear: true,
disabled: false,
required: false,
isShow: true,
rules: [],
events: {},
isGetCurrent: false,
tooltipConfig: { visible: false, title: '提示文本' },
searchType: 'time',
style: { width: '100%' },
},
},
],
},
{
span: 8,
list: [
{
key: '8e7ab50fd3ee4849bdceebab4198a9f6',
field: 'crklx',
label: '出入库类型',
type: 'input',
component: 'Input',
colProps: { span: 24 },
defaultValue: '',
componentProps: {
width: '100%',
span: 7,
defaultValue: '',
placeholder: '',
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: false,
allowClear: false,
showLabel: true,
required: false,
rules: [],
events: {},
listStyle: '',
isSave: false,
isShow: true,
scan: false,
bordered: true,
isShowAi: false,
tooltipConfig: { visible: false, title: '提示文本' },
style: { width: '100%' },
},
},
],
},
{
span: 8,
list: [
{
key: '6c39c3b78f9448408de4342df16cc748',
field: 'ck',
label: '仓库',
type: 'input',
component: 'Input',
colProps: { span: 24 },
defaultValue: '',
componentProps: {
width: '100%',
span: 7,
defaultValue: '',
placeholder: '',
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: false,
allowClear: false,
showLabel: true,
required: false,
rules: [],
events: {},
listStyle: '',
isSave: false,
isShow: true,
scan: false,
bordered: true,
isShowAi: false,
tooltipConfig: { visible: false, title: '提示文本' },
style: { width: '100%' },
},
},
],
},
{
span: 8,
list: [
{
key: '9f64a605992b43cc9443c96669b33b3d',
field: 'gys',
label: '供应商',
type: 'input',
component: 'Input',
colProps: { span: 24 },
defaultValue: '',
componentProps: {
width: '100%',
span: 7,
defaultValue: '',
placeholder: '',
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: false,
allowClear: false,
showLabel: true,
required: false,
rules: [],
events: {},
listStyle: '',
isSave: false,
isShow: true,
scan: false,
bordered: true,
isShowAi: false,
tooltipConfig: { visible: false, title: '提示文本' },
style: { width: '100%' },
},
},
],
},
{
span: 8,
list: [
{
key: '208ae8323f36498d8f7f03a332837637',
field: 'zdr',
label: '制单人',
type: 'input',
component: 'Input',
colProps: { span: 24 },
defaultValue: '',
componentProps: {
width: '100%',
span: 7,
defaultValue: '',
placeholder: '',
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: false,
allowClear: false,
showLabel: true,
required: false,
rules: [],
events: {},
listStyle: '',
isSave: false,
isShow: true,
scan: false,
bordered: true,
isShowAi: false,
tooltipConfig: { visible: false, title: '提示文本' },
style: { width: '100%' },
},
},
],
},
{
span: 8,
list: [
{
key: '6d7e64828eeb46e7b7a10bcca6c50c16',
field: 'kczz',
label: '库存组织',
type: 'input',
component: 'Input',
colProps: { span: 24 },
defaultValue: '',
componentProps: {
width: '100%',
span: 7,
defaultValue: '',
placeholder: '',
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: false,
allowClear: false,
showLabel: true,
required: false,
rules: [],
events: {},
listStyle: '',
isSave: false,
isShow: true,
scan: false,
bordered: true,
isShowAi: false,
tooltipConfig: { visible: false, title: '提示文本' },
style: { width: '100%' },
},
},
],
},
{
span: 8,
list: [
{
key: '94f59d97b377411fb1097853bd9479b0',
field: 'fj',
label: '上传附件',
type: 'upload',
component: 'Upload',
colProps: { span: 24 },
componentProps: {
api: uploadApi,
span: 7,
defaultValue: '',
accept: '',
maxNumber: 5,
maxSize: 5,
showLabel: true,
multiple: false,
disabled: false,
required: false,
isShow: true,
events: {},
listType: 'text',
sourceType: 'album,camera',
tooltipConfig: { visible: false, title: '提示文本' },
},
},
],
},
{
span: 8,
list: [
{
key: '4ca80a2d3a8244bc8d3380b6b0457c25',
field: 'zsl',
label: '总数量',
type: 'number',
component: 'InputNumber',
colProps: { span: 24 },
defaultValue: 0,
componentProps: {
width: '100%',
span: 7,
defaultValue: 0,
min: 0,
step: 1,
disabled: false,
showLabel: true,
controls: true,
required: false,
subTotal: false,
isShow: false,
rules: [],
events: {},
tooltipConfig: { visible: false, title: '提示文本' },
style: { width: '100%' },
},
},
],
},
{
span: 24,
list: [
{
key: '2adde8c1d7e24327874bec1411479ec8',
field: 'bz',
label: '备注',
type: 'textarea',
component: 'InputTextArea',
colProps: { span: 24 },
defaultValue: '',
componentProps: {
width: '100%',
span: 2,
defaultValue: '',
placeholder: '请输入备注',
rows: 4,
autoSize: false,
showCount: false,
disabled: false,
showLabel: true,
allowClear: false,
required: false,
isShow: true,
isShowAi: false,
rules: [],
events: {},
tooltipConfig: { visible: false, title: '提示文本' },
style: { width: '100%' },
},
},
],
},
{
span: 8,
list: [
{
key: '139048460226487596074dfbbaedba0c',
field: 'id',
label: 'Id',
type: 'input',
component: 'Input',
colProps: { span: 24 },
defaultValue: '',
componentProps: {
width: '100%',
span: 7,
defaultValue: '',
placeholder: '请输入Id',
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: false,
allowClear: false,
showLabel: true,
required: false,
rules: [],
events: {},
listStyle: '',
isSave: false,
isShow: false,
scan: false,
bordered: true,
isShowAi: false,
tooltipConfig: { visible: false, title: '提示文本' },
style: { width: '100%' },
},
},
],
},
],
componentProps: {
gutter: 16,
justify: 'start',
align: 'top',
isShow: true,
showBorder: false,
bordercolor: '#d9d9d9',
bordershowtype: [true, true, true, true],
borderwidth: 1,
padding: '10px',
margin: '10px',
},
},
{
key: 'b83f5fe60aff4037af22a97f4db50c63',
label: '物料明细',
field: 'mesWarehouseArrivedInfoList',
type: 'form',
component: 'SubForm',
required: true,
colProps: { span: 24 },
componentProps: {
mainKey: 'mesWarehouseArrivedInfoList',
columns: [
{
key: 'd9b1947e596646a9882a13d7e8107675',
title: 'id',
dataIndex: 'id',
componentType: 'Input',
defaultValue: '',
componentProps: {
width: '100%',
span: '',
defaultValue: '',
placeholder: '请输入id',
maxlength: null,
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: false,
allowClear: false,
showLabel: true,
required: false,
rules: [],
events: {},
listStyle: '',
isSave: false,
isShow: false,
scan: false,
bordered: true,
isShowAi: false,
tooltipConfig: { visible: false, title: '提示文本' },
},
},
{
key: '75216f13cd444df0a6ae1b338c8de5f3',
title: '来源单号ID',
dataIndex: 'lydhid',
componentType: 'Input',
defaultValue: '',
componentProps: {
width: '100%',
span: '',
defaultValue: '',
placeholder: '',
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: false,
allowClear: false,
showLabel: true,
required: false,
rules: [],
events: {},
listStyle: '',
isSave: false,
isShow: true,
scan: false,
bordered: true,
isShowAi: false,
tooltipConfig: { visible: false, title: '提示文本' },
prestrainField: 'lyddid',
},
},
{
key: 'd156328500cb4894ad6856524fb85d98',
title: '物料编码',
dataIndex: 'wlbm',
componentType: 'Input',
defaultValue: '',
componentProps: {
width: '100%',
span: '',
defaultValue: '',
placeholder: '',
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: false,
allowClear: false,
showLabel: true,
required: false,
rules: [],
events: {},
listStyle: '',
isSave: false,
isShow: true,
scan: false,
bordered: true,
isShowAi: false,
tooltipConfig: { visible: false, title: '提示文本' },
prestrainField: 'wlbm',
},
},
{
key: 'e8b50d775cf34c278af462df13a9c865',
title: '物料名称',
dataIndex: 'wlmc',
componentType: 'Input',
defaultValue: '',
componentProps: {
width: '100%',
span: '',
defaultValue: '',
placeholder: '',
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: false,
allowClear: false,
showLabel: true,
required: false,
rules: [],
events: {},
listStyle: '',
isSave: false,
isShow: true,
scan: false,
bordered: true,
isShowAi: false,
tooltipConfig: { visible: false, title: '提示文本' },
prestrainField: 'wlmc',
},
},
{
key: '0e6903d4d9014dcfae6b1cb666d448b7',
title: '规格型号',
dataIndex: 'ggxh',
componentType: 'Input',
defaultValue: '',
componentProps: {
width: '100%',
span: '',
defaultValue: '',
placeholder: '',
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: false,
allowClear: false,
showLabel: true,
required: false,
rules: [],
events: {},
listStyle: '',
isSave: false,
isShow: true,
scan: false,
bordered: true,
isShowAi: false,
tooltipConfig: { visible: false, title: '提示文本' },
prestrainField: 'ggxh',
},
},
{
key: '4301478a5ef2448abdfdeee629297fbf',
title: '单位',
dataIndex: 'dw',
componentType: 'Input',
defaultValue: '',
componentProps: {
width: '100%',
span: '',
defaultValue: '',
placeholder: '',
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: false,
allowClear: false,
showLabel: true,
required: false,
rules: [],
events: {},
listStyle: '',
isSave: false,
isShow: true,
scan: false,
bordered: true,
isShowAi: false,
tooltipConfig: { visible: false, title: '提示文本' },
prestrainField: 'dw',
},
},
{
key: 'ac4098a101a84c40b7ef51f714b136d9',
title: '实收数量',
dataIndex: 'sssl',
componentType: 'InputNumber',
componentProps: {
width: '100%',
span: '',
min: 0,
step: 1,
disabled: false,
showLabel: true,
controls: true,
required: false,
subTotal: false,
isShow: true,
rules: [],
events: {},
tooltipConfig: { visible: false, title: '提示文本' },
prestrainField: 'sssl',
listStyle: "return 'width:100%'",
},
},
{
key: '9cd15589c75f476ebe5605b3352e8ffc',
title: '应收数量',
dataIndex: 'yssl',
componentType: 'InputNumber',
componentProps: {
width: '100%',
span: '',
min: 0,
step: 1,
disabled: false,
showLabel: true,
controls: true,
required: false,
subTotal: false,
isShow: true,
rules: [],
events: {},
tooltipConfig: { visible: false, title: '提示文本' },
prestrainField: 'yssl',
listStyle: "return 'width:100%'",
},
},
{
key: '9a27b6bf1d2445e796c474269ee23514',
title: '需求部门',
dataIndex: 'xqbm',
componentType: 'Input',
defaultValue: '',
componentProps: {
width: '100%',
span: '',
defaultValue: '',
placeholder: '',
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: false,
allowClear: false,
showLabel: true,
required: false,
rules: [],
events: {},
listStyle: '',
isSave: false,
isShow: true,
scan: false,
bordered: true,
isShowAi: false,
tooltipConfig: { visible: false, title: '提示文本' },
prestrainField: 'xqbm',
},
},
{
key: 'd2d0c0c885684a99a792beb3dc3415ba',
title: '是否赠品',
dataIndex: 'sfzp',
componentType: 'Input',
defaultValue: '',
componentProps: {
width: '100%',
span: '',
defaultValue: '',
placeholder: '',
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: false,
allowClear: false,
showLabel: true,
required: false,
rules: [],
events: {},
listStyle: '',
isSave: false,
isShow: true,
scan: false,
bordered: true,
isShowAi: false,
tooltipConfig: { visible: false, title: '提示文本' },
prestrainField: 'sfzp',
},
},
{
key: 'f25594957e6543e5a4d109a576c0a557',
title: '是否质检',
dataIndex: 'sfzj',
componentType: 'Input',
defaultValue: '',
componentProps: {
width: '100%',
span: '',
defaultValue: '',
placeholder: '',
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: false,
allowClear: false,
showLabel: true,
required: false,
rules: [],
events: {},
listStyle: '',
isSave: false,
isShow: true,
scan: false,
bordered: true,
isShowAi: false,
tooltipConfig: { visible: false, title: '提示文本' },
prestrainField: 'zfzj',
},
},
{
key: '18a8a0253ac34f5eae913f671b763505',
title: '货位号',
dataIndex: 'hwh',
componentType: 'Input',
defaultValue: '',
componentProps: {
width: '100%',
span: '',
defaultValue: '',
placeholder: '',
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: false,
allowClear: false,
showLabel: true,
required: false,
rules: [],
events: {},
listStyle: '',
isSave: false,
isShow: true,
scan: false,
bordered: true,
isShowAi: false,
tooltipConfig: { visible: false, title: '提示文本' },
prestrainField: 'hwh',
},
},
{
key: '261352c5876c4c438f0c8d0973454d8a',
title: '备注',
dataIndex: 'bz',
componentType: 'Input',
defaultValue: '',
componentProps: {
width: '100%',
span: '',
defaultValue: '',
placeholder: '',
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: false,
allowClear: false,
showLabel: true,
required: false,
rules: [],
events: {},
listStyle: '',
isSave: false,
isShow: true,
scan: false,
bordered: true,
isShowAi: false,
tooltipConfig: { visible: false, title: '提示文本' },
prestrainField: 'bz',
},
},
],
span: '24',
preloadType: 'api',
apiConfig: {
path: '/getArrivedInfo',
method: 'GET',
apiId: '1ac03783f66c4a1d9770567cd3de1fca',
apiParams: [
{
key: '1',
title: 'Query Params',
tableInfo: [
{
name: 'ddhid',
value: '{"bindField":"id","fieldKey":"139048460226487596074dfbbaedba0c"}',
required: true,
defaultValue: '0',
bindType: 'data',
},
],
},
{ key: '2', title: 'Header', tableInfo: [] },
{ key: '3', title: 'Body' },
],
script:
'var sql="select * from mes_warehouse_arrived_info where id = #{ddhid}";\r\nreturn db.select(sql);',
},
itemId: '',
dicOptions: [],
useSelectButton: false,
buttonName: '选择数据',
showLabel: true,
showComponentBorder: true,
showBorder: false,
bordercolor: '#f0f0f0',
bordershowtype: [true, true, true, true],
borderwidth: 1,
showIndex: true,
isShow: true,
multipleHeads: [],
buttonList: [],
topButtonList: [
{
key: 'button1767921063540',
label: '批量报检',
icon: 'ant-design:alert-outlined',
style: 'primary',
event: [
{
operateType: 2,
operateConfig: {
apiConfig: { path: '' },
js: "if(formActionType.selectedRowsData\n\t&&Array.isArray(formActionType.selectedRowsData)\n\t&&formActionType.selectedRowsData.length>0){\n\tlet item = formActionType.selectedRowsData;\n\tfor(let i=0; i<item.length; i++){\n formActionType.httpRequest({\n requestType: 'put',\n requestUrl: '/magic-api//updateSfzj',\n params: {\n id: item[i].id\n },\n errorMessageMode: 'message'\n })\n }\n}",
},
},
],
type: 1,
},
],
isExport: false,
isImport: false,
isDeleteSelected: false,
isListView: false,
viewList: [],
isShowAdd: true,
isShowDelete: false,
hasCheckedCol: true,
events: {},
showPagenation: true,
},
},
],
showActionButtonGroup: false,
buttonLocation: 'center',
actionColOptions: { span: 24 },
showResetButton: false,
showSubmitButton: false,
hiddenComponent: [],
};
export const formButtons = [
{
key: 'confirm',
code: 'confirm',
name: '确定',
style: 'primary',
event: [],
isShow: true,
index: 2,
type: 1,
},
{
key: 'cancel',
code: 'cancel',
name: '取消',
style: 'default',
event: [],
isShow: true,
index: 1,
type: 1,
},
{
key: 'reset',
code: 'reset',
name: '重置',
style: 'default',
event: [],
isShow: true,
index: 0,
type: 1,
},
];
export const permissionList = [
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '单据号',
fieldId: 'djh',
isSubTable: false,
showChildren: true,
type: 'input',
key: '2be7c2009d5d496fa83ebca7a699f656',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '单据日期',
fieldId: 'djrq',
isSubTable: false,
showChildren: true,
type: 'date',
key: 'd30ddf6f2a4c44799cdf61184f930cdf',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '出入库类型',
fieldId: 'crklx',
isSubTable: false,
showChildren: true,
type: 'input',
key: '8e7ab50fd3ee4849bdceebab4198a9f6',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '仓库',
fieldId: 'ck',
isSubTable: false,
showChildren: true,
type: 'input',
key: '6c39c3b78f9448408de4342df16cc748',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '供应商',
fieldId: 'gys',
isSubTable: false,
showChildren: true,
type: 'input',
key: '9f64a605992b43cc9443c96669b33b3d',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '制单人',
fieldId: 'zdr',
isSubTable: false,
showChildren: true,
type: 'input',
key: '208ae8323f36498d8f7f03a332837637',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '库存组织',
fieldId: 'kczz',
isSubTable: false,
showChildren: true,
type: 'input',
key: '6d7e64828eeb46e7b7a10bcca6c50c16',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '上传附件',
fieldId: 'fj',
isSubTable: false,
showChildren: true,
type: 'upload',
key: '94f59d97b377411fb1097853bd9479b0',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '总数量',
fieldId: 'zsl',
isSubTable: false,
showChildren: true,
type: 'number',
key: '4ca80a2d3a8244bc8d3380b6b0457c25',
children: [],
options: {},
defaultValue: 0,
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '备注',
fieldId: 'bz',
isSubTable: false,
showChildren: true,
type: 'textarea',
key: '2adde8c1d7e24327874bec1411479ec8',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: 'Id',
fieldId: 'id',
isSubTable: false,
showChildren: true,
type: 'input',
key: '139048460226487596074dfbbaedba0c',
children: [],
options: {},
defaultValue: '',
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: true,
showChildren: false,
tableName: 'mesWarehouseArrivedInfoList',
fieldName: '物料明细',
fieldId: 'mesWarehouseArrivedInfoList',
type: 'form',
key: 'b83f5fe60aff4037af22a97f4db50c63',
children: [
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: false,
isSaveTable: false,
showChildren: false,
tableName: 'mesWarehouseArrivedInfoList',
fieldName: 'id',
fieldId: 'id',
type: 'Input',
key: 'd9b1947e596646a9882a13d7e8107675',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: false,
isSaveTable: false,
showChildren: false,
tableName: 'mesWarehouseArrivedInfoList',
fieldName: '来源单号ID',
fieldId: 'lydhid',
type: 'Input',
key: '75216f13cd444df0a6ae1b338c8de5f3',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: false,
isSaveTable: false,
showChildren: false,
tableName: 'mesWarehouseArrivedInfoList',
fieldName: '物料编码',
fieldId: 'wlbm',
type: 'Input',
key: 'd156328500cb4894ad6856524fb85d98',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: false,
isSaveTable: false,
showChildren: false,
tableName: 'mesWarehouseArrivedInfoList',
fieldName: '物料名称',
fieldId: 'wlmc',
type: 'Input',
key: 'e8b50d775cf34c278af462df13a9c865',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: false,
isSaveTable: false,
showChildren: false,
tableName: 'mesWarehouseArrivedInfoList',
fieldName: '规格型号',
fieldId: 'ggxh',
type: 'Input',
key: '0e6903d4d9014dcfae6b1cb666d448b7',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: false,
isSaveTable: false,
showChildren: false,
tableName: 'mesWarehouseArrivedInfoList',
fieldName: '单位',
fieldId: 'dw',
type: 'Input',
key: '4301478a5ef2448abdfdeee629297fbf',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: false,
isSaveTable: false,
showChildren: false,
tableName: 'mesWarehouseArrivedInfoList',
fieldName: '实收数量',
fieldId: 'sssl',
type: 'InputNumber',
key: 'ac4098a101a84c40b7ef51f714b136d9',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: false,
isSaveTable: false,
showChildren: false,
tableName: 'mesWarehouseArrivedInfoList',
fieldName: '应收数量',
fieldId: 'yssl',
type: 'InputNumber',
key: '9cd15589c75f476ebe5605b3352e8ffc',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: false,
isSaveTable: false,
showChildren: false,
tableName: 'mesWarehouseArrivedInfoList',
fieldName: '需求部门',
fieldId: 'xqbm',
type: 'Input',
key: '9a27b6bf1d2445e796c474269ee23514',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: false,
isSaveTable: false,
showChildren: false,
tableName: 'mesWarehouseArrivedInfoList',
fieldName: '是否赠品',
fieldId: 'sfzp',
type: 'Input',
key: 'd2d0c0c885684a99a792beb3dc3415ba',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: false,
isSaveTable: false,
showChildren: false,
tableName: 'mesWarehouseArrivedInfoList',
fieldName: '是否质检',
fieldId: 'sfzj',
type: 'Input',
key: 'f25594957e6543e5a4d109a576c0a557',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: false,
isSaveTable: false,
showChildren: false,
tableName: 'mesWarehouseArrivedInfoList',
fieldName: '货位号',
fieldId: 'hwh',
type: 'Input',
key: '18a8a0253ac34f5eae913f671b763505',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: false,
isSaveTable: false,
showChildren: false,
tableName: 'mesWarehouseArrivedInfoList',
fieldName: '备注',
fieldId: 'bz',
type: 'Input',
key: '261352c5876c4c438f0c8d0973454d8a',
children: [],
},
],
},
];
<template>
<ResizePageWrapper :hasLeft="false">
<template #resizeRight>
<BasicTable @register="registerTable" isMenuTable ref="tableRef"
>
<template #toolbar>
<template v-for="button in tableButtonConfig" :key="button.code">
<a-button v-if="button.isDefault" type="primary" @click="buttonClick(button.code)">
<template #icon><Icon :icon="button.icon" /></template>
{{ button.name }}
</a-button>
<CustomButtonModal v-else-if="button.buttonType == 'modal'" :info="button" />
<a-button v-else :type="button.buttonType === 'danger' ? 'default' : button.buttonType || 'primary'" :danger="button.buttonType === 'danger'" >
<template #icon><Icon :icon="button.icon" /></template>
{{ button.name }}
</a-button>
</template>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.dataIndex === 'action'">
<TableAction
:actions="getLessActions(record)"
:dropDownActions="getMoreActions(record)"
/>
</template>
<template v-else-if="column.dataIndex && column?.listStyle">
<span :style="executeListStyle(getValue(record, column, 'style'), column?.listStyle)">{{
getValue(record, column, 'value')
}}</span>
</template>
</template>
</BasicTable>
</template>
<CgdhModal @register="registerModal" @success="handleFormSuccess" @cancel="handleFormCancel"/>
</ResizePageWrapper>
</template>
<script lang="ts" setup>
import { ref, computed,provide,Ref, createVNode,
} from 'vue';
import { Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { BasicTable, useTable, TableAction, ActionItem } from '/@/components/Table';
import { getMesWarehouseArrivedPage, deleteMesWarehouseArrived} from '/@/api/ckgl/cgdh';
import { ResizePageWrapper } from '/@/components/Page';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
import { usePermission } from '/@/hooks/web/usePermission';
import CustomButtonModal from '/@/components/Form/src/components/CustomButtonModal.vue';
import { executeListStyle, getValue } from '/@/hooks/web/useListStyle';//列表样式配置
import { useRouter } from 'vue-router';
import { useModal } from '/@/components/Modal';
import CgdhModal from './components/CgdhModal.vue';
import { searchFormSchema, columns } from './components/config';
import Icon from '/@/components/Icon/index';
const listSpliceNum = ref(3); //操作列最先展示几个
import { useConcurrentLock } from '/@/hooks/web/useConcurrentLock';
const pageParamsInfo = ref<any>({});
const { enableLockeData,handleOpenFormEnableLockeData, handleCloseFormEnableLocke, handleHasEnableLocke } =
useConcurrentLock();
const { notification } = useMessage();
const { t } = useI18n();
defineEmits(['register']);
const { filterColumnAuth, filterButtonAuth, hasPermission } = usePermission();
const filterColumns = filterColumnAuth(columns);
const tableRef = ref();
//展示在列表内的按钮
const actionButtons = ref<string[]>(["view","edit","delete"]);
const buttonConfigs = computed(()=>{
const list = [{"buttonId":"2009445983314264064","name":"查看","code":"view","icon":"ant-design:eye-outlined","isDefault":true,"isUse":true},{"buttonId":"2009445983314264065","name":"新增","code":"add","icon":"ant-design:plus-outlined","isDefault":true,"isUse":true},{"buttonId":"2009445983314264066","name":"编辑","code":"edit","icon":"ant-design:form-outlined","isDefault":true,"isUse":true,"isEnableLock":true},{"buttonId":"2009445983314264067","name":"删除","code":"delete","icon":"ant-design:delete-outlined","isDefault":true,"isUse":true}]
return filterButtonAuth(list);
})
const tableButtonConfig = computed(() => {
return buttonConfigs.value?.filter((x) => !actionButtons.value.includes(x.code));
});
const actionButtonConfig = computed(() => {
return buttonConfigs.value?.filter((x) => actionButtons.value.includes(x.code));
});
const btnEvent = {view : handleView,add : handleAdd,edit : handleEdit,delete : handleDelete,}
const { currentRoute } = useRouter();
const formIdComputedRef = computed(() => currentRoute.value.meta.formId as string);
provide<Ref<string>>('currentFormId', formIdComputedRef);
const [registerModal, { openModal }] = useModal();
const [registerTable, { reload, }] = useTable({
title: 'Cgdh列表',
api: getMesWarehouseArrivedPage,
rowKey: 'id',
columns: filterColumns,
pagination: {
pageSize: 10,
},
formConfig: {
labelWidth: 100,
schemas: searchFormSchema,
fieldMapToTime: [],
showResetButton: false,
},
bordered:false,
beforeFetch: (params) => {
pageParamsInfo.value = {...params, FormId: formIdComputedRef.value,PK: 'id' }
return pageParamsInfo.value;
},
afterFetch: (res) => {
},
useSearchForm: true,
showTableSetting: true,
striped: false,
actionColumn: {
width: 195,
title: '操作',
dataIndex: 'action',
slots: { customRender: 'action' },
},
tableSetting: {
size: false,
},
customRow,
isAdvancedQuery: false,
querySelectOption: JSON.stringify(searchFormSchema),
objectId: formIdComputedRef.value, ////系统表单formId,自定义表单releaseId的id值
});
function buttonClick(code) {
btnEvent[code]();
}
function handleAdd() {
openModal(true, { isUpdate: false, });
}
async function handleEdit(record: Recordable) {
let field = 'id';
try {
let hasIn = handleHasEnableLocke(buttonConfigs.value, 'edit');
if (hasIn) {
let res = await handleOpenFormEnableLockeData(
record[field],
formIdComputedRef.value,
);
if (res !== null) {
return;
}
}
let info = {
id: record[field],
isUpdate: true,
};
openModal(true, info);
} catch (error) {}
}
function handleDelete(record: Recordable) {
deleteList([record.id]);
}
function deleteList(ids) {
Modal.confirm({
title: '提示信息',
icon: createVNode(ExclamationCircleOutlined),
content: '是否确认删除?',
okText: '确认',
cancelText: '取消',
onOk() {
deleteMesWarehouseArrived(ids).then((_) => {
handleSuccess();
notification.success({
message: 'Tip',
description: t('删除成功!'),
});
});
},
onCancel() {},
});
}
function customRow(record: Recordable) {
return {
ondblclick: () => {
if (record.isCanEdit && hasPermission("cgdh:edit")) {
handleEdit(record);
}
},
};
}
function handleSuccess() {
reload();
}
function handleFormSuccess() {
handleSuccess();
handleCloseFormEnableLocke(buttonConfigs.value, 'edit');
}
function handleFormCancel() {
handleCloseFormEnableLocke(buttonConfigs.value, 'edit');
}
function handleView(record: Recordable) {
let info={
isView: true,
id: record.id,
}
openModal(true, info);
}
function getLessActions(record: Recordable) {
let list = getActions(record);
return list.slice(0, listSpliceNum.value);
}
function getMoreActions(record: Recordable) {
let list = getActions(record);
return list.slice(listSpliceNum.value);
}
function getActions(record: Recordable):ActionItem[] {
record.isCanEdit = false;
let actionsList: ActionItem[] = [];
actionButtonConfig.value?.map((button) => {
if (!record?.workflowData?.processId) {
record.isCanEdit = true;
actionsList.push({
...button,
auth: `cgdh:${button.code}`,
label: button?.name,
color: button.code === 'delete' ? 'error' : undefined,
onClick: btnEvent[button.code]?.bind(null, record),
});
} else {
if (!['edit', 'delete'].includes(button.code)) {
actionsList.push({
auth: `cgdh:${button.code}`,
label: button?.name,
onClick: btnEvent[button.code]?.bind(null, record),
});
}
}
});
return actionsList;
}
</script>
<style lang="less" scoped>
:deep(.ant-table-selection-col) {
width: 50px;
}
.show{
display: flex;
}
.hide{
display: none !important;
}
</style>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment