|
@@ -5,7 +5,7 @@
|
|
|
<el-card shadow="hover">
|
|
|
<el-form ref="queryFormRef" :model="queryParams" :inline="true" label-width="150px">
|
|
|
<el-form-item label="产品分类" prop="productCategory">
|
|
|
- <el-cascader v-model="queryParams.productCategoryList" :options="categoryOptions" :props="{ checkStrictly: false, emitPath: true, value: 'value', label: 'label', children: 'children' }" placeholder="请选择" clearable filterable style="width: 200px" />
|
|
|
+ <el-cascader v-model="queryParams.productCategoryList" :options="categoryOptions" :props="{ checkStrictly: true, emitPath: true, value: 'value', label: 'label', children: 'children' }" placeholder="请选择" clearable filterable style="width: 200px" />
|
|
|
</el-form-item>
|
|
|
<el-form-item>
|
|
|
<el-input v-model="queryParams.productName" placeholder="请输入名称/编码" clearable @keyup.enter="handleQuery" style="margin-left: 30px;" />
|
|
@@ -32,9 +32,9 @@
|
|
|
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['warehouse:nutrition:remove']">删除</el-button>
|
|
|
</el-col> -->
|
|
|
|
|
|
- <el-col :span="1.5">
|
|
|
+ <!-- <el-col :span="1.5">
|
|
|
<el-button type="warning" plain @click="handleImport" v-hasPermi="['system:diseaseLabel:export']">导入</el-button>
|
|
|
- </el-col>
|
|
|
+ </el-col> -->
|
|
|
<el-col :span="1.5">
|
|
|
<el-button type="warning" plain @click="handleExport" v-hasPermi="['warehouse:nutrition:export']">导出</el-button>
|
|
|
</el-col>
|
|
@@ -146,7 +146,7 @@
|
|
|
<el-row :gutter="20">
|
|
|
<el-col :span="12">
|
|
|
<el-form-item label="产品所属分类:" prop="productCategory">
|
|
|
- <el-cascader v-model="form.productCategoryList" :options="categoryOptions" :props="{ checkStrictly: false, emitPath: true, value: 'value', label: 'label', children: 'children' }" placeholder="请选择" clearable filterable style="width: 100%" />
|
|
|
+ <el-cascader v-model="form.productCategoryList" :options="categoryOptions" :props="{ checkStrictly: true, emitPath: true, value: 'value', label: 'label', children: 'children' }" placeholder="请选择" clearable filterable style="width: 100%" />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
@@ -194,12 +194,11 @@
|
|
|
<el-row :gutter="20">
|
|
|
<el-col :span="12">
|
|
|
<el-form-item label="产品所属标签:" prop="productLabelList">
|
|
|
- <el-select v-model="form.productLabelList" multiple placeholder="请选择" style="width: 100%;" :disabled="true" @mousedown.prevent="diseaseLabelDialogVisible = true" class="custom-label-select" value-key="labelId">
|
|
|
+ <el-select v-model="form.productLabelList" multiple placeholder="请选择" style="width: 100%;" :disabled="true" @click="diseaseLabelDialogVisible = true" class="custom-label-select" value-key="labelId">
|
|
|
<el-option v-for="item in form.productLabelList" :key="item.labelId" :label="item.labelName" :value="item">
|
|
|
<el-tag type="info" size="small">{{ item.labelName }}</el-tag>
|
|
|
</el-option>
|
|
|
</el-select>
|
|
|
- <lableDialog :model-value="diseaseLabelDialogVisible" @update:modelValue="val => diseaseLabelDialogVisible = val" @confirm="onLabelConfirm" />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
@@ -209,7 +208,6 @@
|
|
|
<el-tag type="info" size="small">{{ item.labelName }}</el-tag>
|
|
|
</el-option>
|
|
|
</el-select>
|
|
|
- <lableDialog :model-value="contraindicationLabelDialogVisible" @update:modelValue="val => contraindicationLabelDialogVisible = val" @confirm="onContraindicationLabelConfirm" />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
@@ -1009,13 +1007,13 @@
|
|
|
</template>
|
|
|
</el-dialog>
|
|
|
<el-dialog title="批量设置" v-model="batchSetDialogVisible" width="400px" append-to-body>
|
|
|
- <el-form :model="batchSetForm" label-width="120px">
|
|
|
- <el-form-item label="保质期临期提醒">
|
|
|
+ <el-form :model="batchSetForm" label-width="120px" :rules="batchRules">
|
|
|
+ <el-form-item label="保质期临期提醒" prop="shelfLifeReminder">
|
|
|
<el-input v-model="batchSetForm.shelfLifeReminder" min="1" placeholder="请输入" style="width: 200px;">
|
|
|
<template #append>个月</template>
|
|
|
</el-input>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="许可证临期提醒">
|
|
|
+ <el-form-item label="许可证临期提醒" prop="licenseExpiryReminder">
|
|
|
<el-input v-model="batchSetForm.licenseExpiryReminder" min="1" placeholder="请输入" style="width: 200px;">
|
|
|
<template #append>个月</template>
|
|
|
</el-input>
|
|
@@ -1034,10 +1032,10 @@
|
|
|
<el-divider content-position="left">基本信息:</el-divider>
|
|
|
<el-row :gutter="40" style="margin-top: 30px">
|
|
|
<el-col :span="12">
|
|
|
- <div><b>产品名称:</b>{{ form.productName || '--' }}</div>
|
|
|
- <div><b>院方系统编码:</b>{{ form.hospitalSystemCode || '--' }}</div>
|
|
|
- <div><b>商品编码:</b>{{ form.productCode || '--' }}</div>
|
|
|
- <div><b>产品所属分类:</b>{{ form.productCategory || '--' }}</div>
|
|
|
+ <div><b><span style="color:red;margin-right: 3px">*</span>产品名称:</b>{{ form.productName || '--' }}</div>
|
|
|
+ <div><b><span style="color:red;margin-right: 3px">*</span>院方系统编码:</b>{{ form.hospitalSystemCode || '--' }}</div>
|
|
|
+ <div><b><span style="color:red;margin-right: 3px">*</span>商品编码:</b>{{ form.productCode || '--' }}</div>
|
|
|
+ <div><b><span style="color:red;margin-right: 3px">*</span>产品所属分类:</b>{{ form.productCategory || '--' }}</div>
|
|
|
<div><b>生产厂商:</b>{{ getDictLabel(product_manufacturer, form.manufacturer) || '--' }}</div>
|
|
|
<div><b>品牌:</b>{{ form.brand || '--' }}</div>
|
|
|
<div><b>产品所属标签:</b>{{ form.productLabel || '--' }}</div>
|
|
@@ -1045,33 +1043,33 @@
|
|
|
<div><b>商品许可证有效期至:</b>{{ form.productLicenseExpiry ? (form.productLicenseExpiry.slice(0, 10)) : '--' }}</div>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
- <div><b>商品资质:</b>{{ getDictLabel(product_qualification, form.productQualification) || '--' }}</div>
|
|
|
+ <div><b><span style="color:red;margin-right: 3px">*</span>商品资质:</b>{{ getDictLabel(product_qualification, form.productQualification) || '--' }}</div>
|
|
|
<div><b>批准文号:</b>{{ form.approvalNumber || '--' }}</div>
|
|
|
<div><b>口味:</b>{{ form.taste || '--' }}</div>
|
|
|
<div><b>剂型/形态:</b>{{ getDictLabel(dosage_form, form.dosageForm) || '--' }}</div>
|
|
|
<div><b>供应商:</b>{{ getDictLabel(product_supplier, form.supplier) || '--' }}</div>
|
|
|
<div><b>产品适用科室:</b>{{ form.applicableDepartment|| '--' }}</div>
|
|
|
<div><b>禁忌症所属标签:</b>{{ form.contraindicationLabel || '--' }}</div>
|
|
|
- <div><b>保质期临期提醒:</b>{{ form.shelfLifeReminder || '--' }}</div>
|
|
|
+ <div><b><span style="color:red;margin-right: 3px">*</span>保质期临期提醒:</b>{{ form.shelfLifeReminder || '--' }}</div>
|
|
|
<div><b>保质期:</b>{{ form.shelfLife || '--' }}</div>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
<el-divider content-position="left">入货信息:</el-divider>
|
|
|
<el-row :gutter="40" style="margin-top: 30px">
|
|
|
<el-col :span="12">
|
|
|
- <div><b>入货价格:</b>{{ form.purchasePrice || '--' }} 元</div>
|
|
|
+ <div><b><span style="color:red;margin-right: 3px">*</span>入货价格:</b>{{ form.purchasePrice || '--' }} 元</div>
|
|
|
<div><b>默认用法:</b>{{ getDictLabel(default_usage, form.defaultUsage) || '--' }}</div>
|
|
|
- <div><b>商品规格:</b>{{ form.productSpec || '--' }}{{getDictLabel(product_spec_unit ,form.productSpecUnit )|| '--' }}/{{getDictLabel(product_package_unit ,form.packageUnit )|| '--' }}</div>
|
|
|
+ <div><b><span style="color:red;margin-right: 3px">*</span>商品规格:</b>{{ form.productSpec || '--' }}{{getDictLabel(product_spec_unit ,form.productSpecUnit )|| '--' }}/{{getDictLabel(product_package_unit ,form.packageUnit )|| '--' }}</div>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
- <div><b>入货单位:</b>{{ getDictLabel(product_package_unit, form.purchaseUnit) || '--' }}</div>
|
|
|
- <div><b>预包装单位:</b>{{ getDictLabel(product_package_unit, form.packageUnit) || '--' }}</div>
|
|
|
+ <div><b><span style="color:red;margin-right: 3px">*</span>入货单位:</b>{{ getDictLabel(product_package_unit, form.purchaseUnit) || '--' }}</div>
|
|
|
+ <div><b><span style="color:red;margin-right: 3px">*</span>预包装单位:</b>{{ getDictLabel(product_package_unit, form.packageUnit) || '--' }}</div>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
<el-divider content-position="left">预包装销售设置:</el-divider>
|
|
|
<el-row :gutter="40" style="margin-top: 30px">
|
|
|
<el-col :span="12">
|
|
|
- <div><b>预包装销售价:</b>{{ form.packagePrice || '--' }}元/{{ getDictLabel(product_package_unit, form.packageUnit) || '--' }}</div>
|
|
|
+ <div><b><span style="color:red;margin-right: 3px">*</span>预包装销售价:</b>{{ form.packagePrice || '--' }}元/{{ getDictLabel(product_package_unit, form.packageUnit) || '--' }}</div>
|
|
|
<div><b>最小包装规格:</b>{{ form.minSpec || '--' }} {{getDictLabel(product_spec_unit ,form.productSpecUnit )|| '--' }}/{{ getDictLabel(product_package_unit, form.minUnit) || '--' }}</div>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
@@ -1082,7 +1080,7 @@
|
|
|
<el-divider content-position="left">配置销售设置:</el-divider>
|
|
|
<el-row :gutter="40" style="margin-top: 30px">
|
|
|
<el-col :span="12">
|
|
|
- <div><b>配置销售价格:</b>{{ form.configSalePrice || '--' }} 元/{{getDictLabel(product_spec_unit ,form.productSpecUnit )|| '--' }}</div>
|
|
|
+ <div><b><span style="color:red;margin-right: 3px">*</span>配置销售价格:</b>{{ form.configSalePrice || '--' }} 元/{{getDictLabel(product_spec_unit ,form.productSpecUnit )|| '--' }}</div>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
<div><b>配置损耗率:</b>{{ form.configLossRate || '--' }} %</div>
|
|
@@ -1339,7 +1337,7 @@
|
|
|
<el-tab-pane label="其他" name="others">
|
|
|
<span style="color: red; font-size: 16px; margin-bottom: 10px">注:每100(g/ml) 含量</span>
|
|
|
<el-row :gutter="40" style="margin-top: 30px">
|
|
|
- <el-col :span="6" >
|
|
|
+ <el-col :span="6">
|
|
|
<div><b>血糖生成指数:</b>{{ form.bloodGlucoseIndex || '--' }} mg</div>
|
|
|
</el-col>
|
|
|
<el-col :span="6">
|
|
@@ -1431,555 +1429,574 @@
|
|
|
请上传 .xls , .xlsx 标准格式文件
|
|
|
</div>
|
|
|
</el-dialog>
|
|
|
+ <!-- 添加疾病标签弹窗 -->
|
|
|
+ <LabelDialog
|
|
|
+ v-model="diseaseLabelDialogVisible"
|
|
|
+ :initial-selected-labels="form.productLabelList || []"
|
|
|
+ @confirm="onLabelConfirm"
|
|
|
+ />
|
|
|
+ <!-- 添加禁忌症标签弹窗 -->
|
|
|
+ <LabelDialog
|
|
|
+ v-model="contraindicationLabelDialogVisible"
|
|
|
+ :initial-selected-labels="form.contraindicationLabelList || []"
|
|
|
+ @confirm="onContraindicationLabelConfirm"
|
|
|
+ />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
-<script setup name="Nutrition" lang="ts">
|
|
|
- import { listNutrition, getNutrition, delNutrition, addNutrition, updateNutrition, batchUpdateNutrition } from '@/api/warehouse/productNutrition/index';
|
|
|
- import { NutritionVO, NutritionQuery, NutritionForm } from '@/api/warehouse/productNutrition/types';
|
|
|
- import { listCategory } from '@/api/warehouse/productCategory/index';
|
|
|
- import { listDept } from '@/api/system/dept';
|
|
|
- import { globalHeaders } from '@/utils/request';
|
|
|
- import { FormInstance, ElMessageBox, UploadFile, UploadFiles } from 'element-plus';
|
|
|
- import { getCurrentInstance, ComponentInternalInstance, ref, reactive, toRefs, onMounted } from 'vue';
|
|
|
- import { log } from 'console';
|
|
|
- import lableDialog from './labelDialog.vue';
|
|
|
- import FileUpload from '@/components/FileUpload/index.vue';
|
|
|
- const diseaseLabelDialogVisible = ref(false);
|
|
|
- const contraindicationLabelDialogVisible = ref(false);
|
|
|
-
|
|
|
- const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
|
|
- const { product_qualification, dosage_form, product_package_unit, product_supplier, put_flag, product_manufacturer, default_usage, product_spec_unit } = toRefs < any > (proxy ?.useDict('product_qualification', 'dosage_form', 'product_package_unit', 'product_supplier', 'put_flag', 'product_manufacturer', 'default_usage', 'product_spec_unit'));
|
|
|
-
|
|
|
-
|
|
|
- const nutritionList = ref < NutritionVO[] > ([]);
|
|
|
- const baseUrl =
|
|
|
- import.meta.env.VITE_APP_BASE_API; // 上传文件地址
|
|
|
- const uploadFileUrl = ref(baseUrl + 'warehouse/nutrition/importExcel');
|
|
|
- const buttonLoading = ref(false);
|
|
|
- const loading = ref(true);
|
|
|
- const showSearch = ref(true);
|
|
|
- const ids = ref < Array < string | number >> ([]);
|
|
|
- const single = ref(true);
|
|
|
- const multiple = ref(true);
|
|
|
- const total = ref(0);
|
|
|
- const headers = ref(globalHeaders()); // 请求头设置
|
|
|
-
|
|
|
- const activeTab = ref('basic');
|
|
|
- const detailDialogVisible = ref(false);
|
|
|
- const batchSetDialogVisible = ref(false);
|
|
|
- const fileList = ref([]); // 用于Excel导入的文件列表
|
|
|
- const batchSetForm = reactive({
|
|
|
- shelfLifeReminder: '',
|
|
|
- licenseExpiryReminder: ''
|
|
|
+<script setup lang="ts">
|
|
|
+import { ref, reactive, onMounted, getCurrentInstance } from 'vue';
|
|
|
+import { listNutrition, getNutrition, delNutrition, addNutrition, updateNutrition, batchUpdateNutrition } from '@/api/warehouse/productNutrition/index';
|
|
|
+import { NutritionVO, NutritionQuery, NutritionForm } from '@/api/warehouse/productNutrition/types';
|
|
|
+import { listCategory } from '@/api/warehouse/productCategory/index';
|
|
|
+import { listDept } from '@/api/system/dept';
|
|
|
+import { globalHeaders } from '@/utils/request';
|
|
|
+import { FormInstance, ElMessageBox, UploadFile, UploadFiles } from 'element-plus';
|
|
|
+import { log } from 'console';
|
|
|
+import LabelDialog from './labelDialog.vue';
|
|
|
+import FileUpload from '@/components/FileUpload/index.vue';
|
|
|
+
|
|
|
+const diseaseLabelDialogVisible = ref(false);
|
|
|
+const contraindicationLabelDialogVisible = ref(false);
|
|
|
+
|
|
|
+const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
|
|
+const { product_qualification, dosage_form, product_package_unit, product_supplier, put_flag, product_manufacturer, default_usage, product_spec_unit } = toRefs < any > (proxy ?.useDict('product_qualification', 'dosage_form', 'product_package_unit', 'product_supplier', 'put_flag', 'product_manufacturer', 'default_usage', 'product_spec_unit'));
|
|
|
+
|
|
|
+
|
|
|
+const nutritionList = ref < NutritionVO[] > ([]);
|
|
|
+const baseUrl =
|
|
|
+ import.meta.env.VITE_APP_BASE_API; // 上传文件地址
|
|
|
+const uploadFileUrl = ref(baseUrl + 'warehouse/nutrition/importExcel');
|
|
|
+const buttonLoading = ref(false);
|
|
|
+const loading = ref(true);
|
|
|
+const showSearch = ref(true);
|
|
|
+const ids = ref < Array < string | number >> ([]);
|
|
|
+const single = ref(true);
|
|
|
+const multiple = ref(true);
|
|
|
+const total = ref(0);
|
|
|
+const headers = ref(globalHeaders()); // 请求头设置
|
|
|
+
|
|
|
+const activeTab = ref('basic');
|
|
|
+const detailDialogVisible = ref(false);
|
|
|
+const batchSetDialogVisible = ref(false);
|
|
|
+const fileList = ref([]); // 用于Excel导入的文件列表
|
|
|
+const batchSetForm = reactive({
|
|
|
+ shelfLifeReminder: '',
|
|
|
+ licenseExpiryReminder: ''
|
|
|
+});
|
|
|
+
|
|
|
+const batchRules = {
|
|
|
+ shelfLifeReminder: [{ required: true, message: "保质期临期提醒不能为空", trigger: "blur" }],
|
|
|
+ licenseExpiryReminder: [{ required: true, message: "许可证临期提醒不能为空", trigger: "blur" }],
|
|
|
+
|
|
|
+};
|
|
|
+
|
|
|
+const treeData = ref([]); // 定义 treeData
|
|
|
+const deptList = ref([]); // 定义 科室list
|
|
|
+
|
|
|
+const queryFormRef = ref < FormInstance > ();
|
|
|
+const nutritionFormRef = ref < FormInstance > ();
|
|
|
+
|
|
|
+const dialog = reactive < DialogOption > ({
|
|
|
+ visible: false,
|
|
|
+ title: ''
|
|
|
+});
|
|
|
+const dialogFile = reactive < DialogOption > ({
|
|
|
+ visible: false,
|
|
|
+ title: '请上传'
|
|
|
+});
|
|
|
+
|
|
|
+const initFormData: NutritionForm = {
|
|
|
+ id: undefined,
|
|
|
+ ids: undefined,
|
|
|
+ productName: undefined,
|
|
|
+ hospitalSystemCode: undefined,
|
|
|
+ productCode: undefined,
|
|
|
+ productCategory: undefined,
|
|
|
+ productCategoryList: undefined,
|
|
|
+ manufacturer: undefined,
|
|
|
+ brand: undefined,
|
|
|
+ licenseExpiryReminder: undefined,
|
|
|
+ productLicenseExpiry: undefined,
|
|
|
+ productQualification: undefined,
|
|
|
+ approvalNumber: undefined,
|
|
|
+ taste: undefined,
|
|
|
+ dosageForm: undefined,
|
|
|
+ supplier: undefined,
|
|
|
+ applicableDepartment: undefined,
|
|
|
+ applicableDepartmentList: undefined,
|
|
|
+ contraindicationLabel: undefined,
|
|
|
+ shelfLifeReminder: undefined,
|
|
|
+ shelfLife: undefined,
|
|
|
+ purchasePrice: undefined,
|
|
|
+ purchaseUnit: '2',
|
|
|
+ defaultUsage: '2',
|
|
|
+ packageUnit: '2',
|
|
|
+ productSpec: undefined,
|
|
|
+ productSpecValue: undefined,
|
|
|
+ productSpecUnit: '1',
|
|
|
+ packagePrice: undefined,
|
|
|
+ minUnit: '3',
|
|
|
+ minSpec: undefined,
|
|
|
+ netContent: undefined,
|
|
|
+ configSalePrice: undefined,
|
|
|
+ configLossRate: undefined,
|
|
|
+ calorie: undefined,
|
|
|
+ carbohydrate: undefined,
|
|
|
+ heatEnergy: undefined,
|
|
|
+ protein: undefined,
|
|
|
+ fat: undefined,
|
|
|
+ moisture: undefined,
|
|
|
+ ca: undefined,
|
|
|
+ p: undefined,
|
|
|
+ k: undefined,
|
|
|
+ na: undefined,
|
|
|
+ mg: undefined,
|
|
|
+ cl: undefined,
|
|
|
+ fe: undefined,
|
|
|
+ zn: undefined,
|
|
|
+ se: undefined,
|
|
|
+ cu: undefined,
|
|
|
+ mn: undefined,
|
|
|
+ i: undefined,
|
|
|
+ f: undefined,
|
|
|
+ cr: undefined,
|
|
|
+ mo: undefined,
|
|
|
+ isoleucine: undefined,
|
|
|
+ tryptophan: undefined,
|
|
|
+ sulfurAminoAcid: undefined,
|
|
|
+ histidine: undefined,
|
|
|
+ aromaticAminoAcid: undefined,
|
|
|
+ glutamicAcid: undefined,
|
|
|
+ threonine: undefined,
|
|
|
+ serine: undefined,
|
|
|
+ arginine: undefined,
|
|
|
+ lysine: undefined,
|
|
|
+ asparticAcid: undefined,
|
|
|
+ cysteine: undefined,
|
|
|
+ proline: undefined,
|
|
|
+ tyrosine: undefined,
|
|
|
+ leucine: undefined,
|
|
|
+ valine: undefined,
|
|
|
+ methionine: undefined,
|
|
|
+ alanine: undefined,
|
|
|
+ phenylalanine: undefined,
|
|
|
+ glycine: undefined,
|
|
|
+ fattyAcid: undefined,
|
|
|
+ saturatedFattyAcid: undefined,
|
|
|
+ monounsaturatedFattyAcid: undefined,
|
|
|
+ polyunsaturatedFattyAcid: undefined,
|
|
|
+ vitaminA: undefined,
|
|
|
+ vitaminACarotene: undefined,
|
|
|
+ vitaminAAlcohol: undefined,
|
|
|
+ vitaminD: undefined,
|
|
|
+ vitaminE: undefined,
|
|
|
+ vitaminETocopherol: undefined,
|
|
|
+ vitaminK: undefined,
|
|
|
+ vitaminBOne: undefined,
|
|
|
+ vitaminBTwo: undefined,
|
|
|
+ vitaminBSix: undefined,
|
|
|
+ vitaminBTwelve: undefined,
|
|
|
+ niacin: undefined,
|
|
|
+ vitaminC: undefined,
|
|
|
+ folicAcid: undefined,
|
|
|
+ choline: undefined,
|
|
|
+ biotin: undefined,
|
|
|
+ pantothenicAcid: undefined,
|
|
|
+ cholesterol: undefined,
|
|
|
+ bloodGlucoseIndex: undefined,
|
|
|
+ insolubleDietaryFiber: undefined,
|
|
|
+ dietaryFiber: undefined,
|
|
|
+ ash: undefined,
|
|
|
+ solubleDietaryFiber: undefined,
|
|
|
+ applicableCrowd: undefined,
|
|
|
+ unsuitableCrowd: undefined,
|
|
|
+ osmoticPressure: undefined,
|
|
|
+ rawMaterial: undefined,
|
|
|
+ indicationsContraindications: undefined,
|
|
|
+ usageAndDosage: undefined,
|
|
|
+ productFeatures: undefined,
|
|
|
+ storageConditions: undefined,
|
|
|
+ warningInstructions: undefined,
|
|
|
+ productAttachments: undefined,
|
|
|
+ productAttachmentsList: [],
|
|
|
+ status: undefined,
|
|
|
+ putFlag: undefined,
|
|
|
+ outboundNumber: undefined,
|
|
|
+ productLabel: undefined,
|
|
|
+ productLabelList: [],
|
|
|
+ contraindicationLabelList: [],
|
|
|
+};
|
|
|
+
|
|
|
+const data = reactive < PageData < NutritionForm,
|
|
|
+ NutritionQuery >> ({
|
|
|
+ form: { ...initFormData },
|
|
|
+ queryParams: {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ productName: undefined,
|
|
|
+ productCategory: undefined,
|
|
|
+ productCategoryList: [],
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ productName: [
|
|
|
+ { required: true, message: "产品名称不能为空", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ hospitalSystemCode: [
|
|
|
+ { required: true, message: "院方系统编码不能为空", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ productCode: [
|
|
|
+ { required: true, message: "商品编码不能为空", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ productCategory: [
|
|
|
+ { required: true, message: "产品所属分类不能为空", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ productQualification: [
|
|
|
+ { required: true, message: "商品资质不能为空", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ shelfLifeReminder: [
|
|
|
+ { required: true, message: "保质期临期提醒不能为空", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ shelfLife: [
|
|
|
+ { required: true, message: "保质期不能为空", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ purchasePrice: [
|
|
|
+ { required: true, message: "入货价格不能为空", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ purchaseUnit: [
|
|
|
+ { required: true, message: "入货单位不能为空", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ productSpec: [
|
|
|
+ { required: true, message: "商品规格不能为空", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ configSalePrice: [
|
|
|
+ { required: true, message: "配置销售价格不能为空", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ packagePrice: [
|
|
|
+ { required: true, message: "预包装价格不能为空", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
- const treeData = ref([]); // 定义 treeData
|
|
|
- const deptList = ref([]); // 定义 科室list
|
|
|
+const { queryParams, form, rules } = toRefs(data);
|
|
|
|
|
|
- const queryFormRef = ref < FormInstance > ();
|
|
|
- const nutritionFormRef = ref < FormInstance > ();
|
|
|
+const categoryOptions = ref([]);
|
|
|
|
|
|
- const dialog = reactive < DialogOption > ({
|
|
|
- visible: false,
|
|
|
- title: ''
|
|
|
+function buildCategoryTree(flatList) {
|
|
|
+ const idMap = {};
|
|
|
+ const tree = [];
|
|
|
+ flatList.forEach(item => {
|
|
|
+ idMap[item.categoryId] = {
|
|
|
+ label: item.categoryName,
|
|
|
+ value: item.categoryId,
|
|
|
+ children: []
|
|
|
+ };
|
|
|
});
|
|
|
- const dialogFile = reactive < DialogOption > ({
|
|
|
- visible: false,
|
|
|
- title: '请上传'
|
|
|
+ flatList.forEach(item => {
|
|
|
+ if (item.parentId && item.parentId !== 0 && idMap[item.parentId]) {
|
|
|
+ idMap[item.parentId].children.push(idMap[item.categoryId]);
|
|
|
+ } else if (item.parentId === 0) {
|
|
|
+ tree.push(idMap[item.categoryId]);
|
|
|
+ }
|
|
|
});
|
|
|
-
|
|
|
- const initFormData: NutritionForm = {
|
|
|
- id: undefined,
|
|
|
- ids: undefined,
|
|
|
- productName: undefined,
|
|
|
- hospitalSystemCode: undefined,
|
|
|
- productCode: undefined,
|
|
|
- productCategory: undefined,
|
|
|
- productCategoryList: undefined,
|
|
|
- manufacturer: undefined,
|
|
|
- brand: undefined,
|
|
|
- licenseExpiryReminder: undefined,
|
|
|
- productLicenseExpiry: undefined,
|
|
|
- productQualification: undefined,
|
|
|
- approvalNumber: undefined,
|
|
|
- taste: undefined,
|
|
|
- dosageForm: undefined,
|
|
|
- supplier: undefined,
|
|
|
- applicableDepartment: undefined,
|
|
|
- applicableDepartmentList: undefined,
|
|
|
- contraindicationLabel: undefined,
|
|
|
- shelfLifeReminder: undefined,
|
|
|
- shelfLife: undefined,
|
|
|
- purchasePrice: undefined,
|
|
|
- purchaseUnit: '2',
|
|
|
- defaultUsage: '2',
|
|
|
- packageUnit: '2',
|
|
|
- productSpec: undefined,
|
|
|
- productSpecValue: undefined,
|
|
|
- productSpecUnit: '1',
|
|
|
- packagePrice: undefined,
|
|
|
- minUnit: '3',
|
|
|
- minSpec: undefined,
|
|
|
- netContent: undefined,
|
|
|
- configSalePrice: undefined,
|
|
|
- configLossRate: undefined,
|
|
|
- calorie: undefined,
|
|
|
- carbohydrate: undefined,
|
|
|
- heatEnergy: undefined,
|
|
|
- protein: undefined,
|
|
|
- fat: undefined,
|
|
|
- moisture: undefined,
|
|
|
- ca: undefined,
|
|
|
- p: undefined,
|
|
|
- k: undefined,
|
|
|
- na: undefined,
|
|
|
- mg: undefined,
|
|
|
- cl: undefined,
|
|
|
- fe: undefined,
|
|
|
- zn: undefined,
|
|
|
- se: undefined,
|
|
|
- cu: undefined,
|
|
|
- mn: undefined,
|
|
|
- i: undefined,
|
|
|
- f: undefined,
|
|
|
- cr: undefined,
|
|
|
- mo: undefined,
|
|
|
- isoleucine: undefined,
|
|
|
- tryptophan: undefined,
|
|
|
- sulfurAminoAcid: undefined,
|
|
|
- histidine: undefined,
|
|
|
- aromaticAminoAcid: undefined,
|
|
|
- glutamicAcid: undefined,
|
|
|
- threonine: undefined,
|
|
|
- serine: undefined,
|
|
|
- arginine: undefined,
|
|
|
- lysine: undefined,
|
|
|
- asparticAcid: undefined,
|
|
|
- cysteine: undefined,
|
|
|
- proline: undefined,
|
|
|
- tyrosine: undefined,
|
|
|
- leucine: undefined,
|
|
|
- valine: undefined,
|
|
|
- methionine: undefined,
|
|
|
- alanine: undefined,
|
|
|
- phenylalanine: undefined,
|
|
|
- glycine: undefined,
|
|
|
- fattyAcid: undefined,
|
|
|
- saturatedFattyAcid: undefined,
|
|
|
- monounsaturatedFattyAcid: undefined,
|
|
|
- polyunsaturatedFattyAcid: undefined,
|
|
|
- vitaminA: undefined,
|
|
|
- vitaminACarotene: undefined,
|
|
|
- vitaminAAlcohol: undefined,
|
|
|
- vitaminD: undefined,
|
|
|
- vitaminE: undefined,
|
|
|
- vitaminETocopherol: undefined,
|
|
|
- vitaminK: undefined,
|
|
|
- vitaminBOne: undefined,
|
|
|
- vitaminBTwo: undefined,
|
|
|
- vitaminBSix: undefined,
|
|
|
- vitaminBTwelve: undefined,
|
|
|
- niacin: undefined,
|
|
|
- vitaminC: undefined,
|
|
|
- folicAcid: undefined,
|
|
|
- choline: undefined,
|
|
|
- biotin: undefined,
|
|
|
- pantothenicAcid: undefined,
|
|
|
- cholesterol: undefined,
|
|
|
- bloodGlucoseIndex: undefined,
|
|
|
- insolubleDietaryFiber: undefined,
|
|
|
- dietaryFiber: undefined,
|
|
|
- ash: undefined,
|
|
|
- solubleDietaryFiber: undefined,
|
|
|
- applicableCrowd: undefined,
|
|
|
- unsuitableCrowd: undefined,
|
|
|
- osmoticPressure: undefined,
|
|
|
- rawMaterial: undefined,
|
|
|
- indicationsContraindications: undefined,
|
|
|
- usageAndDosage: undefined,
|
|
|
- productFeatures: undefined,
|
|
|
- storageConditions: undefined,
|
|
|
- warningInstructions: undefined,
|
|
|
- productAttachments: undefined,
|
|
|
- productAttachmentsList: [],
|
|
|
- status: undefined,
|
|
|
- putFlag: undefined,
|
|
|
- outboundNumber: undefined,
|
|
|
- productLabel: undefined,
|
|
|
- productLabelList: [],
|
|
|
- contraindicationLabelList: [],
|
|
|
- };
|
|
|
-
|
|
|
- const data = reactive < PageData < NutritionForm,
|
|
|
- NutritionQuery >> ({
|
|
|
- form: { ...initFormData },
|
|
|
- queryParams: {
|
|
|
- pageNum: 1,
|
|
|
- pageSize: 10,
|
|
|
- productName: undefined,
|
|
|
- productCategory: undefined,
|
|
|
- productCategoryList: [],
|
|
|
- },
|
|
|
- rules: {
|
|
|
- productName: [
|
|
|
- { required: true, message: "产品名称不能为空", trigger: "blur" }
|
|
|
- ],
|
|
|
- hospitalSystemCode: [
|
|
|
- { required: true, message: "院方系统编码不能为空", trigger: "blur" }
|
|
|
- ],
|
|
|
- productCode: [
|
|
|
- { required: true, message: "商品编码不能为空", trigger: "blur" }
|
|
|
- ],
|
|
|
- productCategory: [
|
|
|
- { required: true, message: "产品所属分类不能为空", trigger: "blur" }
|
|
|
- ],
|
|
|
- productQualification: [
|
|
|
- { required: true, message: "商品资质不能为空", trigger: "blur" }
|
|
|
- ],
|
|
|
- shelfLifeReminder: [
|
|
|
- { required: true, message: "保质期临期提醒不能为空", trigger: "blur" }
|
|
|
- ],
|
|
|
- shelfLife: [
|
|
|
- { required: true, message: "保质期不能为空", trigger: "blur" }
|
|
|
- ],
|
|
|
- purchasePrice: [
|
|
|
- { required: true, message: "入货价格不能为空", trigger: "blur" }
|
|
|
- ],
|
|
|
- purchaseUnit: [
|
|
|
- { required: true, message: "入货单位不能为空", trigger: "blur" }
|
|
|
- ],
|
|
|
- productSpec: [
|
|
|
- { required: true, message: "商品规格不能为空", trigger: "blur" }
|
|
|
- ],
|
|
|
- configSalePrice: [
|
|
|
- { required: true, message: "配置销售价格不能为空", trigger: "blur" }
|
|
|
- ],
|
|
|
- packagePrice: [
|
|
|
- { required: true, message: "预包装价格不能为空", trigger: "blur" }
|
|
|
- ],
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- const { queryParams, form, rules } = toRefs(data);
|
|
|
-
|
|
|
- const categoryOptions = ref([]);
|
|
|
-
|
|
|
- function buildCategoryTree(flatList) {
|
|
|
- const idMap = {};
|
|
|
- const tree = [];
|
|
|
- flatList.forEach(item => {
|
|
|
- idMap[item.categoryId] = {
|
|
|
- label: item.categoryName,
|
|
|
- value: item.categoryId,
|
|
|
- children: []
|
|
|
- };
|
|
|
- });
|
|
|
- flatList.forEach(item => {
|
|
|
- if (item.parentId && item.parentId !== 0 && idMap[item.parentId]) {
|
|
|
- idMap[item.parentId].children.push(idMap[item.categoryId]);
|
|
|
- } else if (item.parentId === 0) {
|
|
|
- tree.push(idMap[item.categoryId]);
|
|
|
- }
|
|
|
- });
|
|
|
- // 去除没有children的children字段
|
|
|
- function clean(node) {
|
|
|
- if (node.children && node.children.length === 0) {
|
|
|
- delete node.children;
|
|
|
- } else if (node.children) {
|
|
|
- node.children.forEach(clean);
|
|
|
- }
|
|
|
+ // 去除没有children的children字段
|
|
|
+ function clean(node) {
|
|
|
+ if (node.children && node.children.length === 0) {
|
|
|
+ delete node.children;
|
|
|
+ } else if (node.children) {
|
|
|
+ node.children.forEach(clean);
|
|
|
}
|
|
|
- tree.forEach(clean);
|
|
|
- return tree;
|
|
|
- }
|
|
|
-
|
|
|
- /** 查询营养产品信息列表 */
|
|
|
- const getList = async () => {
|
|
|
-
|
|
|
- loading.value = true;
|
|
|
- const res = await listNutrition(queryParams.value);
|
|
|
- nutritionList.value = res.rows;
|
|
|
- total.value = res.total;
|
|
|
- loading.value = false;
|
|
|
}
|
|
|
-
|
|
|
- const getDeptList = async () => {
|
|
|
- loading.value = true;
|
|
|
- try {
|
|
|
- const res = await listDept({});
|
|
|
- if (!res.data) {
|
|
|
- console.warn("部门数据为空");
|
|
|
- deptList.value = [];
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- // 处理树形数据
|
|
|
- const processedData = proxy ?.handleTree(res.data, 'deptId');
|
|
|
- if (!processedData) {
|
|
|
- console.warn("树形数据处理失败");
|
|
|
- deptList.value = [];
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- deptList.value = processedData;
|
|
|
-
|
|
|
- } catch (error) {
|
|
|
- console.error('获取部门列表失败:', error);
|
|
|
+ tree.forEach(clean);
|
|
|
+ return tree;
|
|
|
+}
|
|
|
+
|
|
|
+/** 查询营养产品信息列表 */
|
|
|
+const getList = async () => {
|
|
|
+
|
|
|
+ loading.value = true;
|
|
|
+ const res = await listNutrition(queryParams.value);
|
|
|
+ nutritionList.value = res.rows;
|
|
|
+ total.value = res.total;
|
|
|
+ loading.value = false;
|
|
|
+}
|
|
|
+
|
|
|
+const getDeptList = async () => {
|
|
|
+ loading.value = true;
|
|
|
+ try {
|
|
|
+ const res = await listDept({});
|
|
|
+ if (!res.data) {
|
|
|
+ console.warn("部门数据为空");
|
|
|
deptList.value = [];
|
|
|
- } finally {
|
|
|
- loading.value = false;
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- /** 导出按钮操作 */
|
|
|
- const downLoadTemplate = () => {
|
|
|
- proxy ?.getDownload('warehouse/nutrition/downLoadTemplate', {}, `营养产品模版.xlsx`)
|
|
|
- }
|
|
|
-
|
|
|
- /** 导入按钮操作 */
|
|
|
- const handleImport = () => {
|
|
|
- dialogFile.visible = true;
|
|
|
- fileList.value = [];
|
|
|
- }
|
|
|
-
|
|
|
- // 上传失败
|
|
|
- const handleUploadError = () => {
|
|
|
- proxy ?.$modal.msgError('上传Excel失败');
|
|
|
- proxy ?.$modal.closeLoading();
|
|
|
- };
|
|
|
-
|
|
|
- // 上传成功回调
|
|
|
- const handleUploadSuccess = (res: any, file: UploadFile) => {
|
|
|
- if (res.code === 200) {
|
|
|
- dialogFile.visible = false;
|
|
|
- fileList.value = [];
|
|
|
- proxy ?.$modal.closeLoading();
|
|
|
- } else {
|
|
|
- proxy ?.$modal.msgError(res.msg);
|
|
|
- proxy ?.$modal.closeLoading();
|
|
|
- }
|
|
|
- fileList.value = [];
|
|
|
- };
|
|
|
-
|
|
|
-
|
|
|
- /** 上传前loading加载 */
|
|
|
- const handleBeforeUpload = (file: any) => {
|
|
|
- const isLt = file.size / 1024 / 1024 < 10;
|
|
|
- if (!isLt) {
|
|
|
- proxy ?.$modal.msgError(`上传头像图片大小不能超过10MB!`);
|
|
|
- return false;
|
|
|
+ return;
|
|
|
}
|
|
|
- proxy ?.$modal.loading('正在上传文件,请稍候...');
|
|
|
- return true;
|
|
|
- };
|
|
|
|
|
|
- function openBatchSetDialog() {
|
|
|
- if (!ids.value.length) {
|
|
|
- proxy ?.$modal.msgWarning('请先选择要批量设置的产品');
|
|
|
+ // 处理树形数据
|
|
|
+ const processedData = proxy ?.handleTree(res.data, 'deptId');
|
|
|
+ if (!processedData) {
|
|
|
+ console.warn("树形数据处理失败");
|
|
|
+ deptList.value = [];
|
|
|
return;
|
|
|
}
|
|
|
- batchSetForm.shelfLifeReminder = '';
|
|
|
- batchSetForm.licenseExpiryReminder = '';
|
|
|
- batchSetDialogVisible.value = true;
|
|
|
- }
|
|
|
|
|
|
- async function handleBatchSetSubmit() {
|
|
|
- const params = {
|
|
|
- ids: ids.value,
|
|
|
- shelfLifeReminder: batchSetForm.shelfLifeReminder,
|
|
|
- licenseExpiryReminder: batchSetForm.licenseExpiryReminder
|
|
|
- };
|
|
|
+ deptList.value = processedData;
|
|
|
|
|
|
- try {
|
|
|
- await batchUpdateNutrition(params);
|
|
|
- proxy ?.$modal.msgSuccess('批量设置成功');
|
|
|
- batchSetDialogVisible.value = false;
|
|
|
- getList();
|
|
|
- } catch (e) {
|
|
|
- proxy ?.$modal.msgError('批量设置失败');
|
|
|
- }
|
|
|
- }
|
|
|
- /** 取消按钮 */
|
|
|
- const cancel = () => {
|
|
|
- reset();
|
|
|
- dialog.visible = false;
|
|
|
+ } catch (error) {
|
|
|
+ console.error('获取部门列表失败:', error);
|
|
|
+ deptList.value = [];
|
|
|
+ } finally {
|
|
|
+ loading.value = false;
|
|
|
}
|
|
|
-
|
|
|
- /** 表单重置 */
|
|
|
- const reset = () => {
|
|
|
- form.value = { ...initFormData };
|
|
|
- nutritionFormRef.value ?.resetFields();
|
|
|
+};
|
|
|
+
|
|
|
+/** 下载模板按钮操作 */
|
|
|
+const downLoadTemplate = () => {
|
|
|
+ proxy ?.getDownload('warehouse/nutrition/downLoadTemplate', {}, `营养产品模版.xlsx`)
|
|
|
+}
|
|
|
+
|
|
|
+/** 导入按钮操作 */
|
|
|
+const handleImport = () => {
|
|
|
+ dialogFile.visible = true;
|
|
|
+ fileList.value = [];
|
|
|
+}
|
|
|
+
|
|
|
+// 上传失败
|
|
|
+const handleUploadError = () => {
|
|
|
+ proxy ?.$modal.msgError('上传Excel失败');
|
|
|
+ proxy ?.$modal.closeLoading();
|
|
|
+};
|
|
|
+
|
|
|
+// 上传成功回调
|
|
|
+const handleUploadSuccess = (res: any, file: UploadFile) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ dialogFile.visible = false;
|
|
|
fileList.value = [];
|
|
|
+ proxy ?.$modal.closeLoading();
|
|
|
+ } else {
|
|
|
+ proxy ?.$modal.msgError(res.msg);
|
|
|
+ proxy ?.$modal.closeLoading();
|
|
|
}
|
|
|
+ fileList.value = [];
|
|
|
+};
|
|
|
|
|
|
- /** 搜索按钮操作 */
|
|
|
- const handleQuery = () => {
|
|
|
- // 取最后一级分类ID传给后端
|
|
|
- if (queryParams.value.productCategoryList && queryParams.value.productCategoryList.length) {
|
|
|
- queryParams.value.productCategory = queryParams.value.productCategoryList.slice(-1)[0];
|
|
|
- } else {
|
|
|
- queryParams.value.productCategory = undefined;
|
|
|
- }
|
|
|
- queryParams.value.pageNum = 1;
|
|
|
- getList();
|
|
|
- }
|
|
|
|
|
|
- /** 重置按钮操作 */
|
|
|
- const resetQuery = () => {
|
|
|
- queryFormRef.value ?.resetFields();
|
|
|
- queryParams.value.productCategoryList = [];
|
|
|
- queryParams.value.productCategory = undefined;
|
|
|
- queryParams.value.productName = undefined;
|
|
|
- handleQuery();
|
|
|
+/** 上传前loading加载 */
|
|
|
+const handleBeforeUpload = (file: any) => {
|
|
|
+ const isLt = file.size / 1024 / 1024 < 10;
|
|
|
+ if (!isLt) {
|
|
|
+ proxy ?.$modal.msgError(`上传头像图片大小不能超过10MB!`);
|
|
|
+ return false;
|
|
|
}
|
|
|
-
|
|
|
- /** 多选框选中数据 */
|
|
|
- const handleSelectionChange = (selection: NutritionVO[]) => {
|
|
|
- ids.value = selection.map(item => item.id);
|
|
|
- single.value = selection.length != 1;
|
|
|
- multiple.value = !selection.length;
|
|
|
+ proxy ?.$modal.loading('正在上传文件,请稍候...');
|
|
|
+ return true;
|
|
|
+};
|
|
|
+
|
|
|
+function openBatchSetDialog() {
|
|
|
+ if (!ids.value.length) {
|
|
|
+ proxy ?.$modal.msgWarning('请先选择要批量设置的产品');
|
|
|
+ return;
|
|
|
}
|
|
|
+ batchSetForm.shelfLifeReminder = '';
|
|
|
+ batchSetForm.licenseExpiryReminder = '';
|
|
|
+ batchSetDialogVisible.value = true;
|
|
|
+}
|
|
|
+
|
|
|
+async function handleBatchSetSubmit() {
|
|
|
+ const params = {
|
|
|
+ ids: ids.value,
|
|
|
+ shelfLifeReminder: batchSetForm.shelfLifeReminder,
|
|
|
+ licenseExpiryReminder: batchSetForm.licenseExpiryReminder
|
|
|
+ };
|
|
|
|
|
|
- /** 新增按钮操作 */
|
|
|
- const handleAdd = () => {
|
|
|
- reset();
|
|
|
- dialog.visible = true;
|
|
|
- dialog.title = "添加营养产品信息";
|
|
|
+ try {
|
|
|
+ await batchUpdateNutrition(params);
|
|
|
+ proxy ?.$modal.msgSuccess('批量设置成功');
|
|
|
+ batchSetDialogVisible.value = false;
|
|
|
+ getList();
|
|
|
+ } catch (e) {
|
|
|
+ proxy ?.$modal.msgError('批量设置失败');
|
|
|
}
|
|
|
-
|
|
|
- /** 修改按钮操作 */
|
|
|
- const handleUpdate = async (row ? : NutritionVO) => {
|
|
|
- reset();
|
|
|
- const _id = row ?.id || ids.value[0]
|
|
|
- const res = await getNutrition(_id);
|
|
|
- Object.assign(form.value, res.data);
|
|
|
- dialog.visible = true;
|
|
|
- dialog.title = "修改营养产品信息";
|
|
|
+}
|
|
|
+/** 取消按钮 */
|
|
|
+const cancel = () => {
|
|
|
+ reset();
|
|
|
+ dialog.visible = false;
|
|
|
+}
|
|
|
+
|
|
|
+/** 表单重置 */
|
|
|
+const reset = () => {
|
|
|
+ form.value = { ...initFormData };
|
|
|
+ nutritionFormRef.value ?.resetFields();
|
|
|
+ fileList.value = [];
|
|
|
+}
|
|
|
+
|
|
|
+/** 搜索按钮操作 */
|
|
|
+const handleQuery = () => {
|
|
|
+ // 取最后一级分类ID传给后端
|
|
|
+ if (queryParams.value.productCategoryList && queryParams.value.productCategoryList.length) {
|
|
|
+ queryParams.value.productCategory = queryParams.value.productCategoryList.slice(-1)[0];
|
|
|
+ } else {
|
|
|
+ queryParams.value.productCategory = undefined;
|
|
|
}
|
|
|
-
|
|
|
- /** 提交按钮 */
|
|
|
- const submitForm = () => {
|
|
|
- nutritionFormRef.value ?.validate(async (valid: boolean) => {
|
|
|
- if (valid) {
|
|
|
- buttonLoading.value = true;
|
|
|
- // form.value.productSpec = form.value.productSpec && form.value.productSpecUnit ? `${form.value.productSpec}${form.value.productSpecUnit}` : '';
|
|
|
- if (form.value.id) {
|
|
|
- await updateNutrition(form.value).finally(() => buttonLoading.value = false);
|
|
|
- } else {
|
|
|
- await addNutrition(form.value).finally(() => buttonLoading.value = false);
|
|
|
- }
|
|
|
- proxy ?.$modal.msgSuccess("操作成功");
|
|
|
- dialog.visible = false;
|
|
|
- await getList();
|
|
|
+ queryParams.value.pageNum = 1;
|
|
|
+ getList();
|
|
|
+}
|
|
|
+
|
|
|
+/** 重置按钮操作 */
|
|
|
+const resetQuery = () => {
|
|
|
+ queryFormRef.value ?.resetFields();
|
|
|
+ queryParams.value.productCategoryList = [];
|
|
|
+ queryParams.value.productCategory = undefined;
|
|
|
+ queryParams.value.productName = undefined;
|
|
|
+ handleQuery();
|
|
|
+}
|
|
|
+
|
|
|
+/** 多选框选中数据 */
|
|
|
+const handleSelectionChange = (selection: NutritionVO[]) => {
|
|
|
+ ids.value = selection.map(item => item.id);
|
|
|
+ single.value = selection.length != 1;
|
|
|
+ multiple.value = !selection.length;
|
|
|
+}
|
|
|
+
|
|
|
+/** 新增按钮操作 */
|
|
|
+const handleAdd = () => {
|
|
|
+ reset();
|
|
|
+ dialog.visible = true;
|
|
|
+ dialog.title = "添加营养产品信息";
|
|
|
+}
|
|
|
+
|
|
|
+/** 修改按钮操作 */
|
|
|
+const handleUpdate = async (row ? : NutritionVO) => {
|
|
|
+ reset();
|
|
|
+ const _id = row ?.id || ids.value[0]
|
|
|
+ const res = await getNutrition(_id);
|
|
|
+ Object.assign(form.value, res.data);
|
|
|
+ dialog.visible = true;
|
|
|
+ dialog.title = "修改营养产品信息";
|
|
|
+}
|
|
|
+
|
|
|
+/** 提交按钮 */
|
|
|
+const submitForm = () => {
|
|
|
+ nutritionFormRef.value ?.validate(async (valid: boolean) => {
|
|
|
+ if (valid) {
|
|
|
+ buttonLoading.value = true;
|
|
|
+ // form.value.productSpec = form.value.productSpec && form.value.productSpecUnit ? `${form.value.productSpec}${form.value.productSpecUnit}` : '';
|
|
|
+ if (form.value.id) {
|
|
|
+ await updateNutrition(form.value).finally(() => buttonLoading.value = false);
|
|
|
+ } else {
|
|
|
+ await addNutrition(form.value).finally(() => buttonLoading.value = false);
|
|
|
}
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- /** 保存并上架按钮操作 */
|
|
|
- const submitFormAndPutaway = () => {
|
|
|
- nutritionFormRef.value ?.validate(async (valid: boolean) => {
|
|
|
- if (valid) {
|
|
|
- buttonLoading.value = true;
|
|
|
- form.value.putFlag = '1';
|
|
|
- // form.value.productSpec = form.value.productSpec && form.value.productSpecUnit ? `${form.value.productSpec}${form.value.productSpecUnit}` : '';
|
|
|
- if (form.value.id) {
|
|
|
- await updateNutrition(form.value).finally(() => buttonLoading.value = false);
|
|
|
- } else {
|
|
|
- await addNutrition(form.value).finally(() => buttonLoading.value = false);
|
|
|
- }
|
|
|
- proxy ?.$modal.msgSuccess("操作成功");
|
|
|
- dialog.visible = false;
|
|
|
- await getList();
|
|
|
+ proxy ?.$modal.msgSuccess("操作成功");
|
|
|
+ dialog.visible = false;
|
|
|
+ await getList();
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+/** 保存并上架按钮操作 */
|
|
|
+const submitFormAndPutaway = () => {
|
|
|
+ nutritionFormRef.value ?.validate(async (valid: boolean) => {
|
|
|
+ if (valid) {
|
|
|
+ buttonLoading.value = true;
|
|
|
+ form.value.putFlag = '1';
|
|
|
+ // form.value.productSpec = form.value.productSpec && form.value.productSpecUnit ? `${form.value.productSpec}${form.value.productSpecUnit}` : '';
|
|
|
+ if (form.value.id) {
|
|
|
+ await updateNutrition(form.value).finally(() => buttonLoading.value = false);
|
|
|
+ } else {
|
|
|
+ await addNutrition(form.value).finally(() => buttonLoading.value = false);
|
|
|
}
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- /** 删除按钮操作 */
|
|
|
- const handleDelete = async (row ? : NutritionVO) => {
|
|
|
- const _ids = row ?.id || ids.value;
|
|
|
- await proxy ?.$modal.confirm('是否确认删除营养产品信息编号为"' + _ids + '"的数据项?');
|
|
|
- await delNutrition(_ids);
|
|
|
- proxy ?.$modal.msgSuccess("删除成功");
|
|
|
- await getList();
|
|
|
- }
|
|
|
-
|
|
|
- /** 导出按钮操作 */
|
|
|
- const handleExport = () => {
|
|
|
- proxy ?.download('warehouse/nutrition/export', {
|
|
|
- ...queryParams.value
|
|
|
- }, `nutrition_${new Date().getTime()}.xlsx`)
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- const onSpecUnitChange = () => {
|
|
|
- if (!form.value.productSpecUnit) form.value.productSpecUnit = 'g';
|
|
|
- }
|
|
|
-
|
|
|
- // 详情弹窗逻辑
|
|
|
- const handleDetail = async (row: NutritionVO) => {
|
|
|
- reset();
|
|
|
- const res = await getNutrition(row.id);
|
|
|
- Object.assign(form.value, res.data);
|
|
|
- detailDialogVisible.value = true;
|
|
|
- activeTab.value = 'basic';
|
|
|
- };
|
|
|
-
|
|
|
- // 上下架切换
|
|
|
- const handlePutFlag = async (row: NutritionVO, flag: string) => {
|
|
|
- await proxy ?.$modal.confirm(`是否确认${flag === '1' ? '上架' : '下架'}该产品?`);
|
|
|
- const updateData = { ...row, putFlag: flag };
|
|
|
- await updateNutrition(updateData);
|
|
|
- proxy ?.$modal.msgSuccess(`${flag === '1' ? '上架' : '下架'}成功`);
|
|
|
- await getList();
|
|
|
- };
|
|
|
-
|
|
|
- onMounted(async () => {
|
|
|
- getList();
|
|
|
- getDeptList(); // 初始化时加载部门数据
|
|
|
- const res = await listCategory();
|
|
|
- categoryOptions.value = buildCategoryTree(res.rows || []);
|
|
|
- if (!form.value.productSpecUnit) form.value.productSpecUnit = 'g';
|
|
|
+ proxy ?.$modal.msgSuccess("操作成功");
|
|
|
+ dialog.visible = false;
|
|
|
+ await getList();
|
|
|
+ }
|
|
|
});
|
|
|
-
|
|
|
- const getCategoryName = (categoryIds) => {
|
|
|
- if (!categoryIds) return '--';
|
|
|
-
|
|
|
- // 处理多个分类ID的情况
|
|
|
- const ids = categoryIds.toString().split(',');
|
|
|
- const categoryNames = ids.map(id => {
|
|
|
- const findCategory = (categories, targetId) => {
|
|
|
- for (const category of categories) {
|
|
|
- if (category.value.toString() === targetId.toString()) {
|
|
|
- return category.label;
|
|
|
- }
|
|
|
- if (category.children) {
|
|
|
- const found = findCategory(category.children, targetId);
|
|
|
- if (found) return found;
|
|
|
- }
|
|
|
+}
|
|
|
+
|
|
|
+/** 删除按钮操作 */
|
|
|
+const handleDelete = async (row ? : NutritionVO) => {
|
|
|
+ const _ids = row ?.id || ids.value;
|
|
|
+ await proxy ?.$modal.confirm('是否确认删除营养产品信息编号为"' + _ids + '"的数据项?');
|
|
|
+ await delNutrition(_ids);
|
|
|
+ proxy ?.$modal.msgSuccess("删除成功");
|
|
|
+ await getList();
|
|
|
+}
|
|
|
+
|
|
|
+/** 导出按钮操作 */
|
|
|
+const handleExport = () => {
|
|
|
+ proxy ?.download('warehouse/nutrition/export', {
|
|
|
+ ...queryParams.value
|
|
|
+ }, `nutrition_${new Date().getTime()}.xlsx`)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+const onSpecUnitChange = () => {
|
|
|
+ if (!form.value.productSpecUnit) form.value.productSpecUnit = 'g';
|
|
|
+}
|
|
|
+
|
|
|
+// 详情弹窗逻辑
|
|
|
+const handleDetail = async (row: NutritionVO) => {
|
|
|
+ reset();
|
|
|
+ const res = await getNutrition(row.id);
|
|
|
+ Object.assign(form.value, res.data);
|
|
|
+ detailDialogVisible.value = true;
|
|
|
+ activeTab.value = 'basic';
|
|
|
+};
|
|
|
+
|
|
|
+// 上下架切换
|
|
|
+const handlePutFlag = async (row: NutritionVO, flag: string) => {
|
|
|
+ await proxy ?.$modal.confirm(`是否确认${flag === '1' ? '上架' : '下架'}该产品?`);
|
|
|
+ const updateData = { ...row, putFlag: flag };
|
|
|
+ await updateNutrition(updateData);
|
|
|
+ proxy ?.$modal.msgSuccess(`${flag === '1' ? '上架' : '下架'}成功`);
|
|
|
+ await getList();
|
|
|
+};
|
|
|
+
|
|
|
+onMounted(async () => {
|
|
|
+ getList();
|
|
|
+ getDeptList(); // 初始化时加载部门数据
|
|
|
+ const res = await listCategory();
|
|
|
+ categoryOptions.value = buildCategoryTree(res.rows || []);
|
|
|
+ if (!form.value.productSpecUnit) form.value.productSpecUnit = 'g';
|
|
|
+});
|
|
|
+
|
|
|
+const getCategoryName = (categoryIds) => {
|
|
|
+ if (!categoryIds) return '--';
|
|
|
+
|
|
|
+ // 处理多个分类ID的情况
|
|
|
+ const ids = categoryIds.toString().split(',');
|
|
|
+ const categoryNames = ids.map(id => {
|
|
|
+ const findCategory = (categories, targetId) => {
|
|
|
+ for (const category of categories) {
|
|
|
+ if (category.value.toString() === targetId.toString()) {
|
|
|
+ return category.label;
|
|
|
}
|
|
|
- return null;
|
|
|
- };
|
|
|
- return findCategory(categoryOptions.value, id);
|
|
|
- }).filter(name => name !== null);
|
|
|
-
|
|
|
- return categoryNames.length > 0 ? categoryNames.join('/') : '--';
|
|
|
- };
|
|
|
-
|
|
|
- // 弹窗回填
|
|
|
- function onLabelConfirm(selectedLabels) {
|
|
|
- form.value.productLabelList = selectedLabels;
|
|
|
- }
|
|
|
-
|
|
|
- function onContraindicationLabelConfirm(selectedLabels) {
|
|
|
- form.value.contraindicationLabelList = selectedLabels;
|
|
|
- } // 字典label工具
|
|
|
- function getDictLabel(dictList, value) {
|
|
|
- if (!dictList || !Array.isArray(dictList)) return value || '--';
|
|
|
- const found = dictList.find(item => item.value === value);
|
|
|
- return found ? found.label : value || '--';
|
|
|
- }
|
|
|
+ if (category.children) {
|
|
|
+ const found = findCategory(category.children, targetId);
|
|
|
+ if (found) return found;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ };
|
|
|
+ return findCategory(categoryOptions.value, id);
|
|
|
+ }).filter(name => name !== null);
|
|
|
+
|
|
|
+ return categoryNames.length > 0 ? categoryNames.join('/') : '--';
|
|
|
+};
|
|
|
+
|
|
|
+// 弹窗回填
|
|
|
+function onLabelConfirm(selectedLabels) {
|
|
|
+ form.value.productLabelList = selectedLabels;
|
|
|
+}
|
|
|
+
|
|
|
+function onContraindicationLabelConfirm(selectedLabels) {
|
|
|
+ form.value.contraindicationLabelList = selectedLabels;
|
|
|
+} // 字典label工具
|
|
|
+function getDictLabel(dictList, value) {
|
|
|
+ if (!dictList || !Array.isArray(dictList)) return value || '--';
|
|
|
+ const found = dictList.find(item => item.value === value);
|
|
|
+ return found ? found.label : value || '--';
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|