From 6a387d2c344ca95a077c03713c4f475390ed578d Mon Sep 17 00:00:00 2001 From: ailanyin Date: Mon, 20 Mar 2023 10:40:18 +0800 Subject: [PATCH] model field --- src/constant/dict.js | 32 ++--- src/views/product/firmware/index.vue | 8 +- .../product/product/components/model.vue | 71 +++++++++-- .../product/product/{components => }/edit.vue | 16 ++- src/views/product/product/index.vue | 117 +++++++++++++++--- src/views/register.vue | 1 - 6 files changed, 196 insertions(+), 49 deletions(-) rename src/views/product/product/{components => }/edit.vue (96%) diff --git a/src/constant/dict.js b/src/constant/dict.js index 00cbb7f..8402846 100644 --- a/src/constant/dict.js +++ b/src/constant/dict.js @@ -8,20 +8,11 @@ export const deviceTypeMap = new Map([ [2, "网关子设备"], [3, "网关子设备"], ]); -export const vertificateMethodOptions = [ - { - label: "简单认证", - value: 1, - }, - { - label: "加密认证", - value: 2, - }, - { - label: "简单+加密", - value: 3, - }, -]; +export const vertificateMethodOptions = new Map([ + [1, "简单认证"], + [2, "加密认证"], + [3, "简单+加密"], +]); export const isTopMap = new Map([ [0, "是"], @@ -33,7 +24,18 @@ export const isMonitor = new Map([ [1, "否"], ]); -export const productStatusMap = [[1, ""]]; +export const productStatusMap = [ + { + label: "未发布", + value: 1, + tag: "info", + }, + { + label: "已发布", + value: 2, + tag: "success", + }, +]; export const firmwareLatestTypeOptions = [ { diff --git a/src/views/product/firmware/index.vue b/src/views/product/firmware/index.vue index 2ebdf49..7c0f9c7 100644 --- a/src/views/product/firmware/index.vue +++ b/src/views/product/firmware/index.vue @@ -79,8 +79,8 @@ 搜索 + >搜索 + 重置 @@ -234,6 +234,7 @@ - + + + + + + + 事件 + + + + @@ -142,25 +185,25 @@ @@ -197,6 +240,7 @@ { type: 3, })), ]; + modelList.value = modelList.value.sort( + (a, b) => b.createTime - a.createTime + ); } catch (e) { console.log(e); } @@ -429,6 +476,7 @@ const reset = () => { isSys: null, isTop: null, isMonitor: null, + isReadonly: 0, delFlag: null, createBy: null, createTime: null, @@ -490,8 +538,15 @@ const handleDelete = (row) => { }; // 类型改变 const typeChange = (label) => { - if (label === 2 || label === 3) { - form.value.isMonitor = 0; + // if (label === 2 || label === 3) { + // form.value.isMonitor = 0; + // } + if ( + label === 1 && + form.value.datatype !== "integer" && + form.value.datatype !== "decimal" + ) { + form.value.datatype = "integer"; } }; const dataTypeChange = () => {}; @@ -528,6 +583,7 @@ const submitForm = () => { form.value.specs = formatThingsSpecs(); form.value.productId = product.value.productId; form.value.productName = product.value.productName; + form.value.updateTime = Date.now(); const _modelJson = JSON.parse(modelJson.value); const modelType = modelTypeMap.get(form.value.type); _modelJson[modelType].forEach((el, index) => { @@ -558,6 +614,7 @@ const submitForm = () => { // 格式化specs form.value.modelId = uuidv4(); form.value.specs = formatThingsSpecs(); + form.value.createTime = Date.now(); form.value.productId = product.value.productId; form.value.productName = product.value.productName; // if (form.value.type === 2) { diff --git a/src/views/product/product/components/edit.vue b/src/views/product/product/edit.vue similarity index 96% rename from src/views/product/product/components/edit.vue rename to src/views/product/product/edit.vue index 5b22f43..9164289 100644 --- a/src/views/product/product/components/edit.vue +++ b/src/views/product/product/edit.vue @@ -103,10 +103,10 @@ placeholder="请选择认证方式" > @@ -139,7 +139,7 @@ /> - + @@ -173,6 +173,10 @@ const checkProductSnUnique = debounce((rule, value, callback) => { isProductSnUnique.value = undefined; return; } + if (value === oriSn.value) { + callback(); + return; + } checkProductSn(value) .then((response) => { const isUnique = response.data; @@ -241,6 +245,7 @@ function reset() { } // 获取产品详情, 回显表单 +const oriSn = ref(""); // 自己的sn const getData = () => { reset(); const _productId = route.query.productId; @@ -249,6 +254,7 @@ const getData = () => { tab.updatePage(tabObj); getProduct(_productId).then((response) => { form.value = response.data; + oriSn.value = response.data.productSn; }); } else { const tabObj = Object.assign({}, route, { title: "新增产品" }); diff --git a/src/views/product/product/index.vue b/src/views/product/product/index.vue index b730678..bc975f8 100644 --- a/src/views/product/product/index.vue +++ b/src/views/product/product/index.vue @@ -24,12 +24,18 @@ @keyup.enter="handleQuery" /> - - + @@ -146,20 +152,53 @@ - - + + + + + + - + + + - - - + + + + + + + + + - - - + + + 0) { + result = findNode(node.children, categoryId); + if (result) break; + } + } + return result; +} + // 取消按钮 function cancel() { open.value = false; @@ -430,7 +494,22 @@ function handleExport() { ); } +const getTenantOptions = async (keyword) => { + const response = await listTenant({ + pageNum: 1, + pageSize: 20, + tenantName: keyword, + }); + tenantOptions.value = response.rows; +}; +const getCategoryList = async () => { + const response = await listCategory(); + categoryOptions.value = response.data; +}; + getList(); +getCategoryList(); +getTenantOptions();