Merge branch 'master' of http://119.91.43.128:3001/sheng/mes-ui-d2
Some checks failed
Release pipeline / Always run job (push) Has been cancelled
Release pipeline / publish (push) Has been cancelled

This commit is contained in:
hui
2026-06-02 13:56:00 +08:00
17 changed files with 3460 additions and 1 deletions

View File

@@ -0,0 +1,57 @@
import { request } from '@/api/_service'
// 注BASE URL 与后台 method 名暂沿用旧项目命名,等待后台数据库路由表统一更新
const BASE = 'production_configuration/matetial_model/matetial_category/'
function apiParams (method, data = {}) {
return {
method: `production_configuration_matetial_model_matetial_category_${method}`,
platform: 'background',
...data
}
}
// 获取全部物料类别
export function getMaterialCategoryAll (data) {
return request({
url: BASE + 'all',
method: 'get',
params: apiParams('all', data)
})
}
// 获取物料类别列表
export function getMaterialCategoryList (data) {
return request({
url: BASE + 'list',
method: 'get',
params: apiParams('list', data)
})
}
// 创建物料类别
export function createMaterialCategory (data) {
return request({
url: BASE + 'create',
method: 'post',
data: apiParams('create', data)
})
}
// 编辑物料类别
export function editMaterialCategory (data) {
return request({
url: BASE + 'edit',
method: 'put',
data: apiParams('edit', data)
})
}
// 删除物料类别
export function deleteMaterialCategory (data) {
return request({
url: BASE + 'delete',
method: 'delete',
data: apiParams('delete', data)
})
}

View File

@@ -0,0 +1,94 @@
import { request } from '@/api/_service'
// 注BASE URL 与后台 method 名暂沿用旧项目命名,等待后台数据库路由表统一更新
const BASE = 'production_configuration/matetial_model/matetial_management/'
function apiParams (method, data = {}) {
return {
method: `production_configuration_matetial_model_matetial_management_${method}`,
platform: 'background',
...data
}
}
// 获取全部物料
export function getMaterialMasterAll (data) {
return request({
url: BASE + 'all',
method: 'get',
params: apiParams('all', data)
})
}
// 获取物料列表
export function getMaterialMasterList (data) {
return request({
url: BASE + 'list',
method: 'get',
params: apiParams('list', data)
})
}
// 创建物料
export function createMaterialMaster (data) {
return request({
url: BASE + 'create',
method: 'post',
data: apiParams('create', data)
})
}
// 编辑物料
export function editMaterialMaster (data) {
return request({
url: BASE + 'edit',
method: 'put',
data: apiParams('edit', data)
})
}
// 删除物料
export function deleteMaterialMaster (data) {
return request({
url: BASE + 'delete',
method: 'delete',
data: apiParams('delete', data)
})
}
// 批量删除物料
export function batchDeleteMaterialMaster (data) {
return request({
url: BASE + 'batch_delete',
method: 'delete',
data: apiParams('batch_delete', data)
})
}
// 获取物料数据导入模板
export function getImportTemplate (data) {
return request({
url: BASE + 'get_import_template',
method: 'post',
responseType: 'blob',
data: apiParams('get_import_template', data)
})
}
// 物料数据导入
export function importMaterialData (data) {
return request({
url: BASE + 'matetial_data_import',
method: 'post',
data: apiParams('matetial_data_import', data)
})
}
// 物料数据导出任务创建
export function exportMaterialTask (data) {
return request({
url: BASE + 'matetial_data_export_task',
method: 'post',
data: apiParams('matetial_data_export_task', data)
})
}

View File

@@ -0,0 +1,57 @@
import { request } from '@/api/_service'
// 注BASE URL 与后台 method 名暂沿用旧项目命名,等待后台数据库路由表统一更新
const BASE = 'production_configuration/matetial_model/unit/'
function apiParams (method, data = {}) {
return {
method: `production_configuration_matetial_model_unit_${method}`,
platform: 'background',
...data
}
}
// 获取全部单位(下拉框用)
export function getUnitAll (data) {
return request({
url: BASE + 'all',
method: 'get',
params: apiParams('all', data)
})
}
// 获取单位列表
export function getUnitList (data) {
return request({
url: BASE + 'list',
method: 'get',
params: apiParams('list', data)
})
}
// 创建单位
export function createUnit (data) {
return request({
url: BASE + 'create',
method: 'post',
data: apiParams('create', data)
})
}
// 编辑单位
export function editUnit (data) {
return request({
url: BASE + 'edit',
method: 'put',
data: apiParams('edit', data)
})
}
// 删除单位
export function deleteUnit (data) {
return request({
url: BASE + 'delete',
method: 'delete',
data: apiParams('delete', data)
})
}

View File

@@ -0,0 +1,64 @@
import { request } from '@/api/_service'
const BASE = 'production_configuration/technology_model/optional_params/'
function apiParams (method, data = {}) {
return {
method: `production_master_data_process_model_optional_params_${method}`,
platform: 'background',
...data
}
}
export function getOptionalParamsList (data) {
return request({
url: BASE + 'list',
method: 'get',
params: apiParams('list', data)
})
}
export function createOptionalParams (data) {
return request({
url: BASE + 'create',
method: 'post',
data: apiParams('create', data)
})
}
export function editOptionalParams (data) {
return request({
url: BASE + 'edit',
method: 'put',
data: apiParams('edit', data)
})
}
export function deleteOptionalParams (data) {
return request({
url: BASE + 'delete',
method: 'delete',
data: apiParams('delete', data)
})
}
export function getImportTemplate (data) {
return request({
url: BASE + 'get_import_template',
method: 'post',
responseType: 'blob',
data: {
method: 'production_master_data_process_model_optional_params_get_import_template',
platform: 'background',
...data
}
})
}
export function importDataCreate (data) {
return request({
url: BASE + 'import_data_create',
method: 'post',
data: apiParams('import_data_create', data)
})
}

View File

@@ -0,0 +1,55 @@
import { request } from '@/api/_service'
const BASE = 'production_configuration/technology_model/technology_flow_workingsubclass/'
function apiParams (method, data = {}) {
return {
method: `production_master_data_process_model_process_step_${method}`,
platform: 'background',
...data
}
}
export function getProcessStepList (data) {
return request({
url: BASE + 'list',
method: 'get',
params: apiParams('list', data)
})
}
export function createProcessStep (data) {
return request({
url: BASE + 'create',
method: 'post',
data: apiParams('create', data)
})
}
export function editProcessStep (data) {
return request({
url: BASE + 'edit',
method: 'put',
data: apiParams('edit', data)
})
}
export function deleteProcessStep (data) {
return request({
url: BASE + 'delete',
method: 'delete',
data: apiParams('delete', data)
})
}
export function settingSubmit (data) {
return request({
url: BASE + 'setting_submit',
method: 'post',
data: {
method: 'production_master_data_process_model_process_step_setting_submit',
platform: 'background',
...data
}
})
}

View File

