|
@@ -10,6 +10,7 @@ import Cookies from 'js-cookie';
|
|
|
import { successMessage } from '/@/utils/message';
|
|
|
import { dictionary } from '/@/utils/dictionary';
|
|
|
import { APIResponseData } from '../columns/types';
|
|
|
+import { h } from 'vue';
|
|
|
|
|
|
export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
|
|
|
const pageRequest = async (query: UserPageQuery) => {
|
|
@@ -46,15 +47,10 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
|
width: 220,
|
|
|
view: {
|
|
|
show: true,
|
|
|
- click: ({ row }) => {
|
|
|
- window.dispatchEvent(new CustomEvent('workflow-view', { detail: row }));
|
|
|
- },
|
|
|
+
|
|
|
},
|
|
|
edit: {
|
|
|
show: true,
|
|
|
- click: ({ row }) => {
|
|
|
- window.dispatchEvent(new CustomEvent('workflow-edit', { detail: row }));
|
|
|
- },
|
|
|
},
|
|
|
remove: {
|
|
|
show: true,
|
|
@@ -223,13 +219,13 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
|
editForm:{show:false},
|
|
|
from:{
|
|
|
show:false,
|
|
|
- component: { placeholder: '请输入已借出' },
|
|
|
- rules: [{ required: true, message: '请输入已借出' }],
|
|
|
+ component: { placeholder: '请输入库存数量' },
|
|
|
+ rules: [{ required: false, message: '请输入库存数量' }],
|
|
|
|
|
|
}
|
|
|
},
|
|
|
warehouse:{
|
|
|
- title:'库存仓库',
|
|
|
+ title:'存放仓库',
|
|
|
type:"dict-select",
|
|
|
column: { minWidth: 150 },
|
|
|
dict: dict({
|
|
@@ -238,7 +234,8 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
|
label: 'name'
|
|
|
}),
|
|
|
form: {
|
|
|
- component: { placeholder: '请选择库存仓库' }
|
|
|
+ component: { placeholder: '请选择存放仓库' },
|
|
|
+ rules: [{ required: true, message: '请选择存放仓库' }],
|
|
|
}
|
|
|
},
|
|
|
status:{
|
|
@@ -263,6 +260,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
|
dict: dict({
|
|
|
data: dictionary('device_button_status_bool'),
|
|
|
}),
|
|
|
+ form: {
|
|
|
+ rules: [{ required: true, message: '请选择是否可见' }],
|
|
|
+ }
|
|
|
|
|
|
},
|
|
|
|
|
@@ -284,8 +284,8 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
|
formatter: ({ value }) => (value ? dayjs(value).format('YYYY-MM-DD') : ''),
|
|
|
},
|
|
|
form: {
|
|
|
- component: { placeholder: '请选择购买日期' },
|
|
|
- rules: [{ required: true, message: '请选择购买日期' }],
|
|
|
+ component: { placeholder: '请选择采购时间' },
|
|
|
+ rules: [{ required: false, message: '请选择采购时间' }],
|
|
|
},
|
|
|
valueResolve({ form, value }) {
|
|
|
form.purchase_date = value ? dayjs(value).format('YYYY-MM-DD') : null;
|
|
@@ -318,19 +318,42 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
|
column: { minWidth: 100 },
|
|
|
form: {
|
|
|
component: { placeholder: '请输入设备购入价格' },
|
|
|
- rules: [{ required: true, message: '请输入设备购入价格' }],
|
|
|
+ rules: [{ required: false, message: '请输入设备购入价格' }],
|
|
|
},
|
|
|
},
|
|
|
warranty_expiration: {
|
|
|
- title: '保质期',
|
|
|
+ title: '质保期',
|
|
|
type: 'date',
|
|
|
search: { show: false },
|
|
|
column: { minWidth: 120 ,
|
|
|
formatter: ({ value }) => (value ? dayjs(value).format('YYYY-MM-DD') : ''),
|
|
|
},
|
|
|
+ viewForm: {
|
|
|
+ title: '质保到期',
|
|
|
+ component: {
|
|
|
+ render({ value }) {
|
|
|
+ // eslint-disable-next-line no-console
|
|
|
+ console.log("valuevaluevalue:::",value);
|
|
|
+ if (!value) return '未设置';
|
|
|
+ const formatted = dayjs(value).format('YYYY-MM-DD');
|
|
|
+ const isExpired = dayjs(value).isBefore(dayjs(), 'day');
|
|
|
+ return h(
|
|
|
+ 'span',
|
|
|
+ {
|
|
|
+ style: {
|
|
|
+ color: isExpired ? 'red' : 'inherit',
|
|
|
+ fontWeight: isExpired ? 'bold' : 'normal'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ isExpired ? `${formatted}(已过期)` : formatted
|
|
|
+ );
|
|
|
+ },
|
|
|
+ showHtml: true,
|
|
|
+ }
|
|
|
+ },
|
|
|
form: {
|
|
|
- component: { placeholder: '请选择购买日期' },
|
|
|
- rules: [{ required: true, message: '请选择购买日期' }],
|
|
|
+ component: { placeholder: '请选择质保期' },
|
|
|
+ rules: [{ required: false, message: '请选择质保期' }],
|
|
|
},
|
|
|
valueResolve({ form, value }) {
|
|
|
form.warranty_expiration = value ? dayjs(value).format('YYYY-MM-DD') : null;
|
|
@@ -339,6 +362,88 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
|
form.warranty_expiration = value;
|
|
|
},
|
|
|
},
|
|
|
+ tenant_id:{
|
|
|
+ title: '租户id',
|
|
|
+ type: 'input',
|
|
|
+ value: 1,
|
|
|
+ column: {
|
|
|
+ show:false,
|
|
|
+ minWidth: 120,
|
|
|
+ },
|
|
|
+ // dict: dict({
|
|
|
+ // url: '/api/system/tenant/list/',
|
|
|
+ // value: 'id',
|
|
|
+ // label: 'name'
|
|
|
+ // }),
|
|
|
+ form: {
|
|
|
+ value:1,
|
|
|
+ show:false,
|
|
|
+ component: { placeholder: '请填租户id' },
|
|
|
+ rules: [{ required: false, message: '请填租户id' }],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ category:{
|
|
|
+ show: false,
|
|
|
+ title: '设备类别',
|
|
|
+ search: { show: false },
|
|
|
+ type: 'dict-select',
|
|
|
+ column: { show: false,minWidth: 120 },
|
|
|
+ dict: dict({
|
|
|
+ url: '/api/system/device/category/',
|
|
|
+ value: 'id',
|
|
|
+ label: 'name'
|
|
|
+ }),
|
|
|
+ form: {
|
|
|
+ component: { placeholder: '请输入设备类别' },
|
|
|
+ rules: [{ required: true, message: '请输入设备类别' }],
|
|
|
+ }
|
|
|
+ },
|
|
|
+ quantity:{
|
|
|
+ show: false,
|
|
|
+ title: '库存数量',
|
|
|
+ search: { show: false },
|
|
|
+ type: 'input',
|
|
|
+ column: { show: false,minWidth: 120 },
|
|
|
+ viewForm:{
|
|
|
+ component:{placeholder:""}
|
|
|
+ },
|
|
|
+ form: {
|
|
|
+ component: { placeholder: '请输入库存数量' },
|
|
|
+ rules: [{ required: true, message: '请输入库存数量' }],
|
|
|
+ valueBuilder({ form, value }) {
|
|
|
+ // form.tags =Array.from(String(value), Number);
|
|
|
+ form.quantity = form.total_quantity;
|
|
|
+
|
|
|
+ },
|
|
|
+ }
|
|
|
+ },
|
|
|
+ tags:{
|
|
|
+ show: false,
|
|
|
+ title: '设备标签',
|
|
|
+ search: { show: false },
|
|
|
+ type: 'dict-select',
|
|
|
+ column: { show: false,minWidth: 120 },
|
|
|
+ dict: dict({
|
|
|
+ url: '/api/system/device_tags/',
|
|
|
+ value: 'id',
|
|
|
+ label: 'name'
|
|
|
+ }),
|
|
|
+ viewForm:{
|
|
|
+ component:{placeholder:""}
|
|
|
+ },
|
|
|
+ form: {
|
|
|
+ component: { placeholder: '请选择设备标签' },
|
|
|
+ rules: [{ required: true, message: '请选择设备标签' }],
|
|
|
+ valueResolve({ form, value }) {
|
|
|
+ form.tags = Array.from(String(value), Number);
|
|
|
+ },
|
|
|
+ valueBuilder({ form, value }) {
|
|
|
+ // form.tags =Array.from(String(value), Number);
|
|
|
+ form.tags = Array.isArray(value)? value.length > 0 ? Number(value[0]) : '': Number(value);
|
|
|
+
|
|
|
+ },
|
|
|
+ }
|
|
|
+ },
|
|
|
image:{
|
|
|
title: '设备图片',
|
|
|
type: 'image-uploader',
|
|
@@ -356,8 +461,6 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
|
accept: ".jpg,.png",
|
|
|
uploadRequest: async ({ action, file, onProgress }) => {
|
|
|
const token = Cookies.get('token');
|
|
|
- // eslint-disable-next-line no-console
|
|
|
- console.log("token:::",token);
|
|
|
const data = new FormData();
|
|
|
data.append("image", file);
|
|
|
return await request({
|
|
@@ -376,7 +479,7 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
|
},
|
|
|
successHandle(ret) {
|
|
|
// eslint-disable-next-line no-console
|
|
|
- console.log("ret.data.image_url:::",ret.data.image_url);
|
|
|
+ // console.log("ret.data.image_url:::",ret.data.image_url);
|
|
|
|
|
|
return {
|
|
|
url: getBaseURL(ret.data.image_url),
|
|
@@ -416,72 +519,6 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
|
// },
|
|
|
|
|
|
|
|
|
- },
|
|
|
- tenant_id:{
|
|
|
- title: '租户id',
|
|
|
- type: 'input',
|
|
|
- value: 1,
|
|
|
- column: {
|
|
|
- show:false,
|
|
|
- minWidth: 120,
|
|
|
- },
|
|
|
- // dict: dict({
|
|
|
- // url: '/api/system/tenant/list/',
|
|
|
- // value: 'id',
|
|
|
- // label: 'name'
|
|
|
- // }),
|
|
|
- form: {
|
|
|
- value:1,
|
|
|
- show:false,
|
|
|
- component: { placeholder: '请填租户id' },
|
|
|
- rules: [{ required: false, message: '请填租户id' }],
|
|
|
- },
|
|
|
- },
|
|
|
- category:{
|
|
|
- show: false,
|
|
|
- title: '类别id',
|
|
|
- search: { show: false },
|
|
|
- type: 'dict-select',
|
|
|
- column: { show: false,minWidth: 120 },
|
|
|
- dict: dict({
|
|
|
- url: '/api/system/device/category/',
|
|
|
- value: 'id',
|
|
|
- label: 'name'
|
|
|
- }),
|
|
|
- form: {
|
|
|
- component: { placeholder: '请输入类别id' }
|
|
|
- }
|
|
|
- },
|
|
|
- quantity:{
|
|
|
- show: false,
|
|
|
- title: '库存数量',
|
|
|
- search: { show: false },
|
|
|
- type: 'input',
|
|
|
- column: { show: false,minWidth: 120 },
|
|
|
- form: {
|
|
|
- component: { placeholder: '请输入库存数量' }
|
|
|
- }
|
|
|
- },
|
|
|
- tags:{
|
|
|
- show: false,
|
|
|
- title: '设备标签',
|
|
|
- search: { show: false },
|
|
|
- type: 'dict-select',
|
|
|
- column: { show: false,minWidth: 120 },
|
|
|
- dict: dict({
|
|
|
- url: '/api/system/device_tags/',
|
|
|
- value: 'id',
|
|
|
- label: 'name'
|
|
|
- }),
|
|
|
- form: {
|
|
|
- component: { placeholder: '请选择设备标签' },
|
|
|
- valueResolve({ form, value }) {
|
|
|
- form.tags = Array.from(String(value), Number);
|
|
|
- },
|
|
|
- valueBuilder({ form, value }) {
|
|
|
- form.tags =Array.from(String(value), Number);
|
|
|
- },
|
|
|
- }
|
|
|
},
|
|
|
// maintenancename: {
|
|
|
// title: '维修名称',
|
|
@@ -516,7 +553,7 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
|
}
|
|
|
},
|
|
|
icon: "el-icon-goods",
|
|
|
- columns: ["code","category_name", "name", "status","borrowed_quantity","brand","specification","serial_number","warehouse","is_visible","department","purchase_date","supplier","price","warranty_expiration","image","tenant_id","category","quantity","tags"]
|
|
|
+ columns: ["code","category_name", "name", "status","borrowed_quantity","brand","specification","serial_number","warehouse","is_visible","department","purchase_date","supplier","price","warranty_expiration","tenant_id","category","quantity","tags","image"]
|
|
|
},
|
|
|
borrow: {
|
|
|
label: "借用记录",
|