Commit 902a7bcb502f19e041e8a4274507332f00e2db29

Authored by xp.Huang
2 parents 04568e8f 95ca839d

Merge branch 'feat/category' into 'main_dev'

feat: 产品添加产品品类相关

See merge request yunteng/thingskit-front!995
  1 +import { defHttp } from '/@/utils/http/axios';
  2 +// import { PaginationResult } from '/#/axios';
  3 +
  4 +enum Api {
  5 + DEVICE_PROFILE_CATEGORY = '/device_profile/category',
  6 +}
  7 +
  8 +/**
  9 + * 新增产品分类
  10 + */
  11 +export const deviceProfileCategory = (params) => {
  12 + return defHttp.post<any>({
  13 + url: `${Api.DEVICE_PROFILE_CATEGORY}`,
  14 + params,
  15 + });
  16 +};
  17 +
  18 +/**
  19 + * 获取列表
  20 + */
  21 +export const getDeviceClassList = (params) => {
  22 + return defHttp.get<any>({
  23 + url: Api.DEVICE_PROFILE_CATEGORY,
  24 + params,
  25 + });
  26 +};
  27 +
  28 +/**
  29 + * 删除产品分类
  30 + */
  31 +export const deleteDeviceClass = (params) => {
  32 + return defHttp.delete<any>({
  33 + url: Api.DEVICE_PROFILE_CATEGORY,
  34 + params,
  35 + });
  36 +};