@@ -99,6 +99,153 @@
"confirm_delete": "Are you sure to delete?",
"validation_fail": "Validation failed",
"please_enter": "Please enter {name}"
},
"process_step": {
"search": "Search",
"reset": "Reset",
"query": "Query",
"sort": "No.",
"process_unit_code": "Process Unit Code",
"process_unit_name": "Process Unit Name",
"device_category": "Device Category",
"remark": "Remark",
"enter_remark": "Enter remark",
"operation": "Actions",
"add": "Add",
"edit": "Edit",
"delete": "Delete",
"tips": "Tip",
"confirm": "Confirm",
"cancel": "Cancel",
"enter_process_unit_code": "Enter process unit code",
"enter_process_unit_name": "Enter process unit name",
"select_device_category": "Please select device category",
"remark_required": "Please enter remark",
"preset_setting": "Preset Settings",
"add_process_unit": "Add Process Unit",
"edit_process_unit": "Edit Process Unit",
"preset_result_param": "Preset Result Parameters",
"length_1_100": "Length must be 1-100 characters",
"operation_success": "Operation succeeded",
"validation_fail": "Validation failed",
"confirm_message": "Proceed with this action?",
"name": "Name",
"param": "Parameter",
"category": "Category",
"default_value": "Default Value",
"unit": "Unit",
"is_unique": "Is Unique",
"yes": "Yes",
"no": "No",
"is_upload": "Is Upload Required",
"need_device_upload": "Requires Device Upload",
"add_row": "Add Row",
"import": "Import",
"close": "Close",
"help": "Process unit is the basic operation unit in the process flow, used to define each processing step in the production process.",
"enter_name": "Please enter name",
"enter_param": "Please enter parameter",
"select_type": "Please select type",
"confirm_delete_data": "Are you sure to delete this data?",
"save_success": "Saved successfully",
"add_success": "Added successfully",
"delete_success": "Deleted successfully",
"setting_placeholder": "Preset setting configuration area",
"setting_tip": "Configure preset settings for this process unit here",
"import_tip": "Import function is under development"
}
},
"material_model": {
"material_category": {
"search": "Search",
"reset": "Reset",
"enter_code": "Please enter category code",
"enter_name": "Please enter category name",
"enter_remark": "Please enter remark",
"operation_success": "Operation succeeded",
"create_success": "Create succeeded",
"edit_success": "Edit succeeded",
"delete_success": "Delete succeeded",
"sort": "#",
"code": "Code",
"name": "Name",
"remark": "Remark",
"create_time": "Created At",
"operation": "Action",
"add": "Add",
"edit": "Edit",
"delete": "Delete",
"remark_length": "Length 1 to 45 characters",
"add_title": "Add Material Category",
"edit_title": "Edit Material Category",
"cancel": "Cancel",
"confirm": "Confirm",
"tip": "Tip",
"confirm_delete": "Are you sure to perform this operation?",
"validation_fail": "Validation failed",
"please_enter": "Please enter {name}",
"help": "Material category is used to distinguish raw materials and semi-finished products"
},
"material_master": {
"search": "Search",
"reset": "Reset",
"material_code": "Material Code",
"material_name": "Material Name",
"material_category": "Category",
"unit": "Unit",
"enter_material_code": "Please enter material code",
"enter_material_name": "Please enter material name",
"select_material_category": "Please select a category",
"select_unit": "Please select a unit",
"remark": "Remark",
"enter_remark": "Please enter remark",
"remark_length": "Length 1 to 100 characters",
"create_user": "Created By",
"create_time": "Created At",
"operation": "Action",
"add": "Add",
"edit": "Edit",
"delete": "Delete",
"batch_delete": "Batch Delete",
"operation_success": "Operation succeeded",
"add_title": "Add Material",
"edit_title": "Edit Material",
"cancel": "Cancel",
"confirm": "Confirm",
"tip": "Tip",
"confirm_delete": "Are you sure to perform this operation?",
"confirm_batch_delete": "Are you sure to delete the selected materials?",
"please_select_data": "Please select data first",
"validation_fail": "Validation failed",
"please_enter": "Please enter {name}",
"help": "Material master data is used to maintain material code, name, specifications, etc."
},
"material_unit": {
"search": "Search",
"reset": "Reset",
"unit_code": "Unit Code",
"unit_name": "Unit Name",
"enter_unit_code": "Please enter unit code",
"enter_unit_name": "Please enter unit name",
"remark": "Remark",
"enter_remark": "Please enter remark",
"length_1_100": "Length 1 to 100 characters",
"create_time": "Created At",
"operation": "Action",
"sort": "#",
"add": "Add",
"edit": "Edit",
"delete": "Delete",
"operation_success": "Operation succeeded",
"add_title": "Add Unit",
"edit_title": "Edit Unit",
"cancel": "Cancel",
"confirm": "Confirm",
"tip": "Tip",
"confirm_delete": "Are you sure to perform this operation?",
"validation_fail": "Validation failed",
"please_enter": "Please enter {name}",
"help": "Unit is used to maintain material measurement units (e.g. piece, box, kg)"
}
},
"product_management": {

View File

@@ -99,6 +99,153 @@
"confirm_delete": "确定要执行该操作吗?",
"validation_fail": "校验失败",
"please_enter": "请输入{name}"
},
"process_step": {
"search": "查询",
"reset": "重置",
"query": "查询",
"sort": "序号",
"process_unit_code": "工序单元编码",
"process_unit_name": "工序单元名称",
"device_category": "设备类别",
"remark": "备注",
"enter_remark": "请输入备注",
"operation": "操作",
"add": "新增",
"edit": "编辑",
"delete": "删除",
"tips": "提示",
"confirm": "确定",
"cancel": "取消",
"enter_process_unit_code": "请输入工序单元编码",
"enter_process_unit_name": "请输入工序单元名称",
"select_device_category": "请选择设备类别",
"remark_required": "请输入备注",
"preset_setting": "预设设定值",
"add_process_unit": "新增工序单元",
"edit_process_unit": "编辑工序单元",
"preset_result_param": "预设结果参数",
"length_1_100": "长度在 1 到 100 个字符",
"operation_success": "操作成功",
"validation_fail": "校验失败",
"confirm_message": "确定要执行该操作吗?",
"name": "名称",
"param": "参数",
"category": "类别",
"default_value": "默认值",
"unit": "单位",
"is_unique": "是否唯一",
"yes": "是",
"no": "否",
"is_upload": "是否上传",
"need_device_upload": "是否需要设备上传",
"add_row": "新增一行",
"import": "导入",
"close": "关闭",
"help": "工序单元是工艺流程中的基本作业单元,用于定义生产过程中的各个加工步骤。",
"enter_name": "请输入名称",
"enter_param": "请输入参数",
"select_type": "请选择类型",
"confirm_delete_data": "确定删除该数据?",
"save_success": "保存成功",
"add_success": "新增成功",
"delete_success": "删除成功",
"setting_placeholder": "预设设定值配置区域",
"setting_tip": "在此配置工序单元的预设设定值",
"import_tip": "导入功能开发中"
}
},
"material_model": {
"material_category": {
"search": "查询",
"reset": "重置",
"enter_code": "请输入物料类别编码",
"enter_name": "请输入物料类别名称",
"enter_remark": "请输入备注",
"operation_success": "操作成功",
"create_success": "新增成功",
"edit_success": "编辑成功",
"delete_success": "删除成功",
"sort": "序号",
"code": "物料类别编码",
"name": "物料类别名称",
"remark": "备注",
"create_time": "创建时间",
"operation": "操作",
"add": "新 增",
"edit": "编 辑",
"delete": "删 除",
"remark_length": "长度在 1 到 45 个字符",
"add_title": "新增物料类别",
"edit_title": "编辑物料类别",
"cancel": "取消",
"confirm": "确定",
"tip": "提示",
"confirm_delete": "确定要执行该操作吗?",
"validation_fail": "校验失败",
"please_enter": "请输入{name}",
"help": "物料类别用于区分原材料和半成品"
},
"material_master": {
"search": "查询",
"reset": "重置",
"material_code": "物料编码",
"material_name": "物料名称",
"material_category": "物料类别",
"unit": "单位",
"enter_material_code": "请输入物料编码",
"enter_material_name": "请输入物料名称",
"select_material_category": "请选择物料类别",
"select_unit": "请选择单位",
"remark": "备注",
"enter_remark": "请输入备注",
"remark_length": "长度在 1 到 100 个字符",
"create_user": "创建人",
"create_time": "创建时间",
"operation": "操作",
"add": "新 增",
"edit": "编 辑",
"delete": "删 除",
"batch_delete": "批量删除",
"operation_success": "操作成功",
"add_title": "新增物料信息",
"edit_title": "编辑物料信息",
"cancel": "取消",
"confirm": "确定",
"tip": "提示",
"confirm_delete": "确定要执行该操作吗?",
"confirm_batch_delete": "确定要删除所选物料吗?",
"please_select_data": "请先选择要删除的数据",
"validation_fail": "校验失败",
"please_enter": "请输入{name}",
"help": "物料信息用于维护物料编码、名称、规格等属性"
},
"material_unit": {
"search": "查询",
"reset": "重置",
"unit_code": "单位编码",
"unit_name": "单位名称",
"enter_unit_code": "请输入单位编码",
"enter_unit_name": "请输入单位名称",
"remark": "备注",
"enter_remark": "请输入备注",
"length_1_100": "长度在 1 到 100 个字符",
"create_time": "创建时间",
"operation": "操作",
"sort": "序号",
"add": "新 增",
"edit": "编 辑",
"delete": "删 除",
"operation_success": "操作成功",
"add_title": "新增单位",
"edit_title": "编辑单位",
"cancel": "取消",
"confirm": "确定",
"tip": "提示",
"confirm_delete": "确定要执行该操作吗?",
"validation_fail": "校验失败",
"please_enter": "请输入{name}",
"help": "计量单位用于维护物料所用单位如个、箱、kg"
}
},
"product_management": {

View File

@@ -32,11 +32,35 @@ export default {
meta: { ...meta, cache: true, title: '工艺流程类别' },
component: _import('production-master-data/process-model/process-category')
},
{
path: 'technology_model/technology_flow_workingsubclass',
name: `${pre}technology_model-technology_flow_workingsubclass`,
meta: { ...meta, cache: true, title: '工序单元' },
component: _import('production-master-data/process-model/process-step')
},
{
path: 'product_model/battery_model',
name: `${pre}product_management-product_list`,
meta: { ...meta, cache: true, title: '产品列表' },
component: _import('production-master-data/product-management/product-list')
},
{
path: 'matetial_model/matetial_category',
name: `${pre}material_model-material_category`,
meta: { ...meta, cache: true, title: '物料类别列表' },
component: _import('production-master-data/material-model/material-category')
},
{
path: 'matetial_model/matetial_management',
name: `${pre}material_model-material_master`,
meta: { ...meta, cache: true, title: '物料信息管理' },
component: _import('production-master-data/material-model/material-master')
},
{
path: 'matetial_model/unit',
name: `${pre}material_model-material_unit`,
meta: { ...meta, cache: true, title: '计量单位' },
component: _import('production-master-data/material-model/material-unit')
}
])('production_configuration-')
}

