182 lines
4.0 KiB
TypeScript
182 lines
4.0 KiB
TypeScript
import printerApi, { type editRequest } from "@/api/account/printer";
|
||
import { options } from './config'
|
||
|
||
import type { IModalConfig } from "@/components/CURD/types";
|
||
|
||
const modalConfig: IModalConfig<editRequest> = {
|
||
pageName: "sys:user",
|
||
dialog: {
|
||
title: "修改打印机",
|
||
width: 800,
|
||
draggable: true,
|
||
},
|
||
form: {
|
||
labelWidth: 100,
|
||
},
|
||
formAction: function (data) {
|
||
let obj = { ...data }
|
||
obj.printType = data.printType.join(',')
|
||
if (data.categoryIdsArr) {
|
||
obj.categoryIds = JSON.stringify(data.categoryIdsArr)
|
||
obj.categoryList = JSON.stringify(data.categoryIdsArr)
|
||
}
|
||
return printerApi.edit(obj);
|
||
},
|
||
beforeSubmit(data) {
|
||
console.log("提交之前处理", data);
|
||
},
|
||
formItems: [
|
||
{
|
||
label: "设备名称",
|
||
prop: "name",
|
||
rules: [{ required: true, message: "设备名称不能为空", trigger: "blur" }],
|
||
type: "input",
|
||
attrs: {
|
||
placeholder: "请输入设备名称",
|
||
},
|
||
col: {
|
||
xs: 24,
|
||
sm: 12,
|
||
},
|
||
},
|
||
{
|
||
type: "select",
|
||
label: "类型",
|
||
prop: "connectionType",
|
||
rules: [{ required: true, message: "请选择设备类型", trigger: "blur" }],
|
||
attrs: {
|
||
placeholder: "请选择设备类型",
|
||
clearable: true,
|
||
style: {
|
||
width: "200px",
|
||
},
|
||
},
|
||
options: options.connectionType,
|
||
col: {
|
||
xs: 24,
|
||
sm: 12,
|
||
},
|
||
},
|
||
{
|
||
label: "ip地址",
|
||
prop: "address",
|
||
rules: [{ required: true, message: "请输入ip地址", trigger: "blur" }],
|
||
type: "input",
|
||
attrs: {
|
||
placeholder: "请输入ip地址",
|
||
},
|
||
col: {
|
||
xs: 24,
|
||
sm: 12,
|
||
},
|
||
},
|
||
{
|
||
label: "端口",
|
||
prop: "port",
|
||
type: "input",
|
||
attrs: {
|
||
placeholder: "请输入端口",
|
||
},
|
||
col: {
|
||
xs: 24,
|
||
sm: 12,
|
||
},
|
||
},
|
||
{
|
||
type: "select",
|
||
label: "打印类型",
|
||
prop: "subType",
|
||
rules: [{ required: false, message: "请选择打印类型", trigger: "blur" }],
|
||
attrs: {
|
||
placeholder: "请选择打印类型",
|
||
clearable: true,
|
||
style: {
|
||
width: "200px",
|
||
},
|
||
},
|
||
options: options.subType,
|
||
col: {
|
||
xs: 24,
|
||
sm: 12,
|
||
},
|
||
},
|
||
{
|
||
type: "select",
|
||
label: "打印机品牌",
|
||
prop: "contentType",
|
||
rules: [{ required: true, message: "请选择打印机品牌", trigger: "blur" }],
|
||
attrs: {
|
||
placeholder: "请选择打印机品牌",
|
||
clearable: true,
|
||
style: {
|
||
width: "200px",
|
||
},
|
||
},
|
||
options: options.contentType,
|
||
col: {
|
||
xs: 24,
|
||
sm: 12,
|
||
},
|
||
},
|
||
{
|
||
type: "radio-button",
|
||
label: "小票尺寸",
|
||
prop: "receiptSize",
|
||
options: options.receiptSize,
|
||
initialValue: options.receiptSize[0].value
|
||
},
|
||
{
|
||
type: "radio-button",
|
||
label: "分类打印",
|
||
prop: "classifyPrint",
|
||
options: options.classifyPrint,
|
||
initialValue: options.classifyPrint[0].value
|
||
},
|
||
|
||
{
|
||
type: "custom",
|
||
slotName: 'classifyPrintData',
|
||
prop: "categoryIdsArr",
|
||
label: "",
|
||
},
|
||
|
||
|
||
|
||
{
|
||
type: "radio",
|
||
label: "打印数量",
|
||
prop: "printQty",
|
||
options: options.printQty,
|
||
initialValue: options.printQty[0].value
|
||
},
|
||
{
|
||
type: "radio",
|
||
label: "打印方式",
|
||
prop: "printMethod",
|
||
options: options.printMethod,
|
||
initialValue: options.printMethod[0].value
|
||
},
|
||
{
|
||
type: "checkbox",
|
||
label: "打印类型",
|
||
prop: "printType",
|
||
options: options.printType,
|
||
initialValue: options.printType.map(v => v.value)
|
||
},
|
||
|
||
{
|
||
label: "打印机状态",
|
||
prop: "status",
|
||
type: "switch",
|
||
initialValue: 1,
|
||
attrs: {
|
||
activeValue: 1,
|
||
inactiveValue: 0,
|
||
}
|
||
},
|
||
],
|
||
};
|
||
|
||
// 如果有异步数据会修改配置的,推荐用reactive包裹,而纯静态配置的可以直接导出
|
||
export default reactive(modalConfig);
|