... ...
... ... @@ -194,6 +194,7 @@ export interface DeviceRecord {
194 194 customerAdditionalInfo?: {
195 195 isPublic?: boolean;
196 196 };
  197 + ifShowClass?: Boolean;
197 198 }
198 199
199 200 export interface DeviceModelOfMatterAttrs {
... ...
... ... @@ -41,13 +41,14 @@ export interface FunctionJson {
41 41 }
42 42
43 43 export interface ModelOfMatterParams {
44   - deviceProfileId: string;
  44 + deviceProfileId?: string;
45 45 functionJson: FunctionJson;
46 46 functionName: string;
47 47 functionType: FunctionType;
48 48 identifier: string;
49 49 remark: string;
50 50 id?: string;
  51 + categoryId?: string;
51 52 callType?: string;
52 53 eventType?: string;
53 54 accessMode?: string;
... ... @@ -57,10 +58,12 @@ export interface ModelOfMatterParams {
57 58 export interface GetModelTslParams {
58 59 functionType: FunctionType;
59 60 deviceProfileId: string;
  61 + ifShowClass?: string | Boolean;
60 62 }
61 63
62 64 export interface ImportModelOfMatterType {
63 65 data: Recordable;
64 66 functionType: string;
65   - tkDeviceProfileId: string;
  67 + tkDeviceProfileId?: string;
  68 + categoryId?: string;
66 69 }
... ...
... ... @@ -18,13 +18,21 @@ enum ModelOfMatter {
18 18 IMPORT = '/things_model/import',
19 19
20 20 GET_MODEL_SERVICE = '/things_model/get_services',
  21 + CATEGORY = '/things_model/category',
  22 + CATEGORY_IMPORT = '/things_model/categoryImport',
  23 +
  24 + CATEGORY_EXPORT = '/things_model/categoryGetExport',
  25 +
  26 + IMPORT_CSV = '/things_model/csvImport',
21 27 }
22 28
23 29 export const getModelList = (
24 30 params: BasicPageParams & {
25   - deviceProfileId: string;
  31 + deviceProfileId?: string;
26 32 functionTyp?: FunctionType;
27 33 nameOrIdentifier?: string;
  34 + selectType?: string | undefined;
  35 + id?: string;
28 36 }
29 37 ) => {
30 38 return defHttp.get({
... ... @@ -82,3 +90,82 @@ export const importModelOfMatter = (data: ImportModelOfMatterType) => {
82 90 data,
83 91 });
84 92 };
  93 +
  94 +// 产品品类接口
  95 +
  96 +// 新增
  97 +export const createModelCategory = (params: Partial<ModelOfMatterParams>) => {
  98 + return defHttp.post({
  99 + url: ModelOfMatter.CATEGORY,
  100 + params,
  101 + });
  102 +};
  103 +
  104 +// 修改
  105 +export const updateModelCategory = (params: Partial<ModelOfMatterParams>) => {
  106 + return defHttp.put({
  107 + url: ModelOfMatter.CATEGORY,
  108 + params,
  109 + });
  110 +};
  111 +
  112 +// 删除
  113 +export const deleteModelCategory = (params: string[]) => {
  114 + return defHttp.delete({
  115 + url: ModelOfMatter.CATEGORY,
  116 + params: {
  117 + ids: params,
  118 + },
  119 + });
  120 +};
  121 +
  122 +// 导入
  123 +export const importModelCategory = (data: ImportModelOfMatterType) => {
  124 + return defHttp.post({
  125 + url: ModelOfMatter.CATEGORY_IMPORT,
  126 + data,
  127 + });
  128 +};
  129 +
  130 +// 导出
  131 +export const ExportModelCategory = (params: any) => {
  132 + const { functionType, deviceProfileId } = params;
  133 + return defHttp.get({
  134 + url: `${ModelOfMatter.CATEGORY_EXPORT}/${functionType}/${deviceProfileId}`,
  135 + params,
  136 + });
  137 +};
  138 +
  139 +/**
  140 + * 物模型产品品类界面excel导入
  141 + */
  142 +
  143 +export const importCsvCategory = (params: {
  144 + categoryId?: string;
  145 + deviceProfileId?: string;
  146 + file: FormData;
  147 +}) => {
  148 + const { categoryId } = params || {};
  149 +
  150 + return defHttp.post<any>({
  151 + url: `${ModelOfMatter.IMPORT_CSV}?categoryId=${categoryId}`,
  152 + params: params.file,
  153 + });
  154 +};
  155 +
  156 +/**
  157 + * 物模型产品物模型界面excel导入
  158 + */
  159 +
  160 +export const importCsvDeviceProfileId = (params: {
  161 + categoryId?: string;
  162 + deviceProfileId?: string;
  163 + file: FormData;
  164 +}) => {
  165 + const { deviceProfileId } = params || {};
  166 +
  167 + return defHttp.post<any>({
  168 + url: `${ModelOfMatter.IMPORT_CSV}?deviceProfileId=${deviceProfileId}`,
  169 + params: params.file,
  170 + });
  171 +};
... ...
  1 +<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1699588251601" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1411" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M145.621959 0c-44.79888 0-79.998 36.81188-79.998 81.61076v860.77848c0 44.79888 35.19912 81.61076 79.998 81.61076h732.781681a81.969151 81.969151 0 0 0 81.61076-81.61076V324.80468L657.60916 0h-511.987201z" fill="#F17F53" p-id="1412"></path><path d="M657.60916 0v233.59416c0 25.59936 17.61236 92.79768 97.61036 92.79768h204.79488L657.60916 0z" fill="#FFFFFF" p-id="1413"></path><path d="M109.117272 659.874703c1.61276 0 2.867128 0.614385 3.814305 1.868753s1.663958 2.764731 2.175945 4.582286 0.81918 3.737507 0.972776 5.862253 0.230394 4.044699 0.230394 5.862254v5.708657c2.099148 3.302317 4.78708 6.886228 8.0126 10.726132s6.963026 7.449414 11.18692 10.80293 8.78058 6.143846 13.721257 8.39659 10.214145 3.379116 15.820405 3.379115c5.99025 0 11.622109-1.407965 16.869978-4.198295s10.137347-6.527837 14.617235-11.18692 8.652584-9.98375 12.441288-15.974001 7.21902-12.236494 10.265344-18.661933 5.759856-12.876478 8.089398-19.276318 4.377491-12.287693 6.067048-17.689158 3.046324-10.086148 4.044699-14.028449 1.689558-6.681433 2.099147-8.166196c2.611135-10.598135 4.81268-20.761081 6.681433-30.437639s2.764731-19.250719 2.764731-28.645684c0-2.303942-0.691183-3.60951-2.099147-3.891103l-37.19587 10.495738a19.916302 19.916302 0 0 1-5.094273 0.895978c-3.788705 0-6.963026-1.20317-9.522962-3.60951s-3.814305-5.862253-3.814305-10.342142 0.435189-8.114997 1.279968-10.879728 2.201545-4.81268 4.044699-6.220644 4.275093-2.329542 7.270218-2.764731 6.655834-0.665583 10.956527-0.665583h2.099147c2.40634-0.511987 5.478263-1.20317 9.21577-2.099148s7.935802-1.919952 12.518087-3.071923l14.694032-3.737507 15.743607-4.044699c5.299068-1.356766 10.572536-2.662333 15.820404-3.9679a1637.283868 1637.283868 0 0 1 23.474613-5.63186l5.990251-1.279968a22.01545 22.01545 0 0 1 3.737506-0.588785c1.20317 0 2.303942 0.358391 3.302318 1.049574s1.817555 1.58716 2.483138 2.636734a14.514837 14.514837 0 0 1 2.175945 7.423814c0 2.995125-1.151971 5.60626-3.455913 7.807805s-5.19667 4.121497-8.703783 5.785456-7.321417 3.097523-11.468513 4.351891l-11.62211 3.532711c-3.60951 1.100772-6.681433 2.175946-9.215769 3.22552s-3.967901 2.227144-4.275093 3.532711c-0.511987 4.40309-0.998375 9.292568-1.510363 14.694033s-1.049574 10.546936-1.638359 15.462014c-0.204795 1.20317-0.614385 4.095898-1.279968 8.703782s-1.561561 10.188545-2.687932 16.79318-2.559936 13.823654-4.198295 21.682658-3.532712 15.564411-5.63186 23.167421c-2.303942 8.294193-5.324667 17.151571-9.062173 26.546536s-8.191795 18.559536-13.337267 27.442514-10.982125 17.228369-17.484363 24.984976-13.542061 14.130847-21.145071 19.122721a58.929727 58.929727 0 0 1-23.19302 8.089398 61.336067 61.336067 0 0 1-9.369366 0.742382c-5.19667 0-10.828529-0.691183-16.869978-2.099148s-12.134097-3.404715-18.226744-5.99025-11.9805-5.734257-17.61236-9.369366-10.674933-7.705407-15.078023-12.159696-7.910202-9.21577-10.495738-14.335641-3.891103-10.444539-3.891102-16.050799c0-4.300692 0.435189-8.0126 1.279968-11.110122s2.227144-5.60626 4.121496-7.500613 4.428689-3.302317 7.577411-4.198295 7.014225-1.484763 11.519712-1.484763zM305.61796 693.333067c3.404715 1.20317 6.886228 2.611135 10.418939 4.198295s7.21902 3.123122 11.033324 4.582285 7.782205 2.662333 11.929302 3.686308 8.575786 1.510362 13.286068 1.510362c5.503862 0 11.058924-0.639984 16.639584-1.945551s11.084523-3.225519 16.434789-5.785455 10.470138-5.657459 15.385215-9.292568 9.394965-7.884603 13.490863-12.671683c4.505487-5.094273 8.242994-9.727757 11.238119-13.874854s5.427064-7.859004 7.270218-11.110122 3.174321-6.041449 3.967901-8.39659 1.20317-4.377491 1.20317-6.067048c0-2.508737-0.844779-4.684683-2.559936-6.527837s-3.967901-3.379116-6.835029-4.582285-6.067048-2.073548-9.676558-2.636734-7.347016-0.81918-11.238119-0.81918c-2.303942 0-4.991875 0.076798-8.089398 0.230394l-9.446164 0.460789-9.292567 0.38399a150.39624 150.39624 0 0 1-7.807805 0.153596c-3.302317 0-6.732632-0.38399-10.265344-1.126372s-7.014225-1.971151-10.418939-3.686307-6.553436-3.9935-9.446164-6.911828a35.403915 35.403915 0 0 1-8.831779-15.743606 24.626584 24.626584 0 0 1-0.742382-6.143846c0-2.40634 0.179196-4.684683 0.537587-6.83503s0.767981-4.223894 1.279968-6.220644c1.407965-4.991875 3.737507-10.086148 6.963026-15.231619s7.142221-10.162946 11.698907-15.078023 9.497363-9.650959 14.847629-14.258844 10.854129-8.934177 16.511587-12.978875 11.21252-7.705407 16.639584-10.956526 10.521337-6.01585 15.23162-8.319792c6.604635-3.19992 13.337267-5.529462 20.172295-6.963026s13.61886-2.175946 20.325892-2.175946c3.9935 0 7.807805 0.537587 11.391715 1.58716s6.78383 2.585535 9.522962 4.582286 4.915077 4.479888 6.527837 7.423814 2.40634 6.323042 2.40634 10.137347c0 2.201545-0.255994 4.044699-0.742381 5.555061s-1.151971 2.713532-1.945552 3.686308-1.663958 1.61276-2.636734 2.022349-1.919952 0.588785-2.918327 0.588785c-2.687933 0-5.171071-0.307192-7.423814-0.895977s-4.428689-1.279968-6.527837-2.02235-4.198295-1.459164-6.297443-2.099147-4.40309-0.972776-6.911827-0.972776c-7.398215 0-14.924427 1.484763-22.578635 4.428689s-15.103622 6.707032-22.348242 11.23812-14.105247 9.625359-20.556286 15.231619-12.236494 11.058924-17.330767 16.357991c-2.687933 2.79033-4.684683 5.60626-5.913452 8.39659s-1.868753 5.452664-1.868753 7.961401c0 3.711907 1.61276 6.604635 4.81268 8.703782s7.091023 3.148721 11.698907 3.148722c2.687933 0 5.759856-0.051199 9.138972-0.153597a796.140096 796.140096 0 0 0 20.761081-0.844779c3.353516-0.153596 6.323042-0.230394 8.934176-0.230394 6.195045 0 12.159696 0.870378 17.842754 2.636734s10.751731 4.326292 15.154821 7.731007 7.935802 7.628609 10.572536 12.671683 3.967901 10.828529 3.967901 17.330767c0 3.9935-0.588785 8.038199-1.791955 12.159696s-2.841529 8.217395-4.940677 12.364491-4.505487 8.242994-7.19342 12.287693-5.555061 8.0126-8.550186 11.929301c-5.401465 6.988625-11.417315 13.59326-18.073148 19.788306s-13.721257 11.59651-21.22187 16.204395-15.436414 8.242994-23.781805 10.956526-16.921177 4.044699-25.727357 4.044699a74.724532 74.724532 0 0 1-23.551411-4.121497c-3.891103-1.356766-7.577411-3.046324-11.033325-5.094273s-6.476638-4.377491-9.062173-6.963026-4.684683-5.478263-6.220644-8.626984-2.329542-6.579036-2.329542-10.265344c0-1.791955 0.281593-3.532712 0.819179-5.17107s1.868753-2.559936 4.070299-2.559936zM497.152371 651.631709c1.791955-7.500612 4.40309-15.18042 7.807805-23.013824s7.398215-15.718007 12.0061-23.62821 9.727757-15.666808 15.385215-23.321017a316.868878 316.868878 0 0 1 57.982551-59.928102c3.19992-2.201545 6.143846-3.660708 8.857378-4.351891s5.555061-1.049574 8.550186-1.049573c3.19992 0 6.041449 0.486388 8.550187 1.433564s4.991875 2.662333 7.500612 5.17107c0.79358 0.895978 1.638359 1.689558 2.559936 2.40634s1.740756 1.049574 2.559936 1.049574c0.204795 0 0.460788-0.230394 0.742382-0.665583l0.972775-1.587161c0.358391-0.614385 0.767981-1.228769 1.279968-1.868753s1.100772-1.126372 1.791956-1.433564c1.689558-0.79358 3.737507-1.331167 6.067048-1.58716s4.735882-0.38399 7.116622-0.383991c4.505487 0 8.857379 0.81918 13.055674 2.483138s7.910202 3.967901 11.110122 6.963026c7.60301 7.091023 13.362866 15.59001 17.330767 25.496963s5.913452 20.556286 5.913452 31.948001c0 10.188545-1.510362 21.19627-4.505488 32.997575-2.611135 10.39334-6.323042 20.505087-11.18692 30.309642s-10.546936 18.994725-17.100373 27.59611-13.849254 16.460388-21.887452 23.551412-16.613985 13.20927-25.727357 18.303542-18.610735 9.062173-28.492088 11.929302-19.941901 4.275093-30.156046 4.275093c-9.497363 0-18.021949-1.459164-25.573761-4.351891s-13.951651-6.988625-19.19952-12.287693-9.241369-11.59651-12.006099-18.892328-4.121497-15.410815-4.121497-24.293793c0-3.788705 0.230394-7.628609 0.665583-11.468513s1.151971-7.807805 2.150346-11.801305z m25.343367 10.060549a63.230419 63.230419 0 0 0-1.638359 13.490862c0 5.60626 0.972776 10.521337 2.918327 14.770831s4.710282 7.807805 8.242994 10.649334 7.807805 4.991875 12.748481 6.451039 10.367741 2.175946 16.281193 2.175945c6.988625 0 14.130847-1.100772 21.375465-3.302317s14.335642-5.401465 21.22187-9.59976 13.542061-9.241369 19.941901-15.154821 12.313292-12.594885 17.765956-20.095498 10.290943-15.641209 14.540437-24.447389 7.679808-18.149946 10.265343-28.056898c0.998375-3.60951 1.715157-7.347016 2.175946-11.238119s0.665583-7.654209 0.665583-11.238119c0-5.811055-0.639984-11.340516-1.945551-16.639584s-3.455914-10.00935-6.451039-14.105248-6.937427-7.372616-11.852504-9.830154-10.905327-3.686308-17.99635-3.686308c-0.998375 0-1.766356 0.435189-2.329542 1.279968s-1.126372 1.919952-1.715157 3.225519c-0.511987 1.100772-1.075173 2.252744-1.715157 3.455914a11.878103 11.878103 0 0 1-6.451039 5.555061 15.794805 15.794805 0 0 1-5.785455 0.895978c-1.689558 0-3.19992-0.38399-4.505487-1.126372s-2.611135-1.766356-3.891103-3.071923l-1.510362-1.433564a1.971151 1.971151 0 0 0-1.356766-0.537587c-0.895978 0-2.073548 0.40959-3.532712 1.20317s-2.943926 1.740756-4.505487 2.841529-3.046324 2.252744-4.505488 3.455914-2.585535 2.252744-3.379115 3.148721c-6.80943 6.988625-13.567661 14.617235-20.325892 22.885828s-12.978876 16.767581-18.661934 25.57376-10.674933 17.663558-14.924427 26.623335-7.270218 17.561161-9.16457 25.880953zM760.083398 546.495138c0.588785-2.611135 1.356766-5.375866 2.252744-8.319792s2.099148-5.657459 3.609509-8.089398 3.455914-4.505487 5.862254-6.143847 5.452664-2.483138 9.138971-2.483137c3.507112 0 6.630234 0.972776 9.369366 2.918327s5.222269 3.916702 7.423814 5.913452c2.611135 1.689558 5.094273 5.145471 7.500613 10.342141s4.863878 11.59651 7.423814 19.19952 5.299068 16.204395 8.242994 25.804155 6.195045 19.660308 9.753356 30.156046 7.526212 21.221869 11.929302 32.178396 9.394965 21.631459 15.001225 32.024799l3.148721 5.631859a95.076023 95.076023 0 0 0 7.142222 10.879728c1.049574 1.305567 1.817555 1.945551 2.329542 1.945552 0.307192 0 0.639984-0.742381 1.049573-2.252744s0.844779-3.302317 1.356767-5.401465l1.58716-6.451039a59.902502 59.902502 0 0 1 1.58716-5.401465 476.736882 476.736882 0 0 0 13.721257-37.426264c2.739132-8.447789 5.785455-18.482738 9.062174-30.079248a1560.127397 1560.127397 0 0 0 14.182045-54.526637c1.151971-4.966276 2.252744-10.00935 3.302317-15.154821s1.971151-10.162946 2.764731-15.078023 1.356766-9.138972 1.638359-12.748481a77.540461 77.540461 0 0 1 0.691183-8.242994c0.255994-1.894353 0.563186-3.865503 0.972776-5.913452s0.921577-3.916702 1.58716-5.63186 1.484763-3.097523 2.483138-4.198295 2.201545-1.638359 3.60951-1.638359 3.123122 0.204795 5.171071 0.588786 3.916702 0.998375 5.631859 1.791955c1.894353 2.611135 3.635109 5.734257 5.17107 9.369366s2.329542 8.575786 2.329542 14.77083c0 3.891103-0.40959 8.575786-1.20317 14.02845s-1.817555 11.289318-3.071923 17.561161a634.864128 634.864128 0 0 1-8.934177 38.245443c-1.61276 6.041449-3.123122 11.59651-4.582285 16.639584s-2.662333 9.21577-3.686308 12.518087c-1.791955 5.811055-3.686308 11.775706-5.631859 17.919552s-4.095898 12.594885-6.451039 19.353117-4.889478 13.900452-7.654208 21.452263-5.836654 15.61561-9.21577 24.216995c-1.510362 3.891103-3.225519 7.807805-5.171071 11.698907s-4.172696 7.423814-6.681433 10.572536-5.324667 5.708657-8.473388 7.654209-6.681433 2.918327-10.572536 2.918327c-2.303942 0-4.684683-0.332792-7.116622-0.972776s-4.531087-1.971151-6.220644-3.967901c-8.191795-9.497363-15.487613-20.274693-21.887453-32.331991s-12.134097-24.652184-17.17717-37.810255-9.522962-26.444139-13.414065-39.909402-7.449414-26.316142-10.649334-38.629435l-0.895978-3.455913c-0.40959-1.407965-0.767981-2.81593-1.126371-4.275093s-0.691183-2.764731-1.049574-3.967901-0.742381-2.175946-1.20317-2.918327-0.972776-1.126372-1.58716-1.126372-1.356766 1.100772-2.252744 3.302317-1.791955 4.684683-2.687933 7.423815-1.715157 5.427064-2.483138 8.012599l-1.433564 4.940677c-0.691183 2.611135-1.740756 6.323042-3.148721 11.18692l-4.735882 16.434789c-1.766356 6.118247-3.660708 12.543686-5.708657 19.353117l-5.913452 19.737106a1165.026874 1165.026874 0 0 1-12.902078 40.728582l-3.891102 12.364491c-1.279968 4.147096-2.508737 7.935802-3.60951 11.314917s-1.791955 5.657459-2.099148 6.758231c-1.20317 3.788705-2.969526 6.681433-5.324667 8.626984s-4.735882 2.918327-7.116622 2.918327c-1.510362 0-2.995125-0.537587-4.505487-1.58716s-2.81593-2.329542-3.967901-3.814305-2.099148-3.123122-2.841529-4.863878-1.126372-3.327917-1.126372-4.735882c0-0.79358 0.255994-2.073548 0.742382-3.814304s1.305567-4.735882 2.40634-8.934177l3.891102-15.462013 44.338092-143.638009z" fill="#FFFFFF" p-id="1414"></path></svg>
\ No newline at end of file
... ...
  1 +<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1699933658783" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1443" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M145.621959 0c-44.79888 0-79.998 36.81188-79.998 81.61076v860.77848c0 44.79888 35.19912 81.61076 79.998 81.61076h732.781681a81.969151 81.969151 0 0 0 81.61076-81.61076V324.80468L657.60916 0h-511.987201z" fill="#25B39E" p-id="1444"></path><path d="M657.60916 0v233.59416c0 25.59936 17.61236 92.79768 97.61036 92.79768h204.79488L657.60916 0z" fill="#FFFFFF" p-id="1445"></path><path d="M158.498438 694.485038c0-3.507112 0.511987-7.19342 1.510362-11.110122 3.404715-13.59326 7.372616-26.930527 11.929302-39.986201s8.678183-26.034549 12.36449-38.936626 6.78383-23.781805 9.21577-32.613585 4.633484-16.460388 6.527837-22.80903 3.660708-11.826904 5.247869-16.434789 3.353516-9.138972 5.247868-13.644459c1.20317-2.687933 2.534337-5.503862 3.967901-8.39659s3.020724-5.58066 4.735882-8.0126 3.481513-4.454289 5.324667-5.99025 3.763106-2.329542 5.785455-2.329542c4.095898 0 7.21902 0.665583 9.369366 2.02235s3.481513 2.585535 3.9935 3.686308l1.356766 6.143846c1.510362-0.102397 3.455914-0.38399 5.862254-0.819179s4.81268-0.921577 7.270218-1.433565 4.735882-0.998375 6.835029-1.510362 3.711907-0.947176 4.81268-1.356766c6.604635-1.791955 12.697283-3.353516 18.303542-4.659083s10.930927-2.38074 15.974001-3.22552 9.881353-1.484763 14.463638-1.868753 9.241369-0.588785 13.951651-0.588785c4.607885 0 8.345391 0.255994 11.238119 0.742381s5.19667 1.177571 6.911828 2.02235 2.867128 1.843154 3.532711 2.995125 0.972776 2.38074 0.972776 3.686308c0 1.20317-0.332792 2.483138-0.972776 3.814304s-1.715157 2.636734-3.225519 3.814305-3.455914 2.252744-5.862254 3.148721-5.401465 1.510362-9.010974 1.791955c-0.895978 0.204795-2.969526 0.563186-6.220645 1.126372l-10.572535 1.791955-10.80293 1.868754a129.60956 129.60956 0 0 0-7.039824 1.356766h0.153596c-0.588785 0.102397-2.022349 0.486388-4.275093 1.126372s-4.966276 1.407965-8.166196 2.252743-6.681433 1.817555-10.41894 2.918327l-11.110122 3.22552a687.163621 687.163621 0 0 0-17.637959 5.324667c-6.092648 2.40634-10.879728 5.58066-14.335642 9.522961s-6.169446 8.370991-8.166195 13.286068c-0.40959 0.895978-0.998375 2.431939-1.791956 4.582286l-2.636734 7.347016-3.071923 8.780581-3.148721 8.857378c-0.998375 2.81593-1.868753 5.350266-2.636734 7.654209s-1.279968 3.9935-1.587161 5.094272c-0.307192 0.998375-0.511987 1.894353-0.588785 2.687933s-0.153596 1.407965-0.153596 1.791955c0 0.588785 0.153596 0.895978 0.460788 0.895978 1.510362 0 4.633484-0.665583 9.369366-2.022349s10.290943-3.020724 16.639584-5.017475l20.40269-6.451039c7.244619-2.303942 14.207645-4.454289 20.837879-6.451038s12.569286-3.686308 17.765956-5.017475 8.959776-2.022349 11.238119-2.022349c3.507112 0 5.862253 0.563186 7.039824 1.715157s1.791955 2.431939 1.791955 3.814304c0 3.60951-1.279968 6.758231-3.814304 9.446164s-5.734257 5.043074-9.522962 7.039824c-1.20317 0.588785-3.430314 1.484763-6.681433 2.636734s-6.758231 2.329542-10.495738 3.532712l-10.726132 3.455914-7.347016 2.406339c-9.804555 3.788705-17.765956 6.937427-23.935402 9.369366s-11.135722 4.454289-14.924427 5.99025l-8.78058 3.532712c-2.047949 0.81918-3.942301 1.484763-5.708657 2.02235s-3.686308 1.075173-5.785456 1.58716-4.940676 1.254369-8.652583 2.150346c-0.895978 2.099148-1.945551 5.273468-3.148722 9.522962s-2.355141 8.652584-3.455913 13.20927-2.022349 8.78058-2.764731 12.671683-1.126372 6.604635-1.126372 8.089398c0 1.791955 0.255994 3.123122 0.742381 3.967901s1.100772 1.433564 1.791956 1.715157 1.407965 0.460788 2.099147 0.460788h1.638359c4.81268 0 10.572536-0.691183 17.330767-2.099147s13.414065-3.251119 20.018699-5.555061c6.297443-2.201545 11.801305-4.607885 16.511588-7.193421s9.113372-5.017475 13.286068-7.270218 8.191795-4.147096 12.159696-5.708657 8.268593-2.38074 12.978875-2.483138c0.998375 0 2.175946 0.102397 3.532712 0.307192s2.636734 0.563186 3.814304 1.126372 2.175946 1.279968 2.918327 2.175946 1.023974 2.047949 0.81918 3.455913c-0.40959 2.892728-1.843154 5.759856-4.351891 8.550186s-5.657459 5.503862-9.446164 8.089398-8.038199 5.094273-12.748481 7.500613-9.497363 4.684683-14.41244 6.835029-9.702157 4.095898-14.41244 5.862253-8.908577 3.276718-12.594885 4.582286c-9.19017 3.19992-18.149946 5.555061-26.853729 7.039824s-16.460388 2.252744-23.372215 2.252743c-7.60301 0-13.414065-1.433564-17.484363-4.275093s-6.067048-7.577411-6.067048-14.182045zM336.541986 699.579311a14.489238 14.489238 0 0 1-13.721257 1.638359c-1.356766-0.691183-2.508737-1.61276-3.455913-2.764731a12.902077 12.902077 0 0 1-2.918327-8.319792c0-2.099148 0.435189-3.865503 1.279968-5.324667s1.894353-2.687933 3.148721-3.737507 2.611135-1.919952 4.044699-2.636734 2.764731-1.305567 3.967901-1.791955c3.9935-2.611135 8.498988-5.811055 13.490863-9.59976s10.137347-7.884603 15.462013-12.236494 10.572536-8.78058 15.820404-13.286068l14.924427-12.902077 6.758231-5.990251a121.59696 121.59696 0 0 0-13.59326-31.128821l-5.017474-8.166196-3.686308-5.990251a7.782205 7.782205 0 0 1-1.279968-4.198295 14.258844 14.258844 0 0 1 7.116622-11.340516 11.417315 11.417315 0 0 1 5.785455-1.433564c3.19992 0 6.01585 0.665583 8.473388 2.022349s4.633484 3.071923 6.527837 5.171071 3.558311 4.377491 4.940677 6.835029 2.662333 4.78708 3.737506 6.963026c0.588785 1.20317 1.254369 2.79033 1.945552 4.81268s1.382365 4.121497 2.022349 6.37424l1.868753 6.604635 1.510363 5.631859c4.40309-4.198295 8.678183-8.601385 12.825279-13.209269a587.556511 587.556511 0 0 0 18.892328-22.194646c1.740756-2.201545 3.58391-4.223894 5.478263-6.067048s3.839904-3.379116 5.862253-4.582285 4.147096-1.791955 6.451039-1.791955c3.891103 0 6.681433 0.998375 8.319792 2.995125s2.483138 4.607885 2.483138 7.807804c0 3.404715-0.614385 6.527837-1.868753 9.369366s-2.867128 5.068673-4.863879 6.681433c-2.892728 2.303942-6.067048 5.068673-9.522962 8.319792s-6.937427 6.681433-10.495737 10.265344l-10.572536 10.649333c-3.507112 3.507112-6.707032 6.655834-9.59976 9.446164-1.20317 1.100772-2.227144 2.201545-3.071923 3.302318s-1.279968 2.508737-1.279968 4.198295c0 0.998375 0.281593 2.252744 0.819179 3.737506s1.254369 3.097523 2.099148 4.81268l2.559936 5.171071c0.870378 1.740756 1.58716 3.327917 2.175945 4.735881 1.20317 2.687933 2.867128 5.887853 5.017475 9.59976s4.300692 7.577411 6.451039 11.62211 4.0191 8.166196 5.631859 12.364491 2.40634 8.191795 2.40634 12.006099a20.761081 20.761081 0 0 1-3.737507 12.082898c-1.075173 1.561561-2.329542 2.764731-3.686308 3.686308s-2.636734 1.356766-3.814304 1.356766c-2.611135 0-4.684683-0.307192-6.220645-0.895977s-2.867128-1.510362-3.967901-2.687933-2.022349-2.662333-2.764731-4.428689-1.58716-3.763106-2.483137-6.067049c-1.305567-3.711907-2.995125-7.961401-5.094273-12.748481s-4.275093-9.548561-6.527837-14.258844-4.377491-9.062173-6.374241-13.132471-3.558311-7.116622-4.659083-9.21577l-8.626984 6.835029-11.468514 9.062174-17.919552 14.105247c-7.244619 5.708657-16.588385 12.953276-28.0057 21.861854zM490.752531 646.921427a158.588035 158.588035 0 0 1 22.041049-48.510787c5.299068-7.833404 11.314917-15.103622 18.073148-21.759456s14.130847-12.082898 22.117847-16.281193c2.611135-1.407965 5.452664-2.457539 8.550187-3.148722s6.246244-1.049574 9.446163-1.049573c3.302317 0 6.374241 0.307192 9.21577 0.895977s5.299068 1.61276 7.347016 2.995125 3.686308 3.19992 4.863879 5.401465 1.791955 4.889478 1.791955 8.089398c0 2.40634-0.358391 4.81268-1.049574 7.270218s-1.740756 4.659084-3.148721 6.604635-3.148721 3.532712-5.247869 4.735882-4.556686 1.791955-7.347016 1.791955c-2.201545 0-4.223894-0.40959-6.067048-1.20317a47.102822 47.102822 0 0 1-7.884603-4.275093 19.916302 19.916302 0 0 0-2.841529-1.279968c-3.9935 1.791955-7.782205 4.172696-11.314917 7.116622s-6.860628 6.220644-9.906953 9.830154-5.862253 7.449414-8.39659 11.545312-4.838279 8.191795-6.911827 12.287693-3.788705 8.114997-5.247869 12.082897-2.636734 7.577411-3.532712 10.879728c-0.691183 2.40634-1.331167 5.119872-1.868753 8.166196s-0.81918 6.01585-0.819179 8.934177c0 1.99675 0.179196 3.891103 0.537586 5.708657s0.972776 3.404715 1.868753 4.81268 2.099148 2.508737 3.60951 3.302317 3.353516 1.20317 5.555061 1.20317c3.507112 0 6.963026-0.460788 10.41894-1.356766s6.835029-2.047949 10.137346-3.455913 6.527837-3.020724 9.676559-4.863879a314.129747 314.129747 0 0 0 14.924426-9.369366c1.919952-1.279968 3.711907-2.457539 5.401465-3.455913s3.276718-1.817555 4.735882-2.483138 2.713532-0.972776 3.814305-0.972776c1.510362 0 2.892728 0.38399 4.198295 1.126372s1.945551 2.022349 1.945551 3.814305a12.79968 12.79968 0 0 1-0.895978 4.351891c-1.407965 3.891103-3.302317 7.398215-5.708657 10.495738s-5.068673 5.862253-8.0126 8.319792-6.092648 4.633484-9.446163 6.527836-6.681433 3.660708-9.983751 5.247869c-6.195045 3.302317-12.466888 5.785455-18.815529 7.423815s-11.673308 2.483138-15.974001 2.483137c-1.407965 0-3.046324-0.153596-4.940677-0.460788s-3.558311-0.742381-4.940676-1.356766c-8.089398-3.507112-14.00285-8.191795-17.689158-14.105247s-5.555061-12.902077-5.555061-20.991476c0-3.507112 0.281593-7.167821 0.81918-11.033324s1.356766-7.807805 2.457538-12.031699zM618.698133 647.689408c0-4.300692 1.151971-7.961401 3.455913-10.956526s5.350266-4.991875 9.138972-5.990251a138.287743 138.287743 0 0 1 13.644459-21.17067c3.404715-4.40309 7.270218-8.831779 11.622109-13.286068s9.138972-8.498988 14.41244-12.159696 10.905327-6.630234 16.946776-8.934177 12.466888-3.455914 19.276318-3.455913c5.811055 0 10.854129 0.691183 15.154821 2.099147s7.859004 3.353516 10.649334 5.862254 4.889478 5.478263 6.297443 8.934176 2.099148 7.167821 2.099147 11.186921c0 3.404715-0.460788 6.655834-1.356766 9.753356-1.407965 5.60626-3.9935 10.495738-7.807805 14.694032s-8.268593 7.884603-13.414064 11.033325-10.751731 5.785455-16.793181 7.884602-12.108497 3.839904-18.149946 5.247869-11.878103 2.483138-17.484363 3.22552-10.444539 1.331167-14.540436 1.715157c-0.895978 1.791955-1.663958 4.070298-2.329542 6.835029s-0.972776 5.427064-0.972776 8.012599c0 5.811055 2.303942 10.290943 6.911828 13.490863s10.956526 4.81268 19.045923 4.81268c4.710282 0 9.19017-0.537587 13.490863-1.58716s8.370991-2.40634 12.236494-4.044699 7.475013-3.455914 10.879728-5.401465 6.502237-3.865503 9.292568-5.785456c3.60951-2.40634 7.014225-4.428689 10.265343-6.067048s6.118247-2.483138 8.626985-2.483138 4.095898 0.614385 4.812679 1.868753 1.049574 2.585535 1.049574 3.967901a34.251944 34.251944 0 0 1-0.307192 4.198295 25.804155 25.804155 0 0 1-8.703783 14.566036c-10.39334 8.191795-21.068273 14.054049-32.024799 17.561161s-22.629834 5.247869-35.019925 5.247869c-2.40634 0-5.222269-0.153596-8.473388-0.460789s-6.630234-0.895978-10.137346-1.791955-6.937427-2.201545-10.342142-3.891103a31.538412 31.538412 0 0 1-15.513212-17.100372 40.037399 40.037399 0 0 1-2.483138-14.847629c0-4.710282 0.639984-9.958151 1.945552-15.743606-1.305567-0.204795-2.534337-0.870378-3.686308-2.02235s-1.715157-2.81593-1.715157-5.017474z m93.898452-41.547762c0.204795-0.511987 0.307192-0.947176 0.307192-1.356766v-1.356766c0-2.687933-0.998375-4.735882-2.995125-6.067048s-4.40309-2.022349-7.19342-2.022349c-4.40309 0-8.729382 1.151971-12.978875 3.455913s-8.242994 5.171071-12.0061 8.626984-7.065423 7.142221-9.983751 11.110123-5.145471 7.526212-6.758231 10.726132c7.19342-0.588785 13.798055-1.58716 19.788306-2.918327s11.21252-3.046324 15.666808-5.094273 8.038199-4.351891 10.80293-6.911827 4.556686-5.299068 5.350266-8.191796zM818.347541 499.929902c0.511987-3.9935 1.305567-7.705407 2.40634-11.110122s2.585535-6.220644 4.428689-8.473389 4.223894-3.379116 7.116623-3.379115c1.61276 0 3.379116 0.307192 5.324666 0.895977s3.788705 1.433564 5.555062 2.483138 3.225519 2.329542 4.428689 3.814305 1.791955 3.148721 1.791955 4.940676c0 0.79358-0.153596 1.715157-0.460788 2.764731s-0.537587 2.073548-0.742382 3.071924l-37.503062 150.293842c-1.510362 5.99025-2.739132 11.724507-3.737507 17.177171s-1.740756 9.932552-2.252744 13.414064v3.60951c0 2.995125-0.204795 6.271843-0.588785 9.830154s-1.151971 6.860628-2.252744 9.906953-2.636734 5.60626-4.582285 7.654208-4.479888 3.071923-7.577411 3.071924c-2.687933 0-5.043074-0.563186-7.039824-1.715158s-3.660708-2.636734-4.940676-4.428689-2.252744-3.737507-2.841529-5.785455-0.895978-3.967901-0.895978-5.785456c0-1.61276 0.153596-3.58391 0.460789-5.913452s0.665583-4.81268 1.126372-7.347016 0.921577-5.094273 1.433564-7.654209 0.998375-4.78708 1.510362-6.681433l38.706232-153.59616a193.275168 193.275168 0 0 1 1.126372-11.058923z" fill="#FFFFFF" p-id="1446"></path></svg>
\ No newline at end of file
... ...
... ... @@ -23,4 +23,7 @@ export enum DictEnum {
23 23 MESSAGE_TYPES_FILTER = 'message_types_filter',
24 24 // 实体类型 规则节点 Filter originator types switch
25 25 ORIGINATOR_TYPES = 'originator_types',
  26 +
  27 + // 产品品类领域
  28 + CATEGORY_FIELD = 'category_field',
26 29 }
... ...
  1 +<script setup lang="ts">
  2 + import { computed, unref } from 'vue';
  3 + import { ref } from 'vue';
  4 + import { BasicModal, useModalInner } from '/@/components/Modal';
  5 + import { schemas } from '../index';
  6 + import { useForm, BasicForm } from '/@/components/Form';
  7 +
  8 + import { deviceProfileCategory } from '/@/api/device/classModal';
  9 +
  10 + const emit = defineEmits(['handleReload', 'register']);
  11 +
  12 + const isUpdate = ref<Boolean>(false);
  13 + const getTitle = computed(() => (!unref(isUpdate) ? '新增分类' : '编辑分类'));
  14 +
  15 + const [registerForm, { getFieldsValue, setFieldsValue, validate }] = useForm({
  16 + labelWidth: 140,
  17 + schemas,
  18 + actionColOptions: {
  19 + span: 14,
  20 + },
  21 + showActionButtonGroup: false,
  22 + });
  23 + const recordInfo = ref<any>({});
  24 +
  25 + const [register, { closeModal, setModalProps }] = useModalInner(async (data) => {
  26 + console.log(123131, data);
  27 + setModalProps({ confirmLoading: false, loading: true });
  28 + isUpdate.value = data?.isUpdate;
  29 + recordInfo.value = data?.record;
  30 + if (data?.record) {
  31 + setFieldsValue(data?.record);
  32 + }
  33 + setModalProps({ loading: false });
  34 + });
  35 +
  36 + const handleCancel = () => {
  37 + closeModal();
  38 + };
  39 +
  40 + const handleOk = async () => {
  41 + await validate();
  42 + let values = getFieldsValue();
  43 + if (unref(isUpdate)) {
  44 + values = { ...values, id: unref(recordInfo).id };
  45 + }
  46 + console.log(unref(isUpdate), values, 'values');
  47 + await deviceProfileCategory(values);
  48 + emit('handleReload');
  49 + handleCancel();
  50 + };
  51 +</script>
  52 +
  53 +<template>
  54 + <div>
  55 + <BasicModal
  56 + v-bind="$attrs"
  57 + width="30rem"
  58 + :title="getTitle"
  59 + @register="register"
  60 + @cancel="handleCancel"
  61 + @ok="handleOk"
  62 + destroyOnClose
  63 + >
  64 + <div>
  65 + <BasicForm @register="registerForm" />
  66 + </div>
  67 + </BasicModal>
  68 + </div>
  69 +</template>
... ...
  1 +import classModal from './classModal.vue';
  2 +import physicalModel from './physicalModel.vue';
  3 +
  4 +export { classModal, physicalModel };
... ...
  1 +<script setup lang="ts">
  2 + import { ref } from 'vue';
  3 + import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
  4 + import PhysicalModelManagementStep from '/@/views/device/profiles/step/PhysicalModelManagementStep.vue';
  5 +
  6 + defineEmits(['register']);
  7 + const record = ref<any>({});
  8 + const [register, {}] = useDrawerInner(async (data: { record: any }) => {
  9 + record.value = { ...data.record, ifShowClass: true };
  10 + });
  11 +</script>
  12 +<template>
  13 + <BasicDrawer v-bind="$attrs" title="物模型" @register="register" width="60%" destroy-on-close>
  14 + <PhysicalModelManagementStep :record="record" />
  15 + </BasicDrawer>
  16 +</template>
... ...
  1 +import { BasicColumn, FormSchema } from '/@/components/Table';
  2 +import { findDictItemByCode } from '/@/api/system/dict';
  3 +
  4 +import { DictEnum } from '/@/enums/dictEnum';
  5 +
  6 +export const columns: BasicColumn[] = [
  7 + {
  8 + title: '领域',
  9 + dataIndex: 'dictItemName',
  10 + },
  11 + {
  12 + title: '名称',
  13 + dataIndex: 'name',
  14 + },
  15 + {
  16 + title: '状态',
  17 + dataIndex: 'status',
  18 + slots: { customRender: 'status' },
  19 + },
  20 +];
  21 +
  22 +export const searchFormSchema: FormSchema[] = [
  23 + {
  24 + field: 'name',
  25 + label: '名称',
  26 + component: 'Input',
  27 + colProps: { span: 6 },
  28 + componentProps: {
  29 + maxLength: 255,
  30 + placeholder: '请输入分类名称',
  31 + },
  32 + },
  33 + {
  34 + field: 'status',
  35 + label: '状态',
  36 + component: 'Select',
  37 + colProps: { span: 6 },
  38 + componentProps: {
  39 + options: [
  40 + { label: '启用', value: '1' },
  41 + { label: '禁用', value: '0' },
  42 + ],
  43 + placeholder: '请选择分类状态',
  44 + },
  45 + },
  46 + {
  47 + field: 'dictItemId',
  48 + label: '领域',
  49 + component: 'ApiSelect',
  50 + colProps: { span: 6 },
  51 + componentProps() {
  52 + return {
  53 + api: findDictItemByCode,
  54 + params: {
  55 + dictCode: DictEnum.CATEGORY_FIELD,
  56 + },
  57 + labelField: 'itemText',
  58 + valueField: 'itemValue',
  59 + placeholder: '请选择领域',
  60 + getPopupContainer: () => document.body,
  61 + };
  62 + },
  63 + },
  64 +];
  65 +
  66 +export const schemas: FormSchema[] = [
  67 + {
  68 + field: 'name',
  69 + label: '品类名称',
  70 + component: 'Input',
  71 + colProps: { span: 21 },
  72 + required: true,
  73 + },
  74 + {
  75 + field: 'dictItemId',
  76 + label: '领域',
  77 + component: 'ApiSelect',
  78 + colProps: { span: 21 },
  79 + required: true,
  80 + componentProps({ formActionType }) {
  81 + return {
  82 + api: findDictItemByCode,
  83 + params: {
  84 + dictCode: DictEnum.CATEGORY_FIELD,
  85 + },
  86 + onChange(value, options) {
  87 + formActionType.setFieldsValue({ dictItemName: value ? options.label : '' });
  88 + },
  89 + labelField: 'itemText',
  90 + valueField: 'itemValue',
  91 + placeholder: '请选择领域',
  92 + getPopupContainer: () => document.body,
  93 + };
  94 + },
  95 + },
  96 + {
  97 + field: 'dictItemName',
  98 + label: '领域名称',
  99 + ifShow: false,
  100 + component: 'Input',
  101 + },
  102 + {
  103 + field: 'status',
  104 + label: '状态',
  105 + component: 'RadioButtonGroup',
  106 + defaultValue: 1,
  107 + componentProps: {
  108 + options: [
  109 + { label: '启用', value: 1 },
  110 + { label: '禁用', value: 0 },
  111 + ],
  112 + },
  113 + },
  114 +];
... ...
  1 +<script setup lang="ts">
  2 + import { ref } from 'vue';
  3 + import { columns, searchFormSchema } from '.';
  4 + import { BasicTable, useTable, TableAction } from '/@/components/Table';
  5 + import { Button, Popconfirm, Switch } from 'ant-design-vue';
  6 + import { useBatchOperation } from '/@/utils/useBatchOperation';
  7 + import { useMessage } from '/@/hooks/web/useMessage';
  8 + import { Authority } from '/@/components/Authority';
  9 + import { useModal } from '/@/components/Modal';
  10 + import { classModal, physicalModel } from './components/index';
  11 + import { useDrawer } from '/@/components/Drawer';
  12 + import { USER_INFO_KEY } from '/@/enums/cacheEnum';
  13 + import { getAuthCache } from '/@/utils/auth';
  14 + import { authBtn } from '/@/enums/roleEnum';
  15 + import {
  16 + getDeviceClassList,
  17 + deleteDeviceClass,
  18 + deviceProfileCategory,
  19 + } from '/@/api/device/classModal';
  20 + const [
  21 + registerTable,
  22 + { reload, setLoading, getSelectRowKeys, setSelectedRowKeys, getRowSelection },
  23 + ] = useTable({
  24 + title: '产品分类列表',
  25 + api: getDeviceClassList,
  26 + columns,
  27 + formConfig: {
  28 + labelWidth: 100,
  29 + schemas: searchFormSchema,
  30 + },
  31 + immediate: true,
  32 + useSearchForm: true,
  33 + showTableSetting: true,
  34 + bordered: true,
  35 + showIndexColumn: false,
  36 + clickToRowSelect: false,
  37 + rowKey: 'id',
  38 + // searchInfo: searchInfo,
  39 + actionColumn: {
  40 + width: 200,
  41 + title: '操作',
  42 + slots: { customRender: 'action' },
  43 + fixed: 'right',
  44 + },
  45 + rowSelection: {
  46 + type: 'checkbox',
  47 + getCheckboxProps: (record: any) => {
  48 + return { disabled: !!record.customerId };
  49 + },
  50 + },
  51 + });
  52 +
  53 + const [registerModal, { openModal }] = useModal();
  54 + const [registerDetailDrawer, { openDrawer }] = useDrawer();
  55 +
  56 + const { createMessage } = useMessage();
  57 + const { isExistOption } = useBatchOperation(getRowSelection, setSelectedRowKeys);
  58 +
  59 + const switchLoading = ref<boolean>(false);
  60 +
  61 + const userInfo: any = getAuthCache(USER_INFO_KEY);
  62 + const role: string = userInfo.roles[0];
  63 +
  64 + const handleReload = () => {
  65 + setSelectedRowKeys([]);
  66 + reload();
  67 + };
  68 +
  69 + // 新增
  70 + const handleCreate = () => {
  71 + openModal(true, {
  72 + isUpdate: false,
  73 + });
  74 + };
  75 +
  76 + // 编辑
  77 + const handleEdit = (record?: any) => {
  78 + openModal(true, {
  79 + isUpdate: true,
  80 + record,
  81 + });
  82 + };
  83 +
  84 + // 详情
  85 + const handleDetail = (record?: any) => {
  86 + openDrawer(true, { record });
  87 + };
  88 +
  89 + // 状态->编辑
  90 + const handleSwitch = async (e: any, record: any) => {
  91 + switchLoading.value = true;
  92 + console.log(e, record);
  93 + await deviceProfileCategory({ ...record, status: e });
  94 + switchLoading.value = false;
  95 + createMessage.success('操作成功');
  96 + reload();
  97 + };
  98 +
  99 + // 删除
  100 + const handleDelete = async (record?: any) => {
  101 + let ids: string[] = [];
  102 + if (record) {
  103 + ids = [record.id];
  104 + } else {
  105 + ids = getSelectRowKeys();
  106 + }
  107 + try {
  108 + setLoading(true);
  109 + await deleteDeviceClass({ ids });
  110 + createMessage.success('删除成功');
  111 + handleReload();
  112 + } catch (error) {
  113 + throw error;
  114 + } finally {
  115 + setLoading(false);
  116 + }
  117 + };
  118 +</script>
  119 +<template>
  120 + <div>
  121 + <BasicTable style="flex: auto" @register="registerTable">
  122 + <template #toolbar>
  123 + <Authority value="api:yt:product:category:post">
  124 + <Button type="primary" @click="handleCreate"> 新增分类 </Button>
  125 + </Authority>
  126 + <Authority value="api:yt:product:category:delete">
  127 + <Popconfirm
  128 + title="您确定要批量删除数据"
  129 + ok-text="确定"
  130 + cancel-text="取消"
  131 + @confirm="handleDelete()"
  132 + >
  133 + <a-button color="error" :disabled="!isExistOption"> 批量删除 </a-button>
  134 + </Popconfirm>
  135 + </Authority>
  136 + </template>
  137 + <template #status="{ record }">
  138 + <Switch
  139 + @click="(e) => handleSwitch(e, record)"
  140 + :loading="switchLoading"
  141 + v-model:checked="record.status"
  142 + checked-children="启用"
  143 + un-checked-children="禁用"
  144 + :checkedValue="1"
  145 + :unCheckedValue="0"
  146 + />
  147 + </template>
  148 + <template #action="{ record }">
  149 + <TableAction
  150 + :actions="[
  151 + {
  152 + label: '详情',
  153 + icon: 'ant-design:eye-outlined',
  154 + auth: 'api:yt:product:category:get',
  155 + onClick: handleDetail.bind(null, record),
  156 + },
  157 + {
  158 + label: '编辑',
  159 + auth: 'api:yt:product:category:update',
  160 + icon: 'clarity:note-edit-line',
  161 + ifShow: authBtn(role),
  162 + onClick: handleEdit.bind(null, record),
  163 + },
  164 + {
  165 + label: '删除',
  166 + auth: 'api:yt:product:category:delete',
  167 + icon: 'ant-design:delete-outlined',
  168 + ifShow: authBtn(role) && !record.status,
  169 + popConfirm: {
  170 + title: '是否确认删除',
  171 + confirm: handleDelete.bind(null, record),
  172 + },
  173 + },
  174 + ]"
  175 + />
  176 + </template>
  177 + </BasicTable>
  178 + <classModal @register="registerModal" @handleReload="handleReload" />
  179 + <physicalModel @register="registerDetailDrawer" />
  180 + </div>
  181 +</template>
... ...
... ... @@ -157,7 +157,6 @@
157 157 };
158 158 const deviceTypeStr = ref('');
159 159 const handleGetDeviceType = async (e) => {
160   - console.log(e);
161 160 deviceTypeStr.value = e;
162 161 await nextTick();
163 162 TransConStRef.value?.updateDisabled(e);
... ...
  1 +<script lang="ts" setup>
  2 + import { columns, searchFormSchema } from './config';
  3 + import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
  4 + import { BasicTable } from '/@/components/Table';
  5 + import { useTable } from '/@/components/Table';
  6 + import { Button } from 'ant-design-vue';
  7 + import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
  8 + import { getDeviceClassList } from '/@/api/device/classModal';
  9 + import { ref } from 'vue';
  10 + const emits = defineEmits([
  11 + 'handleOpenListDrawer',
  12 + 'handleSelectCategory',
  13 + 'handleClose',
  14 + 'register',
  15 + ]);
  16 +
  17 + const categoryId = ref<string | undefined | null>();
  18 + const [registerDrawer] = useDrawerInner((data) => {
  19 + categoryId.value = data.categoryId || {};
  20 + });
  21 + const [registerTable] = useTable({
  22 + title: '',
  23 + api: getDeviceClassList,
  24 + columns,
  25 + formConfig: {
  26 + schemas: searchFormSchema,
  27 + },
  28 + useSearchForm: true,
  29 + showTableSetting: false,
  30 + bordered: true,
  31 + showIndexColumn: false,
  32 + clickToRowSelect: false,
  33 + rowKey: 'id',
  34 + actionColumn: {
  35 + width: 100,
  36 + title: '操作',
  37 + slots: { customRender: 'action' },
  38 + fixed: 'right',
  39 + },
  40 + });
  41 +
  42 + const closeDrawer = () => {
  43 + emits('handleClose');
  44 + };
  45 +
  46 + const handleChecked = (item?: any) => {
  47 + emits('handleSelectCategory', item);
  48 + };
  49 +
  50 + const handleOpenListDrawer = (record?: any) => {
  51 + emits('handleOpenListDrawer', record);
  52 + };
  53 +</script>
  54 +
  55 +<template>
  56 + <BasicDrawer
  57 + :zIndex="1100"
  58 + v-bind="$attrs"
  59 + @register="registerDrawer"
  60 + :showFooter="true"
  61 + destroyOnClose
  62 + @close="closeDrawer"
  63 + title="选择品类"
  64 + width="32%"
  65 + >
  66 + <BasicTable @register="registerTable">
  67 + <template #name="{ record }">
  68 + <span>{{ record.name }}</span>
  69 + <ExclamationCircleOutlined @click.stop="handleOpenListDrawer(record)" class="ml-1" />
  70 + </template>
  71 + <template #action="{ record }">
  72 + <Button type="link" :disabled="categoryId === record.id" @click="handleChecked(record)"
  73 + >选择</Button
  74 + >
  75 + </template>
  76 + </BasicTable>
  77 + </BasicDrawer>
  78 +</template>
... ...
  1 +<script lang="ts" setup>
  2 + import { columnsDrawer } from './config';
  3 + import { unref, ref, watch, nextTick } from 'vue';
  4 + import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
  5 + import { BasicTable } from '/@/components/Table';
  6 + import { useTable } from '/@/components/Table';
  7 + import { Button } from 'ant-design-vue';
  8 + import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
  9 + import { getModelList } from '/@/api/device/modelOfMatter';
  10 +
  11 + defineEmits(['register']);
  12 +
  13 + const props = defineProps<{ cateforyListInfo: any }>();
  14 +
  15 + const recordInfo = ref<any>({});
  16 + const secondVisible = ref<Boolean>(false);
  17 +
  18 + watch(
  19 + () => props.cateforyListInfo,
  20 + async () => {
  21 + recordInfo.value = props.cateforyListInfo.record || {};
  22 + secondVisible.value = props.cateforyListInfo.isRight || false;
  23 + await nextTick();
  24 + reload();
  25 + }
  26 + );
  27 + const [registerListDrawer, { closeDrawer }] = useDrawerInner();
  28 + const [registerTable, { reload }] = useTable({
  29 + title: '',
  30 + api: async (params: Record<'page' | 'pageSize', number>) => {
  31 + return await getModelList({
  32 + ...params,
  33 + id: unref(recordInfo).id,
  34 + selectType: 'category',
  35 + });
  36 + },
  37 + columns: columnsDrawer,
  38 + useSearchForm: false,
  39 + showTableSetting: false,
  40 + bordered: true,
  41 + showIndexColumn: false,
  42 + clickToRowSelect: false,
  43 + rowKey: 'id',
  44 + });
  45 +
  46 + const handleClose = () => {
  47 + closeDrawer();
  48 + };
  49 +</script>
  50 +
  51 +<template>
  52 + <BasicDrawer
  53 + :zIndex="1100"
  54 + @register="registerListDrawer"
  55 + wrap-class-name="secondDrawer"
  56 + :wrap-style="{
  57 + right: secondVisible ? '32%' : 0,
  58 + transition: 'none',
  59 + }"
  60 + v-bind="$attrs"
  61 + :showFooter="true"
  62 + destroyOnClose
  63 + @close="handleClose"
  64 + title="物模型"
  65 + width="40%"
  66 + >
  67 + <BasicTable @register="registerTable">
  68 + <template #name="{ record }">
  69 + <span>{{ record.name }}</span>
  70 + <ExclamationCircleOutlined class="ml-1" />
  71 + </template>
  72 + </BasicTable>
  73 + <template #footer>
  74 + <Button @click="handleClose">取消</Button>
  75 + </template>
  76 + </BasicDrawer>
  77 +</template>
... ...
  1 +<template>
  2 + <BasicModal
  3 + title="导入物模型"
  4 + :maskClosable="false"
  5 + destroyOnClose
  6 + v-bind="$attrs"
  7 + width="25rem"
  8 + @register="register"
  9 + @cancel="handleCancel"
  10 + :showOkBtn="false"
  11 + >
  12 + <div class="w-full h-full" ref="loadingRef">
  13 + <!-- <div class="flex justify-end">
  14 + <Button @click="handleTemplateDownload" type="link">EXCEL模板下载</Button>
  15 + </div> -->
  16 + <div class="flex justify-evenly items-center h-50 !w-full">
  17 + <Upload
  18 + accept=".json,"
  19 + :show-upload-list="false"
  20 + :customRequest="handleImportModel"
  21 + class="flex justify-center items-center"
  22 + >
  23 + <div class="flex flex-col justify-center items-center">
  24 + <img :src="JSONImage" alt="avatar" class="w-20 h-20" />
  25 + <!-- <Button type="primary" :loading="importLoading" class="mt-2"> JSON导入 </Button> -->
  26 + </div>
  27 + </Upload>
  28 + <Upload
  29 + accept=".csv,.xls,.xlsx"
  30 + :show-upload-list="false"
  31 + :customRequest="handleCSVImport"
  32 + class="flex justify-center items-center"
  33 + >
  34 + <div class="flex flex-col justify-center items-center">
  35 + <img :src="CSVImage" alt="avatar" class="w-20 h-20" />
  36 + <!-- <Button type="primary" class="mt-2">CSV导入</Button> -->
  37 + </div>
  38 + </Upload>
  39 + </div>
  40 + </div>
  41 + </BasicModal>
  42 +</template>
  43 +<script lang="ts" setup>
  44 + import { ref, unref } from 'vue';
  45 + import { Upload } from 'ant-design-vue';
  46 + import { BasicModal, useModalInner } from '/@/components/Modal';
  47 + import { DeviceRecord } from '/@/api/device/model/deviceModel';
  48 + import { useMessage } from '/@/hooks/web/useMessage';
  49 + import { isObject, isString } from '/@/utils/is';
  50 + import {
  51 + importCsvCategory,
  52 + importModelCategory,
  53 + importModelOfMatter,
  54 + importCsvDeviceProfileId,
  55 + } from '/@/api/device/modelOfMatter';
  56 + // import XLSX, { CellObject } from 'xlsx';
  57 + import { useLoading } from '/@/components/Loading';
  58 +
  59 + const emits = defineEmits(['register', 'handleImportCSV', 'handleReload']);
  60 +
  61 + defineProps<{
  62 + record: DeviceRecord;
  63 + }>();
  64 +
  65 + const { createMessage } = useMessage();
  66 + const loadingRef = ref();
  67 + const [openLoading, closeLoading] = useLoading({
  68 + target: loadingRef,
  69 + props: {
  70 + tip: '加载中',
  71 + absolute: true,
  72 + },
  73 + });
  74 +
  75 + const JSONImage = ref<string>(new URL('/src/assets/svg/JSON.svg', import.meta.url).href);
  76 + const CSVImage = ref<string>(new URL('/src/assets/svg/excel.svg', import.meta.url).href);
  77 +
  78 + const isEmptyObject = (value: any) => isObject(value) && !Object.keys(value).length;
  79 +
  80 + const ImportInfo = ref<{ id?: string; isCateGory?: string | Boolean }>({});
  81 +
  82 + const [register, { closeModal }] = useModalInner(async (data) => {
  83 + ImportInfo.value = data;
  84 + });
  85 + // 导入loading
  86 + const importLoading = ref(false);
  87 +
  88 + const paseJSON = (string: string) => {
  89 + let data = null;
  90 + let flag = false;
  91 + try {
  92 + if (!isString(string)) return { flag: false, data };
  93 + data = JSON.parse(string);
  94 + flag = true;
  95 + if (!isObject(data)) flag = false;
  96 + } catch (error) {}
  97 + return { flag, data };
  98 + };
  99 +
  100 + // JSON导入
  101 + const handleImportModel = async (data: { file: File }) => {
  102 + const fileReader = new FileReader();
  103 + const { isCateGory, id } = unref(ImportInfo);
  104 +
  105 + fileReader.onload = async () => {
  106 + const { flag, data } = paseJSON(fileReader.result as string);
  107 + if (!flag) {
  108 + createMessage.warning('JSON解析失败,请导入正确的JSON');
  109 + return;
  110 + }
  111 + openLoading();
  112 + try {
  113 + importLoading.value = true;
  114 +
  115 + Object.keys(data || {}).forEach((key) => {
  116 + const value = (data || {})[key];
  117 + if (value && isEmptyObject(value)) {
  118 + (data || {})[key] = [];
  119 + }
  120 + });
  121 +
  122 + const result = isCateGory
  123 + ? await importModelCategory({
  124 + categoryId: id,
  125 + data: data!,
  126 + functionType: 'all',
  127 + })
  128 + : await importModelOfMatter({
  129 + tkDeviceProfileId: id,
  130 + data: data!,
  131 + functionType: 'all',
  132 + });
  133 +
  134 + result
  135 + ? createMessage.success('导入成功~')
  136 + : createMessage.error('JSON解析失败,请导入正确的JSON');
  137 +
  138 + result && emits('handleReload');
  139 + } catch (error) {
  140 + throw error;
  141 + } finally {
  142 + importLoading.value = false;
  143 + closeLoading();
  144 + closeModal();
  145 + }
  146 + };
  147 +
  148 + fileReader.readAsText(data.file, 'utf-8');
  149 + };
  150 +
  151 + // CSV导入
  152 + const handleCSVImport = async ({ file }) => {
  153 + const { isCateGory, id } = unref(ImportInfo);
  154 +
  155 + try {
  156 + openLoading();
  157 + const formData = new FormData();
  158 + formData.set('file', file);
  159 + const flag = isCateGory
  160 + ? await importCsvCategory({ categoryId: id, deviceProfileId: undefined, file: formData })
  161 + : await importCsvDeviceProfileId({
  162 + categoryId: undefined,
  163 + deviceProfileId: id,
  164 + file: formData,
  165 + });
  166 + flag && createMessage.info(flag?.message);
  167 + } catch (msg) {
  168 + console.log(msg, 'msg');
  169 + } finally {
  170 + closeLoading();
  171 + closeModal();
  172 + emits('handleReload');
  173 + }
  174 + };
  175 +
  176 + // const downloadFile = (data: string, fileName: string, type: string, ext: string) => {
  177 + // const blob = new Blob([data], { type: type });
  178 + // const objectURL = URL.createObjectURL(blob);
  179 + // const element = document.createElement('a');
  180 + // element.href = objectURL;
  181 + // element.download = `${fileName}.${ext}`;
  182 + // element.style.display = 'none';
  183 + // document.body.appendChild(element);
  184 + // element.click();
  185 + // element.remove();
  186 + // URL.revokeObjectURL(objectURL);
  187 + // };
  188 +
  189 + // 模板下载
  190 + // const handleTemplateDownload = () => {
  191 +
  192 + // };
  193 +
  194 + const handleCancel = () => {
  195 + closeModal();
  196 + };
  197 +</script>
  198 +
  199 +<style lang="less" scope></style>
... ...
  1 +import { BasicColumn, FormSchema } from '/@/components/Table';
  2 +import { findDictItemByCode } from '/@/api/system/dict';
  3 +import { h, unref } from 'vue';
  4 +import { Tooltip } from 'ant-design-vue';
  5 +
  6 +import { FunctionType } from '/@/views/device/profiles/step/cpns/physical/cpns/config';
  7 +import { useMessage } from '/@/hooks/web/useMessage';
  8 +import { useClipboard } from '@vueuse/core';
  9 +import { DictEnum } from '/@/enums/dictEnum';
  10 +
  11 +// import {
  12 +// EventType,
  13 +// EventTypeColor,
  14 +// EventTypeName,
  15 +// } from '/@/views/device/list/cpns/tabs/EventManage/config';
  16 +
  17 +export const columns: BasicColumn[] = [
  18 + {
  19 + title: '品类名称',
  20 + dataIndex: 'name',
  21 + slots: { customRender: 'name' },
  22 + },
  23 + {
  24 + title: '领域',
  25 + dataIndex: 'dictItemName',
  26 + },
  27 +];
  28 +
  29 +export const formatFunctionType: Record<FunctionType, string> = {
  30 + [FunctionType.PROPERTIES]: '属性',
  31 + [FunctionType.EVENTS]: '事件',
  32 + [FunctionType.SERVICE]: '服务',
  33 +};
  34 +
  35 +const handleCopy = async (value: string) => {
  36 + const { createMessage } = useMessage();
  37 + const { copied, copy } = useClipboard({ legacy: true });
  38 + await copy(value);
  39 + if (unref(copied)) createMessage.success('复制成功~');
  40 + else createMessage.error('复制失败~');
  41 +};
  42 +
  43 +export const columnsDrawer: BasicColumn[] = [
  44 + {
  45 + title: '功能类型',
  46 + dataIndex: 'functionType',
  47 + width: 90,
  48 + format: (text: FunctionType) => {
  49 + return formatFunctionType[text];
  50 + },
  51 + },
  52 + {
  53 + title: '功能名称',
  54 + dataIndex: 'functionName',
  55 + width: 90,
  56 + ellipsis: true,
  57 + },
  58 + {
  59 + title: '标识符',
  60 + dataIndex: 'identifier',
  61 + width: 90,
  62 + ellipsis: true,
  63 + customRender: ({ text }: Record<'text', string>) => {
  64 + return h(Tooltip, { title: text }, () =>
  65 + h('span', { class: 'cursor-pointer', onClick: () => handleCopy(text) }, text)
  66 + );
  67 + },
  68 + },
  69 + {
  70 + title: '数据类型',
  71 + dataIndex: 'functionJson.dataType.type',
  72 + width: 100,
  73 + format: (text: string) => {
  74 + return text || '--';
  75 + },
  76 + ellipsis: true,
  77 + },
  78 + // {
  79 + // title: '事件类型',
  80 + // dataIndex: 'eventType',
  81 + // customRender({ text }) {
  82 + // return h(
  83 + // Tag,
  84 + // {
  85 + // color: EventTypeColor[text as EventType],
  86 + // },
  87 + // () => EventTypeName[text as EventType]
  88 + // );
  89 + // },
  90 + // ellipsis: true,
  91 + // },
  92 + // {
  93 + // title: '状态',
  94 + // dataIndex: 'status',
  95 + // width: 100,
  96 + // customRender: (value: Record<'text', number>) => {
  97 + // const { text } = value;
  98 + // return h(
  99 + // Tag,
  100 + // {
  101 + // color: text ? 'green' : 'red',
  102 + // },
  103 + // () => (text ? '已发布' : '待发布')
  104 + // );
  105 + // },
  106 + // },
  107 +];
  108 +
  109 +export const searchFormSchema: FormSchema[] = [
  110 + {
  111 + field: 'dictItemId',
  112 + label: '',
  113 + component: 'ApiSelect',
  114 + colProps: { span: 7 },
  115 + componentProps() {
  116 + return {
  117 + api: findDictItemByCode,
  118 + params: {
  119 + dictCode: DictEnum.CATEGORY_FIELD,
  120 + },
  121 + labelField: 'itemText',
  122 + valueField: 'itemValue',
  123 + placeholder: '请选择领域',
  124 + // getPopupContainer: () => document.body,
  125 + };
  126 + },
  127 + },
  128 + {
  129 + field: 'name',
  130 + label: '',
  131 + component: 'Input',
  132 + colProps: { span: 10 },
  133 + componentProps: {
  134 + placeholder: '请输入品类名称',
  135 + },
  136 + },
  137 +];
... ...
... ... @@ -42,6 +42,12 @@ export enum ModelOfMatterPermission {
42 42 DELETE = 'api:yt:things_model:delete',
43 43 RELEASE = 'api:yt:things_model:release',
44 44 }
  45 +export enum ModelCategoryPermission {
  46 + CREATE = 'api:yt:things_model:category:post',
  47 + UPDATE = 'api:yt:things_model:category:put',
  48 + DELETE = 'api:yt:things_model:category:delete',
  49 + RELEASE = 'api:yt:things_model:category:release',
  50 +}
45 51
46 52 const handleCopy = async (value: string) => {
47 53 const { createMessage } = useMessage();
... ... @@ -212,6 +218,41 @@ export const step1Schemas: FormSchema[] = [
212 218 },
213 219 },
214 220 {
  221 + field: 'category',
  222 + label: '产品品类',
  223 + component: 'RadioGroup',
  224 + defaultValue: 2,
  225 + required: true,
  226 + componentProps({ formModel }) {
  227 + return {
  228 + options: [
  229 + { label: '自定义品类', value: 2 },
  230 + { label: '标准品类', value: 1 },
  231 + ],
  232 + onChange() {
  233 + formModel.categoryId = null;
  234 + formModel.categoryName = undefined;
  235 + },
  236 + };
  237 + },
  238 + },
  239 + {
  240 + field: 'categoryId',
  241 + label: '产品品类',
  242 + component: 'Input',
  243 + defaultValue: 1,
  244 + ifShow: false,
  245 + },
  246 + {
  247 + field: 'categoryName',
  248 + label: ' ',
  249 + component: 'ApiSelect',
  250 + colProps: { span: 14 },
  251 + slot: 'categoryName',
  252 + required: true,
  253 + ifShow: ({ model }) => model.category === 1,
  254 + },
  255 + {
215 256 field: 'name',
216 257 label: '产品名称',
217 258 required: true,
... ... @@ -325,6 +366,14 @@ export const columns: BasicColumn[] = [
325 366 width: 120,
326 367 },
327 368 {
  369 + title: '产品品类',
  370 + dataIndex: 'categoryName',
  371 + width: 120,
  372 + format: (text) => {
  373 + return text ? text : '自定义品类';
  374 + },
  375 + },
  376 + {
328 377 title: '设备类型',
329 378 dataIndex: 'deviceType',
330 379 width: 90,
... ...
1 1 <template>
2 2 <div class="step1">
3   - <BasicForm @register="register" />
  3 + <BasicForm @register="register">
  4 + <template #categoryName="{ model }">
  5 + <div class="flex">
  6 + <Input
  7 + v-model:value="model.categoryName"
  8 + placeholder="请选择所属品类"
  9 + style="width: 300px"
  10 + @focus="handleFocus"
  11 + />
  12 + <Button type="link" :disabled="!model.categoryName" @click="handleCategoryId"
  13 + >查看功能</Button
  14 + >
  15 + </div>
  16 + </template>
  17 + </BasicForm>
  18 + <CateforyList
  19 + @register="registerDrawer"
  20 + @handleOpenListDrawer="handleOpenListDrawer"
  21 + @handleSelectCategory="handleSelectCategory"
  22 + @handleClose="handleClose"
  23 + />
  24 + <CateforyListDrawer @register="registerListDrawer" :cateforyListInfo="cateforyListInfo" />
4 25 </div>
5 26 </template>
6 27 <script lang="ts" setup>
7   - import { nextTick } from 'vue';
  28 + import { nextTick, ref } from 'vue';
8 29 import { BasicForm, useForm } from '/@/components/Form';
9 30 import { step1Schemas } from '../device.profile.data';
10 31 import { FileItem } from '/@/components/Form/src/components/ApiUpload.vue';
11 32 import { buildUUID } from '/@/utils/uuid';
  33 + import { Input, Button } from 'ant-design-vue';
  34 + import { useDrawer } from '/@/components/Drawer';
  35 + import CateforyList from '../components/CateforyList.vue';
  36 + import CateforyListDrawer from '../components/CateforyListDrawer.vue';
12 37
13 38 const emits = defineEmits(['next', 'emitDeviceType']);
14 39 const props = defineProps({
15 40 ifShowBtn: { type: Boolean, default: true },
16 41 });
  42 + const [registerDrawer, { openDrawer, closeDrawer }] = useDrawer();
  43 + const [registerListDrawer, { openDrawer: openListDrawer, closeDrawer: closeListDrawer }] =
  44 + useDrawer();
17 45
18 46 const [register, { validate, setFieldsValue, resetFields, updateSchema, getFieldsValue }] =
19 47 useForm({
... ... @@ -29,6 +57,7 @@
29 57 },
30 58 submitFunc: customSubmitFunc,
31 59 });
  60 +
32 61 const editOrAddNameStatus = (nameStatus) =>
33 62 updateSchema({
34 63 field: 'name',
... ... @@ -56,11 +85,12 @@
56 85 }
57 86 const { image, ...params } = v;
58 87 console.log(image);
59   - setFieldsValue({ ...params });
  88 + setFieldsValue({ ...params, category: params?.categoryId ? 1 : 2 });
60 89 };
61 90 //获取数据
62 91 async function getFormData() {
63   - const values = await validate();
  92 + await validate();
  93 + const values = getFieldsValue();
64 94 if (!values) return;
65 95 if (Reflect.has(values, 'image')) {
66 96 const file = (values.image || []).at(0) || {};
... ... @@ -82,6 +112,39 @@
82 112 });
83 113 };
84 114
  115 + // 查看功能
  116 + const handleCategoryId = () => {
  117 + const { categoryId } = getFieldsValue() || {};
  118 + if (!categoryId) return;
  119 + cateforyListInfo.value = { record: { id: categoryId }, isRight: false };
  120 + openListDrawer(true);
  121 + };
  122 +
  123 + // 获取焦点
  124 + const handleFocus = () => {
  125 + const { categoryId } = getFieldsValue() || {};
  126 + openDrawer(true, { categoryId });
  127 + };
  128 +
  129 + //打开品类名称
  130 + const cateforyListInfo = ref<any>({});
  131 + const handleOpenListDrawer = (record?: any) => {
  132 + cateforyListInfo.value = { record, isRight: true };
  133 + openListDrawer(true);
  134 + };
  135 +
  136 + // 选择产品品类
  137 + const handleSelectCategory = (item) => {
  138 + closeDrawer();
  139 + closeListDrawer();
  140 + item.id && setFieldsValue({ categoryId: item.id, categoryName: item?.name });
  141 + };
  142 +
  143 + // 关闭抽屉
  144 + const handleClose = () => {
  145 + closeListDrawer();
  146 + };
  147 +
85 148 defineExpose({
86 149 editOrAddNameStatus,
87 150 setFormData,
... ...
... ... @@ -27,25 +27,33 @@
27 27 </div>
28 28 <div class="flex justify-between items-end">
29 29 <div class="flex gap-2">
30   - <Authority :value="ModelOfMatterPermission.CREATE">
  30 + <Authority :value="[ModelOfMatterPermission.CREATE, ModelCategoryPermission.CREATE]">
31 31 <Button v-if="isShowBtn" type="primary" @click="handleCreateOrEdit()">
32 32 新增物模型
33 33 </Button>
34 34 </Authority>
35   - <Button type="primary" @click="handleOpenTsl"> 物模型TSL </Button>
36   - <Authority value="api:yt:things_model:import">
37   - <Upload
  35 + <Button v-if="!record.ifShowClass" type="primary" @click="handleOpenTsl">
  36 + 物模型TSL</Button
  37 + >
  38 + <Button v-else type="primary" @click="handleExport" :loading="loading"
  39 + >导出物模型</Button
  40 + >
  41 + <Authority
  42 + :value="['api:yt:things_model:import', 'api:yt:things_model:category:import']"
  43 + >
  44 + <!-- <Upload
38 45 v-if="isShowBtn"
39 46 accept=".json,"
40 47 :show-upload-list="false"
41 48 :customRequest="handleImportModel"
42 49 >
43 50 <Button type="primary" :loading="importLoading"> 导入物模型 </Button>
44   - </Upload>
  51 + </Upload> -->
  52 + <Button type="primary" @click="handleSelectImport">导入物模型</Button>
45 53 </Authority>
46 54 </div>
47 55 <div class="flex gap-2">
48   - <Authority :value="ModelOfMatterPermission.RELEASE">
  56 + <Authority :value="[ModelOfMatterPermission.RELEASE]">
49 57 <Popconfirm
50 58 title="是否需要发布上线?"
51 59 ok-text="确定"
... ... @@ -61,7 +69,7 @@
61 69 <Button v-if="isShowBtn" class="!bg-gray-200" type="text" @click="handleReturn">
62 70 返回
63 71 </Button>
64   - <Authority :value="ModelOfMatterPermission.DELETE">
  72 + <Authority :value="[ModelOfMatterPermission.DELETE, ModelCategoryPermission.DELETE]">
65 73 <Popconfirm
66 74 title="您确定要批量删除数据"
67 75 ok-text="确定"
... ... @@ -94,14 +102,14 @@
94 102 {
95 103 label: '编辑',
96 104 icon: 'clarity:note-edit-line',
97   - auth: ModelOfMatterPermission.UPDATE,
  105 + auth: [ModelOfMatterPermission.UPDATE, ModelCategoryPermission.UPDATE],
98 106 onClick: handleCreateOrEdit.bind(null, record),
99 107 ifShow: !isShowBtn ? false : true,
100 108 },
101 109 {
102 110 label: '删除',
103 111 icon: 'ant-design:delete-outlined',
104   - auth: ModelOfMatterPermission.DELETE,
  112 + auth: [ModelOfMatterPermission.DELETE, ModelCategoryPermission.DELETE],
105 113 color: 'error',
106 114 ifShow: !isShowBtn ? false : true,
107 115 popConfirm: {
... ... @@ -119,6 +127,11 @@
119 127 @success="handleSuccess"
120 128 />
121 129 <PhysicalModelTsl :record="$props.record" @register="registerModalTsl" />
  130 + <SelectImport
  131 + :record="$props.record"
  132 + @register="registerModalSelect"
  133 + @handleReload="handleReload"
  134 + />
122 135 </div>
123 136 </template>
124 137 <script lang="ts" setup>
... ... @@ -127,25 +140,32 @@
127 140 import {
128 141 modelOfMatterForm,
129 142 ModelOfMatterPermission,
  143 + ModelCategoryPermission,
130 144 physicalColumn,
131 145 } from '../device.profile.data';
132 146 import { useBatchDelete } from '/@/hooks/web/useBatchDelete';
133 147 import { Authority } from '/@/components/Authority';
134 148 import PhysicalModelModal from './cpns/physical/PhysicalModelModal.vue';
135 149 import PhysicalModelTsl from './cpns/physical/PhysicalModelTsl.vue';
136   - import { Popconfirm, Button, Alert, Upload } from 'ant-design-vue';
  150 + import { Popconfirm, Button, Alert } from 'ant-design-vue';
137 151 import { useMessage } from '/@/hooks/web/useMessage';
138 152 import { DeviceRecord } from '/@/api/device/model/deviceModel';
139 153 import {
140 154 deleteModel,
  155 + deleteModelCategory,
141 156 getModelList,
142   - importModelOfMatter,
143 157 releaseModel,
144 158 } from '/@/api/device/modelOfMatter';
145 159 import { OpenModelOfMatterModelParams, OpenModelMode } from './cpns/physical/types';
146 160 import { ModelOfMatterParams } from '/@/api/device/model/modelOfMatterModel';
147   - import { ref } from 'vue';
148   - import { isObject, isString } from '/@/utils/is';
  161 + import { ref, unref } from 'vue';
  162 + import { isObject } from '/@/utils/is';
  163 + import { useRole } from '/@/hooks/business/useRole';
  164 + import { ExportModelCategory } from '/@/api/device/modelOfMatter';
  165 + import { FunctionType } from './cpns/physical/cpns/config';
  166 + import SelectImport from '../components/SelectImport.vue';
  167 +
  168 + const { isPlatformAdmin, isSysadmin } = useRole();
149 169 defineEmits(['register']);
150 170
151 171 const props = defineProps<{
... ... @@ -156,10 +176,15 @@
156 176 const isShowBtn = ref(false);
157 177 const [registerModal, { openModal }] = useModal();
158 178 const [registerModalTsl, { openModal: openModalTsl }] = useModal();
  179 + const [registerModalSelect, { openModal: openModalSelect }] = useModal();
159 180
160 181 const [registerTable, { reload, setProps }] = useTable({
161 182 api: async (params: Record<'page' | 'pageSize', number>) => {
162   - return await getModelList({ ...params, deviceProfileId: props.record.id });
  183 + return await getModelList({
  184 + ...params,
  185 + id: props.record.id,
  186 + selectType: props.record.ifShowClass ? 'category' : undefined,
  187 + });
163 188 },
164 189 columns: physicalColumn,
165 190 showIndexColumn: false,
... ... @@ -186,7 +211,7 @@
186 211 };
187 212
188 213 const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions } = useBatchDelete(
189   - deleteModel,
  214 + props.record.ifShowClass && (isPlatformAdmin || isSysadmin) ? deleteModelCategory : deleteModel,
190 215 handleSuccess,
191 216 setProps
192 217 );
... ... @@ -242,59 +267,136 @@
242 267 }
243 268 };
244 269
245   - const paseJSON = (string: string) => {
246   - let data = null;
247   - let flag = false;
248   - try {
249   - if (!isString(string)) return { flag: false, data };
250   - data = JSON.parse(string);
251   - flag = true;
252   - if (!isObject(data)) flag = false;
253   - } catch (error) {}
254   - return { flag, data };
255   - };
  270 + // const paseJSON = (string: string) => {
  271 + // let data = null;
  272 + // let flag = false;
  273 + // try {
  274 + // if (!isString(string)) return { flag: false, data };
  275 + // data = JSON.parse(string);
  276 + // flag = true;
  277 + // if (!isObject(data)) flag = false;
  278 + // } catch (error) {}
  279 + // return { flag, data };
  280 + // };
256 281
257 282 const isEmptyObject = (value: any) => isObject(value) && !Object.keys(value).length;
258 283
259   - const importLoading = ref(false);
260   - const handleImportModel = async (data: { file: File }) => {
261   - const fileReader = new FileReader();
  284 + // const importLoading = ref(false);
  285 + // const handleImportModel = async (data: { file: File }) => {
  286 + // const fileReader = new FileReader();
  287 +
  288 + // fileReader.onload = async () => {
  289 + // const { flag, data } = paseJSON(fileReader.result as string);
  290 + // if (!flag) {
  291 + // createMessage.warning('JSON解析失败,请导入正确的JSON~');
  292 + // return;
  293 + // }
  294 + // try {
  295 + // importLoading.value = true;
  296 +
  297 + // Object.keys(data || {}).forEach((key) => {
  298 + // const value = (data || {})[key];
  299 + // if (value && isEmptyObject(value)) {
  300 + // (data || {})[key] = [];
  301 + // }
  302 + // });
  303 +
  304 + // const result =
  305 + // (unref(isPlatformAdmin) || unref(isSysadmin)) && props.record.ifShowClass
  306 + // ? await importModelCategory({
  307 + // categoryId: props.record.id,
  308 + // data: data!,
  309 + // functionType: 'all',
  310 + // })
  311 + // : await importModelOfMatter({
  312 + // tkDeviceProfileId: props.record.id,
  313 + // data: data!,
  314 + // functionType: 'all',
  315 + // });
  316 +
  317 + // result
  318 + // ? createMessage.success('导入成功~')
  319 + // : createMessage.error('JSON解析失败,请导入正确的JSON~');
  320 +
  321 + // result && reload();
  322 + // } catch (error) {
  323 + // throw error;
  324 + // } finally {
  325 + // importLoading.value = false;
  326 + // }
  327 + // };
  328 +
  329 + // fileReader.readAsText(data.file, 'utf-8');
  330 + // };
262 331
263   - fileReader.onload = async () => {
264   - const { flag, data } = paseJSON(fileReader.result as string);
265   - if (!flag) {
266   - createMessage.warning('JSON解析失败,请导入正确的JSON~');
267   - return;
268   - }
269   - try {
270   - importLoading.value = true;
  332 + // 选择导入物模型的方式
  333 + const handleSelectImport = () => {
  334 + openModalSelect(true, {
  335 + id: props.record.id,
  336 + isCateGory: (unref(isPlatformAdmin) || unref(isSysadmin)) && props.record.ifShowClass,
  337 + });
  338 + };
271 339
272   - Object.keys(data || {}).forEach((key) => {
273   - const value = (data || {})[key];
274   - if (value && isEmptyObject(value)) {
275   - (data || {})[key] = [];
276   - }
277   - });
  340 + const handleReload = () => {
  341 + reload();
  342 + };
278 343
279   - const result = await importModelOfMatter({
280   - tkDeviceProfileId: props.record.id,
281   - data: data!,
282   - functionType: 'all',
283   - });
  344 + // 导出物模型
  345 + const loading = ref<boolean>(false);
284 346
285   - result
286   - ? createMessage.success('导入成功~')
287   - : createMessage.error('JSON解析失败,请导入正确的JSON~');
  347 + const getAllCategory = () => {
  348 + const { id: deviceProfileId } = props.record;
  349 + return Promise.all([
  350 + ExportModelCategory({
  351 + deviceProfileId,
  352 + functionType: FunctionType.EVENTS,
  353 + }),
  354 + ExportModelCategory({
  355 + deviceProfileId,
  356 + functionType: FunctionType.PROPERTIES,
  357 + }),
  358 + ExportModelCategory({
  359 + deviceProfileId,
  360 + functionType: FunctionType.SERVICE,
  361 + }),
  362 + ]);
  363 + };
  364 + const exportJSONFile = (value: Recordable) => {
  365 + const blob = new Blob([JSON.stringify(value, null, 2)], { type: 'text/json' });
  366 + const objectURL = URL.createObjectURL(blob);
  367 + const element = document.createElement('a');
  368 + element.href = objectURL;
  369 + element.download = `${props.record.name}-model.json`;
  370 + element.style.display = 'none';
  371 + document.body.appendChild(element);
  372 + element.click();
  373 + element.remove();
  374 + URL.revokeObjectURL(objectURL);
  375 + };
288 376
289   - result && reload();
290   - } catch (error) {
291   - throw error;
292   - } finally {
293   - importLoading.value = false;
294   - }
295   - };
  377 + const isEmptyStr = (s: any) => {
  378 + if (s == undefined || s == null || s == '') {
  379 + return true;
  380 + }
  381 + return false;
  382 + };
296 383
297   - fileReader.readAsText(data.file, 'utf-8');
  384 + //产品品类物模型导出
  385 + const handleExport = async () => {
  386 + loading.value = true;
  387 + try {
  388 + const [events, properties, services] = await getAllCategory();
  389 + const value = {
  390 + properties: isEmptyObject(properties) || isEmptyStr(properties) ? [] : properties,
  391 + services: isEmptyObject(services) || isEmptyStr(services) ? [] : services,
  392 + events: isEmptyObject(events) || isEmptyStr(events) ? [] : events,
  393 + };
  394 + exportJSONFile(value);
  395 + } catch (error) {
  396 + throw error;
  397 + } finally {
  398 + loading.value = false;
  399 + }
298 400 };
299 401
300 402 defineExpose({});
... ...
... ... @@ -60,11 +60,19 @@
60 60 import Service from './cpns/Service.vue';
61 61 import Events from './cpns/Events.vue';
62 62 import { ModelOfMatterParams } from '/@/api/device/model/modelOfMatterModel';
63   - import { createModel, updateModel } from '/@/api/device/modelOfMatter';
  63 + import {
  64 + createModel,
  65 + updateModel,
  66 + createModelCategory,
  67 + updateModelCategory,
  68 + } from '/@/api/device/modelOfMatter';
64 69 import { DeviceRecord, DeviceTypeEnum } from '/@/api/device/model/deviceModel';
65 70 import { useMessage } from '/@/hooks/web/useMessage';
66 71 import { OpenModelMode, OpenModelOfMatterModelParams } from './types/index';
67 72 import { FunctionType } from './cpns/config';
  73 + import { useRole } from '/@/hooks/business/useRole';
  74 +
  75 + const { isPlatformAdmin, isSysadmin } = useRole();
68 76
69 77 const emit = defineEmits(['register', 'success']);
70 78
... ... @@ -158,12 +166,25 @@
158 166 params = (await EventsRef.value?.getFormData()) || {};
159 167 }
160 168 params.deviceProfileId = props.record.id;
  169 +
161 170 if (unref(openModalMode) === OpenModelMode.CREATE) {
162   - await createModel(params);
  171 + (await (unref(isSysadmin) || unref(isPlatformAdmin))) && props.record.ifShowClass
  172 + ? createModelCategory({
  173 + ...params,
  174 + deviceProfileId: undefined,
  175 + categoryId: props.record.id,
  176 + })
  177 + : createModel(params);
163 178 createMessage.success('创建成功');
164 179 } else {
165 180 params.id = unref(openModalParams)?.record.id;
166   - await updateModel(params);
  181 + (await (unref(isSysadmin) || unref(isPlatformAdmin))) && props.record.ifShowClass
  182 + ? updateModelCategory({
  183 + ...params,
  184 + deviceProfileId: undefined,
  185 + categoryId: props.record.id,
  186 + })
  187 + : updateModel(params);
167 188 createMessage.success('修改成功');
168 189 }
169 190 closeModal();
... ...
... ... @@ -73,9 +73,18 @@
73 73 const getAllModel = () => {
74 74 const { id: deviceProfileId } = props.record;
75 75 return Promise.all([
76   - getModelTsl({ deviceProfileId, functionType: FunctionType.EVENTS }),
77   - getModelTsl({ deviceProfileId, functionType: FunctionType.PROPERTIES }),
78   - getModelTsl({ deviceProfileId, functionType: FunctionType.SERVICE }),
  76 + getModelTsl({
  77 + deviceProfileId,
  78 + functionType: FunctionType.EVENTS,
  79 + }),
  80 + getModelTsl({
  81 + deviceProfileId,
  82 + functionType: FunctionType.PROPERTIES,
  83 + }),
  84 + getModelTsl({
  85 + deviceProfileId,
  86 + functionType: FunctionType.SERVICE,
  87 + }),
79 88 ]);
80 89 };
81 90
... ...
... ... @@ -84,7 +84,10 @@
84 84 const handleSwitchTsl = async (functionType: FunctionType) => {
85 85 try {
86 86 loading.value = true;
87   - const record = await getModelTsl({ deviceProfileId: props.record.id, functionType });
  87 + const record = await getModelTsl({
  88 + deviceProfileId: props.record.id,
  89 + functionType,
  90 + });
88 91 jsonValue.value = JSON.stringify(
89 92 {
90 93 [functionType]: record,
... ...