View File

@@ -0,0 +1,294 @@
<template>
<d2-container>
<template #header>
<div class="search-bar">
<el-form :inline="true" size="mini">
<el-form-item :label="$t(key('code'))">
<el-input
v-model="search.code"
:placeholder="$t(key('enter_code'))"
clearable
style="width:200px"
@keyup.enter.native="onSearch"
/>
</el-form-item>
<el-form-item :label="$t(key('name'))">
<el-input
v-model="search.name"
:placeholder="$t(key('enter_name'))"
clearable
style="width:200px"
@keyup.enter.native="onSearch"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="onSearch">
{{ $t(key('search')) }}
</el-button>
<el-button icon="el-icon-refresh" @click="onReset">
{{ $t(key('reset')) }}
</el-button>
</el-form-item>
</el-form>
</div>
</template>
<page-table
ref="pageTable"
:columns="columns"
:data="tableData"
:loading="loading"
:toolbar-buttons="toolbarButtons"
:row-buttons="rowButtons"
:pagination="pagination"
help-url="/help/material-category"
:help-text="$t(ckey('help'))"
auto-height
@page-change="onPageChange"
@selection-change="onSelect"
/>
<page-dialog-form
ref="dialogForm"
:visible.sync="dialogVisible"
:title="dialogTitle"
:width="'35%'"
:form-cols="formCols"
:form-data="formData"
:rules="rules"
:label-width="'100px'"
:submitting="submitting"
:confirm-text="key('confirm')"
:cancel-text="key('cancel')"
@submit="onDialogSubmit"
@close="onDialogClose"
/>
</d2-container>
</template>
<script>
import { useTableColumns } from '@/composables/useTableColumns'
import { useTableButtons } from '@/composables/useTableButtons'
import { i18nMixin } from '@/composables/useI18n'
import { confirmMixin } from '@/composables/useConfirmHandle'
import {
getMaterialCategoryList,
createMaterialCategory,
editMaterialCategory,
deleteMaterialCategory
} from '@/api/production-master-data/material-category'
import PageTable from '@/components/page-table'
import PageDialogForm from '@/components/page-dialog-form'
export default {
name: 'production-master-data-material-category',
components: { PageTable, PageDialogForm },
mixins: [i18nMixin('page.production_master_data.material_model.material_category'), confirmMixin],
data () {
return {
loading: false,
submitting: false,
tableData: [],
selectedRows: [],
dialogVisible: false,
dialogTitle: '',
editId: '',
handleType: 'create',
search: { code: '', name: '' },
pagination: { current: 1, size: 10, total: 0 },
formData: { code: '', name: '', remark: '' },
rules: {
code: [
{ required: true, message: this.key('enter_code'), trigger: 'blur' },
{ min: 1, max: 45, message: this.key('remark_length'), trigger: 'blur' }
],
name: [
{ required: true, message: this.key('enter_name'), trigger: 'blur' },
{ min: 1, max: 45, message: this.key('remark_length'), trigger: 'blur' }
]
},
columns: [],
toolbarButtons: [],
rowButtons: [],
formCols: [
[
{
type: 'input',
prop: 'code',
label: this.key('code'),
placeholder: this.key('enter_code'),
clearable: true,
style: { width: '90%' }
}
],
[
{
type: 'input',
prop: 'name',
label: this.key('name'),
placeholder: this.key('enter_name'),
clearable: true,
style: { width: '90%' }
}
],
[
{
type: 'input',
prop: 'remark',
inputType: 'textarea',
autosize: { minRows: 2, maxRows: 6 },
label: this.key('remark'),
placeholder: this.key('enter_remark'),
clearable: true,
style: { width: '90%' }
}
]
]
}
},
created () {
this.columns = useTableColumns([
{ prop: 'sort', label: this.key('sort'), width: 80 },
{ prop: 'code', label: this.key('code'), minWidth: 120 },
{ prop: 'name', label: this.key('name'), minWidth: 120 },
{ prop: 'remark', label: this.key('remark') },
{ prop: 'create_time', label: this.key('create_time'), minWidth: 160 },
{ prop: '_actions', label: this.key('operation'), width: 160, fixed: 'right' }
])
const btns = useTableButtons({
toolbar: [
{
key: 'add',
label: this.key('add'),
icon: 'el-icon-plus',
type: 'primary',
auth: '/production_configuration/matetial_model/matetial_category/create',
onClick: this.openAdd
}
],
row: [
{
key: 'edit',
label: this.key('edit'),
icon: 'el-icon-edit',
auth: '/production_configuration/matetial_model/matetial_category/edit',
onClick: this.openEdit
},
{
key: 'delete',
label: this.key('delete'),
icon: 'el-icon-delete',
color: 'danger',
auth: '/production_configuration/matetial_model/matetial_category/delete',
onClick: this.handleDelete
}
]
}, this.$permission)
this.toolbarButtons = btns.toolbarButtons
this.rowButtons = btns.rowButtons
this.fetchData()
},
methods: {
async fetchData () {
this.loading = true
try {
const res = await getMaterialCategoryList({
...this.search,
page_no: this.pagination.current,
page_size: this.pagination.size
})
const list = Array.isArray(res) ? res : (res.data || [])
const total = Array.isArray(res) ? res.length : (res.count || 0)
this.tableData = list
this.pagination.total = total
} finally {
this.loading = false
}
},
onSearch () {
this.pagination.current = 1
this.fetchData()
},
onReset () {
this.search = { code: '', name: '' }
this.pagination.current = 1
this.fetchData()
},
onPageChange (page) {
this.pagination.current = page.current
this.pagination.size = page.size
this.fetchData()
},
onSelect (rows) {
this.selectedRows = rows
},
resetForm () {
this.formData = { code: '', name: '', remark: '' }
this.editId = ''
},
openAdd () {
this.handleType = 'create'
this.dialogTitle = this.key('add_title')
this.$nextTick(() => {
this.$refs.dialogForm && this.$refs.dialogForm.reset()
this.resetForm()
this.dialogVisible = true
})
},
openEdit (row) {
this.handleType = 'edit'
this.dialogTitle = this.key('edit_title')
this.editId = row.id
this.formData = {
code: row.code,
name: row.name,
remark: row.remark || ''
}
this.dialogVisible = true
},
async onDialogSubmit () {
this.submitting = true
try {
if (this.handleType === 'create') {
await createMaterialCategory(this.formData)
} else {
await editMaterialCategory({ ...this.formData, id: this.editId })
}
this.$message.success(this.$t(this.key('operation_success')))
this.dialogVisible = false
this.fetchData()
} finally {
this.submitting = false
}
},
onDialogClose () {
this.resetForm()
},
async handleDelete (row) {
const cancelled = await this.$confirmAction(
{
message: this.key('confirm_delete'),
title: this.key('tip')
},
() => deleteMaterialCategory({ id: [row.id] })
)
if (cancelled) return
this.$message.success(this.$t(this.key('operation_success')))
this.pagination.current = Math.min(
this.pagination.current,
Math.ceil((this.pagination.total - 1) / this.pagination.size) || 1
)
this.fetchData()
}
}
}
</script>
<style scoped>
.search-bar {
padding: 10px 0;
}
/deep/ .el-form-item--mini.el-form-item {
margin-bottom: 4px;
}
</style>

View File

@@ -0,0 +1,401 @@
<template>
<d2-container>
<template #header>
<div class="search-bar">
<el-form :inline="true" size="mini">
<el-form-item :label="$t(key('material_code'))">
<el-input
v-model="search.code"
:placeholder="$t(key('enter_material_code'))"
clearable
style="width:200px"
@keyup.enter.native="onSearch"
/>
</el-form-item>
<el-form-item :label="$t(key('material_name'))">
<el-input
v-model="search.name"
:placeholder="$t(key('enter_material_name'))"
clearable
style="width:200px"
@keyup.enter.native="onSearch"
/>
</el-form-item>
<el-form-item :label="$t(key('material_category'))">
<el-select
v-model="search.bom_source_category_id"
:placeholder="$t(key('select_material_category'))"
clearable
filterable
style="width:200px"
>
<el-option
v-for="item in categoryOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="onSearch">
{{ $t(key('search')) }}
</el-button>
<el-button icon="el-icon-refresh" @click="onReset">
{{ $t(key('reset')) }}
</el-button>
</el-form-item>
</el-form>
</div>
</template>
<page-table
ref="pageTable"
:columns="columns"
:data="tableData"
:loading="loading"
:toolbar-buttons="toolbarButtons"
:row-buttons="rowButtons"
:pagination="pagination"
help-url="/help/material-master"
:help-text="$t(ckey('help'))"
auto-height
@page-change="onPageChange"
@selection-change="onSelect"
>
<template #col-remark="{ row }">
<el-popover
v-if="row.remark && row.remark.length > 20"
placement="top-start"
width="300"
trigger="hover"
:content="row.remark"
>
<span slot="reference" style="cursor: pointer;">{{ row.remark.substr(0, 20) }}...</span>
</el-popover>
<span v-else>{{ row.remark }}</span>
</template>
</page-table>
<page-dialog-form
ref="dialogForm"
:visible.sync="dialogVisible"
:title="dialogTitle"
:width="'35%'"
:form-cols="dialogFormCols"
:form-data="formData"
:rules="rules"
:label-width="'100px'"
:submitting="submitting"
:confirm-text="key('confirm')"
:cancel-text="key('cancel')"
@submit="onDialogSubmit"
@close="onDialogClose"
/>
</d2-container>
</template>
<script>
import { useTableColumns } from '@/composables/useTableColumns'
import { useTableButtons } from '@/composables/useTableButtons'
import { i18nMixin } from '@/composables/useI18n'
import { confirmMixin } from '@/composables/useConfirmHandle'
import {
getMaterialMasterList,
createMaterialMaster,
editMaterialMaster,
deleteMaterialMaster,
batchDeleteMaterialMaster
} from '@/api/production-master-data/material-master'
import { getMaterialCategoryAll } from '@/api/production-master-data/material-category'
import PageTable from '@/components/page-table'
import PageDialogForm from '@/components/page-dialog-form'
export default {
name: 'production-master-data-material-master',
components: { PageTable, PageDialogForm },
mixins: [i18nMixin('page.production_master_data.material_model.material_master'), confirmMixin],
data () {
return {
loading: false,
submitting: false,
tableData: [],
selectedRows: [],
dialogVisible: false,
dialogTitle: '',
editId: '',
handleType: 'create',
search: { code: '', name: '', bom_source_category_id: '' },
pagination: { current: 1, size: 10, total: 0 },
categoryOptions: [],
formData: { code: '', name: '', bom_source_category_id: '', unit_id: '', remark: '' },
rules: {
code: [
{ required: true, message: this.key('enter_material_code'), trigger: 'blur' },
{ min: 1, max: 100, message: this.key('remark_length'), trigger: 'blur' }
],
name: [
{ required: true, message: this.key('enter_material_name'), trigger: 'blur' },
{ min: 1, max: 100, message: this.key('remark_length'), trigger: 'blur' }
],
bom_source_category_id: [
{ required: true, message: this.key('select_material_category'), trigger: 'change' }
]
},
columns: [],
toolbarButtons: [],
rowButtons: [],
// 表单基础结构,单位字段预留(待 unit 模块迁移后接入下拉数据源)
baseFormCols: [
[
{
type: 'input',
prop: 'code',
label: this.key('material_code'),
placeholder: this.key('enter_material_code'),
clearable: true,
style: { width: '90%' }
}
],
[
{
type: 'input',
prop: 'name',
label: this.key('material_name'),
placeholder: this.key('enter_material_name'),
clearable: true,
style: { width: '90%' }
}
],
[
{
type: 'select',
prop: 'bom_source_category_id',
label: this.key('material_category'),
placeholder: this.key('select_material_category'),
clearable: true,
filterable: true,
style: { width: '90%' },
options: []
}
],
[
{
type: 'input',
prop: 'unit_id',
label: this.key('unit'),
placeholder: this.key('select_unit'),
clearable: true,
style: { width: '90%' }
}
],
[
{
type: 'input',
prop: 'remark',
inputType: 'textarea',
autosize: { minRows: 2, maxRows: 6 },
label: this.key('remark'),
placeholder: this.key('enter_remark'),
clearable: true,
style: { width: '90%' }
}
]
]
}
},
computed: {
// 类别下拉数据通过 computed 注入,避免 JSON.parse(JSON.stringify) 深拷贝
dialogFormCols () {
return this.baseFormCols.map(row => row.map(item => {
if (item.prop === 'bom_source_category_id') {
return { ...item, options: this.categoryOptions }
}
return item
}))
}
},
created () {
this.initCategoryOptions()
this.columns = useTableColumns([
{ prop: 'sort', label: this.key('sort'), width: 80 },
{ prop: 'code', label: this.key('material_code'), minWidth: 120 },
{ prop: 'name', label: this.key('material_name'), minWidth: 140 },
{ prop: 'bom_source_category_name', label: this.key('material_category'), minWidth: 120 },
{ prop: 'unit_name', label: this.key('unit'), minWidth: 100 },
{ prop: 'remark', label: this.key('remark'), minWidth: 160, slot: true },
{ prop: 'username', label: this.key('create_user'), minWidth: 100 },
{ prop: 'create_time', label: this.key('create_time'), minWidth: 160 },
{ prop: '_actions', label: this.key('operation'), width: 180, fixed: 'right' }
])
const btns = useTableButtons({
toolbar: [
{
key: 'add',
label: this.key('add'),
icon: 'el-icon-plus',
type: 'primary',
auth: '/production_configuration/matetial_model/matetial_management/create',
onClick: this.openAdd
},
{
key: 'batch_delete',
label: this.key('batch_delete'),
icon: 'el-icon-delete',
color: 'danger',
auth: '/system_settings/matetial_model/matetial_management/batch-delete',
onClick: this.handleBatchDelete
}
],
row: [
{
key: 'edit',
label: this.key('edit'),
icon: 'el-icon-edit',
auth: '/production_configuration/matetial_model/matetial_management/edit',
onClick: this.openEdit
},
{
key: 'delete',
label: this.key('delete'),
icon: 'el-icon-delete',
color: 'danger',
auth: '/production_configuration/matetial_model/matetial_management/delete',
onClick: this.handleDelete
}
]
}, this.$permission)
this.toolbarButtons = btns.toolbarButtons
this.rowButtons = btns.rowButtons
this.fetchData()
},
methods: {
async initCategoryOptions () {
try {
const res = await getMaterialCategoryAll()
const data = Array.isArray(res) ? res : (res.data || [])
this.categoryOptions = data.map(item => ({ value: item.id, label: item.name }))
} catch { /* 类别下拉加载失败时,下拉为空即可,不影响主流程 */ }
},
async fetchData () {
this.loading = true
try {
const res = await getMaterialMasterList({
...this.search,
page_no: this.pagination.current,
page_size: this.pagination.size
})
const list = Array.isArray(res) ? res : (res.data || [])
const total = Array.isArray(res) ? res.length : (res.count || 0)
this.tableData = list
this.pagination.total = total
} finally {
this.loading = false
}
},
onSearch () {
this.pagination.current = 1
this.fetchData()
},
onReset () {
this.search = { code: '', name: '', bom_source_category_id: '' }
this.pagination.current = 1
this.fetchData()
},
onPageChange (page) {
this.pagination.current = page.current
this.pagination.size = page.size
this.fetchData()
},
onSelect (rows) {
this.selectedRows = rows
},
resetForm () {
this.formData = { code: '', name: '', bom_source_category_id: '', unit_id: '', remark: '' }
this.editId = ''
},
openAdd () {
this.handleType = 'create'
this.dialogTitle = this.key('add_title')
this.$nextTick(() => {
this.$refs.dialogForm && this.$refs.dialogForm.reset()
this.resetForm()
this.dialogVisible = true
})
},
openEdit (row) {
this.handleType = 'edit'
this.dialogTitle = this.key('edit_title')
this.editId = row.id
this.formData = {
code: row.code,
name: row.name,
bom_source_category_id: row.bom_source_category_id,
unit_id: row.unit_id,
remark: row.remark || ''
}
this.dialogVisible = true
},
async onDialogSubmit () {
this.submitting = true
try {
if (this.handleType === 'create') {
await createMaterialMaster(this.formData)
} else {
await editMaterialMaster({ ...this.formData, id: this.editId })
}
this.$message.success(this.$t(this.key('operation_success')))
this.dialogVisible = false
this.fetchData()
} finally {
this.submitting = false
}
},
onDialogClose () {
this.resetForm()
},
async handleDelete (row) {
const cancelled = await this.$confirmAction(
{
message: this.key('confirm_delete'),
title: this.key('tip')
},
() => deleteMaterialMaster({ id: [row.id] })
)
if (cancelled) return
this.$message.success(this.$t(this.key('operation_success')))
this.pagination.current = Math.min(
this.pagination.current,
Math.ceil((this.pagination.total - 1) / this.pagination.size) || 1
)
this.fetchData()
},
async handleBatchDelete () {
if (this.selectedRows.length <= 0) {
this.$message.error(this.$t(this.key('please_select_data')))
return
}
const ids = this.selectedRows.map(item => item.id)
const cancelled = await this.$confirmAction(
{
message: this.key('confirm_batch_delete'),
title: this.key('tip')
},
() => batchDeleteMaterialMaster({ id: ids })
)
if (cancelled) return
this.$message.success(this.$t(this.key('operation_success')))
this.fetchData()
}
}
}
</script>
<style scoped>
.search-bar {
padding: 10px 0;
}
/deep/ .el-form-item--mini.el-form-item {
margin-bottom: 4px;
}
</style>

View File

@@ -0,0 +1,288 @@
<template>
<d2-container>
<template #header>
<div class="search-bar">
<el-form :inline="true" size="mini">
<el-form-item :label="$t(key('unit_code'))">
<el-input
v-model="search.code"
:placeholder="$t(key('enter_unit_code'))"
clearable
style="width:200px"
@keyup.enter.native="onSearch"
/>
</el-form-item>
<el-form-item :label="$t(key('unit_name'))">
<el-input
v-model="search.name"
:placeholder="$t(key('enter_unit_name'))"
clearable
style="width:200px"
@keyup.enter.native="onSearch"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="onSearch">
{{ $t(key('search')) }}
</el-button>
<el-button icon="el-icon-refresh" @click="onReset">
{{ $t(key('reset')) }}
</el-button>
</el-form-item>
</el-form>
</div>
</template>
<page-table
ref="pageTable"
:columns="columns"
:data="tableData"
:loading="loading"
:toolbar-buttons="toolbarButtons"
:row-buttons="rowButtons"
:pagination="pagination"
:help-text="$t(ckey('help'))"
auto-height
@page-change="onPageChange"
/>
<page-dialog-form
ref="dialogForm"
:visible.sync="dialogVisible"
:title="dialogTitle"
:width="'35%'"
:form-cols="formCols"
:form-data="formData"
:rules="rules"
:label-width="'100px'"
:submitting="submitting"
:confirm-text="key('confirm')"
:cancel-text="key('cancel')"
@submit="onDialogSubmit"
@close="onDialogClose"
/>
</d2-container>
</template>
<script>
import { useTableColumns } from '@/composables/useTableColumns'
import { useTableButtons } from '@/composables/useTableButtons'
import { i18nMixin } from '@/composables/useI18n'
import { confirmMixin } from '@/composables/useConfirmHandle'
import {
getUnitList,
createUnit,
editUnit,
deleteUnit
} from '@/api/production-master-data/material-unit'
import PageTable from '@/components/page-table'
import PageDialogForm from '@/components/page-dialog-form'
export default {
name: 'production-master-data-material-unit',
components: { PageTable, PageDialogForm },
mixins: [i18nMixin('page.production_master_data.material_model.material_unit'), confirmMixin],
data () {
return {
loading: false,
submitting: false,
tableData: [],
dialogVisible: false,
dialogTitle: '',
editId: '',
handleType: 'create',
search: { code: '', name: '' },
pagination: { current: 1, size: 10, total: 0 },
formData: { code: '', name: '', remark: '' },
rules: {
code: [
{ required: true, message: this.key('enter_unit_code'), trigger: 'blur' },
{ min: 1, max: 100, message: this.key('length_1_100'), trigger: 'blur' }
],
name: [
{ required: true, message: this.key('enter_unit_name'), trigger: 'blur' },
{ min: 1, max: 100, message: this.key('length_1_100'), trigger: 'blur' }
]
},
formCols: [
[
{
type: 'input',
prop: 'code',
label: this.key('unit_code'),
placeholder: this.key('enter_unit_code'),
clearable: true,
style: { width: '90%' }
}
],
[
{
type: 'input',
prop: 'name',
label: this.key('unit_name'),
placeholder: this.key('enter_unit_name'),
clearable: true,
style: { width: '90%' }
}
],
[
{
type: 'input',
prop: 'remark',
inputType: 'textarea',
autosize: { minRows: 2, maxRows: 6 },
label: this.key('remark'),
placeholder: this.key('enter_remark'),
clearable: true,
style: { width: '90%' }
}
]
],
columns: [],
toolbarButtons: [],
rowButtons: []
}
},
created () {
this.columns = useTableColumns([
{ prop: 'sort', label: this.key('sort'), width: 80 },
{ prop: 'code', label: this.key('unit_code'), minWidth: 140 },
{ prop: 'name', label: this.key('unit_name'), minWidth: 140 },
{ prop: 'remark', label: this.key('remark'), minWidth: 200 },
{ prop: 'create_time', label: this.key('create_time'), minWidth: 160 },
{ prop: '_actions', label: this.key('operation'), width: 180, fixed: 'right' }
])
const btns = useTableButtons({
toolbar: [
{
key: 'add',
label: this.key('add'),
icon: 'el-icon-plus',
type: 'primary',
auth: '/production_configuration/matetial_model/unit/create',
onClick: this.openAdd
}
],
row: [
{
key: 'edit',
label: this.key('edit'),
icon: 'el-icon-edit',
auth: '/production_configuration/matetial_model/unit/edit',
onClick: this.openEdit
},
{
key: 'delete',
label: this.key('delete'),
icon: 'el-icon-delete',
color: 'danger',
auth: '/production_configuration/matetial_model/unit/delete',
onClick: this.handleDelete
}
]
}, this.$permission)
this.toolbarButtons = btns.toolbarButtons
this.rowButtons = btns.rowButtons
this.fetchData()
},
methods: {
async fetchData () {
this.loading = true
try {
const res = await getUnitList({
...this.search,
page_no: this.pagination.current,
page_size: this.pagination.size
})
const list = Array.isArray(res) ? res : (res.data || [])
const total = Array.isArray(res) ? res.length : (res.count || 0)
this.tableData = list
this.pagination.total = total
} finally {
this.loading = false
}
},
onSearch () {
this.pagination.current = 1
this.fetchData()
},
onReset () {
this.search = { code: '', name: '' }
this.pagination.current = 1
this.fetchData()
},
onPageChange (page) {
this.pagination.current = page.current
this.pagination.size = page.size
this.fetchData()
},
resetForm () {
this.formData = { code: '', name: '', remark: '' }
this.editId = ''
},
openAdd () {
this.handleType = 'create'
this.dialogTitle = this.key('add_title')
this.$nextTick(() => {
this.$refs.dialogForm && this.$refs.dialogForm.reset()
this.resetForm()
this.dialogVisible = true
})
},
openEdit (row) {
this.handleType = 'edit'
this.dialogTitle = this.key('edit_title')
this.editId = row.id
this.formData = {
code: row.code,
name: row.name,
remark: row.remark || ''
}
this.dialogVisible = true
},
async onDialogSubmit () {
this.submitting = true
try {
if (this.handleType === 'create') {
await createUnit(this.formData)
} else {
await editUnit({ ...this.formData, id: this.editId })
}
this.$message.success(this.$t(this.key('operation_success')))
this.dialogVisible = false
this.fetchData()
} finally {
this.submitting = false
}
},
onDialogClose () {
this.resetForm()
},
async handleDelete (row) {
const cancelled = await this.$confirmAction(
{
message: this.key('confirm_delete'),
title: this.key('tip')
},
() => deleteUnit({ id: [row.id] })
)
if (cancelled) return
this.$message.success(this.$t(this.key('operation_success')))
this.pagination.current = Math.min(
this.pagination.current,
Math.ceil((this.pagination.total - 1) / this.pagination.size) || 1
)
this.fetchData()
}
}
}
</script>
<style scoped>
.search-bar {
padding: 10px 0;
}
/deep/ .el-form-item--mini.el-form-item {
margin-bottom: 4px;
}
</style>

View File

@@ -0,0 +1,302 @@
<template>
<el-dialog
:title="title"
:visible.sync="visible"
:append-to-body="true"
:close-on-click-modal="false"
:before-close="handleClose"
width="80%"
>
<div class="search-content">
<el-card class="box-card">
<el-form :inline="true" size="mini">
<el-form-item :label="$t(key('name'))">
<el-input
v-model="searchForm.name"
:placeholder="$t(key('enter_name'))"
clearable
/>
</el-form-item>
<el-form-item :label="$t(key('param'))">
<el-input
v-model="searchForm.code"
:placeholder="$t(key('enter_param'))"
clearable
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="onSearch">
{{ $t(key('query')) }}
</el-button>
</el-form-item>
</el-form>
</el-card>
</div>
<el-table
ref="table"
:data="tableData"
border
:loading="loading"
max-height="450"
style="width: 100%"
>
<el-table-column :label="$t(key('name'))" prop="name" width="200" show-overflow-tooltip />
<el-table-column :label="$t(key('param'))" prop="code" width="150" show-overflow-tooltip />
<el-table-column :label="$t(key('category'))" prop="field_type" width="120" />
<el-table-column :label="$t(key('remark'))" prop="remark" show-overflow-tooltip />
<el-table-column :label="$t(key('is_unique'))" width="100" align="center">
<template slot-scope="{ row }">
<el-tag v-if="row.is_only === 1" type="success" size="mini">{{ $t(key('yes')) }}</el-tag>
<el-tag v-else type="info" size="mini">{{ $t(key('no')) }}</el-tag>
</template>
</el-table-column>
<el-table-column :label="$t(key('is_upload'))" width="100" align="center">
<template slot-scope="{ row }">
<el-tag v-if="row.is_upload === 1" type="success" size="mini">{{ $t(key('yes')) }}</el-tag>
<el-tag v-else type="info" size="mini">{{ $t(key('no')) }}</el-tag>
</template>
</el-table-column>
<el-table-column :label="$t(key('operation'))" width="120" fixed="right">
<template slot-scope="{ row }">
<el-button type="text" size="mini" icon="el-icon-edit" @click="handleEdit(row)">
{{ $t(key('edit')) }}
</el-button>
<el-button type="text" size="mini" icon="el-icon-delete" style="color: #F56C6C" @click="handleDelete(row)">
{{ $t(key('delete')) }}
</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
:current-page="pagination.current"
:page-sizes="[10, 20, 50, 100]"
:page-size="pagination.size"
:total="pagination.total"
layout="total, sizes, prev, pager, next, jumper"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
/>
<div slot="footer" class="dialog-footer">
<el-button type="primary" size="mini" @click="handleAdd">{{ $t(key('add_row')) }}</el-button>
<el-button type="success" size="mini" icon="el-icon-download" @click="handleImport">{{ $t(key('import')) }}</el-button>
<el-button size="mini" @click="handleClose">{{ $t(key('close')) }}</el-button>
</div>
<el-dialog
:title="dialogTitle"
:visible.sync="innerVisible"
append-to-body
width="600px"
:before-close="handleInnerClose"
>
<el-form ref="form" :model="formData" :rules="rules" label-width="100px">
<el-form-item :label="$t(key('param'))" prop="code">
<el-input v-model="formData.code" :placeholder="$t(key('enter_param'))" clearable />
</el-form-item>
<el-form-item :label="$t(key('name'))" prop="name">
<el-input v-model="formData.name" :placeholder="$t(key('enter_name'))" clearable />
</el-form-item>
<el-form-item :label="$t(key('category'))" prop="field_type">
<el-select v-model="formData.field_type" :placeholder="$t(key('select_type'))" style="width: 100%">
<el-option label="FLOAT" value="FLOAT" />
<el-option label="INT" value="INT" />
<el-option label="VARCHAR" value="VARCHAR" />
<el-option label="TEXT" value="TEXT" />
<el-option label="TIMESTAMP" value="TIMESTAMP" />
</el-select>
</el-form-item>
<el-form-item :label="$t(key('remark'))">
<el-input v-model="formData.remark" type="textarea" :rows="2" :placeholder="$t(key('remark_required'))" />
</el-form-item>
<el-form-item :label="$t(key('is_unique'))">
<el-radio-group v-model="formData.is_only">
<el-radio :label="1">{{ $t(key('yes')) }}</el-radio>
<el-radio :label="0">{{ $t(key('no')) }}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item :label="$t(key('is_upload'))">
<el-radio-group v-model="formData.is_upload">
<el-radio :label="1">{{ $t(key('yes')) }}</el-radio>
<el-radio :label="0">{{ $t(key('no')) }}</el-radio>
</el-radio-group>
</el-form-item>
</el-form>
<div slot="footer">
<el-button @click="handleInnerClose">{{ $t(key('cancel')) }}</el-button>
<el-button type="primary" @click="handleSubmit">{{ $t(key('confirm')) }}</el-button>
</div>
</el-dialog>
</el-dialog>
</template>
<script>
import { i18nMixin } from '@/composables/useI18n'
import {
getOptionalParamsList,
createOptionalParams,
editOptionalParams,
deleteOptionalParams
} from '@/api/production-master-data/optional-params'
export default {
name: 'ProcessStepResultParam',
components: {},
mixins: [i18nMixin('page.production_master_data.process_model.process_step')],
props: {
title: {
type: String,
default: ''
},
visible: {
type: Boolean,
default: false
},
workingsubclass_id: {
type: [String, Number],
default: ''
}
},
data () {
return {
loading: false,
tableData: [],
searchForm: { name: '', code: '' },
pagination: { current: 1, size: 10, total: 0 },
innerVisible: false,
dialogTitle: '',
formData: {
id: '',
code: '',
name: '',
field_type: '',
remark: '',
is_only: 0,
is_upload: 0
},
rules: {
code: [{ required: true, message: this.key('enter_param'), trigger: 'blur' }],
name: [{ required: true, message: this.key('enter_name'), trigger: 'blur' }],
field_type: [{ required: true, message: this.key('select_type'), trigger: 'change' }]
}
}
},
watch: {
workingsubclass_id: {
handler (val) {
if (val) {
this.fetchData()
}
},
immediate: true
}
},
methods: {
handleClose () {
this.$emit('close')
},
handleInnerClose () {
this.innerVisible = false
this.$refs.form && this.$refs.form.resetFields()
},
onSearch () {
this.pagination.current = 1
this.fetchData()
},
fetchData () {
if (!this.workingsubclass_id) return
this.loading = true
getOptionalParamsList({
workingsubclass_id: this.workingsubclass_id,
page_no: this.pagination.current,
page_size: this.pagination.size,
...this.searchForm
}).then(res => {
const list = Array.isArray(res) ? res : (res.data || [])
const total = Array.isArray(res) ? res.length : (res.count || 0)
this.tableData = list
this.pagination.total = total
}).finally(() => {
this.loading = false
})
},
handleSizeChange (size) {
this.pagination.size = size
this.pagination.current = 1
this.fetchData()
},
handleCurrentChange (current) {
this.pagination.current = current
this.fetchData()
},
handleAdd () {
this.dialogTitle = this.key('add_row')
this.formData = {
id: '',
code: '',
name: '',
field_type: '',
remark: '',
is_only: 0,
is_upload: 0
}
this.innerVisible = true
},
handleEdit (row) {
this.dialogTitle = this.key('edit')
this.formData = {
id: row.id,
code: row.code,
name: row.name,
field_type: row.field_type,
remark: row.remark || '',
is_only: row.is_only || 0,
is_upload: row.is_upload || 0
}
this.innerVisible = true
},
handleDelete (row) {
this.$confirm(this.key('confirm_delete_data'), this.key('tips'), {
confirmButtonText: this.key('confirm'),
cancelButtonText: this.key('cancel'),
type: 'warning'
}).then(() => {
deleteOptionalParams({ workingsubclass_id: this.workingsubclass_id, id: row.id }).then(() => {
this.$message.success(this.key('operation_success'))
this.fetchData()
})
}).catch(() => {})
},
handleSubmit () {
this.$refs.form.validate(valid => {
if (!valid) return
const action = this.formData.id ? editOptionalParams : createOptionalParams
const data = { workingsubclass_id: this.workingsubclass_id, ...this.formData }
if (this.formData.id) {
delete data.id
}
action(data).then(() => {
this.$message.success(this.key('operation_success'))
this.innerVisible = false
this.$refs.form.resetFields()
this.fetchData()
})
})
},
handleImport () {
this.$message.info(this.key('import_tip'))
}
}
}
</script>
<style scoped>
.search-content {
margin-bottom: 15px;
}
.box-card {
width: 100%;
}
</style>

View File

@@ -0,0 +1,91 @@
<template>
<el-dialog
:title="title"
:visible.sync="visible"
:append-to-body="true"
:close-on-click-modal="false"
:before-close="handleClose"
:width="width"
>
<div class="setting-content">
<el-alert
:title="settingTip"
type="info"
:closable="false"
show-icon
/>
<div class="setting-placeholder">
<p>{{ $t(key('setting_placeholder')) }}</p>
<el-tag type="warning">{{ type }}</el-tag>
</div>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="handleClose">{{ $t(key('cancel')) }}</el-button>
<el-button type="primary" @click="handleSubmit">{{ $t(key('confirm')) }}</el-button>
</div>
</el-dialog>
</template>
<script>
import { i18nMixin } from '@/composables/useI18n'
export default {
name: 'ProcessStepSettingDialog',
mixins: [i18nMixin('page.production_master_data.process_model.process_step')],
props: {
type: {
type: String,
default: ''
},
code: {
type: String,
default: ''
},
title: {
type: String,
default: ''
},
width: {
type: String,
default: '50%'
},
visible: {
type: Boolean,
default: false
},
pluginData: {
default: ''
}
},
computed: {
settingTip () {
return this.$t(this.key('setting_tip'))
}
},
methods: {
handleClose () {
this.$emit('close')
},
handleSubmit () {
this.$message.success(this.key('operation_success'))
this.$emit('close')
}
}
}
</script>
<style scoped>
.setting-content {
padding: 10px 0;
}
.setting-placeholder {
margin-top: 20px;
text-align: center;
padding: 40px 0;
color: #909399;
}
.setting-placeholder p {
margin-bottom: 15px;
font-size: 14px;
}
</style>

View File

@@ -0,0 +1,379 @@
<template>
<d2-container>
<template #header>
<div class="search-bar">
<el-form :inline="true" size="mini">
<el-form-item :label="$t(key('process_unit_code'))">
<el-input
v-model="search.code"
:placeholder="$t(key('enter_process_unit_code'))"
clearable
style="width:200px"
@keyup.enter.native="onSearch"
/>
</el-form-item>
<el-form-item :label="$t(key('process_unit_name'))">
<el-input
v-model="search.name"
:placeholder="$t(key('enter_process_unit_name'))"
clearable
style="width:200px"
@keyup.enter.native="onSearch"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="onSearch">
{{ $t(key('search')) }}
</el-button>
<el-button icon="el-icon-refresh" @click="onReset">
{{ $t(key('reset')) }}
</el-button>
</el-form-item>
</el-form>
</div>
</template>
<page-table
ref="pageTable"
:columns="columns"
:data="tableData"
:loading="loading"
:toolbar-buttons="toolbarButtons"
:row-buttons="rowButtons"
:pagination="pagination"
help-url="/help/process-step"
:help-text="$t(ckey('help'))"
auto-height
@page-change="onPageChange"
@selection-change="onSelect"
/>
<page-dialog-form
ref="dialogForm"
:visible.sync="dialogVisible"
:title="dialogTitle"
:width="'35%'"
:form-cols="formCols"
:form-data="formData"
:rules="rules"
:label-width="'120px'"
:submitting="submitting"
:confirm-text="key('confirm')"
:cancel-text="key('cancel')"
@submit="onDialogSubmit"
@close="onDialogClose"
/>
<technology-flow-model
:visible.sync="settingVisible"
:title="settingTitle"
:type="settingType"
:code="settingCode"
:width="settingWidth"
:plugin-data="settingPluginData"
@close="settingVisible = false"
@submit="handleSettingSubmit"
/>
<result-param
:visible.sync="resultVisible"
:title="resultTitle"
:workingsubclass-id="currentRowId"
@close="resultVisible = false"
/>
</d2-container>
</template>
<script>
import { useTableColumns } from '@/composables/useTableColumns'
import { useTableButtons } from '@/composables/useTableButtons'
import { i18nMixin } from '@/composables/useI18n'
import { confirmMixin } from '@/composables/useConfirmHandle'
import {
getProcessStepList,
createProcessStep,
editProcessStep,
deleteProcessStep
} from '@/api/production-master-data/process-step'
import PageTable from '@/components/page-table'
import PageDialogForm from '@/components/page-dialog-form'
import TechnologyFlowModel from './components/technology-flow-model.vue'
import ResultParam from './components/result-param.vue'
export default {
name: 'production-master-data-process-step',
components: { PageTable, PageDialogForm, TechnologyFlowModel, ResultParam },
mixins: [i18nMixin('page.production_master_data.process_model.process_step'), confirmMixin],
data () {
return {
loading: false,
submitting: false,
tableData: [],
selectedRows: [],
dialogVisible: false,
dialogTitle: '',
editId: '',
handleType: 'create',
search: { code: '', name: '' },
pagination: { current: 1, size: 10, total: 0 },
formData: { code: '', name: '', device_category_id: '', remark: '' },
settingVisible: false,
settingTitle: '',
settingType: '',
settingCode: '',
settingWidth: '50%',
settingPluginData: '',
resultVisible: false,
resultTitle: '',
currentRowId: '',
rules: {
code: [
{ required: true, message: this.key('enter_process_unit_code'), trigger: 'blur' },
{ min: 1, max: 100, message: this.key('length_1_100'), trigger: 'blur' }
],
name: [
{ required: true, message: this.key('enter_process_unit_name'), trigger: 'blur' },
{ min: 1, max: 100, message: this.key('length_1_100'), trigger: 'blur' }
],
device_category_id: [
{ required: true, message: this.key('select_device_category'), trigger: 'change' }
]
},
columns: [],
toolbarButtons: [],
rowButtons: [],
formCols: [
[
{
type: 'input',
prop: 'code',
label: this.key('process_unit_code'),
placeholder: this.key('enter_process_unit_code'),
clearable: true,
disabled: false,
style: { width: '90%' }
}
],
[
{
type: 'input',
prop: 'name',
label: this.key('process_unit_name'),
placeholder: this.key('enter_process_unit_name'),
clearable: true,
style: { width: '90%' }
}
],
[
{
type: 'select',
prop: 'device_category_id',
label: this.key('device_category'),
placeholder: this.key('select_device_category'),
clearable: true,
filterable: true,
style: { width: '90%' },
options: []
}
],
[
{
type: 'input',
prop: 'remark',
inputType: 'textarea',
autosize: { minRows: 2, maxRows: 6 },
label: this.key('remark'),
placeholder: this.key('remark_required'),
clearable: true,
style: { width: '90%' }
}
]
]
}
},
created () {
this.columns = useTableColumns([
{ prop: 'sort', label: this.key('sort'), width: 80 },
{ prop: 'code', label: this.key('process_unit_code'), minWidth: 120 },
{ prop: 'name', label: this.key('process_unit_name'), minWidth: 120 },
{ prop: 'device_category_name', label: this.key('device_category'), minWidth: 120 },
{ prop: 'remark', label: this.key('remark') },
{ prop: '_actions', label: this.key('operation'), width: 160, fixed: 'right' }
])
const btns = useTableButtons({
toolbar: [
{
key: 'add',
label: this.key('add'),
icon: 'el-icon-plus',
type: 'primary',
auth: '/production_configuration/technology_model/technology_flow_workingsubclass/create',
onClick: this.openAdd
}
],
row: [
{
key: 'edit',
label: this.key('edit'),
icon: 'el-icon-edit',
auth: '/production_configuration/technology_model/technology_flow_workingsubclass/edit',
onClick: this.openEdit
},
{
key: 'setting',
label: this.key('preset_setting'),
icon: 'el-icon-setting',
color: 'warning',
auth: '/production_configuration/technology_model/technology_flow_workingsubclass/setting',
onClick: this.openSetting
},
{
key: 'result',
label: this.key('preset_result_param'),
icon: 'el-icon-document',
color: 'success',
auth: '/production_configuration/technology_model/technology_flow_workingsubclass/result',
onClick: this.openResult
},
{
key: 'delete',
label: this.key('delete'),
icon: 'el-icon-delete',
color: 'danger',
auth: '/production_configuration/technology_model/technology_flow_workingsubclass/delete',
onClick: this.handleDelete
}
]
}, this.$permission)
this.toolbarButtons = btns.toolbarButtons
this.rowButtons = btns.rowButtons
this.fetchData()
},
methods: {
async fetchData () {
this.loading = true
try {
const res = await getProcessStepList({
...this.search,
page_no: this.pagination.current,
page_size: this.pagination.size
})
const list = Array.isArray(res) ? res : (res.data || [])
const total = Array.isArray(res) ? res.length : (res.count || 0)
this.tableData = list
this.pagination.total = total
} finally {
this.loading = false
}
},
onSearch () {
this.pagination.current = 1
this.fetchData()
},
onReset () {
this.search = { code: '', name: '' }
this.pagination.current = 1
this.fetchData()
},
onPageChange (page) {
this.pagination.current = page.current
this.pagination.size = page.size
this.fetchData()
},
onSelect (rows) {
this.selectedRows = rows
},
resetForm () {
this.formData = { code: '', name: '', device_category_id: '', remark: '' }
this.editId = ''
this.$nextTick(() => {
this.formCols[0][0].disabled = false
})
},
openAdd () {
this.handleType = 'create'
this.dialogTitle = this.key('add_process_unit')
this.$nextTick(() => {
this.$refs.dialogForm && this.$refs.dialogForm.reset()
this.resetForm()
this.dialogVisible = true
})
},
openEdit (row) {
this.handleType = 'edit'
this.dialogTitle = this.key('edit_process_unit')
this.editId = row.id
this.formData = {
code: row.code,
name: row.name,
device_category_id: row.device_category_id || '',
remark: row.remark || ''
}
this.$nextTick(() => {
this.formCols[0][0].disabled = true
})
this.dialogVisible = true
},
async onDialogSubmit () {
this.submitting = true
try {
if (this.handleType === 'create') {
await createProcessStep(this.formData)
} else {
await editProcessStep({ ...this.formData, id: this.editId })
}
this.$message.success(this.$t(this.key('operation_success')))
this.dialogVisible = false
this.fetchData()
} finally {
this.submitting = false
}
},
onDialogClose () {
this.resetForm()
},
async handleDelete (row) {
const cancelled = await this.$confirmAction(
{
message: this.key('confirm_message'),
title: this.key('tips')
},
() => deleteProcessStep({ id: [row.id] })
)
if (cancelled) return
this.$message.success(this.$t(this.key('operation_success')))
this.pagination.current = Math.min(
this.pagination.current,
Math.ceil((this.pagination.total - 1) / this.pagination.size) || 1
)
this.fetchData()
},
openSetting (row) {
this.currentRowId = row.id
this.settingTitle = this.key('preset_setting')
this.settingType = row.device_category_id || ''
this.settingCode = row.code
this.settingWidth = '60%'
this.settingVisible = true
},
handleSettingSubmit (data) {
this.$message.success(this.$t(this.key('operation_success')))
this.settingVisible = false
},
openResult (row) {
this.currentRowId = row.id
this.resultTitle = this.key('preset_result_param')
this.resultVisible = true
}
}
}
</script>
<style scoped>
.search-bar {
padding: 10px 0;
}
/deep/ .el-form-item--mini.el-form-item {
margin-bottom: 4px;
}
</style>